-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dark mode #322
Dark mode #322
Conversation
Experimenting with this on an emulator, I find that if the dark theme setting is configured, then the app is launched clean, it works as expected. However, if the app was running already when the dark mode setting is changed, the app may not take the theme or may do so improperly. Here is an example.
Note that the title text is really dark. A similar situation happens when switching from dark to light. I'm not sure yet what is causing this behavior on only what appears to be the card title text. (The note text is correct). Are you able to duplicate this on your test device or emulator? |
I did run into this issue earlier but I thought I fixed it. Seems I did miss a case. I'll take another look at it, thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 8 of 11 files at r1, 3 of 3 files at r2.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @TheLastProject)
a discussion (no related file):
I've only a few comments on the code. Let me know if you track down the theme change issue I mentioned, and I'll take a look again.
app/src/main/java/protect/card_locker/preferences/SettingsActivity.java, line 58 at r2 (raw file):
findPreference(getResources().getString(R.string.settings_key_theme)).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object o) {
I do not mind if the { is at the end of the line or on the next line. Kindly make it consistent in the file, though.
app/src/main/java/protect/card_locker/preferences/SettingsActivity.java, line 65 at r2 (raw file):
return true; } else if(o.toString().equals(getResources().getString(R.string.settings_key_dark_theme)))
Could the if/else if/ pattern be changed either to if/else if/else or if/if/? That is,
if ( /*check light theme*/) {
// something
} else if (/*check dark theme*/) {
//something
} else {
//something
}
return true
or
if (/*check*) {
//something
return true
}
if (/*check*/) {
//something
return true
}
// last option
return true;
app/src/main/java/protect/card_locker/preferences/SettingsActivity.java, line 73 at r2 (raw file):
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); getActivity().recreate();
If all paths end up recreating and returning true, why not do the common work at the end and return once?
I'll deal with the code comments soon, thanks for reviewing.
The issue became less prevalent with recent commits, but it still does occur on some elements (like the border around the about webview). I'm not sure why that happens so it may take some time until I can figure that out, if ever. I will notify you if I believe I found it though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 10 of 13 files reviewed, 4 unresolved discussions (waiting on @brarcher)
a discussion (no related file):
Previously, brarcher (Branden Archer) wrote…
I've only a few comments on the code. Let me know if you track down the theme change issue I mentioned, and I'll take a look again.
Done.
app/src/main/java/protect/card_locker/preferences/SettingsActivity.java, line 58 at r2 (raw file):
Previously, brarcher (Branden Archer) wrote…
I do not mind if the { is at the end of the line or on the next line. Kindly make it consistent in the file, though.
Done.
app/src/main/java/protect/card_locker/preferences/SettingsActivity.java, line 65 at r2 (raw file):
Previously, brarcher (Branden Archer) wrote…
Could the if/else if/ pattern be changed either to if/else if/else or if/if/? That is,
if ( /*check light theme*/) { // something } else if (/*check dark theme*/) { //something } else { //something } return true
or
if (/*check*) { //something return true } if (/*check*/) { //something return true } // last option return true;
Done.
app/src/main/java/protect/card_locker/preferences/SettingsActivity.java, line 73 at r2 (raw file):
Previously, brarcher (Branden Archer) wrote…
If all paths end up recreating and returning true, why not do the common work at the end and return once?
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you ever seen the issue when launching the app when it was not running? That is, the theme was already configured, the app was swiped from recents then re-launched? Having the dark theme work well in that scenario will be more important that when the theme is being toggled, as I anticipate that if one configures their phone to be a theme it will stay that way. (Is that a valid assumption?) It may not look polished if there are transient issues when the theme changes, however having dark mode work well all other times may balance it out.
Reviewable status: 10 of 13 files reviewed, 4 unresolved discussions (waiting on @brarcher)
I've only ever seen it go wrong for the very specific scenario you mentioned, and I managed to fix that so it only bugs out the about dialog now:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r3, 1 of 1 files at r4.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @brarcher and @TheLastProject)
app/src/main/java/protect/card_locker/BarcodeImageWriterTask.java, line 115 at r4 (raw file):
int bitMatrixHeight = bitMatrix.getHeight(); // Returns: left,top,width,height enclosing rectangle of all 1 bits, or null if it is all white
I'm thinking that there still needs to be a white border around the barcode. The reason is, if the barcode goes right to the edge and it is dark theme, a detector will not be able to distinguish the boundaries of the barcode. For example, in my test setup I have an emulator and a physical phone, and I have my phone attempt to read the barcode from the emulator's screen. The phone is able to read this one:
but not this one:
With the barcode drawing changes reverted one gets the following:
which is successfully read. I recall from somewhere that barcode are intended to have a certain amount of buffer space to avoid these issues. We may not be able to remove the buffer space that the ZXing library generates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 12 of 13 files reviewed, 4 unresolved discussions (waiting on @brarcher and @TheLastProject)
app/src/main/java/protect/card_locker/BarcodeImageWriterTask.java, line 118 at r5 (raw file):
int[] enclosingRectangle = bitMatrix.getEnclosingRectangle(); // We add 20 pixels on all sides to ensure small intentional padding around the barcodes isn't removed
Arguably 20 pixels is arbitrary. My understanding is that the padding, or quiet zone, around a barcode should be "at least seven to ten times of the narrowest bar width in the barcode."
https://www.cognex.com/what-is/industrial-barcode-reading/1d-barcodes
I think that ZXing takes care of creating an appropriate quiet zone. My concern is that with changing the effective drawing area for the barcode that the expected quiet zone may be eroded. Can these changes be removed? Or, are they addressing a concern that I do not quite get yet?
Yeah, I indeed reverted it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r6.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @brarcher and @TheLastProject)
Sorry, did not see your reply initially. Sounds good! |
Thanks for adding this feature! |
And thank you for reviewing, testing and accepting it :) |
Fixes #298. Defaults to whatever the system theme is. When changing the value in settings, instantly swaps theme.
Yes, this is really all that needed to be done. Android did a pretty good job at making dark themes possible easily.
This change is