
var SETUPUSR_LAUNCH_FOCUS_ICON=1;
var SETUPUSR_LAUNCH_FOCUS_NAME=2;
var SETUPUSR_LAUNCH_FOCUS_VOICE=3;
var SETUPUSR_LAUNCH_FOCUS_FACE=4;
var SETUPUSR_LAUNCH_FOCUS_HS=5;
var SETUPUSR_LAUNCH_FOCUS_MHC=6;
function my_switch_op(){}
my_switch_op.prototype=HOME.switchscreen_op;
var return_lock=function(){
return startup_selection.return_lock.apply(this,arguments);};
var exec_lock=function(){
return startup_selection.exec_lock.apply(this,arguments);};
function voice_control(){
this.superClass=my_switch_op;
this.superClass({});
this.cursor=null;}
voice_control.prototype=new my_switch_op();
voice_control.prototype.toString=function(){
return "[voice_control]";}
voice_control.prototype.key_hook=function (up_down,key){
if(startup_selection.is_return_lock==true)return true;

if(up_down==KEY_PRESS){
switch(key){
case TXK_ENTER:
if(this.is_move)
return false;
var me=this;
var enabled=me._filter_func(me._active_screen[1]);
if(!enabled)return;
exec_lock(true);
var current_key=this.getCurrentScreenKey();
this.jumpScreen(current_key,function(){
exec_lock(false);
var enabled=me._filter_func(me._active_screen[1]);
if(!enabled)return;
me.top_menu.selectScreen();
me._voice_control();
HOME.HomeSoundPlay("enter");
me.updateUsrprof();
me.cursor=null;
if(!me._back_previous())
me.switchUI(me,HOME.MY_SCREEN);});
return true;
case TXK_RETURN:
if(!this._back_previous())
this._back_hs();
return true;
case TXK_HOME:
case TXK_EXIT:
this._back_hs();
return true;
case TXK_RIGHT:
case TXK_LEFT:
break;
default:
return false;}
}
if(this.cursor!=null)
this.cursor=my_top_menu;
if(key==TXK_LEFT||key==TXK_RIGHT){
return this.__proto__.__proto__.key_hook.apply(this,arguments);}
return false;};
voice_control.prototype._back_previous=function(){
var launch_from=this.getLaunchFrom();
switch(launch_from){
case "setupuser":
var usrprof_id=this.getUsrprofID();
var arg="-U %s -f %s".replace("%s",usrprof_id).replace("%s",SETUPUSR_LAUNCH_FOCUS_HS);
apputil.launch_apl(SETUPUSER_APPS,arg);
return true;
default:
break;}
return false;};
voice_control.prototype.usrprof_id=null;
voice_control.prototype.setUsrprofID=function(usrprof_id){
if(!isNumber(usrprof_id)){
this._usrprof_id=null;
this.top_menu.userIcon.src="";
return;}
this._usrprof_id=usrprof_id;
var uprofile=getProfile(usrprof_id);
if(uprofile){
this.top_menu.userIcon.src=uprofile.mhc.icon;}
};
voice_control.prototype.getUsrprofID=function(){
return this._usrprof_id;};
voice_control.prototype.setLaunchFrom=function(from){
this._launch_from=from;};
voice_control.prototype.getLaunchFrom=function(){
return this._launch_from;};
voice_control.prototype.init=function(){
var me=this;
this.top_menu=my_top_menu;
this.top_menu.left_menu=startup_selection.left_menu;
this.top_menu.left_menu.indicator=startup_selection.indicator;
this.top_menu.left_menu.template_menu=startup_selection.template_menu;
this.screen_base=startup_selection.screen_base;
this.top_menu.left_menu.screen_base=this.screen_base;

this.top_menu.init();
this.cursor=this.top_menu;
this.components=[this.focus];
this.components.unshift(this.screen_base);
this.components.unshift(this.top_menu);}
voice_control.prototype.in_hook=function (enable_screen,func){
this.cursor=this.top_menu;
this.setLaunchFrom(null);
var filter_func=function (screen,menu){
if(screen instanceof Screen){
if(screen.getTemplateName()=="inst")
return false;
return screen.canSetOwner();}
return false;}
this._filter_func=filter_func;
var args=[enable_screen,func,this._filter_func];
return this.__proto__.__proto__.in_hook.apply(this,args);}
voice_control.prototype._voice_control=function (){
var usrprof_id=this.getUsrprofID();
var current_key=this.getCurrentScreenKey();
var info=HOME.getScreenInfo(current_key);
if(isNumber(usrprof_id)){
info.usrprof_id=usrprof_id;}else {
info.usrprof_id=null;}
var ret=HOME.storeScreenInfo(info,current_key);
if(ret){
HOME.storeVoiceControlScreen(usrprof_id,current_key);}
};
var my_top_menu=new container({});
my_top_menu.extend=function(){
if(startup_selection.top_menu){
for(var name in startup_selection.top_menu)
my_top_menu[name]=startup_selection.top_menu[name];}
}();
my_top_menu.init=function(){
this.userIcon=new gimage({translate:[-1920/2+664/2-200,1080/2-54/2-26-2,0],
width:90,height:90});
this.screen_title=new gtextbox({translate:[80,1080/2-54/2-26,0],
align:CENTER,valign:MIDDLE,
width:1600,height:100,color:COL_TEXT_ONBASE,
font_size:50,});

this.border=new gbox({translate:[0,1080/2-62+2-46,0],
width:1920,height:2,color:COL_BORDER_ONBASE});
this.components=[
this.userIcon,
this.screen_title,
this.left_menu,
this.border,
];
this.menu=[];
this.cursor=null;}
my_top_menu.in_hook=function(){
this.cursor=this.left_menu;
var msg=(LANG("LT_HOME_JUMP_SCREEN")||"Please select a Home Screen which is called automatically when you say '%s'.");
var voicecmd_my_home="";
try{
voicecmd_my_home=system.voice_control.voicecmd_my_home||"";}catch(e){}
msg=msg.replace("%s",voicecmd_my_home);
setf_text(this.screen_title,msg);
change_font_size_b(this.screen_title);
this.userIcon.src="";
return startup_selection.top_menu.in_hook.apply(this,arguments);};
my_top_menu.out_hook=function(){
setf_text(this.screen_title,"");
this.userIcon.src="";
return startup_selection.top_menu.out_hook.apply(this,arguments);};
my_top_menu.key_hook=function(up_down,key){
if(this.cursor!=null)
this.cursor=this.left_menu;
if(this.cursor&&this.cursor.key_hook)
if(this.cursor.key_hook(up_down,key))
return true;

if(up_down!=KEY_PRESS)
return false;
return false;};

