From d313380482b7cb4e9f48a69064cf87a0d2318de9 Mon Sep 17 00:00:00 2001 From: Allison Naaktgeboren Date: Tue, 1 Sep 2015 15:32:33 -0700 Subject: [PATCH 01/19] Bug 1189719 - Recall and display search history within main browser UI.r=mcomella --- mobile/android/base/db/BrowserContract.java | 1 + mobile/android/base/home/BrowserSearch.java | 2 +- mobile/android/base/home/SearchEngineRow.java | 131 ++++++++++++------ .../base/resources/layout/suggestion_item.xml | 9 +- 4 files changed, 98 insertions(+), 45 deletions(-) diff --git a/mobile/android/base/db/BrowserContract.java b/mobile/android/base/db/BrowserContract.java index 11c1bdf0523..09f133d90bd 100644 --- a/mobile/android/base/db/BrowserContract.java +++ b/mobile/android/base/db/BrowserContract.java @@ -475,6 +475,7 @@ public class BrowserContract { public static final String CONTENT_TYPE = "vnd.android.cursor.dir/searchhistory"; public static final String QUERY = "query"; + public static final String DATE = "date"; public static final String TABLE_NAME = "searchhistory"; public static final Uri CONTENT_URI = Uri.withAppendedPath(SEARCH_HISTORY_AUTHORITY_URI, "searchhistory"); diff --git a/mobile/android/base/home/BrowserSearch.java b/mobile/android/base/home/BrowserSearch.java index 7b898053b86..7ed9fc8990f 100644 --- a/mobile/android/base/home/BrowserSearch.java +++ b/mobile/android/base/home/BrowserSearch.java @@ -911,7 +911,7 @@ public class BrowserSearch extends HomeFragment final SearchEngine engine = mSearchEngines.get(position); final boolean animate = (mAnimateSuggestions && engine.hasSuggestions()); - row.updateFromSearchEngine(engine, animate); + row.updateSuggestions(mSuggestionsEnabled, engine, mSearchTerm, animate); if (animate) { // Only animate suggestions the first time they are shown mAnimateSuggestions = false; diff --git a/mobile/android/base/home/SearchEngineRow.java b/mobile/android/base/home/SearchEngineRow.java index 667ab7902b3..c315557f227 100644 --- a/mobile/android/base/home/SearchEngineRow.java +++ b/mobile/android/base/home/SearchEngineRow.java @@ -5,6 +5,7 @@ package org.mozilla.gecko.home; +import org.mozilla.gecko.db.BrowserContract.SearchHistory; import org.mozilla.gecko.R; import org.mozilla.gecko.Telemetry; import org.mozilla.gecko.TelemetryContract; @@ -16,6 +17,8 @@ import org.mozilla.gecko.widget.AnimatedHeightLayout; import org.mozilla.gecko.widget.FaviconView; import org.mozilla.gecko.widget.FlowLayout; +import android.database.Cursor; +import android.content.ContentResolver; import android.content.Context; import android.util.AttributeSet; import android.view.KeyEvent; @@ -133,7 +136,10 @@ class SearchEngineRow extends AnimatedHeightLayout { return suggestionText.getText().toString(); } - private void setSuggestionOnView(View v, String suggestion) { + private void setSuggestionOnView(View v, String suggestion, boolean isUserSavedSearch) { + final ImageView historyIcon = (ImageView) v.findViewById(R.id.suggestion_item_icon); + historyIcon.setVisibility(isUserSavedSearch ? View.VISIBLE: View.GONE); + final TextView suggestionText = (TextView) v.findViewById(R.id.suggestion_text); suggestionText.setText(suggestion); setDescriptionOnSuggestion(suggestionText, suggestion); @@ -172,7 +178,76 @@ class SearchEngineRow extends AnimatedHeightLayout { mEditSuggestionListener = listener; } - public void updateFromSearchEngine(SearchEngine searchEngine, boolean animate) { + private void bindSuggestionView(String suggestion, boolean animate, int recycledSuggestionCount, Integer previousSuggestionChildIndex, boolean isUserSavedSearch){ + final View suggestionItem; + + // Reuse suggestion views from recycled view, if possible. + if (previousSuggestionChildIndex + 1 < recycledSuggestionCount) { + suggestionItem = mSuggestionView.getChildAt(previousSuggestionChildIndex + 1); + suggestionItem.setVisibility(View.VISIBLE); + } else { + suggestionItem = mInflater.inflate(R.layout.suggestion_item, null); + + suggestionItem.setOnClickListener(mClickListener); + suggestionItem.setOnLongClickListener(mLongClickListener); + + // Store the position of the suggestion for telemetry. + suggestionItem.setTag(String.valueOf(previousSuggestionChildIndex)); + + mSuggestionView.addView(suggestionItem); + } + + setSuggestionOnView(suggestionItem, suggestion, isUserSavedSearch); + + if (animate) { + AlphaAnimation anim = new AlphaAnimation(0, 1); + anim.setDuration(ANIMATION_DURATION); + anim.setStartOffset(previousSuggestionChildIndex * ANIMATION_DURATION); + suggestionItem.startAnimation(anim); + } + } + + private void hideRecycledSuggestions(int lastVisibleChildIndex, int recycledSuggestionCount) { + // Hide extra suggestions that have been recycled. + for (int i = lastVisibleChildIndex + 1; i < recycledSuggestionCount; ++i) { + mSuggestionView.getChildAt(i).setVisibility(View.GONE); + } + } + + private void updateFromSavedSearches(String searchTerm, boolean animate, int suggestionCounter, int recycledSuggestionCount) { + final ContentResolver cr = getContext().getContentResolver(); + + String[] columns = new String[] { SearchHistory.QUERY }; + String sortOrderAndLimit = SearchHistory.DATE + " DESC"; + + final Cursor c = cr.query(SearchHistory.CONTENT_URI, columns, null, null, sortOrderAndLimit); + if (c == null) { + return; + } + try { + if (c.moveToFirst()) { + int counter = 0; + final int searchColumn = c.getColumnIndexOrThrow(SearchHistory.QUERY); + do { + final String savedSearch = c.getString(searchColumn); + if (counter == 4) { + break; + } + // Bug 1200371 will move the filtering/matching and limit into the sql query + if (savedSearch.startsWith(searchTerm)) { + bindSuggestionView(savedSearch, animate, recycledSuggestionCount, suggestionCounter, true); + ++suggestionCounter; + ++counter; + } + } while (c.moveToNext()); + } + } finally { + c.close(); + } + hideRecycledSuggestions(suggestionCounter, recycledSuggestionCount); + } + + private int updateFromSearchEngine(SearchEngine searchEngine, boolean animate, int recycledSuggestionCount) { // Update search engine reference. mSearchEngine = searchEngine; @@ -182,54 +257,30 @@ class SearchEngineRow extends AnimatedHeightLayout { // Set the initial content description. setDescriptionOnSuggestion(mUserEnteredTextView, mUserEnteredTextView.getText().toString()); - // Add additional suggestions given by this engine. - final int recycledSuggestionCount = mSuggestionView.getChildCount(); - int suggestionCounter = 0; + // Apply Search Engine's suggestions for (String suggestion : mSearchEngine.getSuggestions()) { - final View suggestionItem; - - // Reuse suggestion views from recycled view, if possible. - if (suggestionCounter + 1 < recycledSuggestionCount) { - suggestionItem = mSuggestionView.getChildAt(suggestionCounter + 1); - suggestionItem.setVisibility(View.VISIBLE); - } else { - suggestionItem = mInflater.inflate(R.layout.suggestion_item, null); - - suggestionItem.setOnClickListener(mClickListener); - suggestionItem.setOnLongClickListener(mLongClickListener); - - // Store the position of the suggestion for telemetry. - suggestionItem.setTag(String.valueOf(suggestionCounter)); - - final ImageView magnifier = - (ImageView) suggestionItem.findViewById(R.id.suggestion_magnifier); - magnifier.setVisibility(View.GONE); - - mSuggestionView.addView(suggestionItem); - } - - setSuggestionOnView(suggestionItem, suggestion); - - if (animate) { - AlphaAnimation anim = new AlphaAnimation(0, 1); - anim.setDuration(ANIMATION_DURATION); - anim.setStartOffset(suggestionCounter * ANIMATION_DURATION); - suggestionItem.startAnimation(anim); - } - + bindSuggestionView(suggestion, animate, recycledSuggestionCount, suggestionCounter, false); ++suggestionCounter; } - // Hide extra suggestions that have been recycled. - for (int i = suggestionCounter + 1; i < recycledSuggestionCount; ++i) { - mSuggestionView.getChildAt(i).setVisibility(View.GONE); - } + hideRecycledSuggestions(suggestionCounter, recycledSuggestionCount); // Make sure mSelectedView is still valid. if (mSelectedView >= mSuggestionView.getChildCount()) { mSelectedView = mSuggestionView.getChildCount() - 1; } + + return suggestionCounter; + } + + public void updateSuggestions(boolean suggestionsEnabled, SearchEngine searchEngine, String searchTerm, boolean animate) { + // This can be called before the opt-in permission prompt is shown or set. Check first. + if (suggestionsEnabled) { + final int recycledSuggestionCount = mSuggestionView.getChildCount(); + final int suggestionViewCount = updateFromSearchEngine(searchEngine, animate, recycledSuggestionCount); + updateFromSavedSearches(searchTerm, animate, suggestionViewCount, recycledSuggestionCount); + } } @Override diff --git a/mobile/android/base/resources/layout/suggestion_item.xml b/mobile/android/base/resources/layout/suggestion_item.xml index 49dbeaf44d2..8118ef042d2 100644 --- a/mobile/android/base/resources/layout/suggestion_item.xml +++ b/mobile/android/base/resources/layout/suggestion_item.xml @@ -12,11 +12,12 @@ android:clickable="true" android:padding="7dp"> - + android:layout_width="18dip" + android:layout_height="18dip" + android:visibility="gone"/> Date: Tue, 1 Sep 2015 15:52:26 -0700 Subject: [PATCH 02/19] Bug 1197054 - Build changes to get rid of bookmarks.inc.r=nalexander --- mobile/android/base/locales/Makefile.in | 14 ------ .../base/locales/en-US/android_strings.dtd | 15 ++++++ mobile/android/base/strings.xml.in | 13 +++-- mobile/locales/Makefile.in | 48 +------------------ mobile/locales/en-US/profile/bookmarks.inc | 41 ---------------- .../locales/generic/profile/bookmarks.json.in | 8 ---- 6 files changed, 22 insertions(+), 117 deletions(-) delete mode 100644 mobile/locales/en-US/profile/bookmarks.inc delete mode 100644 mobile/locales/generic/profile/bookmarks.json.in diff --git a/mobile/android/base/locales/Makefile.in b/mobile/android/base/locales/Makefile.in index 7851f5ad89e..e94e52a7a15 100644 --- a/mobile/android/base/locales/Makefile.in +++ b/mobile/android/base/locales/Makefile.in @@ -44,18 +44,6 @@ chrome-%:: $(dir-res-raw)-$(AB_rCD)/browsersearch.json \ AB_CD=$* -# setup the path to bookmarks.inc. copied and tweaked version of MERGE_FILE from config/config.mk -MOBILE_LOCALE_SRCDIR = $(if $(filter en-US,$(AB_CD)),$(topsrcdir)/mobile/locales/en-US,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/mobile) - -ifdef LOCALE_MERGEDIR -BOOKMARKSPATH = $(firstword \ - $(wildcard $(LOCALE_MERGEDIR)/mobile/profile/bookmarks.inc ) \ - $(wildcard $(MOBILE_LOCALE_SRCDIR)/profile/bookmarks.inc ) \ - $(topsrcdir)/mobile/locales/en-US/profile/bookmarks.inc ) -else -BOOKMARKSPATH = $(abspath $(MOBILE_LOCALE_SRCDIR)/profile/bookmarks.inc) -endif - # Determine the ../res/values[-*]/ path strings-xml-bypath = $(filter %/strings.xml,$(MAKECMDGOALS)) ifeq (,$(strip $(strings-xml-bypath))) @@ -69,7 +57,6 @@ strings-xml-preqs =\ $(STRINGSPATH) \ $(SEARCHSTRINGSPATH) \ $(SYNCSTRINGSPATH) \ - $(BOOKMARKSPATH) \ $(if $(IS_LANGUAGE_REPACK),FORCE) \ $(NULL) @@ -80,7 +67,6 @@ $(dir-strings-xml)/strings.xml: $(strings-xml-preqs) $(call py_action,preprocessor, \ $(DEFINES) \ -DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME) \ - -DBOOKMARKSPATH='$(BOOKMARKSPATH)' \ -DBRANDPATH='$(BRANDPATH)' \ -DMOZ_ANDROID_SHARED_ACCOUNT_TYPE=$(MOZ_ANDROID_SHARED_ACCOUNT_TYPE) \ -DMOZ_ANDROID_SHARED_FXACCOUNT_TYPE=$(MOZ_ANDROID_SHARED_FXACCOUNT_TYPE) \ diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 69d669dcac3..fb027f9288f 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -703,3 +703,18 @@ just addresses the organization to follow, e.g. "This site is run by " --> + + + + + + + + + + + + + + + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index e88fb35d6a6..05d730d96ef 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -19,7 +19,6 @@ ]> -#includesubst @BOOKMARKSPATH@ @MOZ_APP_DISPLAYNAME@ @ANDROID_PACKAGE_NAME@ @@ -453,25 +452,25 @@ - @bookmarks_aboutBrowser@ + &bookmarks_about_browser; about:firefox - @bookmarks_addons@ + &bookmarks_addons; https://addons.mozilla.org/android/ - @bookmarks_support@ + &bookmarks_support; https://support.mozilla.org/products/mobile - @bookmarks_marketplace@ + &bookmarks_marketplace; https://marketplace.firefox.com/ - @bookmarks_restricted_webmaker@ + &bookmarks_restricted_webmaker; https://webmaker.org/ - @bookmarks_restricted_support@ + &bookmarks_restricted_support; https://support.mozilla.org/kb/kids diff --git a/mobile/locales/Makefile.in b/mobile/locales/Makefile.in index 3b71ee64f36..ecf96301f70 100644 --- a/mobile/locales/Makefile.in +++ b/mobile/locales/Makefile.in @@ -44,17 +44,6 @@ search-jar-default: search-jar ########################################################################### -bookmarks = bookmarks.json -bookmarks-ts = $(tgt-gendir)/$(bookmarks) -src-bookmarks = $(srcdir)/generic/profile/$(bookmarks).in - -GARBAGE += $(bookmarks) $(bookmarks-ts) -# --------------------------------------------------------------------------- -# Note: Always symlink bookmarks.json to pickup the current build for a -# locale. Phase 2 edits should remove the common/symlink file and -# provide a user function able to derive the path. -########################################################################### - ## Searchlist plugin config plugin-file-array = \ $(wildcard $(LOCALE_SRCDIR)/searchplugins/list.txt) \ @@ -144,7 +133,6 @@ libs-%: $(libs-preqs) $(display-deps) @$(MAKE) -C $(DEPTH)/toolkit/locales libs-$* @$(MAKE) -C $(DEPTH)/intl/locales AB_CD=$* XPI_NAME=locale-$* - @$(MAKE) -B $(bookmarks) AB_CD=$* @$(MAKE) -B searchplugins AB_CD=$* XPI_NAME=locale-$* @$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref @$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales AB_CD=$* XPI_NAME=locale-$* @@ -152,7 +140,6 @@ libs-%: $(libs-preqs) # Tailored target to just add the chrome processing for multi-locale builds chrome-%: $(display-deps) - @$(MAKE) -B $(bookmarks) AB_CD=$* @$(MAKE) -B searchplugins AB_CD=$* @$(MAKE) chrome AB_CD=$* @$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales chrome AB_CD=$* @@ -160,37 +147,4 @@ chrome-%: NO_JA_JP_MAC_AB_CD := $(if $(filter ja-JP-mac, $(AB_CD)),ja,$(AB_CD)) -# emulate vpath to gather deps with a path -has-mergedir = $(if $(strip $(LOCALE_MERGEDIR)),1) -bookmarks-inc-array = \ - $(wildcard \ - $(if $(has_mergedir),$(LOCALE_MERGEDIR)/mobile/profile/bookmarks.inc) \ - $(LOCALE_SRCDIR)/profile/bookmarks.inc \ - $(if $(has-mergedir),$(srcdir)/en-US/profile/bookmarks.inc) \ - ) -bookmarks-inc = $(firstword $(bookmarks-inc-array)) - -bookmarks-preqs = \ - $(bookmarks-inc) \ - $(src-bookmarks) \ - generic/profile/$(bookmarks).in \ - $(if $(IS_LANGUAGE_REPACK),FORCE) \ - $(GLOBAL_DEPS) \ - $(NULL) - -$(bookmarks-ts): $(bookmarks-preqs) - $(display_deps) - $(call py_action,preprocessor, \ - -I $< \ - -DAB_CD=$(NO_JA_JP_MAC_AB_CD) \ - $(src-bookmarks) \ - -o $@) - -.PHONY: bookmarks $(bookmarks) -bookmarks: $(bookmarks) -$(bookmarks): $(bookmarks-ts) - @echo '\nGenerating: $@' - ln -fn $< . - - -export:: searchplugins bookmarks +export:: searchplugins diff --git a/mobile/locales/en-US/profile/bookmarks.inc b/mobile/locales/en-US/profile/bookmarks.inc deleted file mode 100644 index dd25ad10299..00000000000 --- a/mobile/locales/en-US/profile/bookmarks.inc +++ /dev/null @@ -1,41 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -#filter emptyLines - -# LOCALIZATION NOTE: The 'en-US' strings in the URLs will be replaced with -# your locale code, and link to your translated pages as soon as they're -# live. - -# LOCALIZATION NOTE: Some of these URLs are currently 404s, but should be coming -# online shortly. - -# LOCALIZATION NOTE (bookmarks_title): -# title for the folder that will contains the default bookmarks -#define bookmarks_title Mobile - -# LOCALIZATION NOTE (bookmarks_aboutBrowser): -# link title for about:fennec -#define bookmarks_aboutBrowser Firefox: About your browser - -# LOCALIZATION NOTE (bookmarks_addons): -# link title for https://addons.mozilla.org/en-US/mobile -#define bookmarks_addons Firefox: Customize with add-ons - -# LOCALIZATION NOTE (bookmarks_support): -# link title for https://support.mozilla.org/ -#define bookmarks_support Firefox: Support - -# LOCALIZATION NOTE (bookmarks_marketplace): -# link title for https://marketplace.firefox.com -#define bookmarks_marketplace Firefox Marketplace - -# LOCALIZATION NOTE (bookmarks_restricted_support): -# link title for https://support.mozilla.org/kb/kids -#define bookmarks_restricted_support Firefox Help and Support for a simplified kid-friendly version of Firefox - -# LOCALIZATION NOTE (bookmarks_restricted_webmaker): -# link title for https://webmaker.org -#define bookmarks_restricted_webmaker Learn the Web: Mozilla Webmaker - -#unfilter emptyLines diff --git a/mobile/locales/generic/profile/bookmarks.json.in b/mobile/locales/generic/profile/bookmarks.json.in deleted file mode 100644 index 0c1dfc798a9..00000000000 --- a/mobile/locales/generic/profile/bookmarks.json.in +++ /dev/null @@ -1,8 +0,0 @@ -#filter substitution -{"type":"text/x-moz-place-container","root":"placesRoot","children": - [{"type":"text/x-moz-place-container","title":"@bookmarks_title@","annos":[{"name":"mobile/bookmarksRoot","expires":4,"type":1,"value":1}], -# Bug 921433: this is empty, because bookmarks are now added via resource -# strings: see LocalBrowserDB.addDefaultBookmarks. - "children": [] - }] -} From 07148a9c9bfc867a9376d4b54d2586bbc5f1e0c4 Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Tue, 1 Sep 2015 16:00:42 -0700 Subject: [PATCH 03/19] Bug 1200322 - Fix a11y problem around key navigation in the urlbar. r=Mossop --- browser/base/content/urlbarBindings.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/browser/base/content/urlbarBindings.xml b/browser/base/content/urlbarBindings.xml index 9506e8c381d..7797335b3f1 100644 --- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -193,8 +193,9 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. case KeyEvent.DOM_VK_LEFT: case KeyEvent.DOM_VK_RIGHT: case KeyEvent.DOM_VK_HOME: - this.popup.hidePopup(); - return; + // Reset the selected index so that nsAutoCompleteController + // simply closes the popup without trying to fill anything. + this.popup.selectedIndex = -1; break; } From 2296cb6513d8ec66f9551dc5025df390fc001b24 Mon Sep 17 00:00:00 2001 From: Allison Naaktgeboren Date: Tue, 1 Sep 2015 16:28:47 -0700 Subject: [PATCH 04/19] CLOSED TREE missing space in commit from Bug 1197054 --- mobile/android/base/locales/en-US/android_strings.dtd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index fb027f9288f..f58764daab6 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -712,7 +712,7 @@ just addresses the organization to follow, e.g. "This site is run by " --> - + From d05a9afe2a7a3560ba5b539a882ff71cfde91c89 Mon Sep 17 00:00:00 2001 From: "Bernardo P. Rittmeyer" Date: Mon, 31 Aug 2015 16:42:21 -0700 Subject: [PATCH 05/19] Bug 1195949 - Remove key icon from context menu fill. r=MattN --- browser/base/content/browser-context.inc | 1 - browser/themes/shared/contextmenu.inc.css | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/browser/base/content/browser-context.inc b/browser/base/content/browser-context.inc index cd7b2ede3ae..c9b12849a93 100644 --- a/browser/base/content/browser-context.inc +++ b/browser/base/content/browser-context.inc @@ -420,7 +420,6 @@