Settings menu did not refresh correctly on preference change. fixes #284
This commit is contained in:
parent
225f03e106
commit
bfc5ddc15d
|
@ -15,7 +15,6 @@ import android.preference.Preference;
|
|||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
@ -148,6 +147,17 @@ public class PreferenceActivity extends android.preference.PreferenceActivity {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
findPreference(UserPreferences.PREF_ENABLE_AUTODL)
|
||||
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (newValue instanceof Boolean) {
|
||||
findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER).setEnabled((Boolean) newValue);
|
||||
setSelectedNetworksEnabled((Boolean) newValue && UserPreferences.isEnableAutodownloadWifiFilter());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER)
|
||||
.setOnPreferenceChangeListener(
|
||||
new OnPreferenceChangeListener() {
|
||||
|
@ -166,11 +176,11 @@ public class PreferenceActivity extends android.preference.PreferenceActivity {
|
|||
findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE)
|
||||
.setOnPreferenceChangeListener(
|
||||
new OnPreferenceChangeListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object o) {
|
||||
checkItemVisibility();
|
||||
if (o instanceof String) {
|
||||
setEpisodeCacheSizeText(UserPreferences.readEpisodeCacheSize((String) o));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -115,7 +115,7 @@ public class UserPreferences implements
|
|||
PREF_ENABLE_AUTODL_WIFI_FILTER, false);
|
||||
autodownloadSelectedNetworks = StringUtils.split(
|
||||
sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
|
||||
episodeCacheSize = readEpisodeCacheSize(sp.getString(
|
||||
episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(
|
||||
PREF_EPISODE_CACHE_SIZE, "20"));
|
||||
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
|
||||
playbackSpeed = sp.getString(PREF_PLAYBACK_SPEED, "1.0");
|
||||
|
@ -139,7 +139,7 @@ public class UserPreferences implements
|
|||
return TimeUnit.HOURS.toMillis(hours);
|
||||
}
|
||||
|
||||
private int readEpisodeCacheSize(String valueFromPrefs) {
|
||||
private int readEpisodeCacheSizeInternal(String valueFromPrefs) {
|
||||
if (valueFromPrefs.equals(context
|
||||
.getString(R.string.pref_episode_cache_unlimited))) {
|
||||
return EPISODE_CACHE_SIZE_UNLIMITED;
|
||||
|
@ -300,7 +300,7 @@ public class UserPreferences implements
|
|||
autodownloadSelectedNetworks = StringUtils.split(
|
||||
sp.getString(PREF_AUTODL_SELECTED_NETWORKS, ""), ',');
|
||||
} else if (key.equals(PREF_EPISODE_CACHE_SIZE)) {
|
||||
episodeCacheSize = readEpisodeCacheSize(sp.getString(
|
||||
episodeCacheSize = readEpisodeCacheSizeInternal(sp.getString(
|
||||
PREF_EPISODE_CACHE_SIZE, "20"));
|
||||
} else if (key.equals(PREF_ENABLE_AUTODL)) {
|
||||
enableAutodownload = sp.getBoolean(PREF_ENABLE_AUTODL, false);
|
||||
|
@ -474,4 +474,12 @@ public class UserPreferences implements
|
|||
Log.d(TAG, "Automatic update was deactivated");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads episode cache size as it is saved in the episode_cache_size_values array.
|
||||
* */
|
||||
public static int readEpisodeCacheSize(String valueFromPrefs) {
|
||||
instanceAvailable();
|
||||
return instance.readEpisodeCacheSizeInternal(valueFromPrefs);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue