When the PATTERN screen request is incorrect show message to user
This commit is contained in:
parent
0019385827
commit
4743042c7e
2 changed files with 59 additions and 2 deletions
|
@ -1,18 +1,24 @@
|
|||
package cy.agorise.crystalwallet.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.arch.lifecycle.LiveData;
|
||||
import android.arch.lifecycle.Observer;
|
||||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.andrognito.patternlockview.PatternLockView;
|
||||
import com.andrognito.patternlockview.listener.PatternLockViewListener;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
@ -24,8 +30,15 @@ import cy.agorise.crystalwallet.util.PasswordManager;
|
|||
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
|
||||
|
||||
public class PatternRequestActivity extends AppCompatActivity {
|
||||
|
||||
private String patternEncrypted;
|
||||
|
||||
@BindView(R.id.tvPatternText)
|
||||
TextView tvPatternText;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//Do nothing to prevent the user to use the back button
|
||||
|
@ -34,6 +47,7 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
@BindView(R.id.patternLockView)
|
||||
PatternLockView patternLockView;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -77,8 +91,7 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
thisActivity.finish();
|
||||
}
|
||||
} else {
|
||||
patternLockView.clearPattern();
|
||||
patternLockView.requestFocus();
|
||||
incorrect();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +109,41 @@ public class PatternRequestActivity extends AppCompatActivity {
|
|||
});
|
||||
}
|
||||
|
||||
private void incorrect(){
|
||||
|
||||
/*
|
||||
* Show error
|
||||
* */
|
||||
final Activity activity = this;
|
||||
tvPatternText.setText(activity.getResources().getString(R.string.Incorrect_pattern));
|
||||
tvPatternText.setTextColor(Color.RED);
|
||||
tvPatternText.setVisibility(View.VISIBLE);
|
||||
final Timer t = new Timer();
|
||||
t.scheduleAtFixedRate(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
t.cancel();
|
||||
tvPatternText.setVisibility(View.INVISIBLE);
|
||||
patternLockView.clearPattern();
|
||||
patternLockView.requestFocus();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
//Set how long before to start calling the TimerTask (in milliseconds)
|
||||
1000,
|
||||
//Set the amount of time between each execution (in milliseconds)
|
||||
1000);
|
||||
}
|
||||
|
||||
public String patternToString(List<PatternLockView.Dot> pattern){
|
||||
String patternString = "";
|
||||
for (PatternLockView.Dot nextDot : pattern){
|
||||
|
|
|
@ -5,6 +5,15 @@
|
|||
android:orientation="vertical"
|
||||
android:background="@drawable/gradient">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPatternText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:visibility="invisible"
|
||||
android:layout_marginTop="25dp"/>
|
||||
|
||||
<com.andrognito.patternlockview.PatternLockView
|
||||
android:id="@+id/patternLockView"
|
||||
android:layout_width="280dp"
|
||||
|
|
Loading…
Reference in a new issue