package reparto_intmex.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 BA(this.getApplicationContext(), null, null, "reparto_intmex.keymon.lat", "reparto_intmex.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_intmex.keymon.lat", "reparto_intmex.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_intmex.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 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_intmex.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_intmex.keymon.lat.main _main = null;
public reparto_intmex.keymon.lat.appupdater _appupdater = null;
public reparto_intmex.keymon.lat.starter _starter = null;
public reparto_intmex.keymon.lat.mapa_cliente _mapa_cliente = null;
public reparto_intmex.keymon.lat.mapa_rutas _mapa_rutas = null;
public reparto_intmex.keymon.lat.subs _subs = null;
public reparto_intmex.keymon.lat.tracker _tracker = null;
public reparto_intmex.keymon.lat.newinst2 _newinst2 = null;
public reparto_intmex.keymon.lat.b4xpages _b4xpages = null;
public reparto_intmex.keymon.lat.b4xcollections _b4xcollections = null;
public reparto_intmex.keymon.lat.httputils2service _httputils2service = null;
public reparto_intmex.keymon.lat.xuiviewsutils _xuiviewsutils = null;

public static void initializeProcessGlobals() {
             try {
                Class.forName(BA.applicationContext.getPackageName() + ".main").getMethod("initializeProcessGlobals").invoke(null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
}
public static String  _activity_create(boolean _firsttime) throws Exception{
 //BA.debugLineNum = 27;BA.debugLine="Sub Activity_Create(FirstTime As Boolean)";
 //BA.debugLineNum = 28;BA.debugLine="If(FirstTime) Then";
if ((_firsttime)) { 
 //BA.debugLineNum = 29;BA.debugLine="g.Initialize(\"GPS\")";
_g.Initialize("GPS");
 };
 //BA.debugLineNum = 31;BA.debugLine="Activity.LoadLayout(\"foto\")";
mostCurrent._activity.LoadLayout("foto",mostCurrent.activityBA);
 //BA.debugLineNum = 32;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")));
 //BA.debugLineNum = 33;BA.debugLine="c.Position = 0";
mostCurrent._c.setPosition((int) (0));
 //BA.debugLineNum = 34;BA.debugLine="cuenta = c.GetString(\"CUENTA\")";
mostCurrent._cuenta = mostCurrent._c.GetString("CUENTA");
 //BA.debugLineNum = 35;BA.debugLine="End Sub";
return "";
}
public static boolean  _activity_keypress(int _key) throws Exception{
 //BA.debugLineNum = 174;BA.debugLine="Sub Activity_KeyPress (key As Int) As Boolean";
 //BA.debugLineNum = 176;BA.debugLine="If key=KeyCodes.KEYCODE_BACK Then";
if (_key==anywheresoftware.b4a.keywords.Common.KeyCodes.KEYCODE_BACK) { 
 //BA.debugLineNum = 178;BA.debugLine="B4XPages.ShowPage(\"Principal\")";
mostCurrent._b4xpages._showpage /*String*/ (mostCurrent.activityBA,"Principal");
 };
 //BA.debugLineNum = 182;BA.debugLine="Return False";
if (true) return anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 183;BA.debugLine="End Sub";
return false;
}
public static String  _activity_pause(boolean _userclosed) throws Exception{
 //BA.debugLineNum = 46;BA.debugLine="Sub Activity_Pause (UserClosed As Boolean)";
 //BA.debugLineNum = 47;BA.debugLine="camEx.Release";
mostCurrent._camex._release /*String*/ ();
 //BA.debugLineNum = 48;BA.debugLine="End Sub";
return "";
}
public static String  _activity_resume() throws Exception{
 //BA.debugLineNum = 37;BA.debugLine="Sub Activity_Resume";
 //BA.debugLineNum = 38;BA.debugLine="InitializeCamera";
_initializecamera();
 //BA.debugLineNum = 39;BA.debugLine="End Sub";
return "";
}
public static String  _btneffect_click() throws Exception{
anywheresoftware.b4a.objects.collections.List _effects = null;
String _effect = "";
 //BA.debugLineNum = 138;BA.debugLine="Sub btnEffect_Click";
 //BA.debugLineNum = 139;BA.debugLine="Dim effects As List = camEx.GetSupportedColorEffe";
_effects = new anywheresoftware.b4a.objects.collections.List();
_effects = mostCurrent._camex._getsupportedcoloreffects /*anywheresoftware.b4a.objects.collections.List*/ ();
 //BA.debugLineNum = 140;BA.debugLine="If effects.IsInitialized = False Then";
if (_effects.IsInitialized()==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 141;BA.debugLine="ToastMessageShow(\"Effects not supported.\", False";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Effects not supported."),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 142;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 144;BA.debugLine="Dim effect As String = effects.Get((effects.Index";
_effect = BA.ObjectToString(_effects.Get((int) ((_effects.IndexOf((Object)(mostCurrent._camex._getcoloreffect /*String*/ ()))+1)%_effects.getSize())));
 //BA.debugLineNum = 145;BA.debugLine="camEx.SetColorEffect(effect)";
mostCurrent._camex._setcoloreffect /*String*/ (_effect);
 //BA.debugLineNum = 146;BA.debugLine="ToastMessageShow(effect, False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence(_effect),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 147;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ ();
 //BA.debugLineNum = 148;BA.debugLine="End Sub";
return "";
}
public static String  _btnflash_click() throws Exception{
float[] _f = null;
anywheresoftware.b4a.objects.collections.List _flashmodes = null;
String _flash = "";
 //BA.debugLineNum = 150;BA.debugLine="Sub btnFlash_Click";
 //BA.debugLineNum = 151;BA.debugLine="Dim f() As Float = camEx.GetFocusDistances";
_f = mostCurrent._camex._getfocusdistances /*float[]*/ ();
 //BA.debugLineNum = 152;BA.debugLine="Log(f(0) & \", \" & f(1) & \", \" & f(2))";
anywheresoftware.b4a.keywords.Common.LogImpl("864684034",BA.NumberToString(_f[(int) (0)])+", "+BA.NumberToString(_f[(int) (1)])+", "+BA.NumberToString(_f[(int) (2)]),0);
 //BA.debugLineNum = 153;BA.debugLine="Dim flashModes As List = camEx.GetSupportedFlashM";
_flashmodes = new anywheresoftware.b4a.objects.collections.List();
_flashmodes = mostCurrent._camex._getsupportedflashmodes /*anywheresoftware.b4a.objects.collections.List*/ ();
 //BA.debugLineNum = 154;BA.debugLine="If flashModes.IsInitialized = False Then";
if (_flashmodes.IsInitialized()==anywheresoftware.b4a.keywords.Common.False) { 
 //BA.debugLineNum = 155;BA.debugLine="ToastMessageShow(\"Flash not supported.\", False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Flash not supported."),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 156;BA.debugLine="Return";
if (true) return "";
 };
 //BA.debugLineNum = 158;BA.debugLine="Dim flash As String = flashModes.Get((flashModes.";
_flash = BA.ObjectToString(_flashmodes.Get((int) ((_flashmodes.IndexOf((Object)(mostCurrent._camex._getflashmode /*String*/ ()))+1)%_flashmodes.getSize())));
 //BA.debugLineNum = 159;BA.debugLine="camEx.SetFlashMode(flash)";
mostCurrent._camex._setflashmode /*String*/ (_flash);
 //BA.debugLineNum = 160;BA.debugLine="ToastMessageShow(flash, False)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence(_flash),anywheresoftware.b4a.keywords.Common.False);
 //BA.debugLineNum = 161;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ ();
 //BA.debugLineNum = 162;BA.debugLine="End Sub";
return "";
}
public static String  _btnfocus_click() throws Exception{
 //BA.debugLineNum = 78;BA.debugLine="Sub btnFocus_Click";
 //BA.debugLineNum = 79;BA.debugLine="camEx.FocusAndTakePicture";
mostCurrent._camex._focusandtakepicture /*String*/ ();
 //BA.debugLineNum = 80;BA.debugLine="End Sub";
return "";
}
public static String  _btnpicturesize_click() throws Exception{
reparto_intmex.keymon.lat.cameraexclass._camerasize[] _picturesizes = null;
reparto_intmex.keymon.lat.cameraexclass._camerasize _current = null;
int _i = 0;
reparto_intmex.keymon.lat.cameraexclass._camerasize _ps = null;
 //BA.debugLineNum = 163;BA.debugLine="Sub btnPictureSize_Click";
 //BA.debugLineNum = 164;BA.debugLine="Dim pictureSizes() As CameraSize = camEx.GetSuppo";
_picturesizes = mostCurrent._camex._getsupportedpicturessizes /*reparto_intmex.keymon.lat.cameraexclass._camerasize[]*/ ();
 //BA.debugLineNum = 165;BA.debugLine="Dim current As CameraSize = camEx.GetPictureSize";
_current = mostCurrent._camex._getpicturesize /*reparto_intmex.keymon.lat.cameraexclass._camerasize*/ ();
 //BA.debugLineNum = 166;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 ) {
 //BA.debugLineNum = 167;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;};
 }
};
 //BA.debugLineNum = 169;BA.debugLine="Dim ps As CameraSize = pictureSizes((i + 1) Mod p";
_ps = _picturesizes[(int) ((_i+1)%_picturesizes.length /*int*/ )];
 //BA.debugLineNum = 170;BA.debugLine="camEx.SetPictureSize(ps.Width, ps.Height)";
mostCurrent._camex._setpicturesize /*String*/ (_ps.Width /*int*/ ,_ps.Height /*int*/ );
 //BA.debugLineNum = 171;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);
 //BA.debugLineNum = 172;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ ();
 //BA.debugLineNum = 173;BA.debugLine="End Sub";
return "";
}
public static String  _btntakepicture_click() throws Exception{
reparto_intmex.keymon.lat.cameraexclass._camerasize _ps = null;
 //BA.debugLineNum = 68;BA.debugLine="Sub btnTakePicture_Click";
 //BA.debugLineNum = 69;BA.debugLine="Dim ps As CameraSize";
_ps = new reparto_intmex.keymon.lat.cameraexclass._camerasize();
 //BA.debugLineNum = 70;BA.debugLine="ps.Width =640";
_ps.Width /*int*/  = (int) (640);
 //BA.debugLineNum = 71;BA.debugLine="ps.Height =480";
_ps.Height /*int*/  = (int) (480);
 //BA.debugLineNum = 72;BA.debugLine="camEx.SetPictureSize(ps.Width, ps.Height)";
mostCurrent._camex._setpicturesize /*String*/ (_ps.Width /*int*/ ,_ps.Height /*int*/ );
 //BA.debugLineNum = 74;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ ();
 //BA.debugLineNum = 75;BA.debugLine="camEx.TakePicture";
mostCurrent._camex._takepicture /*String*/ ();
 //BA.debugLineNum = 76;BA.debugLine="End Sub";
return "";
}
public static String  _camera1_picturetaken(byte[] _data) throws Exception{
String _filename = "";
String _dir = "";
String _sdate = "";
String _stime = "";
int _i = 0;
 //BA.debugLineNum = 82;BA.debugLine="Sub Camera1_PictureTaken (Data() As Byte)";
 //BA.debugLineNum = 83;BA.debugLine="Dim filename As String = \"1.jpg\"";
_filename = "1.jpg";
 //BA.debugLineNum = 84;BA.debugLine="Dim dir As String = File.DirInternal";
_dir = anywheresoftware.b4a.keywords.Common.File.getDirInternal();
 //BA.debugLineNum = 86;BA.debugLine="camEx.SavePictureToFile(Data, dir, filename)";
mostCurrent._camex._savepicturetofile /*String*/ (_data,_dir,_filename);
 //BA.debugLineNum = 87;BA.debugLine="camEx.StartPreview 'restart preview";
mostCurrent._camex._startpreview /*String*/ ();
 //BA.debugLineNum = 91;BA.debugLine="Dim sDate,sTime As String";
_sdate = "";
_stime = "";
 //BA.debugLineNum = 94;BA.debugLine="DateTime.DateFormat = \"MM/dd/yyyy\"";
anywheresoftware.b4a.keywords.Common.DateTime.setDateFormat("MM/dd/yyyy");
 //BA.debugLineNum = 95;BA.debugLine="sDate=DateTime.Date(DateTime.Now)";
_sdate = anywheresoftware.b4a.keywords.Common.DateTime.Date(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
 //BA.debugLineNum = 96;BA.debugLine="sTime=DateTime.Time(DateTime.Now)";
_stime = anywheresoftware.b4a.keywords.Common.DateTime.Time(anywheresoftware.b4a.keywords.Common.DateTime.getNow());
 //BA.debugLineNum = 97;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")));
 //BA.debugLineNum = 98;BA.debugLine="c.Position = 0";
mostCurrent._c.setPosition((int) (0));
 //BA.debugLineNum = 99;BA.debugLine="cuenta = c.GetString(\"CUENTA\")";
mostCurrent._cuenta = mostCurrent._c.GetString("CUENTA");
 //BA.debugLineNum = 100;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")));
 //BA.debugLineNum = 101;BA.debugLine="c.Position = 0";
mostCurrent._c.setPosition((int) (0));
 //BA.debugLineNum = 102;BA.debugLine="USUARIO = c.GetString(\"USUARIO\")";
mostCurrent._usuario = mostCurrent._c.GetString("USUARIO");
 //BA.debugLineNum = 103;BA.debugLine="c.Close";
mostCurrent._c.Close();
 //BA.debugLineNum = 104;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)");
 //BA.debugLineNum = 106;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")));
 //BA.debugLineNum = 108;BA.debugLine="If c.RowCount>0 Then";
if (mostCurrent._c.getRowCount()>0) { 
 //BA.debugLineNum = 109;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 ) {
 //BA.debugLineNum = 110;BA.debugLine="c.Position=i";
mostCurrent._c.setPosition(_i);
 //BA.debugLineNum = 111;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")}));
 //BA.debugLineNum = 113;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"))}));
 }
};
 };
 //BA.debugLineNum = 124;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_intmex.keymon.lat.b4xmainpage*/ (mostCurrent.activityBA)._noventa /*reparto_intmex.keymon.lat.c_noventa*/ ._comentario /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (mostCurrent.activityBA)._lat_gps /*String*/ ),(Object)(mostCurrent._b4xpages._mainpage /*reparto_intmex.keymon.lat.b4xmainpage*/ (mostCurrent.activityBA)._lon_gps /*String*/ ),(Object)(_data)}));
 //BA.debugLineNum = 125;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)"));
 //BA.debugLineNum = 126;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)");
 //BA.debugLineNum = 127;BA.debugLine="B4XPages.ShowPage(\"Principal\")";
mostCurrent._b4xpages._showpage /*String*/ (mostCurrent.activityBA,"Principal");
 //BA.debugLineNum = 130;BA.debugLine="End Sub";
return "";
}
public static String  _camera1_ready(boolean _success) throws Exception{
 //BA.debugLineNum = 57;BA.debugLine="Sub Camera1_Ready (Success As Boolean)";
 //BA.debugLineNum = 58;BA.debugLine="If Success Then";
if (_success) { 
 //BA.debugLineNum = 59;BA.debugLine="camEx.SetJpegQuality(90)";
mostCurrent._camex._setjpegquality /*String*/ ((int) (90));
 //BA.debugLineNum = 60;BA.debugLine="camEx.CommitParameters";
mostCurrent._camex._commitparameters /*String*/ ();
 //BA.debugLineNum = 61;BA.debugLine="camEx.StartPreview";
mostCurrent._camex._startpreview /*String*/ ();
 //BA.debugLineNum = 62;BA.debugLine="Log(camEx.GetPreviewSize)";
anywheresoftware.b4a.keywords.Common.LogImpl("864290821",BA.ObjectToString(mostCurrent._camex._getpreviewsize /*reparto_intmex.keymon.lat.cameraexclass._camerasize*/ ()),0);
 }else {
 //BA.debugLineNum = 64;BA.debugLine="ToastMessageShow(\"Cannot open camera.\", True)";
anywheresoftware.b4a.keywords.Common.ToastMessageShow(BA.ObjectToCharSequence("Cannot open camera."),anywheresoftware.b4a.keywords.Common.True);
 };
 //BA.debugLineNum = 66;BA.debugLine="End Sub";
return "";
}
public static String  _changecamera_click() throws Exception{
 //BA.debugLineNum = 132;BA.debugLine="Sub ChangeCamera_Click";
 //BA.debugLineNum = 133;BA.debugLine="camEx.Release";
mostCurrent._camex._release /*String*/ ();
 //BA.debugLineNum = 134;BA.debugLine="frontCamera = Not(frontCamera)";
_frontcamera = anywheresoftware.b4a.keywords.Common.Not(_frontcamera);
 //BA.debugLineNum = 135;BA.debugLine="InitializeCamera";
_initializecamera();
 //BA.debugLineNum = 136;BA.debugLine="End Sub";
return "";
}
public static String  _globals() throws Exception{
 //BA.debugLineNum = 14;BA.debugLine="Sub Globals";
 //BA.debugLineNum = 15;BA.debugLine="Private p_camara As Panel";
mostCurrent._p_camara = new anywheresoftware.b4a.objects.PanelWrapper();
 //BA.debugLineNum = 16;BA.debugLine="Private camEx As CameraExClass";
mostCurrent._camex = new reparto_intmex.keymon.lat.cameraexclass();
 //BA.debugLineNum = 17;BA.debugLine="Dim btnTakePicture As Button";
mostCurrent._btntakepicture = new anywheresoftware.b4a.objects.ButtonWrapper();
 //BA.debugLineNum = 19;BA.debugLine="Dim c As Cursor";
mostCurrent._c = new anywheresoftware.b4a.sql.SQL.CursorWrapper();
 //BA.debugLineNum = 20;BA.debugLine="Dim cuenta As String";
mostCurrent._cuenta = "";
 //BA.debugLineNum = 21;BA.debugLine="Dim lat_gps As String";
mostCurrent._lat_gps = "";
 //BA.debugLineNum = 23;BA.debugLine="Dim USUARIO As String";
mostCurrent._usuario = "";
 //BA.debugLineNum = 24;BA.debugLine="Dim MOTIVO As String";
mostCurrent._motivo = "";
 //BA.debugLineNum = 25;BA.debugLine="End Sub";
return "";
}
public static String  _gps_locationchanged(anywheresoftware.b4a.gps.LocationWrapper _location1) throws Exception{
 //BA.debugLineNum = 50;BA.debugLine="Sub GPS_LocationChanged (Location1 As Location)";
 //BA.debugLineNum = 55;BA.debugLine="End Sub";
return "";
}
public static String  _initializecamera() throws Exception{
 //BA.debugLineNum = 41;BA.debugLine="Private Sub InitializeCamera";
 //BA.debugLineNum = 42;BA.debugLine="camEx.Initialize(p_camara, frontCamera, Me, \"Came";
mostCurrent._camex._initialize /*String*/ (mostCurrent.activityBA,mostCurrent._p_camara,_frontcamera,foto.getObject(),"Camera1");
 //BA.debugLineNum = 43;BA.debugLine="frontCamera = camEx.Front";
_frontcamera = mostCurrent._camex._front /*boolean*/ ;
 //BA.debugLineNum = 44;BA.debugLine="End Sub";
return "";
}
public static String  _process_globals() throws Exception{
 //BA.debugLineNum = 7;BA.debugLine="Sub Process_Globals";
 //BA.debugLineNum = 8;BA.debugLine="Private frontCamera As Boolean = False";
_frontcamera = anywheresoftware.b4a.keywords.Common.False;
 //BA.debugLineNum = 10;BA.debugLine="Dim g As GPS";
_g = new anywheresoftware.b4a.gps.GPS();
 //BA.debugLineNum = 12;BA.debugLine="End Sub";
return "";
}
}
