From 6cd558e595a1d7cb6912b9c2cc1fb8e9e5267ecc Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Thu, 15 Jun 2017 11:11:00 -0700 Subject: [PATCH] Add divider line below "see all apps" preference Change-Id: I94cbf47fd987a6ff4c4fabcc3124fae1f0438876 Fix: 62040104 Test: make RunSettingsRoboTests --- res/xml/app_and_notification.xml | 5 +++++ .../applications/RecentAppsPreferenceController.java | 7 +++++++ .../applications/RecentAppsPreferenceControllerTest.java | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml index 47fc3785b13..4a5ee1dda91 100644 --- a/res/xml/app_and_notification.xml +++ b/res/xml/app_and_notification.xml @@ -40,6 +40,11 @@ + + + SKIP_SYSTEM_PACKAGES = new ArraySet<>(); @@ -77,6 +79,7 @@ public class RecentAppsPreferenceController extends PreferenceController private PreferenceCategory mCategory; private Preference mSeeAllPref; + private Preference mDivider; private boolean mHasRecentApps; static { @@ -121,12 +124,14 @@ public class RecentAppsPreferenceController extends PreferenceController super.updateNonIndexableKeys(keys); // Don't index category name into search. It's not actionable. keys.add(KEY_PREF_CATEGORY); + keys.add(KEY_DIVIDER); } @Override public void displayPreference(PreferenceScreen screen) { mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey()); mSeeAllPref = screen.findPreference(KEY_SEE_ALL); + mDivider = screen.findPreference(KEY_DIVIDER); super.displayPreference(screen); refreshUi(mCategory.getContext()); } @@ -180,6 +185,7 @@ public class RecentAppsPreferenceController extends PreferenceController private void displayOnlyAppInfo() { mCategory.setTitle(null); + mDivider.setVisible(false); mSeeAllPref.setTitle(R.string.applications_settings); mSeeAllPref.setIcon(null); int prefCount = mCategory.getPreferenceCount(); @@ -193,6 +199,7 @@ public class RecentAppsPreferenceController extends PreferenceController private void displayRecentApps(Context prefContext, List recentApps) { mCategory.setTitle(R.string.recent_app_category_title); + mDivider.setVisible(true); mSeeAllPref.setSummary(null); mSeeAllPref.setIcon(R.drawable.ic_chevron_right_24dp); diff --git a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java index bfc5cd3b0a4..2b18e0542a3 100644 --- a/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/RecentAppsPreferenceControllerTest.java @@ -68,6 +68,8 @@ public class RecentAppsPreferenceControllerTest { private PreferenceCategory mCategory; @Mock private Preference mSeeAllPref; + @Mock + private PreferenceCategory mDivider; @Mock(answer = Answers.RETURNS_DEEP_STUBS) private Context mMockContext; @Mock @@ -94,6 +96,8 @@ public class RecentAppsPreferenceControllerTest { when(mScreen.findPreference(RecentAppsPreferenceController.KEY_SEE_ALL)) .thenReturn(mSeeAllPref); + when(mScreen.findPreference(RecentAppsPreferenceController.KEY_DIVIDER)) + .thenReturn(mDivider); when(mCategory.getContext()).thenReturn(mContext); } @@ -108,7 +112,8 @@ public class RecentAppsPreferenceControllerTest { mController.updateNonIndexableKeys(nonIndexable); - assertThat(nonIndexable).containsExactly(mController.getPreferenceKey()); + assertThat(nonIndexable).containsAllOf(mController.getPreferenceKey(), + RecentAppsPreferenceController.KEY_DIVIDER); } @Test @@ -136,6 +141,7 @@ public class RecentAppsPreferenceControllerTest { verify(mCategory).setTitle(null); verify(mSeeAllPref).setTitle(R.string.applications_settings); verify(mSeeAllPref).setIcon(null); + verify(mDivider).setVisible(false); } @Test @@ -180,6 +186,7 @@ public class RecentAppsPreferenceControllerTest { verify(mSeeAllPref).setSummary(null); verify(mSeeAllPref).setIcon(R.drawable.ic_chevron_right_24dp); + verify(mDivider).setVisible(true); } @Test