From b75e4654a818cd4109d6411a8ea08a44e50b2cf0 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 27 Nov 2012 23:20:40 -0800 Subject: Cache whether or not the user wants the screen to stay on --- .../github/daneren2005/dsub/service/DownloadServiceImpl.java | 10 +++++++++- .../src/github/daneren2005/dsub/util/Constants.java | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index aae4829a..a718ad9d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -59,6 +59,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.PowerManager; import android.util.Log; +import github.daneren2005.dsub.activity.SubsonicTabActivity; /** * @author Sindre Mehus @@ -99,7 +100,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { private static DownloadService instance; private String suggestedPlaylistName; private PowerManager.WakeLock wakeLock; - private boolean keepScreenOn = false; + private boolean keepScreenOn; private static boolean equalizerAvailable; private static boolean visualizerAvailable; @@ -175,6 +176,8 @@ public class DownloadServiceImpl extends Service implements DownloadService { SharedPreferences prefs = Util.getPreferences(this); timerDuration = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_SLEEP_TIMER_DURATION, "60")); sleepTimer = null; + + keepScreenOn = prefs.getBoolean(Constants.PREFERENCES_KEY_KEEP_SCREEN_ON, false); instance = this; lifecycleSupport.onCreate(); @@ -335,6 +338,11 @@ public class DownloadServiceImpl extends Service implements DownloadService { @Override public void setKeepScreenOn(boolean keepScreenOn) { this.keepScreenOn = keepScreenOn; + + SharedPreferences prefs = Util.getPreferences(this); + SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean(Constants.PREFERENCES_KEY_KEEP_SCREEN_ON, keepScreenOn); + editor.commit(); } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index 42acde16..4d48b6d4 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -83,6 +83,7 @@ public final class Constants { public static final String PREFERENCES_KEY_SHUFFLE_START_YEAR = "startYear"; public static final String PREFERENCES_KEY_SHUFFLE_END_YEAR = "endYear"; public static final String PREFERENCES_KEY_SHUFFLE_GENRE = "genre"; + public static final String PREFERENCES_KEY_KEEP_SCREEN_ON = "keepScreenOn"; // Name of the preferences file. public static final String PREFERENCES_FILE_NAME = "github.daneren2005.dsub_preferences"; -- cgit v1.2.3