Skip to content

Commit

Permalink
Renamed some classes to make it more redable and added tour guide tut…
Browse files Browse the repository at this point in the history
…orial
  • Loading branch information
israelalagbe committed Jun 4, 2019
1 parent 6561b69 commit fb0109c
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</intent-filter>
</activity>
<activity
android:name=".PinCode"
android:name=".PatternActivity"
android:label="@string/pin_code_activity_name" />
<activity android:name=".CameraActivity" />
<activity
Expand All @@ -58,7 +58,7 @@
</intent-filter>
</receiver>

<activity android:name=".PinCodeAlternative" />
<activity android:name=".PincodeActivity" />
</application>

</manifest>
17 changes: 13 additions & 4 deletions app/src/main/java/wavetech/facelocker/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(){
Expand Down Expand Up @@ -72,7 +74,13 @@ public void onComplete(List<PatternLockView.Dot> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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="";
Expand All @@ -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(){
Expand All @@ -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
Expand All @@ -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();
}
}
13 changes: 11 additions & 2 deletions app/src/main/java/wavetech/facelocker/utils/TourHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_pin_code.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
tools:context=".PinCode">
tools:context=".PatternActivity">

<View
android:id="@+id/opacityFilter"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_pin_code_alternative.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
tools:context=".PinCodeAlternative">
tools:context=".PincodeActivity">

<View
android:id="@+id/opacityFilter"
Expand Down

0 comments on commit fb0109c

Please sign in to comment.