-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Productionised Webview Check using Dialog Boxes #15876
Conversation
Message to maintainers, this PR contains strings changes.
Read more about updating strings on the wiki, |
@@ -141,6 +144,7 @@ import kotlin.time.measureTimedValue | |||
const val MIGRATION_WAS_LAST_POSTPONED_AT_SECONDS = "secondWhenMigrationWasPostponedLast" | |||
const val TIMES_STORAGE_MIGRATION_POSTPONED_KEY = "timesStorageMigrationPostponed" | |||
const val OLDEST_WORKING_WEBVIEW_VERSION = 77 | |||
const val WEBVIEW_UPDATION_LINK = "https://github.com/ankidroid/Anki-Android/wiki" |
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.
use constants.xml
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.
This should link to an actual page with information
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.
Hey! I have been working to fix this, but I was unable to find a page in the wiki relating to updating WebView. So, I was wondering if you had an external wiki in mind.
…out Older WebView Version and Information to Correct it.
…out Older WebView Version and Information to Correct it.
…out Older WebView Version and Information to Correct it.
…box code structure and added support for translations
Hey, I have made some changes. Could you please review them? |
…box code structure and added support for translations
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.
Initial round of feedback, we'll need some more time on the strings, perhaps bring the conversation to #ankidroid-dev
, then detail the results of this conversation on the pull request
|
||
if (webviewPackageInfo == null) { | ||
// User is missing both com.android.webview and com.google.android.webview | ||
AlertDialog.Builder(context).show { |
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.
Could you extract each of these into methods
It's difficult to follow the dialog selection logic because this method contains both the selection and implementation logc
Uri.parse(context.getString(R.string.webview_update_link)) | ||
context.startActivity(openURL) | ||
} | ||
neutralButton(R.string.deck_picker_disable_older_webview) { |
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.
Is a user going to know what to do here?
@@ -296,4 +296,5 @@ | |||
<string name="show_onboarding" maxLength="41">Show onboarding walkthrough</string> | |||
<string name="show_onboarding_desc">Display feature tutorial to learn more about the app</string> | |||
<string name="reset_onboarding_desc">Show all tutorials again</string> | |||
<string name="webview_update_link">https://github.com/ankidroid/Anki-Android/wiki/FAQ#other-questions</string> |
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.
This should be a specific page which you have created, don't leave it in the FAQ
@@ -260,5 +260,10 @@ | |||
</string> | |||
|
|||
<string name="deck_already_exists">Deck already exists</string> | |||
<string name="deck_picker_disable_older_webview">Disable WebView</string> | |||
<string name="deck_picker_updation_older_webview">Install Now </string> |
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.
This should likely be 'learn more', which we already have a string for
<string name="deck_picker_updation_older_webview">Install Now </string> | ||
<string name="webview_update_message">The WebView version %1$s is outdated (less than %2$s). You can update it by following the given link.</string> | ||
<string name="missing_webview">"AnkiDroid relies on the System WebView which is unavailable"</string> | ||
<string name="older_webview_found_alert">"The WebView Package com.android.webview is not supported.You must disable the existing WebView Package and Install com.google.android.webview ."</string> |
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.
<string name="older_webview_found_alert">"The WebView Package com.android.webview is not supported.You must disable the existing WebView Package and Install com.google.android.webview ."</string> | |
<string name="older_webview_found_alert">"The WebView package com.android.webview is not supported. You must disable the existing WebView package and install com.google.android.webview ."</string> |
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.
This string will need a lot more thought to best communicate the problem to a non-technical user
…ttons to Help Dialog and A Wiki Page.
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.
Much better, thanks!
Probably a couple of rounds of feedback, then let's get this in!
@@ -164,11 +165,20 @@ sealed class AnkiDroidFolder(val permissionSet: PermissionSet) { | |||
} | |||
|
|||
@Parcelize | |||
enum class PermissionSet(val permissions: List<String>, val permissionsFragment: Class<out PermissionsFragment>?) : Parcelable { | |||
LEGACY_ACCESS(Permissions.legacyStorageAccessPermissions, PermissionsUntil29Fragment::class.java), | |||
enum class PermissionSet( |
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.
was this change intentional? If not, please revert
} | ||
cancelable(false) | ||
} | ||
// Nothing as already checked inside webViewFailedToLoad |
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.
Use val webviewPackageInfo = getAndroidSystemWebViewPackageInfo(packageManager) ?: return
neutralButton(R.string.help_title_get_help) { | ||
// Show the HelpDialog | ||
val helpDialog = HelpDialog.newHelpInstance() | ||
helpDialog.show(fragmentManager, "HelpDialog") |
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.
@lukstbit I'd expect something along the lines of requireAnkiActivity().showDialogFragment()
here, did you have an intended pattern for opening the Dialog outside the Help
button?
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.
Nothing special, the two factory methods just return a plain instance of the help dialog that can be used with showDialogFragment()
.
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.
@aayush-tripathi best to provide an AnkiActivity
here instead of a Context
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.
Still pending, change also needs to be applied in the other method
val openURL = Intent(Intent.ACTION_VIEW) | ||
openURL.data = | ||
Uri.parse(context.getString(R.string.webview_update_link)) | ||
context.startActivity(openURL) |
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.
use AnkiActivity.openUrl()
@@ -296,4 +296,5 @@ | |||
<string name="show_onboarding" maxLength="41">Show onboarding walkthrough</string> | |||
<string name="show_onboarding_desc">Display feature tutorial to learn more about the app</string> | |||
<string name="reset_onboarding_desc">Show all tutorials again</string> | |||
<string name="webview_update_link">https://github.com/ankidroid/Anki-Android/wiki/WebView-Detection-and-Updation</string> |
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.
Updation
isn't a word.
Try: WebView Package Updates
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.
I'd expect different links for 'Learn more' on the two screens
@@ -260,5 +260,7 @@ | |||
</string> | |||
|
|||
<string name="deck_already_exists">Deck already exists</string> | |||
<string name="webview_update_message">The WebView version is outdated (must be >= %1$s)</string> |
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.
Only use positional arg syntax if there's more than 1 arg
<string name="webview_update_message">The WebView version is outdated (must be >= %1$s)</string> | |
<string name="webview_update_message">The WebView version is outdated (must be >= %s)</string> |
@@ -197,11 +220,85 @@ internal fun selectAnkiDroidFolder( | |||
} | |||
|
|||
fun selectAnkiDroidFolder(context: Context): AnkiDroidFolder { | |||
val canAccessLegacyStorage = Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || Environment.isExternalStorageLegacy() | |||
val currentFolderIsAccessibleAndLegacy = canAccessLegacyStorage && isLegacyStorage(context, setCollectionPath = false) == true | |||
val canAccessLegacyStorage = |
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.
ditto, please revert if this was an accidental change
@@ -260,5 +260,7 @@ | |||
</string> | |||
|
|||
<string name="deck_already_exists">Deck already exists</string> | |||
<string name="webview_update_message">The WebView version is outdated (must be >= %1$s)</string> | |||
<string name="older_webview_found_alert">Android System WebView is out of date. You may need to use com.google.android.webview</string> |
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.
I feel these strings should list the current package name and version, as is done on my suggested dialog in Discord
…Added buttons to Help Dialog and A Wiki Page." This reverts commit a0fe9f4.
…ttons to Help Dialog and A Wiki Page.
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.
Thanks, generally looks good, needs a bit of work on the messages
neutralButton(R.string.help_title_get_help) { | ||
// Show the HelpDialog | ||
val helpDialog = HelpDialog.newHelpInstance() | ||
helpDialog.show(fragmentManager, "HelpDialog") |
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.
@aayush-tripathi best to provide an AnkiActivity
here instead of a Context
if (versionCode < OLDEST_WORKING_WEBVIEW_VERSION) { | ||
showOutdatedWebViewDialog(context, fragmentManager, webviewPackageInfo.versionName) | ||
} |
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.
Move this check above if (webviewOlder == null) {
and invert it to return early if the condition is met
If a user is using a WebView with a valid version (even if it's an unexpected package), then we shouldn't block the user from using the app
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.
I don't think so that any version of com.android.webview
is valid.
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.
* inform the user with a dialog box containing further instructions. | ||
*/ | ||
fun checkWebviewVersion(packageManager: PackageManager, context: Context, fragmentManager: FragmentManager) { | ||
val webviewPackageInfo = getAndroidSystemWebViewPackageInfo(packageManager) ?: return |
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.
Could you add Timber.w
warnings if the user does have an outdated WebView
And a Timber.d
if the WebView is good
@@ -260,5 +260,7 @@ | |||
</string> | |||
|
|||
<string name="deck_already_exists">Deck already exists</string> | |||
<string name="webview_update_message">The Android System WebView is out of date\n\ncom.google.android.webview : %s</string> | |||
<string name="older_native_webview_found_alert">"The WebView Package com.android.webview is not supported.You must disable the existing WebView Package and Install com.google.android.webview\n\ncom.android.webview %s</string> |
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.
- I'd go back and use the strings I supplied on Discord
- Provide the package name as an argument
- Add a space after a full stop
@@ -260,5 +260,7 @@ | |||
</string> | |||
|
|||
<string name="deck_already_exists">Deck already exists</string> | |||
<string name="webview_update_message">The Android System WebView is out of date\n\ncom.google.android.webview : %s</string> |
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.
ditto, and remove the space before the colon
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.
One small change, then good to go I think, looks great!
neutralButton(R.string.help_title_get_help) { | ||
// Show the HelpDialog | ||
val helpDialog = HelpDialog.newHelpInstance() | ||
helpDialog.show(fragmentManager, "HelpDialog") |
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.
Still pending, change also needs to be applied in the other method
The branch seems to have conflict. Can you try fixing the conflict. |
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.
Nitpicks only, looks good, thanks!
// In case the user returns to the App without making the required updates to WebView | ||
// As without a "onResume()" , the dialog box is removed on resume. |
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.
move the comment above the line
} | ||
} | ||
|
||
private fun showOutdatedWebViewDialog(context: AnkiActivity, webview: PackageInfo) { |
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.
rename context
-> activity
} | ||
} | ||
|
||
private fun showNativeOutdatedWebViewDialog(context: AnkiActivity, webview: PackageInfo) { |
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.
ditto
Just a feedback @aayush-tripathi, next time instead of using |
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.
Build is failing
Pretty much there, thanks!
One minor comment-based change on the XML, then let's get this in
<string name="answering_error_report">Report error</string> | ||
<string name="storage_full_message">There is not enough free storage space to open AnkiDroid. Free up some space to continue. </string> | ||
<string name="storage_full_message">There is not enough free storage space to open AnkiDroid. Free up some space to continue. </string> | ||
<string name="repair_deck_dialog">Do you really want to try to repair the database?\n\nBefore starting the attempt, a copy will be created in subfolder “%s”.</string> | ||
<string name="intent_aedict_empty">Category “default” is empty</string> |
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.
Revert this, it'll ping our translators unnecessarily
@@ -271,3 +275,4 @@ also changes the interval of the card" | |||
<string name="range_delimiter" comment="Placed between two input boxes to denote a range">–</string> | |||
|
|||
</resources> | |||
|
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.
Revert - it'll be picked up by our translation sync
Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically |
Purpose / Description
Added dialog boxes which inform the users in older android devices of their old WebView versions (<=77) and also helps them update the WebView to a newer version.
Fixes
Approach
The earlier debug only test informed the devs whether the WebView version was outdated , I have worked on that further and have introduced a dialog box for the users with a link to Wiki (Exact page can be changed by modifying the
const val WEBVIEW_UPDATION_LINK with information regarding updating to the latest version.
Also , I tried to differentiate between the packages
com.android.webview
andcom.google.android.webview
as this requires special steps :com.android.webview
has to be disabled andcom.google.android.webview
has to be installed as of #15847 (comment).How Has This Been Tested?
Unit Tests (./gradlew jacocoUnitTestReport)
Ran on a virtual device (Android 7.0 , API 24 ) containing an older webview version to ensure the dialog box works
( I was unable to test whether the dialog box works for devices having "com.android.webview" )
oldwebviewerror.1.mp4
Checklist
Please, go through these checks before submitting the PR.