use of com.android.settingslib.widget.AppPreference in project android_packages_apps_Settings by omnirom.
the class AppConversationListPreferenceController method createConversationPref.
protected Preference createConversationPref(final ConversationChannelWrapper conversation) {
AppPreference pref = new AppPreference(mContext);
populateConversationPreference(conversation, pref);
return pref;
}
use of com.android.settingslib.widget.AppPreference in project android_packages_apps_Settings by omnirom.
the class PasswordsPreferenceController method addPasswordPreferences.
private void addPasswordPreferences(Context prefContext, @UserIdInt int user, PreferenceGroup group) {
for (int i = 0; i < mServices.size(); i++) {
final AutofillServiceInfo service = mServices.get(i);
final AppPreference pref = new AppPreference(prefContext);
final ServiceInfo serviceInfo = service.getServiceInfo();
pref.setTitle(serviceInfo.loadLabel(mPm));
final Drawable icon = mIconFactory.getBadgedIcon(serviceInfo, serviceInfo.applicationInfo, user);
pref.setIcon(Utils.getSafeIcon(icon));
pref.setOnPreferenceClickListener(p -> {
final Intent intent = new Intent(Intent.ACTION_MAIN).setClassName(serviceInfo.packageName, service.getPasswordsActivity());
prefContext.startActivityAsUser(intent, UserHandle.of(user));
return true;
});
// Set a placeholder summary to avoid a UI flicker when the value loads.
pref.setSummary(R.string.autofill_passwords_count_placeholder);
final MutableLiveData<Integer> passwordCount = new MutableLiveData<>();
passwordCount.observe(mLifecycleOwner, count -> {
// TODO(b/169455298): Validate the result.
final CharSequence summary = mContext.getResources().getQuantityString(R.plurals.autofill_passwords_count, count, count);
pref.setSummary(summary);
});
// TODO(b/169455298): Limit the number of concurrent queries.
// TODO(b/169455298): Cache the results for some time.
requestSavedPasswordCount(service, user, passwordCount);
group.addPreference(pref);
}
}
use of com.android.settingslib.widget.AppPreference in project android_packages_apps_Settings by omnirom.
the class RecentLocationRequestPreferenceController method displayPreference.
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mCategoryRecentLocationRequests = screen.findPreference(getPreferenceKey());
final Context prefContext = mCategoryRecentLocationRequests.getContext();
final List<RecentLocationApps.Request> recentLocationRequests = new ArrayList<>();
final UserManager userManager = UserManager.get(mContext);
for (RecentLocationApps.Request request : mRecentLocationApps.getAppListSorted(false)) {
if (isRequestMatchesProfileType(userManager, request, mType)) {
recentLocationRequests.add(request);
if (recentLocationRequests.size() == MAX_APPS) {
break;
}
}
}
if (recentLocationRequests.size() > 0) {
// Add preferences to container in original order (already sorted by recency).
for (RecentLocationApps.Request request : recentLocationRequests) {
mCategoryRecentLocationRequests.addPreference(createAppPreference(prefContext, request, 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_apps);
banner.setSelectable(false);
mCategoryRecentLocationRequests.addPreference(banner);
}
}
use of com.android.settingslib.widget.AppPreference in project android_packages_apps_Settings by omnirom.
the class RecentLocationRequestSeeAllPreferenceController method updateState.
@Override
public void updateState(Preference preference) {
mCategoryAllRecentLocationRequests.removeAll();
mPreference = preference;
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 : recentLocationRequests) {
final Preference appPreference = createAppPreference(preference.getContext(), request, mFragment);
mCategoryAllRecentLocationRequests.addPreference(appPreference);
}
}
}
use of com.android.settingslib.widget.AppPreference in project android_packages_apps_Settings by omnirom.
the class RecentLocationAccessPreferenceController method createAppPreference.
/**
* Create a {@link AppPreference}
*/
public static AppPreference createAppPreference(Context prefContext, RecentLocationAccesses.Access access, DashboardFragment fragment) {
final AppPreference pref = new AppPreference(prefContext);
pref.setIcon(access.icon);
pref.setTitle(access.label);
pref.setSummary(StringUtil.formatRelativeTime(prefContext, System.currentTimeMillis() - access.accessFinishTime, false, RelativeDateTimeFormatter.Style.SHORT));
pref.setOnPreferenceClickListener(new PackageEntryClickedListener(fragment.getContext(), access.packageName, access.userHandle));
return pref;
}
Aggregations