Password reset
This commit is contained in:
		
							parent
							
								
									5e82b320e7
								
							
						
					
					
						commit
						1d27cca48b
					
				
							
								
								
									
										1
									
								
								.idea/.name
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.idea/.name
									
									
									
										generated
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
BeaconDemo
 | 
			
		||||
@ -20,6 +20,8 @@
 | 
			
		||||
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
 | 
			
		||||
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    <application
 | 
			
		||||
        android:allowBackup="true"
 | 
			
		||||
        android:dataExtractionRules="@xml/data_extraction_rules"
 | 
			
		||||
@ -28,7 +30,8 @@
 | 
			
		||||
        android:label="@string/app_name"
 | 
			
		||||
        android:supportsRtl="true"
 | 
			
		||||
        android:theme="@style/Theme.AppCompat.Light"
 | 
			
		||||
        tools:targetApi="31">
 | 
			
		||||
        tools:targetApi="31"
 | 
			
		||||
        tools:replace="android:icon">
 | 
			
		||||
        <activity
 | 
			
		||||
            android:name=".Activity.DetailActivity"
 | 
			
		||||
            android:exported="false" />
 | 
			
		||||
 | 
			
		||||
@ -128,6 +128,20 @@ public class DetailActivity extends AppCompatActivity implements View.OnClickLis
 | 
			
		||||
        positiveButton.setOnClickListener(new View.OnClickListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onClick(View view) {
 | 
			
		||||
                String pass = edtPassR.getText().toString();
 | 
			
		||||
                String conpass = edtConPassR.getText().toString();
 | 
			
		||||
                System.out.println(pass + " " + conpass);
 | 
			
		||||
 | 
			
		||||
                if(pass.equals(conpass) ){
 | 
			
		||||
                    Intent intent = new Intent(DetailActivity.this,MainActivity.class);
 | 
			
		||||
                    intent.putExtra("password",pass);
 | 
			
		||||
                    startActivity(intent);
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                else{
 | 
			
		||||
                    Toast.makeText(DetailActivity.this, "Passwords dont match", Toast.LENGTH_SHORT).show();
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        cancel.setOnClickListener(new View.OnClickListener() {
 | 
			
		||||
 | 
			
		||||
@ -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:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user