From fb0109c87cd9c3635cd58415da49e5b752aaede8 Mon Sep 17 00:00:00 2001 From: israelalagbe Date: Tue, 4 Jun 2019 12:03:24 +0100 Subject: [PATCH] Renamed some classes to make it more redable and added tour guide tutorial --- app/src/main/AndroidManifest.xml | 4 +-- .../wavetech/facelocker/MainActivity.java | 17 +++++++++--- .../{PinCode.java => PatternActivity.java} | 14 +++++++--- ...eAlternative.java => PincodeActivity.java} | 27 ++++++++++++++----- .../wavetech/facelocker/utils/TourHelper.java | 13 +++++++-- app/src/main/res/layout/activity_pin_code.xml | 2 +- .../layout/activity_pin_code_alternative.xml | 2 +- 7 files changed, 60 insertions(+), 19 deletions(-) rename app/src/main/java/wavetech/facelocker/{PinCode.java => PatternActivity.java} (81%) rename app/src/main/java/wavetech/facelocker/{PinCodeAlternative.java => PincodeActivity.java} (60%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b824b5c..8f17090 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,7 +33,7 @@ - + diff --git a/app/src/main/java/wavetech/facelocker/MainActivity.java b/app/src/main/java/wavetech/facelocker/MainActivity.java index ddcfda9..72037ca 100644 --- a/app/src/main/java/wavetech/facelocker/MainActivity.java +++ b/app/src/main/java/wavetech/facelocker/MainActivity.java @@ -10,19 +10,19 @@ import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.CardView; -import android.text.InputType; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; -import android.widget.Button; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ListView; import android.widget.Switch; import android.widget.Toast; +import com.getkeepsafe.taptargetview.TapTargetView; + import java.util.ArrayList; import at.markushi.ui.CircleButton; @@ -63,6 +63,15 @@ protected void onCreate(Bundle savedInstanceState) { params.height = cardMinimizeHeightPixel; cardView.setLayoutParams(params); } + else { + TourHelper.showTourForView(this,addFaceButton,"Add new Face","Tap this button to add a new face to the database",new TapTargetView.Listener() { // The listener can listen for regular clicks, long clicks or cancels + @Override + public void onTargetClick(TapTargetView view) { + super.onTargetClick(view); // This call is optional + TourHelper.showTourForView(MainActivity.this,clearFacesButton,"Delete Faces","Tap this button to delete existing faces from the database"); + } + }); + } final ArrayAdapter adapter = new ArrayAdapter<>(this, R.layout.activity_listview, faces); @@ -98,7 +107,7 @@ public void onClick(View view) { if(passwordStore.getIsScreenLockEnabled()) startScreenLock(); else - TourHelper.showEnableButtonTour(this,enableLockSwitch,"Enable Button","Tap this button now to enable face locker"); + TourHelper.showTourForView(this,enableLockSwitch,"Enable Switch","Tap this switch now to enable face locker"); askForPermissions(); enableLockSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @@ -166,7 +175,7 @@ else if(passwordStore.hasFace(faceName)){ } private void launchPinCodeActivity(){ - Intent intent=new Intent(MainActivity.this,PinCode.class); + Intent intent=new Intent(MainActivity.this,PatternActivity.class); startActivity(intent); } private void launchCameraActivity(){ diff --git a/app/src/main/java/wavetech/facelocker/PinCode.java b/app/src/main/java/wavetech/facelocker/PatternActivity.java similarity index 81% rename from app/src/main/java/wavetech/facelocker/PinCode.java rename to app/src/main/java/wavetech/facelocker/PatternActivity.java index e63d4f2..aebb8ae 100644 --- a/app/src/main/java/wavetech/facelocker/PinCode.java +++ b/app/src/main/java/wavetech/facelocker/PatternActivity.java @@ -11,12 +11,14 @@ import com.andrognito.patternlockview.PatternLockView; import com.andrognito.patternlockview.listener.PatternLockViewListener; import com.andrognito.patternlockview.utils.PatternLockUtils; +import com.getkeepsafe.taptargetview.TapTargetView; import java.util.List; import wavetech.facelocker.utils.PasswordStore; +import wavetech.facelocker.utils.TourHelper; -public class PinCode extends AppCompatActivity { +public class PatternActivity extends AppCompatActivity { private PatternLockView mPatternLockView; private Button continueButton; private PasswordStore passwordStore; @@ -37,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) { } private void launchAlternativePincodeActivity(){ - Intent intent=new Intent(PinCode.this,PinCodeAlternative.class); + Intent intent=new Intent(PatternActivity.this,PincodeActivity.class); startActivity(intent); } private void initializeListeners(){ @@ -72,7 +74,13 @@ public void onComplete(List pattern) { PatternLockUtils.patternToString(mPatternLockView, pattern)); passwordStore.setPatternCode(PatternLockUtils.patternToString(mPatternLockView, pattern)); continueButton.setVisibility(View.VISIBLE); - + TourHelper.showTourForView(PatternActivity.this,continueButton,"Save button","Click this button now to go to the next stage" ,new TapTargetView.Listener() { // The listener can listen for regular clicks, long clicks or cancels + @Override + public void onTargetClick(TapTargetView view) { + super.onTargetClick(view); // This call is optional + launchAlternativePincodeActivity(); + } + }); } @Override diff --git a/app/src/main/java/wavetech/facelocker/PinCodeAlternative.java b/app/src/main/java/wavetech/facelocker/PincodeActivity.java similarity index 60% rename from app/src/main/java/wavetech/facelocker/PinCodeAlternative.java rename to app/src/main/java/wavetech/facelocker/PincodeActivity.java index 80df6ae..50eb764 100644 --- a/app/src/main/java/wavetech/facelocker/PinCodeAlternative.java +++ b/app/src/main/java/wavetech/facelocker/PincodeActivity.java @@ -9,9 +9,12 @@ import android.widget.Button; import android.widget.EditText; +import com.getkeepsafe.taptargetview.TapTargetView; + import wavetech.facelocker.utils.PasswordStore; +import wavetech.facelocker.utils.TourHelper; -public class PinCodeAlternative extends AppCompatActivity { +public class PincodeActivity extends AppCompatActivity { private EditText pinCodeInput; private Button btnContinue; String pinCodeText=""; @@ -23,6 +26,7 @@ protected void onCreate(Bundle savedInstanceState) { passwordStore= new PasswordStore(getApplicationContext()); pinCodeInput = findViewById(R.id.pinCodeInput); btnContinue=findViewById(R.id.btnContinue); + TourHelper.showTourForView(this,pinCodeInput,"Password","Please enter your password not less than 8 characters"); initializeListeners(); } private void initializeListeners(){ @@ -35,8 +39,16 @@ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { pinCodeText=charSequence.toString(); - if(pinCodeText.length()>=8) + if(pinCodeText.length()>=8){ btnContinue.setVisibility(View.VISIBLE); + TourHelper.showTourForView(PincodeActivity.this,btnContinue,"Save button","Click this button now to go to the next stage" ,new TapTargetView.Listener() { // The listener can listen for regular clicks, long clicks or cancels + @Override + public void onTargetClick(TapTargetView view) { + super.onTargetClick(view); // This call is optional + continueButtonClick(); + } + }); + } } @Override @@ -48,14 +60,17 @@ public void afterTextChanged(Editable editable) { btnContinue.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - passwordStore.setPinCode(pinCodeText); - passwordStore.save(); - launchCameraActivity(); + continueButtonClick(); } }); } private void launchCameraActivity(){ - Intent intent=new Intent(PinCodeAlternative.this,CameraActivity.class); + Intent intent=new Intent(PincodeActivity.this,CameraActivity.class); startActivity(intent); } + private void continueButtonClick(){ + passwordStore.setPinCode(pinCodeText); + passwordStore.save(); + launchCameraActivity(); + } } diff --git a/app/src/main/java/wavetech/facelocker/utils/TourHelper.java b/app/src/main/java/wavetech/facelocker/utils/TourHelper.java index b78f94e..ee53ff9 100644 --- a/app/src/main/java/wavetech/facelocker/utils/TourHelper.java +++ b/app/src/main/java/wavetech/facelocker/utils/TourHelper.java @@ -8,7 +8,16 @@ import com.getkeepsafe.taptargetview.TapTargetView; public class TourHelper { - public static void showEnableButtonTour(Activity context, View targetView, String title, String description){ - TapTargetView.showFor(context,TapTarget.forView(targetView,title,description)); + public static void showTourForView(Activity context, View targetView, String title, String description, TapTargetView.Listener listener){ + TapTargetView.showFor(context, + TapTarget.forView(targetView,title,description) + .transparentTarget(true) + ,listener); + } + public static void showTourForView(Activity context, View targetView, String title, String description){ + TapTargetView.showFor(context, + TapTarget.forView(targetView,title,description) + .transparentTarget(true) + ); } } diff --git a/app/src/main/res/layout/activity_pin_code.xml b/app/src/main/res/layout/activity_pin_code.xml index 0e01a0e..2f2240d 100644 --- a/app/src/main/res/layout/activity_pin_code.xml +++ b/app/src/main/res/layout/activity_pin_code.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background" - tools:context=".PinCode"> + tools:context=".PatternActivity"> + tools:context=".PincodeActivity">