Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4dd897f authored by Michael Webster's avatar Michael Webster Committed by Steve Kondik
Browse files

Trackball/LED settings fixes:

-Disable settings in Trackball notification activity for sholes that
are not supported in the current implementation.

-Add note explaining that not all colors are available on all devices

-Fix potential FC condition when custom color picker is selected
and no previous color had been set.

Change-Id: I8cc8e04245be43c2768803cf301d5c191d687b89
parent 8343abd3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -151,6 +151,8 @@
    <string name="trackball_remove_default_toast">Can\'t remove this category as its the default one.</string>
    <string name="trackball_reset_all">Reset all colors and categories.</string>
    <string name="trackball_array_error">Unfortunately there was an array error. This package has been forced into Miscellaneous category.</string>
    <string name="trackball_color_notice_title">NOTE:</string>
    <string name="trackball_color_notice_summary">Not all colors will display on all devices.</string>

    <!-- Trackball Settings : Warning dialog -->
    <string name="notification_battery_warning_title">WARNING: May cause battery drain</string>
+31 −19
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ import android.content.pm.PackageManager;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.CheckBoxPreference;
@@ -74,6 +75,8 @@ public class TrackballNotificationActivity extends PreferenceActivity implements
    private static final String PULSE_IN_ORDER = "pulse_colors_in_order";
    private static final String RESET_NOTIFS = "reset_notifications";

    private static final boolean SHOLES_DEVICE = Build.DEVICE.contains("sholes");

    public List<String> uniqueArray(String[] array) {
        Set<String> set = new HashSet<String>(Arrays.asList(array));
        List<String> array2 = new ArrayList<String>(set);
@@ -387,6 +390,11 @@ public class TrackballNotificationActivity extends PreferenceActivity implements
            blendPulse.setTitle(R.string.pref_trackball_blend_title);
            blendPulse.setEnabled(Settings.System.getInt(getContentResolver(), Settings.System.TRACKBALL_NOTIFICATION_SUCCESSION, 0) == 1 ? false : true);
            advancedScreen.addPreference(blendPulse);
            if (SHOLES_DEVICE) {
                blendPulse.setEnabled(false);
                blendPulse.setChecked(false);
                Settings.System.putInt(getContentResolver(), Settings.System.TRACKBALL_NOTIFICATION_BLEND_COLOR, 0);
            }

            CheckBoxPreference successionPulse = new CheckBoxPreference(this);
            successionPulse.setKey(PULSE_SUCCESSION);
@@ -513,6 +521,12 @@ public class TrackballNotificationActivity extends PreferenceActivity implements
                    testColor.setEnabled(!packageValues[1].equals("none"));
                }
                appName.addPreference(testColor);

                Preference notice = new Preference(this);
                notice.setKey("NULL");
                notice.setTitle(R.string.trackball_color_notice_title);
                notice.setSummary(R.string.trackball_color_notice_summary);
                appName.addPreference(notice);
            }
        }

@@ -624,13 +638,9 @@ public class TrackballNotificationActivity extends PreferenceActivity implements
            final CheckBoxPreference keyPref = (CheckBoxPreference) preference;
            value = keyPref.isChecked();
            if (!value) {
                PreferenceScreen prefSet = getPreferenceScreen();
                CheckBoxPreference disablePref = (CheckBoxPreference)prefSet.findPreference(BLEND_COLORS);
                disablePref.setEnabled(true);
                blendToggle(true);
            } else {
                PreferenceScreen prefSet = getPreferenceScreen();
                CheckBoxPreference disablePref = (CheckBoxPreference)prefSet.findPreference(BLEND_COLORS);
                disablePref.setEnabled(false);
                blendToggle(false);
            }
            if (value == false) {
                Settings.System.putInt(getContentResolver(),
@@ -661,13 +671,9 @@ public class TrackballNotificationActivity extends PreferenceActivity implements
            final CheckBoxPreference keyPref = (CheckBoxPreference) preference;
            value = keyPref.isChecked();
            if (!value) {
                PreferenceScreen prefSet = getPreferenceScreen();
                CheckBoxPreference disablePref = (CheckBoxPreference)prefSet.findPreference(BLEND_COLORS);
                disablePref.setEnabled(true);
                blendToggle(true);
            } else {
                PreferenceScreen prefSet = getPreferenceScreen();
                CheckBoxPreference disablePref = (CheckBoxPreference)prefSet.findPreference(BLEND_COLORS);
                disablePref.setEnabled(false);
                blendToggle(false);
            }
            if (value == false) {
                Settings.System.putInt(getContentResolver(),
@@ -698,13 +704,9 @@ public class TrackballNotificationActivity extends PreferenceActivity implements
            final CheckBoxPreference keyPref = (CheckBoxPreference) preference;
            value = keyPref.isChecked();
            if (!value) {
                PreferenceScreen prefSet = getPreferenceScreen();
                CheckBoxPreference disablePref = (CheckBoxPreference)prefSet.findPreference(BLEND_COLORS);
                disablePref.setEnabled(true);
                blendToggle(true);
            } else {
                PreferenceScreen prefSet = getPreferenceScreen();
                CheckBoxPreference disablePref = (CheckBoxPreference)prefSet.findPreference(BLEND_COLORS);
                disablePref.setEnabled(false);
                blendToggle(false);
            }
            if (value == false) {
                Settings.System.putInt(getContentResolver(),
@@ -776,7 +778,11 @@ public class TrackballNotificationActivity extends PreferenceActivity implements
        if (mPackage[1].equals("random")) {
            return -16777216;
        } else {
            try {
                return Color.parseColor(mPackage[1]);
            } catch (IllegalArgumentException e) {
                return -16777216;
            }
        }
    }

@@ -867,4 +873,10 @@ public class TrackballNotificationActivity extends PreferenceActivity implements
        return "#" + alpha + red + green + blue;
    }

    private void blendToggle(boolean toggle) {
        if (!SHOLES_DEVICE) {
            CheckBoxPreference disablePref = (CheckBoxPreference) getPreferenceScreen().findPreference(BLEND_COLORS);
            disablePref.setEnabled(toggle);
        }
    }
}