Search in sources :

Example 1 with PackageListAdapter

use of com.crdroid.settings.preferences.PackageListAdapter in project android_packages_apps_crDroidSettings by crdroidandroid.

the class NotificationLightSettings method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final Context context = getContext();
    addPreferencesFromResource(R.xml.notification_light_settings);
    getActivity().getActionBar().setTitle(R.string.notification_light_title);
    PreferenceScreen prefSet = getPreferenceScreen();
    Resources resources = getResources();
    PreferenceGroup mAdvancedPrefs = (PreferenceGroup) prefSet.findPreference(ADVANCED_SECTION);
    PreferenceGroup mGeneralPrefs = (PreferenceGroup) prefSet.findPreference(GENERAL_SECTION);
    // Get the system defined default notification color
    mDefaultColor = resources.getColor(com.android.internal.R.color.config_defaultNotificationColor, null);
    mDefaultLedOn = resources.getInteger(com.android.internal.R.integer.config_defaultNotificationLedOn);
    mDefaultLedOff = resources.getInteger(com.android.internal.R.integer.config_defaultNotificationLedOff);
    mHALAdjustableBrightness = LightsCapabilities.supports(context, LightsCapabilities.LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS);
    mLedCanPulse = LightsCapabilities.supports(context, LightsCapabilities.LIGHTS_PULSATING_LED);
    mMultiColorLed = LightsCapabilities.supports(context, LightsCapabilities.LIGHTS_RGB_NOTIFICATION_LED);
    mEnabledPref = (SystemSettingSwitchPreference) findPreference(Settings.System.NOTIFICATION_LIGHT_PULSE);
    mEnabledPref.setOnPreferenceChangeListener(this);
    mDefaultPref = (ApplicationLightPreference) findPreference(DEFAULT_PREF);
    mAutoGenerateColors = (LineageSystemSettingSwitchPreference) findPreference(LineageSettings.System.NOTIFICATION_LIGHT_COLOR_AUTO);
    // Advanced light settings
    mNotificationBrightnessPref = (NotificationBrightnessPreference) findPreference(LineageSettings.System.NOTIFICATION_LIGHT_BRIGHTNESS_LEVEL);
    mScreenOnLightsPref = (LineageSystemSettingSwitchPreference) findPreference(LineageSettings.System.NOTIFICATION_LIGHT_SCREEN_ON);
    mScreenOnLightsPref.setOnPreferenceChangeListener(this);
    mCustomEnabledPref = (LineageSystemSettingSwitchPreference) findPreference(LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE);
    if (!mMultiColorLed && !mHALAdjustableBrightness) {
        removePreference(BRIGHTNESS_SECTION);
    }
    if (!mLedCanPulse && !mMultiColorLed) {
        mGeneralPrefs.removePreference(mDefaultPref);
        mAdvancedPrefs.removePreference(mCustomEnabledPref);
    } else {
        mCustomEnabledPref.setOnPreferenceChangeListener(this);
        mDefaultPref.setOnPreferenceChangeListener(this);
        mDefaultPref.setDefaultValues(mDefaultColor, mDefaultLedOn, mDefaultLedOff);
    }
    // Missed call and Voicemail preferences should only show on devices with a voice capabilities
    TelephonyManager tm = getActivity().getSystemService(TelephonyManager.class);
    if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE || (!mLedCanPulse && !mMultiColorLed)) {
        removePreference(PHONE_SECTION);
    } else {
        mCallPref = (ApplicationLightPreference) findPreference(MISSED_CALL_PREF);
        mCallPref.setOnPreferenceChangeListener(this);
        mCallPref.setDefaultValues(mDefaultColor, mDefaultLedOn, mDefaultLedOff);
        mVoicemailPref = (ApplicationLightPreference) findPreference(VOICEMAIL_PREF);
        mVoicemailPref.setOnPreferenceChangeListener(this);
        mVoicemailPref.setDefaultValues(mDefaultColor, mDefaultLedOn, mDefaultLedOff);
    }
    if (!mLedCanPulse && !mMultiColorLed) {
        removePreference(APPLICATION_SECTION);
    } else {
        mApplicationPrefList = (PreferenceGroup) findPreference(APPLICATION_SECTION);
        mApplicationPrefList.setOrderingAsAdded(false);
    }
    // Get launch-able applications
    mPackageManager = getActivity().getPackageManager();
    mPackageAdapter = new PackageListAdapter(getActivity());
    mPackages = new HashMap<String, Package>();
    setHasOptionsMenu(true);
    if (!mMultiColorLed) {
        resetColors();
        mGeneralPrefs.removePreference(mAutoGenerateColors);
    } else {
        mAutoGenerateColors.setOnPreferenceChangeListener(this);
    // watch(LineageSettings.System.getUriFor(LineageSettings.System.NOTIFICATION_LIGHT_COLOR_AUTO));
    }
// watch(Settings.System.getUriFor(Settings.System.NOTIFICATION_LIGHT_PULSE));
}
Also used : Context(android.content.Context) PackageListAdapter(com.crdroid.settings.preferences.PackageListAdapter) PreferenceScreen(androidx.preference.PreferenceScreen) TelephonyManager(android.telephony.TelephonyManager) PreferenceGroup(androidx.preference.PreferenceGroup) Resources(android.content.res.Resources)

Example 2 with PackageListAdapter

use of com.crdroid.settings.preferences.PackageListAdapter in project android_packages_apps_crDroidSettings by crdroidandroid.

the class SlimRecentsBlacklist method initializeAllPreferences.

private void initializeAllPreferences() {
    mPackageManager = getPackageManager();
    mPackageAdapter = new PackageListAdapter(getActivity());
    mBlacklistPrefList = (PreferenceGroup) findPreference("blacklist_applications");
    mBlacklistPrefList.setOrderingAsAdded(false);
    mBlacklistPackages = new HashMap<String, Package>();
    mAddBlacklistPref = findPreference("add_blacklist_packages");
    mAddBlacklistPref.setOnPreferenceClickListener(this);
}
Also used : PackageListAdapter(com.crdroid.settings.preferences.PackageListAdapter)

Aggregations

PackageListAdapter (com.crdroid.settings.preferences.PackageListAdapter)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 TelephonyManager (android.telephony.TelephonyManager)1 PreferenceGroup (androidx.preference.PreferenceGroup)1 PreferenceScreen (androidx.preference.PreferenceScreen)1