package com.tcl.factory.view;


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.Debug;

public class ParamSettingSoundCurve extends SubMenu{
	private int sourcetype=0;
	private int curvetype=6;
	
	
public static  String MenuInfos_ParamSettingSoundCurve[][]={
	{"Source",""},
	{"Curve_0",""},
	{"Curve_1",""},
	{"Curve_10",""},
	{"Curve_25",""},
	{"Curve_50",""},
	{"Curve_75",""},
	{"Curve_100",""},
};

 	public ParamSettingSoundCurve()
	{
		super.menuInfos=MenuInfos_ParamSettingSoundCurve;
		super.menuLabel = "Main\\Param Setting\\SNDCURVE";
		super.setTAG();
		updateMenuInfos();	
	}
 	

	
 	
	public void KeyEvent(int keyCode,int pos){
		super.enterSubMenu(pos);
		switch(keyCode)
		{
		case KeyEvent.KEYCODE_DPAD_LEFT:
		case KeyEvent.KEYCODE_DPAD_RIGHT:
		{		
			switch(pos)
			{
				case 0: changeNextInputSource(keyCode);break;
				case 1: super.ValueHandler(TVDefine.Curve, keyCode, curvetype, 0);break;
				case 2: super.ValueHandler(TVDefine.Curve, keyCode, curvetype, 1);break;
				case 3: super.ValueHandler(TVDefine.Curve, keyCode, curvetype, 2);break;
				case 4: super.ValueHandler(TVDefine.Curve, keyCode, curvetype, 3);break;
				case 5: super.ValueHandler(TVDefine.Curve, keyCode, curvetype, 4);break;
				case 6: super.ValueHandler(TVDefine.Curve, keyCode, curvetype, 5);break;
				case 7: super.ValueHandler(TVDefine.Curve, keyCode, curvetype, 6);break;
			}		
			ThirdParty.updateVolume();
		}
		break;
		default:
			break;
		}
	}
	 
	/* (non-Javadoc)
	 * Factory
	 */
	@Override
	public void updateMenuInfos() {
		updateCurrentInputSource();
		super.updateValueInfo(TVDefine.Curve,curvetype,0, 1);
		super.updateValueInfo(TVDefine.Curve,curvetype,1, 2);
		super.updateValueInfo(TVDefine.Curve,curvetype,2, 3);
		super.updateValueInfo(TVDefine.Curve,curvetype,3, 4);
		super.updateValueInfo(TVDefine.Curve,curvetype,4, 5);
		super.updateValueInfo(TVDefine.Curve,curvetype,5, 6);
		super.updateValueInfo(TVDefine.Curve,curvetype,6, 7);
	}
	

	
	

	public void  updateCurrentInputSource(){
		
		menuInfos[0][1]=TV.getSourceType();
		String str=menuInfos[0][1];
		Debug.v("updateCurrentInputSource--------", str);
		if(str.equals("ATV")){
			sourcetype=0;
		}
		else if(str.equals("AV")){
			sourcetype=1;
		}
		else if(str.equals("YPBPR")){
			sourcetype=2;
		}
		else if(str.equals("VGA")){
			sourcetype=3;
		}
		else if(str.equals("HDMI")){
			sourcetype=4;
		}
		else if(str.equals("DTV")){
			sourcetype=5;
		}
		else if(str.equals("USB-STORAGE")){
			sourcetype=6;
		}
		else if(str.equals("KTV")){
			sourcetype=7;
		}
		Debug.v("updateCurrentInputSource--------", str);
	}


	void changeNextInputSource(int keyCode){		

		if(keyCode==KeyEvent.KEYCODE_DPAD_RIGHT){
			sourcetype++;
			if(sourcetype>7)
				sourcetype=0;
		}
		else{
			sourcetype--;
			if(sourcetype<0)
				sourcetype=7;
		}
		switch(sourcetype){
		case 0:TV.setSource(DEFS.SOURCE_ATV, 1);break;
		case 1:TV.setSource(DEFS.SOURCE_AV, 1);break;
		case 2:TV.setSource(DEFS.SOURCE_YPBPR, 1);break;
		case 3:TV.setSource(DEFS.SOURCE_VGA, 1);break;
		case 4:TV.setSource(DEFS.SOURCE_HDMI, 1);break;
		case 5:TV.setSource(DEFS.SOURCE_DTV, 1);break;
		case 6:TV.setSource(DEFS.SOURCE_STORAGE, 1);break;
		case 7:TV.setSource(DEFS.SOURCE_KTV, 1);break;
		}
	}

	
	
}
