Search in sources :

Example 1 with RecentLocationApps

use of com.android.settingslib.location.RecentLocationApps in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LocationSettings method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    final SettingsActivity activity = (SettingsActivity) getActivity();
    PreferenceScreen root = getPreferenceScreen();
    if (root != null) {
        root.removeAll();
    }
    addPreferencesFromResource(R.xml.location_settings);
    root = getPreferenceScreen();
    setupManagedProfileCategory(root);
    mLocationMode = root.findPreference(KEY_LOCATION_MODE);
    mLocationMode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            activity.startPreferencePanel(LocationMode.class.getName(), null, R.string.location_mode_screen_title, null, LocationSettings.this, 0);
            return true;
        }
    });
    mAgpsEnabled = getActivity().getResources().getBoolean(R.bool.config_agps_enabled);
    mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GPS);
    if (!mAgpsEnabled) {
        root.removePreference(mAssistedGps);
    }
    if (mAssistedGps != null) {
        mAssistedGps.setChecked(Settings.Global.getInt(getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 0) == 1);
    }
    mCategoryRecentLocationRequests = (PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
    RecentLocationApps recentApps = new RecentLocationApps(activity);
    List<RecentLocationApps.Request> recentLocationRequests = recentApps.getAppList();
    List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
    for (final RecentLocationApps.Request request : recentLocationRequests) {
        DimmableIconPreference pref = new DimmableIconPreference(getPrefContext(), request.contentDescription);
        pref.setIcon(request.icon);
        pref.setTitle(request.label);
        if (request.isHighBattery) {
            pref.setSummary(R.string.location_high_battery_use);
        } else {
            pref.setSummary(R.string.location_low_battery_use);
        }
        pref.setOnPreferenceClickListener(new PackageEntryClickedListener(request.packageName, request.userHandle));
        recentLocationPrefs.add(pref);
    }
    if (recentLocationRequests.size() > 0) {
        addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
    } else {
        // If there's no item to display, add a "No recent apps" item.
        Preference banner = new Preference(getPrefContext());
        banner.setLayoutResource(R.layout.location_list_no_item);
        banner.setTitle(R.string.location_no_recent_apps);
        banner.setSelectable(false);
        mCategoryRecentLocationRequests.addPreference(banner);
    }
    boolean lockdownOnLocationAccess = false;
    // injected location services must not be shown.
    if (mManagedProfile != null && mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile)) {
        lockdownOnLocationAccess = true;
    }
    addLocationServices(activity, root, lockdownOnLocationAccess);
    refreshLocationMode();
    return root;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ArrayList(java.util.ArrayList) RecentLocationApps(com.android.settingslib.location.RecentLocationApps) DimmableIconPreference(com.android.settings.DimmableIconPreference) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SettingsActivity(com.android.settings.SettingsActivity)

Example 2 with RecentLocationApps

use of com.android.settingslib.location.RecentLocationApps in project android_packages_apps_Settings by crdroidandroid.

the class LocationSettings method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    final SettingsActivity activity = (SettingsActivity) getActivity();
    PreferenceScreen root = getPreferenceScreen();
    if (root != null) {
        root.removeAll();
    }
    addPreferencesFromResource(R.xml.location_settings);
    root = getPreferenceScreen();
    setupManagedProfileCategory(root);
    mLocationMode = root.findPreference(KEY_LOCATION_MODE);
    mLocationMode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            activity.startPreferencePanel(LocationSettings.this, LocationMode.class.getName(), null, R.string.location_mode_screen_title, null, LocationSettings.this, 0);
            return true;
        }
    });
    RecentLocationApps recentApps = new RecentLocationApps(activity);
    List<RecentLocationApps.Request> recentLocationRequests = recentApps.getAppList();
    final AppLocationPermissionPreferenceController preferenceController = new AppLocationPermissionPreferenceController(activity);
    preferenceController.displayPreference(root);
    mCategoryRecentLocationRequests = (PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
    List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
    for (final RecentLocationApps.Request request : recentLocationRequests) {
        DimmableIconPreference pref = new DimmableIconPreference(getPrefContext(), request.contentDescription);
        pref.setIcon(request.icon);
        pref.setTitle(request.label);
        pref.setOnPreferenceClickListener(new PackageEntryClickedListener(request.packageName, request.userHandle));
        recentLocationPrefs.add(pref);
    }
    if (recentLocationRequests.size() > 0) {
        addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
    } else {
        // If there's no item to display, add a "No recent apps" item.
        Preference banner = new Preference(getPrefContext());
        banner.setLayoutResource(R.layout.location_list_no_item);
        banner.setTitle(R.string.location_no_recent_apps);
        banner.setSelectable(false);
        mCategoryRecentLocationRequests.addPreference(banner);
    }
    boolean lockdownOnLocationAccess = false;
    // injected location services must not be shown.
    if (mManagedProfile != null && mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile)) {
        lockdownOnLocationAccess = true;
    }
    addLocationServices(activity, root, lockdownOnLocationAccess);
    refreshLocationMode();
    return root;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ArrayList(java.util.ArrayList) RecentLocationApps(com.android.settingslib.location.RecentLocationApps) DimmableIconPreference(com.android.settings.DimmableIconPreference) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SettingsActivity(com.android.settings.SettingsActivity)

Example 3 with RecentLocationApps

use of com.android.settingslib.location.RecentLocationApps in project android_packages_apps_Settings by SudaMod.

the class LocationSettings method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    final SettingsActivity activity = (SettingsActivity) getActivity();
    PreferenceScreen root = getPreferenceScreen();
    if (root != null) {
        root.removeAll();
    }
    addPreferencesFromResource(R.xml.location_settings);
    root = getPreferenceScreen();
    setupManagedProfileCategory(root);
    mLocationMode = root.findPreference(KEY_LOCATION_MODE);
    mLocationMode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            activity.startPreferencePanel(LocationSettings.this, LocationMode.class.getName(), null, R.string.location_mode_screen_title, null, LocationSettings.this, 0);
            return true;
        }
    });
    RecentLocationApps recentApps = new RecentLocationApps(activity);
    List<RecentLocationApps.Request> recentLocationRequests = recentApps.getAppList();
    final AppLocationPermissionPreferenceController preferenceController = new AppLocationPermissionPreferenceController(activity);
    preferenceController.displayPreference(root);
    mCategoryRecentLocationRequests = (PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
    List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
    for (final RecentLocationApps.Request request : recentLocationRequests) {
        DimmableIconPreference pref = new DimmableIconPreference(getPrefContext(), request.contentDescription);
        pref.setIcon(request.icon);
        pref.setTitle(request.label);
        pref.setOnPreferenceClickListener(new PackageEntryClickedListener(request.packageName, request.userHandle));
        recentLocationPrefs.add(pref);
    }
    if (recentLocationRequests.size() > 0) {
        addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
    } else {
        // If there's no item to display, add a "No recent apps" item.
        Preference banner = new Preference(getPrefContext());
        banner.setLayoutResource(R.layout.location_list_no_item);
        banner.setTitle(R.string.location_no_recent_apps);
        banner.setSelectable(false);
        mCategoryRecentLocationRequests.addPreference(banner);
    }
    boolean lockdownOnLocationAccess = false;
    // injected location services must not be shown.
    if (mManagedProfile != null && mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile)) {
        lockdownOnLocationAccess = true;
    }
    addLocationServices(activity, root, lockdownOnLocationAccess);
    refreshLocationMode();
    return root;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ArrayList(java.util.ArrayList) RecentLocationApps(com.android.settingslib.location.RecentLocationApps) DimmableIconPreference(com.android.settings.DimmableIconPreference) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SettingsActivity(com.android.settings.SettingsActivity)

Example 4 with RecentLocationApps

use of com.android.settingslib.location.RecentLocationApps in project platform_packages_apps_Settings by BlissRoms.

the class LocationSettings method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    final SettingsActivity activity = (SettingsActivity) getActivity();
    PreferenceScreen root = getPreferenceScreen();
    if (root != null) {
        root.removeAll();
    }
    addPreferencesFromResource(R.xml.location_settings);
    root = getPreferenceScreen();
    setupManagedProfileCategory(root);
    mLocationMode = root.findPreference(KEY_LOCATION_MODE);
    mLocationMode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            activity.startPreferencePanel(LocationSettings.this, LocationMode.class.getName(), null, R.string.location_mode_screen_title, null, LocationSettings.this, 0);
            return true;
        }
    });
    RecentLocationApps recentApps = new RecentLocationApps(activity);
    List<RecentLocationApps.Request> recentLocationRequests = recentApps.getAppList();
    final AppLocationPermissionPreferenceController preferenceController = new AppLocationPermissionPreferenceController(activity);
    preferenceController.displayPreference(root);
    mCategoryRecentLocationRequests = (PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
    List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
    for (final RecentLocationApps.Request request : recentLocationRequests) {
        DimmableIconPreference pref = new DimmableIconPreference(getPrefContext(), request.contentDescription);
        pref.setIcon(request.icon);
        pref.setTitle(request.label);
        pref.setOnPreferenceClickListener(new PackageEntryClickedListener(request.packageName, request.userHandle));
        recentLocationPrefs.add(pref);
    }
    if (recentLocationRequests.size() > 0) {
        addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
    } else {
        // If there's no item to display, add a "No recent apps" item.
        Preference banner = new Preference(getPrefContext());
        banner.setLayoutResource(R.layout.location_list_no_item);
        banner.setTitle(R.string.location_no_recent_apps);
        banner.setSelectable(false);
        mCategoryRecentLocationRequests.addPreference(banner);
    }
    boolean lockdownOnLocationAccess = false;
    // injected location services must not be shown.
    if (mManagedProfile != null && mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile)) {
        lockdownOnLocationAccess = true;
    }
    addLocationServices(activity, root, lockdownOnLocationAccess);
    refreshLocationMode();
    return root;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ArrayList(java.util.ArrayList) RecentLocationApps(com.android.settingslib.location.RecentLocationApps) DimmableIconPreference(com.android.settings.DimmableIconPreference) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SettingsActivity(com.android.settings.SettingsActivity)

Example 5 with RecentLocationApps

use of com.android.settingslib.location.RecentLocationApps in project android_packages_apps_Settings by LineageOS.

the class LocationSettings method createPreferenceHierarchy.

private PreferenceScreen createPreferenceHierarchy() {
    final SettingsActivity activity = (SettingsActivity) getActivity();
    PreferenceScreen root = getPreferenceScreen();
    if (root != null) {
        root.removeAll();
    }
    addPreferencesFromResource(R.xml.location_settings);
    root = getPreferenceScreen();
    setupManagedProfileCategory(root);
    mLocationMode = root.findPreference(KEY_LOCATION_MODE);
    mLocationMode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            activity.startPreferencePanel(LocationSettings.this, LocationMode.class.getName(), null, R.string.location_mode_screen_title, null, LocationSettings.this, 0);
            return true;
        }
    });
    RecentLocationApps recentApps = new RecentLocationApps(activity);
    List<RecentLocationApps.Request> recentLocationRequests = recentApps.getAppList();
    final AppLocationPermissionPreferenceController preferenceController = new AppLocationPermissionPreferenceController(activity);
    preferenceController.displayPreference(root);
    mCategoryRecentLocationRequests = (PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
    List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
    for (final RecentLocationApps.Request request : recentLocationRequests) {
        DimmableIconPreference pref = new DimmableIconPreference(getPrefContext(), request.contentDescription);
        pref.setIcon(request.icon);
        pref.setTitle(request.label);
        pref.setOnPreferenceClickListener(new PackageEntryClickedListener(request.packageName, request.userHandle));
        recentLocationPrefs.add(pref);
    }
    if (recentLocationRequests.size() > 0) {
        addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
    } else {
        // If there's no item to display, add a "No recent apps" item.
        Preference banner = new Preference(getPrefContext());
        banner.setLayoutResource(R.layout.location_list_no_item);
        banner.setTitle(R.string.location_no_recent_apps);
        banner.setSelectable(false);
        mCategoryRecentLocationRequests.addPreference(banner);
    }
    boolean lockdownOnLocationAccess = false;
    // injected location services must not be shown.
    if (mManagedProfile != null && mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile)) {
        lockdownOnLocationAccess = true;
    }
    addLocationServices(activity, root, lockdownOnLocationAccess);
    refreshLocationMode();
    return root;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) ArrayList(java.util.ArrayList) RecentLocationApps(com.android.settingslib.location.RecentLocationApps) DimmableIconPreference(com.android.settings.DimmableIconPreference) DimmableIconPreference(com.android.settings.DimmableIconPreference) RestrictedSwitchPreference(com.android.settingslib.RestrictedSwitchPreference) Preference(android.support.v7.preference.Preference) SettingsActivity(com.android.settings.SettingsActivity)

Aggregations

Preference (android.support.v7.preference.Preference)7 PreferenceScreen (android.support.v7.preference.PreferenceScreen)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7 SettingsActivity (com.android.settings.SettingsActivity)7 RestrictedSwitchPreference (com.android.settingslib.RestrictedSwitchPreference)7 RecentLocationApps (com.android.settingslib.location.RecentLocationApps)7 ArrayList (java.util.ArrayList)7 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)1