Search in sources :

Example 6 with EnterpriseDefaultApps

use of com.android.settings.applications.EnterpriseDefaultApps in project platform_packages_apps_Settings by BlissRoms.

the class EnterpriseSetDefaultAppsListPreferenceController method createPreferences.

private void createPreferences(Context prefContext, PreferenceGroup group, EnumMap<EnterpriseDefaultApps, List<ApplicationInfo>> apps) {
    if (group == null) {
        return;
    }
    for (EnterpriseDefaultApps typeOfDefault : EnterpriseDefaultApps.values()) {
        final List<ApplicationInfo> appsForCategory = apps.get(typeOfDefault);
        if (appsForCategory == null || appsForCategory.isEmpty()) {
            continue;
        }
        final Preference preference = new Preference(prefContext);
        preference.setTitle(getTitle(prefContext, typeOfDefault, appsForCategory.size()));
        preference.setSummary(buildSummaryString(prefContext, appsForCategory));
        preference.setOrder(typeOfDefault.ordinal());
        preference.setSelectable(false);
        group.addPreference(preference);
    }
}
Also used : EnterpriseDefaultApps(com.android.settings.applications.EnterpriseDefaultApps) Preference(android.support.v7.preference.Preference) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 7 with EnterpriseDefaultApps

use of com.android.settings.applications.EnterpriseDefaultApps in project platform_packages_apps_Settings by BlissRoms.

the class EnterpriseSetDefaultAppsListPreferenceController method buildAppList.

/**
 * Builds data for UI. Updates mUsers and mApps so that they contain non-empty list.
 */
private void buildAppList() {
    mUsers = new ArrayList<>();
    mApps = new ArrayList<>();
    for (UserHandle user : mUserFeatureProvider.getUserProfiles()) {
        boolean hasDefaultsForUser = false;
        EnumMap<EnterpriseDefaultApps, List<ApplicationInfo>> userMap = null;
        for (EnterpriseDefaultApps typeOfDefault : EnterpriseDefaultApps.values()) {
            List<UserAppInfo> apps = mApplicationFeatureProvider.findPersistentPreferredActivities(user.getIdentifier(), typeOfDefault.getIntents());
            if (apps.isEmpty()) {
                continue;
            }
            if (!hasDefaultsForUser) {
                hasDefaultsForUser = true;
                mUsers.add(apps.get(0).userInfo);
                userMap = new EnumMap<>(EnterpriseDefaultApps.class);
                mApps.add(userMap);
            }
            ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
            for (UserAppInfo userAppInfo : apps) {
                applicationInfos.add(userAppInfo.appInfo);
            }
            userMap.put(typeOfDefault, applicationInfos);
        }
    }
    new Handler(mContext.getMainLooper()).post(() -> {
        updateUi();
    });
}
Also used : EnterpriseDefaultApps(com.android.settings.applications.EnterpriseDefaultApps) ApplicationInfo(android.content.pm.ApplicationInfo) ArrayList(java.util.ArrayList) Handler(android.os.Handler) UserHandle(android.os.UserHandle) UserAppInfo(com.android.settings.applications.UserAppInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with EnterpriseDefaultApps

use of com.android.settings.applications.EnterpriseDefaultApps in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class EnterpriseSetDefaultAppsListPreferenceController method buildAppList.

/**
 * Builds data for UI. Updates mUsers and mApps so that they contain non-empty list.
 */
private void buildAppList() {
    mUsers = new ArrayList<>();
    mApps = new ArrayList<>();
    for (UserHandle user : mUserFeatureProvider.getUserProfiles()) {
        boolean hasDefaultsForUser = false;
        EnumMap<EnterpriseDefaultApps, List<ApplicationInfo>> userMap = null;
        for (EnterpriseDefaultApps typeOfDefault : EnterpriseDefaultApps.values()) {
            List<UserAppInfo> apps = mApplicationFeatureProvider.findPersistentPreferredActivities(user.getIdentifier(), typeOfDefault.getIntents());
            if (apps.isEmpty()) {
                continue;
            }
            if (!hasDefaultsForUser) {
                hasDefaultsForUser = true;
                mUsers.add(apps.get(0).userInfo);
                userMap = new EnumMap<>(EnterpriseDefaultApps.class);
                mApps.add(userMap);
            }
            ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
            for (UserAppInfo userAppInfo : apps) {
                applicationInfos.add(userAppInfo.appInfo);
            }
            userMap.put(typeOfDefault, applicationInfos);
        }
    }
    ThreadUtils.postOnMainThread(() -> updateUi());
}
Also used : EnterpriseDefaultApps(com.android.settings.applications.EnterpriseDefaultApps) UserHandle(android.os.UserHandle) UserAppInfo(com.android.settings.applications.UserAppInfo) ApplicationInfo(android.content.pm.ApplicationInfo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with EnterpriseDefaultApps

use of com.android.settings.applications.EnterpriseDefaultApps in project android_packages_apps_Settings by LineageOS.

the class EnterpriseSetDefaultAppsListPreferenceController method buildAppList.

/**
 * Builds data for UI. Updates mUsers and mApps so that they contain non-empty list.
 */
private void buildAppList() {
    mUsers = new ArrayList<>();
    mApps = new ArrayList<>();
    for (UserHandle user : mUserFeatureProvider.getUserProfiles()) {
        boolean hasDefaultsForUser = false;
        EnumMap<EnterpriseDefaultApps, List<ApplicationInfo>> userMap = null;
        for (EnterpriseDefaultApps typeOfDefault : EnterpriseDefaultApps.values()) {
            List<UserAppInfo> apps = mApplicationFeatureProvider.findPersistentPreferredActivities(user.getIdentifier(), typeOfDefault.getIntents());
            if (apps.isEmpty()) {
                continue;
            }
            if (!hasDefaultsForUser) {
                hasDefaultsForUser = true;
                mUsers.add(apps.get(0).userInfo);
                userMap = new EnumMap<>(EnterpriseDefaultApps.class);
                mApps.add(userMap);
            }
            ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
            for (UserAppInfo userAppInfo : apps) {
                applicationInfos.add(userAppInfo.appInfo);
            }
            userMap.put(typeOfDefault, applicationInfos);
        }
    }
    new Handler(mContext.getMainLooper()).post(() -> {
        updateUi();
    });
}
Also used : EnterpriseDefaultApps(com.android.settings.applications.EnterpriseDefaultApps) ApplicationInfo(android.content.pm.ApplicationInfo) ArrayList(java.util.ArrayList) Handler(android.os.Handler) UserHandle(android.os.UserHandle) UserAppInfo(com.android.settings.applications.UserAppInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with EnterpriseDefaultApps

use of com.android.settings.applications.EnterpriseDefaultApps in project android_packages_apps_Settings by DirtyUnicorns.

the class EnterpriseSetDefaultAppsListPreferenceController method buildAppList.

/**
 * Builds data for UI. Updates mUsers and mApps so that they contain non-empty list.
 */
private void buildAppList() {
    mUsers = new ArrayList<>();
    mApps = new ArrayList<>();
    for (UserHandle user : mUserFeatureProvider.getUserProfiles()) {
        boolean hasDefaultsForUser = false;
        EnumMap<EnterpriseDefaultApps, List<ApplicationInfo>> userMap = null;
        for (EnterpriseDefaultApps typeOfDefault : EnterpriseDefaultApps.values()) {
            List<UserAppInfo> apps = mApplicationFeatureProvider.findPersistentPreferredActivities(user.getIdentifier(), typeOfDefault.getIntents());
            if (apps.isEmpty()) {
                continue;
            }
            if (!hasDefaultsForUser) {
                hasDefaultsForUser = true;
                mUsers.add(apps.get(0).userInfo);
                userMap = new EnumMap<>(EnterpriseDefaultApps.class);
                mApps.add(userMap);
            }
            ArrayList<ApplicationInfo> applicationInfos = new ArrayList<>();
            for (UserAppInfo userAppInfo : apps) {
                applicationInfos.add(userAppInfo.appInfo);
            }
            userMap.put(typeOfDefault, applicationInfos);
        }
    }
    new Handler(mContext.getMainLooper()).post(() -> {
        updateUi();
    });
}
Also used : EnterpriseDefaultApps(com.android.settings.applications.EnterpriseDefaultApps) ApplicationInfo(android.content.pm.ApplicationInfo) ArrayList(java.util.ArrayList) Handler(android.os.Handler) UserHandle(android.os.UserHandle) UserAppInfo(com.android.settings.applications.UserAppInfo) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ApplicationInfo (android.content.pm.ApplicationInfo)14 EnterpriseDefaultApps (com.android.settings.applications.EnterpriseDefaultApps)14 UserHandle (android.os.UserHandle)7 UserAppInfo (com.android.settings.applications.UserAppInfo)7 ArrayList (java.util.ArrayList)7 List (java.util.List)7 Handler (android.os.Handler)5 Preference (android.support.v7.preference.Preference)5 Preference (androidx.preference.Preference)2