Merge "Add divider line below "see all apps" preference" into oc-dr1-dev

am: 0e9711ab92

Change-Id: I80aee4e13aff91ac66309df438511826a2b75187
This commit is contained in:
Doris Ling
2017-07-26 02:08:44 +00:00
committed by android-build-merger
4 changed files with 21 additions and 2 deletions

View File

@@ -40,6 +40,11 @@
</Preference> </Preference>
</PreferenceCategory> </PreferenceCategory>
<!-- Empty category to draw divider -->
<PreferenceCategory
android:key="all_app_info_divider"
android:order="-190"/>
<Preference <Preference
android:key="manage_perms" android:key="manage_perms"
android:title="@string/app_permissions" android:title="@string/app_permissions"

View File

@@ -50,7 +50,7 @@ public class AppAndNotificationDashboardFragment extends DashboardFragment {
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
super.onAttach(context); super.onAttach(context);
mProgressiveDisclosureMixin.setTileLimit(3); mProgressiveDisclosureMixin.setTileLimit(4);
} }
@Override @Override

View File

@@ -62,6 +62,8 @@ public class RecentAppsPreferenceController extends PreferenceController
private static final String TAG = "RecentAppsCtrl"; private static final String TAG = "RecentAppsCtrl";
private static final String KEY_PREF_CATEGORY = "recent_apps_category"; private static final String KEY_PREF_CATEGORY = "recent_apps_category";
@VisibleForTesting @VisibleForTesting
static final String KEY_DIVIDER = "all_app_info_divider";
@VisibleForTesting
static final String KEY_SEE_ALL = "all_app_info"; static final String KEY_SEE_ALL = "all_app_info";
private static final int SHOW_RECENT_APP_COUNT = 5; private static final int SHOW_RECENT_APP_COUNT = 5;
private static final Set<String> SKIP_SYSTEM_PACKAGES = new ArraySet<>(); private static final Set<String> SKIP_SYSTEM_PACKAGES = new ArraySet<>();
@@ -78,6 +80,7 @@ public class RecentAppsPreferenceController extends PreferenceController
private PreferenceCategory mCategory; private PreferenceCategory mCategory;
private Preference mSeeAllPref; private Preference mSeeAllPref;
private Preference mDivider;
private boolean mHasRecentApps; private boolean mHasRecentApps;
static { static {
@@ -122,12 +125,14 @@ public class RecentAppsPreferenceController extends PreferenceController
super.updateNonIndexableKeys(keys); super.updateNonIndexableKeys(keys);
// Don't index category name into search. It's not actionable. // Don't index category name into search. It's not actionable.
keys.add(KEY_PREF_CATEGORY); keys.add(KEY_PREF_CATEGORY);
keys.add(KEY_DIVIDER);
} }
@Override @Override
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey()); mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
mSeeAllPref = screen.findPreference(KEY_SEE_ALL); mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
mDivider = screen.findPreference(KEY_DIVIDER);
super.displayPreference(screen); super.displayPreference(screen);
refreshUi(mCategory.getContext()); refreshUi(mCategory.getContext());
} }
@@ -181,6 +186,7 @@ public class RecentAppsPreferenceController extends PreferenceController
private void displayOnlyAppInfo() { private void displayOnlyAppInfo() {
mCategory.setTitle(null); mCategory.setTitle(null);
mDivider.setVisible(false);
mSeeAllPref.setTitle(R.string.applications_settings); mSeeAllPref.setTitle(R.string.applications_settings);
mSeeAllPref.setIcon(null); mSeeAllPref.setIcon(null);
int prefCount = mCategory.getPreferenceCount(); int prefCount = mCategory.getPreferenceCount();
@@ -194,6 +200,7 @@ public class RecentAppsPreferenceController extends PreferenceController
private void displayRecentApps(Context prefContext, List<UsageStats> recentApps) { private void displayRecentApps(Context prefContext, List<UsageStats> recentApps) {
mCategory.setTitle(R.string.recent_app_category_title); mCategory.setTitle(R.string.recent_app_category_title);
mDivider.setVisible(true);
mSeeAllPref.setSummary(null); mSeeAllPref.setSummary(null);
mSeeAllPref.setIcon(R.drawable.ic_chevron_right_24dp); mSeeAllPref.setIcon(R.drawable.ic_chevron_right_24dp);

View File

@@ -72,6 +72,8 @@ public class RecentAppsPreferenceControllerTest {
private PreferenceCategory mCategory; private PreferenceCategory mCategory;
@Mock @Mock
private Preference mSeeAllPref; private Preference mSeeAllPref;
@Mock
private PreferenceCategory mDivider;
@Mock(answer = Answers.RETURNS_DEEP_STUBS) @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mMockContext; private Context mMockContext;
@Mock @Mock
@@ -98,6 +100,8 @@ public class RecentAppsPreferenceControllerTest {
when(mScreen.findPreference(RecentAppsPreferenceController.KEY_SEE_ALL)) when(mScreen.findPreference(RecentAppsPreferenceController.KEY_SEE_ALL))
.thenReturn(mSeeAllPref); .thenReturn(mSeeAllPref);
when(mScreen.findPreference(RecentAppsPreferenceController.KEY_DIVIDER))
.thenReturn(mDivider);
when(mCategory.getContext()).thenReturn(mContext); when(mCategory.getContext()).thenReturn(mContext);
} }
@@ -112,7 +116,8 @@ public class RecentAppsPreferenceControllerTest {
mController.updateNonIndexableKeys(nonIndexable); mController.updateNonIndexableKeys(nonIndexable);
assertThat(nonIndexable).containsExactly(mController.getPreferenceKey()); assertThat(nonIndexable).containsAllOf(mController.getPreferenceKey(),
RecentAppsPreferenceController.KEY_DIVIDER);
} }
@Test @Test
@@ -140,6 +145,7 @@ public class RecentAppsPreferenceControllerTest {
verify(mCategory).setTitle(null); verify(mCategory).setTitle(null);
verify(mSeeAllPref).setTitle(R.string.applications_settings); verify(mSeeAllPref).setTitle(R.string.applications_settings);
verify(mSeeAllPref).setIcon(null); verify(mSeeAllPref).setIcon(null);
verify(mDivider).setVisible(false);
} }
@Test @Test
@@ -186,6 +192,7 @@ public class RecentAppsPreferenceControllerTest {
verify(mSeeAllPref).setSummary(null); verify(mSeeAllPref).setSummary(null);
verify(mSeeAllPref).setIcon(R.drawable.ic_chevron_right_24dp); verify(mSeeAllPref).setIcon(R.drawable.ic_chevron_right_24dp);
verify(mDivider).setVisible(true);
} }
@Test @Test