mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-02 14:51:43 -04:00
Configure brightening screen when display a barcode
When a barcode is displayed the screen's brightness is set to the maximum, in an attempt to provide the best chance for a barcode scanner to capture the barcode. However, it may not always be desired to increase the brightness, for example when using the app in low light. This change adds a setting to control the screen brightening behavior when a barcode is viewed.
This commit is contained in:
@@ -96,7 +96,7 @@ 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)
|
||||
if(window != null && settings.useMaxBrightnessDisplayingBarcode())
|
||||
{
|
||||
WindowManager.LayoutParams attributes = window.getAttributes();
|
||||
attributes.screenBrightness = 1F;
|
||||
|
||||
@@ -34,6 +34,11 @@ public class Settings
|
||||
return settings.getInt(getResString(keyId), getResInt(defaultId));
|
||||
}
|
||||
|
||||
private boolean getBoolean(@StringRes int keyId, boolean defaultValue)
|
||||
{
|
||||
return settings.getBoolean(getResString(keyId), defaultValue);
|
||||
}
|
||||
|
||||
public int getCardTitleListFontSize()
|
||||
{
|
||||
return getInt(R.string.settings_key_card_title_list_font_size, R.integer.settings_card_title_list_font_size_sp);
|
||||
@@ -58,4 +63,9 @@ public class Settings
|
||||
{
|
||||
return getInt(R.string.settings_key_card_note_font_size, R.integer.settings_card_note_font_size_sp);
|
||||
}
|
||||
|
||||
public boolean useMaxBrightnessDisplayingBarcode()
|
||||
{
|
||||
return getBoolean(R.string.settings_key_display_barcode_max_brightness, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user