|
|
@ -90,6 +90,12 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
boolean _approverstatus; |
|
|
|
|
|
|
|
String Employeeid,LocName,Latitude,Longitude,Limit; |
|
|
|
|
|
|
|
String currentLat,currentlong; |
|
|
|
|
|
|
|
boolean is_out_of_location; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -132,8 +138,19 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
System.out.println("Current date and time " + currentDateAndTime); |
|
|
|
|
|
|
|
SharedPreferences shared = getSharedPreferences("MyPrefs", MODE_PRIVATE); |
|
|
|
String loginFromShare = shared.getString("login", ""); |
|
|
|
String Descriptor = shared.getString("Descriptor", ""); |
|
|
|
Employeeid = shared.getString("Employeeid", ""); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentLat = shared.getString("Lattitude", ""); |
|
|
|
currentlong = shared.getString("Longitude", ""); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("Value ofcurrentLat currentLatn "+ currentLat + " "+ currentlong); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -214,7 +231,7 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
|
|
|
|
TextView username = view.findViewById(R.id.username); |
|
|
|
username.setText(loginFromShare); |
|
|
|
username.setText(Employeeid); |
|
|
|
|
|
|
|
TextView request = view.findViewById(R.id.request); |
|
|
|
|
|
|
@ -252,6 +269,7 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
emergency.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
|
|
|
|
emergencySos(); |
|
|
|
} |
|
|
|
}); |
|
|
@ -492,6 +510,8 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
public void emergencySos(){ |
|
|
|
final ProgressDialog loading = ProgressDialog.show(CheckInActivity.this, "Authenticating", "Please wait ", false, false); |
|
|
|
|
|
|
|
System.out.println("Emergency sos "); |
|
|
|
|
|
|
|
String url= "http://43.242.212.92:7001/api/lgt/EmargencySOS"; |
|
|
|
StringRequest stringRequest=new StringRequest(Request.Method.POST, url, new com.android.volley.Response.Listener<String>() { |
|
|
|
@Override |
|
|
@ -504,6 +524,7 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
try { |
|
|
|
valueEmer = jsonObject.getString("_statusMessage"); |
|
|
|
System.out.println("Emergency sos on response"); |
|
|
|
} catch (JSONException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
@ -527,8 +548,8 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
protected Map<String, String> getParams() { |
|
|
|
Map<String, String> params = new HashMap<String, String>(); |
|
|
|
|
|
|
|
params.put("employeeid", "29034"); |
|
|
|
params.put("userid", "skumar"); |
|
|
|
params.put("employeeid", Employeeid); |
|
|
|
params.put("userid", "101"); |
|
|
|
|
|
|
|
|
|
|
|
return params; |
|
|
@ -616,10 +637,10 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
protected Map<String, String> getParams() { |
|
|
|
Map<String, String> params = new HashMap<String, String>(); |
|
|
|
|
|
|
|
params.put("employeeid", "101"); |
|
|
|
params.put("location", "loca1"); |
|
|
|
params.put("latitude", "10.235"); |
|
|
|
params.put("longitude", "55.666"); |
|
|
|
params.put("employeeid", Employeeid); |
|
|
|
params.put("location", LocName); |
|
|
|
params.put("latitude", currentLat); |
|
|
|
params.put("longitude", currentlong); |
|
|
|
params.put("checkintime", currentDateAndTime); |
|
|
|
params.put("locStateDevice", "1"); |
|
|
|
params.put("locStateApp", "1"); |
|
|
@ -630,6 +651,8 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
params.put("spoofingEnb", "0"); |
|
|
|
params.put("providerNetTime", "10/07/2023 12:10:05"); |
|
|
|
|
|
|
|
System.out.println("value of parms "+params); |
|
|
|
|
|
|
|
return params; |
|
|
|
} |
|
|
|
}; |
|
|
@ -686,10 +709,10 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
protected Map<String, String> getParams() { |
|
|
|
Map<String, String> params = new HashMap<String, String>(); |
|
|
|
|
|
|
|
params.put("employeeid", "29034"); |
|
|
|
params.put("location", "loca1"); |
|
|
|
params.put("latitude", "10.235"); |
|
|
|
params.put("longitude", "55.666"); |
|
|
|
params.put("employeeid", Employeeid); |
|
|
|
params.put("location", LocName); |
|
|
|
params.put("latitude", Latitude); |
|
|
|
params.put("longitude", Longitude); |
|
|
|
params.put("checkouttime", currentDateAndTime); |
|
|
|
params.put("locStateDevice", "1"); |
|
|
|
params.put("locStateApp", "1"); |
|
|
@ -707,7 +730,7 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
public void targetLocationListFromCheckIn(){ |
|
|
|
final ProgressDialog loading = ProgressDialog.show(CheckInActivity.this, "Checking location", "Please wait while checking", false, false); |
|
|
|
String url= "http://43.242.212.92:7001/api/lgt/EmployeeLocation?employeeid=29034"; |
|
|
|
String url= "http://43.242.212.92:7001/api/lgt/EmployeeLocation?employeeid=" + Employeeid; |
|
|
|
StringRequest stringRequest=new StringRequest(Request.Method.GET, url, new com.android.volley.Response.Listener<String>() { |
|
|
|
@Override |
|
|
|
public void onResponse(String response) { |
|
|
@ -716,13 +739,97 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
try { |
|
|
|
JSONObject jsonObject=new JSONObject(response); |
|
|
|
JSONArray jsonArray=jsonObject.getJSONArray("_lstEmployee_Location"); |
|
|
|
/*for(int i=0;i<jsonArray.length();i++){ |
|
|
|
for(int i=0;i<jsonArray.length();i++){ |
|
|
|
JSONObject jb1=jsonArray.getJSONObject(i); |
|
|
|
targetLat1=jb1.getString("Latitude"); |
|
|
|
|
|
|
|
LocName = jb1.getString("LocName"); |
|
|
|
Latitude = jb1.getString("Latitude"); |
|
|
|
Longitude = jb1.getString("Longitude"); |
|
|
|
Limit = jb1.getString("Limit"); |
|
|
|
|
|
|
|
Location current = new Location(""); |
|
|
|
current.setLatitude(Double.parseDouble(Latitude)); |
|
|
|
current.setLongitude(Double.parseDouble(Longitude)); |
|
|
|
|
|
|
|
if(Latitude.equals("22.5807° N")){ |
|
|
|
Latitude = "22.5807"; |
|
|
|
|
|
|
|
} |
|
|
|
if(Longitude.equals("88.4363° E")){ |
|
|
|
Longitude = "88.4363"; |
|
|
|
} |
|
|
|
|
|
|
|
Location target = new Location(""); |
|
|
|
target.setLatitude(Double.parseDouble(Latitude)); |
|
|
|
target.setLongitude(Double.parseDouble(Longitude)); |
|
|
|
|
|
|
|
float distance = current.distanceTo(target); |
|
|
|
|
|
|
|
System.out.println("Value of distance " + distance); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(distance <= Float.valueOf(Limit)){ |
|
|
|
Toast.makeText(CheckInActivity.this, "Attendance ready to be captured", Toast.LENGTH_SHORT).show(); |
|
|
|
checkIn(); |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
Toast.makeText(CheckInActivity.this, "You are out of range!Please get back to location", Toast.LENGTH_SHORT).show(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*if(currentLat.equals(Latitude) || currentlong.equals(Longitude)){ |
|
|
|
|
|
|
|
if(Latitude.equals("22.5807° N")){ |
|
|
|
Latitude = "22.5807"; |
|
|
|
|
|
|
|
} |
|
|
|
if(Longitude.equals("88.4363° E")){ |
|
|
|
Longitude = "88.4363"; |
|
|
|
} |
|
|
|
|
|
|
|
Location target = new Location(""); |
|
|
|
target.setLatitude(Double.parseDouble(Latitude)); |
|
|
|
target.setLongitude(Double.parseDouble(Longitude)); |
|
|
|
|
|
|
|
float distance = current.distanceTo(target); |
|
|
|
|
|
|
|
System.out.println("Value of distance " + distance); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(distance <= Float.valueOf(Limit)){ |
|
|
|
Toast.makeText(CheckInActivity.this, "Attendance ready to be captured", Toast.LENGTH_SHORT).show(); |
|
|
|
checkIn(); |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
// Toast.makeText(CheckInActivity.this, "You are out of range!Please get back to location", Toast.LENGTH_SHORT).show(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
Toast.makeText(CheckInActivity.this, "You are out of range!Please get back to location", Toast.LENGTH_SHORT).show(); |
|
|
|
// is_out_of_location = true; |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* if(is_out_of_location){ |
|
|
|
Toast.makeText(CheckInActivity.this, "You are out of range!Please get back to location", Toast.LENGTH_SHORT).show(); |
|
|
|
}*/ |
|
|
|
JSONObject jb1=jsonArray.getJSONObject(0); |
|
|
|
/*JSONObject jb1=jsonArray.getJSONObject(0); |
|
|
|
targetLat1= jb1.getString("Latitude"); |
|
|
|
targetLon1 = jb1.getString("Longitude"); |
|
|
|
|
|
|
@ -750,18 +857,19 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
Toast.makeText(CheckInActivity.this, "Attendance ready to be captured", Toast.LENGTH_SHORT).show(); |
|
|
|
checkIn(); |
|
|
|
/*Intent intent = new Intent(CheckInActivity.this, RegisterActivity.class); |
|
|
|
*//*Intent intent = new Intent(CheckInActivity.this, RegisterActivity.class); |
|
|
|
intent.putExtra("FromLoginPage",true); |
|
|
|
startActivity(intent);*/ |
|
|
|
startActivity(intent);*//* |
|
|
|
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
} catch (JSONException e) { |
|
|
|
} |
|
|
|
catch (JSONException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
|
|
|
|
loading.dismiss(); |
|
|
|
Toast.makeText(CheckInActivity.this, "Data added to API", Toast.LENGTH_SHORT).show(); |
|
|
|
//Toast.makeText(CheckInActivity.this, "Data added to API", Toast.LENGTH_SHORT).show(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -784,7 +892,7 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
public void targetLocationListFromCheckOut(){ |
|
|
|
final ProgressDialog loading = ProgressDialog.show(CheckInActivity.this, "Checking location", "Please wait while checking", false, false); |
|
|
|
String url= "http://43.242.212.92:7001/api/lgt/EmployeeLocation?employeeid=29034"; |
|
|
|
String url= "http://43.242.212.92:7001/api/lgt/EmployeeLocation?employeeid="+Employeeid; |
|
|
|
StringRequest stringRequest=new StringRequest(Request.Method.GET, url, new com.android.volley.Response.Listener<String>() { |
|
|
|
@Override |
|
|
|
public void onResponse(String response) { |
|
|
@ -793,13 +901,52 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
try { |
|
|
|
JSONObject jsonObject=new JSONObject(response); |
|
|
|
JSONArray jsonArray=jsonObject.getJSONArray("_lstEmployee_Location"); |
|
|
|
/*for(int i=0;i<jsonArray.length();i++){ |
|
|
|
for(int i=0;i<jsonArray.length();i++){ |
|
|
|
JSONObject jb1=jsonArray.getJSONObject(i); |
|
|
|
targetLat1=jb1.getString("Latitude"); |
|
|
|
|
|
|
|
LocName = jb1.getString("LocName"); |
|
|
|
Latitude = jb1.getString("Latitude"); |
|
|
|
Longitude = jb1.getString("Longitude"); |
|
|
|
Limit = jb1.getString("Limit"); |
|
|
|
|
|
|
|
if(Latitude.equals("22.5807° N")){ |
|
|
|
Latitude = "22.5807"; |
|
|
|
|
|
|
|
} |
|
|
|
if(Longitude.equals("88.4363° E")){ |
|
|
|
Longitude = "88.4363"; |
|
|
|
} |
|
|
|
|
|
|
|
Location current = new Location(""); |
|
|
|
current.setLatitude(Double.parseDouble(Latitude)); |
|
|
|
current.setLongitude(Double.parseDouble(Longitude)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Location target = new Location(""); |
|
|
|
target.setLatitude(Double.parseDouble(Latitude)); |
|
|
|
target.setLongitude(Double.parseDouble(Longitude)); |
|
|
|
|
|
|
|
float distance = current.distanceTo(target); |
|
|
|
|
|
|
|
System.out.println("Value of distance " + distance); |
|
|
|
|
|
|
|
if(distance <= Float.valueOf(Limit)){ |
|
|
|
Toast.makeText(CheckInActivity.this, "Attendance ready to be captured", Toast.LENGTH_SHORT).show(); |
|
|
|
checkOut(); |
|
|
|
} |
|
|
|
else { |
|
|
|
Toast.makeText(CheckInActivity.this, "You are out of range!Please get back to location", Toast.LENGTH_SHORT).show(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* if(is_out_of_location){ |
|
|
|
Toast.makeText(CheckInActivity.this, "You are out of range!Please get back to location", Toast.LENGTH_SHORT).show(); |
|
|
|
}*/ |
|
|
|
JSONObject jb1=jsonArray.getJSONObject(0); |
|
|
|
/*JSONObject jb1=jsonArray.getJSONObject(0); |
|
|
|
targetLat1= jb1.getString("Latitude"); |
|
|
|
targetLon1 = jb1.getString("Longitude"); |
|
|
|
|
|
|
@ -826,19 +973,20 @@ public class CheckInActivity extends AppCompatActivity { |
|
|
|
else{ |
|
|
|
|
|
|
|
Toast.makeText(CheckInActivity.this, "Attendance ready to be captured", Toast.LENGTH_SHORT).show(); |
|
|
|
checkOut(); |
|
|
|
/*Intent intent = new Intent(CheckInActivity.this, RegisterActivity.class); |
|
|
|
checkIn(); |
|
|
|
*//*Intent intent = new Intent(CheckInActivity.this, RegisterActivity.class); |
|
|
|
intent.putExtra("FromLoginPage",true); |
|
|
|
startActivity(intent);*/ |
|
|
|
startActivity(intent);*//* |
|
|
|
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
} catch (JSONException e) { |
|
|
|
} |
|
|
|
catch (JSONException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
|
|
|
|
loading.dismiss(); |
|
|
|
Toast.makeText(CheckInActivity.this, "Data added to API", Toast.LENGTH_SHORT).show(); |
|
|
|
// Toast.makeText(CheckInActivity.this, "Data added to API", Toast.LENGTH_SHORT).show(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|