diff options
author | Dave Daynard <nardholio@gmail.com> | 2015-05-11 05:22:57 -0400 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-29 17:36:32 -0700 |
commit | 061e9a1bbfbe202b57eef686268d3dd3c34d2c15 (patch) | |
tree | f2c71f260703b0d13c6c124c2464a6fd56706608 | |
parent | f268c796bb210ade5bdc0debfc1d1c834daac758 (diff) | |
download | packages_apps_Settings-061e9a1bbfbe202b57eef686268d3dd3c34d2c15.zip packages_apps_Settings-061e9a1bbfbe202b57eef686268d3dd3c34d2c15.tar.gz packages_apps_Settings-061e9a1bbfbe202b57eef686268d3dd3c34d2c15.tar.bz2 |
Settings: Livedisplay: Respect default values passed from CMHW
Not all CMHW color calibration uses a default value of 100%, nor does it
use a minimum of 20%
Change-Id: I5ca925e77e41ebf050f2a7c5a81c4e10d9406f91
-rw-r--r-- | src/com/android/settings/livedisplay/DisplayColor.java | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/com/android/settings/livedisplay/DisplayColor.java b/src/com/android/settings/livedisplay/DisplayColor.java index 0fee9d3..d6b7b37 100644 --- a/src/com/android/settings/livedisplay/DisplayColor.java +++ b/src/com/android/settings/livedisplay/DisplayColor.java @@ -19,6 +19,7 @@ package com.android.settings.livedisplay; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; +import android.hardware.CmHardwareManager; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; @@ -34,6 +35,8 @@ import android.widget.TextView; import com.android.settings.IntervalSeekBar; import com.android.settings.R; +import static android.hardware.CmHardwareManager.FEATURE_DISPLAY_COLOR_CALIBRATION; + /** * Special preference type that allows configuration of Color settings */ @@ -42,6 +45,11 @@ public class DisplayColor extends DialogPreference { private final Context mContext; + private final int minRGB; + private final int maxRGB; + private final float defaultRGB; + private final boolean useCMHW; + // These arrays must all match in length and order private static final int[] SEEKBAR_ID = new int[] { R.id.color_red_seekbar, @@ -65,6 +73,20 @@ public class DisplayColor extends DialogPreference { mContext = context; + final CmHardwareManager mCmHardwareManager = + (CmHardwareManager) mContext.getSystemService(Context.CMHW_SERVICE); + useCMHW = mCmHardwareManager.isSupported(FEATURE_DISPLAY_COLOR_CALIBRATION); + if (useCMHW) { + minRGB = mCmHardwareManager.getDisplayColorCalibrationMin(); + maxRGB = mCmHardwareManager.getDisplayColorCalibrationMax(); + defaultRGB = (float) mCmHardwareManager.getDisplayColorCalibrationDefault() / maxRGB; + } else { + // Initialize these just to avoid compiler errors. + minRGB = 20; + maxRGB = 100; + defaultRGB = 1.0f; + } + setDialogLayoutResource(R.layout.display_color_calibration); } @@ -88,16 +110,17 @@ public class DisplayColor extends DialogPreference { String[] colorAdjustment = colorAdjustmentTemp == null ? null : colorAdjustmentTemp.split(" "); if (colorAdjustment == null || colorAdjustment.length != 3) { - colorAdjustment = new String[] { "1.0", "1.0", "1.0" }; + colorAdjustment = new String[] { Float.toString(defaultRGB), + Float.toString(defaultRGB), Float.toString(defaultRGB) }; } try { mOriginalColors[0] = Float.parseFloat(colorAdjustment[0]); mOriginalColors[1] = Float.parseFloat(colorAdjustment[1]); mOriginalColors[2] = Float.parseFloat(colorAdjustment[2]); } catch (NumberFormatException e) { - mOriginalColors[0] = 1.0f; - mOriginalColors[1] = 1.0f; - mOriginalColors[2] = 1.0f; + mOriginalColors[0] = defaultRGB; + mOriginalColors[1] = defaultRGB; + mOriginalColors[2] = defaultRGB; } System.arraycopy(mOriginalColors, 0, mCurrentColors, 0, 3); @@ -106,6 +129,12 @@ public class DisplayColor extends DialogPreference { IntervalSeekBar seekBar = (IntervalSeekBar) view.findViewById(SEEKBAR_ID[i]); TextView value = (TextView) view.findViewById(SEEKBAR_VALUE_ID[i]); mSeekBars[i] = new ColorSeekBar(seekBar, value, i); + if (useCMHW) { + mSeekBars[i].mSeekBar.setMinimum((float) minRGB / maxRGB); + /* Maximum hasn't changed but it's relative to the minimum so it needs + to be reset */ + mSeekBars[i].mSeekBar.setMaximum(1.0f); + } mSeekBars[i].mSeekBar.setProgressFloat(mCurrentColors[i]); int percent = Math.round(100F * mCurrentColors[i]); value.setText(String.format("%d%%", percent)); @@ -124,8 +153,8 @@ public class DisplayColor extends DialogPreference { @Override public void onClick(View v) { for (int i = 0; i < mSeekBars.length; i++) { - mSeekBars[i].mSeekBar.setProgressFloat(1.00f); - mCurrentColors[i] = 1.0f; + mSeekBars[i].mSeekBar.setProgressFloat(defaultRGB); + mCurrentColors[i] = defaultRGB; } updateColors(mCurrentColors); } |