From e93fad67764ce2665525488e5b2928002aeb12ed Mon Sep 17 00:00:00 2001 From: William Budington Date: Fri, 26 Aug 2016 21:10:54 -0700 Subject: [PATCH] Firefox for Android: Controls are now in a menu, providing a less intrusive UI (fixes #6036) --- src/chrome/content/code/AndroidUI.jsm | 122 +++++++++++++++----------- utils/android-push.sh | 2 +- 2 files changed, 74 insertions(+), 50 deletions(-) diff --git a/src/chrome/content/code/AndroidUI.jsm b/src/chrome/content/code/AndroidUI.jsm index 564ab03f3686..a269e04a813d 100644 --- a/src/chrome/content/code/AndroidUI.jsm +++ b/src/chrome/content/code/AndroidUI.jsm @@ -7,8 +7,10 @@ var HTTPSEverywhere = CC["@eff.org/https-everywhere;1"] CU.import("resource://gre/modules/Prompt.jsm"); -var menuId; -var urlbarId; +var menuToggleId; +var menuParentId; +var menuRulesId; +var menuDefaultsId; var aWindow = getWindow(); @@ -21,12 +23,7 @@ function loadIntoWindow() { return; } var enabled = HTTPSEverywhere.prefs.getBoolPref("globalEnabled"); - addToggleItemToMenu(enabled); - if (enabled) { - urlbarId = aWindow.NativeWindow.pageactions.add(urlbarOptions); - } else if (urlbarId) { - aWindow.NativeWindow.pageactions.remove(urlbarId); - } + addMenuItems(enabled); // When navigating away from a page, we want to clear the applicable list for // that page. There are a few different APIs to do this, but this is the one @@ -43,8 +40,7 @@ function unloadFromWindow() { if (!aWindow) { return; } - aWindow.NativeWindow.menu.remove(menuId); - aWindow.NativeWindow.pageactions.remove(urlbarId); + aWindow.NativeWindow.menu.remove(menuParentId); } @@ -53,13 +49,72 @@ function unloadFromWindow() { */ function addToggleItemToMenu(enabled) { - if (menuId) { aWindow.NativeWindow.menu.remove(menuId); } - var menuLabel = enabled ? "HTTPS Everywhere (on)" : "HTTPS Everywhere (off)"; - menuId = aWindow.NativeWindow.menu.add(menuLabel, null, function() { - popupToggleMenu(aWindow, enabled); + if (menuToggleId) { aWindow.NativeWindow.menu.remove(menuToggleId); } + var menuLabel = enabled ? "Disable" : "Enable"; + menuToggleId = aWindow.NativeWindow.menu.add({ + name: menuLabel, + callback: function() { + popupToggleMenu(aWindow, enabled); + }, + parent: menuParentId }); } +function addRulesItemToMenu(enabled){ + if (menuRulesId) { aWindow.NativeWindow.menu.remove(menuRulesId); } + + if (enabled) { + menuRulesId = aWindow.NativeWindow.menu.add({ + name: "Enable/disable rules", + callback: function() { + popupInfo.fill(); + rulesPrompt.setMultiChoiceItems(popupInfo.ruleItems); + rulesPrompt.show(function(data) { + var db = data.button; + if (db === -1) { return null; } // user didn't click the accept button + + for (var i=0; i /dev/null 2>/dev/null && adb devices >/dev/null 2>/dev/null ; then adb push "../$XPI_NAME" /sdcard/"$XPI_NAME" adb shell am start -a android.intent.action.VIEW \ -c android.intent.category.DEFAULT \ - -d file:///mnt/sdcard/"$XPI_NAME" \ + -d file:///mnt/sdcard/pkg/ \ -n $ANDROID_APP_ID/.App fi fi