diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2012-01-10 19:32:09 +0700 |
---|---|---|
committer | Pawit Pornkitprasan <p.pawit@gmail.com> | 2012-01-10 19:32:09 +0700 |
commit | 799cb39f2b744dea372c86f82f67712c8726e785 (patch) | |
tree | 8024ef0c5f0c5ef1325fe3726117fa607405178b /AriesParts/src/com | |
parent | c64ac590be93348edde924c27c93b53f3ecf9252 (diff) | |
download | device_samsung_aries-common-799cb39f2b744dea372c86f82f67712c8726e785.zip device_samsung_aries-common-799cb39f2b744dea372c86f82f67712c8726e785.tar.gz device_samsung_aries-common-799cb39f2b744dea372c86f82f67712c8726e785.tar.bz2 |
AriesParts: Add v0 color gamma and mDNIe Settings
Diffstat (limited to 'AriesParts/src/com')
4 files changed, 111 insertions, 6 deletions
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); } |