ankidroid / Anki-Android

AnkiDroid: Anki flashcards on Android. Your secret trick to achieve superhuman information retention.
GNU General Public License v3.0
8.81k stars 2.25k forks source link

Change log is light when using dark mode #6535

Closed Jonta closed 1 year ago

Jonta commented 4 years ago
Reproduction Steps
  1. Have app in Dark Mode
  2. Get app update
Expected Result

Dark colours in app update popup

Actual Result

Light colours

Debug info

AnkiDroid Version = 2.11.3

Android Version = 9

ACRA UUID = Not disclosing

Research

Enter an [x] character to confirm the points below:

github-actions[bot] commented 4 years ago

Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing

mikehardy commented 4 years ago

Ha! I'd never thought of that. The developers are typically running alpha on their devices and the changelog only pops when you are on the stable track and get an update, so I the last few at least I'm the person that writes the darn things but never see them :-).

We're just opening a webview, should be easy to send it the appropriate styling, although those are famous last words.

mikehardy commented 4 years ago

If anyone is interested in taking this on, note that the changelog is generated:

If there is some infrastructural thing that needs to happen (to inject a style into the .asc -> .html conversion or who knows), that's fine

mikehardy commented 4 years ago

and here's the eventual WebView load https://github.com/ankidroid/Anki-Android/blob/5d81aee0bd1f388fc16a59820946addc074a8b81/AnkiDroid/src/main/java/com/ichi2/anki/Info.java#L146

david-allison commented 4 years ago

You should be able to apply styling via JS with the following code (untested on API < Kitkat):

        String js = "javascript:alert('hello world');"
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            webView.evaluateJavascript(js, null);
        } else {
            webView.loadUrl(js);
        }

Code to detect if we're in night mode:

        boolean nightMode = preferences.getBoolean("invertedColors", false);
github-actions[bot] commented 4 years ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] commented 4 years ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

github-actions[bot] commented 3 years ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

Jonta commented 3 years ago

still searching for solutions

mrudultora commented 3 years ago

@david-allison-1

Can I implement in the below way rather than the method suggested by you?

Firstly, I will read the changelog.html from assets folder, and if the theme of the app is dark/black, I will replace body tag in a different way. For more clear info, I will search <body (it's intentional to include only and only first angular bracket of body tag) and replace it with something like this <body text="#FFFFFF" link="#E37068". This will work in both debug mode and release mode, because there is only one body tag (obviously). And the background of the webview will be changed using typedValue.

mrudultora commented 3 years ago

Please clarify few things...

• Whether its debug or release mode... in both cases the changelogs will be fetched from assets folder ? • Color changes required in theme (link colors, title color, etc.) .

I tried the way you suggested but was unable to change the theme using webView.evaluateJavascript. Also, after downloading the app from Google Play Store there is no option to view changelogs in Advanced Settings. Is this a bug or it's intentional. I am unable to view changelogs in release mode.

david-allison commented 3 years ago

Whether its debug or release mode... in both cases the changelogs will be fetched from assets folder ?

Yes: The same file -

https://github.com/ankidroid/Anki-Android/blob/cde9ec5200bb9917147797a420ce80d3fab8c67f/AnkiDroid/src/main/java/com/ichi2/anki/Info.java#L137

Color changes required in theme (link colors, title color, etc.) .

Use your best judgment

I tried the way you suggested but was unable to change the theme using webView.evaluateJavascript.

Was this because there was a problem with JS evaluation? "It doesn't work" doesn't give us much to go off to get it working

Also, after downloading the app from Google Play Store there is no option to view changelogs in Advanced Settings. Is this a bug or it's intentional. I am unable to view changelogs in release mode.

No, but I've been considering it. Feel free to add a PR/an issue to do so (ideally in the advanced settings).


Can I implement in the below way rather than the method suggested by you?

webView.loadUrl is much simpler than webView.loadData. I feel JavaScript would be a better solution, but modifying the HTML as a stream would definitely work as a Plan B. I'd prefer JS, but if there's an explainable technical issue, then explain why it won't work and go with the HTML modification

mrudultora commented 3 years ago

@david-allison-1 I have tried it in another way using javascript only. Here, I will inject javascript function after webView.loadUrl so that I change properties. If I will face any problem, I will let you know.

Color changes required in theme (link colors, title color, etc.) . Use your best judgment

Okay. I will change with appropriate colors.

Jonta commented 3 years ago

Perhaps related enough to be in this issue:

Still a white flash before showing the updates in dark mode

2.15.6 - 20210714

Android 10

mrudultora commented 3 years ago

@Jonta A white flash happens as the webview is created and loaded and then javascript code runs. The amount of info in changelogs is too big so it takes some time. The same code works for "About Ankidroid" and "Open Changelog", but this doesn't happens in "About Ankidroid" due to smaller content. I hope this explains the reason of white flash. Talking about the solution, I would like to get other's view on it.

mikehardy commented 3 years ago

Interesting - you could open a blank page with the correct background then re-load with the changelog perhaps. I consider this a mild issue but if you are in a very dark setting and have dark mode on I bet that pop of white is pretty unexpected

mrudultora commented 3 years ago

Yeah, that can be done. I would look to make a PR in the meantime.

BrayanDSO commented 1 year ago

Fixed