From 5665a1a0a5a32e3f66bddd22221f2957746c9511 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Wed, 22 Feb 2017 21:36:07 +0100 Subject: make max brightness in fullscreen configurable fixes #105 --- .../ui/ShowFullscreenMessageActivity.java | 26 ++++++++++++++++++---- src/main/res/values-de/strings.xml | 2 ++ src/main/res/values/strings.xml | 2 ++ src/main/res/xml/preferences.xml | 5 +++++ 4 files changed, 31 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java b/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java index 75c6d8849..c333d1cb5 100644 --- a/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ShowFullscreenMessageActivity.java @@ -2,12 +2,14 @@ package de.pixart.messenger.ui; import android.app.Activity; import android.content.Intent; +import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.graphics.BitmapFactory; import android.media.MediaMetadataRetriever; import android.net.Uri; import android.os.Bundle; +import android.preference.PreferenceManager; import android.util.Log; import android.view.View; import android.view.WindowManager; @@ -54,7 +56,9 @@ public class ShowFullscreenMessageActivity extends Activity { oldOrientation = getRequestedOrientation(); WindowManager.LayoutParams layout = getWindow().getAttributes(); - layout.screenBrightness = 1; + if (useMaxBrightness()) { + layout.screenBrightness = 1; + } getWindow().setAttributes(layout); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_fullscreen_message); @@ -212,7 +216,9 @@ public class ShowFullscreenMessageActivity extends Activity { @Override protected void onResume() { WindowManager.LayoutParams layout = getWindow().getAttributes(); - layout.screenBrightness = 1; + if (useMaxBrightness()) { + layout.screenBrightness = 1; + } getWindow().setAttributes(layout); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); mVideo.setShouldAutoplay(true); @@ -223,7 +229,9 @@ public class ShowFullscreenMessageActivity extends Activity { protected void onPause() { mVideo.reset(); WindowManager.LayoutParams layout = getWindow().getAttributes(); - layout.screenBrightness = -1; + if (useMaxBrightness()) { + layout.screenBrightness = -1; + } getWindow().setAttributes(layout); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setRequestedOrientation(oldOrientation); @@ -234,10 +242,20 @@ public class ShowFullscreenMessageActivity extends Activity { public void onStop() { mVideo.reset(); WindowManager.LayoutParams layout = getWindow().getAttributes(); - layout.screenBrightness = -1; + if (useMaxBrightness()) { + layout.screenBrightness = -1; + } getWindow().setAttributes(layout); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setRequestedOrientation(oldOrientation); super.onStop(); } + + public boolean useMaxBrightness() { + return getPreferences().getBoolean("use_max_brightness", true); + } + + protected SharedPreferences getPreferences() { + return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + } } \ No newline at end of file diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index eb6af903e..2da868dfd 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -690,5 +690,7 @@ 7 Tage Heute Fange an zu schreiben… + Maximale Helligkeit + Maximale Helligkeit aktivieren, wenn Videos oder Bilder im Vollbild betracht werden. diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index bdd6c6fb7..fd109379b 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -739,4 +739,6 @@ 6 months Today Start chtatting… + Switch to maximum brightness while watching videos or images in fullscreen. + Maximum brightness diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 05d4551fb..ac3ea1445 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -28,6 +28,11 @@ android:key="quick_action" android:summary="@string/pref_quick_action_summary" android:title="@string/pref_quick_action" /> +