From 9492d206d9a6dddd26438b5a9f730fde533a8b54 Mon Sep 17 00:00:00 2001 From: Branden Archer Date: Tue, 19 Jul 2016 23:42:36 -0400 Subject: [PATCH] Adjust brightness to its maximum when displaying a card Some users have mentioned that a barcode scanner has the best success when the screen is at its brightest. To enable the best results, the screen brightness will now be adjusted to its maximum when displaying a loyalty card. https://github.com/brarcher/loyalty-card-locker/issues/21 --- .../card_locker/LoyaltyCardViewActivity.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 3b8f72a9c..2589678f3 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -14,6 +14,8 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewTreeObserver; +import android.view.Window; +import android.view.WindowManager; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; @@ -56,6 +58,20 @@ public class LoyaltyCardViewActivity extends AppCompatActivity Log.i(TAG, "To view card: " + loyaltyCardId); + if(viewLoyaltyCard) + { + // The brightness value is on a scale from [0, ..., 1], where + // '1' is the brightest. We attempt to maximize the brightness + // to help barcode readers scan the barcode. + Window window = getWindow(); + if(window != null) + { + WindowManager.LayoutParams attributes = window.getAttributes(); + attributes.screenBrightness = 1F; + window.setAttributes(attributes); + } + } + final EditText storeField = (EditText) findViewById(R.id.storeName); final EditText noteField = (EditText) findViewById(R.id.note); final EditText cardIdField = (EditText) findViewById(R.id.cardId);