Merge "Revert "Initial search bar implementation."" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
dfc1983601
@@ -22,10 +22,9 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
||||
android-support-v4 \
|
||||
android-support-v13 \
|
||||
android-support-v7-appcompat \
|
||||
android-support-v7-cardview \
|
||||
android-support-v7-preference \
|
||||
android-support-v7-recyclerview \
|
||||
android-support-v7-preference \
|
||||
android-support-v7-appcompat \
|
||||
android-support-v14-preference
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := \
|
||||
|
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2017 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:padding="@dimen/search_bar_margin">
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/actionBarSize"/>
|
||||
</LinearLayout>
|
@@ -18,31 +18,7 @@
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
<FrameLayout
|
||||
android:id="@+id/main_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"/>
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/search_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/search_bar_margin"
|
||||
app:cardCornerRadius="2dp"
|
||||
app:cardBackgroundColor="?android:attr/colorBackground"
|
||||
app:cardElevation="2dp">
|
||||
<Toolbar
|
||||
android:id="@+id/search_action_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/search_bar_negative_margin"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:navigationIcon="@drawable/ic_search_24dp"
|
||||
android:title="@string/search_menu"
|
||||
android:titleTextAppearance="?android:attr/subtitleTextAppearance"
|
||||
android:titleTextColor="?android:attr/textColorHint"
|
||||
android:theme="?android:attr/actionBarTheme"/>
|
||||
</android.support.v7.widget.CardView>
|
||||
</FrameLayout>
|
||||
android:id="@+id/main_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
/>
|
||||
|
@@ -140,12 +140,6 @@
|
||||
<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. -->
|
||||
<dimen name="search_bar_margin">8dp</dimen>
|
||||
<dimen name="search_bar_negative_margin">-8dp</dimen>
|
||||
|
||||
<!-- Dimensions for Wifi Assistant Card -->
|
||||
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>
|
||||
<dimen name="wifi_assistant_padding_start_end">16dp</dimen>
|
||||
|
@@ -50,7 +50,6 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settings.Settings.WifiSettingsActivity;
|
||||
@@ -63,7 +62,6 @@ import com.android.settings.dashboard.DashboardSummary;
|
||||
import com.android.settings.development.DevelopmentSettings;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.DynamicIndexableContentMonitor;
|
||||
import com.android.settings.search2.SearchActivity;
|
||||
import com.android.settings.search2.SearchFeatureProvider;
|
||||
import com.android.settings.wfd.WifiDisplaySettings;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
@@ -77,7 +75,7 @@ import java.util.Set;
|
||||
public class SettingsActivity extends SettingsDrawerActivity
|
||||
implements PreferenceManager.OnPreferenceTreeClickListener,
|
||||
PreferenceFragment.OnPreferenceStartFragmentCallback,
|
||||
ButtonBarHandler, FragmentManager.OnBackStackChangedListener, OnClickListener {
|
||||
ButtonBarHandler, FragmentManager.OnBackStackChangedListener {
|
||||
|
||||
private static final String LOG_TAG = "Settings";
|
||||
|
||||
@@ -347,14 +345,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
launchSettingFragment(initialFragmentName, isSubSettings, intent);
|
||||
}
|
||||
|
||||
if (mIsShowingDashboard) {
|
||||
findViewById(R.id.search_bar).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.action_bar).setVisibility(View.GONE);
|
||||
Toolbar toolbar = findViewById(R.id.search_action_bar);
|
||||
toolbar.setOnClickListener(this);
|
||||
setActionBar(toolbar);
|
||||
}
|
||||
|
||||
mActionBar = getActionBar();
|
||||
if (mActionBar != null) {
|
||||
mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
|
||||
@@ -442,10 +432,10 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
switchToFragment(initialFragmentName, initialArguments, true, false,
|
||||
mInitialTitleResId, mInitialTitle, false);
|
||||
} else {
|
||||
// Show search icon as up affordance if we are displaying the main Dashboard
|
||||
mDisplayHomeAsUpEnabled = true;
|
||||
// toolbar is search affordance so don't show search
|
||||
mDisplaySearch = false;
|
||||
// No UP affordance if we are displaying the main Dashboard
|
||||
mDisplayHomeAsUpEnabled = false;
|
||||
// Show Search affordance
|
||||
mDisplaySearch = true;
|
||||
mInitialTitleResId = R.string.dashboard_title;
|
||||
|
||||
switchToFragment(DashboardSummary.class.getName(), null /* args */, false, false,
|
||||
@@ -949,10 +939,4 @@ public class SettingsActivity extends SettingsDrawerActivity
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(this, SearchActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import android.annotation.AttrRes;
|
||||
import android.annotation.ColorInt;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
@@ -57,7 +55,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
private static final String STATE_CATEGORY_LIST = "category_list";
|
||||
private static final String STATE_SUGGESTION_MODE = "suggestion_mode";
|
||||
private static final String STATE_SUGGESTIONS_SHOWN_LOGGED = "suggestions_shown_logged";
|
||||
private static final int DONT_SET_BACKGROUND_ATTR = -1;
|
||||
|
||||
private final IconCache mCache;
|
||||
private final Context mContext;
|
||||
@@ -225,9 +222,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
public void onBindViewHolder(DashboardItemHolder holder, int position) {
|
||||
final int type = mDashboardData.getItemTypeByPosition(position);
|
||||
switch (type) {
|
||||
case R.layout.dashboard_header_spacer:
|
||||
onBindHeaderSpacer(holder, position);
|
||||
break;
|
||||
case R.layout.dashboard_category:
|
||||
onBindCategory(holder,
|
||||
(DashboardCategory) mDashboardData.getItemEntityByPosition(position));
|
||||
@@ -358,33 +352,6 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
notifyDashboardDataChanged(prevData);
|
||||
}
|
||||
|
||||
private void onBindHeaderSpacer(DashboardItemHolder holder, int position) {
|
||||
if (mDashboardData.size() > (position + 1)) {
|
||||
// The spacer that goes underneath the search bar needs to match the
|
||||
// background of the first real view. That view is either a condition,
|
||||
// a suggestion, or the dashboard item.
|
||||
//
|
||||
// If it's a dashboard item, set null background so it uses the parent's
|
||||
// background like the other views. Otherwise, match the colors.
|
||||
int nextType = mDashboardData.getItemTypeByPosition(position + 1);
|
||||
int colorAttr = nextType == R.layout.suggestion_header
|
||||
? android.R.attr.colorSecondary
|
||||
: nextType == R.layout.condition_card
|
||||
? android.R.attr.colorAccent
|
||||
: DONT_SET_BACKGROUND_ATTR;
|
||||
|
||||
if (colorAttr != DONT_SET_BACKGROUND_ATTR) {
|
||||
TypedArray array = holder.itemView.getContext()
|
||||
.obtainStyledAttributes(new int[]{colorAttr});
|
||||
@ColorInt int color = array.getColor(0, 0);
|
||||
array.recycle();
|
||||
holder.itemView.setBackgroundColor(color);
|
||||
} else {
|
||||
holder.itemView.setBackground(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void onBindSuggestionHeader(final DashboardItemHolder holder, DashboardData
|
||||
.SuggestionHeaderData data) {
|
||||
|
@@ -45,8 +45,7 @@ public class DashboardData {
|
||||
public static final int DEFAULT_SUGGESTION_COUNT = 2;
|
||||
|
||||
// id namespace for different type of items.
|
||||
private static final int NS_HEADER_SPACER = 0;
|
||||
private static final int NS_SPACER = 1000;
|
||||
private static final int NS_SPACER = 0;
|
||||
private static final int NS_ITEMS = 2000;
|
||||
private static final int NS_CONDITION = 3000;
|
||||
|
||||
@@ -229,9 +228,6 @@ public class DashboardData {
|
||||
* and mIsShowingAll, mSuggestionMode flag.
|
||||
*/
|
||||
private void buildItemsData() {
|
||||
// add the view that goes under the search bar
|
||||
countItem(null, R.layout.dashboard_header_spacer, true, NS_HEADER_SPACER);
|
||||
resetCount();
|
||||
boolean hasConditions = false;
|
||||
for (int i = 0; mConditions != null && i < mConditions.size(); i++) {
|
||||
boolean shouldShow = mConditions.get(i).shouldShow();
|
||||
|
@@ -54,10 +54,13 @@ public class SearchFeatureProviderImpl implements SearchFeatureProvider {
|
||||
String menuTitle = activity.getString(R.string.search_menu);
|
||||
MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, menuTitle)
|
||||
.setIcon(R.drawable.ic_search_24dp)
|
||||
.setOnMenuItemClickListener(item -> {
|
||||
Intent intent = new Intent(activity, SearchActivity.class);
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
Intent intent = new Intent(activity, SearchActivity.class);
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
|
@@ -20,15 +20,12 @@ import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
|
||||
import com.android.settings.search2.SearchActivity;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -38,7 +35,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@@ -142,15 +138,4 @@ public class SettingsActivityTest {
|
||||
|
||||
assertThat(mActivity.mDisplaySearch).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnClick() {
|
||||
doReturn("com.android.settings").when(mActivity).getPackageName();
|
||||
|
||||
mActivity.onClick(null);
|
||||
|
||||
Intent intent = ShadowApplication.getInstance().getNextStartedActivity();
|
||||
assertThat(intent.getComponent()).isEqualTo(
|
||||
new ComponentName("com.android.settings", SearchActivity.class.getName()));
|
||||
}
|
||||
}
|
||||
|
@@ -19,23 +19,16 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.dashboard.conditional.Condition;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settings.testutils.shadow.ShadowDynamicIndexableContentMonitor;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -54,7 +47,6 @@ import java.util.List;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -107,53 +99,6 @@ public class DashboardAdapterTest {
|
||||
when(mView.getTag()).thenReturn(mCondition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnBindViewHolder_spacer_noSuggestions_noConditions() {
|
||||
makeCategory();
|
||||
DashboardAdapter.DashboardItemHolder holder = setupSpacer();
|
||||
|
||||
mDashboardAdapter.onBindViewHolder(holder, 0);
|
||||
|
||||
assertThat(holder.itemView.getBackground()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnBindViewHolder_spacer_suggestion_noConditions() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
makeCategory();
|
||||
DashboardAdapter.DashboardItemHolder holder = setupSpacer();
|
||||
|
||||
mDashboardAdapter.onBindViewHolder(holder, 0);
|
||||
|
||||
assertThat(holder.itemView.getBackground()).isNotNull();
|
||||
assertThat(holder.itemView.getBackground()).isInstanceOf(ColorDrawable.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnBindViewHolder_spacer_noSuggestion_condition() {
|
||||
makeCondition();
|
||||
makeCategory();
|
||||
DashboardAdapter.DashboardItemHolder holder = setupSpacer();
|
||||
|
||||
mDashboardAdapter.onBindViewHolder(holder, 0);
|
||||
|
||||
assertThat(holder.itemView.getBackground()).isNotNull();
|
||||
assertThat(holder.itemView.getBackground()).isInstanceOf(ColorDrawable.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnBindViewHolder_spacer_suggestion_condition() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
makeCondition();
|
||||
makeCategory();
|
||||
DashboardAdapter.DashboardItemHolder holder = setupSpacer();
|
||||
|
||||
mDashboardAdapter.onBindViewHolder(holder, 0);
|
||||
|
||||
assertThat(holder.itemView.getBackground()).isNotNull();
|
||||
assertThat(holder.itemView.getBackground()).isInstanceOf(ColorDrawable.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetConditions_AfterSetConditions_ExpandedConditionNull() {
|
||||
mDashboardAdapter.onExpandClick(mView);
|
||||
@@ -164,7 +109,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_NotExpanded() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||
verify(mFactory.metricsFeatureProvider, times(2)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
mActionPackageCaptor.capture());
|
||||
@@ -179,7 +124,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_NotExpandedAndPaused() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||
mDashboardAdapter.onPause();
|
||||
verify(mFactory.metricsFeatureProvider, times(4)).action(
|
||||
any(Context.class), mActionCategoryCaptor.capture(),
|
||||
@@ -196,7 +141,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_Expanded() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||
mDashboardAdapter.onBindSuggestionHeader(
|
||||
mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
@@ -215,7 +160,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedAndPaused() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||
mDashboardAdapter.onBindSuggestionHeader(
|
||||
mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
@@ -238,7 +183,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedAfterPause() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||
mDashboardAdapter.onPause();
|
||||
mDashboardAdapter.onBindSuggestionHeader(
|
||||
mSuggestionHolder, mSuggestionHeaderData);
|
||||
@@ -263,7 +208,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedAfterPauseAndPausedAgain() {
|
||||
setupSuggestions(makeSuggestions("pkg1", "pkg2", "pkg3"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1", "pkg2", "pkg3"}));
|
||||
mDashboardAdapter.onPause();
|
||||
mDashboardAdapter.onBindSuggestionHeader(
|
||||
mSuggestionHolder, mSuggestionHeaderData);
|
||||
@@ -292,7 +237,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShown() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1"}));
|
||||
mDashboardAdapter.onBindSuggestionHeader(
|
||||
mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
@@ -309,7 +254,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShownAndPaused() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1"}));
|
||||
mDashboardAdapter.onBindSuggestionHeader(
|
||||
mSuggestionHolder, mSuggestionHeaderData);
|
||||
mSuggestionHolder.itemView.callOnClick();
|
||||
@@ -328,7 +273,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShownAfterPause() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1"}));
|
||||
mDashboardAdapter.onPause();
|
||||
mDashboardAdapter.onBindSuggestionHeader(
|
||||
mSuggestionHolder, mSuggestionHeaderData);
|
||||
@@ -348,7 +293,7 @@ public class DashboardAdapterTest {
|
||||
|
||||
@Test
|
||||
public void testSuggestionsLogs_ExpandedWithLessThanDefaultShownAfterPauseAndPausedAgain() {
|
||||
setupSuggestions(makeSuggestions("pkg1"));
|
||||
setUpSuggestions(makeSuggestions(new String[]{"pkg1"}));
|
||||
mDashboardAdapter.onPause();
|
||||
mDashboardAdapter.onBindSuggestionHeader(
|
||||
mSuggestionHolder, mSuggestionHeaderData);
|
||||
@@ -368,7 +313,7 @@ public class DashboardAdapterTest {
|
||||
assertThat(mActionCategoryCaptor.getAllValues().toArray()).isEqualTo(expectedActions);
|
||||
}
|
||||
|
||||
private List<Tile> makeSuggestions(String... pkgNames) {
|
||||
private List<Tile> makeSuggestions(String[] pkgNames) {
|
||||
final List<Tile> suggestions = new ArrayList<>();
|
||||
for (String pkgName : pkgNames) {
|
||||
Tile suggestion = new Tile();
|
||||
@@ -379,31 +324,11 @@ public class DashboardAdapterTest {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
private void setupSuggestions(List<Tile> suggestions) {
|
||||
private void setUpSuggestions(List<Tile> suggestions) {
|
||||
mDashboardAdapter.setCategoriesAndSuggestions(new ArrayList<>(), suggestions);
|
||||
mSuggestionHolder = mDashboardAdapter.onCreateViewHolder(
|
||||
new FrameLayout(RuntimeEnvironment.application),
|
||||
mDashboardAdapter.getItemViewType(1));
|
||||
mDashboardAdapter.getItemViewType(0));
|
||||
}
|
||||
|
||||
private void makeCondition() {
|
||||
final List<Condition> conditions = new ArrayList<>();
|
||||
Condition condition = mock(Condition.class);
|
||||
when(condition.shouldShow()).thenReturn(true);
|
||||
conditions.add(condition);
|
||||
mDashboardAdapter.setConditions(conditions);
|
||||
}
|
||||
|
||||
private void makeCategory() {
|
||||
List<DashboardCategory> categories = new ArrayList<>();
|
||||
categories.add(new DashboardCategory());
|
||||
mDashboardAdapter.setCategory(categories);
|
||||
}
|
||||
|
||||
private DashboardAdapter.DashboardItemHolder setupSpacer() {
|
||||
Context context = RuntimeEnvironment.application;
|
||||
final View view = LayoutInflater.from(context)
|
||||
.inflate(R.layout.dashboard_header_spacer, new LinearLayout(context), false);
|
||||
return new DashboardAdapter.DashboardItemHolder(view);
|
||||
}
|
||||
}
|
||||
|
@@ -112,7 +112,7 @@ public class DashboardDataTest {
|
||||
public void testBuildItemsData_containsAllData() {
|
||||
final DashboardData.SuggestionHeaderData data =
|
||||
new DashboardData.SuggestionHeaderData(false, 1, 0);
|
||||
final Object[] expectedObjects = {null, mTestCondition, null, data, mTestSuggestion,
|
||||
final Object[] expectedObjects = {mTestCondition, null, data, mTestSuggestion,
|
||||
mDashboardCategory, mTestCategoryTile};
|
||||
final int expectedSize = expectedObjects.length;
|
||||
|
||||
@@ -171,7 +171,7 @@ public class DashboardDataTest {
|
||||
@Test
|
||||
public void testDiffUtil_DataEqual_noResultData() {
|
||||
List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
||||
testDiffUtil(mDashboardDataWithOneConditions,
|
||||
testDiffUtil(mDashboardDataWithOneConditions,
|
||||
mDashboardDataWithOneConditions, testResultData);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public class DashboardDataTest {
|
||||
//Build testResultData
|
||||
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
||||
testResultData.add(new ListUpdateResult.ResultData(
|
||||
ListUpdateResult.ResultData.TYPE_OPERATION_INSERT, 2, 1));
|
||||
ListUpdateResult.ResultData.TYPE_OPERATION_INSERT, 1, 1));
|
||||
|
||||
testDiffUtil(mDashboardDataWithOneConditions,
|
||||
mDashboardDataWithTwoConditions, testResultData);
|
||||
@@ -191,7 +191,7 @@ public class DashboardDataTest {
|
||||
//Build testResultData
|
||||
final List<ListUpdateResult.ResultData> testResultData = new ArrayList<>();
|
||||
testResultData.add(new ListUpdateResult.ResultData(
|
||||
ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 1, 6));
|
||||
ListUpdateResult.ResultData.TYPE_OPERATION_REMOVE, 0, 6));
|
||||
|
||||
testDiffUtil(mDashboardDataWithOneConditions, mDashboardDataWithNoItems, testResultData);
|
||||
}
|
||||
@@ -203,8 +203,8 @@ public class DashboardDataTest {
|
||||
mDashboardDataWithOneConditions.getItemList(),
|
||||
mDashboardDataWithOneConditions.getItemList());
|
||||
|
||||
// Item in position 1 is condition card, which payload should not be null
|
||||
assertThat(callback.getChangePayload(1, 1)).isNotNull();
|
||||
// Item in position 0 is condition card, which payload should not be null
|
||||
assertThat(callback.getChangePayload(0, 0)).isNotEqualTo(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -214,9 +214,9 @@ public class DashboardDataTest {
|
||||
mDashboardDataWithOneConditions.getItemList(),
|
||||
mDashboardDataWithOneConditions.getItemList());
|
||||
|
||||
// Position 0 is spacer, 1 is condition card, so others' payload should be null
|
||||
for (int i = 2; i < mDashboardDataWithOneConditions.getItemList().size(); i++) {
|
||||
assertThat(callback.getChangePayload(i, i)).isNull();
|
||||
// Only item in position 0 is condition card, so others' payload should be null
|
||||
for (int i = 1; i < mDashboardDataWithOneConditions.getItemList().size(); i++) {
|
||||
assertThat(callback.getChangePayload(i, i)).isEqualTo(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -356,11 +356,6 @@ public class DashboardDataTest {
|
||||
|
||||
return arg2 - resultData.arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "op:" + operation + ",arg1:" + arg1 + ",arg2:" + arg2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user