Displayed dialog for distance from location
This commit is contained in:
parent
45a0b864f3
commit
ef5153765f
@ -172,6 +172,7 @@ dependencies {
|
|||||||
implementation 'com.trello:rxlifecycle-components:1.0'
|
implementation 'com.trello:rxlifecycle-components:1.0'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'com.google.android.material:material:1.0.0'
|
implementation 'com.google.android.material:material:1.0.0'
|
||||||
|
implementation 'com.github.f0ris.sweetalert:library:1.5.1'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
@ -22,7 +23,11 @@
|
|||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme"
|
||||||
|
tools:replace="android:icon,android:allowBackup">
|
||||||
|
<activity
|
||||||
|
android:name=".views.EmployeeActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".register.SavePhotoActivity"
|
android:name=".register.SavePhotoActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
package ru.visionlab.femdemo;
|
package ru.visionlab.femdemo;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.location.LocationManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -19,16 +25,24 @@ import android.widget.PopupMenu;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import cn.pedant.SweetAlert.SweetAlertDialog;
|
||||||
import ru.visionlab.femdemo.login.LoginActivity;
|
import ru.visionlab.femdemo.login.LoginActivity;
|
||||||
import ru.visionlab.femdemo.register.RegisterActivityNew;
|
import ru.visionlab.femdemo.register.RegisterActivityNew;
|
||||||
|
import ru.visionlab.femdemo.views.EmployeeActivity;
|
||||||
|
|
||||||
public class CheckInActivity extends AppCompatActivity {
|
public class CheckInActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private static final int REQUEST_LOCATION=1;
|
||||||
|
|
||||||
ImageView logout;
|
ImageView logout;
|
||||||
ImageView menu;
|
ImageView menu;
|
||||||
|
|
||||||
AlertDialog dialogBuilder;
|
AlertDialog dialogBuilder;
|
||||||
|
|
||||||
|
Button btnCheckIn;
|
||||||
|
|
||||||
|
LocationManager locationManager;
|
||||||
|
String latitude,longitude;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -36,6 +50,19 @@ public class CheckInActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
logout = findViewById(R.id.logout);
|
logout = findViewById(R.id.logout);
|
||||||
|
|
||||||
|
btnCheckIn = findViewById(R.id.btnCheckIn);
|
||||||
|
btnCheckIn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
/*Intent intent = new Intent(CheckInActivity.this, EmployeeActivity.class);
|
||||||
|
startActivity(intent);*/
|
||||||
|
|
||||||
|
location();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
logout.setOnClickListener(new View.OnClickListener() {
|
logout.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -58,19 +85,11 @@ public class CheckInActivity extends AppCompatActivity {
|
|||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Intent intent = new Intent(CheckInActivity.this, LoginActivity.class);
|
Intent intent = new Intent(CheckInActivity.this, LoginActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*Button btn_confirm = view.findViewById(R.id.btn_confirm);
|
|
||||||
Button btn_cancel = view.findViewById(R.id.btn_cancel);
|
|
||||||
TextView txt_title = view.findViewById(R.id.txt_title);
|
|
||||||
TextView txt_content = view.findViewById(R.id.txt_content);
|
|
||||||
|
|
||||||
btn_cancel.setVisibility(View.GONE);
|
|
||||||
btn_confirm.setText("OK");
|
|
||||||
|
|
||||||
txt_title.setText("WARNING");
|
|
||||||
txt_content.setText("This job is not active. Please synchronize to get the latest data, then contact your coordinator if needed.");*/
|
|
||||||
|
|
||||||
|
|
||||||
final AlertDialog alertDialog = new AlertDialog.Builder(CheckInActivity.this)
|
final AlertDialog alertDialog = new AlertDialog.Builder(CheckInActivity.this)
|
||||||
@ -87,59 +106,148 @@ public class CheckInActivity extends AppCompatActivity {
|
|||||||
params.horizontalMargin = -100;
|
params.horizontalMargin = -100;
|
||||||
alertDialog.getWindow().setAttributes(params);
|
alertDialog.getWindow().setAttributes(params);
|
||||||
|
|
||||||
/*btn_confirm.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
alertDialog.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
btn_cancel.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
alertDialog.cancel();
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*menu.setOnClickListener(new View.OnClickListener() {
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void location(){
|
||||||
|
locationManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
//Check gps is enable or not
|
||||||
|
|
||||||
|
if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||||
|
//Write Function To enable gps
|
||||||
|
|
||||||
|
OnGPS();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//GPS is already On then
|
||||||
|
|
||||||
|
getLocation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnGPS() {
|
||||||
|
|
||||||
|
final AlertDialog.Builder builder= new AlertDialog.Builder(this);
|
||||||
|
|
||||||
|
builder.setMessage("Enable GPS").setCancelable(false).setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
||||||
// instance of alert dialog to build alert dialog
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(CheckInActivity.this);
|
|
||||||
builder.setIcon(R.drawable.andrew);
|
|
||||||
builder.setTitle("Andrew Bahl");
|
|
||||||
// builder.setMessage("Bottom Alert dialog");
|
|
||||||
|
|
||||||
// set the neutral button to do some actions
|
|
||||||
builder.setNeutralButton("Logout", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
Intent intent = new Intent(CheckInActivity.this, LoginActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// show the alert dialog
|
|
||||||
AlertDialog alertDialog = builder.create();
|
|
||||||
alertDialog.show();
|
|
||||||
alertDialog.getWindow().setLayout(800,400);
|
|
||||||
alertDialog.getWindow().setGravity(Gravity.TOP);
|
|
||||||
*//*PopupMenu popupMenu = new PopupMenu(CheckInActivity.this, menu);
|
|
||||||
popupMenu.getMenuInflater().inflate(R.menu.navigation_menu, popupMenu.getMenu());
|
|
||||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
|
||||||
// Toast message on menu item clicked
|
|
||||||
Toast.makeText(CheckInActivity.this, "You Clicked " + menuItem.getTitle(), Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Showing the popup menu
|
|
||||||
popupMenu.show();*//*
|
|
||||||
}
|
}
|
||||||
});*/
|
}).setNegativeButton("NO", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final AlertDialog alertDialog=builder.create();
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
private void getLocation() {
|
||||||
|
|
||||||
|
//Check Permissions again
|
||||||
|
|
||||||
|
if (ActivityCompat.checkSelfPermission(CheckInActivity.this,android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(CheckInActivity.this,
|
||||||
|
|
||||||
|
android.Manifest.permission.ACCESS_FINE_LOCATION) !=PackageManager.PERMISSION_GRANTED)
|
||||||
|
{
|
||||||
|
ActivityCompat.requestPermissions(this,new String[]
|
||||||
|
{android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Location LocationGps= locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||||
|
Location LocationNetwork=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||||
|
Location LocationPassive=locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
|
||||||
|
|
||||||
|
if (LocationGps !=null)
|
||||||
|
{
|
||||||
|
double lat=LocationGps.getLatitude();
|
||||||
|
double longi=LocationGps.getLongitude();
|
||||||
|
|
||||||
|
latitude=String.valueOf(lat);
|
||||||
|
longitude=String.valueOf(longi);
|
||||||
|
System.out.println("Position 1");
|
||||||
|
// showLocationTxt.setText("Your Location:"+"\n"+"Latitude= "+latitude+"\n"+"Longitude= "+longitude);
|
||||||
|
}
|
||||||
|
else if (LocationNetwork !=null)
|
||||||
|
{
|
||||||
|
double lat=LocationNetwork.getLatitude();
|
||||||
|
double longi=LocationNetwork.getLongitude();
|
||||||
|
|
||||||
|
/*double newLat = 22.5135;
|
||||||
|
double newLong = 88.4029;*/
|
||||||
|
|
||||||
|
double newLat = 22.5150;
|
||||||
|
double newLong = 88.3930;
|
||||||
|
|
||||||
|
float[] results = new float[1];
|
||||||
|
Location.distanceBetween(lat,longi,newLat,newLong,results);
|
||||||
|
float distance = results[0];
|
||||||
|
Toast.makeText(this,String.valueOf(distance)+" metres from location",Toast.LENGTH_LONG).show();
|
||||||
|
if(distance > 400){
|
||||||
|
moreThanFour();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lessThanFour();
|
||||||
|
}
|
||||||
|
latitude=String.valueOf(lat);
|
||||||
|
longitude=String.valueOf(longi);
|
||||||
|
System.out.println("Position 2");
|
||||||
|
// showLocationTxt.setText("Your Location:"+"\n"+"Latitude= "+latitude+"\n"+"Longitude= "+longitude);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (LocationPassive !=null)
|
||||||
|
{
|
||||||
|
double lat=LocationPassive.getLatitude();
|
||||||
|
double longi=LocationPassive.getLongitude();
|
||||||
|
|
||||||
|
latitude=String.valueOf(lat);
|
||||||
|
longitude=String.valueOf(longi);
|
||||||
|
System.out.println("Position 3");
|
||||||
|
// showLocationTxt.setText("Your Location:"+"\n"+"Latitude= "+latitude+"\n"+"Longitude= "+longitude);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Toast.makeText(this, "Can't Get Your Location", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moreThanFour(){
|
||||||
|
new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
|
||||||
|
.setTitleText("Are you sure you are near location?")
|
||||||
|
.setContentText("Please be in your precise location")
|
||||||
|
.setConfirmText("OK").setConfirmText("OK").setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(SweetAlertDialog sDialog) {
|
||||||
|
sDialog.dismissWithAnimation();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void lessThanFour(){
|
||||||
|
new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
|
||||||
|
.setTitleText("You are currently near location")
|
||||||
|
.setContentText("Attendance can be captured now")
|
||||||
|
.setConfirmText("OK").setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(SweetAlertDialog sDialog) {
|
||||||
|
sDialog.dismissWithAnimation();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import android.hardware.Camera;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.widget.LinearLayoutCompat;
|
||||||
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -76,6 +77,8 @@ public class LoginActivity extends BaseActivity {
|
|||||||
Button login_new;
|
Button login_new;
|
||||||
Button reg_new;
|
Button reg_new;
|
||||||
|
|
||||||
|
LinearLayoutCompat lay_licence_verify;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -85,6 +88,8 @@ public class LoginActivity extends BaseActivity {
|
|||||||
//login = findViewById(R.id.login);
|
//login = findViewById(R.id.login);
|
||||||
register = findViewById(R.id.register);
|
register = findViewById(R.id.register);
|
||||||
|
|
||||||
|
lay_licence_verify = findViewById(R.id.lay_licence_verify);
|
||||||
|
|
||||||
login_new = findViewById(R.id.login_new);
|
login_new = findViewById(R.id.login_new);
|
||||||
|
|
||||||
login_new.setOnClickListener(new View.OnClickListener() {
|
login_new.setOnClickListener(new View.OnClickListener() {
|
||||||
@ -160,10 +165,12 @@ public class LoginActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
case 0: {
|
case 0: {
|
||||||
Log.d(TAG, "Face engine were succesfully created " + getFilesDir() + "/vl/data");
|
Log.d(TAG, "Face engine were succesfully created " + getFilesDir() + "/vl/data");
|
||||||
|
lay_licence_verify.setVisibility(View.VISIBLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
Toast.makeText(this, "License Verification failed!", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "License Verification failed!", Toast.LENGTH_LONG).show();
|
||||||
|
lay_licence_verify.setVisibility(View.VISIBLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
|
@ -69,7 +69,8 @@ public class LoginActivityNew extends AppCompatActivity {
|
|||||||
isAllFieldsChecked = CheckAllFields();
|
isAllFieldsChecked = CheckAllFields();
|
||||||
if(isAllFieldsChecked) {
|
if(isAllFieldsChecked) {
|
||||||
// login();
|
// login();
|
||||||
Intent intent = new Intent(LoginActivityNew.this, AuthenticationActivity.class);
|
//Intent intent = new Intent(LoginActivityNew.this, AuthenticationActivity.class);
|
||||||
|
Intent intent = new Intent(LoginActivityNew.this, CheckInActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,221 @@
|
|||||||
|
package ru.visionlab.femdemo.views;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.location.LocationManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import cn.pedant.SweetAlert.SweetAlertDialog;
|
||||||
|
import ru.visionlab.femdemo.CheckInActivity;
|
||||||
|
import ru.visionlab.femdemo.R;
|
||||||
|
import ru.visionlab.femdemo.login.LoginActivity;
|
||||||
|
|
||||||
|
public class EmployeeActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private static final int REQUEST_LOCATION=1;
|
||||||
|
|
||||||
|
TextView showLocationTxt;
|
||||||
|
LocationManager locationManager;
|
||||||
|
String latitude,longitude;
|
||||||
|
|
||||||
|
ImageView logout;
|
||||||
|
ImageView menu;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_employee);
|
||||||
|
ActivityCompat.requestPermissions(this,new String[]
|
||||||
|
{android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION);
|
||||||
|
|
||||||
|
showLocationTxt=findViewById(R.id.show_location);
|
||||||
|
|
||||||
|
logout = findViewById(R.id.logout);
|
||||||
|
|
||||||
|
|
||||||
|
locationManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
|
||||||
|
//Check gps is enable or not
|
||||||
|
|
||||||
|
if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
|
||||||
|
{
|
||||||
|
//Write Function To enable gps
|
||||||
|
|
||||||
|
OnGPS();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//GPS is already On then
|
||||||
|
|
||||||
|
getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
logout.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(EmployeeActivity.this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
menu = findViewById(R.id.menu);
|
||||||
|
menu.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
|
||||||
|
view = inflater.inflate(R.layout.layout, null);
|
||||||
|
|
||||||
|
TextView popup_log_out = view.findViewById(R.id.popup_log_out);
|
||||||
|
|
||||||
|
popup_log_out.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Intent intent = new Intent(EmployeeActivity.this, LoginActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final AlertDialog alertDialog = new AlertDialog.Builder(EmployeeActivity.this)
|
||||||
|
.setView(view)
|
||||||
|
.create();
|
||||||
|
alertDialog.show();
|
||||||
|
alertDialog.getWindow().setLayout(600,460);
|
||||||
|
alertDialog.getWindow().setGravity(Gravity.TOP|Gravity.LEFT);
|
||||||
|
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||||
|
|
||||||
|
|
||||||
|
WindowManager.LayoutParams params = alertDialog.getWindow().getAttributes();
|
||||||
|
alertDialog.setCanceledOnTouchOutside(true);
|
||||||
|
params.horizontalMargin = -100;
|
||||||
|
alertDialog.getWindow().setAttributes(params);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getLocation() {
|
||||||
|
|
||||||
|
//Check Permissions again
|
||||||
|
|
||||||
|
if (ActivityCompat.checkSelfPermission(EmployeeActivity.this,android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(EmployeeActivity.this,
|
||||||
|
|
||||||
|
android.Manifest.permission.ACCESS_FINE_LOCATION) !=PackageManager.PERMISSION_GRANTED)
|
||||||
|
{
|
||||||
|
ActivityCompat.requestPermissions(this,new String[]
|
||||||
|
{android.Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Location LocationGps= locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||||
|
Location LocationNetwork=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||||
|
Location LocationPassive=locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER);
|
||||||
|
|
||||||
|
if (LocationGps !=null)
|
||||||
|
{
|
||||||
|
double lat=LocationGps.getLatitude();
|
||||||
|
double longi=LocationGps.getLongitude();
|
||||||
|
|
||||||
|
latitude=String.valueOf(lat);
|
||||||
|
longitude=String.valueOf(longi);
|
||||||
|
System.out.println("Position 1");
|
||||||
|
showLocationTxt.setText("Your Location:"+"\n"+"Latitude= "+latitude+"\n"+"Longitude= "+longitude);
|
||||||
|
}
|
||||||
|
else if (LocationNetwork !=null)
|
||||||
|
{
|
||||||
|
double lat=LocationNetwork.getLatitude();
|
||||||
|
double longi=LocationNetwork.getLongitude();
|
||||||
|
|
||||||
|
double newLat = 22.5135;
|
||||||
|
double newLong = 88.4029;
|
||||||
|
|
||||||
|
float[] results = new float[1];
|
||||||
|
Location.distanceBetween(lat,longi,newLat,newLong,results);
|
||||||
|
float distance = results[0];
|
||||||
|
Toast.makeText(this,String.valueOf(distance)+" metres from location",Toast.LENGTH_LONG).show();
|
||||||
|
if(distance > 400){
|
||||||
|
moreThanFour();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
lessThanFour();
|
||||||
|
}
|
||||||
|
latitude=String.valueOf(lat);
|
||||||
|
longitude=String.valueOf(longi);
|
||||||
|
System.out.println("Position 2");
|
||||||
|
showLocationTxt.setText("Your Location:"+"\n"+"Latitude= "+latitude+"\n"+"Longitude= "+longitude);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (LocationPassive !=null)
|
||||||
|
{
|
||||||
|
double lat=LocationPassive.getLatitude();
|
||||||
|
double longi=LocationPassive.getLongitude();
|
||||||
|
|
||||||
|
latitude=String.valueOf(lat);
|
||||||
|
longitude=String.valueOf(longi);
|
||||||
|
System.out.println("Position 3");
|
||||||
|
showLocationTxt.setText("Your Location:"+"\n"+"Latitude= "+latitude+"\n"+"Longitude= "+longitude);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Toast.makeText(this, "Can't Get Your Location", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGPS() {
|
||||||
|
|
||||||
|
final AlertDialog.Builder builder= new AlertDialog.Builder(this);
|
||||||
|
|
||||||
|
builder.setMessage("Enable GPS").setCancelable(false).setPositiveButton("YES", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
||||||
|
}
|
||||||
|
}).setNegativeButton("NO", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final AlertDialog alertDialog=builder.create();
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moreThanFour(){
|
||||||
|
new SweetAlertDialog(this, SweetAlertDialog.WARNING_TYPE)
|
||||||
|
.setTitleText("Are you sure you are near location?")
|
||||||
|
.setContentText("Please be in your precise location")
|
||||||
|
.setConfirmText("OK").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void lessThanFour(){
|
||||||
|
new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
|
||||||
|
.setTitleText("You are currently near location")
|
||||||
|
.setContentText("Attendance can be captured now")
|
||||||
|
.setConfirmText("OK").show();
|
||||||
|
}
|
||||||
|
}
|
@ -45,7 +45,7 @@
|
|||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnLogin"
|
android:id="@+id/btnCheckIn"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="40dp"
|
android:layout_marginTop="40dp"
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".views.EmployeeActivity"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="15dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/menu"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:background="@drawable/menu" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/logout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:background="@drawable/back" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/show_location"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="Location"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
@ -16,6 +16,8 @@
|
|||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:scrollbars="none">
|
android:scrollbars="none">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -39,6 +41,27 @@
|
|||||||
/>
|
/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.LinearLayoutCompat
|
||||||
|
android:id="@+id/lay_licence_verify"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="#FF2E2E"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:text="Please complete licence verification"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="350px"
|
android:layout_width="350px"
|
||||||
android:layout_height="350px"
|
android:layout_height="350px"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user