diff options
Diffstat (limited to 'AriesParts')
8 files changed, 216 insertions, 7 deletions
diff --git a/AriesParts/res/layout/preference_dialog_color_tuning.xml b/AriesParts/res/layout/preference_dialog_color_tuning.xml index f228541..f67cf5d 100644 --- a/AriesParts/res/layout/preference_dialog_color_tuning.xml +++ b/AriesParts/res/layout/preference_dialog_color_tuning.xml @@ -80,13 +80,86 @@ android:paddingLeft="20dip" android:paddingRight="20dip" /> - <ImageView android:src="@drawable/color_tuning_preview" + <ImageView android:id="@+id/color_tuning_preview" + android:src="@drawable/color_tuning_preview" android:layout_width="match_parent" android:layout_height="40dip" android:layout_below="@id/color_blue_seekbar" android:paddingTop="20dip" android:paddingLeft="20dip" android:paddingRight="20dip" /> + + <TextView android:id="@+id/color_red_v0_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/color_tuning_preview" + android:text="@string/color_red_v0_title" + android:paddingTop="30dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> + <TextView android:id="@+id/color_red_v0_value" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/color_tuning_preview" + android:layout_alignParentRight="true" + android:paddingTop="30dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> + <SeekBar android:id="@+id/color_red_v0_seekbar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/color_red_v0_text" + android:paddingTop="2dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> + + <TextView android:id="@+id/color_green_v0_text" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/color_red_v0_seekbar" + android:text="@string/color_green_v0_title" + android:paddingTop="10dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> + <TextView android:id="@+id/color_green_v0_value" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/color_red_v0_seekbar" + android:layout_alignParentRight="true" + android:paddingTop="10dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> + <SeekBar android:id="@+id/color_green_v0_seekbar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/color_green_v0_text" + android:paddingTop="2dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> + + <TextView android:id="@+id/color_blue_v0_text" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/color_green_v0_seekbar" + android:text="@string/color_blue_v0_title" + android:paddingTop="10dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> + <TextView android:id="@+id/color_blue_v0_value" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_below="@id/color_green_v0_seekbar" + android:layout_alignParentRight="true" + android:paddingTop="10dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> + <SeekBar android:id="@+id/color_blue_v0_seekbar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_below="@id/color_blue_v0_text" + android:paddingTop="2dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" /> </RelativeLayout> </ScrollView>
\ No newline at end of file diff --git a/AriesParts/res/values/arrays.xml b/AriesParts/res/values/arrays.xml index 5d32de2..a0abb5b 100644 --- a/AriesParts/res/values/arrays.xml +++ b/AriesParts/res/values/arrays.xml @@ -1,4 +1,22 @@ <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> + <string-array name="mdnie_entries"> + <item>Disabled</item> + <item>UI Mode</item> + <item>Video Mode</item> + <item>Video Warm Mode</item> + <item>Video Cold Mode</item> + <item>Camera Mode</item> + </string-array> + + <string-array name="mdnie_entries_values" translatable="false"> + <item>6</item> + <item>0</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>4</item> + </string-array> + <string-array name="backlight_timeout_entries"> <item>Default (1.6 seconds)</item> <item>0.5 seconds</item> diff --git a/AriesParts/res/values/strings.xml b/AriesParts/res/values/strings.xml index 735ffe7..74adc79 100644 --- a/AriesParts/res/values/strings.xml +++ b/AriesParts/res/values/strings.xml @@ -8,6 +8,11 @@ <string name="color_red_title">Red</string> <string name="color_green_title">Green</string> <string name="color_blue_title">Blue</string> + <string name="color_red_v0_title">Red (v0 Gamma)</string> + <string name="color_green_v0_title">Green (v0 Gamma)</string> + <string name="color_blue_v0_title">Blue (v0 Gamma)</string> + <string name="mdnie_title_head">mDNIe Mode</string> + <string name="mdnie_summary_head">Adjust mDNIe display post-processing</string> <string name="category_touchkey_title">Touch Keys</string> <string name="backlight_timeout_title_head">Backlight Timeout</string> diff --git a/AriesParts/res/xml/main.xml b/AriesParts/res/xml/main.xml index 4c705f4..66876f2 100644 --- a/AriesParts/res/xml/main.xml +++ b/AriesParts/res/xml/main.xml @@ -8,6 +8,14 @@ android:key="color_tuning" android:title="@string/color_tuning_title_head" android:summary="@string/color_tuning_summary_head" /> + <!-- mDNIe Options --> + <ListPreference + android:key="mdnie" + android:title="@string/mdnie_title_head" + android:summary="@string/mdnie_summary_head" + android:entries="@array/mdnie_entries" + android:entryValues="@array/mdnie_entries_values" + android:defaultValue="6" /> </PreferenceCategory> <PreferenceCategory diff --git a/AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java b/AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java index 7ac4b31..70af316 100644 --- a/AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java +++ b/AriesParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java @@ -34,16 +34,37 @@ public class ColorTuningPreference extends DialogPreference { R.id.color_blue_value }; + private static final int[] V0_SEEKBAR_ID = new int[] { + R.id.color_red_v0_seekbar, + R.id.color_green_v0_seekbar, + R.id.color_blue_v0_seekbar, + }; + + private static final int[] V0_VALUE_DISPLAY_ID = new int[] { + R.id.color_red_v0_value, + R.id.color_green_v0_value, + R.id.color_blue_v0_value + }; + private static final String[] FILE_PATH = new String[] { "/sys/devices/virtual/misc/color_tuning/red_multiplier", "/sys/devices/virtual/misc/color_tuning/green_multiplier", "/sys/devices/virtual/misc/color_tuning/blue_multiplier" }; - private ColorSeekBar mSeekBars[] = new ColorSeekBar[3]; + private static final String[] V0_FILE_PATH = new String[] { + "/sys/devices/virtual/misc/color_tuning/v0_red_gamma_hack", + "/sys/devices/virtual/misc/color_tuning/v0_green_gamma_hack", + "/sys/devices/virtual/misc/color_tuning/v0_blue_gamma_hack" + }; + + private ColorSeekBar mSeekBars[] = new ColorSeekBar[6]; private static final int MAX_VALUE = Integer.MAX_VALUE; + private static final int V0_MAX_VALUE = 20; + private static final int V0_DEFAULT_VALUE = 0; + // Track instances to know when to restore original color // (when the orientation changes, a new dialog is created before the old one is destroyed) private static int sInstances = 0; @@ -65,6 +86,12 @@ public class ColorTuningPreference extends DialogPreference { TextView valueDisplay = (TextView) view.findViewById(VALUE_DISPLAY_ID[i]); mSeekBars[i] = new ColorSeekBar(seekBar, valueDisplay, FILE_PATH[i]); } + + for (int i = 0; i < V0_SEEKBAR_ID.length; i++) { + SeekBar seekBar = (SeekBar) view.findViewById(V0_SEEKBAR_ID[i]); + TextView valueDisplay = (TextView) view.findViewById(V0_VALUE_DISPLAY_ID[i]); + mSeekBars[SEEKBAR_ID.length + i] = new V0ColorSeekBar(seekBar, valueDisplay, V0_FILE_PATH[i]); + } } @Override @@ -98,6 +125,10 @@ public class ColorTuningPreference extends DialogPreference { int value = sharedPrefs.getInt(filePath, MAX_VALUE); Utils.writeColor(filePath, value); } + for (String filePath : V0_FILE_PATH) { + int value = sharedPrefs.getInt(filePath, V0_DEFAULT_VALUE); + Utils.writeColor(filePath, value); + } } /** @@ -111,16 +142,21 @@ public class ColorTuningPreference extends DialogPreference { supported = false; } } + for (String filePath : V0_FILE_PATH) { + if (!Utils.fileExists(filePath)) { + supported = false; + } + } return supported; } class ColorSeekBar implements SeekBar.OnSeekBarChangeListener { - private String mFilePath; - private int mOriginal; - private SeekBar mSeekBar; - private TextView mValueDisplay; + protected String mFilePath; + protected int mOriginal; + protected SeekBar mSeekBar; + protected TextView mValueDisplay; public ColorSeekBar(SeekBar seekBar, TextView valueDisplay, String filePath) { mSeekBar = seekBar; @@ -136,6 +172,10 @@ public class ColorTuningPreference extends DialogPreference { seekBar.setOnSeekBarChangeListener(this); } + // For inheriting class + protected ColorSeekBar() { + } + public void reset() { mSeekBar.setProgress(mOriginal); updateValue(mOriginal); @@ -164,10 +204,32 @@ public class ColorTuningPreference extends DialogPreference { // Do nothing } - private void updateValue(int progress) { + protected void updateValue(int progress) { mValueDisplay.setText(String.format("%.3f", (double) progress / MAX_VALUE)); } } + class V0ColorSeekBar extends ColorSeekBar { + + public V0ColorSeekBar(SeekBar seekBar, TextView valueDisplay, String filePath) { + mSeekBar = seekBar; + mValueDisplay = valueDisplay; + mFilePath = filePath; + + // Read original value + SharedPreferences sharedPreferences = getSharedPreferences(); + mOriginal = sharedPreferences.getInt(mFilePath, V0_DEFAULT_VALUE); + + seekBar.setMax(V0_MAX_VALUE); + reset(); + seekBar.setOnSeekBarChangeListener(this); + } + + @Override + protected void updateValue(int progress) { + mValueDisplay.setText(String.valueOf(progress)); + } + + } } diff --git a/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java b/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java index 8cb2555..42710da 100644 --- a/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java +++ b/AriesParts/src/com/cyanogenmod/settings/device/DeviceSettings.java @@ -14,12 +14,14 @@ import android.preference.PreferenceActivity; public class DeviceSettings extends PreferenceActivity { public static final String KEY_COLOR_TUNING = "color_tuning"; + public static final String KEY_MDNIE = "mdnie"; public static final String KEY_BACKLIGHT_TIMEOUT = "backlight_timeout"; public static final String KEY_HSPA = "hspa"; public static final String KEY_TVOUT_ENABLE = "tvout_enable"; public static final String KEY_TVOUT_SYSTEM = "tvout_system"; private ColorTuningPreference mColorTuning; + private ListPreference mMdnie; private ListPreference mBacklightTimeout; private ListPreference mHspa; private CheckBoxPreference mTvOutEnable; @@ -44,6 +46,10 @@ public class DeviceSettings extends PreferenceActivity { mColorTuning = (ColorTuningPreference) findPreference(KEY_COLOR_TUNING); mColorTuning.setEnabled(ColorTuningPreference.isSupported()); + mMdnie = (ListPreference) findPreference(KEY_MDNIE); + mMdnie.setEnabled(Mdnie.isSupported()); + mMdnie.setOnPreferenceChangeListener(new Mdnie()); + mBacklightTimeout = (ListPreference) findPreference(KEY_BACKLIGHT_TIMEOUT); mBacklightTimeout.setEnabled(TouchKeyBacklightTimeout.isSupported()); mBacklightTimeout.setOnPreferenceChangeListener(new TouchKeyBacklightTimeout()); diff --git a/AriesParts/src/com/cyanogenmod/settings/device/Mdnie.java b/AriesParts/src/com/cyanogenmod/settings/device/Mdnie.java new file mode 100644 index 0000000..ce6bd75 --- /dev/null +++ b/AriesParts/src/com/cyanogenmod/settings/device/Mdnie.java @@ -0,0 +1,36 @@ +package com.cyanogenmod.settings.device; + +import android.content.Context; +import android.content.SharedPreferences; +import android.preference.Preference; +import android.preference.Preference.OnPreferenceChangeListener; +import android.preference.PreferenceManager; + +public class Mdnie implements OnPreferenceChangeListener { + + private static final String FILE = "/sys/class/mdnieset_ui/switch_mdnieset_ui/mdnieset_ui_file_cmd"; + + public static boolean isSupported() { + return Utils.fileExists(FILE); + } + + /** + * Restore backlight timeout setting from SharedPreferences. (Write to kernel.) + * @param context The context to read the SharedPreferences from + */ + public static void restore(Context context) { + if (!isSupported()) { + return; + } + + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); + Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_MDNIE, "6")); + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + Utils.writeValue(FILE, (String) newValue); + return true; + } + +} diff --git a/AriesParts/src/com/cyanogenmod/settings/device/Startup.java b/AriesParts/src/com/cyanogenmod/settings/device/Startup.java index bb64961..c2affb4 100644 --- a/AriesParts/src/com/cyanogenmod/settings/device/Startup.java +++ b/AriesParts/src/com/cyanogenmod/settings/device/Startup.java @@ -9,6 +9,7 @@ public class Startup extends BroadcastReceiver { @Override public void onReceive(final Context context, final Intent bootintent) { ColorTuningPreference.restore(context); + Mdnie.restore(context); TouchKeyBacklightTimeout.restore(context); Hspa.restore(context); } |