use of com.android.settingslib.location.RecentLocationAccesses in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RecentLocationAccessPreferenceController method updateRecentApps.
private void updateRecentApps() {
final List<RecentLocationAccesses.Access> recentLocationAccesses = mRecentLocationAccesses.getAppListSorted();
if (recentLocationAccesses.size() > 0) {
// Display the top 3 preferences to container in original order.
int i = 0;
for (; i < Math.min(recentLocationAccesses.size(), MAXIMUM_APP_COUNT); i++) {
final RecentLocationAccesses.Access access = recentLocationAccesses.get(i);
final AppEntityInfo appEntityInfo = new AppEntityInfo.Builder().setIcon(access.icon).setTitle(access.label).setSummary(StringUtil.formatRelativeTime(mContext, System.currentTimeMillis() - access.accessFinishTime, false, RelativeDateTimeFormatter.Style.SHORT)).setOnClickListener((v) -> {
final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSION);
intent.putExtra(Intent.EXTRA_PERMISSION_NAME, Manifest.permission.ACCESS_FINE_LOCATION);
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, access.packageName);
intent.putExtra(Intent.EXTRA_USER, access.userHandle);
mContext.startActivity(intent);
}).build();
mController.setAppEntity(i, appEntityInfo);
}
for (; i < MAXIMUM_APP_COUNT; i++) {
mController.removeAppEntity(i);
}
}
mController.apply();
}
use of com.android.settingslib.location.RecentLocationAccesses in project android_packages_apps_Settings by omnirom.
the class RecentLocationAccessPreferenceController method displayPreference.
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mCategoryRecentLocationRequests = screen.findPreference(getPreferenceKey());
final Context prefContext = mCategoryRecentLocationRequests.getContext();
final List<RecentLocationAccesses.Access> recentLocationAccesses = new ArrayList<>();
final UserManager userManager = UserManager.get(mContext);
for (RecentLocationAccesses.Access access : mRecentLocationApps.getAppListSorted(/* showSystemApps= */
false)) {
if (isRequestMatchesProfileType(userManager, access, mType)) {
recentLocationAccesses.add(access);
if (recentLocationAccesses.size() == MAX_APPS) {
break;
}
}
}
if (recentLocationAccesses.size() > 0) {
// Add preferences to container in original order (already sorted by recency).
for (RecentLocationAccesses.Access access : recentLocationAccesses) {
mCategoryRecentLocationRequests.addPreference(createAppPreference(prefContext, access, mFragment));
}
} else {
// If there's no item to display, add a "No recent apps" item.
final Preference banner = new AppPreference(prefContext);
banner.setTitle(R.string.location_no_recent_accesses);
banner.setSelectable(false);
mCategoryRecentLocationRequests.addPreference(banner);
}
}
use of com.android.settingslib.location.RecentLocationAccesses in project android_packages_apps_Settings by omnirom.
the class RecentLocationAccessSeeAllPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
mCategoryAllRecentLocationAccess.removeAll();
mPreference = preference;
final UserManager userManager = UserManager.get(mContext);
final List<RecentLocationAccesses.Access> recentLocationAccesses = new ArrayList<>();
for (RecentLocationAccesses.Access access : mRecentLocationAccesses.getAppListSorted(mShowSystem)) {
if (isRequestMatchesProfileType(userManager, access, mType)) {
recentLocationAccesses.add(access);
}
}
if (recentLocationAccesses.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);
mCategoryAllRecentLocationAccess.addPreference(banner);
} else {
for (RecentLocationAccesses.Access request : recentLocationAccesses) {
final Preference appPreference = createAppPreference(preference.getContext(), request, mFragment);
mCategoryAllRecentLocationAccess.addPreference(appPreference);
}
}
}
Aggregations