Search in sources :

Example 1 with PackageListAdapter

use of com.cosmic.settings.preferences.PackageListAdapter in project platform_packages_apps_Galaxy by Cosmic-OS.

the class GamingMode method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get launch-able applications
    addPreferencesFromResource(R.xml.gaming_mode_settings);
    final PreferenceScreen prefScreen = getPreferenceScreen();
    mHardwareKeysDisable = (SwitchPreference) findPreference(GAMING_MODE_HW_KEYS);
    mGamingModeEnabled = (SwitchPreference) findPreference(GAMING_MODE_ENABLED);
    if (!haveHWkeys()) {
        prefScreen.removePreference(mHardwareKeysDisable);
    }
    mPackageManager = getPackageManager();
    mPackageAdapter = new PackageListAdapter(getActivity());
    mGamingPrefList = (PreferenceGroup) findPreference("gamingmode_applications");
    mGamingPrefList.setOrderingAsAdded(false);
    mGamingPackages = new HashMap<String, Package>();
    mAddGamingPref = findPreference("add_gamingmode_packages");
    mAddGamingPref.setOnPreferenceClickListener(this);
    mContext = getActivity().getApplicationContext();
    SettingsObserver observer = new SettingsObserver(new Handler(Looper.getMainLooper()));
    observer.observe();
}
Also used : PackageListAdapter(com.cosmic.settings.preferences.PackageListAdapter) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Handler(android.os.Handler)

Example 2 with PackageListAdapter

use of com.cosmic.settings.preferences.PackageListAdapter in project platform_packages_apps_Galaxy by Cosmic-OS.

the class HeadsUpSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get launch-able applications
    addPreferencesFromResource(R.xml.heads_up_settings);
    mPackageManager = getPackageManager();
    mPackageAdapter = new PackageListAdapter(getActivity());
    mStoplistPrefList = (PreferenceGroup) findPreference("stoplist_applications");
    mStoplistPrefList.setOrderingAsAdded(false);
    mBlacklistPrefList = (PreferenceGroup) findPreference("blacklist_applications");
    mBlacklistPrefList.setOrderingAsAdded(false);
    mStoplistPackages = new HashMap<String, Package>();
    mBlacklistPackages = new HashMap<String, Package>();
    mAddStoplistPref = findPreference("add_stoplist_packages");
    mAddBlacklistPref = findPreference("add_blacklist_packages");
    mAddStoplistPref.setOnPreferenceClickListener(this);
    mAddBlacklistPref.setOnPreferenceClickListener(this);
    Resources systemUiResources;
    try {
        systemUiResources = getPackageManager().getResourcesForApplication("com.android.systemui");
    } catch (Exception e) {
        return;
    }
    int defaultTimeOut = systemUiResources.getInteger(systemUiResources.getIdentifier("com.android.systemui:integer/heads_up_notification_decay", null, null));
    mHeadsUpTimeOut = (ListPreference) findPreference(PREF_HEADS_UP_TIME_OUT);
    mHeadsUpTimeOut.setOnPreferenceChangeListener(this);
    int headsUpTimeOut = Settings.System.getInt(getContentResolver(), Settings.System.HEADS_UP_TIMEOUT, defaultTimeOut);
    mHeadsUpTimeOut.setValue(String.valueOf(headsUpTimeOut));
    updateHeadsUpTimeOutSummary(headsUpTimeOut);
    int defaultSnooze = systemUiResources.getInteger(systemUiResources.getIdentifier("com.android.systemui:integer/heads_up_default_snooze_length_ms", null, null));
    mHeadsUpSnoozeTime = (ListPreference) findPreference(PREF_HEADS_UP_SNOOZE_TIME);
    mHeadsUpSnoozeTime.setOnPreferenceChangeListener(this);
    int headsUpSnooze = Settings.System.getInt(getContentResolver(), Settings.System.HEADS_UP_NOTIFICATION_SNOOZE, defaultSnooze);
    mHeadsUpSnoozeTime.setValue(String.valueOf(headsUpSnooze));
    updateHeadsUpSnoozeTimeSummary(headsUpSnooze);
}
Also used : PackageListAdapter(com.cosmic.settings.preferences.PackageListAdapter) Resources(android.content.res.Resources) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 3 with PackageListAdapter

use of com.cosmic.settings.preferences.PackageListAdapter in project platform_packages_apps_Galaxy by Cosmic-OS.

the class NotificationSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.cosmic_settings_notifications);
    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    mAnnoyingNotification = (ListPreference) findPreference("less_notification_sounds");
    mAnnoyingNotification.setOnPreferenceChangeListener(this);
    int threshold = Settings.System.getIntForUser(getContentResolver(), Settings.System.MUTE_ANNOYING_NOTIFICATIONS_THRESHOLD, 30000, UserHandle.USER_CURRENT);
    mAnnoyingNotification.setValue(String.valueOf(threshold));
    mPackageManager = getPackageManager();
    mPackageAdapter = new PackageListAdapter(getActivity());
    mStoplistPrefList = (PreferenceGroup) findPreference("stoplist_applications");
    mStoplistPrefList.setOrderingAsAdded(false);
    mBlacklistPrefList = (PreferenceGroup) findPreference("blacklist_applications");
    mBlacklistPrefList.setOrderingAsAdded(false);
    mStoplistPackages = new HashMap<String, Package>();
    mBlacklistPackages = new HashMap<String, Package>();
    mAddStoplistPref = findPreference("add_stoplist_packages");
    mAddBlacklistPref = findPreference("add_blacklist_packages");
    mAddStoplistPref.setOnPreferenceClickListener(this);
    mAddBlacklistPref.setOnPreferenceClickListener(this);
    Resources systemUiResources;
    try {
        systemUiResources = getPackageManager().getResourcesForApplication("com.android.systemui");
    } catch (Exception e) {
        return;
    }
    int defaultTimeOut = systemUiResources.getInteger(systemUiResources.getIdentifier("com.android.systemui:integer/heads_up_notification_decay", null, null));
    mHeadsUpTimeOut = (ListPreference) findPreference(PREF_HEADS_UP_TIME_OUT);
    mHeadsUpTimeOut.setOnPreferenceChangeListener(this);
    int headsUpTimeOut = Settings.System.getInt(getContentResolver(), Settings.System.HEADS_UP_TIMEOUT, defaultTimeOut);
    mHeadsUpTimeOut.setValue(String.valueOf(headsUpTimeOut));
    updateHeadsUpTimeOutSummary(headsUpTimeOut);
    int defaultSnooze = systemUiResources.getInteger(systemUiResources.getIdentifier("com.android.systemui:integer/heads_up_default_snooze_length_ms", null, null));
    mHeadsUpSnoozeTime = (ListPreference) findPreference(PREF_HEADS_UP_SNOOZE_TIME);
    mHeadsUpSnoozeTime.setOnPreferenceChangeListener(this);
    int headsUpSnooze = Settings.System.getInt(getContentResolver(), Settings.System.HEADS_UP_NOTIFICATION_SNOOZE, defaultSnooze);
    mHeadsUpSnoozeTime.setValue(String.valueOf(headsUpSnooze));
    updateHeadsUpSnoozeTimeSummary(headsUpSnooze);
    mForceExpanded = (SwitchPreference) findPreference(FORCE_EXPANDED_NOTIFICATIONS);
    mForceExpanded.setChecked((Settings.System.getInt(getContentResolver(), Settings.System.FORCE_EXPANDED_NOTIFICATIONS, 0) == 1));
}
Also used : PackageListAdapter(com.cosmic.settings.preferences.PackageListAdapter) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Resources(android.content.res.Resources) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ContentResolver(android.content.ContentResolver)

Aggregations

PackageListAdapter (com.cosmic.settings.preferences.PackageListAdapter)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)2 Resources (android.content.res.Resources)2 PreferenceScreen (android.support.v7.preference.PreferenceScreen)2 ContentResolver (android.content.ContentResolver)1 Handler (android.os.Handler)1