Commit b53c04f3 authored by Alexandre Perraud's avatar Alexandre Perraud

Preferences : TV preferences reorganization

parent c82a12ae
......@@ -17,7 +17,9 @@
android:persistent="true"
android:title="@string/audio_title_alignment" />
<PreferenceCategory android:title="@string/headset_prefs_category">
<PreferenceCategory
android:title="@string/headset_prefs_category"
android:key="headset_prefs_category">
<CheckBoxPreference
android:defaultValue="true"
android:key="enable_headset_detection"
......
......@@ -58,6 +58,8 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findPreference("ui_category").setVisible(false);
}
@Override
......
/*
* *************************************************************************
* Advanced.java
* PreferencesAdvanced.java
* **************************************************************************
* Copyright © 2015 VLC authors and VideoLAN
* Author: Geoffrey Métais
......@@ -30,25 +30,21 @@ import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.preference.EditTextPreference;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceManager;
import android.text.TextUtils;
import android.widget.Toast;
import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.vlc.BuildConfig;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.helpers.AudioUtil;
import org.videolan.vlc.gui.helpers.BitmapCache;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.VLCOptions;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class Advanced extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
public class PreferencesAdvanced extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected int getXml() {
return R.xml.preferences_adv;
......@@ -67,27 +63,6 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference
findPreference("quit_app").setEnabled(false);
}
// Audio output
ListPreference aoutPref = (ListPreference) findPreference("aout");
final HWDecoderUtil.AudioOutput aout = HWDecoderUtil.getAudioOutputFromDevice();
if (aout == HWDecoderUtil.AudioOutput.AUDIOTRACK || aout == HWDecoderUtil.AudioOutput.OPENSLES) {
/* no AudioOutput choice */
findPreference("aout").setVisible(false);
} else {
int aoutEntriesId = R.array.aouts;
int aoutEntriesIdValues = R.array.aouts_values;
aoutPref.setEntries(aoutEntriesId);
aoutPref.setEntryValues(aoutEntriesIdValues);
final String value = aoutPref.getValue();
if (value == null)
aoutPref.setValue(String.valueOf(VLCOptions.AOUT_AUDIOTRACK));
else {
/* number of entries decreased, handle old values */
final int intValue = Integer.parseInt(value);
if (intValue != VLCOptions.AOUT_AUDIOTRACK && intValue != VLCOptions.AOUT_OPENSLES)
aoutPref.setValue(String.valueOf(VLCOptions.AOUT_AUDIOTRACK));
}
}
// Video output
// FIXME : This setting is disable until OpenGL is fixed
// ListPreference voutPref = (ListPreference) findPreference("vout");
......@@ -98,34 +73,6 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference
// if (voutPref.getValue() == null)
// voutPref.setValue("0" VOUT_ANDROID_SURFACE );
// Network caching
EditTextPreference networkCachingPref = (EditTextPreference) findPreference("network_caching");
networkCachingPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = sharedPrefs.edit();
try {
editor.putInt("network_caching_value", Integer.parseInt((String)newValue));
} catch(NumberFormatException e) {
editor.putInt("network_caching_value", 0);
editor.putString("network_caching", "0");
}
editor.apply();
return true;
}
});
// Set locale
EditTextPreference setLocalePref = (EditTextPreference) findPreference("set_locale");
setLocalePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Toast.makeText(VLCApplication.getAppContext(), R.string.set_locale_popup, Toast.LENGTH_SHORT).show();
return true;
}
});
}
@Override
......@@ -177,12 +124,30 @@ public class Advanced extends BasePreferenceFragment implements SharedPreference
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
switch (key){
case "aout":
case "set_locale":
UiTools.snacker(getView(), R.string.set_locale_popup);
break;
case "network_caching":
SharedPreferences.Editor editor = sharedPreferences.edit();
try {
editor.putInt("network_caching_value", Integer.parseInt(sharedPreferences.getString(key,"0")));
} catch(NumberFormatException e) {
editor.putInt("network_caching_value", 0);
EditTextPreference networkCachingPref = (EditTextPreference) findPreference(key);
networkCachingPref.setText("");
UiTools.snacker(getView(), R.string.network_caching_popup);
}
editor.apply();
// No break because need VLCInstance.restart();
case "vout":
case "chroma_format":
case "deblocking":
case "enable_frame_skip":
case "enable_time_stretching_audio":
VLCInstance.restart();
if (getActivity() != null )
((PreferencesActivity)getActivity()).restartMediaPlayer();
break;
}
}
}
/*
* *************************************************************************
* PreferencesAudio.java
* **************************************************************************
* Copyright © 2016 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* ***************************************************************************
*/
package org.videolan.vlc.gui.tv.preferences;
import android.annotation.TargetApi;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.preference.TwoStatePreference;
import org.videolan.libvlc.util.HWDecoderUtil;
import org.videolan.vlc.R;
import org.videolan.vlc.util.VLCInstance;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class PreferencesAudio extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected int getXml() {
return R.xml.preferences_audio;
}
@Override
protected int getTitleId() {
return R.string.audio_prefs_category;
}
@Override
public void onStart() {
super.onStart();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findPreference("enable_headset_detection").setVisible(false);
findPreference("enable_play_on_headset_insertion").setVisible(false);
findPreference("enable_steal_remote_control").setVisible(false);
findPreference("headset_prefs_category").setVisible(false);
final HWDecoderUtil.AudioOutput aout = HWDecoderUtil.getAudioOutputFromDevice();
if (aout != HWDecoderUtil.AudioOutput.ALL) {
/* no AudioOutput choice */
findPreference("aout").setVisible(false);
}
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
switch (key){
case "aout":
VLCInstance.restart();
if (getActivity() != null )
((PreferencesActivity)getActivity()).restartMediaPlayer();
}
}
}
\ No newline at end of file
/*
* *************************************************************************
* Developer.java
* PreferencesDeveloper.java
* **************************************************************************
* Copyright © 2015 VLC authors and VideoLAN
* Author: Geoffrey Métais
......@@ -24,9 +24,11 @@
package org.videolan.vlc.gui.tv.preferences;
import android.Manifest;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.preference.Preference;
......@@ -37,7 +39,8 @@ import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.DebugLogActivity;
import org.videolan.vlc.util.VLCInstance;
public class Developer extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class PreferencesDeveloper extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected int getXml() {
return R.xml.preferences_dev;
......@@ -82,7 +85,6 @@ public class Developer extends BasePreferenceFragment implements SharedPreferenc
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
switch (key){
case "dev_hardware_decoder":
case "enable_verbose_mode":
VLCInstance.restart();
if (getActivity() != null )
......
......@@ -28,14 +28,11 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceManager;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
......@@ -55,40 +52,27 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
return R.string.preferences;
}
@Override
public void onStart() {
super.onStart();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findPreference("screen_orientation").setVisible(false);
// Screen orientation
ListPreference screenOrientationPref = (ListPreference) findPreference("screen_orientation");
screenOrientationPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString("screen_orientation_value", (String) newValue);
editor.apply();
return true;
}
});
/*** SharedPreferences Listener to apply changes ***/
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
findPreference("ui_category").setVisible(false);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if(key.equalsIgnoreCase("hardware_acceleration")
|| key.equalsIgnoreCase("subtitle_text_encoding")) {
if(key.equalsIgnoreCase("hardware_acceleration")) {
VLCInstance.restart();
if (getActivity() != null )
((PreferencesActivity)getActivity()).restartMediaPlayer();
}
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
switch (preference.getKey()){
......@@ -98,17 +82,23 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
startActivity(intent);
getActivity().setResult(PreferencesActivity.RESULT_RESTART);
return true;
case "enable_black_theme":
((PreferencesActivity) getActivity()).exitAndRescan();
return true;
case "ui_category":
loadFragment(new PreferencesUi());
// case "ui_category":
// loadFragment(new PreferencesUi());
// break;
case "video_category":
loadFragment(new PreferencesVideo());
break;
case "subtitles_category":
loadFragment(new PreferencesSubtitles());
break;
case "audio_category":
loadFragment(new PreferencesAudio());
break;
case "adv_category":
loadFragment(new Advanced());
loadFragment(new PreferencesAdvanced());
break;
case "dev_category":
loadFragment(new Developer());
loadFragment(new PreferencesDeveloper());
break;
case PLAYBACK_HISTORY:
getActivity().setResult(PreferencesActivity.RESULT_RESTART);
......
/*
* *************************************************************************
* PreferencesSubtitles.java
* **************************************************************************
* Copyright © 2016 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* ***************************************************************************
*/
package org.videolan.vlc.gui.tv.preferences;
import android.annotation.TargetApi;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.R;
import org.videolan.vlc.util.VLCInstance;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class PreferencesSubtitles extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected int getXml() {
return R.xml.preferences_subtitles;
}
@Override
protected int getTitleId() {
return R.string.subtitles_prefs_category;
}
@Override
public void onStart() {
super.onStart();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findPreference("languages_download_list").setVisible(AndroidUtil.isHoneycombOrLater());
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
switch (key){
case "subtitles_size":
case "subtitles_color":
case "subtitles_background":
case "subtitle_text_encoding":
VLCInstance.restart();
if (getActivity() != null )
((PreferencesActivity)getActivity()).restartMediaPlayer();
}
}
}
......@@ -51,14 +51,7 @@ public class PreferencesUi extends BasePreferenceFragment {
super.onCreate(savedInstanceState);
findPreference("enable_clone_mode").setVisible(false);
findPreference("force_list_portrait").setVisible(false);
findPreference("enable_headset_detection").setVisible(false);
findPreference("enable_play_on_headset_insertion").setVisible(false);
findPreference("enable_steal_remote_control").setVisible(false);
findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp());
findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp());
findPreference("tv_ui").setVisible(AndroidDevices.hasTsp());
findPreference("lockscreen_cover").setVisible(false);
findPreference("enable_black_theme").setVisible(false);
}
......@@ -73,7 +66,6 @@ public class PreferencesUi extends BasePreferenceFragment {
case "enable_steal_remote_control":
PlaybackService.Client.restartService(getActivity());
return true;
case "force_list_portrait":
case "tv_ui":
((PreferencesActivity) getActivity()).setRestart();
return true;
......
/*
* *************************************************************************
* PreferencesVideo.java
* **************************************************************************
* Copyright © 2016 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* ***************************************************************************
*/
package org.videolan.vlc.gui.tv.preferences;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import org.videolan.vlc.R;
import org.videolan.vlc.util.AndroidDevices;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class PreferencesVideo extends BasePreferenceFragment {
@Override
protected int getXml() {
return R.xml.preferences_video;
}
@Override
protected int getTitleId() {
return R.string.video_prefs_category;
}
@Override
public void onStart() {
super.onStart();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findPreference("force_list_portrait").setVisible(false);
findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp());
findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp());
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey() == null)
return false;
switch (preference.getKey()){
case "video_min_group_length":
getActivity().setResult(PreferencesActivity.RESULT_RESTART);
return true;
}
return super.onPreferenceTreeClick(preference);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment