mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-01-08 06:57:59 -05:00
Added option to keep the screen on
This commit is contained in:
committed by
Miha Frangež
parent
34f8c830fd
commit
940be02851
@@ -233,10 +233,22 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
// '1' is the brightest. We attempt to maximize the brightness
|
||||
// to help barcode readers scan the barcode.
|
||||
Window window = getWindow();
|
||||
if(window != null && settings.useMaxBrightnessDisplayingBarcode())
|
||||
if(window != null)
|
||||
{
|
||||
WindowManager.LayoutParams attributes = window.getAttributes();
|
||||
attributes.screenBrightness = 1F;
|
||||
|
||||
if (settings.useMaxBrightnessDisplayingBarcode())
|
||||
{
|
||||
attributes.screenBrightness = 1F;
|
||||
}
|
||||
|
||||
if (settings.getKeepScreenOn())
|
||||
{
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
}
|
||||
|
||||
window.setAttributes(attributes);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,4 +90,9 @@ public class Settings
|
||||
{
|
||||
return getBoolean(R.string.settings_key_lock_barcode_orientation, false);
|
||||
}
|
||||
|
||||
public boolean getKeepScreenOn()
|
||||
{
|
||||
return getBoolean(R.string.settings_key_keep_screen_on, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,8 @@
|
||||
<string name="settings_key_display_barcode_max_brightness" translatable="false">pref_display_card_max_brightness</string>
|
||||
<string name="settings_lock_barcode_orientation">Lock barcode orientation</string>
|
||||
<string name="settings_key_lock_barcode_orientation" translatable="false">pref_lock_barcode_orientation</string>
|
||||
<string name="settings_keep_screen_on">Keep screen on</string>
|
||||
<string name="settings_key_keep_screen_on" translatable="false">pref_keep_screen_on</string>
|
||||
|
||||
<string name="sharedpreference_active_tab" translatable="false">sharedpreference_active_tab</string>
|
||||
|
||||
|
||||
@@ -58,6 +58,12 @@
|
||||
android:key="@string/settings_key_lock_barcode_orientation"
|
||||
android:title="@string/settings_lock_barcode_orientation"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="@string/settings_key_keep_screen_on"
|
||||
android:title="@string/settings_keep_screen_on"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
Reference in New Issue
Block a user