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

Commit 87bff78f authored by Wysie's avatar Wysie
Browse files

Release 1.91. Added ability to use custom colors.

parent 575ec64d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -770,6 +770,8 @@
    <string name="title_digits_color_focused">Digits color (focused)</string>
    <string name="title_digits_color_pressed">Digits color (pressed)</string>
    <string name="title_choose_color">Choose a color</string>
    <string name="title_use_custom_color">Use custom digits colors</string>
    <string name="summaryon_custom_color">Supported formats: #RRGGBB or #AARRGGBB. Input the # as well.</string>
    
    <string name="title_call_log_category">Call log</string>    
    <string name="title_cl_relative_time">Relative times</string>
+18 −0
Original line number Diff line number Diff line
@@ -58,6 +58,24 @@
            android:entries="@array/digits_colors"
            android:entryValues="@array/digits_colors_values"
            android:defaultValue="-1" />
        <CheckBoxPreference
            android:key="dial_digit_use_custom_color"
            android:title="@string/title_use_custom_color"
            android:defaultValue="false"
            android:summary="@string/summaryon_custom_color"
            android:disableDependentsState="false" />
        <EditTextPreference
            android:key="focused_digit_color_custom"
            android:title="@string/title_digits_color_focused"
            android:dependency="dial_digit_use_custom_color" />
        <EditTextPreference
            android:key="pressed_digit_color_custom"
            android:title="@string/title_digits_color_pressed"
            android:dependency="dial_digit_use_custom_color" />
        <EditTextPreference
            android:key="unselected_digit_color_custom"
            android:title="@string/title_digits_color_unselected"
            android:dependency="dial_digit_use_custom_color" />
    </PreferenceCategory>
    <PreferenceCategory android:title="@string/recentCallsIconLabel">
        <CheckBoxPreference
+35 −7
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.ListPreference;
import android.preference.CheckBoxPreference;
import android.preference.PreferenceActivity;
import android.content.ComponentName;
import android.content.pm.PackageManager;
@@ -30,13 +31,15 @@ import android.content.pm.ResolveInfo;

import android.util.Log;

public class ContactsPreferences extends PreferenceActivity implements Preference.OnPreferenceChangeListener {
public class ContactsPreferences extends PreferenceActivity implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener {

    private static final String TAG = "ContactsPreferences";

    private ListPreference mVMButton;
    private ListPreference mVMHandler;
    private ListPreference colorFocused, colorPressed, colorUnselected;
    private CheckBoxPreference useCustomColor;
    //private EditTextPreference customColorFocused, customColorPressed, customColorUnselected;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -47,16 +50,17 @@ public class ContactsPreferences extends PreferenceActivity implements Preferenc

        mVMButton = (ListPreference) findPreference("vm_button");
        mVMHandler = (ListPreference) findPreference("vm_handler");       
        
        colorFocused = (ListPreference) findPreference("focused_digit_color");
        colorPressed = (ListPreference) findPreference("pressed_digit_color");
        colorUnselected = (ListPreference) findPreference("unselected_digit_color");
        useCustomColor = (CheckBoxPreference) findPreference("dial_digit_use_custom_color");

        mVMButton.setOnPreferenceChangeListener(this);
        mVMHandler.setOnPreferenceChangeListener(this);
        colorFocused.setOnPreferenceChangeListener(this);
        colorPressed.setOnPreferenceChangeListener(this);
        colorUnselected.setOnPreferenceChangeListener(this);
        useCustomColor.setOnPreferenceClickListener(this);

        loadHandlers();

@@ -65,6 +69,29 @@ public class ContactsPreferences extends PreferenceActivity implements Preferenc
        updatePrefs(colorFocused, colorFocused.getValue());
        updatePrefs(colorPressed, colorPressed.getValue());
        updatePrefs(colorUnselected, colorUnselected.getValue());        
        updatePrefs(useCustomColor);
    }
    
    public boolean onPreferenceClick(Preference preference) {
        updatePrefs(preference);
        
        return true;
    }
    
    private void updatePrefs(Preference preference) {
        if (preference.getKey().equals("dial_digit_use_custom_color")) {
            CheckBoxPreference p = (CheckBoxPreference) findPreference(preference.getKey());
            if (p.isChecked()) {
                colorFocused.setEnabled(false);
                colorPressed.setEnabled(false);
                colorUnselected.setEnabled(false);
            }
            else {
                colorFocused.setEnabled(true);
                colorPressed.setEnabled(true);
                colorUnselected.setEnabled(true);
            }            
        }
    }
    
    public boolean onPreferenceChange (Preference preference, Object newValue) {
@@ -74,6 +101,7 @@ public class ContactsPreferences extends PreferenceActivity implements Preferenc

    private void updatePrefs(Preference preference, Object newValue) {  
        ListPreference p = (ListPreference) findPreference(preference.getKey());
        
        try {       
            p.setSummary(p.getEntries()[p.findIndexOfValue((String) newValue)]);
        } catch (ArrayIndexOutOfBoundsException e) {
+20 −4
Original line number Diff line number Diff line
@@ -1151,9 +1151,25 @@ public class TwelveKeyDialer extends Activity implements View.OnClickListener,
    }
    
    private void setDigitsColor() {        
        int colorFocused = Integer.parseInt(prefs.getString("focused_digit_color", "-16777216"));
        int colorPressed = Integer.parseInt(prefs.getString("pressed_digit_color", "-16777216"));
        int colorUnselected = Integer.parseInt(prefs.getString("unselected_digit_color", "-1"));
        int colorFocused = -16777216;
        int colorPressed = -16777216;
        int colorUnselected = -1;
        
        if (prefs.getBoolean("dial_digit_use_custom_color", false)) {
            try {
                colorFocused = Color.parseColor(prefs.getString("focused_digit_color_custom", "-16777216"));
                colorPressed = Color.parseColor(prefs.getString("pressed_digit_color_custom", "-16777216"));
                colorUnselected = Color.parseColor(prefs.getString("unselected_digit_color_custom", "-1"));
            }
            catch (IllegalArgumentException e) {
                //Do nothing
            }            
        }
        else {
            colorFocused = Integer.parseInt(prefs.getString("focused_digit_color", "-16777216"));
            colorPressed = Integer.parseInt(prefs.getString("pressed_digit_color", "-16777216"));
            colorUnselected = Integer.parseInt(prefs.getString("unselected_digit_color", "-1"));
        }
    
        mDigits.setTextColor(new ColorStateList(
                     new int[][] {