Skip to content

Commit

Permalink
Merge pull request #259 from brarcher/setting-barcode-brightness
Browse files Browse the repository at this point in the history
Configure brightening screen when display a barcode
  • Loading branch information
brarcher authored Jul 26, 2018
2 parents 8c7a327 + 34c0780 commit ceea518
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void onResume()
// '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;
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/protect/card_locker/preferences/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ private int getInt(@StringRes int keyId, @IntegerRes int defaultId)
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);
Expand All @@ -58,4 +63,9 @@ public int getCardNoteFontSize()
{
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);
}
}
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,6 @@
<string name="settings_key_card_id_font_size" translatable="false">pref_card_id_font_size_sp</string>
<string name="settings_card_note_font_size">Card note font size</string>
<string name="settings_key_card_note_font_size" translatable="false">pref_card_note_font_size_sp</string>

<string name="settings_display_barcode_max_brightness">Brighten barcode view</string>
<string name="settings_key_display_barcode_max_brightness" translatable="false">pref_display_card_max_brightness</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
android:defaultValue="@integer/settings_card_note_font_size_sp"
app:vnt_maxValue="@integer/settings_card_note_max_font_size_sp"
app:vnt_minValue="@integer/settings_card_note_min_font_size_sp" />
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/settings_key_display_barcode_max_brightness"
android:title="@string/settings_display_barcode_max_brightness"/>

</PreferenceCategory>

Expand Down

0 comments on commit ceea518

Please sign in to comment.