package reparto_izca.keymon.lat;


import anywheresoftware.b4a.B4AMenuItem;
import android.app.Activity;
import android.os.Bundle;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BALayout;
import anywheresoftware.b4a.B4AActivity;
import anywheresoftware.b4a.ObjectWrapper;
import anywheresoftware.b4a.objects.ActivityWrapper;
import java.lang.reflect.InvocationTargetException;
import anywheresoftware.b4a.B4AUncaughtException;
import anywheresoftware.b4a.debug.*;
import java.lang.ref.WeakReference;

public class foto extends Activity implements B4AActivity{
	public static foto mostCurrent;
	static boolean afterFirstLayout;
	static boolean isFirst = true;
    private static boolean processGlobalsRun = false;
	BALayout layout;
	public static BA processBA;
	BA activityBA;
    ActivityWrapper _activity;
    java.util.ArrayList<B4AMenuItem> menuItems;
	public static final boolean fullScreen = false;
	public static final boolean includeTitle = true;
    public static WeakReference<Activity> previousOne;
    public static boolean dontPause;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        mostCurrent = this;
		if (processBA == null) {
			processBA = new anywheresoftware.b4a.ShellBA(this.getApplicationContext(), null, null, "reparto_izca.keymon.lat", "reparto_izca.keymon.lat.foto");
			processBA.loadHtSubs(this.getClass());
	        float deviceScale = getApplicationContext().getResources().getDisplayMetrics().density;
	        BALayout.setDeviceScale(deviceScale);
            
		}
		else if (previousOne != null) {
			Activity p = previousOne.get();
			if (p != null && p != this) {
                BA.LogInfo("Killing previous instance (foto).");
				p.finish();
			}
		}
        processBA.setActivityPaused(true);
        processBA.runHook("oncreate", this, null);
		if (!includeTitle) {
        	this.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
        }
        if (fullScreen) {
        	getWindow().setFlags(android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,   
        			android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }
		
        processBA.sharedProcessBA.activityBA = null;
		layout = new BALayout(this);
		setContentView(layout);
		afterFirstLayout = false;
        WaitForLayout wl = new WaitForLayout();
        if (anywheresoftware.b4a.objects.ServiceHelper.StarterHelper.startFromActivity(this, processBA, wl, false))
		    BA.handler.postDelayed(wl, 5);

	}
	static class WaitForLayout implements Runnable {
		public void run() {
			if (afterFirstLayout)
				return;
			if (mostCurrent == null)
				return;
            
			if (mostCurrent.layout.getWidth() == 0) {
				BA.handler.postDelayed(this, 5);
				return;
			}
			mostCurrent.layout.getLayoutParams().height = mostCurrent.layout.getHeight();
			mostCurrent.layout.getLayoutParams().width = mostCurrent.layout.getWidth();
			afterFirstLayout = true;
			mostCurrent.afterFirstLayout();
		}
	}
	private void afterFirstLayout() {
        if (this != mostCurrent)
			return;
		activityBA = new BA(this, layout, processBA, "reparto_izca.keymon.lat", "reparto_izca.keymon.lat.foto");
        
        processBA.sharedProcessBA.activityBA = new java.lang.ref.WeakReference<BA>(activityBA);
        anywheresoftware.b4a.objects.ViewWrapper.lastId = 0;
        _activity = new ActivityWrapper(activityBA, "activity");
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (BA.isShellModeRuntimeCheck(processBA)) {
			if (isFirst)
				processBA.raiseEvent2(null, true, "SHELL", false);
			processBA.raiseEvent2(null, true, "CREATE", true, "reparto_izca.keymon.lat.foto", processBA, activityBA, _activity, anywheresoftware.b4a.keywords.Common.Density, mostCurrent);
			_activity.reinitializeForShell(activityBA, "activity");
		}
        initializeProcessGlobals();		
        initializeGlobals();
        
        BA.LogInfo("** Activity (foto) Create " + (isFirst ? "(first time)" : "") + " **");
        processBA.raiseEvent2(null, true, "activity_create", false, isFirst);
		isFirst = false;
		if (this != mostCurrent)
			return;
        processBA.setActivityPaused(false);
        BA.LogInfo("** Activity (foto) Resume **");
        processBA.raiseEvent(null, "activity_resume");
        if (android.os.Build.VERSION.SDK_INT >= 11) {
			try {
				android.app.Activity.class.getMethod("invalidateOptionsMenu").invoke(this,(Object[]) null);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}
	public void addMenuItem(B4AMenuItem item) {
		if (menuItems == null)
			menuItems = new java.util.ArrayList<B4AMenuItem>();
		menuItems.add(item);
	}
	@Override
	public boolean onCreateOptionsMenu(android.view.Menu menu) {
		super.onCreateOptionsMenu(menu);
        try {
            if (processBA.subExists("activity_actionbarhomeclick")) {
                Class.forName("android.app.ActionBar").getMethod("setHomeButtonEnabled", boolean.class).invoke(
                    getClass().getMethod("getActionBar").invoke(this), true);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (processBA.runHook("oncreateoptionsmenu", this, new Object[] {menu}))
            return true;
		if (menuItems == null)
			return false;
		for (B4AMenuItem bmi : menuItems) {
			android.view.MenuItem mi = menu.add(bmi.title);
			if (bmi.drawable != null)
				mi.setIcon(bmi.drawable);
            if (android.os.Build.VERSION.SDK_INT >= 11) {
				try {
                    if (bmi.addToBar) {
				        android.view.MenuItem.class.getMethod("setShowAsAction", int.class).invoke(mi, 1);
                    }
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			mi.setOnMenuItemClickListener(new B4AMenuItemsClickListener(bmi.eventName.toLowerCase(BA.cul)));
		}
        
		return true;
	}   
 @Override
 public boolean onOptionsItemSelected(android.view.MenuItem item) {
    if (item.getItemId() == 16908332) {
        processBA.raiseEvent(null, "activity_actionbarhomeclick");
        return true;
    }
    else
        return super.onOptionsItemSelected(item); 
}
@Override
 public boolean onPrepareOptionsMenu(android.view.Menu menu) {
    super.onPrepareOptionsMenu(menu);
    processBA.runHook("onprepareoptionsmenu", this, new Object[] {menu});
    return true;
    
 }
 protected void onStart() {
    super.onStart();
    processBA.runHook("onstart", this, null);
}
 protected void onStop() {
    super.onStop();
    processBA.runHook("onstop", this, null);
}
    public void onWindowFocusChanged(boolean hasFocus) {
       super.onWindowFocusChanged(hasFocus);
       if (processBA.subExists("activity_windowfocuschanged"))
           processBA.raiseEvent2(null, true, "activity_windowfocuschanged", false, hasFocus);
    }
	private class B4AMenuItemsClickListener implements android.view.MenuItem.OnMenuItemClickListener {
		private final String eventName;
		public B4AMenuItemsClickListener(String eventName) {
			this.eventName = eventName;
		}
		public boolean onMenuItemClick(android.view.MenuItem item) {
			processBA.raiseEventFromUI(item.getTitle(), eventName + "_click");
			return true;
		}
	}
    public static Class<?> getObject() {
		return foto.class;
	}
    private Boolean onKeySubExist = null;
    private Boolean onKeyUpSubExist = null;
	@Override
	public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
        if (processBA.runHook("onkeydown", this, new Object[] {keyCode, event}))
            return true;
		if (onKeySubExist == null)
			onKeySubExist = processBA.subExists("activity_keypress");
		if (onKeySubExist) {
			if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK &&
					android.os.Build.VERSION.SDK_INT >= 18) {
				HandleKeyDelayed hk = new HandleKeyDelayed();
				hk.kc = keyCode;
				BA.handler.post(hk);
				return true;
			}
			else {
				boolean res = new HandleKeyDelayed().runDirectly(keyCode);
				if (res)
					return true;
			}
		}
		return super.onKeyDown(keyCode, event);
	}
	private class HandleKeyDelayed implements Runnable {
		int kc;
		public void run() {
			runDirectly(kc);
		}
		public boolean runDirectly(int keyCode) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keypress", false, keyCode);
			if (res == null || res == true) {
                return true;
            }
            else if (keyCode == anywheresoftware.b4a.keywords.constants.KeyCodes.KEYCODE_BACK) {
				finish();
				return true;
			}
            return false;
		}
		
	}
    @Override
	public boolean onKeyUp(int keyCode, android.view.KeyEvent event) {
        if (processBA.runHook("onkeyup", this, new Object[] {keyCode, event}))
            return true;
		if (onKeyUpSubExist == null)
			onKeyUpSubExist = processBA.subExists("activity_keyup");
		if (onKeyUpSubExist) {
			Boolean res =  (Boolean)processBA.raiseEvent2(_activity, false, "activity_keyup", false, keyCode);
			if (res == null || res == true)
				return true;
		}
		return super.onKeyUp(keyCode, event);
	}
	@Override
	public void onNewIntent(android.content.Intent intent) {
        super.onNewIntent(intent);
		this.setIntent(intent);
        processBA.runHook("onnewintent", this, new Object[] {intent});
	}
    @Override 
	public void onPause() {
		super.onPause();
        if (_activity == null)
            return;
        if (this != mostCurrent)
			return;
		anywheresoftware.b4a.Msgbox.dismiss(true);
        if (!dontPause)
            BA.LogInfo("** Activity (foto) Pause, UserClosed = " + activityBA.activity.isFinishing() + " **");
        else
            BA.LogInfo("** Activity (foto) Pause event (activity is not paused). **");
        if (mostCurrent != null)
            processBA.raiseEvent2(_activity, true, "activity_pause", false, activityBA.activity.isFinishing());		
        if (!dontPause) {
            processBA.setActivityPaused(true);
            mostCurrent = null;
        }

        if (!activityBA.activity.isFinishing())
			previousOne = new WeakReference<Activity>(this);
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        processBA.runHook("onpause", this, null);
	}

	@Override
	public void onDestroy() {
        super.onDestroy();
		previousOne = null;
        processBA.runHook("ondestroy", this, null);
	}
    @Override 
	public void onResume() {
		super.onResume();
        mostCurrent = this;
        anywheresoftware.b4a.Msgbox.isDismissing = false;
        if (activityBA != null) { //will be null during activity create (which waits for AfterLayout).
        	ResumeMessage rm = new ResumeMessage(mostCurrent);
        	BA.handler.post(rm);
        }
        processBA.runHook("onresume", this, null);
	}
    private static class ResumeMessage implements Runnable {
    	private final WeakReference<Activity> activity;
    	public ResumeMessage(Activity activity) {
    		this.activity = new WeakReference<Activity>(activity);
    	}
		public void run() {
            foto mc = mostCurrent;
			if (mc == null || mc != activity.get())
				return;
			processBA.setActivityPaused(false);
            BA.LogInfo("** Activity (foto) Resume **");
            if (mc != mostCurrent)
                return;
		    processBA.raiseEvent(mc._activity, "activity_resume", (Object[])null);
		}
    }
	@Override
	protected void onActivityResult(int requestCode, int resultCode,
	      android.content.Intent data) {
		processBA.onActivityResult(requestCode, resultCode, data);
        processBA.runHook("onactivityresult", this, new Object[] {requestCode, resultCode});
	}
	private static void initializeGlobals() {
		processBA.raiseEvent2(null, true, "globals", false, (Object[])null);
	}
    public void onRequestPermissionsResult(int requestCode,
        String permissions[], int[] grantResults) {
        for (int i = 0;i < permissions.length;i++) {
            Object[] o = new Object[] {permissions[i], grantResults[i] == 0};
            processBA.raiseEventFromDifferentThread(null,null, 0, "activity_permissionresult", true, o);
        }
            
    }



public static void initializeProcessGlobals() {
             try {
                Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
}
public anywheresoftware.b4a.keywords.Common __c = null;
public static boolean _frontcamera = false;
public static anywheresoftware.b4a.gps.GPS _g = null;
public anywheresoftware.b4a.objects.PanelWrapper _p_camara = null;
public reparto_izca.keymon.lat.cameraexclass _camex = null;
public anywheresoftware.b4a.objects.ButtonWrapper _btntakepicture = null;
public anywheresoftware.b4a.sql.SQL.CursorWrapper _c = null;
public static String _cuenta = "";
public static String _lat_gps = "";
public static String _usuario = "";
public static String _motivo = "";
public b4a.example.dateutils _dateutils = null;
public reparto_izca.keymon.lat.main _main = null;
public reparto_izca.keymon.lat.appupdater _appupdater = null;
public reparto_izca.keymon.lat.subs _subs = null;
public reparto_izca.keymon.lat.mapa_cliente _mapa_cliente = null;
public reparto_izca.keymon.lat.mapa_rutas _mapa_rutas = null;
public reparto_izca.keymon.lat.starter _starter = null;
public reparto_izca.keymon.lat.tracker _tracker = null;
public reparto_izca.keymon.lat.newinst2 _newinst2 = null;
public reparto_izca.keymon.lat.b4xpages _b4xpages = null;
public reparto_izca.keymon.lat.b4xcollections _b4xcollections = null;
public reparto_izca.keymon.lat.httputils2service _httputils2service = null;
public reparto_izca.keymon.lat.xuiviewsutils _xuiviewsutils = null;
public static String  _activity_create(boolean _firsttime) throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_create", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "activity_create", new Object[] {_firsttime}));}
RDebugUtils.currentLine=69468160;
 //BA.debugLineNum = 69468160;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
RDebugUtils.currentLine=69468161;
 //BA.debugLineNum = 69468161;BA.debugLine="If(FirstTime) Then";
if ((_firsttime)) { 
RDebugUtils.currentLine=69468162;
 //BA.debugLineNum = 69468162;BA.debugLine="g.Initialize(\"GPS\")";
_g.Initialize("GPS");
 };
RDebugUtils.currentLine=69468164;
 //BA.debugLineNum = 69468164;BA.debugLine="Activity.LoadLayout(\"foto\")";
mostCurrent._activity.LoadLayout("foto",mostCurrent.activityBA);
RDebugUtils.currentLine=69468165;
 //BA.debugLineNum = 69468165;BA.debugLine="c=Starter.skmt.ExecQuery(\"select cuenta from cuen";
mostCurrent._c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("select cuenta from cuentaa")));
RDebugUtils.currentLine=69468166;
 //BA.debugLineNum = 69468166;BA.debugLine="c.Position = 0";
mostCurrent._c.setPosition((int) (0));
RDebugUtils.currentLine=69468167;
 //BA.debugLineNum = 69468167;BA.debugLine="cuenta = c.GetString(\"CUENTA\")";
mostCurrent._cuenta = mostCurrent._c.GetString("CUENTA");
RDebugUtils.currentLine=69468168;
 //BA.debugLineNum = 69468168;BA.debugLine="End Sub";
return "";
}
public static boolean  _activity_keypress(int _key) throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_keypress", false))
	 {return ((Boolean) Debug.delegate(mostCurrent.activityBA, "activity_keypress", new Object[] {_key}));}
RDebugUtils.currentLine=70320128;
 //BA.debugLineNum = 70320128;BA.debugLine="Sub Activity_KeyPress (key As Int) As Boolean";
RDebugUtils.currentLine=70320130;
 //BA.debugLineNum = 70320130;BA.debugLine="If key=KeyCodes.KEYCODE_BACK Then";
if (_key==anywheresoftware.b4a.keywords.Common.KeyCodes.KEYCODE_BACK) { 
RDebugUtils.currentLine=70320132;
 //BA.debugLineNum = 70320132;BA.debugLine="B4XPages.ShowPage(\"Principal\")";
mostCurrent._b4xpages._showpage /*String*/ (mostCurrent.activityBA,"Principal");
 };
RDebugUtils.currentLine=70320136;
 //BA.debugLineNum = 70320136;BA.debugLine="Return False";
if (true) return anywheresoftware.b4a.keywords.Common.False;
RDebugUtils.currentLine=70320137;
 //BA.debugLineNum = 70320137;BA.debugLine="End Sub";
return false;
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
RDebugUtils.currentModule="foto";
RDebugUtils.currentLine=69664768;
 //BA.debugLineNum = 69664768;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
RDebugUtils.currentLine=69664769;
 //BA.debugLineNum = 69664769;BA.debugLine="camEx.Release";
mostCurrent._camex._release /*String*/ (null);
RDebugUtils.currentLine=69664770;
 //BA.debugLineNum = 69664770;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "activity_resume", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "activity_resume", null));}
RDebugUtils.currentLine=69533696;
 //BA.debugLineNum = 69533696;BA.debugLine="Sub Activity_Resume";
RDebugUtils.currentLine=69533697;
 //BA.debugLineNum = 69533697;BA.debugLine="InitializeCamera";
_initializecamera();
RDebugUtils.currentLine=69533698;
 //BA.debugLineNum = 69533698;BA.debugLine="End Sub";
return "";
}
public static String  _initializecamera() throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "initializecamera", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "initializecamera", null));}
RDebugUtils.currentLine=69599232;
 //BA.debugLineNum = 69599232;BA.debugLine="Private Sub InitializeCamera";
RDebugUtils.currentLine=69599233;
 //BA.debugLineNum = 69599233;BA.debugLine="camEx.Initialize(p_camara, frontCamera, Me, \"Came";
mostCurrent._camex._initialize /*String*/ (null,mostCurrent.activityBA,mostCurrent._p_camara,_frontcamera,foto.getObject(),"Camera1");
RDebugUtils.currentLine=69599234;
 //BA.debugLineNum = 69599234;BA.debugLine="frontCamera = camEx.Front";
_frontcamera = mostCurrent._camex._front /*boolean*/ ;
RDebugUtils.currentLine=69599235;
 //BA.debugLineNum = 69599235;BA.debugLine="End Sub";
return "";
}
public static String  _btneffect_click() throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btneffect_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btneffect_click", null));}
anywheresoftware.b4a.objects.collections.List _effects = null;
String _effect = "";
RDebugUtils.currentLine=70123520;
 //BA.debugLineNum = 70123520;BA.debugLine="Sub btnEffect_Click";
RDebugUtils.currentLine=70123521;
 //BA.debugLineNum = 70123521;BA.debugLine="Dim effects As List = camEx.GetSupportedColorEffe";
_effects = new anywheresoftware.b4a.objects.collections.List();
_effects = mostCurrent._camex._getsupportedcoloreffects /*anywheresoftware.b4a.objects.collections.List*/ (null);
RDebugUtils.currentLine=70123522;
 //BA.debugLineNum = 70123522;BA.debugLine="If effects.IsInitialized = False Then";
if (_effects.IsInitialized()==anywheresoftware.b4a.keywords.Common.False) { 
RDebugUtils.currentLine=70123523;
 //BA.debugLineNum = 70123523;BA.debugLine="ToastMessageShow(\"Effects not supported.\", False";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Effects not supported."),anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=70123524;
 //BA.debugLineNum = 70123524;BA.debugLine="Return";
if (true) return "";
 };
RDebugUtils.currentLine=70123526;
 //BA.debugLineNum = 70123526;BA.debugLine="Dim effect As String = effects.Get((effects.Index";
_effect = BA.ObjectToString(_effects.Get((int) ((_effects.IndexOf((Object)(mostCurrent._camex._getcoloreffect /*String*/ (null)))+1)%_effects.getSize())));
RDebugUtils.currentLine=70123527;
 //BA.debugLineNum = 70123527;BA.debugLine="camEx.SetColorEffect(effect)";
mostCurrent._camex._setcoloreffect /*String*/ (null,_effect);
RDebugUtils.currentLine=70123528;
 //BA.debugLineNum = 70123528;BA.debugLine="ToastMessageShow(effect, False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence(_effect),anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=70123529;
 //BA.debugLineNum = 70123529;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ (null);
RDebugUtils.currentLine=70123530;
 //BA.debugLineNum = 70123530;BA.debugLine="End Sub";
return "";
}
public static String  _btnflash_click() throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btnflash_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btnflash_click", null));}
float[] _f = null;
anywheresoftware.b4a.objects.collections.List _flashmodes = null;
String _flash = "";
RDebugUtils.currentLine=70189056;
 //BA.debugLineNum = 70189056;BA.debugLine="Sub btnFlash_Click";
RDebugUtils.currentLine=70189057;
 //BA.debugLineNum = 70189057;BA.debugLine="Dim f() As Float = camEx.GetFocusDistances";
_f = mostCurrent._camex._getfocusdistances /*float[]*/ (null);
RDebugUtils.currentLine=70189058;
 //BA.debugLineNum = 70189058;BA.debugLine="Log(f(0) & \", \" & f(1) & \", \" & f(2))";
anywheresoftware.b4a.keywords.Common.LogImpl("870189058",BA.NumberToString(_f[(int) (0)])+", "+BA.NumberToString(_f[(int) (1)])+", "+BA.NumberToString(_f[(int) (2)]),0);
RDebugUtils.currentLine=70189059;
 //BA.debugLineNum = 70189059;BA.debugLine="Dim flashModes As List = camEx.GetSupportedFlashM";
_flashmodes = new anywheresoftware.b4a.objects.collections.List();
_flashmodes = mostCurrent._camex._getsupportedflashmodes /*anywheresoftware.b4a.objects.collections.List*/ (null);
RDebugUtils.currentLine=70189060;
 //BA.debugLineNum = 70189060;BA.debugLine="If flashModes.IsInitialized = False Then";
if (_flashmodes.IsInitialized()==anywheresoftware.b4a.keywords.Common.False) { 
RDebugUtils.currentLine=70189061;
 //BA.debugLineNum = 70189061;BA.debugLine="ToastMessageShow(\"Flash not supported.\", False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Flash not supported."),anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=70189062;
 //BA.debugLineNum = 70189062;BA.debugLine="Return";
if (true) return "";
 };
RDebugUtils.currentLine=70189064;
 //BA.debugLineNum = 70189064;BA.debugLine="Dim flash As String = flashModes.Get((flashModes.";
_flash = BA.ObjectToString(_flashmodes.Get((int) ((_flashmodes.IndexOf((Object)(mostCurrent._camex._getflashmode /*String*/ (null)))+1)%_flashmodes.getSize())));
RDebugUtils.currentLine=70189065;
 //BA.debugLineNum = 70189065;BA.debugLine="camEx.SetFlashMode(flash)";
mostCurrent._camex._setflashmode /*String*/ (null,_flash);
RDebugUtils.currentLine=70189066;
 //BA.debugLineNum = 70189066;BA.debugLine="ToastMessageShow(flash, False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence(_flash),anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=70189067;
 //BA.debugLineNum = 70189067;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ (null);
RDebugUtils.currentLine=70189068;
 //BA.debugLineNum = 70189068;BA.debugLine="End Sub";
return "";
}
public static String  _btnfocus_click() throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btnfocus_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btnfocus_click", null));}
RDebugUtils.currentLine=69926912;
 //BA.debugLineNum = 69926912;BA.debugLine="Sub btnFocus_Click";
RDebugUtils.currentLine=69926913;
 //BA.debugLineNum = 69926913;BA.debugLine="camEx.FocusAndTakePicture";
mostCurrent._camex._focusandtakepicture /*String*/ (null);
RDebugUtils.currentLine=69926914;
 //BA.debugLineNum = 69926914;BA.debugLine="End Sub";
return "";
}
public static String  _btnpicturesize_click() throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btnpicturesize_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btnpicturesize_click", null));}
reparto_izca.keymon.lat.cameraexclass._camerasize[] _picturesizes = null;
reparto_izca.keymon.lat.cameraexclass._camerasize _current = null;
int _i = 0;
reparto_izca.keymon.lat.cameraexclass._camerasize _ps = null;
RDebugUtils.currentLine=70254592;
 //BA.debugLineNum = 70254592;BA.debugLine="Sub btnPictureSize_Click";
RDebugUtils.currentLine=70254593;
 //BA.debugLineNum = 70254593;BA.debugLine="Dim pictureSizes() As CameraSize = camEx.GetSuppo";
_picturesizes = mostCurrent._camex._getsupportedpicturessizes /*reparto_izca.keymon.lat.cameraexclass._camerasize[]*/ (null);
RDebugUtils.currentLine=70254594;
 //BA.debugLineNum = 70254594;BA.debugLine="Dim current As CameraSize = camEx.GetPictureSize";
_current = mostCurrent._camex._getpicturesize /*reparto_izca.keymon.lat.cameraexclass._camerasize*/ (null);
RDebugUtils.currentLine=70254595;
 //BA.debugLineNum = 70254595;BA.debugLine="For i = 0 To pictureSizes.Length - 1";
{
final int step3 = 1;
final int limit3 = (int) (_picturesizes.length /*int*/ -1);
_i = (int) (0) ;
for (;_i <= limit3 ;_i = _i + step3 ) {
RDebugUtils.currentLine=70254596;
 //BA.debugLineNum = 70254596;BA.debugLine="If pictureSizes(i).Width = current.Width And pic";
if (_picturesizes[_i].Width /*int*/ ==_current.Width /*int*/  && _picturesizes[_i].Height /*int*/ ==_current.Height /*int*/ ) { 
if (true) break;};
 }
};
RDebugUtils.currentLine=70254598;
 //BA.debugLineNum = 70254598;BA.debugLine="Dim ps As CameraSize = pictureSizes((i + 1) Mod p";
_ps = _picturesizes[(int) ((_i+1)%_picturesizes.length /*int*/ )];
RDebugUtils.currentLine=70254599;
 //BA.debugLineNum = 70254599;BA.debugLine="camEx.SetPictureSize(ps.Width, ps.Height)";
mostCurrent._camex._setpicturesize /*String*/ (null,_ps.Width /*int*/ ,_ps.Height /*int*/ );
RDebugUtils.currentLine=70254600;
 //BA.debugLineNum = 70254600;BA.debugLine="ToastMessageShow(ps.Width & \"x\" & ps.Height & i,";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence(BA.NumberToString(_ps.Width /*int*/ )+"x"+BA.NumberToString(_ps.Height /*int*/ )+BA.NumberToString(_i)),anywheresoftware.b4a.keywords.Common.False);
RDebugUtils.currentLine=70254601;
 //BA.debugLineNum = 70254601;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ (null);
RDebugUtils.currentLine=70254602;
 //BA.debugLineNum = 70254602;BA.debugLine="End Sub";
return "";
}
public static String  _btntakepicture_click() throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "btntakepicture_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "btntakepicture_click", null));}
reparto_izca.keymon.lat.cameraexclass._camerasize _ps = null;
RDebugUtils.currentLine=69861376;
 //BA.debugLineNum = 69861376;BA.debugLine="Sub btnTakePicture_Click";
RDebugUtils.currentLine=69861377;
 //BA.debugLineNum = 69861377;BA.debugLine="Dim ps As CameraSize";
_ps = new reparto_izca.keymon.lat.cameraexclass._camerasize();
RDebugUtils.currentLine=69861378;
 //BA.debugLineNum = 69861378;BA.debugLine="ps.Width =640";
_ps.Width /*int*/  = (int) (640);
RDebugUtils.currentLine=69861379;
 //BA.debugLineNum = 69861379;BA.debugLine="ps.Height =480";
_ps.Height /*int*/  = (int) (480);
RDebugUtils.currentLine=69861380;
 //BA.debugLineNum = 69861380;BA.debugLine="camEx.SetPictureSize(ps.Width, ps.Height)";
mostCurrent._camex._setpicturesize /*String*/ (null,_ps.Width /*int*/ ,_ps.Height /*int*/ );
RDebugUtils.currentLine=69861382;
 //BA.debugLineNum = 69861382;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ (null);
RDebugUtils.currentLine=69861383;
 //BA.debugLineNum = 69861383;BA.debugLine="camEx.TakePicture";
mostCurrent._camex._takepicture /*String*/ (null);
RDebugUtils.currentLine=69861384;
 //BA.debugLineNum = 69861384;BA.debugLine="End Sub";
return "";
}
public static String  _camera1_picturetaken(byte[] _data) throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "camera1_picturetaken", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "camera1_picturetaken", new Object[] {_data}));}
String _filename = "";
String _dir = "";
String _sdate = "";
String _stime = "";
int _i = 0;
RDebugUtils.currentLine=69992448;
 //BA.debugLineNum = 69992448;BA.debugLine="Sub Camera1_PictureTaken (Data() As Byte)";
RDebugUtils.currentLine=69992449;
 //BA.debugLineNum = 69992449;BA.debugLine="Dim filename As String = \"1.jpg\"";
_filename = "1.jpg";
RDebugUtils.currentLine=69992450;
 //BA.debugLineNum = 69992450;BA.debugLine="Dim dir As String = File.DirInternal";
_dir = anywheresoftware.b4a.keywords.Common.File.getDirInternal();
RDebugUtils.currentLine=69992452;
 //BA.debugLineNum = 69992452;BA.debugLine="camEx.SavePictureToFile(Data, dir, filename)";
mostCurrent._camex._savepicturetofile /*String*/ (null,_data,_dir,_filename);
RDebugUtils.currentLine=69992453;
 //BA.debugLineNum = 69992453;BA.debugLine="camEx.StartPreview 'restart preview";
mostCurrent._camex._startpreview /*String*/ (null);
RDebugUtils.currentLine=69992457;
 //BA.debugLineNum = 69992457;BA.debugLine="Dim sDate,sTime As String";
_sdate = "";
_stime = "";
RDebugUtils.currentLine=69992460;
 //BA.debugLineNum = 69992460;BA.debugLine="DateTime.DateFormat = \"MM/dd/yyyy\"";
anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat("MM/dd/yyyy");
RDebugUtils.currentLine=69992461;
 //BA.debugLineNum = 69992461;BA.debugLine="sDate=DateTime.Date(DateTime.Now)";
_sdate = anywheresoftware.b4a.keywords.Common.DateTime.Date(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
RDebugUtils.currentLine=69992462;
 //BA.debugLineNum = 69992462;BA.debugLine="sTime=DateTime.Time(DateTime.Now)";
_stime = anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
RDebugUtils.currentLine=69992463;
 //BA.debugLineNum = 69992463;BA.debugLine="c=Starter.skmt.ExecQuery(\"select CUENTA from cuen";
mostCurrent._c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("select CUENTA from cuentaa")));
RDebugUtils.currentLine=69992464;
 //BA.debugLineNum = 69992464;BA.debugLine="c.Position = 0";
mostCurrent._c.setPosition((int) (0));
RDebugUtils.currentLine=69992465;
 //BA.debugLineNum = 69992465;BA.debugLine="cuenta = c.GetString(\"CUENTA\")";
mostCurrent._cuenta = mostCurrent._c.GetString("CUENTA");
RDebugUtils.currentLine=69992466;
 //BA.debugLineNum = 69992466;BA.debugLine="c=Starter.skmt.ExecQuery(\"select USUARIO from usu";
mostCurrent._c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("select USUARIO from usuarioa")));
RDebugUtils.currentLine=69992467;
 //BA.debugLineNum = 69992467;BA.debugLine="c.Position = 0";
mostCurrent._c.setPosition((int) (0));
RDebugUtils.currentLine=69992468;
 //BA.debugLineNum = 69992468;BA.debugLine="USUARIO = c.GetString(\"USUARIO\")";
mostCurrent._usuario = mostCurrent._c.GetString("USUARIO");
RDebugUtils.currentLine=69992469;
 //BA.debugLineNum = 69992469;BA.debugLine="c.Close";
mostCurrent._c.Close();
RDebugUtils.currentLine=69992470;
 //BA.debugLineNum = 69992470;BA.debugLine="Starter.skmt.ExecNonQuery(\"DELETE FROM NOVENTA WH";
mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery("DELETE FROM NOVENTA WHERE NV_CLIENTE IN (select cuenta from cuentaa)");
RDebugUtils.currentLine=69992472;
 //BA.debugLineNum = 69992472;BA.debugLine="c=Starter.skmt.ExecQuery(\"select HVD_CLIENTE,HVD_";
mostCurrent._c = (anywheresoftware.b4a.sql.SQL.CursorWrapper) anywheresoftware.b4a.AbsObjectWrapper.ConvertToWrapper(new anywheresoftware.b4a.sql.SQL.CursorWrapper(), (android.database.Cursor)(mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")));
RDebugUtils.currentLine=69992474;
 //BA.debugLineNum = 69992474;BA.debugLine="If c.RowCount>0 Then";
if (mostCurrent._c.getRowCount()>0) { 
RDebugUtils.currentLine=69992475;
 //BA.debugLineNum = 69992475;BA.debugLine="For i=0 To c.RowCount -1";
{
final int step19 = 1;
final int limit19 = (int) (mostCurrent._c.getRowCount()-1);
_i = (int) (0) ;
for (;_i <= limit19 ;_i = _i + step19 ) {
RDebugUtils.currentLine=69992476;
 //BA.debugLineNum = 69992476;BA.debugLine="c.Position=i";
mostCurrent._c.setPosition(_i);
RDebugUtils.currentLine=69992477;
 //BA.debugLineNum = 69992477;BA.debugLine="Starter.skmt.ExecNonQuery2(\"insert into reparto";
mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("insert into reparto(REP_CLIENTE, REP_PRONOMBRE, REP_CANT, REP_COSTO_TOT)  select  HVD_CLIENTE, HVD_PRONOMBRE, HVD_CANT, HVD_COSTO_TOT from hist_ventas where HVD_PRONOMBRE = ? and HVD_cliente in (Select CUENTA from cuentaa) ",anywheresoftware.b4a.keywords.Common.ArrayToList(new String[]{mostCurrent._c.GetString("HVD_PRONOMBRE")}));
RDebugUtils.currentLine=69992479;
 //BA.debugLineNum = 69992479;BA.debugLine="Starter.skmt.ExecNonQuery2(\"update cat_gunaprod";
mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_nombre = ?",anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(mostCurrent._c.GetString("HVD_CANT")),(Object)(mostCurrent._c.GetString("HVD_PRONOMBRE"))}));
 }
};
 };
RDebugUtils.currentLine=69992490;
 //BA.debugLineNum = 69992490;BA.debugLine="Starter.skmt.ExecNonQuery2(\"INSERT INTO  NOVENTA";
mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery2("INSERT INTO  NOVENTA (NV_CLIENTE,NV_FECHA,NV_USER,NV_MOTIVO,NV_COMM,NV_LAT,NV_LON, NV_FOTO) VALUES(?,?,?,?,?,?,?,?) ",anywheresoftware.b4a.keywords.Common.ArrayToList(new Object[]{(Object)(mostCurrent._cuenta),(Object)(_sdate+_stime),(Object)(mostCurrent._usuario),(Object)("CERRADO"),(Object)(mostCurrent._b4xpages._mainpage /*reparto_izca.keymon.lat.b4xmainpage*/ (mostCurrent.activityBA)._noventa /*reparto_izca.keymon.lat.c_noventa*/ ._comentario /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_izca.keymon.lat.b4xmainpage*/ (mostCurrent.activityBA)._lat_gps /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_izca.keymon.lat.b4xmainpage*/ (mostCurrent.activityBA)._lon_gps /*String*/ ),(Object)(_data)}));
RDebugUtils.currentLine=69992491;
 //BA.debugLineNum = 69992491;BA.debugLine="Starter.skmt.ExecNonQuery($\"UPDATE kmt_info set g";
mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery(("UPDATE kmt_info set gestion = 3, HORAENT = '"+anywheresoftware.b4a.keywords.Common.SmartStringFormatter("",(Object)(_sdate+" "+_stime))+"' where CAT_CL_CODIGO In (select cuenta from cuentaa)"));
RDebugUtils.currentLine=69992492;
 //BA.debugLineNum = 69992492;BA.debugLine="Starter.skmt.ExecNonQuery(\"update HIST_VENTAS SET";
mostCurrent._starter._skmt /*anywheresoftware.b4a.sql.SQL*/ .ExecNonQuery("update HIST_VENTAS SET HVD_RECHAZO = 1 WHERE HVD_CLIENTE IN (SELECT CUENTA FROM CUENTAA)");
RDebugUtils.currentLine=69992493;
 //BA.debugLineNum = 69992493;BA.debugLine="B4XPages.ShowPage(\"Principal\")";
mostCurrent._b4xpages._showpage /*String*/ (mostCurrent.activityBA,"Principal");
RDebugUtils.currentLine=69992496;
 //BA.debugLineNum = 69992496;BA.debugLine="End Sub";
return "";
}
public static String  _camera1_ready(boolean _success) throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "camera1_ready", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "camera1_ready", new Object[] {_success}));}
RDebugUtils.currentLine=69795840;
 //BA.debugLineNum = 69795840;BA.debugLine="Sub Camera1_Ready (Success As Boolean)";
RDebugUtils.currentLine=69795841;
 //BA.debugLineNum = 69795841;BA.debugLine="If Success Then";
if (_success) { 
RDebugUtils.currentLine=69795842;
 //BA.debugLineNum = 69795842;BA.debugLine="camEx.SetJpegQuality(90)";
mostCurrent._camex._setjpegquality /*String*/ (null,(int) (90));
RDebugUtils.currentLine=69795843;
 //BA.debugLineNum = 69795843;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ (null);
RDebugUtils.currentLine=69795844;
 //BA.debugLineNum = 69795844;BA.debugLine="camEx.StartPreview";
mostCurrent._camex._startpreview /*String*/ (null);
RDebugUtils.currentLine=69795845;
 //BA.debugLineNum = 69795845;BA.debugLine="Log(camEx.GetPreviewSize)";
anywheresoftware.b4a.keywords.Common.LogImpl("869795845",BA.ObjectToString(mostCurrent._camex._getpreviewsize /*reparto_izca.keymon.lat.cameraexclass._camerasize*/ (null)),0);
 }else {
RDebugUtils.currentLine=69795847;
 //BA.debugLineNum = 69795847;BA.debugLine="ToastMessageShow(\"Cannot open camera.\", True)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Cannot open camera."),anywheresoftware.b4a.keywords.Common.True);
 };
RDebugUtils.currentLine=69795849;
 //BA.debugLineNum = 69795849;BA.debugLine="End Sub";
return "";
}
public static String  _changecamera_click() throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "changecamera_click", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "changecamera_click", null));}
RDebugUtils.currentLine=70057984;
 //BA.debugLineNum = 70057984;BA.debugLine="Sub ChangeCamera_Click";
RDebugUtils.currentLine=70057985;
 //BA.debugLineNum = 70057985;BA.debugLine="camEx.Release";
mostCurrent._camex._release /*String*/ (null);
RDebugUtils.currentLine=70057986;
 //BA.debugLineNum = 70057986;BA.debugLine="frontCamera = Not(frontCamera)";
_frontcamera = anywheresoftware.b4a.keywords.Common.Not(_frontcamera);
RDebugUtils.currentLine=70057987;
 //BA.debugLineNum = 70057987;BA.debugLine="InitializeCamera";
_initializecamera();
RDebugUtils.currentLine=70057988;
 //BA.debugLineNum = 70057988;BA.debugLine="End Sub";
return "";
}
public static String  _gps_locationchanged(anywheresoftware.b4a.gps.LocationWrapper _location1) throws Exception{
RDebugUtils.currentModule="foto";
if (Debug.shouldDelegate(mostCurrent.activityBA, "gps_locationchanged", false))
	 {return ((String) Debug.delegate(mostCurrent.activityBA, "gps_locationchanged", new Object[] {_location1}));}
RDebugUtils.currentLine=69730304;
 //BA.debugLineNum = 69730304;BA.debugLine="Sub GPS_LocationChanged (Location1 As Location)";
RDebugUtils.currentLine=69730309;
 //BA.debugLineNum = 69730309;BA.debugLine="End Sub";
return "";
}
}