Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1098)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/infobar/TranslateCompactInfoBar.java

Issue 2840933003: Shows snackbar in translate infobar, after certain user actions. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/TranslateCompactInfoBar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/TranslateCompactInfoBar.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/TranslateCompactInfoBar.java
index 60ddf05a4e2f4f0d453d0961183ec0ce63d33bde..13e687c3509f4c0dbe6823addc644ba0feeaec5c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/TranslateCompactInfoBar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/TranslateCompactInfoBar.java
@@ -15,6 +15,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.infobar.translate.TranslateMenu;
import org.chromium.chrome.browser.infobar.translate.TranslateMenuHelper;
import org.chromium.chrome.browser.infobar.translate.TranslateTabLayout;
+import org.chromium.chrome.browser.snackbar.Snackbar;
/**
* Java version of the compcat translate infobar
@@ -40,7 +41,21 @@ class TranslateCompactInfoBar extends InfoBar
@CalledByNative
private boolean closeInfoBar(int snackbarType, int nativePtr) {
- // TODO(ramyasharma): Show snackbar.
+ if (snackbarType == TranslateSnackbarType.NEVER_TRANSLATE) {
+ getSnackbarManager().showSnackbar(createSnackbar(
+ getContext().getString(R.string.translate_snackbar_language_never,
+ mOptions.sourceLanguageName()),
+ Snackbar.UMA_TRANSLATE_NEVER, nativePtr));
+ } else if (snackbarType == TranslateSnackbarType.ALWAYS_TRANSLATE) {
+ getSnackbarManager().showSnackbar(createSnackbar(
+ getContext().getString(R.string.translate_snackbar_always_translate,
+ mOptions.sourceLanguageName(), mOptions.targetLanguageName()),
+ Snackbar.UMA_TRANSLATE_ALWAYS, nativePtr));
+ } else if (snackbarType == TranslateSnackbarType.NEVER_TRANSLATE_SITE) {
+ getSnackbarManager().showSnackbar(
+ createSnackbar(getContext().getString(R.string.translate_snackbar_site_never),
+ Snackbar.UMA_TRANSLATE_NEVER_SITE, nativePtr));
+ }
return super.closeInfoBar();
}
@@ -188,6 +203,11 @@ class TranslateCompactInfoBar extends InfoBar
}
}
+ private Snackbar createSnackbar(String title, int type, int nativePtr) {
gone 2017/04/26 17:27:02 You don't actually use the nativePtr.
ramyasharma 2017/04/27 08:03:11 ah yes. Not yet, but in the next cl I will. Remove
+ return Snackbar.make(
+ title, new TranslateSnackbarController(), Snackbar.TYPE_NOTIFICATION, type);
+ }
+
private native void nativeApplyStringTranslateOption(
long nativeTranslateCompactInfoBar, int option, String value);
private native void nativeApplyBoolTranslateOption(

Powered by Google App Engine
This is Rietveld 408576698