Add personal/work tab for ManageApplications
- Add ProfileSelectManageApplications containing tabLayout - Modify StorageItemPreferenceController to display only personal or work profile data - Add getTargetFragment in Utils to handle fragment selection Bug: 141601408 Test: manual Change-Id: Ie4db1ce2e77f60a82018e5a3e1f2fccb812502dc
This commit is contained in:
@@ -143,6 +143,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
public static final String EXTRA_STORAGE_TYPE = "storageType";
|
||||
public static final String EXTRA_WORK_ONLY = "workProfileOnly";
|
||||
public static final String EXTRA_WORK_ID = "workId";
|
||||
public static final String EXTRA_PERSONAL_ONLY = "personalOnly";
|
||||
|
||||
private static final String EXTRA_SORT_ORDER = "sortOrder";
|
||||
private static final String EXTRA_SHOW_SYSTEM = "showSystem";
|
||||
@@ -234,6 +235,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
private int mStorageType;
|
||||
private boolean mIsWorkOnly;
|
||||
private int mWorkUserId;
|
||||
private boolean mIsPersonalOnly;
|
||||
private View mEmptyView;
|
||||
private int mFilterType;
|
||||
|
||||
@@ -308,6 +310,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
}
|
||||
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
|
||||
mFilter = appFilterRegistry.get(appFilterRegistry.getDefaultFilterType(mListType));
|
||||
mIsPersonalOnly = args != null ? args.getBoolean(EXTRA_PERSONAL_ONLY) : false;
|
||||
mIsWorkOnly = args != null ? args.getBoolean(EXTRA_WORK_ONLY) : false;
|
||||
mWorkUserId = args != null ? args.getInt(EXTRA_WORK_ID) : NO_USER_SPECIFIED;
|
||||
mExpandSearch = activity.getIntent().getBooleanExtra(EXTRA_EXPAND_SEARCH_VIEW, false);
|
||||
@@ -405,8 +408,22 @@ public class ManageApplications extends InstrumentedFragment
|
||||
|
||||
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
|
||||
mFilterAdapter.enableFilter(appFilterRegistry.getDefaultFilterType(mListType));
|
||||
|
||||
AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
|
||||
if (mIsWorkOnly) {
|
||||
compositeFilter = new CompoundFilter(compositeFilter, ApplicationsState.FILTER_WORK);
|
||||
}
|
||||
if (mIsPersonalOnly) {
|
||||
compositeFilter = new CompoundFilter(compositeFilter,
|
||||
ApplicationsState.FILTER_PERSONAL);
|
||||
}
|
||||
if (compositeFilter != null) {
|
||||
mApplications.setCompositeFilter(compositeFilter);
|
||||
}
|
||||
|
||||
if (mListType == LIST_TYPE_MAIN) {
|
||||
if (UserManager.get(getActivity()).getUserProfiles().size() > 1) {
|
||||
if (UserManager.get(getActivity()).getUserProfiles().size() > 1 && !mIsWorkOnly
|
||||
&& !mIsPersonalOnly) {
|
||||
mFilterAdapter.enableFilter(FILTER_APPS_PERSONAL);
|
||||
mFilterAdapter.enableFilter(FILTER_APPS_WORK);
|
||||
}
|
||||
@@ -420,15 +437,6 @@ public class ManageApplications extends InstrumentedFragment
|
||||
if (mListType == LIST_TYPE_HIGH_POWER) {
|
||||
mFilterAdapter.enableFilter(FILTER_APPS_POWER_WHITELIST_ALL);
|
||||
}
|
||||
|
||||
AppFilter compositeFilter = getCompositeFilter(mListType, mStorageType, mVolumeUuid);
|
||||
if (mIsWorkOnly) {
|
||||
final AppFilter workFilter = appFilterRegistry.get(FILTER_APPS_WORK).getFilter();
|
||||
compositeFilter = new CompoundFilter(compositeFilter, workFilter);
|
||||
}
|
||||
if (compositeFilter != null) {
|
||||
mApplications.setCompositeFilter(compositeFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -449,9 +457,11 @@ public class ManageApplications extends InstrumentedFragment
|
||||
return new CompoundFilter(ApplicationsState.FILTER_MOVIES, filter);
|
||||
} else if (listType == LIST_TYPE_PHOTOGRAPHY) {
|
||||
return new CompoundFilter(ApplicationsState.FILTER_PHOTOS, filter);
|
||||
} else {
|
||||
final AppFilterRegistry appFilterRegistry = AppFilterRegistry.getInstance();
|
||||
return appFilterRegistry.get(
|
||||
appFilterRegistry.getDefaultFilterType(listType)).getFilter();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -508,7 +518,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
|
||||
outState.putBoolean(EXTRA_HAS_ENTRIES, mApplications.mHasReceivedLoadEntries);
|
||||
outState.putBoolean(EXTRA_HAS_BRIDGE, mApplications.mHasReceivedBridgeCallback);
|
||||
if(mSearchView != null) {
|
||||
if (mSearchView != null) {
|
||||
outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
|
||||
}
|
||||
if (mApplications != null) {
|
||||
@@ -1166,7 +1176,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
mSearchFilter = new SearchFilter();
|
||||
}
|
||||
// If we haven't load apps list completely, don't filter anything.
|
||||
if(mOriginalEntries == null) {
|
||||
if (mOriginalEntries == null) {
|
||||
Log.w(TAG, "Apps haven't loaded completely yet, so nothing can be filtered");
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user