Search in sources :

Example 1 with AppEntityInfo

use of com.android.settingslib.widget.AppEntityInfo 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();
}
Also used : Context(android.content.Context) PreferenceScreen(androidx.preference.PreferenceScreen) LayoutPreference(com.android.settingslib.widget.LayoutPreference) RelativeDateTimeFormatter(android.icu.text.RelativeDateTimeFormatter) PreferenceControllerMixin(com.android.settings.core.PreferenceControllerMixin) Intent(android.content.Intent) Preference(androidx.preference.Preference) Manifest(android.Manifest) List(java.util.List) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) Utils(com.android.settings.Utils) DAYS(java.util.concurrent.TimeUnit.DAYS) StringUtil(com.android.settingslib.utils.StringUtil) View(android.view.View) RecentLocationAccesses(com.android.settingslib.location.RecentLocationAccesses) AppEntityInfo(com.android.settingslib.widget.AppEntityInfo) AppEntitiesHeaderController(com.android.settingslib.widget.AppEntitiesHeaderController) DeviceConfig(android.provider.DeviceConfig) VisibleForTesting(androidx.annotation.VisibleForTesting) R(com.android.settings.R) AppEntityInfo(com.android.settingslib.widget.AppEntityInfo) RecentLocationAccesses(com.android.settingslib.location.RecentLocationAccesses) Intent(android.content.Intent)

Aggregations

Manifest (android.Manifest)1 Context (android.content.Context)1 Intent (android.content.Intent)1 RelativeDateTimeFormatter (android.icu.text.RelativeDateTimeFormatter)1 DeviceConfig (android.provider.DeviceConfig)1 View (android.view.View)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 Preference (androidx.preference.Preference)1 PreferenceScreen (androidx.preference.PreferenceScreen)1 R (com.android.settings.R)1 Utils (com.android.settings.Utils)1 PreferenceControllerMixin (com.android.settings.core.PreferenceControllerMixin)1 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)1 RecentLocationAccesses (com.android.settingslib.location.RecentLocationAccesses)1 StringUtil (com.android.settingslib.utils.StringUtil)1 AppEntitiesHeaderController (com.android.settingslib.widget.AppEntitiesHeaderController)1 AppEntityInfo (com.android.settingslib.widget.AppEntityInfo)1 LayoutPreference (com.android.settingslib.widget.LayoutPreference)1 List (java.util.List)1 DAYS (java.util.concurrent.TimeUnit.DAYS)1