package com.tcl.factory.view;

 
import android.content.Context;
import android.view.KeyEvent;

import com.tcl.factory.bsp.TV;
import com.tcl.factory.bsp.TVDefine;
import com.tcl.factory.def.DEFS;
import com.tcl.factory.thirdparty.ThirdParty;
import com.tcl.factory.utils.Utils;

 

public class DModeParamSetting extends SubMenu
{
 
	public static Context mContext = null;
 


	public static  String MenuInfos_DModeParamSetting[][]={
		{"0-Sound Setting",""},
		{"1-Picture Curve",""},
		{"2-Picture Setting",""},
		{"3-SSC(Spread Spectrum clocking) Adjust",""},
		{"4-DBC(Dynamic Backlight Control)",""},
		//{"5-CI(Common Interface) Card",""},
		{"5-Overscan",""},
		{"6-WIFI CHEAK",""},
		//{"8-USB FILE",""},
		{"7-MEMC LEVEL",""},
		{"8-Light Sensor",""}
	};

	int MEMC_Level =0;
	public DModeParamSetting()
	{
		super.menuInfos=MenuInfos_DModeParamSetting;
		super.menuLabel = "Main\\Setting Menu";
		super.setTAG();
		updateMenuInfos();
	}
 
	public void KeyEvent(int keyCode,int pos)
	{
		switch(keyCode)
		{
		case KeyEvent.KEYCODE_DPAD_LEFT:
		case KeyEvent.KEYCODE_DPAD_RIGHT:
		{
			switch(pos)
			{
				//case 5: ;break;
				//Utils.intentHandler(DEFS.Package_TCL_TV, DEFS.Activity_TCL_CICard) ;break;
				//case 6: ;break;
				//Utils.intentHandler(DEFS.Package_Android_Setting, DEFS.Activity_Android_Setting_WIFI) ;break;
	//			case 8: Utils.intentHandler(DEFS.Package_TCL_FileExplorer, DEFS.Activity_TCL_FileExplorer ) ;break;
				case 7:Set_MEMC_Level(keyCode);break;			
			}
		}
		break;
		default:
			break;
		}
	}
	
	
	
	private void Set_MEMC_Level(int keyCode) 
	{
	    MEMC_Level=TV.readV(TVDefine.MemcLevel);
		MEMC_Level=dataDeal(MEMC_Level,keyCode);
		TV.writeV(TVDefine.MemcLevel, MEMC_Level);
	}
	
	private int dataDeal(int mValue,int EventCode){
		if(EventCode==KeyEvent.KEYCODE_DPAD_LEFT){
			mValue--;
		}
		else if(EventCode == KeyEvent.KEYCODE_DPAD_RIGHT){	
			mValue++;
		}
		if(mValue>3)mValue = 0;
		else if(mValue<0)mValue = 3;
		 
		return mValue;
	}
 	 
	/* (non-Javadoc)
	 * Factory
	 */
	@Override
	public void updateMenuInfos() 
	{
		//super.updateStatusInfo(TVDefine.Curve,curvetype,2, 4);
		//super.updateStatusInfo(TVDefine.CICard, 5);
		MEMC_Level=ThirdParty.getMemcLevel();
		menuInfos[7][1] = ""+MEMC_Level;
	}
	/* (non-Javadoc)
	 * Factory
	 */
	@Override
	public void enterSubMenu(int pos) 
	{
		// TODO Auto-generated method stub
		super.enterSubMenu(pos);
		
		switch(pos)
		{
//		case 0:MainMenu.mSubMenu=new ParamSettingSoundCurve(); break;
		case 0:MainMenu.mSubMenu=new ParamSettingSound(); break;
		case 1:MainMenu.mSubMenu=new ParamSettingCurve(); break;
 		case 2:MainMenu.mSubMenu=new ParamSettingPIC(); break;
		case 3:MainMenu.mSubMenu=new ParamSettingSSC(); break;
		case 4:
			if(ThirdParty.isCnPrj()) {
				MainMenu.mSubMenu=new ParamSettingDBC(); 
			} else {
				MainMenu.mSubMenu=new ParamSettingDBCAu();
			}
			break;
//		case 4:MainMenu.mSubMenu=new ParamSettingDBCAu(); break;
		//case 5:break;
		//if(TV.readS(TVDefine.CICard)) Utils.intentHandler(DEFS.Package_TCL_TV, DEFS.Activity_TCL_CICard) ;break;
		case 5:MainMenu.mSubMenu=new ParamSettingOverscan();break;
		//Utils.intentHandler(DEFS.Package_Android_Setting, DEFS.Activity_Android_Setting_WIFI) ;break;
		case 6:Utils.intentHandler(DEFS.Package_Android_Setting);break;
		//case 8:Utils.intentHandler(DEFS.Package_TCL_FileExplorer, DEFS.Activity_TCL_FileExplorer );break;
		//case 10:MainMenu.mSubMenu=new ParamSettingADC(); break;
		case 8:MainMenu.mSubMenu = new ParamSettingLightSensor();break;
		}
	}
}
