package gunav2.keymon.com.mx;


import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.B4AClass;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.debug.*;

public class c_updateavailable extends B4AClass.ImplB4AClass implements BA.SubDelegator{
    private static java.util.HashMap<String, java.lang.reflect.Method> htSubs;
    private void innerInitialize(BA _ba) throws Exception {
        if (ba == null) {
            ba = new BA(_ba, this, htSubs, "gunav2.keymon.com.mx.c_updateavailable");
            if (htSubs == null) {
                ba.loadHtSubs(this.getClass());
                htSubs = ba.htSubs;
            }
            
        }
        if (BA.isShellModeRuntimeCheck(ba)) 
			   this.getClass().getMethod("_class_globals", gunav2.keymon.com.mx.c_updateavailable.class).invoke(this, new Object[] {null});
        else
            ba.raiseEvent2(null, true, "class_globals", false);
    }

 public anywheresoftware.b4a.keywords.Common __c = null;
public anywheresoftware.b4a.objects.B4XViewWrapper _root = null;
public anywheresoftware.b4a.objects.B4XViewWrapper.XUI _xui = null;
public b4a.example.dateutils _dateutils = null;
public gunav2.keymon.com.mx.main _main = null;
public gunav2.keymon.com.mx.starter _starter = null;
public gunav2.keymon.com.mx.subs _subs = null;
public gunav2.keymon.com.mx.mapa_rutas _mapa_rutas = null;
public gunav2.keymon.com.mx.appupdater _appupdater = null;
public gunav2.keymon.com.mx.firebasemessaging _firebasemessaging = null;
public gunav2.keymon.com.mx.tracker _tracker = null;
public gunav2.keymon.com.mx.newinst2 _newinst2 = null;
public gunav2.keymon.com.mx.b4xpages _b4xpages = null;
public gunav2.keymon.com.mx.b4xcollections _b4xcollections = null;
public gunav2.keymon.com.mx.httputils2service _httputils2service = null;
public gunav2.keymon.com.mx.xuiviewsutils _xuiviewsutils = null;
public void  _b4xpage_appear() throws Exception{
ResumableSub_B4XPage_Appear rsub = new ResumableSub_B4XPage_Appear(this);
rsub.resume(ba, null);
}
public static class ResumableSub_B4XPage_Appear extends BA.ResumableSub {
public ResumableSub_B4XPage_Appear(gunav2.keymon.com.mx.c_updateavailable parent) {
this.parent = parent;
}
gunav2.keymon.com.mx.c_updateavailable parent;
int _result = 0;
anywheresoftware.b4a.objects.IntentWrapper _in = null;

@Override
public void resume(BA ba, Object[] result) throws Exception{

    while (true) {
try {

        switch (state) {
            case -1:
return;

case 0:
//C
this.state = 1;
 //BA.debugLineNum = 19;BA.debugLine="Try";
if (true) break;

case 1:
//try
this.state = 10;
this.catchState = 9;
this.state = 3;
if (true) break;

case 3:
//C
this.state = 4;
this.catchState = 9;
 //BA.debugLineNum = 20;BA.debugLine="Do While Not(CanRequestPackageInstalls)";
if (true) break;

case 4:
//do while
this.state = 7;
while (parent.__c.Not(parent._canrequestpackageinstalls())) {
this.state = 6;
if (true) break;
}
if (true) break;

case 6:
//C
this.state = 4;
 //BA.debugLineNum = 21;BA.debugLine="MsgboxAsync($\"Por favor permita que ${Applicati";
parent.__c.MsgboxAsync(BA.ObjectToCharSequence(("Por favor permita que "+parent.__c.SmartStringFormatter("",(Object)(parent.__c.Application.getPackageName()))+" instale actualizaciones")),BA.ObjectToCharSequence("Instalar actualización"),ba);
 //BA.debugLineNum = 22;BA.debugLine="Wait For Msgbox_Result(Result As Int)";
parent.__c.WaitFor("msgbox_result", ba, this, null);
this.state = 16;
return;
case 16:
//C
this.state = 4;
_result = (Integer) result[0];
;
 //BA.debugLineNum = 23;BA.debugLine="Dim in As Intent";
_in = new anywheresoftware.b4a.objects.IntentWrapper();
 //BA.debugLineNum = 24;BA.debugLine="in.Initialize(\"android.settings.MANAGE_UNKNOWN_";
_in.Initialize("android.settings.MANAGE_UNKNOWN_APP_SOURCES","package:"+parent.__c.Application.getPackageName());
 //BA.debugLineNum = 25;BA.debugLine="StartActivity(in)";
parent.__c.StartActivity(ba,(Object)(_in.getObject()));
 if (true) break;

case 7:
//C
this.state = 10;
;
 if (true) break;

case 9:
//C
this.state = 10;
this.catchState = 0;
 //BA.debugLineNum = 28;BA.debugLine="Log(\"updateAvailable() Error - \" & LastException";
parent.__c.LogImpl("444630026","updateAvailable() Error - "+parent.__c.LastException(ba).getMessage(),0);
 if (true) break;
if (true) break;
;
 //BA.debugLineNum = 30;BA.debugLine="If appUpdater.newApp.update Then";

case 10:
//if
this.state = 15;
this.catchState = 0;
if (parent._appupdater._newapp /*gunav2.keymon.com.mx.appupdater._mnewversion*/ .update /*boolean*/ ) { 
this.state = 12;
}else {
this.state = 14;
}if (true) break;

case 12:
//C
this.state = 15;
 //BA.debugLineNum = 31;BA.debugLine="ofreceActualizacion";
parent._ofreceactualizacion();
 if (true) break;

case 14:
//C
this.state = 15;
 //BA.debugLineNum = 33;BA.debugLine="sinActualizacion";
parent._sinactualizacion();
 if (true) break;

case 15:
//C
this.state = -1;
;
 //BA.debugLineNum = 35;BA.debugLine="End Sub";
if (true) break;
}} 
       catch (Exception e0) {
			
if (catchState == 0)
    throw e0;
else {
    state = catchState;
ba.setLastException(e0);}
            }
        }
    }
}
public void  _msgbox_result(int _result) throws Exception{
}
public String  _b4xpage_created(anywheresoftware.b4a.objects.B4XViewWrapper _root1) throws Exception{
 //BA.debugLineNum = 12;BA.debugLine="Private Sub B4XPage_Created (Root1 As B4XView)";
 //BA.debugLineNum = 13;BA.debugLine="Root = Root1";
_root = _root1;
 //BA.debugLineNum = 15;BA.debugLine="Root.Color = Colors.Transparent";
_root.setColor(__c.Colors.Transparent);
 //BA.debugLineNum = 16;BA.debugLine="End Sub";
return "";
}
public boolean  _canrequestpackageinstalls() throws Exception{
anywheresoftware.b4j.object.JavaObject _ctxt = null;
anywheresoftware.b4j.object.JavaObject _packagemanager = null;
 //BA.debugLineNum = 42;BA.debugLine="public Sub CanRequestPackageInstalls As Boolean";
 //BA.debugLineNum = 44;BA.debugLine="Dim ctxt As JavaObject";
_ctxt = new anywheresoftware.b4j.object.JavaObject();
 //BA.debugLineNum = 45;BA.debugLine="ctxt.InitializeContext";
_ctxt.InitializeContext(ba);
 //BA.debugLineNum = 46;BA.debugLine="Dim PackageManager As JavaObject = ctxt.RunMethod";
_packagemanager = new anywheresoftware.b4j.object.JavaObject();
_packagemanager = (anywheresoftware.b4j.object.JavaObject) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4j.object.JavaObject(), (java.lang.Object)(_ctxt.RunMethod("getPackageManager",(Object[])(__c.Null))));
 //BA.debugLineNum = 47;BA.debugLine="Return PackageManager.RunMethod(\"canRequestPackag";
if (true) return BA.ObjectToBoolean(_packagemanager.RunMethod("canRequestPackageInstalls",(Object[])(__c.Null)));
 //BA.debugLineNum = 48;BA.debugLine="End Sub";
return false;
}
public String  _class_globals() throws Exception{
 //BA.debugLineNum = 1;BA.debugLine="Sub Class_Globals";
 //BA.debugLineNum = 2;BA.debugLine="Private Root As B4XView 'ignore";
_root = new anywheresoftware.b4a.objects.B4XViewWrapper();
 //BA.debugLineNum = 3;BA.debugLine="Private xui As XUI 'ignore";
_xui = new anywheresoftware.b4a.objects.B4XViewWrapper.XUI();
 //BA.debugLineNum = 4;BA.debugLine="End Sub";
return "";
}
public Object  _initialize(anywheresoftware.b4a.BA _ba) throws Exception{
innerInitialize(_ba);
 //BA.debugLineNum = 7;BA.debugLine="Public Sub Initialize As Object";
 //BA.debugLineNum = 8;BA.debugLine="Return Me";
if (true) return this;
 //BA.debugLineNum = 9;BA.debugLine="End Sub";
return null;
}
public String  _ofreceactualizacion() throws Exception{
 //BA.debugLineNum = 50;BA.debugLine="Sub ofreceActualizacion";
 //BA.debugLineNum = 51;BA.debugLine="If Msgbox2(appUpdater.newApp.newMsg,\"Actualizació";
if (__c.Msgbox2(BA.ObjectToCharSequence(_appupdater._newapp /*gunav2.keymon.com.mx.appupdater._mnewversion*/ .newMsg /*String*/ ),BA.ObjectToCharSequence("Actualización disponible"),"Si","","No",(android.graphics.Bitmap)(__c.Null),ba)==__c.DialogResponse.POSITIVE) { 
 //BA.debugLineNum = 53;BA.debugLine="CallSubDelayed(appUpdater, \"download_newApk\")";
__c.CallSubDelayed(ba,(Object)(_appupdater.getObject()),"download_newApk");
 };
 //BA.debugLineNum = 55;BA.debugLine="B4XPages.MainPage.ocultaProgreso";
_b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (ba)._ocultaprogreso /*String*/ ();
 //BA.debugLineNum = 57;BA.debugLine="StartActivity(Main)";
__c.StartActivity(ba,(Object)(_main.getObject()));
 //BA.debugLineNum = 61;BA.debugLine="End Sub";
return "";
}
public String  _sinactualizacion() throws Exception{
 //BA.debugLineNum = 63;BA.debugLine="Sub sinActualizacion";
 //BA.debugLineNum = 69;BA.debugLine="Msgbox(appUpdater.newApp.okMsg, \"Aplicación al c";
__c.Msgbox(BA.ObjectToCharSequence(_appupdater._newapp /*gunav2.keymon.com.mx.appupdater._mnewversion*/ .okMsg /*String*/ ),BA.ObjectToCharSequence("Aplicación al corriente"),ba);
 //BA.debugLineNum = 74;BA.debugLine="B4XPages.MainPage.ocultaProgreso";
_b4xpages._mainpage /*gunav2.keymon.com.mx.b4xmainpage*/ (ba)._ocultaprogreso /*String*/ ();
 //BA.debugLineNum = 78;BA.debugLine="B4XPages.ShowPage(\"login\")";
_b4xpages._showpage /*String*/ (ba,"login");
 //BA.debugLineNum = 79;BA.debugLine="End Sub";
return "";
}
public Object callSub(String sub, Object sender, Object[] args) throws Exception {
BA.senderHolder.set(sender);
if (BA.fastSubCompare(sub, "B4XPAGE_CREATED"))
	return _b4xpage_created((anywheresoftware.b4a.objects.B4XViewWrapper) args[0]);
return BA.SubDelegator.SubNotFound;
}
}
