From 7f0a8e3de6dddfc3e0fec3fb2637520200c4b286 Mon Sep 17 00:00:00 2001 From: Tommy Nyquist Date: Wed, 17 Oct 2018 18:23:42 +0000 Subject: [PATCH] Revert "Update UI for unsupported Android OS and make Jelly Bean unsupported." This reverts commit 601b3e3a12f9cd79a051aab197278eb3daa6f79d. Reason for revert: Breaks Chrome Custom Tabs. Original change's description: > Update UI for unsupported Android OS and make Jelly Bean unsupported. > > This CL updates the UI to show a badge icon in the app menu icon > whenever the user is running Chrome on a currently unsupported Android > version. This badge in the app menu is only displayed once, until the > user taps the app menu icon. If the user does in fact get a new version, > the badge state is reset, and will be shown again. The current behavior > for out of date users stays the same as before (once per cold start). > > In addition, a new menu item is displayed at the top of the menu that > explains that Chrome is unable to update. Nothing happens when you tap > the menu item in the case of an unsupported OS version. > > The new menu item and the new warning message in About Chrome will > always be displayed when the user is in this state, regardless of > whether the app menu has already been tapped (which removes the badge). > > This CL also updates the UI in Settings - About Chrome to show a new > message and a warning icon when the user is running Chrome on an > unsupported version of the Android OS. > > By default, Jelly Bean is considered unsupported after this CL, but this > can be overridden from the variations framework. > > It is possible to use command line flags or chrome://flags for > testing the different states, though that does not impact the > About Chrome screen. > > Binary-Size: This CL adds new assets and the minimal code required. > Bug: 847940 > Change-Id: If128e1692b66c5804928183718000aaf1e2ffaa6 > Reviewed-on: https://chromium-review.googlesource.com/c/1243167 > Commit-Queue: Tommy Nyquist > Reviewed-by: Theresa > Cr-Original-Commit-Position: refs/heads/master@{#599369}(cherry picked from commit 5423fd8ab9355223e880007e08c1df4fcd3208fe) > Reviewed-on: https://chromium-review.googlesource.com/c/1279959 > Reviewed-by: Tommy Nyquist > Cr-Commit-Position: refs/branch-heads/3578@{#15} > Cr-Branched-From: 4226ddf99103e493d7afb23a4c7902ee496108b6-refs/heads/master@{#599034} TBR=nyquist@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: 847940 Change-Id: Iec0d8b4c07f123597f4883d1be3f14c3207e7c05 Reviewed-on: https://chromium-review.googlesource.com/c/1286281 Reviewed-by: Tommy Nyquist Cr-Commit-Position: refs/branch-heads/3578@{#92} Cr-Branched-From: 4226ddf99103e493d7afb23a4c7902ee496108b6-refs/heads/master@{#599034} --- .../ic_error_grey800_24dp_filled.png | Bin 325 -> 0 bytes .../ic_error_white_24dp_filled.png | Bin 302 -> 0 bytes .../ic_error_grey800_24dp_filled.png | Bin 227 -> 0 bytes .../ic_error_white_24dp_filled.png | Bin 204 -> 0 bytes .../ic_error_grey800_24dp_filled.png | Bin 371 -> 0 bytes .../ic_error_white_24dp_filled.png | Bin 353 -> 0 bytes .../ic_error_grey800_24dp_filled.png | Bin 543 -> 0 bytes .../ic_error_white_24dp_filled.png | Bin 512 -> 0 bytes .../ic_error_grey800_24dp_filled.png | Bin 707 -> 0 bytes .../ic_error_white_24dp_filled.png | Bin 707 -> 0 bytes .../os_version_unsupported_preference.xml | 39 --- .../java/res/layout/toolbar_tablet.xml | 6 +- chrome/android/java/res/values-v17/styles.xml | 3 + .../java/res/xml/about_chrome_preferences.xml | 2 +- .../chrome/browser/ChromeActivity.java | 3 +- .../chrome/browser/ChromeFeatureList.java | 1 - .../chrome/browser/ChromeSwitches.java | 17 +- .../chrome/browser/SingleTabActivity.java | 2 +- .../browser/appmenu/AppMenuAdapter.java | 9 +- .../browser/customtabs/CustomTabActivity.java | 3 +- .../browser/omaha/UpdateMenuItemHelper.java | 326 ++++-------------- .../browser/omaha/VersionNumberGetter.java | 15 - .../AboutChromePreferenceOSVersion.java | 36 -- .../preferences/AboutChromePreferences.java | 15 + .../preferences/ChromePreferenceManager.java | 24 +- .../toolbar/BottomToolbarCoordinator.java | 12 +- .../chrome/browser/toolbar/MenuButton.java | 86 +---- .../chrome/browser/toolbar/ToolbarLayout.java | 80 +++-- .../browser/toolbar/ToolbarManager.java | 34 +- .../chrome/browser/toolbar/ToolbarPhone.java | 15 +- .../chrome/browser/toolbar/ToolbarTablet.java | 2 +- .../java/strings/android_chrome_strings.grd | 11 +- chrome/android/java_sources.gni | 1 - chrome/browser/about_flags.cc | 16 +- chrome/browser/android/chrome_feature_list.cc | 4 - chrome/browser/android/chrome_feature_list.h | 1 - chrome/browser/flag_descriptions.cc | 15 +- chrome/browser/flag_descriptions.h | 7 +- chrome/common/chrome_switches.cc | 4 +- chrome/common/chrome_switches.h | 2 +- tools/metrics/histograms/enums.xml | 1 - 41 files changed, 180 insertions(+), 612 deletions(-) delete mode 100644 chrome/android/java/res/drawable-hdpi/ic_error_grey800_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-hdpi/ic_error_white_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-mdpi/ic_error_grey800_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-mdpi/ic_error_white_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-xhdpi/ic_error_grey800_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-xhdpi/ic_error_white_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-xxhdpi/ic_error_grey800_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-xxhdpi/ic_error_white_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-xxxhdpi/ic_error_grey800_24dp_filled.png delete mode 100644 chrome/android/java/res/drawable-xxxhdpi/ic_error_white_24dp_filled.png delete mode 100644 chrome/android/java/res/layout/os_version_unsupported_preference.xml delete mode 100644 chrome/android/java/src/org/chromium/chrome/browser/preferences/AboutChromePreferenceOSVersion.java diff --git a/chrome/android/java/res/drawable-hdpi/ic_error_grey800_24dp_filled.png b/chrome/android/java/res/drawable-hdpi/ic_error_grey800_24dp_filled.png deleted file mode 100644 index bf2b62a88bc180c9e5c10cd55bf9bb5627ccd345..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 325 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k3?#4J%UA`Z>;rs4T!FNMi%Ua8gRO&$LqdYB zql=A$3y=+D{Qv*o&dJ5b5y*80B0C@hBA9`_OR$STV>-&ZF z#&W3oaJ_F$Y0(o|7i&{6>-?PdF5Xvm8pniXHL@W|3_G_?yvazd`{51 zy7T;=$0vt)b*cY4u`t@ZFHfj5TXT|c(u5;so=%hQs4#jaO}0^~?D?{0{_4q=)qZXa zl}i{Ja)lb_DgW4{z|FIrYv0QU-;VM#)h*d@xKrkHVPectX`QQjy>Fg4-vPRp!PC{x JWt~$(69Bkhe*FLd diff --git a/chrome/android/java/res/drawable-hdpi/ic_error_white_24dp_filled.png b/chrome/android/java/res/drawable-hdpi/ic_error_white_24dp_filled.png deleted file mode 100644 index fa6ac058487a1ab0d889f762d681ed8b85f41b56..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 302 zcmV+}0nz@6P)Nkl3LPgCwn6I=5kf%NNV_$tK1Jh$nrLg+O|i|IVBa zb`KHNh(a`C5Q|J9Hayeeoq9=;2I&w-@wo6!lUwGBj5MDSX>*8FNKg6bk?J3rf$}rV zlJdP-jy`?PEKi%VnnsG``Fhjs{_sINb)q*hLLJ59Mb!E7i*F~=#cX=6ppZjqPDl|b zB@|GckQNZqoRAR^GMtbV5VD-mBp@`cP3V(h$e4{W^N<-TkKvbnarkAg1cpql`RI^8 zTsKmF$QNkxCG0kfeEDmT{6$gzDlPxB;b8B40gX03p%wTOegFUf07*qoM6N<$f+aPA Ad;kCd diff --git a/chrome/android/java/res/drawable-mdpi/ic_error_grey800_24dp_filled.png b/chrome/android/java/res/drawable-mdpi/ic_error_grey800_24dp_filled.png deleted file mode 100644 index 37100ae23652f84dade8942f6ba63cae5df95f1e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbMaAsRa0hxB}_4v@{z>7h6XcdnZ>L zM`s%+S0LNg!MUNK!N$S)|Ns9BI%GnC>bOdR{DK)+m);D#6WaBeY5fn*<3Q0APZ!6K zinzHK9l013Ian_QUOw}#{yyWx6-&hart%-zcfZ(SLI@{om`0AEp755e;4Eo@_s+*; zZVO#*V6Ng%C=j@P@Cc*v0_Ic&_OlDh6}%PM&omq_?U&yZKFNE}^?CfIHgB`*Ob+qL UZd)Jr185(Er>mdKI;Vst0E-|^@Bjb+ diff --git a/chrome/android/java/res/drawable-mdpi/ic_error_white_24dp_filled.png b/chrome/android/java/res/drawable-mdpi/ic_error_white_24dp_filled.png deleted file mode 100644 index d9506cb6379a15ad37a75998b049b814fb24faa6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 204 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjlRaG=Ln?0FoqCY-fC7(e_k%E7 z5vxY_=|%lKq6OUS9`y&4y*5a3{r%wQBq!m!t=`>5=|lrV^R+~WzdHML=Q)U4i!PaX zh*3n+pYfoG#8KbQTHVi{{k&V>)!3ht-mI>W)x?t$c44w9qprvVwFj+C*I05FE~r&X zh!i)QWg}ZuzwDj-+0u|5eAeF!-)<|Y34gY}nDIosc!o*miS(bd+$*~Zbu#?jf$ z%?-%4ad5G9bOExRoILHFK(hb;|F;3Eac~I@4F#)o0dqm(Id?5$fToC)1o;Is)O}uB zB-XV5Cbx3nbH;y{IajUx^kt*du_tH~Ja4b7p7K%%#WoesG!?7kS7#u;T5$OX8|Q31+#z^ELzh#o+1c=d#Wzp$PyQ C%#{QH diff --git a/chrome/android/java/res/drawable-xhdpi/ic_error_white_24dp_filled.png b/chrome/android/java/res/drawable-xhdpi/ic_error_white_24dp_filled.png deleted file mode 100644 index a5826be767530d4ec85d01cb58adb1007c6a7b66..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 353 zcmV-n0iOPeP)~QU5)=%Fd{25!WGDAwV*Vb2 zAd~?BG-^ zb-NOcuz^v4kTqh{5D#1e5Nl3=gJFOpXI2T^0uVYSfMFcKqy(^x1K5-Rj&T5&62LPK z;8Oww#sNa_0Y10rLJs)i(q5x{v1tPtUrgFmf-k!3$z1o->FyUaT`wuSU(|QKtaZ4lW>Fb`Gu%zP`3j z5M3aRwhkcK|NsAQ@cFVDXpMYHkY6yv&qG|t-?)m+t6bo5zvwsHdx@oXe>OQB$rmX& zdeDAzirmd81_nkSPZ!6Kid%1{v-YtV^02g5R?hhK@Bc~V#4Y!HE^T_SKrSHhxa=RZ zf1R5*dCfB6xvaMGl+H7qpAxMG9M=uMU$fa|%yRDTVeiZC6`orxv-8R$cHX~Z^Hr2R zCR_ac%A<;JUj`IwK5!}ASiOw3k7shJ9rGN?oMNp9j)^zZD?Sz-e=QcbW$T-ru@6s% z?weU&Q9RwoHs#*FMj!nSB{vbyQsy3x^P#EFUG4_k+7vG;mYZ?rfs2If_FE#d`Q#w8sFDwF=|8sm*e=|mSW9C-VtlnvPub1ENdA0rc z!PG|M(?_Kg+3cKNv`gKcu~g#E2@S87$8qNCc27Ppe^|mHVN%laOB0S6FfV3cxcMsZ V{BDKhfvrmpbL~x1C5-g1Tql> zGE?3@*a!kym}&y$P(lwhl4}AL5d|tVfy#&im6||JM1dMjpjSkJUYbB{M1fjOARAF2 zJ24Og@lVYCMVc4sM&hB--6+OGse9CjheG$T8V|XC+z~z&ruu2 z89)Pp<~TX|0ND^V4hac%Zf-Wt&Ol`E1X2T33{_mIEGZj zy}jwaX|aJwYoai(TKe-J2fn@h`+mK;Z5F4_gDGFx{z(5g)uy$iI{cKbu5RQq>B?=B z*Iu8QTs<*6%H=@De8-OeT+Qj(1`QUT`7d5hQ~T(npzp;KCiau(L7e%Ih~WFnnQqHY zxs|KV*v~x0+U6MZZ(+BRTm3A3c5ct)k2B2Xb}PTRg88|&T8ZsyCVNq}(7!7fpK}SX zo>F)CS=Y%}(RqhIHc7_z$ur7t{$$TseJ01AXOI7kn=cJHWDIs67TCbLFxS4|e&PoE z|A!KGSL+8fGcI_?{HcxEq>?|NfqB6M=E9Rqry{si5*R&}IGkb*l1#W$ap3F(2H6S* zE6xu|O!}Mx28|9ZYbJ2EOkY{R;PH4b0UAe>bbx1U2Ig;FYdn$ VrpvOXm?eOcfv2mV%Q~loCIDT;5!V0! diff --git a/chrome/android/java/res/drawable-xxxhdpi/ic_error_white_24dp_filled.png b/chrome/android/java/res/drawable-xxxhdpi/ic_error_white_24dp_filled.png deleted file mode 100644 index b1aae4d4e66f769cd167753676713a405438a552..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 707 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wSy#D0(?STf%N|Y1vU=OLOYrzfbP&L z3GxeO;B*zabU)|kt_gw{{!M1IoAZV}{m#RJr{4DhHn6>yK62$Fhpd{9Z(qM$(X2)G z3=E7%JY5_^D&pSWbl^7ma+!4Hw#jR+&rGhKm>uPEAY;B`$A7No^lXC$3(x!)FQ=(}^ik0F;t3P`$@3u2 z{6|Fa{pC!zWvATARcGvHo?>ltjQO{)Tgk0{mOeYTXY$7xW^=oh-(11`TwATgb~Tf| zs9NaX6^zfhgjY|gJN&HcWUT1C!ylU@WBcS8 - - - - - - - - - - - diff --git a/chrome/android/java/res/layout/toolbar_tablet.xml b/chrome/android/java/res/layout/toolbar_tablet.xml index e4aacfc25a0a5..1ec3e2f2dd67b 100644 --- a/chrome/android/java/res/layout/toolbar_tablet.xml +++ b/chrome/android/java/res/layout/toolbar_tablet.xml @@ -68,7 +68,7 @@ android:contentDescription="@string/accessibility_toolbar_btn_tabswitcher_toggle_default" android:visibility="gone" /> - @@ -78,7 +78,6 @@ style="@style/ToolbarMenuButtonTablet" android:src="@drawable/ic_more_vert_black_24dp" android:contentDescription="@string/accessibility_toolbar_btn_menu" - android:layout_gravity="center" app:tint="@color/dark_mode_tint" /> - + diff --git a/chrome/android/java/res/values-v17/styles.xml b/chrome/android/java/res/values-v17/styles.xml index 077aeee26a239..c7e74099d942c 100644 --- a/chrome/android/java/res/values-v17/styles.xml +++ b/chrome/android/java/res/values-v17/styles.xml @@ -207,6 +207,9 @@ 8dp diff --git a/chrome/android/java/res/xml/about_chrome_preferences.xml b/chrome/android/java/res/xml/about_chrome_preferences.xml index e1ddc3099473e..5b8de44f99edb 100644 --- a/chrome/android/java/res/xml/about_chrome_preferences.xml +++ b/chrome/android/java/res/xml/about_chrome_preferences.xml @@ -7,7 +7,7 @@ - () { @Override protected Void doInBackground() { - if (setForcedUpdateData()) return null; - if (VersionNumberGetter.isNewerVersionAvailable(activity)) { mUpdateUrl = MarketURLGetter.getMarketUrl(activity); mLatestVersion = VersionNumberGetter.getInstance().getLatestKnownVersion(activity); - boolean hasSufficientStorage = checkForSufficientStorage(); - mUpdateType = - hasSufficientStorage ? UpdateType.UPDATE_AVAILABLE : UpdateType.NONE; - // If a new version is available, we should later possibly show the OS not - // supported badge, so we need to clear the preference for now. - ChromePreferenceManager.getInstance().removeKey( - ChromePreferenceManager.LATEST_UNSUPPORTED_VERSION); - return null; - } - - if (!VersionNumberGetter.isCurrentOsVersionSupported()) { - mUpdateType = UpdateType.UNSUPPORTED_OS_VERSION; - mLatestUnsupportedVersionPreference = - ChromePreferenceManager.getInstance().readString( - ChromePreferenceManager.LATEST_UNSUPPORTED_VERSION, null); - return null; + mUpdateAvailable = checkForSufficientStorage(); + } else { + mUpdateAvailable = false; } - - mUpdateType = UpdateType.NONE; return null; } - /** - * @return true if all the update related data should be forced to specific values. - */ - private boolean setForcedUpdateData() { - String forcedUpdateType = - getStringParamValue(ChromeSwitches.FORCE_UPDATE_MENU_UPDATE_TYPE); - if (TextUtils.isEmpty(forcedUpdateType)) return false; - - switch (forcedUpdateType) { - case NONE_SWITCH_VALUE: - mUpdateType = UpdateType.NONE; - break; - case UPDATE_AVAILABLE_SWITCH_VALUE: - mUpdateType = UpdateType.UPDATE_AVAILABLE; - String testMarketUrl = - getStringParamValue(ChromeSwitches.MARKET_URL_FOR_TESTING); - if (!TextUtils.isEmpty(testMarketUrl)) mUpdateUrl = testMarketUrl; - break; - case UNSUPPORTED_OS_VERSION_SWITCH_VALUE: - mUpdateType = UpdateType.UNSUPPORTED_OS_VERSION; - // Even in the forced case, ensure that it is possible to read and write - // the pref, since the FORCE_SHOW_UPDATE_MENU_BADGE might not be set. - mLatestUnsupportedVersionPreference = - ChromePreferenceManager.getInstance().readString( - ChromePreferenceManager.LATEST_UNSUPPORTED_VERSION, null); - break; - default: - // If the forced parameter or variation is set, but invalid, we should still - // early out of the calculation. This enables testing of the no-op state. - mUpdateType = UpdateType.UNKNOWN; - break; - } - return true; - } - @Override protected void onPostExecute(Void result) { if (activity.isActivityDestroyed()) return; - activity.onCheckForUpdate(); + activity.onCheckForUpdate(mUpdateAvailable); recordUpdateHistogram(); } } @@ -324,22 +147,19 @@ public void onStart() { } /** - * @param context The current context. + * @param activity The current {@link ChromeActivity}. * @return Whether the update menu item should be shown. */ - public boolean shouldShowMenuItem(Context context) { - switch (getUpdateType()) { - case UpdateType.UPDATE_AVAILABLE: - return isGooglePlayStoreAvailable(context); - case UpdateType.UNSUPPORTED_OS_VERSION: - return true; - case UpdateType.NONE: - // Intentional fall through. - case UpdateType.UNKNOWN: - // Intentional fall through. - default: - return false; + public boolean shouldShowMenuItem(ChromeActivity activity) { + if (getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_ITEM)) { + return true; } + + if (!isGooglePlayStoreAvailable(activity)) { + return false; + } + + return updateAvailable(activity); } private static boolean isGooglePlayStoreAvailable(Context context) { @@ -353,33 +173,40 @@ private static boolean isGooglePlayStoreAvailable(Context context) { } /** - * @param context The current context. + * @param context The current {@link Context}. + * @return The string to use for summary text or the empty string if no summary should be shown. + */ + public String getMenuItemSummaryText(Context context) { + String customSummary = getStringParamValue(CUSTOM_SUMMARY); + if (!TextUtils.isEmpty(customSummary)) { + return customSummary; + } + + return context.getResources().getString(R.string.menu_update_summary_default); + } + + /** + * @param activity The current {@link ChromeActivity}. * @return Whether the update badge should be shown in the toolbar. */ - public boolean shouldShowToolbarBadge(Context context) { - if (getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_BADGE)) return true; - - switch (getUpdateType()) { - case UpdateType.UPDATE_AVAILABLE: - if (!isGooglePlayStoreAvailable(context)) return false; - // The badge is hidden if the update menu item has been clicked until there is an - // even newer version of Chrome available. - String latestVersionWhenClicked = - PrefServiceBridge.getInstance().getLatestVersionWhenClickedUpdateMenuItem(); - return !TextUtils.equals(latestVersionWhenClicked, mLatestVersion); - case UpdateType.UNSUPPORTED_OS_VERSION: - // We should show the badge if the user has not opened the menu. - if (mLatestUnsupportedVersionPreference == null) return true; - - // In case the user has been upgraded since last time they tapped the toolbar badge - // we should show the badge again. - String currentlyUsedVersion = BuildInfo.getInstance().versionName; - return !TextUtils.equals(mLatestUnsupportedVersionPreference, currentlyUsedVersion); - case UpdateType.NONE: // Intentional fall through. - case UpdateType.UNKNOWN: // Intentional fall through. - default: - return false; + public boolean shouldShowToolbarBadge(ChromeActivity activity) { + if (getBooleanParam(ChromeSwitches.FORCE_SHOW_UPDATE_MENU_BADGE)) { + return true; } + + if (!isGooglePlayStoreAvailable(activity)) { + return false; + } + + // The badge is hidden if the update menu item has been clicked until there is an + // even newer version of Chrome available. + String latestVersionWhenClicked = + PrefServiceBridge.getInstance().getLatestVersionWhenClickedUpdateMenuItem(); + if (TextUtils.equals(latestVersionWhenClicked, mLatestVersion)) { + return false; + } + + return updateAvailable(activity); } /** @@ -387,7 +214,6 @@ public boolean shouldShowToolbarBadge(Context context) { * @param activity The current {@link ChromeActivity}. */ public void onMenuItemClicked(ChromeActivity activity) { - if (mUpdateType != UpdateType.UPDATE_AVAILABLE) return; if (mUpdateUrl == null) return; // If the update menu item is showing because it was forced on through about://flags @@ -427,25 +253,6 @@ public void onMenuDismissed() { mMenuItemClicked = false; } - /** - * Called when the user clicks the app menu button while the unsupported OS badge is showing. - */ - public void onMenuButtonClicked() { - if (mUpdateType != UpdateType.UNSUPPORTED_OS_VERSION) return; - - // If we have already stored the current version to a preference, no need to store it again, - // unless their Chrome version has changed. - String currentlyUsedVersion = BuildInfo.getInstance().versionName; - if (mLatestUnsupportedVersionPreference != null - && mLatestUnsupportedVersionPreference.equals(currentlyUsedVersion)) { - return; - } - - ChromePreferenceManager.getInstance().writeString( - ChromePreferenceManager.LATEST_UNSUPPORTED_VERSION, currentlyUsedVersion); - mLatestUnsupportedVersionPreference = currentlyUsedVersion; - } - /** * Creates an {@link AnimatorSet} for showing the update badge that is displayed on top * of the app menu button. @@ -532,12 +339,13 @@ public void onAnimationCancel(Animator animation) { return set; } - /** - * @return The current {@link UpdateType}. Will be {@link UpdateType#UNKNOWN} until it has been - * fetched on a background thread. - */ - public @UpdateType int getUpdateType() { - return mUpdateType; + private boolean updateAvailable(ChromeActivity activity) { + if (!mAlreadyCheckedForUpdates) { + checkForUpdateOnBackgroundThread(activity); + return false; + } + + return mUpdateAvailable; } private void recordItemClickedHistogram(int action) { @@ -549,8 +357,7 @@ private void recordUpdateHistogram() { if (PrefServiceBridge.getInstance().getClickedUpdateMenuItem()) { RecordHistogram.recordEnumeratedHistogram( "GoogleUpdate.MenuItem.ActionTakenAfterItemClicked", - mUpdateType == UpdateType.UPDATE_AVAILABLE ? NOT_UPDATED : UPDATED, - UPDATED_BOUNDARY); + mUpdateAvailable ? NOT_UPDATED : UPDATED, UPDATED_BOUNDARY); PrefServiceBridge.getInstance().setClickedUpdateMenuItem(false); } } @@ -576,7 +383,6 @@ private static boolean getBooleanParam(String paramName) { * @param paramName The name of the parameter (or command-line switch) to get a value for. * @return The command-line flag value if present, or the param is value if present. */ - @Nullable private static String getStringParamValue(String paramName) { String value = CommandLine.getInstance().getSwitchValue(paramName); if (TextUtils.isEmpty(value)) { diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java b/chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java index 0bcacf3f5f303..f5431d56c956b 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java @@ -6,12 +6,10 @@ import android.content.Context; import android.content.SharedPreferences; -import android.os.Build; import org.chromium.base.BuildInfo; import org.chromium.base.ThreadUtils; import org.chromium.base.VisibleForTesting; -import org.chromium.chrome.browser.ChromeFeatureList; /** * Stubbed class for getting version numbers from the rest of Chrome. Override the functions for @@ -92,19 +90,6 @@ public static int getMilestoneFromVersionNumber(String version) { } } - /** - * @return Whether the current Android OS version is supported. - */ - public static boolean isCurrentOsVersionSupported() { - // By default, only Android KitKat and above is supported. - int oldestSupportedVersion = Build.VERSION_CODES.KITKAT; - - if (ChromeFeatureList.isEnabled(ChromeFeatureList.JELLY_BEAN_SUPPORTED)) { - oldestSupportedVersion = Build.VERSION_CODES.JELLY_BEAN; - } - return Build.VERSION.SDK_INT >= oldestSupportedVersion; - } - /** * Checks if we know about a newer version available than the one we're using. This does not * actually fire any requests over to the server: it just checks the version we stored the last diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/AboutChromePreferenceOSVersion.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/AboutChromePreferenceOSVersion.java deleted file mode 100644 index ba5c625fac12b..0000000000000 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/AboutChromePreferenceOSVersion.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.chrome.browser.preferences; - -import android.content.Context; -import android.preference.Preference; -import android.util.AttributeSet; -import android.view.View; - -import org.chromium.chrome.R; -import org.chromium.chrome.browser.omaha.VersionNumberGetter; - -/** - * Preference specifically made for the Android OS version. It supports displaying a warning when - * the current OS version is unsupported. - */ -public class AboutChromePreferenceOSVersion extends Preference { - /** - * Constructor for inflating from XML. - */ - public AboutChromePreferenceOSVersion(Context context, AttributeSet attrs) { - super(context, attrs); - setLayoutResource(R.layout.os_version_unsupported_preference); - } - - @Override - protected void onBindView(View view) { - super.onBindView(view); - // Show additional information only if the OS version is not supported. - if (VersionNumberGetter.isCurrentOsVersionSupported()) return; - - view.findViewById(R.id.os_deprecation_warning).setVisibility(View.VISIBLE); - } -} diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/AboutChromePreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/AboutChromePreferences.java index 4fa819207e988..20b5935d7a376 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/AboutChromePreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/AboutChromePreferences.java @@ -4,13 +4,16 @@ package org.chromium.chrome.browser.preferences; +import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.os.Build; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; import android.text.format.DateUtils; +import android.view.ContextThemeWrapper; import org.chromium.chrome.R; import org.chromium.chrome.browser.ChromeVersionInfo; @@ -27,12 +30,24 @@ public class AboutChromePreferences extends PreferenceFragment { private static final String PREF_OS_VERSION = "os_version"; private static final String PREF_LEGAL_INFORMATION = "legal_information"; + @SuppressLint("ObsoleteSdkInt") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActivity().setTitle(R.string.prefs_about_chrome); PreferenceUtils.addPreferencesFromResource(this, R.xml.about_chrome_preferences); + // TODO(crbug.com/635567): Fix this properly. + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { + ChromeBasePreference deprecationWarning = new ChromeBasePreference( + new ContextThemeWrapper(getActivity(), + R.style.DeprecationWarningPreferenceTheme)); + deprecationWarning.setOrder(-1); + deprecationWarning.setTitle(R.string.deprecation_warning); + deprecationWarning.setIcon(R.drawable.exclamation_triangle); + getPreferenceScreen().addPreference(deprecationWarning); + } + PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance(); AboutVersionStrings versionStrings = prefServiceBridge.getAboutVersionStrings(); Preference p = findPreference(PREF_APPLICATION_VERSION); diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceManager.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceManager.java index d9ad21acab421..69e4791e524e7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/ChromePreferenceManager.java @@ -5,7 +5,6 @@ package org.chromium.chrome.browser.preferences; import android.content.SharedPreferences; -import android.support.annotation.Nullable; import org.chromium.base.ContextUtils; import org.chromium.chrome.browser.crash.MinidumpUploadService.ProcessType; @@ -223,14 +222,6 @@ public class ChromePreferenceManager { */ public static final String ACCESSIBILITY_TAB_SWITCHER = "accessibility_tab_switcher"; - /** - * When the user is shown a badge that the current Android OS version is unsupported, and they - * tap it to display the menu (which has additional information), we store the current version - * of Chrome to this preference to ensure we only show the badge once. The value is cleared - * if the Chrome version later changes. - */ - public static final String LATEST_UNSUPPORTED_VERSION = "android_os_unsupported_chrome_version"; - /** * Deprecated keys for Chrome Home. */ @@ -571,29 +562,18 @@ public boolean readBoolean(String key, boolean defaultValue) { * @param key The name of the preference to modify. * @param value The new value for the preference. */ - public void writeString(String key, String value) { + private void writeString(String key, String value) { SharedPreferences.Editor ed = mSharedPreferences.edit(); ed.putString(key, value); ed.apply(); } - /** - * Reads the given String value from the named shared preference. - * - * @param key The name of the preference to return. - * @param defaultValue The default value to return if there's no value stored. - * @return The value of the preference if stored; defaultValue otherwise. - */ - public String readString(String key, @Nullable String defaultValue) { - return mSharedPreferences.getString(key, defaultValue); - } - /** * Removes the shared preference entry. * * @param key The key of the preference to remove. */ - public void removeKey(String key) { + private void removeKey(String key) { SharedPreferences.Editor ed = mSharedPreferences.edit(); ed.remove(key); ed.apply(); diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/BottomToolbarCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/BottomToolbarCoordinator.java index 37b2647188b43..28efe5c1f13ea 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/BottomToolbarCoordinator.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/BottomToolbarCoordinator.java @@ -153,14 +153,14 @@ public void initializeWithNative(ResourceManager resourceManager, LayoutManager * Show the update badge over the bottom toolbar's app menu. */ public void showAppMenuUpdateBadge() { - mMenuButton.setUpdateBadgeVisibilityIfValidState(true); + mMenuButton.setUpdateBadgeVisibility(true); } /** * Remove the update badge. */ public void removeAppMenuUpdateBadge() { - mMenuButton.setUpdateBadgeVisibilityIfValidState(false); + mMenuButton.setUpdateBadgeVisibility(false); } /** @@ -179,11 +179,8 @@ public void setToolbarSwipeLayout(ToolbarSwipeLayout layout) { mMediator.setToolbarSwipeLayout(layout); } - /** - * @return The wrapper for the app menu button. - */ - public MenuButton getMenuButtonWrapper() { - return mMenuButton; + public View getMenuButton() { + return mMenuButton.getMenuButton(); } public void setIncognito(boolean isIncognito) { @@ -192,7 +189,6 @@ public void setIncognito(boolean isIncognito) { final ColorStateList tint = isIncognito ? mLightModeTint : mDarkModeTint; mTabSwitcherButtonCoordinator.setTint(tint); mMenuButton.setTint(tint); - mMenuButton.setUseLightDrawables(isIncognito); } /** diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/MenuButton.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/MenuButton.java index 9ccbccfdcc9e8..628051cf6f11d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/MenuButton.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/MenuButton.java @@ -6,16 +6,13 @@ import android.content.Context; import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; import android.support.v7.widget.AppCompatImageButton; import android.util.AttributeSet; import android.view.View; import android.widget.FrameLayout; -import android.widget.ImageView; import org.chromium.base.ApiCompatibilityUtils; import org.chromium.chrome.R; -import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; /** * The overflow menu button. @@ -25,8 +22,7 @@ class MenuButton extends FrameLayout { private AppCompatImageButton mMenuImageButton; /** The view for the update badge. */ - private ImageView mUpdateBadgeView; - private boolean mUseLightDrawables; + private View mUpdateBadgeView; public MenuButton(Context context, AttributeSet attrs) { super(context, attrs); @@ -53,54 +49,10 @@ public void setAccessibilityDelegate(AccessibilityDelegate delegate) { } /** - * Sets the update badge to visible if the update state requires it. - * - * Also updates the visuals to the correct type for the case where {@link - * #setUseLightDrawables(boolean)} was invoked before the update state was known. This is the - * case on startup when the bottom toolbar is in use. - * - * @param visible Whether the update badge should be visible. Always sets visibility to GONE - * if the update type does not require a badge. - * TODO(crbug.com/865801): Clean this up when MenuButton and UpdateMenuItemHelper is MVCed. + * @param visible Whether the update badge should be visible. */ - void setUpdateBadgeVisibilityIfValidState(boolean visible) { - switch (UpdateMenuItemHelper.getInstance().getUpdateType()) { - case UpdateMenuItemHelper.UpdateType.UPDATE_AVAILABLE: - // Intentional fall through. - case UpdateMenuItemHelper.UpdateType.UNSUPPORTED_OS_VERSION: - mUpdateBadgeView.setVisibility(visible ? View.VISIBLE : View.GONE); - updateImageResources(); - break; - case UpdateMenuItemHelper.UpdateType.NONE: - // Intentional fall through. - case UpdateMenuItemHelper.UpdateType.UNKNOWN: - // Intentional fall through. - default: - mUpdateBadgeView.setVisibility(View.GONE); - break; - } - } - - /** - * Sets the visual type of update badge to use (if any). - * @param useLightDrawables Whether the light drawable should be used. - */ - void setUseLightDrawables(boolean useLightDrawables) { - mUseLightDrawables = useLightDrawables; - updateImageResources(); - } - - void updateImageResources() { - Drawable drawable; - if (mUseLightDrawables) { - drawable = UpdateMenuItemHelper.getInstance().getLightBadgeDrawable( - mUpdateBadgeView.getResources()); - } else { - drawable = UpdateMenuItemHelper.getInstance().getDarkBadgeDrawable( - mUpdateBadgeView.getResources()); - } - if (drawable == null) return; - mUpdateBadgeView.setImageDrawable(drawable); + void setUpdateBadgeVisibility(boolean visible) { + mUpdateBadgeView.setVisibility(visible ? View.VISIBLE : View.GONE); } /** @@ -110,38 +62,10 @@ boolean isShowingAppMenuUpdateBadge() { return mUpdateBadgeView.getVisibility() == View.VISIBLE; } - void updateContentDescription() { - if (isShowingAppMenuUpdateBadge()) { - switch (UpdateMenuItemHelper.getInstance().getUpdateType()) { - case UpdateMenuItemHelper.UpdateType.UPDATE_AVAILABLE: - setContentDescription(getResources().getString( - R.string.accessibility_toolbar_btn_menu_update)); - break; - case UpdateMenuItemHelper.UpdateType.UNSUPPORTED_OS_VERSION: - setContentDescription(getResources().getString( - R.string.accessibility_toolbar_btn_menu_os_version_unsupported)); - break; - case UpdateMenuItemHelper.UpdateType.NONE: - // Intentional fall through. - case UpdateMenuItemHelper.UpdateType.UNKNOWN: - // Intentional fall through. - default: - break; - } - } else { - setContentDescription( - getResources().getString(R.string.accessibility_toolbar_btn_menu)); - } - } - - AppCompatImageButton getImageButton() { + View getMenuButton() { return mMenuImageButton; } - View getUpdateBadge() { - return mUpdateBadgeView; - } - /** * @param tintList The {@link ColorStateList} that will tint the menu button (the badge is not * tinted). diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java index 937c0ded8bef5..72505262f1305 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarLayout.java @@ -25,6 +25,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.ProgressBar; import org.chromium.base.VisibleForTesting; @@ -60,9 +61,11 @@ public abstract class ToolbarLayout extends FrameLayout implements Toolbar { private final int[] mTempPosition = new int[2]; /** - * The app menu button. + * The ImageButton view that represents the menu button. */ - protected MenuButton mMenuButton; + protected AppCompatImageButton mMenuButton; + private ImageView mMenuBadge; + private View mMenuButtonWrapper; private AppMenuButtonHelper mAppMenuButtonHelper; protected final ColorStateList mDarkModeTint; @@ -143,16 +146,19 @@ protected ToolbarProgressBar createProgressBar() { * instance vars. */ public void disableMenuButton() { - View menuButtonWrapper = getMenuButtonWrapper(); - if (menuButtonWrapper != null) UiUtils.removeViewFromParent(menuButtonWrapper); + UiUtils.removeViewFromParent(getMenuButtonWrapper()); + mMenuButtonWrapper = null; mMenuButton = null; + mMenuBadge = null; } @Override protected void onFinishInflate() { super.onFinishInflate(); - mMenuButton = (MenuButton) findViewById(R.id.menu_button_wrapper); + mMenuButton = (AppCompatImageButton) findViewById(R.id.menu_button); + mMenuBadge = (ImageView) findViewById(R.id.menu_badge); + mMenuButtonWrapper = findViewById(R.id.menu_button_wrapper); // Initialize the provider to an empty version to avoid null checking everywhere. mToolbarDataProvider = new ToolbarDataProvider() { @@ -270,7 +276,7 @@ public void initialize(ToolbarDataProvider toolbarDataProvider, mAppMenuButtonHelper = appMenuButtonHelper; if (mMenuButton != null) { - mMenuButton.setTouchListener(mAppMenuButtonHelper); + mMenuButton.setOnTouchListener(mAppMenuButtonHelper); mMenuButton.setAccessibilityDelegate(mAppMenuButtonHelper); } } @@ -296,21 +302,21 @@ protected void onAttachedToWindow() { * @return The view containing the menu button and menu button badge. */ protected View getMenuButtonWrapper() { - return mMenuButton; + return mMenuButtonWrapper; } /** * @return The {@link AppCompatImageButton} containing the menu button. */ protected AppCompatImageButton getMenuButton() { - return mMenuButton == null ? null : mMenuButton.getImageButton(); + return mMenuButton; } /** * @return The view containing the menu badge. */ protected View getMenuBadge() { - return mMenuButton == null ? null : mMenuButton.getUpdateBadge(); + return mMenuBadge; } /** @@ -808,7 +814,6 @@ public void setMenuButtonHighlight(boolean highlight) { @Override public void showAppMenuUpdateBadge() { mShowMenuBadge = true; - mMenuButton.updateImageResources(); } @Override @@ -818,13 +823,13 @@ public boolean isShowingAppMenuUpdateBadge() { @Override public void removeAppMenuUpdateBadge(boolean animate) { - if (mMenuButton == null) return; + if (mMenuBadge == null) return; boolean wasShowingMenuBadge = mShowMenuBadge; mShowMenuBadge = false; - setMenuButtonContentDescription(); + setMenuButtonContentDescription(false); if (!animate || !wasShowingMenuBadge) { - mMenuButton.setUpdateBadgeVisibilityIfValidState(false); + mMenuBadge.setVisibility(View.GONE); return; } @@ -836,7 +841,7 @@ public void removeAppMenuUpdateBadge(boolean animate) { mMenuButton.setAlpha(0.f); mMenuBadgeAnimatorSet = UpdateMenuItemHelper.createHideUpdateBadgeAnimation( - mMenuButton, mMenuButton.getUpdateBadge()); + mMenuButton, mMenuBadge); mMenuBadgeAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override @@ -884,19 +889,19 @@ public void disableExperimentalButton() {} * bitmap. */ protected void setAppMenuUpdateBadgeToVisible(boolean animate) { - if (mMenuButton == null) return; - setMenuButtonContentDescription(); + if (mMenuBadge == null || mMenuButton == null) return; + setMenuButtonContentDescription(true); if (!animate || mIsMenuBadgeAnimationRunning) { - mMenuButton.setUpdateBadgeVisibilityIfValidState(true); + mMenuBadge.setVisibility(View.VISIBLE); return; } // Set initial states. - mMenuButton.getUpdateBadge().setAlpha(0.f); - mMenuButton.getUpdateBadge().setVisibility(View.VISIBLE); + mMenuBadge.setAlpha(0.f); + mMenuBadge.setVisibility(View.VISIBLE); mMenuBadgeAnimatorSet = UpdateMenuItemHelper.createShowUpdateBadgeAnimation( - mMenuButton, mMenuButton.getUpdateBadge()); + mMenuButton, mMenuBadge); mMenuBadgeAnimatorSet.addListener(new AnimatorListenerAdapter() { @Override @@ -926,12 +931,12 @@ protected void cancelAppMenuUpdateBadgeAnimation() { /** * Sets the update menu badge drawable to the light or dark asset. - * - * @param useLightDrawables Whether the light drawable should be used. + * @param useLightDrawable Whether the light drawable should be used. */ - protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawables) { - if (mMenuButton == null) return; - mMenuButton.setUseLightDrawables(useLightDrawables); + protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawable) { + if (mMenuBadge == null) return; + mMenuBadge.setImageResource(useLightDrawable ? R.drawable.badge_update_light + : R.drawable.badge_update_dark); } /** @@ -941,31 +946,36 @@ protected void setAppMenuUpdateBadgeDrawable(boolean useLightDrawables) { */ protected void setMenuButtonHighlightDrawable(boolean highlighting) { // Return if onFinishInflate didn't finish - if (mMenuButton == null) return; + if (mMenuButtonWrapper == null || mMenuButton == null) return; if (highlighting) { if (mHighlightDrawable == null) { mHighlightDrawable = PulseDrawable.createCircle(getContext()); - mHighlightDrawable.setInset( - ViewCompat.getPaddingStart(mMenuButton.getImageButton()), - mMenuButton.getImageButton().getPaddingTop(), - ViewCompat.getPaddingEnd(mMenuButton.getImageButton()), - mMenuButton.getImageButton().getPaddingBottom()); + mHighlightDrawable.setInset(ViewCompat.getPaddingStart(mMenuButton), + mMenuButton.getPaddingTop(), ViewCompat.getPaddingEnd(mMenuButton), + mMenuButton.getPaddingBottom()); } mHighlightDrawable.setUseLightPulseColor(useLightDrawables()); - mMenuButton.setBackground(mHighlightDrawable); + mMenuButtonWrapper.setBackground(mHighlightDrawable); mHighlightDrawable.start(); } else { - mMenuButton.setBackground(null); + mMenuButtonWrapper.setBackground(null); } } /** * Sets the content description for the menu button. + * @param isUpdateBadgeVisible Whether the update menu badge is visible. */ - protected void setMenuButtonContentDescription() { + protected void setMenuButtonContentDescription(boolean isUpdateBadgeVisible) { if (mMenuButton == null) return; - mMenuButton.updateContentDescription(); + if (isUpdateBadgeVisible) { + mMenuButton.setContentDescription(getResources().getString( + R.string.accessibility_toolbar_btn_menu_update)); + } else { + mMenuButton.setContentDescription(getResources().getString( + R.string.accessibility_toolbar_btn_menu)); + } } @Override diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java index f30b9ab4c4191..9f8d5bc718c6f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java @@ -63,7 +63,6 @@ import org.chromium.chrome.browser.ntp.IncognitoNewTabPage; import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; -import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; import org.chromium.chrome.browser.omnibox.LocationBar; import org.chromium.chrome.browser.omnibox.QueryInOmnibox; import org.chromium.chrome.browser.omnibox.UrlFocusChangeListener; @@ -631,24 +630,12 @@ public void onFindToolbarHidden() { public void onOverviewModeStartedShowing(boolean showToolbar) { mToolbar.setTabSwitcherMode(true, showToolbar, false); updateButtonStatus(); - - // For top toolbar we depend on animations instead. - if (mBottomToolbarCoordinator == null) return; - MenuButton menuButton = mBottomToolbarCoordinator.getMenuButtonWrapper(); - if (menuButton == null) return; - menuButton.setUpdateBadgeVisibilityIfValidState(false); } @Override public void onOverviewModeStartedHiding(boolean showToolbar, boolean delayAnimation) { mToolbar.setTabSwitcherMode(false, showToolbar, delayAnimation); updateButtonStatus(); - - // For top toolbar we depend on animations instead. - if (mBottomToolbarCoordinator == null) return; - MenuButton menuButton = mBottomToolbarCoordinator.getMenuButtonWrapper(); - if (menuButton == null) return; - menuButton.setUpdateBadgeVisibilityIfValidState(true); } @Override @@ -1053,9 +1040,7 @@ public boolean isInitialized() { * @return The view containing the pop up menu button. */ public View getMenuButton() { - if (mBottomToolbarCoordinator != null) { - return mBottomToolbarCoordinator.getMenuButtonWrapper().getImageButton(); - } + if (mBottomToolbarCoordinator != null) return mBottomToolbarCoordinator.getMenuButton(); if (mToolbar != null) return mToolbar.getMenuButton(); return null; } @@ -1248,11 +1233,6 @@ public void onMenuVisibilityChanged(boolean isVisible) { mControlsVisibilityDelegate.hideControlsPersistent(mFullscreenMenuToken); mFullscreenMenuToken = FullscreenManager.INVALID_TOKEN; } - - MenuButton menuButton = getMenuButtonWrapper(); - if (isVisible && menuButton != null && menuButton.isShowingAppMenuUpdateBadge()) { - UpdateMenuItemHelper.getInstance().onMenuButtonClicked(); - } } @Override @@ -1284,18 +1264,6 @@ public void onMenuHighlightChanged(boolean highlighting) { }); } - @Nullable - private MenuButton getMenuButtonWrapper() { - if (mBottomToolbarCoordinator != null) { - return mBottomToolbarCoordinator.getMenuButtonWrapper(); - } - - if (mToolbar == null) return null; - View menuButtonWrapper = mToolbar.getMenuButtonWrapper(); - if (menuButtonWrapper instanceof MenuButton) return (MenuButton) menuButtonWrapper; - return null; - } - /** * Set the delegate that will handle updates from toolbar driven state changes. * @param menuDelegatePhone The menu delegate to be updated (only applicable to phones). diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java index 41cc2a88790d1..218bf7ac5894a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarPhone.java @@ -64,7 +64,6 @@ import org.chromium.chrome.browser.fullscreen.BrowserStateBrowserControlsVisibilityDelegate; import org.chromium.chrome.browser.fullscreen.FullscreenManager; import org.chromium.chrome.browser.ntp.NewTabPage; -import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; import org.chromium.chrome.browser.omnibox.LocationBar; import org.chromium.chrome.browser.omnibox.LocationBarPhone; import org.chromium.chrome.browser.partnercustomizations.HomepageManager; @@ -1840,7 +1839,7 @@ private void updateViewsForTabSwitcherMode() { view.setVisibility(browsingViewsVisibility); } if (mShowMenuBadge) { - setMenuButtonContentDescription(); + setMenuButtonContentDescription(mTabSwitcherState == STATIC_TAB); } updateProgressBarVisibility(); @@ -2908,17 +2907,13 @@ private void setTabSwitcherAnimationMenuDrawable() { } private void setTabSwitcherAnimationMenuBadgeDrawable() { - Drawable darkDrawable = - UpdateMenuItemHelper.getInstance().getDarkBadgeDrawable(this.getResources()); - Drawable lightDrawable = - UpdateMenuItemHelper.getInstance().getLightBadgeDrawable(this.getResources()); - if (darkDrawable == null || lightDrawable == null) return; - - mTabSwitcherAnimationMenuBadgeDarkDrawable = darkDrawable; + mTabSwitcherAnimationMenuBadgeDarkDrawable = ApiCompatibilityUtils.getDrawable( + getResources(), R.drawable.badge_update_dark); mTabSwitcherAnimationMenuBadgeDarkDrawable.mutate(); ((BitmapDrawable) mTabSwitcherAnimationMenuBadgeDarkDrawable).setGravity(Gravity.CENTER); - mTabSwitcherAnimationMenuBadgeLightDrawable = lightDrawable; + mTabSwitcherAnimationMenuBadgeLightDrawable = ApiCompatibilityUtils.getDrawable( + getResources(), R.drawable.badge_update_light); mTabSwitcherAnimationMenuBadgeLightDrawable.mutate(); ((BitmapDrawable) mTabSwitcherAnimationMenuBadgeLightDrawable).setGravity(Gravity.CENTER); } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java index 950692cdb6914..f3f5f248523ba 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarTablet.java @@ -517,7 +517,7 @@ protected void setTabSwitcherMode( mLocationBar.getContainerView().setVisibility(View.INVISIBLE); if (mShowMenuBadge) { getMenuBadge().setVisibility(View.GONE); - setMenuButtonContentDescription(); + setMenuButtonContentDescription(false); } } else { mIsInTabSwitcherMode = false; diff --git a/chrome/android/java/strings/android_chrome_strings.grd b/chrome/android/java/strings/android_chrome_strings.grd index 02322d91aa55d..3a6503cbe926f 100644 --- a/chrome/android/java/strings/android_chrome_strings.grd +++ b/chrome/android/java/strings/android_chrome_strings.grd @@ -1413,7 +1413,7 @@ To obtain new licenses, connect to the internet and play your downloaded content Operating system - Chrome updates are no longer supported for this version of Android + Chrome updates are no longer supported for this version of Android. @@ -2926,12 +2926,6 @@ To change this setting, <resetlink>reset sync

Newer version is available - - Chrome can’t update - - - Android version is unsupported - Move to other window @@ -3184,9 +3178,6 @@ To change this setting, <resetlink>reset sync

Update available. More options - - Chrome can’t update. More options - Search diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni index f91f694ef3035..3911948caaa89 100644 --- a/chrome/android/java_sources.gni +++ b/chrome/android/java_sources.gni @@ -1185,7 +1185,6 @@ chrome_java_sources = [ "java/src/org/chromium/chrome/browser/photo_picker/PickerCategoryView.java", "java/src/org/chromium/chrome/browser/policy/PolicyAuditor.java", "java/src/org/chromium/chrome/browser/preferences/AboutChromePreferences.java", - "java/src/org/chromium/chrome/browser/preferences/AboutChromePreferenceOSVersion.java", "java/src/org/chromium/chrome/browser/preferences/AccessibilityPreferences.java", "java/src/org/chromium/chrome/browser/preferences/ButtonPreference.java", "java/src/org/chromium/chrome/browser/preferences/ChromeBaseCheckBoxPreference.java", diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index e219fadf7cc3e..1cad63e140e6c 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -432,16 +432,6 @@ const FeatureEntry::Choice kChromeHomeSwipeLogicChoices[] = { switches::kChromeHomeSwipeLogicType, "velocity"}, }; -const FeatureEntry::Choice kForceUpdateMenuTypeChoices[] = { - {flags_ui::kGenericExperimentChoiceDefault, "", ""}, - {flag_descriptions::kUpdateMenuTypeNone, switches::kForceUpdateMenuType, - "none"}, - {flag_descriptions::kUpdateMenuTypeUpdateAvailable, - switches::kForceUpdateMenuType, "update_available"}, - {flag_descriptions::kUpdateMenuTypeUnsupportedOSVersion, - switches::kForceUpdateMenuType, "unsupported_os_version"}, -}; - const FeatureEntry::FeatureParam kCCTModuleCache_ZeroMinutes[] = { {"cct_module_cache_time_limit_ms", "0"}}; const FeatureEntry::FeatureParam kCCTModuleCache_OneMinute[] = { @@ -2633,9 +2623,9 @@ const FeatureEntry kFeatureEntries[] = { flag_descriptions::kEnableImageCaptureAPIDescription, kOsAll, FEATURE_VALUE_TYPE(features::kImageCaptureAPI)}, #if defined(OS_ANDROID) - {"force-update-menu-type", flag_descriptions::kUpdateMenuTypeName, - flag_descriptions::kUpdateMenuTypeDescription, kOsAndroid, - MULTI_VALUE_TYPE(kForceUpdateMenuTypeChoices)}, + {"force-show-update-menu-item", flag_descriptions::kUpdateMenuItemName, + flag_descriptions::kUpdateMenuItemDescription, kOsAndroid, + SINGLE_VALUE_TYPE(switches::kForceShowUpdateMenuItem)}, {"update-menu-item-custom-summary", flag_descriptions::kUpdateMenuItemCustomSummaryName, flag_descriptions::kUpdateMenuItemCustomSummaryDescription, kOsAndroid, diff --git a/chrome/browser/android/chrome_feature_list.cc b/chrome/browser/android/chrome_feature_list.cc index a1299b58ee833..d46351c7f56f1 100644 --- a/chrome/browser/android/chrome_feature_list.cc +++ b/chrome/browser/android/chrome_feature_list.cc @@ -117,7 +117,6 @@ const base::Feature* kFeaturesExposedToJava[] = { &kHorizontalTabSwitcherAndroid, &kImprovedA2HS, &kInflateToolbarOnBackgroundThread, - &kJellyBeanSupported, &kLanguagesPreference, &kLongPressBackForHistory, &kModalPermissionDialogView, @@ -333,9 +332,6 @@ const base::Feature kImprovedA2HS{"ImprovedA2HS", const base::Feature kInflateToolbarOnBackgroundThread{ "BackgroundToolbarInflation", base::FEATURE_DISABLED_BY_DEFAULT}; -const base::Feature kJellyBeanSupported{"JellyBeanSupported", - base::FEATURE_DISABLED_BY_DEFAULT}; - const base::Feature kLanguagesPreference{"LanguagesPreference", base::FEATURE_ENABLED_BY_DEFAULT}; diff --git a/chrome/browser/android/chrome_feature_list.h b/chrome/browser/android/chrome_feature_list.h index 62b4825d893eb..00b50b85bd139 100644 --- a/chrome/browser/android/chrome_feature_list.h +++ b/chrome/browser/android/chrome_feature_list.h @@ -58,7 +58,6 @@ extern const base::Feature kHomepageTile; extern const base::Feature kHorizontalTabSwitcherAndroid; extern const base::Feature kImprovedA2HS; extern const base::Feature kInflateToolbarOnBackgroundThread; -extern const base::Feature kJellyBeanSupported; extern const base::Feature kLanguagesPreference; extern const base::Feature kLongPressBackForHistory; extern const base::Feature kModalPermissionDialogView; diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc index b1947af73857b..3c66bce1b7b7c 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc @@ -2695,8 +2695,7 @@ const char kTranslateAndroidManualTriggerDescription[] = const char kUpdateMenuBadgeName[] = "Force show update menu badge"; const char kUpdateMenuBadgeDescription[] = - "When enabled, a badge will be shown on the app menu button if the update " - "type is Update Available or Unsupported OS Version."; + "When enabled, an update badge will be shown on the app menu button."; const char kUpdateMenuItemCustomSummaryDescription[] = "When this flag and the force show update menu item flag are enabled, a " @@ -2704,14 +2703,10 @@ const char kUpdateMenuItemCustomSummaryDescription[] = const char kUpdateMenuItemCustomSummaryName[] = "Update menu item custom summary"; -const char kUpdateMenuTypeName[] = - "Forces the update menu type to a specific type"; -const char kUpdateMenuTypeDescription[] = - "When set, forces the update type to be a specific one, which impacts " - "the app menu badge and menu item for updates."; -const char kUpdateMenuTypeNone[] = "None"; -const char kUpdateMenuTypeUpdateAvailable[] = "Update Available"; -const char kUpdateMenuTypeUnsupportedOSVersion[] = "Unsupported OS Version"; +const char kUpdateMenuItemName[] = "Force show update menu item"; +const char kUpdateMenuItemDescription[] = + R"*(When enabled, an "Update Chrome" item will be shown in the app )*" + R"*(menu.)*"; const char kVrBrowsingTabsViewName[] = "VR browsing tabs view"; const char kVrBrowsingTabsViewDescription[] = diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h index 48223a72d9bed..d8a9cbfc0d869 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h @@ -1634,11 +1634,8 @@ extern const char kUpdateMenuBadgeDescription[]; extern const char kUpdateMenuItemCustomSummaryDescription[]; extern const char kUpdateMenuItemCustomSummaryName[]; -extern const char kUpdateMenuTypeName[]; -extern const char kUpdateMenuTypeDescription[]; -extern const char kUpdateMenuTypeNone[]; -extern const char kUpdateMenuTypeUpdateAvailable[]; -extern const char kUpdateMenuTypeUnsupportedOSVersion[]; +extern const char kUpdateMenuItemName[]; +extern const char kUpdateMenuItemDescription[]; extern const char kVrBrowsingTabsViewName[]; extern const char kVrBrowsingTabsViewDescription[]; diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 8a4b4b4e6f06d..7c22b38c3ddc0 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -783,8 +783,8 @@ const char kEnableHungRendererInfoBar[] = "enable-hung-renderer-infobar"; // Forces the update menu badge to show. const char kForceShowUpdateMenuBadge[] = "force-show-update-menu-badge"; -// Forces the update menu type to a specific type. -const char kForceUpdateMenuType[] = "force-update-menu-type"; +// Forces the update menu item to show. +const char kForceShowUpdateMenuItem[] = "force-show-update-menu-item"; // Forces a custom summary to be displayed below the update menu item. const char kForceShowUpdateMenuItemCustomSummary[] = "custom_summary"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index f724e53ad57ec..7792983001982 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -231,8 +231,8 @@ extern const char kEnableAccessibilityTabSwitcher[]; extern const char kEnableContextualSearch[]; extern const char kEnableHungRendererInfoBar[]; extern const char kForceShowUpdateMenuBadge[]; +extern const char kForceShowUpdateMenuItem[]; extern const char kForceShowUpdateMenuItemCustomSummary[]; -extern const char kForceUpdateMenuType[]; extern const char kMarketUrlForTesting[]; extern const char kProgressBarAnimation[]; extern const char kTrustedCDNBaseURLForTests[]; diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index ea05971d66835..af941bdd4a15f 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -29012,7 +29012,6 @@ from previous Chrome versions. -