|
|
@ -15,6 +15,7 @@ import android.bluetooth.BluetoothAdapter; |
|
|
|
import android.bluetooth.BluetoothManager; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.SharedPreferences; |
|
|
|
import android.content.pm.PackageManager; |
|
|
|
import android.graphics.Color; |
|
|
|
import android.os.Build; |
|
|
@ -63,6 +64,8 @@ import com.minew.beaconplus.sdk.interfaces.OnBluetoothStateChangedListener; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import cn.pedant.SweetAlert.SweetAlertDialog; |
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
private static final int REQUEST_ENABLE_BT = 3; |
|
|
@ -85,8 +88,16 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
TextView txt_name,txt_mac,txt_battery,txt_rssi,txt_device,txt_xaxis,txt_yaxis,txt_zaxis; |
|
|
|
String mac,name,xaxis,yaxis,zaxis; |
|
|
|
int battery,rssi; |
|
|
|
String password= ""; |
|
|
|
|
|
|
|
EditText edtPass; |
|
|
|
boolean passwordGiven=false; |
|
|
|
|
|
|
|
SharedPreferences sharedPreferences; |
|
|
|
private static final String SHARED_PREF_NAME = "myPref"; |
|
|
|
private static final String KEY_PASS= "password"; |
|
|
|
|
|
|
|
String passAvail = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@ -96,6 +107,15 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
//ButterKnife.bind(this); |
|
|
|
mRecycle = findViewById(R.id.recycle); |
|
|
|
|
|
|
|
sharedPreferences = getSharedPreferences(SHARED_PREF_NAME,MODE_PRIVATE); |
|
|
|
passAvail = sharedPreferences.getString(KEY_PASS,null); |
|
|
|
System.out.println("Value of passAvail "+ passAvail); |
|
|
|
|
|
|
|
Intent intent = getIntent(); |
|
|
|
passAvail = intent.getStringExtra("password"); |
|
|
|
System.out.println("Value of pass " + passAvail); |
|
|
|
|
|
|
|
|
|
|
|
if (!ensureBleExists()) |
|
|
|
finish(); |
|
|
|
|
|
|
@ -505,14 +525,30 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
public void onClick(View view) { |
|
|
|
String userPass = edtPass.getText().toString().trim(); |
|
|
|
System.out.println("Value of userPass "+userPass); |
|
|
|
if(userPass.equals("minew123")){ |
|
|
|
//if(userPass.equals(password)){ |
|
|
|
if(userPass.equals("test")){ |
|
|
|
SharedPreferences.Editor editor = sharedPreferences.edit(); |
|
|
|
editor.putString(KEY_PASS,userPass); |
|
|
|
editor.apply(); |
|
|
|
System.out.println("Value of KEY_PASS "+KEY_PASS); |
|
|
|
Toast.makeText(MainActivity.this, "Password accepted", Toast.LENGTH_SHORT).show(); |
|
|
|
Intent intent2 = new Intent(MainActivity.this,DetailActivity.class); |
|
|
|
startActivity(intent2); |
|
|
|
b.dismiss(); |
|
|
|
} |
|
|
|
else{ |
|
|
|
Toast.makeText(MainActivity.this, "Password incorrect", Toast.LENGTH_SHORT).show(); |
|
|
|
new SweetAlertDialog(MainActivity.this, SweetAlertDialog.WARNING_TYPE) |
|
|
|
.setTitleText("Incorrect password") |
|
|
|
.setConfirmText("OK") |
|
|
|
.setContentText("The password you have entered is incorrect . Please try again!") |
|
|
|
.showCancelButton(false) |
|
|
|
.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(SweetAlertDialog sDialog) { |
|
|
|
sDialog.dismiss(); |
|
|
|
} |
|
|
|
}) |
|
|
|
.show(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
@ -544,8 +580,15 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
case PASSWORDVALIDATING: |
|
|
|
Log.e("tag", "PASSWORDVALIDATING"); |
|
|
|
Toast.makeText(MainActivity.this, "PASSWORDVALIDATING", Toast.LENGTH_SHORT).show(); |
|
|
|
passwordFromUser(); |
|
|
|
getPasswordListener.getPassword(password); |
|
|
|
System.out.println("Value of passAvail "+ passAvail); |
|
|
|
if(passAvail == null){ |
|
|
|
passwordFromUser(); |
|
|
|
} |
|
|
|
else { |
|
|
|
Intent intent2 = new Intent(MainActivity.this, DetailActivity.class); |
|
|
|
startActivity(intent2); |
|
|
|
} |
|
|
|
//getPasswordListener.getPassword(password); |
|
|
|
|
|
|
|
break; |
|
|
|
case SYNCHRONIZINGTIME: |
|
|
|