Dark theme: use recreate()

Also move the logic into playbackservice: there is no need to register a 2nd receiver
This commit is contained in:
Adrian Ulrich 2015-05-11 19:03:54 +02:00
parent 3d87a167c8
commit f2c62f16a8
3 changed files with 8 additions and 13 deletions

View File

@ -208,7 +208,7 @@ THE SOFTWARE.
<string name="misc_features">Miscellaneous Features</string>
<string name="use_dark_theme_title">Use dark theme</string>
<string name="use_dark_theme_summary">Enables the dark material theme (requires restart)</string>
<string name="use_dark_theme_summary">Enables the dark material theme</string>
<string name="disable_lockscreen_title">Disable Lockscreen</string>
<string name="disable_lockscreen_summary">Prevent the lockscreen from activating when in the library or playback screen</string>
<string name="use_idle_timeout_title">Enable Idle Timeout</string>

View File

@ -55,8 +55,7 @@ import android.widget.Toast;
public abstract class PlaybackActivity extends Activity
implements Handler.Callback,
View.OnClickListener,
CoverView.Callback,
SharedPreferences.OnSharedPreferenceChangeListener
CoverView.Callback
{
private Action mUpAction;
private Action mDownAction;
@ -119,11 +118,11 @@ public abstract class PlaybackActivity extends Activity
startService(new Intent(this, PlaybackService.class));
SharedPreferences prefs = PlaybackService.getSettings(this);
prefs.registerOnSharedPreferenceChangeListener(this);
mUpAction = Action.getAction(prefs, PrefKeys.SWIPE_UP_ACTION, Action.Nothing);
mDownAction = Action.getAction(prefs, PrefKeys.SWIPE_DOWN_ACTION, Action.Nothing);
Window window = getWindow();
if (prefs.getBoolean(PrefKeys.DISABLE_LOCKSCREEN, false))
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
@ -144,15 +143,6 @@ public abstract class PlaybackActivity extends Activity
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(PrefKeys.USE_DARK_THEME)) {
// Terminate this activity as the currently used theme is outdated
finish();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)

View File

@ -849,6 +849,11 @@ public final class PlaybackService extends Service
refreshReplayGainValues();
} else if (PrefKeys.ENABLE_READAHEAD.equals(key)) {
mReadaheadEnabled = settings.getBoolean(PrefKeys.ENABLE_READAHEAD, false);
} else if (PrefKeys.USE_DARK_THEME.equals(key)) {
// Theme changed: trigger a restart of all registered activites
ArrayList<PlaybackActivity> list = sActivities;
for (int i = list.size(); --i != -1; )
list.get(i).recreate();
}
/* Tell androids cloud-backup manager that we just changed our preferences */
(new BackupManager(this)).dataChanged();