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;
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.applications.manageapplications;
|
||||
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_PERSONAL_ONLY;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.EXTRA_WORK_ONLY;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||
|
||||
/**
|
||||
* Application Setting page for work profile.
|
||||
*/
|
||||
public class ProfileSelectManageApplications extends ProfileSelectFragment {
|
||||
|
||||
@Override
|
||||
public Fragment[] getFragments() {
|
||||
final Bundle workOnly = new Bundle();
|
||||
workOnly.putBoolean(EXTRA_WORK_ONLY, true);
|
||||
final Fragment workFragment = new ManageApplications();
|
||||
workFragment.setArguments(workOnly);
|
||||
|
||||
final Bundle personalOnly = new Bundle();
|
||||
personalOnly.putBoolean(EXTRA_PERSONAL_ONLY, true);
|
||||
final Fragment personalFragment = new ManageApplications();
|
||||
personalFragment.setArguments(personalOnly);
|
||||
return new Fragment[] {
|
||||
personalFragment, //0
|
||||
workFragment
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user