summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
diff options
context:
space:
mode:
authorRaff Tsai <rafftsai@google.com>2019-12-13 16:46:33 +0800
committerRaff Tsai <rafftsai@google.com>2019-12-17 04:25:49 +0000
commit5ec8efe7e0d0122af047667ed49d749bd10a0c4e (patch)
tree0710e12b418b02faabb339cf32d9c33d822a11ac /src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
parentd230b552f5455344c1062511d722bbdeeae48dae (diff)
downloadpackages_apps_Settings-5ec8efe7e0d0122af047667ed49d749bd10a0c4e.tar.gz
packages_apps_Settings-5ec8efe7e0d0122af047667ed49d749bd10a0c4e.tar.bz2
packages_apps_Settings-5ec8efe7e0d0122af047667ed49d749bd10a0c4e.zip
Fix UI issue in LocationSettings
- Add WorkPreferenceController to support directly use work profile related feature in xml - Get only work/personal infos in RecentLocationRequestPreferenceController and RecentLocationRequestSeeAllPreferenceController - Remove ProfileSelectStorageFragment Bug: 141601408 Fixes: 146080649 Test: manual, robolectric Change-Id: Ide39c7a3796e16421f3a5690309c3d746a956de8
Diffstat (limited to 'src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java')
-rw-r--r--src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java b/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
index 4ed9d13add..df0fa40087 100644
--- a/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationRequestSeeAllPreferenceController.java
@@ -15,16 +15,21 @@
*/
package com.android.settings.location;
+import static com.android.settings.location.RecentLocationRequestPreferenceController.createAppPreference;
+import static com.android.settings.location.RecentLocationRequestPreferenceController.isRequestMatchesProfileType;
+
import android.content.Context;
+import android.os.UserManager;
-import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settingslib.location.RecentLocationApps;
import com.android.settingslib.widget.apppreference.AppPreference;
+import java.util.ArrayList;
import java.util.List;
/** Preference controller for preference category displaying all recent location requests. */
@@ -35,6 +40,7 @@ public class RecentLocationRequestSeeAllPreferenceController
private RecentLocationApps mRecentLocationApps;
private boolean mShowSystem = false;
private Preference mPreference;
+ private int mType = ProfileSelectFragment.ProfileType.ALL;
public RecentLocationRequestSeeAllPreferenceController(Context context, String key) {
super(context, key);
@@ -56,33 +62,39 @@ public class RecentLocationRequestSeeAllPreferenceController
public void updateState(Preference preference) {
mCategoryAllRecentLocationRequests.removeAll();
mPreference = preference;
- List<RecentLocationApps.Request> requests = mRecentLocationApps.getAppListSorted(
- mShowSystem);
- if (requests.isEmpty()) {
+
+ final UserManager userManager = UserManager.get(mContext);
+ final List<RecentLocationApps.Request> recentLocationRequests = new ArrayList<>();
+ for (RecentLocationApps.Request request : mRecentLocationApps.getAppListSorted(
+ mShowSystem)) {
+ if (isRequestMatchesProfileType(userManager, request, mType)) {
+ recentLocationRequests.add(request);
+ }
+ }
+
+ if (recentLocationRequests.isEmpty()) {
// If there's no item to display, add a "No recent apps" item.
final Preference banner = new AppPreference(mContext);
banner.setTitle(R.string.location_no_recent_apps);
banner.setSelectable(false);
mCategoryAllRecentLocationRequests.addPreference(banner);
} else {
- for (RecentLocationApps.Request request : requests) {
- Preference appPreference = createAppPreference(preference.getContext(), request);
+ for (RecentLocationApps.Request request : recentLocationRequests) {
+ final Preference appPreference = createAppPreference(
+ preference.getContext(),
+ request, mFragment);
mCategoryAllRecentLocationRequests.addPreference(appPreference);
}
}
}
- @VisibleForTesting
- AppPreference createAppPreference(
- Context prefContext, RecentLocationApps.Request request) {
- final AppPreference pref = new AppPreference(prefContext);
- pref.setSummary(request.contentDescription);
- pref.setIcon(request.icon);
- pref.setTitle(request.label);
- pref.setOnPreferenceClickListener(
- new RecentLocationRequestPreferenceController.PackageEntryClickedListener(
- mFragment, request.packageName, request.userHandle));
- return pref;
+ /**
+ * Initialize {@link ProfileSelectFragment.ProfileType} of the controller
+ *
+ * @param type {@link ProfileSelectFragment.ProfileType} of the controller.
+ */
+ public void setProfileType(@ProfileSelectFragment.ProfileType int type) {
+ mType = type;
}
public void setShowSystem(boolean showSystem) {