Password validation
This commit is contained in:
parent
dd1b33e607
commit
5e82b320e7
@ -2,25 +2,36 @@ package com.example.beacondemo.Activity;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.provider.SyncStateContract;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.example.beacondemo.R;
|
import com.example.beacondemo.R;
|
||||||
import com.example.beacondemo.adapter.RecycleAdapter;
|
import com.example.beacondemo.adapter.RecycleAdapter;
|
||||||
import com.minew.beaconplus.sdk.MTCentralManager;
|
import com.minew.beaconplus.sdk.MTCentralManager;
|
||||||
|
import com.minew.beaconplus.sdk.MTConnectionFeature;
|
||||||
import com.minew.beaconplus.sdk.MTConnectionHandler;
|
import com.minew.beaconplus.sdk.MTConnectionHandler;
|
||||||
import com.minew.beaconplus.sdk.MTFrameHandler;
|
import com.minew.beaconplus.sdk.MTFrameHandler;
|
||||||
import com.minew.beaconplus.sdk.MTPeripheral;
|
import com.minew.beaconplus.sdk.MTPeripheral;
|
||||||
|
import com.minew.beaconplus.sdk.enums.ConnectState;
|
||||||
|
import com.minew.beaconplus.sdk.enums.FeatureSupported;
|
||||||
import com.minew.beaconplus.sdk.enums.FrameType;
|
import com.minew.beaconplus.sdk.enums.FrameType;
|
||||||
|
import com.minew.beaconplus.sdk.enums.PasswordState;
|
||||||
import com.minew.beaconplus.sdk.enums.TriggerType;
|
import com.minew.beaconplus.sdk.enums.TriggerType;
|
||||||
import com.minew.beaconplus.sdk.enums.Version;
|
import com.minew.beaconplus.sdk.enums.Version;
|
||||||
import com.minew.beaconplus.sdk.exception.MTException;
|
import com.minew.beaconplus.sdk.exception.MTException;
|
||||||
@ -44,6 +55,7 @@ import com.minew.beaconplus.sdk.interfaces.SetTriggerListener;
|
|||||||
import com.minew.beaconplus.sdk.model.Trigger;
|
import com.minew.beaconplus.sdk.model.Trigger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DetailActivity extends AppCompatActivity implements View.OnClickListener {
|
public class DetailActivity extends AppCompatActivity implements View.OnClickListener {
|
||||||
@ -69,6 +81,8 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
RecyclerView mRecycle;
|
RecyclerView mRecycle;
|
||||||
|
|
||||||
ArrayList<MinewFrame> advFrames;
|
ArrayList<MinewFrame> advFrames;
|
||||||
|
TextView tv_resetPass;
|
||||||
|
EditText edtPassR,edtConPassR;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -80,6 +94,48 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
initView();
|
initView();
|
||||||
initData();
|
initData();
|
||||||
initListener();
|
initListener();
|
||||||
|
|
||||||
|
|
||||||
|
tv_resetPass.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
resetPassword();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingInflatedId")
|
||||||
|
public void resetPassword() {
|
||||||
|
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
|
||||||
|
LayoutInflater inflater = this.getLayoutInflater();
|
||||||
|
dialogBuilder.setCancelable(false);
|
||||||
|
final View dialogView = inflater.inflate(R.layout.password_reset, null);
|
||||||
|
dialogBuilder.setView(dialogView);
|
||||||
|
edtPassR = dialogView.findViewById(R.id.edtPassR);
|
||||||
|
edtConPassR = dialogView.findViewById(R.id.edtConPassR);
|
||||||
|
|
||||||
|
//System.out.println("Value of userPass "+String.valueOf(userPass));
|
||||||
|
dialogBuilder.setPositiveButton("SUBMIT", null);
|
||||||
|
dialogBuilder.setTitle("Reset Password");
|
||||||
|
dialogBuilder.setMessage("Please enter password to you want to reset.");
|
||||||
|
|
||||||
|
dialogBuilder.setNegativeButton("CANCEL",null);
|
||||||
|
final AlertDialog b = dialogBuilder.create();
|
||||||
|
b.show();
|
||||||
|
Button positiveButton = b.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
|
Button cancel = b.getButton(AlertDialog.BUTTON_NEGATIVE);
|
||||||
|
positiveButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
b.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
@ -96,6 +152,8 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
txt_zaxis=findViewById(R.id.txt_zaxis);
|
txt_zaxis=findViewById(R.id.txt_zaxis);
|
||||||
|
|
||||||
mRecycle = findViewById(R.id.recycle);
|
mRecycle = findViewById(R.id.recycle);
|
||||||
|
tv_resetPass = findViewById(R.id.tv_resetPass);
|
||||||
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String mac = intent.getStringExtra("mac");
|
String mac = intent.getStringExtra("mac");
|
||||||
@ -292,6 +350,40 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
return super.toString();
|
return super.toString();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*MTConnectionHandler mtConnectionHandler = mtPeripheral.mMTConnectionHandler;
|
||||||
|
ConnectState connectState = mtConnectionHandler.getConnectState();
|
||||||
|
// password require or not. None, Require
|
||||||
|
PasswordState passwordState = mMTConnectionHandler.getPasswordState();
|
||||||
|
// device info, such as:(Firmware Version: 0.9.1);
|
||||||
|
HashMap<String, String> systeminfos = (HashMap<String, String>) mMTConnectionHandler.systeminfos;
|
||||||
|
String manufacturer = systeminfos.get(SyncStateContract.Constants.manufacturer);
|
||||||
|
String modlenumber = systeminfos.get(Constants.modlenumber);
|
||||||
|
String macAddress = systeminfos.get(Constants.serialnumber);
|
||||||
|
String hardware = systeminfos.get(Constants.hardware);
|
||||||
|
String firmware = systeminfos.get(Constants.firmware);
|
||||||
|
String software = systeminfos.get(Constants.software);*/
|
||||||
|
|
||||||
|
// device features
|
||||||
|
/*MTConnectionFeature mtConnectionFeature = mMTConnectionHandler.mTConnectionFeature;
|
||||||
|
// atitude of slot(s),
|
||||||
|
int slotAtitude = mtConnectionFeature.getSlotAtitude();
|
||||||
|
Log.d("slotAtitude", String.valueOf(slotAtitude));
|
||||||
|
// parameters can be modified:none,adv,txpower,adv/txpower
|
||||||
|
FeatureSupported featureSupported = mtConnectionFeature.getFeatureSupported();
|
||||||
|
Log.d("featureSupported", String.valueOf(featureSupported));
|
||||||
|
// // frames supported(multiple)
|
||||||
|
List<FrameType> supportedSlots = mtConnectionFeature.getSupportedSlots();
|
||||||
|
Log.d("supportedSlots", String.valueOf(supportedSlots));
|
||||||
|
// Txpower supported(multiple)
|
||||||
|
byte[] supportedTxpowers = mtConnectionFeature.getSupportedTxpowers();
|
||||||
|
Log.d("supportedTxpowers", String.valueOf(supportedTxpowers));
|
||||||
|
// trigger supported(multiple)
|
||||||
|
ArrayList<TriggerType> supportTriggers = (ArrayList<TriggerType>) mtConnectionFeature.supportTriggers;
|
||||||
|
Log.d("supportTriggers", String.valueOf(supportTriggers));
|
||||||
|
// Version of firmware;
|
||||||
|
Version version = mtConnectionFeature.getVersion();
|
||||||
|
Log.d("version", String.valueOf(version));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initListener() {
|
private void initListener() {
|
||||||
@ -300,7 +392,9 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveTrigger() {
|
public void saveTrigger() {
|
||||||
|
System.out.println("Inside save trigger method");
|
||||||
Version version = this.mMTConnectionHandler.mTConnectionFeature.getVersion();
|
Version version = this.mMTConnectionHandler.mTConnectionFeature.getVersion();
|
||||||
|
System.out.println("Version Inside save trigger method" + version.getValue());
|
||||||
if (version.getValue() >= 4) {
|
if (version.getValue() >= 4) {
|
||||||
if (this.mMTConnectionHandler.mTConnectionFeature.supportTriggers.size() > 0
|
if (this.mMTConnectionHandler.mTConnectionFeature.supportTriggers.size() > 0
|
||||||
&& this.mMTConnectionHandler.triggers.size() > 0) {
|
&& this.mMTConnectionHandler.triggers.size() > 0) {
|
||||||
|
@ -2,6 +2,7 @@ package com.example.beacondemo.Activity;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
@ -20,7 +21,10 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -81,6 +85,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
TextView txt_name,txt_mac,txt_battery,txt_rssi,txt_device,txt_xaxis,txt_yaxis,txt_zaxis;
|
TextView txt_name,txt_mac,txt_battery,txt_rssi,txt_device,txt_xaxis,txt_yaxis,txt_zaxis;
|
||||||
String mac,name,xaxis,yaxis,zaxis;
|
String mac,name,xaxis,yaxis,zaxis;
|
||||||
int battery,rssi;
|
int battery,rssi;
|
||||||
|
String password= "";
|
||||||
|
EditText edtPass;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -476,6 +483,40 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public void passwordFromUser() {
|
||||||
|
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
|
||||||
|
LayoutInflater inflater = this.getLayoutInflater();
|
||||||
|
dialogBuilder.setCancelable(false);
|
||||||
|
final View dialogView = inflater.inflate(R.layout.password_dialog, null);
|
||||||
|
dialogBuilder.setView(dialogView);
|
||||||
|
edtPass = dialogView.findViewById(R.id.edtPass);
|
||||||
|
|
||||||
|
//System.out.println("Value of userPass "+String.valueOf(userPass));
|
||||||
|
dialogBuilder.setPositiveButton("SUBMIT", null);
|
||||||
|
dialogBuilder.setTitle("Password Validation");
|
||||||
|
dialogBuilder.setMessage("Please enter password to connect to bluetooth.");
|
||||||
|
final AlertDialog b = dialogBuilder.create();
|
||||||
|
b.show();
|
||||||
|
Button positiveButton = b.getButton(AlertDialog.BUTTON_POSITIVE);
|
||||||
|
//String finalUserPass = userPass;
|
||||||
|
//password = "minew123";
|
||||||
|
positiveButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
String userPass = edtPass.getText().toString().trim();
|
||||||
|
System.out.println("Value of userPass "+userPass);
|
||||||
|
if(userPass.equals("minew123")){
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private ConnectionStatueListener connectionStatueListener = new ConnectionStatueListener() {
|
private ConnectionStatueListener connectionStatueListener = new ConnectionStatueListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -503,8 +544,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
case PASSWORDVALIDATING:
|
case PASSWORDVALIDATING:
|
||||||
Log.e("tag", "PASSWORDVALIDATING");
|
Log.e("tag", "PASSWORDVALIDATING");
|
||||||
Toast.makeText(MainActivity.this, "PASSWORDVALIDATING", Toast.LENGTH_SHORT).show();
|
Toast.makeText(MainActivity.this, "PASSWORDVALIDATING", Toast.LENGTH_SHORT).show();
|
||||||
String password = "minew123";
|
passwordFromUser();
|
||||||
getPasswordListener.getPassword(password);
|
getPasswordListener.getPassword(password);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SYNCHRONIZINGTIME:
|
case SYNCHRONIZINGTIME:
|
||||||
Log.e("tag", "SYNCHRONIZINGTIME");
|
Log.e("tag", "SYNCHRONIZINGTIME");
|
||||||
|
@ -24,10 +24,12 @@
|
|||||||
android:id="@+id/tv_title"
|
android:id="@+id/tv_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="18sp"
|
android:layout_centerInParent="true"
|
||||||
android:textColor="@color/black"
|
|
||||||
android:text="Detail"
|
android:text="Detail"
|
||||||
android:layout_centerInParent="true"/>
|
android:textColor="@color/black"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
@ -148,4 +150,12 @@
|
|||||||
android:layout_marginTop="42dp"
|
android:layout_marginTop="42dp"
|
||||||
android:text="Set trigger"/>
|
android:text="Set trigger"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_resetPass"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="42dp"
|
||||||
|
android:text="Reset password"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
19
app/src/main/res/layout/password_dialog.xml
Normal file
19
app/src/main/res/layout/password_dialog.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edtPass"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:hint="PASSWORD"
|
||||||
|
android:longClickable="false"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
25
app/src/main/res/layout/password_reset.xml
Normal file
25
app/src/main/res/layout/password_reset.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edtPassR"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:hint="PASSWORD"
|
||||||
|
android:longClickable="false"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edtConPassR"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:hint="CONFIRM PASSWORD"
|
||||||
|
android:longClickable="false"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text"
|
||||||
|
android:layout_margin="10dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user