implement KEEP_SCREEN_ON

This commit is contained in:
Adrian Ulrich 2017-04-24 19:16:43 +02:00
parent b792afcd7b
commit 303f9d2375
5 changed files with 17 additions and 0 deletions

View File

@ -225,6 +225,8 @@ THE SOFTWARE.
<string name="theme">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="keep_screen_on_title">Keep screen on</string>
<string name="keep_screen_on_summary">Keep the screen (and device) awake while Vanilla Music is visible</string>
<string name="use_idle_timeout_title">Enable idle timeout</string>
<string name="use_idle_timeout_summary">When active, playback will be stopped after the given period of inactivity</string>
<string name="idle_timeout_title">Idle timeout</string>

View File

@ -29,6 +29,11 @@ THE SOFTWARE.
android:title="@string/disable_lockscreen_title"
android:summary="@string/disable_lockscreen_summary"
android:defaultValue="false" />
<CheckBoxPreference
android:key="keep_screen_on"
android:title="@string/keep_screen_on_title"
android:summary="@string/keep_screen_on_summary"
android:defaultValue="false" />
<CheckBoxPreference
android:key="use_idle_timeout"
android:title="@string/use_idle_timeout_title"

View File

@ -152,12 +152,20 @@ public abstract class PlaybackActivity extends Activity
Window window = getWindow();
// Set lockscreen preference
if (prefs.getBoolean(PrefKeys.DISABLE_LOCKSCREEN, PrefDefaults.DISABLE_LOCKSCREEN))
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
else
window.clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
// Set screen-on preference
if (prefs.getBoolean(PrefKeys.KEEP_SCREEN_ON, PrefDefaults.KEEP_SCREEN_ON))
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
else
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
@Override

View File

@ -69,4 +69,5 @@ public class PrefDefaults {
public static final int AUTOPLAYLIST_PLAYCOUNTS = 0;
public static final boolean IGNORE_AUDIOFOCUS_LOSS = false;
public static final boolean ENABLE_SCROLL_TO_SONG = false;
public static final boolean KEEP_SCREEN_ON = false;
}

View File

@ -70,4 +70,5 @@ public class PrefKeys {
public static final String AUTOPLAYLIST_PLAYCOUNTS = "playcounts_autoplaylist";
public static final String IGNORE_AUDIOFOCUS_LOSS = "ignore_audiofocus_loss";
public static final String ENABLE_SCROLL_TO_SONG = "enable_scroll_to_song";
public static final String KEEP_SCREEN_ON = "keep_screen_on";
}