Misc search fix
- Remove incorrect summary from set date/time
- Remove some unused resources
- Remove ability to clear individual search history
- Add remove all query history menu item
Change-Id: I4383d075310297163fd2206d1a5b9c8f4ed94078
Fix: 62741488
Fix: 31589605
Test: robotests
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c73c909..925b936 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -210,7 +210,7 @@
<activity android:name=".search.SearchActivity"
android:label="@string/search_settings"
- android:icon="@drawable/ic_search_history"
+ android:icon="@drawable/ic_search_24dp"
android:parentActivityName="Settings"
android:theme="@style/Theme.Settings.NoActionBar">
</activity>
diff --git a/res/drawable-hdpi/ic_search_history_am.png b/res/drawable-hdpi/ic_search_history_am.png
deleted file mode 100644
index eaef70c..0000000
--- a/res/drawable-hdpi/ic_search_history_am.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_search_history_am.png b/res/drawable-mdpi/ic_search_history_am.png
deleted file mode 100644
index fd6755f..0000000
--- a/res/drawable-mdpi/ic_search_history_am.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_search_history_am.png b/res/drawable-xhdpi/ic_search_history_am.png
deleted file mode 100644
index 7183fc2..0000000
--- a/res/drawable-xhdpi/ic_search_history_am.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_search_history_am.png b/res/drawable-xxhdpi/ic_search_history_am.png
deleted file mode 100644
index 174409b..0000000
--- a/res/drawable-xxhdpi/ic_search_history_am.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_search_history_am.png b/res/drawable-xxxhdpi/ic_search_history_am.png
deleted file mode 100644
index ffce51e..0000000
--- a/res/drawable-xxxhdpi/ic_search_history_am.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/ic_cross_grey_24dp.xml b/res/drawable/ic_cross_grey_24dp.xml
deleted file mode 100644
index 312c034..0000000
--- a/res/drawable/ic_cross_grey_24dp.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<!-- Copyright (C) 2016 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0">
- <path
- android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"
- android:fillColor="#757575"/>
-</vector>
diff --git a/res/drawable/ic_search_history.xml b/res/drawable/ic_search_history.xml
deleted file mode 100644
index 05384d2..0000000
--- a/res/drawable/ic_search_history.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright 2014, The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-
-<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_search_history_am"
- android:autoMirrored="true"
- />
diff --git a/res/layout/search_saved_query_item.xml b/res/layout/search_saved_query_item.xml
index 50001a5..f8c239a 100644
--- a/res/layout/search_saved_query_item.xml
+++ b/res/layout/search_saved_query_item.xml
@@ -20,28 +20,25 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:background="?android:attr/selectableItemBackground"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical">
+ <ImageView
+ android:id="@android:id/icon"
+ android:layout_width="@dimen/dashboard_tile_image_size"
+ android:layout_height="@dimen/dashboard_tile_image_size"
+ android:scaleType="centerInside"
+ android:layout_marginStart="@dimen/dashboard_tile_image_margin"
+ android:layout_marginEnd="@dimen/dashboard_tile_image_margin"
+ android:src="@drawable/ic_restore" />
+
<TextView
android:id="@android:id/title"
android:layout_height="match_parent"
- android:layout_width="wrap_content"
- android:layout_weight="1"
- android:text="test"
+ android:layout_width="match_parent"
android:gravity="center_vertical"
- android:background="?android:attr/selectableItemBackground"
- android:paddingStart="@dimen/preference_no_icon_padding_start"
android:textAppearance="?android:attr/textAppearanceListItem" />
- <ImageView
- android:id="@android:id/icon"
- android:background="?android:attr/selectableItemBackground"
- android:layout_width="@dimen/dashboard_category_height"
- android:layout_height="@dimen/dashboard_category_height"
- android:paddingStart="@dimen/search_suggestion_item_image_margin_start"
- android:paddingEnd="@dimen/search_suggestion_item_image_margin_end"
- android:scaleType="center"
- android:src="@drawable/ic_cross_grey_24dp" />
-
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/search_suggestion_item.xml b/res/layout/search_suggestion_item.xml
deleted file mode 100644
index 85a3381..0000000
--- a/res/layout/search_suggestion_item.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:minHeight="?android:attr/listPreferredItemHeight"
- android:gravity="center_vertical">
-
- <RelativeLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1">
-
- <TextView android:id="@+id/title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/search_title_padding_start"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:ellipsize="marquee"
- android:fadingEdge="horizontal" />
-
- </RelativeLayout>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:gravity="center"
- android:minWidth="@*android:dimen/preference_icon_minWidth"
- android:orientation="horizontal">
-
- <ImageView
- android:id="@+id/icon"
- android:layout_width="@dimen/search_suggestion_item_image_size"
- android:layout_height="@dimen/search_suggestion_item_image_size"
- android:scaleType="centerInside"
- android:src="@drawable/ic_search_history"
- android:layout_marginStart="@dimen/search_suggestion_item_image_margin_start"
- android:layout_marginEnd="@dimen/search_suggestion_item_image_margin_end"
- />
-
- </LinearLayout>
-
-</LinearLayout>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 0411914..4d30969 100755
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -59,13 +59,6 @@
<dimen name="switchbar_subsettings_margin_start">80dp</dimen>
<dimen name="switchbar_subsettings_margin_end">24dp</dimen>
- <!-- Search title (recent / results) padding start -->
- <dimen name="search_title_padding_start">24dp</dimen>
-
- <!-- Result item image margin start / end -->
- <dimen name="search_result_item_image_margin_start">24dp</dimen>
- <dimen name="search_result_item_image_margin_end">32dp</dimen>
-
<dimen name="search_bar_height">64dp</dimen>
<!-- Dimensions for Wifi Assistant Card -->
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 4bbc43a..0e10a71 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -96,9 +96,6 @@
<!-- Dashboard category panel elevation -->
<dimen name="dashboard_category_elevation">2dp</dimen>
- <!-- Dashboard category layout height -->
- <dimen name="dashboard_category_height">48dp</dimen>
-
<!-- Dashboard tile minimum height -->
<dimen name="dashboard_tile_minimum_height">72dp</dimen>
@@ -116,26 +113,6 @@
<dimen name="switchbar_subsettings_margin_start">72dp</dimen>
<dimen name="switchbar_subsettings_margin_end">16dp</dimen>
- <!-- Search Panel elevation -->
- <dimen name="search_panel_elevation">4dp</dimen>
-
- <!-- Search title (recent / results) padding start -->
- <dimen name="search_title_padding_start">12dp</dimen>
-
- <!-- Result item image size -->
- <dimen name="search_result_item_image_size">24dp</dimen>
-
- <!-- Result item image margin start / end -->
- <dimen name="search_result_item_image_margin_start">12dp</dimen>
- <dimen name="search_result_item_image_margin_end">32dp</dimen>
-
- <!-- Suggestion item image size -->
- <dimen name="search_suggestion_item_image_size">24dp</dimen>
-
- <!-- Suggestion item image margin start / end -->
- <dimen name="search_suggestion_item_image_margin_start">32dp</dimen>
- <dimen name="search_suggestion_item_image_margin_end">32dp</dimen>
-
<!-- The following two margins need to match, with the caveat that
the second should be negative. The second one ensures that the icons and text
align despite the additional padding caused by the search bar's card background. -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index df2168d..a9a0892 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2345,6 +2345,9 @@
<!-- There are no search results for the user's search [CHAR LIMIT=NONE]-->
<string name="search_settings_no_results">No results</string>
+ <!-- Button to clear all search history in Settings [CHAR LIMIT=40]-->
+ <string name="search_clear_history">Clear history</string>
+
<!-- Display settings --><skip/>
<!-- Sound & display settings screen, section header for settings related to display -->
<string name="display_settings">Display</string>
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index 7859119..c9ad0dd 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -14,44 +14,44 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
- android:title="@string/date_and_time"
- settings:keywords="@string/keywords_date_and_time">
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/date_and_time"
+ settings:keywords="@string/keywords_date_and_time">
- <com.android.settingslib.RestrictedSwitchPreference android:key="auto_time"
+ <com.android.settingslib.RestrictedSwitchPreference
+ android:key="auto_time"
android:title="@string/date_time_auto"
android:summaryOn="@string/date_time_auto_summaryOn"
android:summaryOff="@string/date_time_auto_summaryOff"
settings:useAdditionalSummary="true"
- settings:restrictedSwitchSummary="@string/enabled_by_admin"
- />
+ settings:restrictedSwitchSummary="@string/enabled_by_admin" />
- <SwitchPreference android:key="auto_zone"
+ <SwitchPreference
+ android:key="auto_zone"
android:title="@string/zone_auto"
android:summaryOn="@string/zone_auto_summaryOn"
- android:summaryOff="@string/zone_auto_summaryOff"
- />
+ android:summaryOff="@string/zone_auto_summaryOff" />
- <Preference android:key="date"
+ <Preference
+ android:key="date"
android:title="@string/date_time_set_date"
- android:summary="03/10/2008"
- />
+ android:summary="@string/summary_placeholder" />
- <Preference android:key="time"
+ <Preference
+ android:key="time"
android:title="@string/date_time_set_time"
- android:summary="12:00am"
- />
+ android:summary="@string/summary_placeholder" />
<Preference
android:fragment="com.android.settings.datetime.ZonePicker"
android:key="timezone"
android:title="@string/date_time_set_timezone"
- android:summary="GMT-8:00"
- />
+ android:summary="GMT-8:00" />
- <SwitchPreference android:key="24 hour"
- android:title="@string/date_time_24hour"
- />
+ <SwitchPreference
+ android:key="24 hour"
+ android:title="@string/date_time_24hour" />
</PreferenceScreen>
diff --git a/src/com/android/settings/search/SavedQueryController.java b/src/com/android/settings/search/SavedQueryController.java
index f6a3ff6..c61d544 100644
--- a/src/com/android/settings/search/SavedQueryController.java
+++ b/src/com/android/settings/search/SavedQueryController.java
@@ -21,12 +21,16 @@
import android.content.Context;
import android.content.Loader;
import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;
import java.util.List;
-public class SavedQueryController implements LoaderManager.LoaderCallbacks {
+public class SavedQueryController implements LoaderManager.LoaderCallbacks,
+ MenuItem.OnMenuItemClickListener {
// TODO: make a generic background task manager to handle one-off tasks like this one.
@@ -35,6 +39,8 @@
private static final int LOADER_ID_SAVED_QUERIES = 2;
private static final String ARG_QUERY = "remove_query";
+ private static final int MENU_SEARCH_HISTORY = 1000;
+
private final Context mContext;
private final LoaderManager mLoaderManager;
private final SearchFeatureProvider mSearchFeatureProvider;
@@ -55,7 +61,7 @@
case LOADER_ID_SAVE_QUERY_TASK:
return new SavedQueryRecorder(mContext, args.getString(ARG_QUERY));
case LOADER_ID_REMOVE_QUERY_TASK:
- return new SavedQueryRemover(mContext, args.getString(ARG_QUERY));
+ return new SavedQueryRemover(mContext);
case LOADER_ID_SAVED_QUERIES:
return mSearchFeatureProvider.getSavedQueryLoader(mContext);
}
@@ -76,7 +82,21 @@
@Override
public void onLoaderReset(Loader loader) {
+ }
+ @Override
+ public boolean onMenuItemClick(MenuItem item) {
+ if (item.getItemId() != MENU_SEARCH_HISTORY) {
+ return false;
+ }
+ removeQueries();
+ return true;
+ }
+
+ public void buildMenuItem(Menu menu) {
+ final MenuItem item =
+ menu.add(Menu.NONE, MENU_SEARCH_HISTORY, Menu.NONE, R.string.search_clear_history);
+ item.setOnMenuItemClickListener(this);
}
public void saveQuery(String query) {
@@ -85,9 +105,11 @@
mLoaderManager.restartLoader(LOADER_ID_SAVE_QUERY_TASK, args, this);
}
- public void removeQuery(String query) {
+ /**
+ * Remove all saved queries from DB
+ */
+ public void removeQueries() {
final Bundle args = new Bundle();
- args.putString(ARG_QUERY, query);
mLoaderManager.restartLoader(LOADER_ID_REMOVE_QUERY_TASK, args, this);
}
diff --git a/src/com/android/settings/search/SavedQueryRemover.java b/src/com/android/settings/search/SavedQueryRemover.java
index 47bb3ba..77334a5 100644
--- a/src/com/android/settings/search/SavedQueryRemover.java
+++ b/src/com/android/settings/search/SavedQueryRemover.java
@@ -17,25 +17,21 @@
package com.android.settings.search;
+import static com.android.settings.search.IndexDatabaseHelper.Tables.TABLE_SAVED_QUERIES;
+
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.util.Log;
-import com.android.settings.search.IndexDatabaseHelper;
import com.android.settings.utils.AsyncLoader;
-import static com.android.settings.search.IndexDatabaseHelper.Tables.TABLE_SAVED_QUERIES;
-
public class SavedQueryRemover extends AsyncLoader<Void> {
private static final String LOG_TAG = "SavedQueryRemover";
- private final String mQuery;
-
- public SavedQueryRemover(Context context, String query) {
+ public SavedQueryRemover(Context context) {
super(context);
- mQuery = query;
}
@Override
@@ -44,8 +40,8 @@
try {
// First, delete all saved queries that are the same
database.delete(TABLE_SAVED_QUERIES,
- IndexDatabaseHelper.SavedQueriesColumns.QUERY + " = ?",
- new String[]{mQuery});
+ null /* where */,
+ null /* whereArgs */);
} catch (Exception e) {
Log.d(LOG_TAG, "Cannot update saved Search queries", e);
}
diff --git a/src/com/android/settings/search/SavedQueryViewHolder.java b/src/com/android/settings/search/SavedQueryViewHolder.java
index 14509b6..a8d449d 100644
--- a/src/com/android/settings/search/SavedQueryViewHolder.java
+++ b/src/com/android/settings/search/SavedQueryViewHolder.java
@@ -25,12 +25,10 @@
public class SavedQueryViewHolder extends SearchViewHolder {
public final TextView titleView;
- public final View removeButton;
public SavedQueryViewHolder(View view) {
super(view);
titleView = view.findViewById(android.R.id.title);
- removeButton = view.findViewById(android.R.id.icon);
}
@Override
@@ -40,8 +38,7 @@
@Override
public void onBind(SearchFragment fragment, SearchResult result) {
+ itemView.setOnClickListener(v -> fragment.onSavedQueryClicked(result.title));
titleView.setText(result.title);
- titleView.setOnClickListener(v -> fragment.onSavedQueryClicked(result.title));
- removeButton.setOnClickListener(v -> fragment.onRemoveSavedQueryClicked(result.title));
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/search/SearchFragment.java b/src/com/android/settings/search/SearchFragment.java
index 2a485fe..468a196 100644
--- a/src/com/android/settings/search/SearchFragment.java
+++ b/src/com/android/settings/search/SearchFragment.java
@@ -32,6 +32,8 @@
import android.util.Pair;
import android.util.TypedValue;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
@@ -103,7 +105,7 @@
@VisibleForTesting
SearchFeatureProvider mSearchFeatureProvider;
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ @VisibleForTesting
SearchResultsAdapter mSearchAdapter;
@VisibleForTesting
@@ -165,6 +167,12 @@
}
@Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ super.onCreateOptionsMenu(menu, inflater);
+ mSavedQueryController.buildMenuItem(menu);
+ }
+
+ @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.search_panel, container, false);
@@ -361,10 +369,6 @@
onQueryTextChange(queryString);
}
- public void onRemoveSavedQueryClicked(CharSequence title) {
- mSavedQueryController.removeQuery(title.toString());
- }
-
private void restartLoaders() {
mShowingSavedQuery = false;
final LoaderManager loaderManager = getLoaderManager();
diff --git a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java b/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
index 1aed11d..0d1d7e6 100644
--- a/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
+++ b/tests/robotests/src/com/android/settings/search/CursorToSearchResultConverterTest.java
@@ -17,6 +17,8 @@
package com.android.settings.search;
+import static com.google.common.truth.Truth.assertThat;
+
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -26,14 +28,14 @@
import com.android.settings.DisplaySettings;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.dashboard.SiteMapManager;
import com.android.settings.gestures.SwipeToNotificationSettings;
import com.android.settings.search.ResultPayload.Availability;
import com.android.settings.search.ResultPayload.PayloadType;
-
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.wifi.WifiSettings;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,8 +50,6 @@
import java.util.List;
import java.util.Set;
-import static com.google.common.truth.Truth.assertThat;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class CursorToSearchResultConverterTest {
@@ -60,7 +60,7 @@
private static final String TARGET_CLASS = "a.b.c.class";
private static final String KEY = "key";
private static final Intent INTENT = new Intent("com.android.settings");
- private static final int ICON = R.drawable.ic_search_history;
+ private static final int ICON = R.drawable.ic_search_24dp;
private static final int BASE_RANK = 1;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
diff --git a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
index 093909b..d87550b 100644
--- a/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/InlineSwitchViewHolderTest.java
@@ -17,14 +17,18 @@
package com.android.settings.search;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -38,10 +42,6 @@
import java.util.ArrayList;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class InlineSwitchViewHolderTest {
@@ -65,7 +65,7 @@
public void setUp() {
MockitoAnnotations.initMocks(this);
final Context context = RuntimeEnvironment.application;
- mIcon = context.getDrawable(R.drawable.ic_search_history);
+ mIcon = context.getDrawable(R.drawable.ic_search_24dp);
FakeFeatureFactory.setupForTest(mContext);
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
diff --git a/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java b/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
index cee3c78..38e6285 100644
--- a/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/IntentSearchViewHolderTest.java
@@ -85,7 +85,7 @@
View view = LayoutInflater.from(context).inflate(R.layout.search_intent_item, null);
mHolder = new IntentSearchViewHolder(view);
- mIcon = context.getDrawable(R.drawable.ic_search_history);
+ mIcon = context.getDrawable(R.drawable.ic_search_24dp);
mBadgedIcon = context.getDrawable(R.drawable.ic_add);
when(mFragment.getActivity().getPackageManager()).thenReturn(mPackageManager);
}
diff --git a/tests/robotests/src/com/android/settings/search/SavedQueryRecorderAndRemoverTest.java b/tests/robotests/src/com/android/settings/search/SavedQueryRecorderAndRemoverTest.java
index 6d49555..af8cfe4 100644
--- a/tests/robotests/src/com/android/settings/search/SavedQueryRecorderAndRemoverTest.java
+++ b/tests/robotests/src/com/android/settings/search/SavedQueryRecorderAndRemoverTest.java
@@ -18,11 +18,13 @@
package com.android.settings.search;
+import static com.google.common.truth.Truth.assertThat;
+
import android.content.Context;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.testutils.DatabaseTestUtils;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.After;
import org.junit.Before;
@@ -33,8 +35,6 @@
import java.util.List;
-import static com.google.common.truth.Truth.assertThat;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class SavedQueryRecorderAndRemoverTest {
@@ -57,7 +57,7 @@
public void canSaveAndRemoveQuery() {
final String query = "test";
mRecorder = new SavedQueryRecorder(mContext, query);
- mRemover = new SavedQueryRemover(mContext, query);
+ mRemover = new SavedQueryRemover(mContext);
// Record a new query and load all queries from DB
mRecorder.loadInBackground();
@@ -75,4 +75,22 @@
// Saved query list should be empty because it's removed.
assertThat(results).isEmpty();
}
+
+ @Test
+ public void canRemoveAllQueriesAtOnce() {
+ mRemover = new SavedQueryRemover(mContext);;
+
+ // Record a new query and load all queries from DB
+ new SavedQueryRecorder(mContext, "Test1").loadInBackground();
+ new SavedQueryRecorder(mContext, "Test2").loadInBackground();
+ final SavedQueryLoader loader = new SavedQueryLoader(mContext);
+ List<? extends SearchResult> results = loader.loadInBackground();
+ assertThat(results.size()).isEqualTo(2);
+
+ mRemover.loadInBackground();
+ results = loader.loadInBackground();
+
+ // Saved query list should be empty because it's removed.
+ assertThat(results).isEmpty();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/search/SavedQueryViewHolderTest.java b/tests/robotests/src/com/android/settings/search/SavedQueryViewHolderTest.java
index 691fcf7..bb8f6d1 100644
--- a/tests/robotests/src/com/android/settings/search/SavedQueryViewHolderTest.java
+++ b/tests/robotests/src/com/android/settings/search/SavedQueryViewHolderTest.java
@@ -26,8 +26,8 @@
import android.view.View;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -47,7 +47,6 @@
private SavedQueryViewHolder mHolder;
private View mView;
private View mTitleView;
- private View mRemoveButton;
@Before
public void setUp() {
@@ -56,7 +55,6 @@
mView = LayoutInflater.from(mContext)
.inflate(R.layout.search_saved_query_item, null);
mTitleView = mView.findViewById(android.R.id.title);
- mRemoveButton = mView.findViewById(android.R.id.icon);
mHolder = new SavedQueryViewHolder(mView);
}
@@ -65,10 +63,8 @@
final SearchResult result = mock(SearchResult.class);
mHolder.onBind(mSearchFragment, result);
- mTitleView.performClick();
- mRemoveButton.performClick();
+ mHolder.itemView.performClick();
verify(mSearchFragment).onSavedQueryClicked(nullable(CharSequence.class));
- verify(mSearchFragment).onRemoveSavedQueryClicked(nullable(CharSequence.class));
}
}
diff --git a/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java b/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java
index e601087..cd77b25 100644
--- a/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchResultBuilderTest.java
@@ -17,14 +17,16 @@
package com.android.settings.search;
+import static com.google.common.truth.Truth.assertThat;
+
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.search.SearchResult.Builder;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -34,8 +36,6 @@
import java.util.ArrayList;
-import static com.google.common.truth.Truth.assertThat;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class SearchResultBuilderTest {
@@ -57,7 +57,7 @@
mResultPayload = new ResultPayload(new Intent());
final Context context = ShadowApplication.getInstance().getApplicationContext();
- mIcon = context.getDrawable(R.drawable.ic_search_history);
+ mIcon = context.getDrawable(R.drawable.ic_search_24dp);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java b/tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java
index 9c1453f..e605ec1 100644
--- a/tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/search/SearchResultsAdapterTest.java
@@ -17,6 +17,14 @@
package com.android.settings.search;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -26,10 +34,10 @@
import android.widget.FrameLayout;
import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
import com.android.settings.search.SearchResult.Builder;
import com.android.settings.search.ranking.SearchResultsRankerCallback;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
@@ -49,14 +57,6 @@
import java.util.Objects;
import java.util.Set;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class SearchResultsAdapterTest {
@@ -553,7 +553,7 @@
private Set<SearchResult> getIntentSampleResults() {
Set<SearchResult> sampleResults = new HashSet<>();
ArrayList<String> breadcrumbs = new ArrayList<>();
- final Drawable icon = mContext.getDrawable(R.drawable.ic_search_history);
+ final Drawable icon = mContext.getDrawable(R.drawable.ic_search_24dp);
final ResultPayload payload = new ResultPayload(null);
final SearchResult.Builder builder = new Builder();
builder.setTitle("title")