Commit 9b8b7d77 authored by Alexandre Perraud's avatar Alexandre Perraud

Preferences : change category for some preferences

parent b53c04f3
......@@ -7,17 +7,19 @@
<!--android:summary="@string/vout_summary"-->
<!--android:title="@string/vout" />-->
<CheckBoxPreference
android:defaultValue="true"
android:key="playback_speed"
android:summary="@string/playback_speed_summary"
android:title="@string/playback_speed_title" />
<CheckBoxPreference
android:defaultValue="true"
android:key="auto_rescan"
android:summary="@string/auto_rescan_summary"
android:title="@string/auto_rescan" />
<EditTextPreference
android:defaultValue=""
android:key="network_caching"
android:maxLength="5"
android:summary="@string/network_caching_summary"
android:title="@string/network_caching" />
<Preference
android:enabled="true"
android:key="clear_media_db"
......@@ -27,18 +29,6 @@
android:key="clear_history"
android:title="@string/clear_history" />
<EditTextPreference
android:defaultValue=""
android:key="set_locale"
android:summary="@string/set_locale_detail"
android:title="@string/set_locale" />
<EditTextPreference
android:defaultValue=""
android:key="network_caching"
android:maxLength="5"
android:summary="@string/network_caching_summary"
android:title="@string/network_caching" />
<Preference
android:enabled="true"
android:key="quit_app"
......
......@@ -15,8 +15,24 @@
android:summary="@string/tv_ui_summary"
android:title="@string/tv_ui_title" />
<PreferenceCategory android:title="@string/interface_secondary_display_category_title">
<Preference android:summary="@string/interface_secondary_display_category_summary" />
<CheckBoxPreference
android:defaultValue="true"
android:key="playback_speed"
android:summary="@string/playback_speed_summary"
android:title="@string/playback_speed_title" />
<EditTextPreference
android:defaultValue=""
android:key="set_locale"
android:summary="@string/set_locale_detail"
android:title="@string/set_locale" />
<PreferenceCategory
android:title="@string/interface_secondary_display_category_title"
android:key="secondary_display_category">
<Preference
android:summary="@string/interface_secondary_display_category_summary"
android:key="secondary_display_category_summary" />
<CheckBoxPreference
android:defaultValue="false"
......
......@@ -82,10 +82,11 @@ public class PreferencesAdvanced extends BasePreferenceFragment implements Share
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
switch (preference.getKey()) {
if (preference.getKey() == null)
return false;
switch (preference.getKey()){
case "clear_history":
new AlertDialog.Builder(getActivity())
.setTitle(R.string.clear_history)
......@@ -119,9 +120,6 @@ public class PreferencesAdvanced extends BasePreferenceFragment implements Share
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
switch (key){
case "set_locale":
UiTools.snacker(getView(), R.string.set_locale_popup);
break;
case "network_caching":
SharedPreferences.Editor editor = sharedPreferences.edit();
try {
......
......@@ -58,8 +58,6 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findPreference("ui_category").setVisible(false);
}
@Override
......
......@@ -23,13 +23,15 @@
package org.videolan.vlc.gui.preferences;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.helpers.UiTools;
public class PreferencesUi extends BasePreferenceFragment {
public class PreferencesUi extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected int getXml() {
......@@ -44,6 +46,14 @@ public class PreferencesUi extends BasePreferenceFragment {
@Override
public void onStart() {
super.onStart();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onStop() {
super.onStop();
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
@Override
......@@ -66,4 +76,9 @@ public class PreferencesUi extends BasePreferenceFragment {
}
return super.onPreferenceTreeClick(preference);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals("set_locale"))
UiTools.snacker(getView(), R.string.set_locale_popup);
}
}
......@@ -90,7 +90,9 @@ public class PreferencesAdvanced extends BasePreferenceFragment implements Share
@Override
public boolean onPreferenceTreeClick(Preference preference) {
switch (preference.getKey()) {
if (preference.getKey() == null)
return false;
switch (preference.getKey()){
case "clear_history":
new AlertDialog.Builder(getActivity())
.setTitle(R.string.clear_history)
......@@ -124,9 +126,6 @@ public class PreferencesAdvanced extends BasePreferenceFragment implements Share
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
switch (key){
case "set_locale":
UiTools.snacker(getView(), R.string.set_locale_popup);
break;
case "network_caching":
SharedPreferences.Editor editor = sharedPreferences.edit();
try {
......
......@@ -62,7 +62,6 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findPreference("screen_orientation").setVisible(false);
findPreference("ui_category").setVisible(false);
}
@Override
......@@ -82,9 +81,9 @@ public class PreferencesFragment extends BasePreferenceFragment implements Share
startActivity(intent);
getActivity().setResult(PreferencesActivity.RESULT_RESTART);
return true;
// case "ui_category":
// loadFragment(new PreferencesUi());
// break;
case "ui_category":
loadFragment(new PreferencesUi());
break;
case "video_category":
loadFragment(new PreferencesVideo());
break;
......
......@@ -24,17 +24,16 @@
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.Preference;
import android.support.v7.preference.TwoStatePreference;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.util.AndroidDevices;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class PreferencesUi extends BasePreferenceFragment {
public class PreferencesUi extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Override
protected int getXml() {
......@@ -46,6 +45,19 @@ public class PreferencesUi extends BasePreferenceFragment {
return R.string.interface_prefs_screen;
}
@Override
public void onStart() {
super.onStart();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onStop() {
super.onStop();
getPreferenceScreen().getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(this);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -53,23 +65,13 @@ public class PreferencesUi extends BasePreferenceFragment {
findPreference("enable_clone_mode").setVisible(false);
findPreference("tv_ui").setVisible(AndroidDevices.hasTsp());
findPreference("enable_black_theme").setVisible(false);
findPreference("secondary_display_category").setVisible(false);
findPreference("secondary_display_category_summary").setVisible(false);
}
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey() == null)
return false;
switch (preference.getKey()){
case "enable_headset_detection":
((PreferencesActivity)getActivity()).detectHeadset(((TwoStatePreference) preference).isChecked());
return true;
case "enable_steal_remote_control":
PlaybackService.Client.restartService(getActivity());
return true;
case "tv_ui":
((PreferencesActivity) getActivity()).setRestart();
return true;
}
return super.onPreferenceTreeClick(preference);
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals("set_locale"))
UiTools.snacker(getView(), R.string.set_locale_popup);
}
}
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