summaryrefslogtreecommitdiff
authorJinping Wang <jinping.wang@amlogic.com>2017-04-06 12:30:41 (GMT)
committer Jinping Wang <jinping.wang@amlogic.com>2017-04-07 08:25:34 (GMT)
commitcf254163d78211a7a0243dedba46cf1f2f511fb4 (patch)
tree9d6499d8983b65007ba2335b89bdb41234d39bec
parent5462d675899fc6f1e5f28138ccf54a46b24964d9 (diff)
downloadDroidTvSettings-cf254163d78211a7a0243dedba46cf1f2f511fb4.zip
DroidTvSettings-cf254163d78211a7a0243dedba46cf1f2f511fb4.tar.gz
DroidTvSettings-cf254163d78211a7a0243dedba46cf1f2f511fb4.tar.bz2
PD #142027: add new deepcolor function
Change-Id: I30dec367466b04230f0cc76a70e8f41e59030e95
Diffstat
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/com/droidlogic/tv/settings/display/outputmode/ColorAttributeActivity.java151
-rw-r--r--src/com/droidlogic/tv/settings/display/outputmode/OutputUiManager.java476
-rw-r--r--src/com/droidlogic/tv/settings/display/outputmode/OutputmodeActivity.java494
4 files changed, 717 insertions, 407 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2911a72..46c4b03 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -12,6 +12,9 @@
<string name="upgrade_bluetooth_remote">Upgrade bluetoothremote</string>
<string name="device_display">Display</string>
<string name="device_outputmode">Screen resolution</string>
+ <string name="device_color">Color</string>
+ <string name="device_colorattribute">Format and Depth</string>
+ <string name="device_outputmode_moresetting">More setting</string>
<string name="device_outputmode_auto">Auto switch to best resolution</string>
<string name="device_outputmode_deepcolor">deep color mode</string>
<string name="device_outputmode_confirm_mode">Confirm turn off deep color mode</string>
diff --git a/src/com/droidlogic/tv/settings/display/outputmode/ColorAttributeActivity.java b/src/com/droidlogic/tv/settings/display/outputmode/ColorAttributeActivity.java
new file mode 100644
index 0000000..4cd0761
--- a/dev/null
+++ b/src/com/droidlogic/tv/settings/display/outputmode/ColorAttributeActivity.java
@@ -0,0 +1,151 @@
+package com.droidlogic.tv.settings.display.outputmode;
+
+import com.droidlogic.tv.settings.R;
+import com.droidlogic.tv.settings.dialog.old.Action;
+import com.droidlogic.tv.settings.dialog.old.ActionAdapter;
+import com.droidlogic.tv.settings.dialog.old.ActionFragment;
+import com.droidlogic.tv.settings.dialog.old.ContentFragment;
+import com.droidlogic.tv.settings.dialog.old.DialogActivity;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.provider.Settings;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnFocusChangeListener;
+import android.widget.TextView;
+import android.widget.Toast;
+import android.content.BroadcastReceiver;
+import android.content.IntentFilter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+public class ColorAttributeActivity extends DialogActivity implements ActionAdapter.Listener{
+
+ private static final String LOG_TAG = "ColorAttributeActivity";
+ private ContentFragment mContentFragment;
+ private ActionFragment mActionFragment;
+ private OutputUiManager mOutputUiManager;
+ private static String saveValue = null;
+ private static String curValue = null;
+ private static String curMode = null;
+ private static final int MSG_FRESH_UI = 0;
+ private IntentFilter mIntentFilter;
+
+ private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mHandler.sendEmptyMessageDelayed(MSG_FRESH_UI, 1000);
+ }
+ };
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mOutputUiManager = new OutputUiManager(this);
+ mContentFragment = createMainMenuContentFragment();
+ mActionFragment = ActionFragment.newInstance(getMainActions());
+ setContentAndActionFragments(mContentFragment, mActionFragment);
+
+ mIntentFilter = new IntentFilter("android.intent.action.HDMI_PLUGGED");
+ mIntentFilter.addAction(Intent.ACTION_TIME_TICK);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ registerReceiver(mIntentReceiver, mIntentFilter);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ unregisterReceiver(mIntentReceiver);
+ }
+
+ @Override
+ public void onActionClicked(Action action) {
+ curValue= action.getKey().toString().trim();
+ saveValue= mOutputUiManager.getCurrentColorAttribute().toString().trim();
+ curMode = mOutputUiManager.getCurrentMode().trim();
+ Log.i(LOG_TAG,"curValue: "+curValue);
+ Log.i(LOG_TAG,"saveValue: "+saveValue);
+ if (!curValue.equals(saveValue)) {
+ if (isModeSupportColor(curMode,curValue)) {
+ mOutputUiManager.changeColorAttribte(curValue);
+ updateMainScreen();
+ }
+ else{
+ String msg = "Not support this color format & depth!";
+ Toast toast = Toast.makeText(this, msg, Toast.LENGTH_SHORT);
+ toast.show();
+ finish();
+ }
+ }
+ }
+
+ private boolean isModeSupportColor(final String curMode, final String curValue){
+ boolean ret = false;
+ ret = mOutputUiManager.isModeSupportColor(curMode, curValue);
+ return ret;
+ }
+ private ContentFragment createMainMenuContentFragment() {
+ return ContentFragment.newInstance(
+ getString(R.string.device_colorattribute), getString(R.string.device_color),
+ null, R.drawable.ic_settings_display,
+ getResources().getColor(R.color.icon_background));
+ }
+
+ private void goToMainScreen() {
+ updateMainScreen();
+ getFragmentManager().popBackStack(null, 0);
+ }
+
+ private void updateMainScreen() {
+ mOutputUiManager.updateUiMode();
+ ((ActionAdapter) mActionFragment.getAdapter()).setActions(getMainActions());
+ }
+
+ private ArrayList<Action> getMainActions() {
+ ArrayList<Action> actions = new ArrayList<Action>();
+ ArrayList<String> colorTitleList = mOutputUiManager.getColorTitleList();
+ ArrayList<String> colorValueList = mOutputUiManager.getColorValueList();
+ String value = null;
+ String curColorValue = mOutputUiManager.getCurrentColorAttribute().toString().trim();
+ Log.i(LOG_TAG,"curColorValue: "+curColorValue);
+
+ for (int i = 0; i < colorTitleList.size(); i++) {
+ value = colorValueList.get(i).trim();
+ if (curColorValue.equals(value)) {
+ actions.add(new Action.Builder().key(value)
+ .title(" " + colorTitleList.get(i))
+ .checked(true).build());
+ }else {
+ actions.add(new Action.Builder().key(value)
+ .title(" " + colorTitleList.get(i))
+ .description("").build());
+ }
+ }
+ return actions;
+ }
+
+ private Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_FRESH_UI:
+ updateMainScreen();
+ break;
+ }
+ }
+ };
+}
+
diff --git a/src/com/droidlogic/tv/settings/display/outputmode/OutputUiManager.java b/src/com/droidlogic/tv/settings/display/outputmode/OutputUiManager.java
index 87b78e3..5005854 100644
--- a/src/com/droidlogic/tv/settings/display/outputmode/OutputUiManager.java
+++ b/src/com/droidlogic/tv/settings/display/outputmode/OutputUiManager.java
@@ -1,5 +1,7 @@
package com.droidlogic.tv.settings.display.outputmode;
+import com.droidlogic.tv.settings.R;
+
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
@@ -18,7 +20,6 @@ import android.widget.ListView;
import android.widget.TextView;
import com.droidlogic.app.OutputModeManager;
-import com.droidlogic.tv.settings.R;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -32,171 +33,314 @@ import java.util.Arrays;
import java.util.List;
import android.content.Intent;
import android.content.IntentFilter;
-import android.os.UserHandle;
+import android.os.UserHandle ;
public class OutputUiManager {
- private static final String TAG = "OutputUiManager";
- private static boolean DEBUG = false;
-
- public static final String CVBS_MODE = "cvbs";
- public static final String HDMI_MODE = "hdmi";
-
- private static final String[] HDMI_LIST = { "1080p60hz", "1080p50hz", "720p60hz", "720p50hz", "2160p24hz",
- "2160p25hz", "2160p30hz", "2160p50hz420", "2160p60hz420", "smpte24hz", "1080p24hz", "576p50hz", "480p60hz",
- "1080i50hz", "1080i60hz", "576i50hz", "480i60hz", };
- private static final String[] HDMI_TITLE = { "1080p-60hz", "1080p-50hz", "720p-60hz", "720p-50hz", "4k2k-24hz",
- "4k2k-25hz", "4k2k-30hz", "4k2k-50hz", "4k2k-60hz", "4k2k-smpte", "1080p-24hz", "576p-50hz", "480p-60hz",
- "1080i-50hz", "1080i-60hz", "576i-50hz", "480i-60hz" };
- private static final String[] CVBS_MODE_VALUE_LIST = { "480cvbs", "576cvbs" };
- private static final String[] CVBS_MODE_TITLE_LIST = { "480 CVBS", "576 CVBS" };
- private static final int DEFAULT_HDMI_MODE = 0;
- private static final int DEFAULT_CVBS_MODE = 1;
- private static String[] mHdmiValueList;
- private static String[] mHdmiTitleList;
-
- private ArrayList<String> mTitleList = new ArrayList<String>();
- private ArrayList<String> mValueList = new ArrayList<String>();
- private ArrayList<String> mSupportList = new ArrayList<String>();
-
- private OutputModeManager mOutputModeManager;
- private Context mContext;
-
- private static String mUiMode;
-
- public OutputUiManager(Context context) {
- mContext = context;
- mOutputModeManager = new OutputModeManager(mContext);
-
- mUiMode = getUiMode();
- initModeValues(mUiMode);
- }
-
- public String getUiMode() {
- String currentMode = mOutputModeManager.getCurrentOutputMode();
- if (currentMode.contains(CVBS_MODE)) {
- mUiMode = CVBS_MODE;
- } else {
- mUiMode = HDMI_MODE;
- }
- return mUiMode;
- }
-
- public void updateUiMode() {
- mUiMode = getUiMode();
- initModeValues(mUiMode);
- }
-
- public String getCurrentMode() {
- return mOutputModeManager.getCurrentOutputMode();
- }
-
- public int getCurrentModeIndex() {
- String currentMode = mOutputModeManager.getCurrentOutputMode();
- for (int i = 0; i < mValueList.size(); i++) {
- if (currentMode.equals(mValueList.get(i))) {
- return i;
- }
- }
- if (mUiMode.equals(HDMI_MODE)) {
- return DEFAULT_HDMI_MODE;
- } else {
- return DEFAULT_CVBS_MODE;
- }
- }
-
- private void initModeValues(String mode) {
- filterOutputMode();
- mTitleList.clear();
- mValueList.clear();
-
- if (mode.equalsIgnoreCase(HDMI_MODE)) {
- for (int i = 0; i < mHdmiValueList.length; i++) {
- if (mHdmiTitleList[i] != null && mHdmiTitleList[i].length() != 0) {
- mTitleList.add(mHdmiTitleList[i]);
- mValueList.add(mHdmiValueList[i]);
- }
- }
- } else if (mode.equalsIgnoreCase(CVBS_MODE)) {
- for (int i = 0; i < CVBS_MODE_VALUE_LIST.length; i++) {
- mTitleList.add(CVBS_MODE_VALUE_LIST[i]);
- }
- for (int i = 0; i < CVBS_MODE_VALUE_LIST.length; i++) {
- mValueList.add(CVBS_MODE_VALUE_LIST[i]);
- }
- }
- }
-
- public void change2NewMode(final String mode) {
- mOutputModeManager.setBestMode(mode);
- }
-
- public void change2BestMode() {
- mOutputModeManager.setBestMode(null);
- }
-
- public boolean isBestOutputmode() {
- return mOutputModeManager.isBestOutputmode();
- }
-
- public void change2DeepColorMode() {
- mOutputModeManager.setDeepColorMode();
- }
-
- public boolean isDeepColor() {
- return mOutputModeManager.isDeepColor();
- }
-
- public ArrayList<String> getOutputmodeTitleList() {
- return mTitleList;
- }
-
- public ArrayList<String> getOutputmodeValueList() {
- return mValueList;
- }
-
- public void filterOutputMode() {
- List<String> list_value = new ArrayList<String>();
- List<String> list_title = new ArrayList<String>();
-
- mHdmiValueList = HDMI_LIST;
- mHdmiTitleList = HDMI_TITLE;
-
- for (int i = 0; i < mHdmiValueList.length; i++) {
- if (mHdmiValueList[i] != null) {
- list_value.add(mHdmiValueList[i]);
- list_title.add(mHdmiTitleList[i]);
- }
- }
-
- String str_filter_mode = mContext.getResources().getString(R.string.display_filter_outputmode);
- if (str_filter_mode != null && str_filter_mode.length() != 0) {
- String[] array_filter_mode = str_filter_mode.split(",");
- for (int i = 0; i < array_filter_mode.length; i++) {
- for (int j = 0; j < list_value.size(); j++) {
- if ((list_value.get(j).toString()).equals(array_filter_mode[i])) {
- list_value.remove(j);
- list_title.remove(j);
- }
- }
- }
- }
-
- String str_edid = mOutputModeManager.getHdmiSupportList();
- if (str_edid != null && str_edid.length() != 0 && !str_edid.contains("null")) {
- List<String> list_hdmi_mode = new ArrayList<String>();
- List<String> list_hdmi_title = new ArrayList<String>();
- for (int i = 0; i < list_value.size(); i++) {
- if (str_edid.contains(list_value.get(i))) {
- list_hdmi_mode.add(list_value.get(i));
- list_hdmi_title.add(list_title.get(i));
- }
-
- }
- mHdmiValueList = list_hdmi_mode.toArray(new String[list_value.size()]);
- mHdmiTitleList = list_hdmi_title.toArray(new String[list_title.size()]);
- } else {
- mHdmiValueList = list_value.toArray(new String[list_value.size()]);
- mHdmiTitleList = list_title.toArray(new String[list_title.size()]);
- }
- }
+ private static final String TAG = "OutputUiManager";
+ private static boolean DEBUG = false;
+
+ public static final String CVBS_MODE = "cvbs";
+ public static final String HDMI_MODE = "hdmi";
+
+ private static final String[] HDMI_LIST = {
+ "1080p60hz",
+ "1080p50hz",
+ "720p60hz",
+ "720p50hz",
+ "2160p24hz",
+ "2160p25hz",
+ "2160p30hz",
+ "2160p50hz420",
+ "2160p60hz420",
+ "smpte24hz",
+ "1080p24hz",
+ "576p50hz",
+ "480p60hz",
+ "1080i50hz",
+ "1080i60hz",
+ "576i50hz",
+ "480i60hz",
+ };
+ private static final String[] HDMI_TITLE = {
+ "1080p-60hz",
+ "1080p-50hz",
+ "720p-60hz",
+ "720p-50hz",
+ "4k2k-24hz",
+ "4k2k-25hz",
+ "4k2k-30hz",
+ "4k2k-50hz",
+ "4k2k-60hz",
+ "4k2k-smpte",
+ "1080p-24hz",
+ "576p-50hz",
+ "480p-60hz",
+ "1080i-50hz",
+ "1080i-60hz",
+ "576i-50hz",
+ "480i-60hz"
+ };
+
+ private static final String[] HDMI_COLOR_LIST = {
+ "444,12bit",
+ "444,10bit",
+ "444,8bit",
+ "422,12bit",
+ "422,10bit",
+ "422,8bit",
+ "420,12bit",
+ "420,10bit",
+ "420,8bit",
+ "rgb,12bit",
+ "rgb,10bit",
+ "rgb,8bit"
+ };
+ private static final String[] HDMI_COLOR_TITLE = {
+ "YCbCr444 12bit",
+ "YCbCr444 10bit",
+ "YCbCr444 8bit",
+ "YCbCr422 12bit",
+ "YCbCr422 10bit",
+ "YCbCr422 8bit",
+ "YCbCr420 12bit",
+ "YCbCr420 10bit",
+ "YCbCr420 8bit",
+ "RGB 12bit",
+ "RGB 10bit",
+ "RGB 8bit"
+ };
+
+ private static final String[] CVBS_MODE_VALUE_LIST = {
+ "480cvbs",
+ "576cvbs"
+ };
+ private static final String[] CVBS_MODE_TITLE_LIST = {
+ "480 CVBS",
+ "576 CVBS"
+ };
+ private static final int DEFAULT_HDMI_MODE = 0;
+ private static final int DEFAULT_CVBS_MODE = 1;
+ private static String[] mHdmiValueList;
+ private static String[] mHdmiTitleList;
+
+ private static String[] mHdmiColorValueList;
+ private static String[] mHdmiColorTitleList;
+
+ private ArrayList<String> mTitleList = new ArrayList<String>();
+ private ArrayList<String> mValueList = new ArrayList<String>();
+ private ArrayList<String> mSupportList = new ArrayList<String>();
+
+ private ArrayList<String> mColorTitleList = new ArrayList<String>();
+ private ArrayList<String> mColorValueList = new ArrayList<String>();
+
+ private OutputModeManager mOutputModeManager;
+ private Context mContext;
+
+ private static String mUiMode;
+
+ public OutputUiManager(Context context){
+ mContext = context;
+ mOutputModeManager = new OutputModeManager(mContext);
+
+ mUiMode = getUiMode();
+ initModeValues(mUiMode);
+ initColorValues(mUiMode);
+ }
+
+ public String getUiMode(){
+ String currentMode = mOutputModeManager.getCurrentOutputMode();
+ if (currentMode.contains(CVBS_MODE)) {
+ mUiMode = CVBS_MODE;
+ } else {
+ mUiMode = HDMI_MODE;
+ }
+ return mUiMode;
+ }
+
+ public void updateUiMode(){
+ mUiMode = getUiMode();
+ initModeValues(mUiMode);
+ }
+
+ public String getCurrentMode(){
+ return mOutputModeManager.getCurrentOutputMode();
+ }
+
+ public String getCurrentColorAttribute(){
+ return mOutputModeManager.getCurrentColorAttribute();
+ }
+
+ private void initColorValues(String mode){
+ filterColorAttribute();
+ mColorTitleList.clear();
+ mColorValueList.clear();
+
+ if (mode.equalsIgnoreCase(HDMI_MODE)) {
+ for (int i=0 ; i< mHdmiColorValueList.length; i++) {
+ if (mHdmiColorTitleList[i] != null && mHdmiColorTitleList[i].length() != 0) {
+ mColorTitleList.add(mHdmiColorTitleList[i]);
+ mColorValueList.add(mHdmiColorValueList[i]);
+ }
+ }
+ }
+ }
+
+ public void changeColorAttribte(final String colorValue) {
+ mOutputModeManager.setDeepColorAttribute(colorValue);
+ }
+
+ public ArrayList<String> getColorTitleList(){
+ return mColorTitleList;
+ }
+
+ public ArrayList<String> getColorValueList(){
+ return mColorValueList;
+ }
+
+ public void filterColorAttribute() {
+ List<String> listValue = new ArrayList<String>();
+ List<String> listTitle = new ArrayList<String>();
+
+ mHdmiColorValueList = HDMI_COLOR_LIST;
+ mHdmiColorTitleList = HDMI_COLOR_TITLE;
+
+ for (int i = 0; i < mHdmiColorValueList.length; i++) {
+ if (mHdmiColorValueList[i] != null) {
+ listValue.add(mHdmiColorValueList[i]);
+ listTitle.add(mHdmiColorTitleList[i]);
+ }
+ }
+
+ String strColorlist = mOutputModeManager.getHdmiColorSupportList();
+ if (strColorlist != null && strColorlist.length() != 0 && !strColorlist.contains("null")) {
+ List<String> listHdmiMode = new ArrayList<String>();
+ List<String> listHdmiTitle = new ArrayList<String>();
+ for (int i = 0; i < listValue.size(); i++) {
+ if (strColorlist.contains(listValue.get(i))) {
+ listHdmiMode.add(listValue.get(i));
+ listHdmiTitle.add(listTitle.get(i));
+ }
+
+ }
+ mHdmiColorValueList = listHdmiMode.toArray(new String[listValue.size()]);
+ mHdmiColorTitleList = listHdmiTitle.toArray(new String[listTitle.size()]);
+ } else {
+ mHdmiColorValueList = new String[]{""};
+ mHdmiColorTitleList = new String[]{"No data!"};
+ }
+ }
+
+ public boolean isModeSupportColor(final String curMode, final String curValue){
+ return mOutputModeManager.isModeSupportColor(curMode, curValue);
+ }
+
+ public int getCurrentModeIndex(){
+ String currentMode = mOutputModeManager.getCurrentOutputMode();
+ for (int i=0 ; i < mValueList.size();i++) {
+ if (currentMode.equals(mValueList.get(i))) {
+ return i ;
+ }
+ }
+ if (mUiMode.equals(HDMI_MODE)) {
+ return DEFAULT_HDMI_MODE;
+ }else{
+ return DEFAULT_CVBS_MODE;
+ }
+ }
+
+ private void initModeValues(String mode){
+ filterOutputMode();
+ mTitleList.clear();
+ mValueList.clear();
+
+ if (mode.equalsIgnoreCase(HDMI_MODE)) {
+ for (int i=0 ; i< mHdmiValueList.length; i++) {
+ if (mHdmiTitleList[i] != null && mHdmiTitleList[i].length() != 0) {
+ mTitleList.add(mHdmiTitleList[i]);
+ mValueList.add(mHdmiValueList[i]);
+ }
+ }
+ }else if (mode.equalsIgnoreCase(CVBS_MODE)) {
+ for (int i = 0 ; i< CVBS_MODE_VALUE_LIST.length; i++) {
+ mTitleList.add(CVBS_MODE_VALUE_LIST[i]);
+ }
+ for (int i=0 ; i < CVBS_MODE_VALUE_LIST.length ; i++) {
+ mValueList.add(CVBS_MODE_VALUE_LIST[i]);
+ }
+ }
+ }
+
+ public void change2NewMode(final String mode) {
+ mOutputModeManager.setBestMode(mode);
+ }
+
+ public void change2BestMode() {
+ mOutputModeManager.setBestMode(null);
+ }
+ public boolean isBestOutputmode(){
+ return mOutputModeManager.isBestOutputmode();
+ }
+
+ public void change2DeepColorMode() {
+ mOutputModeManager.setDeepColorMode();
+ }
+
+ public boolean isDeepColor(){
+ return mOutputModeManager.isDeepColor();
+ }
+
+ public ArrayList<String> getOutputmodeTitleList(){
+ return mTitleList;
+ }
+
+ public ArrayList<String> getOutputmodeValueList(){
+ return mValueList;
+ }
+
+ public void filterOutputMode() {
+ List<String> listValue = new ArrayList<String>();
+ List<String> listTitle = new ArrayList<String>();
+
+ mHdmiValueList = HDMI_LIST;
+ mHdmiTitleList = HDMI_TITLE;
+
+ for (int i = 0; i < mHdmiValueList.length; i++) {
+ if (mHdmiValueList[i] != null) {
+ listValue.add(mHdmiValueList[i]);
+ listTitle.add(mHdmiTitleList[i]);
+ }
+ }
+
+ String strFilterMode = mContext.getResources().getString(R.string.display_filter_outputmode);
+ if (strFilterMode != null && strFilterMode.length() != 0) {
+ String[] array_filter_mode = strFilterMode.split(",");
+ for (int i = 0; i < array_filter_mode.length; i++) {
+ for (int j = 0; j < listValue.size(); j++) {
+ if ((listValue.get(j).toString()).equals(array_filter_mode[i])) {
+ listValue.remove(j);
+ listTitle.remove(j);
+ }
+ }
+ }
+ }
+
+ String strEdid = mOutputModeManager.getHdmiSupportList();
+ if (strEdid != null && strEdid.length() != 0 && !strEdid.contains("null")) {
+ List<String> listHdmiMode = new ArrayList<String>();
+ List<String> listHdmiTitle = new ArrayList<String>();
+ for (int i = 0; i < listValue.size(); i++) {
+ if (strEdid.contains(listValue.get(i))) {
+ listHdmiMode.add(listValue.get(i));
+ listHdmiTitle.add(listTitle.get(i));
+ }
+
+ }
+ mHdmiValueList = listHdmiMode.toArray(new String[listValue.size()]);
+ mHdmiTitleList = listHdmiTitle.toArray(new String[listTitle.size()]);
+ } else {
+ mHdmiValueList = listValue.toArray(new String[listValue.size()]);
+ mHdmiTitleList = listTitle.toArray(new String[listTitle.size()]);
+ }
+ }
+
}
diff --git a/src/com/droidlogic/tv/settings/display/outputmode/OutputmodeActivity.java b/src/com/droidlogic/tv/settings/display/outputmode/OutputmodeActivity.java
index c3d82f3..7be4f97 100644
--- a/src/com/droidlogic/tv/settings/display/outputmode/OutputmodeActivity.java
+++ b/src/com/droidlogic/tv/settings/display/outputmode/OutputmodeActivity.java
@@ -1,5 +1,6 @@
package com.droidlogic.tv.settings.display.outputmode;
+
import com.droidlogic.tv.settings.R;
import com.droidlogic.tv.settings.dialog.old.Action;
import com.droidlogic.tv.settings.dialog.old.ActionAdapter;
@@ -35,245 +36,256 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
-public class OutputmodeActivity extends DialogActivity
- implements ActionAdapter.Listener, OnClickListener, OnFocusChangeListener {
- private final static String BEST_RESOLUTION = "best resolution";
- private final static String DEEP_COLOR = "deep_color";
- private ContentFragment mContentFragment;
- private ActionFragment mActionFragment;
- private OutputUiManager mOutputUiManager;
- private IntentFilter mIntentFilter;
- private static final int MSG_FRESH_UI = 0;
- private static final int MSG_COUNT_DOWN = 1;
- private static boolean saveDeepColor = false;
- private static String saveMode;
- private View view_dialog;
- private TextView tx_title;
- private TextView tx_content;
- private Timer timer;
- private TimerTask task;
- private AlertDialog mAlertDialog = null;
- private int countdown = 15;
- private static String mode = null;
-
- private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- mHandler.sendEmptyMessageDelayed(MSG_FRESH_UI, 1000);
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- mOutputUiManager = new OutputUiManager(this);
- mContentFragment = createMainMenuContentFragment();
- mActionFragment = ActionFragment.newInstance(getMainActions());
- setContentAndActionFragments(mContentFragment, mActionFragment);
-
- mIntentFilter = new IntentFilter("android.intent.action.HDMI_PLUGGED");
- mIntentFilter.addAction(Intent.ACTION_TIME_TICK);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- registerReceiver(mIntentReceiver, mIntentFilter);
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- unregisterReceiver(mIntentReceiver);
- }
-
- @Override
- public void onActionClicked(Action action) {
- mode = action.getKey();
-
- saveDeepColor = mOutputUiManager.isDeepColor();
- saveMode = mOutputUiManager.getCurrentMode();
-
- if (mode.equals(BEST_RESOLUTION)) {
- mOutputUiManager.change2BestMode();
- } else if (mode.equals(DEEP_COLOR)) {
- mOutputUiManager.change2DeepColorMode();
- } else {
- mOutputUiManager.change2NewMode(mode);
- }
- updateMainScreen();
-
- if (saveDeepColor != mOutputUiManager.isDeepColor() || !saveMode.equals(mOutputUiManager.getCurrentMode())) {
- showDialog();
- }
- }
-
- private void goToMainScreen() {
- updateMainScreen();
- getFragmentManager().popBackStack(null, 0);
- }
-
- private void updateMainScreen() {
- mOutputUiManager.updateUiMode();
- ((ActionAdapter) mActionFragment.getAdapter()).setActions(getMainActions());
- }
-
- private ContentFragment createMainMenuContentFragment() {
- return ContentFragment.newInstance(getString(R.string.device_outputmode), getString(R.string.device_display),
- null, R.drawable.ic_settings_display, getResources().getColor(R.color.icon_background));
- }
-
- private ArrayList<Action> getMainActions() {
- ArrayList<Action> actions = new ArrayList<Action>();
- ArrayList<String> outputmodeTitleList = mOutputUiManager.getOutputmodeTitleList();
- ArrayList<String> outputmodeValueList = mOutputUiManager.getOutputmodeValueList();
-
- if (mOutputUiManager.getUiMode().equals(mOutputUiManager.HDMI_MODE)) {
- String best_resolution_description;
- if (mOutputUiManager.isBestOutputmode()) {
- best_resolution_description = getString(R.string.captions_display_on);
- } else {
- best_resolution_description = getString(R.string.captions_display_off);
- }
- actions.add(new Action.Builder().key(BEST_RESOLUTION)
- .title(" " + getString(R.string.device_outputmode_auto))
- .description(" " + best_resolution_description).build());
- }
-
- String isDeepColor;
- if (mOutputUiManager.isDeepColor()) {
- isDeepColor = getString(R.string.captions_display_on);
- } else {
- isDeepColor = getString(R.string.captions_display_off);
- }
- actions.add(
- new Action.Builder().key(DEEP_COLOR).title(" " + getString(R.string.device_outputmode_deepcolor))
- .description(" " + isDeepColor).build());
-
- int currentModeIndex = mOutputUiManager.getCurrentModeIndex();
- for (int i = 0; i < outputmodeTitleList.size(); i++) {
- if (i == currentModeIndex) {
- actions.add(new Action.Builder().key(outputmodeValueList.get(i))
- .title(" " + outputmodeTitleList.get(i)).checked(true).build());
- } else {
- actions.add(new Action.Builder().key(outputmodeValueList.get(i))
- .title(" " + outputmodeTitleList.get(i)).description("").build());
- }
- }
- return actions;
- }
-
- private void showDialog() {
- if (mAlertDialog == null) {
- LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view_dialog = inflater.inflate(R.layout.dialog_outputmode, null);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- mAlertDialog = builder.create();
- mAlertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
-
- tx_title = (TextView) view_dialog.findViewById(R.id.dialog_title);
- tx_content = (TextView) view_dialog.findViewById(R.id.dialog_content);
-
- TextView button_cancel = (TextView) view_dialog.findViewById(R.id.dialog_cancel);
- button_cancel.setOnClickListener(this);
- button_cancel.setOnFocusChangeListener(this);
-
- TextView button_ok = (TextView) view_dialog.findViewById(R.id.dialog_ok);
- button_ok.setOnClickListener(this);
- button_ok.setOnFocusChangeListener(this);
- }
- mAlertDialog.show();
- mAlertDialog.getWindow().setContentView(view_dialog);
-
- if (mode.equals(DEEP_COLOR)) {
- if (saveDeepColor != mOutputUiManager.isDeepColor() && mOutputUiManager.isDeepColor()) {
- tx_content.setText(getResources().getString(R.string.device_outputmode_confirm_deepcolor));
- } else {
- tx_content.setText(getResources().getString(R.string.device_outputmode_confirm_mode));
- }
- } else {
- if (mOutputUiManager.getOutputmodeTitleList().size() <= 0) {
- tx_content.setText("Get outputmode empty!");
- } else if (mOutputUiManager.getCurrentModeIndex() < mOutputUiManager.getOutputmodeTitleList().size()) {
- tx_content.setText(getResources().getString(R.string.device_outputmode_change) + " "
- + mOutputUiManager.getOutputmodeTitleList().get(mOutputUiManager.getCurrentModeIndex()));
- }
- }
-
- countdown = 15;
- if (timer == null)
- timer = new Timer();
- if (task != null)
- task.cancel();
- task = new DialogTimerTask();
- timer.schedule(task, 0, 1000);
- }
-
- private void recoverOutputMode() {
- if (saveDeepColor == mOutputUiManager.isDeepColor()) {
- mOutputUiManager.change2NewMode(saveMode);
- } else {
- mOutputUiManager.change2DeepColorMode();
- }
- mHandler.sendEmptyMessage(MSG_FRESH_UI);
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.dialog_cancel:
- if (mAlertDialog != null) {
- mAlertDialog.dismiss();
- }
- recoverOutputMode();
- break;
- case R.id.dialog_ok:
- if (mAlertDialog != null) {
- mAlertDialog.dismiss();
- }
- break;
- }
- task.cancel();
- }
-
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (v instanceof TextView) {
- if (hasFocus) {
- } else {
- }
- }
- }
-
- private Handler mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- switch (msg.what) {
- case MSG_FRESH_UI:
- updateMainScreen();
- break;
- case MSG_COUNT_DOWN:
- tx_title.setText(Integer.toString(countdown) + " "
- + getResources().getString(R.string.device_outputmode_countdown));
- if (countdown == 0) {
- if (mAlertDialog != null) {
- mAlertDialog.dismiss();
- }
- recoverOutputMode();
- task.cancel();
- }
- countdown--;
- break;
- }
- }
- };
-
- private class DialogTimerTask extends TimerTask {
- @Override
- public void run() {
- mHandler.sendEmptyMessage(MSG_COUNT_DOWN);
- }
- };
+public class OutputmodeActivity extends DialogActivity implements ActionAdapter.Listener, OnClickListener, OnFocusChangeListener{
+ private final static String BEST_RESOLUTION = "best resolution";
+ private final static String DEEP_COLOR = "deep_color";
+ private final static String MORE_SETTING= "more setting";
+ private ContentFragment mContentFragment;
+ private ActionFragment mActionFragment;
+ private OutputUiManager mOutputUiManager;
+ private IntentFilter mIntentFilter;
+ private static final int MSG_FRESH_UI = 0;
+ private static final int MSG_COUNT_DOWN = 1;
+ private static boolean saveDeepColor = false;
+ private static String saveMode;
+ private View view_dialog;
+ private TextView tx_title;
+ private TextView tx_content;
+ private Timer timer;
+ private TimerTask task;
+ private AlertDialog mAlertDialog = null;
+ private int countdown = 15;
+ private static String mode = null;
+
+ private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mHandler.sendEmptyMessageDelayed(MSG_FRESH_UI, 1000);
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mOutputUiManager = new OutputUiManager(this);
+ mContentFragment = createMainMenuContentFragment();
+ mActionFragment = ActionFragment.newInstance(getMainActions());
+ setContentAndActionFragments(mContentFragment, mActionFragment);
+
+ mIntentFilter = new IntentFilter("android.intent.action.HDMI_PLUGGED");
+ mIntentFilter.addAction(Intent.ACTION_TIME_TICK);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ registerReceiver(mIntentReceiver, mIntentFilter);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ unregisterReceiver(mIntentReceiver);
+ }
+
+ @Override
+ public void onActionClicked(Action action) {
+ mode = action.getKey();
+
+ saveDeepColor = mOutputUiManager.isDeepColor();
+ saveMode = mOutputUiManager.getCurrentMode();
+
+ if (mode.equals(BEST_RESOLUTION)) {
+ mOutputUiManager.change2BestMode();
+ }else if (mode.equals(MORE_SETTING)) {
+ Intent intent = new Intent(OutputmodeActivity.this,ColorAttributeActivity.class);
+ startActivity(intent);
+ return;
+ //mOutputUiManager.change2DeepColorMode();
+ }else {
+ mOutputUiManager.change2NewMode(mode);
+ }
+ updateMainScreen();
+
+ if (saveDeepColor != mOutputUiManager.isDeepColor()
+ || !saveMode.equals(mOutputUiManager.getCurrentMode())) {
+ showDialog();
+ }
+ }
+
+ private void goToMainScreen() {
+ updateMainScreen();
+ getFragmentManager().popBackStack(null, 0);
+ }
+
+ private void updateMainScreen() {
+ mOutputUiManager.updateUiMode();
+ ((ActionAdapter) mActionFragment.getAdapter()).setActions(getMainActions());
+ }
+
+ private ContentFragment createMainMenuContentFragment() {
+ return ContentFragment.newInstance(
+ getString(R.string.device_outputmode), getString(R.string.device_display),
+ null, R.drawable.ic_settings_display,
+ getResources().getColor(R.color.icon_background));
+ }
+
+ private ArrayList<Action> getMainActions() {
+ ArrayList<Action> actions = new ArrayList<Action>();
+ ArrayList<String> outputmodeTitleList = mOutputUiManager.getOutputmodeTitleList();
+ ArrayList<String> outputmodeValueList = mOutputUiManager.getOutputmodeValueList();
+
+ if (mOutputUiManager.getUiMode().equals(mOutputUiManager.HDMI_MODE)) {
+ String best_resolution_description;
+ if (mOutputUiManager.isBestOutputmode()) {
+ best_resolution_description = getString(R.string.captions_display_on);
+ } else{
+ best_resolution_description = getString(R.string.captions_display_off);
+ }
+ actions.add(new Action.Builder().key(BEST_RESOLUTION)
+ .title(" " + getString(R.string.device_outputmode_auto))
+ .description(" " + best_resolution_description).build());
+ }
+ /*
+ String isDeepColor;
+ if (mOutputUiManager.isDeepColor()) {
+ isDeepColor = getString(R.string.captions_display_on);
+ } else{
+ isDeepColor = getString(R.string.captions_display_off);
+ }
+ actions.add(new Action.Builder().key(DEEP_COLOR)
+ .title(" " + getString(R.string.device_outputmode_deepcolor))
+ .description(" " + isDeepColor).build());
+ */
+ actions.add(new Action.Builder().key(MORE_SETTING)
+ .title(" " + getString(R.string.device_outputmode_moresetting))
+ .description("").build());
+
+ int currentModeIndex = mOutputUiManager.getCurrentModeIndex();
+ for (int i = 0; i < outputmodeTitleList.size(); i++) {
+ if (i == currentModeIndex) {
+ actions.add(new Action.Builder().key(outputmodeValueList.get(i))
+ .title(" " + outputmodeTitleList.get(i))
+ .checked(true).build());
+ }else {
+ actions.add(new Action.Builder().key(outputmodeValueList.get(i))
+ .title(" " + outputmodeTitleList.get(i))
+ .description("").build());
+ }
+ }
+ return actions;
+ }
+
+ private void showDialog () {
+ if (mAlertDialog == null) {
+ LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view_dialog = inflater.inflate(R.layout.dialog_outputmode, null);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ mAlertDialog = builder.create();
+ mAlertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
+
+ tx_title = (TextView)view_dialog.findViewById(R.id.dialog_title);
+ tx_content = (TextView)view_dialog.findViewById(R.id.dialog_content);
+
+ TextView button_cancel = (TextView)view_dialog.findViewById(R.id.dialog_cancel);
+ button_cancel.setOnClickListener(this);
+ button_cancel.setOnFocusChangeListener(this);
+
+ TextView button_ok = (TextView)view_dialog.findViewById(R.id.dialog_ok);
+ button_ok.setOnClickListener(this);
+ button_ok.setOnFocusChangeListener(this);
+ }
+ mAlertDialog.show();
+ mAlertDialog.getWindow().setContentView(view_dialog);
+
+ if (mode.equals(DEEP_COLOR)) {
+ if (saveDeepColor != mOutputUiManager.isDeepColor() && mOutputUiManager.isDeepColor()) {
+ tx_content.setText(getResources().getString(R.string.device_outputmode_confirm_deepcolor));
+ } else {
+ tx_content.setText(getResources().getString(R.string.device_outputmode_confirm_mode));
+ }
+ } else {
+ if (mOutputUiManager.getOutputmodeTitleList().size() <= 0) {
+ tx_content.setText("Get outputmode empty!");
+ } else if (mOutputUiManager.getCurrentModeIndex() < mOutputUiManager.getOutputmodeTitleList().size()) {
+ tx_content.setText(getResources().getString(R.string.device_outputmode_change)
+ + " " +mOutputUiManager.getOutputmodeTitleList().get(mOutputUiManager.getCurrentModeIndex()));
+ }
+ }
+
+ countdown = 15;
+ if (timer == null)
+ timer = new Timer();
+ if (task != null)
+ task.cancel();
+ task = new DialogTimerTask();
+ timer.schedule(task, 0, 1000);
+ }
+
+ private void recoverOutputMode() {
+ if (saveDeepColor == mOutputUiManager.isDeepColor()) {
+ mOutputUiManager.change2NewMode(saveMode);
+ } else {
+ mOutputUiManager.change2DeepColorMode();
+ }
+ mHandler.sendEmptyMessage(MSG_FRESH_UI);
+ }
+
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.dialog_cancel:
+ if (mAlertDialog != null) {
+ mAlertDialog.dismiss();
+ }
+ recoverOutputMode();
+ break;
+ case R.id.dialog_ok:
+ if (mAlertDialog != null) {
+ mAlertDialog.dismiss();
+ }
+ break;
+ }
+ task.cancel();
+ }
+
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (v instanceof TextView) {
+ if (hasFocus) {
+ } else {
+ }
+ }
+ }
+
+ private Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_FRESH_UI:
+ updateMainScreen();
+ break;
+ case MSG_COUNT_DOWN:
+ tx_title.setText(Integer.toString(countdown) + " " + getResources().getString(R.string.device_outputmode_countdown));
+ if (countdown == 0) {
+ if (mAlertDialog != null) {
+ mAlertDialog.dismiss();
+ }
+ recoverOutputMode();
+ task.cancel();
+ }
+ countdown--;
+ break;
+ }
+ }
+ };
+
+ private class DialogTimerTask extends TimerTask {
+ @Override
+ public void run() {
+ mHandler.sendEmptyMessage(MSG_COUNT_DOWN);
+ }
+ };
}