diff --git a/mobile/android/chrome/content/ActionBarHandler.js b/mobile/android/chrome/content/ActionBarHandler.js index fa18ce5b182b..b9e60d74cd77 100644 --- a/mobile/android/chrome/content/ActionBarHandler.js +++ b/mobile/android/chrome/content/ActionBarHandler.js @@ -4,6 +4,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); + const PHONE_REGEX = /^\+?[0-9\s,-.\(\)*#pw]{1,30}$/; // Are we a phone #? @@ -326,7 +328,7 @@ var ActionBarHandler = { clipboard.copyString(selectedText); let msg = Strings.browser.GetStringFromName("selectionHelper.textCopied"); - NativeWindow.toast.show(msg, "short"); + Snackbars.show(msg, Snackbars.LENGTH_SHORT); // Then cut the selection text. ActionBarHandler._getSelection(element, win).deleteFromDocument(); @@ -361,7 +363,7 @@ var ActionBarHandler = { clipboard.copyString(selectedText); let msg = Strings.browser.GetStringFromName("selectionHelper.textCopied"); - NativeWindow.toast.show(msg, "short"); + Snackbars.show(msg, Snackbars.LENGTH_SHORT); ActionBarHandler._uninit(); UITelemetry.addEvent("action.1", "actionbar", null, "copy"); diff --git a/mobile/android/chrome/content/MasterPassword.js b/mobile/android/chrome/content/MasterPassword.js index aeeac92feed1..a88db84d19f7 100644 --- a/mobile/android/chrome/content/MasterPassword.js +++ b/mobile/android/chrome/content/MasterPassword.js @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); + var MasterPassword = { pref: "privacy.masterpassword.enabled", _tokenName: "", @@ -61,7 +63,7 @@ var MasterPassword = { } catch(e) { dump("MasterPassword.removePassword: " + e + "\n"); } - NativeWindow.toast.show(Strings.browser.GetStringFromName("masterPassword.incorrect"), "short"); + Snackbars.show(Strings.browser.GetStringFromName("masterPassword.incorrect"), Snackbars.LENGTH_SHORT); return false; } }; diff --git a/mobile/android/chrome/content/PrintHelper.js b/mobile/android/chrome/content/PrintHelper.js index 87035c9e4d05..9b071ee92814 100644 --- a/mobile/android/chrome/content/PrintHelper.js +++ b/mobile/android/chrome/content/PrintHelper.js @@ -4,6 +4,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); + var PrintHelper = { init: function() { Services.obs.addObserver(this, "Print:PDF", false); @@ -48,7 +50,7 @@ var PrintHelper = { // We get two STATE_START calls, one for STATE_IS_DOCUMENT and one for STATE_IS_NETWORK if (stateFlags & Ci.nsIWebProgressListener.STATE_START && stateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { // Let the user know something is happening. Generating the PDF can take some time. - NativeWindow.toast.show(Strings.browser.GetStringFromName("alertPrintjobToast"), "long"); + Snackbars.show(Strings.browser.GetStringFromName("alertPrintjobToast"), Snackbars.LENGTH_LONG); } // We get two STATE_STOP calls, one for STATE_IS_DOCUMENT and one for STATE_IS_NETWORK diff --git a/mobile/android/chrome/content/Reader.js b/mobile/android/chrome/content/Reader.js index b594504a5afb..d90d56439965 100644 --- a/mobile/android/chrome/content/Reader.js +++ b/mobile/android/chrome/content/Reader.js @@ -5,6 +5,8 @@ "use strict"; +XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); + /*globals MAX_URI_LENGTH, MAX_TITLE_LENGTH */ var Reader = { @@ -179,7 +181,7 @@ var Reader = { case "Reader:ToolbarHidden": if (!this._hasUsedToolbar) { - NativeWindow.toast.show(Strings.browser.GetStringFromName("readerMode.toolbarTip"), "short"); + Snackbars.show(Strings.browser.GetStringFromName("readerMode.toolbarTip"), Snackbars.LENGTH_SHORT); Services.prefs.setBoolPref("reader.has_used_toolbar", true); this._hasUsedToolbar = true; } diff --git a/mobile/android/chrome/content/SelectionHandler.js b/mobile/android/chrome/content/SelectionHandler.js index d4d57a17cb12..7f59916dd336 100644 --- a/mobile/android/chrome/content/SelectionHandler.js +++ b/mobile/android/chrome/content/SelectionHandler.js @@ -4,6 +4,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; +XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); + // Define elements that bound phone number containers. const PHONE_NUMBER_CONTAINERS = "td,div"; const DEFER_CLOSE_TRIGGER_MS = 125; // Grace period delay before deferred _closeSelection() @@ -1088,7 +1090,7 @@ var SelectionHandler = { if (selectedText.length) { let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper); clipboard.copyString(selectedText); - NativeWindow.toast.show(Strings.browser.GetStringFromName("selectionHelper.textCopied"), "short"); + Snackbars.show(Strings.browser.GetStringFromName("selectionHelper.textCopied"), Snackbars.LENGTH_SHORT); } this._closeSelection(); }, diff --git a/mobile/android/chrome/content/WebcompatReporter.js b/mobile/android/chrome/content/WebcompatReporter.js index 1e6c1ea40fe8..b3e4ac27e54a 100644 --- a/mobile/android/chrome/content/WebcompatReporter.js +++ b/mobile/android/chrome/content/WebcompatReporter.js @@ -9,6 +9,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); var WebcompatReporter = { menuItem: null, @@ -77,12 +78,12 @@ var WebcompatReporter = { let currentURI = BrowserApp.selectedTab.browser.currentURI.spec; let message = this.strings.GetStringFromName("webcompat.reportDesktopMode.message"); let options = { - button: { + action: { label: this.strings.GetStringFromName("webcompat.reportDesktopModeYes.label"), callback: () => this.reportIssue(currentURI) } }; - NativeWindow.toast.show(message, "long", options); + Snackbars.show(message, Snackbars.LENGTH_LONG, options); }, reportIssue: function(url) { diff --git a/mobile/android/chrome/content/aboutLogins.js b/mobile/android/chrome/content/aboutLogins.js index 0d8a1c961a6d..ff9316099246 100644 --- a/mobile/android/chrome/content/aboutLogins.js +++ b/mobile/android/chrome/content/aboutLogins.js @@ -19,6 +19,7 @@ XPCOMUtils.defineLazyGetter(window, "gChromeWin", () => .getInterface(Ci.nsIDOMWindow) .QueryInterface(Ci.nsIDOMChromeWindow)); +XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Prompt", "resource://gre/modules/Prompt.jsm"); @@ -26,14 +27,14 @@ var debug = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.d. var gStringBundle = Services.strings.createBundle("chrome://browser/locale/aboutLogins.properties"); -function copyStringAndToast(string, notifyString) { +function copyStringShowSnackbar(string, notifyString) { try { let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper); clipboard.copyString(string); - gChromeWin.NativeWindow.toast.show(notifyString, "short"); + Snackbars.show(notifyString, Snackbars.LENGTH_SHORT); } catch (e) { debug("Error copying from about:logins"); - gChromeWin.NativeWindow.toast.show(gStringBundle.GetStringFromName("loginsDetails.copyFailed"), "short"); + Snackbars.show(gStringBundle.GetStringFromName("loginsDetails.copyFailed"), Snackbars.LENGTH_SHORT); } } @@ -300,7 +301,7 @@ var Logins = { if ((newUsername === origUsername) && (newPassword === origPassword) && (newDomain === origDomain) ) { - gChromeWin.NativeWindow.toast.show(gStringBundle.GetStringFromName("editLogin.saved1"), "short"); + Snackbars.show(gStringBundle.GetStringFromName("editLogin.saved1"), Snackbars.LENGTH_SHORT); this._showList(); return; } @@ -319,10 +320,10 @@ var Logins = { } } } catch (e) { - gChromeWin.NativeWindow.toast.show(gStringBundle.GetStringFromName("editLogin.couldNotSave"), "short"); + Snackbars.show(gStringBundle.GetStringFromName("editLogin.couldNotSave"), Snackbars.LENGTH_SHORT); return; } - gChromeWin.NativeWindow.toast.show(gStringBundle.GetStringFromName("editLogin.saved1"), "short"); + Snackbars.show(gStringBundle.GetStringFromName("editLogin.saved1"), Snackbars.LENGTH_SHORT); this._showList(); }, @@ -363,7 +364,7 @@ var Logins = { switch (data.button) { case 0: // Corresponds to "Copy password" button. - copyStringAndToast(password, gStringBundle.GetStringFromName("loginsDetails.passwordCopied")); + copyStringShowSnackbar(password, gStringBundle.GetStringFromName("loginsDetails.passwordCopied")); } }); }, @@ -395,10 +396,10 @@ var Logins = { this._showPassword(login.password); break; case 1: - copyStringAndToast(login.password, gStringBundle.GetStringFromName("loginsDetails.passwordCopied")); + copyStringShowSnackbar(login.password, gStringBundle.GetStringFromName("loginsDetails.passwordCopied")); break; case 2: - copyStringAndToast(login.username, gStringBundle.GetStringFromName("loginsDetails.usernameCopied")); + copyStringShowSnackbar(login.username, gStringBundle.GetStringFromName("loginsDetails.usernameCopied")); break; case 3: this._selectedLogin = login; diff --git a/mobile/android/modules/DownloadNotifications.jsm b/mobile/android/modules/DownloadNotifications.jsm index 58d33a12d166..4336dab8046f 100644 --- a/mobile/android/modules/DownloadNotifications.jsm +++ b/mobile/android/modules/DownloadNotifications.jsm @@ -15,6 +15,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", "resource://gre/modules/Fil XPCOMUtils.defineLazyModuleGetter(this, "Notifications", "resource://gre/modules/Notifications.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "Snackbars", "resource://gre/modules/Snackbars.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "ParentalControls", "@mozilla.org/parental-controls-service;1", "nsIParentalControlsService"); @@ -64,7 +65,7 @@ var DownloadNotifications = { if (!ParentalControls.isAllowed(ParentalControls.DOWNLOAD)) { download.cancel().catch(Cu.reportError); download.removePartialData().catch(Cu.reportError); - window.NativeWindow.toast.show(strings.GetStringFromName("downloads.disabledInGuest"), "long"); + Snackbars.show(strings.GetStringFromName("downloads.disabledInGuest"), Snackbars.LENGTH_LONG); return; } @@ -72,9 +73,9 @@ var DownloadNotifications = { notifications.set(download, notification); notification.showOrUpdate(); - // If this is a new download, show a toast as well. + // If this is a new download, show a snackbar as well. if (this._viewAdded) { - window.NativeWindow.toast.show(strings.GetStringFromName("alertDownloadsToast"), "long"); + Snackbars.show(strings.GetStringFromName("alertDownloadsToast"), Snackbars.LENGTH_LONG); } },