am fa9d8258
: am 8a44f2c4
: am a3add1d2
: am c6a96d40
: Merge "Add color transform setting" into mnc-dr-dev
* commit 'fa9d8258d4d186c1aeaf3f79cff892d0a290e6a5': Add color transform setting
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:paddingBottom="8dp"
|
android:paddingBottom="4dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
|
22
res/layout/radio_list_container.xml
Normal file
22
res/layout/radio_list_container.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2015 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
|
android:orientation="vertical" />
|
@@ -39,7 +39,7 @@
|
|||||||
<TextView android:id="@android:id/summary"
|
<TextView android:id="@android:id/summary"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="4dp"
|
android:paddingBottom="8dp"
|
||||||
android:paddingStart="52dp"
|
android:paddingStart="52dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
@@ -5978,6 +5978,7 @@
|
|||||||
<string name="keywords_app_permissions">apps permissions security</string>
|
<string name="keywords_app_permissions">apps permissions security</string>
|
||||||
<string name="keywords_default_apps">apps default</string>
|
<string name="keywords_default_apps">apps default</string>
|
||||||
<string name="keywords_ignore_optimizations">ignore optimizations doze app standby</string>
|
<string name="keywords_ignore_optimizations">ignore optimizations doze app standby</string>
|
||||||
|
<string name="keywords_color_mode">vibrant rgb srgb color natural standard</string>
|
||||||
<!-- Search keywords for different screen unlock modes : slide to unlock, password, pattern and PIN [CHAR LIMIT=none] -->
|
<!-- Search keywords for different screen unlock modes : slide to unlock, password, pattern and PIN [CHAR LIMIT=none] -->
|
||||||
<string name="keywords_lockscreen">slide password pattern pin</string>
|
<string name="keywords_lockscreen">slide password pattern pin</string>
|
||||||
|
|
||||||
@@ -7032,4 +7033,21 @@
|
|||||||
|
|
||||||
<!-- Description of setting that controls gesture to open camera by double tapping the power button [CHAR LIMIT=NONE] -->
|
<!-- Description of setting that controls gesture to open camera by double tapping the power button [CHAR LIMIT=NONE] -->
|
||||||
<string name="camera_double_tap_power_gesture_desc">Quickly open camera without unlocking your screen</string>
|
<string name="camera_double_tap_power_gesture_desc">Quickly open camera without unlocking your screen</string>
|
||||||
|
|
||||||
|
<!-- Name of each color mode for the display. [CHAR LIMIT=40] -->
|
||||||
|
<string-array name="color_mode_names">
|
||||||
|
<item>Vibrant (default)</item>
|
||||||
|
<item>Natural</item>
|
||||||
|
<item>Standard</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Description of each color mode for the display. [CHAR LIMIT=NONE] -->
|
||||||
|
<string-array name="color_mode_descriptions">
|
||||||
|
<item>Enhanced colors</item>
|
||||||
|
<item>Natural colors as seen by the eye</item>
|
||||||
|
<item>Colors optimized for digital content</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Name of feature to change color setting for the display [CHAR LIMIT=60] -->
|
||||||
|
<string name="picture_color_mode">Picture color mode</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -103,6 +103,12 @@
|
|||||||
android:key="auto_rotate"
|
android:key="auto_rotate"
|
||||||
android:title="@string/display_auto_rotate_title" />
|
android:title="@string/display_auto_rotate_title" />
|
||||||
|
|
||||||
|
<com.android.settings.ColorModePreference
|
||||||
|
android:key="color_mode"
|
||||||
|
android:title="@string/picture_color_mode"
|
||||||
|
android:persistent="false"
|
||||||
|
settings:keywords="@string/keywords_color_mode" />
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:key="wifi_display"
|
android:key="wifi_display"
|
||||||
android:title="@string/wifi_display_settings_title"
|
android:title="@string/wifi_display_settings_title"
|
||||||
|
177
src/com/android/settings/ColorModePreference.java
Normal file
177
src/com/android/settings/ColorModePreference.java
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.android.settings;
|
||||||
|
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.hardware.display.DisplayManager;
|
||||||
|
import android.hardware.display.DisplayManager.DisplayListener;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.preference.DialogPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.Display.ColorTransform;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Checkable;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class ColorModePreference extends DialogPreference implements
|
||||||
|
OnClickListener, DisplayListener {
|
||||||
|
|
||||||
|
private DisplayManager mDisplayManager;
|
||||||
|
private Display mDisplay;
|
||||||
|
|
||||||
|
private int mCurrentIndex;
|
||||||
|
private ArrayList<ColorTransformDescription> mDescriptions;
|
||||||
|
|
||||||
|
public ColorModePreference(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
mDisplayManager = getContext().getSystemService(DisplayManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTransformsCount() {
|
||||||
|
return mDescriptions.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startListening() {
|
||||||
|
mDisplayManager.registerDisplayListener(this, new Handler(Looper.getMainLooper()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopListening() {
|
||||||
|
mDisplayManager.unregisterDisplayListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisplayAdded(int displayId) {
|
||||||
|
if (displayId == Display.DEFAULT_DISPLAY) {
|
||||||
|
updateCurrentAndSupported();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisplayChanged(int displayId) {
|
||||||
|
if (displayId == Display.DEFAULT_DISPLAY) {
|
||||||
|
updateCurrentAndSupported();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisplayRemoved(int displayId) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateCurrentAndSupported() {
|
||||||
|
mDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
|
||||||
|
|
||||||
|
mDescriptions = new ArrayList<>();
|
||||||
|
|
||||||
|
Resources resources = getContext().getResources();
|
||||||
|
int[] transforms = resources.getIntArray(
|
||||||
|
com.android.internal.R.array.config_colorTransforms);
|
||||||
|
String[] titles = resources.getStringArray(R.array.color_mode_names);
|
||||||
|
String[] descriptions = resources.getStringArray(R.array.color_mode_descriptions);
|
||||||
|
// Map the resource information describing color transforms.
|
||||||
|
for (int i = 0; i < transforms.length; i++) {
|
||||||
|
if (transforms[i] != -1) {
|
||||||
|
ColorTransformDescription desc = new ColorTransformDescription();
|
||||||
|
desc.colorTransform = transforms[i];
|
||||||
|
desc.title = titles[i];
|
||||||
|
desc.summary = descriptions[i];
|
||||||
|
mDescriptions.add(desc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Match up a ColorTransform to every description.
|
||||||
|
ColorTransform[] supportedColorTransforms = mDisplay.getSupportedColorTransforms();
|
||||||
|
for (int i = 0; i < supportedColorTransforms.length; i++) {
|
||||||
|
for (int j = 0; j < mDescriptions.size(); j++) {
|
||||||
|
if (mDescriptions.get(j).colorTransform
|
||||||
|
== supportedColorTransforms[i].getColorTransform()
|
||||||
|
&& mDescriptions.get(j).transform == null) {
|
||||||
|
mDescriptions.get(j).transform = supportedColorTransforms[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Remove any extras that don't have a transform for some reason.
|
||||||
|
for (int i = 0; i < mDescriptions.size(); i++) {
|
||||||
|
if (mDescriptions.get(i).transform == null) {
|
||||||
|
mDescriptions.remove(i--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorTransform currentTransform = mDisplay.getColorTransform();
|
||||||
|
mCurrentIndex = -1;
|
||||||
|
for (int i = 0; i < mDescriptions.size(); i++) {
|
||||||
|
if (mDescriptions.get(i).colorTransform == currentTransform.getColorTransform()) {
|
||||||
|
mCurrentIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mCurrentIndex != -1) {
|
||||||
|
setSummary(mDescriptions.get(mCurrentIndex).title);
|
||||||
|
} else {
|
||||||
|
setSummary(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected View onCreateDialogView() {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||||
|
LinearLayout v = (LinearLayout) inflater.inflate(R.layout.radio_list_container, null);
|
||||||
|
for (int i = 0; i < mDescriptions.size(); i++) {
|
||||||
|
View child = inflater.inflate(R.layout.radio_with_summary, v, false);
|
||||||
|
ColorTransformDescription desc = mDescriptions.get(i);
|
||||||
|
child.setTag(desc);
|
||||||
|
((TextView) child.findViewById(android.R.id.title)).setText(desc.title);
|
||||||
|
((TextView) child.findViewById(android.R.id.summary)).setText(desc.summary);
|
||||||
|
((Checkable) child).setChecked(i == mCurrentIndex);
|
||||||
|
child.setClickable(true);
|
||||||
|
child.setOnClickListener(this);
|
||||||
|
v.addView(child);
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPrepareDialogBuilder(Builder builder) {
|
||||||
|
super.onPrepareDialogBuilder(builder);
|
||||||
|
builder.setPositiveButton(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
ColorTransformDescription desc = (ColorTransformDescription) v.getTag();
|
||||||
|
|
||||||
|
mDisplay.requestColorTransform(desc.transform);
|
||||||
|
mCurrentIndex = mDescriptions.indexOf(desc);
|
||||||
|
|
||||||
|
setSummary(desc.title);
|
||||||
|
getDialog().dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ColorTransformDescription {
|
||||||
|
private int colorTransform;
|
||||||
|
private String title;
|
||||||
|
private String summary;
|
||||||
|
private ColorTransform transform;
|
||||||
|
}
|
||||||
|
}
|
@@ -79,6 +79,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
private static final String KEY_CAMERA_GESTURE = "camera_gesture";
|
private static final String KEY_CAMERA_GESTURE = "camera_gesture";
|
||||||
private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE
|
private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE
|
||||||
= "camera_double_tap_power_gesture";
|
= "camera_double_tap_power_gesture";
|
||||||
|
private static final String KEY_COLOR_MODE = "color_mode";
|
||||||
|
|
||||||
private DropDownPreference mFontSizePref;
|
private DropDownPreference mFontSizePref;
|
||||||
|
|
||||||
@@ -94,6 +95,8 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
private SwitchPreference mCameraGesturePreference;
|
private SwitchPreference mCameraGesturePreference;
|
||||||
private SwitchPreference mCameraDoubleTapPowerGesturePreference;
|
private SwitchPreference mCameraDoubleTapPowerGesturePreference;
|
||||||
|
|
||||||
|
private ColorModePreference mColorModePreference;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getMetricsCategory() {
|
protected int getMetricsCategory() {
|
||||||
return MetricsLogger.DISPLAY;
|
return MetricsLogger.DISPLAY;
|
||||||
@@ -168,6 +171,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
removePreference(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
|
removePreference(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mColorModePreference = (ColorModePreference) findPreference(KEY_COLOR_MODE);
|
||||||
|
mColorModePreference.updateCurrentAndSupported();
|
||||||
|
if (mColorModePreference.getTransformsCount() < 2) {
|
||||||
|
removePreference(KEY_COLOR_MODE);
|
||||||
|
mColorModePreference = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (RotationPolicy.isRotationLockToggleVisible(activity)) {
|
if (RotationPolicy.isRotationLockToggleVisible(activity)) {
|
||||||
DropDownPreference rotatePreference =
|
DropDownPreference rotatePreference =
|
||||||
(DropDownPreference) findPreference(KEY_AUTO_ROTATE);
|
(DropDownPreference) findPreference(KEY_AUTO_ROTATE);
|
||||||
@@ -359,6 +369,17 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
updateState();
|
updateState();
|
||||||
|
if (mColorModePreference != null) {
|
||||||
|
mColorModePreference.startListening();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (mColorModePreference != null) {
|
||||||
|
mColorModePreference.stopListening();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState() {
|
private void updateState() {
|
||||||
@@ -402,6 +423,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
getContentResolver(), CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
|
getContentResolver(), CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
|
||||||
mCameraDoubleTapPowerGesturePreference.setChecked(value == 0);
|
mCameraDoubleTapPowerGesturePreference.setChecked(value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mColorModePreference != null) {
|
||||||
|
mColorModePreference.updateCurrentAndSupported();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateScreenSaverSummary() {
|
private void updateScreenSaverSummary() {
|
||||||
@@ -528,6 +553,11 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
if (!isCameraDoubleTapPowerGestureAvailable(context.getResources())) {
|
if (!isCameraDoubleTapPowerGestureAvailable(context.getResources())) {
|
||||||
result.add(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
|
result.add(KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE);
|
||||||
}
|
}
|
||||||
|
ColorModePreference pref = new ColorModePreference(context, null);
|
||||||
|
pref.updateCurrentAndSupported();
|
||||||
|
if (pref.getTransformsCount() < 2) {
|
||||||
|
result.add(KEY_COLOR_MODE);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user