2012-07-09 13:11:44 +04:00
|
|
|
/* ownCloud Android client application
|
|
|
|
* Copyright (C) 2011 Bartek Przybylski
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package eu.alefzero.owncloud.ui.activity;
|
|
|
|
|
2012-07-16 14:59:25 +04:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
2012-07-09 13:11:44 +04:00
|
|
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|
|
|
|
|
|
|
import eu.alefzero.owncloud.R;
|
|
|
|
|
2012-07-17 17:16:27 +04:00
|
|
|
|
2012-07-09 13:11:44 +04:00
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
2012-07-17 17:16:27 +04:00
|
|
|
import android.graphics.Typeface;
|
2012-07-09 13:11:44 +04:00
|
|
|
import android.os.Bundle;
|
2012-07-17 17:16:27 +04:00
|
|
|
import android.os.Handler;
|
2012-07-09 13:11:44 +04:00
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
import android.text.Editable;
|
2012-07-17 17:16:27 +04:00
|
|
|
import android.text.InputType;
|
2012-07-09 13:11:44 +04:00
|
|
|
import android.text.TextWatcher;
|
2012-07-17 17:16:27 +04:00
|
|
|
import android.text.method.PasswordTransformationMethod;
|
2012-07-09 13:11:44 +04:00
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.View.OnClickListener;
|
|
|
|
import android.view.View.OnFocusChangeListener;
|
|
|
|
import android.view.View.OnKeyListener;
|
2012-07-17 17:16:27 +04:00
|
|
|
import android.view.ViewGroup;
|
2012-07-09 13:11:44 +04:00
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.EditText;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
|
|
public class PinCodeActivity extends SherlockFragmentActivity {
|
|
|
|
|
|
|
|
|
2012-07-09 17:10:26 +04:00
|
|
|
public final static String EXTRA_ACTIVITY = "eu.alefzero.owncloud.ui.activity.PinCodeActivity.ACTIVITY";
|
|
|
|
public final static String EXTRA_NEW_STATE = "eu.alefzero.owncloud.ui.activity.PinCodeActivity.NEW_STATE";
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
Button bCancel;
|
|
|
|
TextView mPinHdr;
|
|
|
|
EditText mText1;
|
|
|
|
EditText mText2;
|
|
|
|
EditText mText3;
|
|
|
|
EditText mText4;
|
|
|
|
|
|
|
|
String [] tempText ={"","","",""};
|
|
|
|
|
|
|
|
String activity;
|
|
|
|
|
|
|
|
boolean confirmingPinCode = false;
|
|
|
|
boolean pinCodeChecked = false;
|
|
|
|
boolean newPasswordEntered = false;
|
|
|
|
boolean bChange = true; // to control that only one blocks jump
|
2012-07-13 16:46:40 +04:00
|
|
|
int tCounter ; // Count the number of attempts an user could introduce the PIN code
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.pincodelock);
|
|
|
|
|
|
|
|
Intent intent = getIntent();
|
2012-07-09 17:10:26 +04:00
|
|
|
activity = intent.getStringExtra(EXTRA_ACTIVITY);
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
bCancel = (Button) findViewById(R.id.cancel);
|
|
|
|
mPinHdr = (TextView) findViewById(R.id.pinHdr);
|
|
|
|
mText1 = (EditText) findViewById(R.id.txt1);
|
|
|
|
mText1.requestFocus();
|
2012-07-17 17:16:27 +04:00
|
|
|
getWindow().setSoftInputMode(android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
2012-07-09 13:11:44 +04:00
|
|
|
mText2 = (EditText) findViewById(R.id.txt2);
|
|
|
|
mText3 = (EditText) findViewById(R.id.txt3);
|
|
|
|
mText4 = (EditText) findViewById(R.id.txt4);
|
|
|
|
|
|
|
|
|
2012-07-17 17:16:27 +04:00
|
|
|
|
2012-07-09 13:11:44 +04:00
|
|
|
SharedPreferences appPrefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext());
|
|
|
|
|
2012-07-11 20:59:59 +04:00
|
|
|
|
|
|
|
// Not PIN Code defined yet.
|
|
|
|
// In a previous version settings is allow from start
|
|
|
|
if ( (appPrefs.getString("PrefPinCode1", null) == null ) ){
|
2012-07-23 16:53:46 +04:00
|
|
|
setChangePincodeView(true);
|
2012-07-09 13:11:44 +04:00
|
|
|
pinCodeChecked = true;
|
|
|
|
newPasswordEntered = true;
|
|
|
|
|
2012-07-13 16:46:40 +04:00
|
|
|
}else{
|
2012-07-11 20:59:59 +04:00
|
|
|
|
2012-07-13 16:46:40 +04:00
|
|
|
if (appPrefs.getBoolean("set_pincode", false)){
|
|
|
|
// pincode activated
|
|
|
|
if (activity.equals("preferences")){
|
|
|
|
// PIN has been activated yet
|
|
|
|
mPinHdr.setText(R.string.pincode_configure_your_pin);
|
|
|
|
pinCodeChecked = true ; // No need to check it
|
|
|
|
setChangePincodeView(true);
|
|
|
|
}else{
|
|
|
|
// PIN active
|
|
|
|
bCancel.setVisibility(View.INVISIBLE);
|
|
|
|
bCancel.setVisibility(View.GONE);
|
|
|
|
mPinHdr.setText(R.string.pincode_enter_pin_code);
|
|
|
|
setChangePincodeView(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}else {
|
|
|
|
// pincode removal
|
2012-07-17 17:16:27 +04:00
|
|
|
mPinHdr.setText(R.string.pincode_remove_your_pincode);
|
2012-07-13 16:46:40 +04:00
|
|
|
pinCodeChecked = false;
|
|
|
|
setChangePincodeView(true);
|
|
|
|
}
|
2012-07-09 13:11:44 +04:00
|
|
|
|
2012-07-13 16:46:40 +04:00
|
|
|
}
|
2012-07-09 13:11:44 +04:00
|
|
|
setTextListeners();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2012-07-17 17:16:27 +04:00
|
|
|
|
|
|
|
|
2012-07-13 16:46:40 +04:00
|
|
|
|
|
|
|
protected void setInitVars(){
|
|
|
|
confirmingPinCode = false;
|
|
|
|
pinCodeChecked = false;
|
|
|
|
newPasswordEntered = false;
|
|
|
|
|
|
|
|
}
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
protected void setInitView(){
|
|
|
|
bCancel.setVisibility(View.INVISIBLE);
|
|
|
|
bCancel.setVisibility(View.GONE);
|
2012-07-09 17:19:44 +04:00
|
|
|
mPinHdr.setText(R.string.pincode_enter_pin_code);
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
|
2012-07-11 20:59:59 +04:00
|
|
|
|
|
|
|
protected void setChangePincodeView(boolean state){
|
|
|
|
|
|
|
|
if(state){
|
|
|
|
bCancel.setVisibility(View.VISIBLE);
|
2012-07-09 13:11:44 +04:00
|
|
|
bCancel.setOnClickListener(new OnClickListener() {
|
2012-07-11 20:59:59 +04:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
|
|
|
SharedPreferences.Editor appPrefsE = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext()).edit();
|
|
|
|
|
|
|
|
SharedPreferences appPrefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext());
|
|
|
|
|
|
|
|
boolean state = appPrefs.getBoolean("set_pincode", false);
|
|
|
|
appPrefsE.putBoolean("set_pincode",!state);
|
|
|
|
appPrefsE.commit();
|
2012-07-13 16:46:40 +04:00
|
|
|
setInitVars();
|
2012-07-11 20:59:59 +04:00
|
|
|
finish();
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
});
|
2012-07-11 20:59:59 +04:00
|
|
|
}
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-07-11 20:59:59 +04:00
|
|
|
|
|
|
|
|
2012-07-09 13:11:44 +04:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
protected void setTextListeners(){
|
|
|
|
|
|
|
|
/*------------------------------------------------
|
|
|
|
* FIRST BOX
|
|
|
|
-------------------------------------------------*/
|
|
|
|
|
|
|
|
mText1.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before,
|
|
|
|
int count) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
|
|
|
int after) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
2012-07-26 15:08:14 +04:00
|
|
|
if (s.length() > 0) {
|
|
|
|
if (!confirmingPinCode){
|
|
|
|
tempText[0] = mText1.getText().toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
mText2.requestFocus();
|
|
|
|
}
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------
|
|
|
|
* SECOND BOX
|
|
|
|
-------------------------------------------------*/
|
|
|
|
mText2.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before,
|
|
|
|
int count) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
|
|
|
int after) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
2012-07-26 15:08:14 +04:00
|
|
|
if (s.length() > 0) {
|
|
|
|
if (!confirmingPinCode){
|
|
|
|
tempText[1] = mText2.getText().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
mText3.requestFocus();
|
|
|
|
}
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mText2.setOnKeyListener(new OnKeyListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DEL && bChange) {
|
|
|
|
|
|
|
|
mText1.setText("");
|
|
|
|
mText1.requestFocus();
|
2012-07-16 14:59:25 +04:00
|
|
|
if (!confirmingPinCode)
|
|
|
|
tempText[0] = "";
|
2012-07-09 13:11:44 +04:00
|
|
|
bChange= false;
|
|
|
|
|
|
|
|
}else if(!bChange){
|
|
|
|
bChange=true;
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mText2.setOnFocusChangeListener(new OnFocusChangeListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFocusChange(View v, boolean hasFocus) {
|
|
|
|
// TODO Auto-generated method stub
|
2012-07-17 17:16:27 +04:00
|
|
|
|
2012-07-19 13:51:05 +04:00
|
|
|
mText2.setCursorVisible(true);
|
2012-07-09 13:11:44 +04:00
|
|
|
if (mText1.getText().toString().equals("")){
|
2012-07-19 13:51:05 +04:00
|
|
|
mText2.setSelected(false);
|
|
|
|
mText2.setCursorVisible(false);
|
2012-07-09 13:11:44 +04:00
|
|
|
mText1.requestFocus();
|
2012-07-19 13:51:05 +04:00
|
|
|
mText1.setSelected(true);
|
|
|
|
mText1.setSelection(0);
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------
|
|
|
|
* THIRD BOX
|
|
|
|
-------------------------------------------------*/
|
|
|
|
mText3.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before,
|
|
|
|
int count) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
|
|
|
int after) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
2012-07-26 15:08:14 +04:00
|
|
|
if (s.length() > 0) {
|
|
|
|
if (!confirmingPinCode){
|
|
|
|
tempText[2] = mText3.getText().toString();
|
|
|
|
}
|
|
|
|
mText4.requestFocus();
|
|
|
|
}
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mText3.setOnKeyListener(new OnKeyListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DEL && bChange) {
|
|
|
|
mText2.requestFocus();
|
2012-07-16 14:59:25 +04:00
|
|
|
if (!confirmingPinCode)
|
|
|
|
tempText[1] = "";
|
2012-07-09 13:11:44 +04:00
|
|
|
mText2.setText("");
|
|
|
|
bChange= false;
|
|
|
|
|
|
|
|
}else if(!bChange){
|
|
|
|
bChange=true;
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mText3.setOnFocusChangeListener(new OnFocusChangeListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFocusChange(View v, boolean hasFocus) {
|
|
|
|
// TODO Auto-generated method stub
|
2012-07-19 13:51:05 +04:00
|
|
|
mText3.setCursorVisible(true);
|
2012-07-09 13:11:44 +04:00
|
|
|
if (mText1.getText().toString().equals("")){
|
2012-07-19 13:51:05 +04:00
|
|
|
mText3.setSelected(false);
|
|
|
|
mText3.setCursorVisible(false);
|
|
|
|
mText1.requestFocus();
|
|
|
|
mText1.setSelected(true);
|
|
|
|
mText1.setSelection(0);
|
2012-07-09 13:11:44 +04:00
|
|
|
}else if (mText2.getText().toString().equals("")){
|
2012-07-19 13:51:05 +04:00
|
|
|
mText3.setSelected(false);
|
|
|
|
mText3.setCursorVisible(false);
|
|
|
|
mText2.requestFocus();
|
|
|
|
mText2.setSelected(true);
|
|
|
|
mText2.setSelection(0);
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/*------------------------------------------------
|
|
|
|
* FOURTH BOX
|
|
|
|
-------------------------------------------------*/
|
|
|
|
mText4.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before,
|
|
|
|
int count) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
|
|
|
int after) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable s) {
|
2012-07-26 15:08:14 +04:00
|
|
|
if (s.length() > 0) {
|
|
|
|
|
|
|
|
if (!confirmingPinCode){
|
|
|
|
tempText[3] = mText4.getText().toString();
|
|
|
|
}
|
|
|
|
mText1.requestFocus();
|
2012-07-09 13:11:44 +04:00
|
|
|
|
2012-07-26 15:08:14 +04:00
|
|
|
if (!pinCodeChecked){
|
|
|
|
pinCodeChecked = checkPincode();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pinCodeChecked && activity.equals("FileDisplayActivity")){
|
|
|
|
finish();
|
|
|
|
} else if (pinCodeChecked){
|
|
|
|
|
|
|
|
Intent intent = getIntent();
|
|
|
|
String newState = intent.getStringExtra(EXTRA_NEW_STATE);
|
|
|
|
|
|
|
|
if (newState.equals("false")){
|
|
|
|
SharedPreferences.Editor appPrefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext()).edit();
|
|
|
|
appPrefs.putBoolean("set_pincode",false);
|
|
|
|
appPrefs.commit();
|
|
|
|
|
|
|
|
setInitVars();
|
|
|
|
pinCodeEnd(false);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
if (!confirmingPinCode){
|
|
|
|
pinCodeChangeRequest();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
confirmPincode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mText4.setOnKeyListener(new OnKeyListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DEL && bChange) {
|
|
|
|
mText3.requestFocus();
|
2012-07-16 14:59:25 +04:00
|
|
|
if (!confirmingPinCode)
|
|
|
|
tempText[2]="";
|
2012-07-09 13:11:44 +04:00
|
|
|
mText3.setText("");
|
|
|
|
bChange= false;
|
|
|
|
|
|
|
|
}else if(!bChange){
|
|
|
|
bChange=true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mText4.setOnFocusChangeListener(new OnFocusChangeListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFocusChange(View v, boolean hasFocus) {
|
|
|
|
// TODO Auto-generated method stub
|
2012-07-19 13:51:05 +04:00
|
|
|
|
|
|
|
mText4.setCursorVisible(true);
|
|
|
|
|
2012-07-09 13:11:44 +04:00
|
|
|
if (mText1.getText().toString().equals("")){
|
2012-07-19 13:51:05 +04:00
|
|
|
mText4.setSelected(false);
|
|
|
|
mText4.setCursorVisible(false);
|
|
|
|
mText1.requestFocus();
|
|
|
|
mText1.setSelected(true);
|
|
|
|
mText1.setSelection(0);
|
2012-07-09 13:11:44 +04:00
|
|
|
}else if (mText2.getText().toString().equals("")){
|
2012-07-19 13:51:05 +04:00
|
|
|
mText4.setSelected(false);
|
|
|
|
mText4.setCursorVisible(false);
|
|
|
|
mText2.requestFocus();
|
|
|
|
mText2.setSelected(true);
|
|
|
|
mText2.setSelection(0);
|
2012-07-09 13:11:44 +04:00
|
|
|
}else if (mText3.getText().toString().equals("")){
|
2012-07-19 13:51:05 +04:00
|
|
|
mText4.setSelected(false);
|
|
|
|
mText4.setCursorVisible(false);
|
|
|
|
mText3.requestFocus();
|
|
|
|
mText3.setSelected(true);
|
|
|
|
mText3.setSelection(0);
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // end setTextListener
|
|
|
|
|
|
|
|
|
|
|
|
protected void pinCodeChangeRequest(){
|
|
|
|
|
2012-07-11 20:59:59 +04:00
|
|
|
clearBoxes();
|
2012-07-13 16:46:40 +04:00
|
|
|
mPinHdr.setText(R.string.pincode_reenter_your_pincode);
|
2012-07-11 20:59:59 +04:00
|
|
|
confirmingPinCode =true;
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean checkPincode(){
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences appPrefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext());
|
|
|
|
|
|
|
|
String pText1 = appPrefs.getString("PrefPinCode1", null);
|
|
|
|
String pText2 = appPrefs.getString("PrefPinCode2", null);
|
|
|
|
String pText3 = appPrefs.getString("PrefPinCode3", null);
|
|
|
|
String pText4 = appPrefs.getString("PrefPinCode4", null);
|
|
|
|
|
|
|
|
if ( tempText[0].equals(pText1) &&
|
|
|
|
tempText[1].equals(pText2) &&
|
|
|
|
tempText[2].equals(pText3) &&
|
|
|
|
tempText[3].equals(pText4) ) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
}else {
|
2012-07-16 14:59:25 +04:00
|
|
|
Arrays.fill(tempText, null);
|
2012-07-09 13:11:44 +04:00
|
|
|
AlertDialog aDialog = new AlertDialog.Builder(this).create();
|
2012-07-17 17:16:27 +04:00
|
|
|
CharSequence errorSeq = getString(R.string.common_error);
|
|
|
|
aDialog.setTitle(errorSeq);
|
2012-07-13 16:46:40 +04:00
|
|
|
CharSequence cseq = getString(R.string.pincode_wrong);
|
|
|
|
aDialog.setMessage(cseq);
|
2012-07-17 17:16:27 +04:00
|
|
|
CharSequence okSeq = getString(R.string.common_ok);
|
|
|
|
aDialog.setButton(okSeq, new DialogInterface.OnClickListener(){
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
// TODO Auto-generated method stub("");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
aDialog.show();
|
|
|
|
clearBoxes();
|
2012-07-13 16:46:40 +04:00
|
|
|
mPinHdr.setText(R.string.pincode_enter_pin_code);
|
2012-07-09 13:11:44 +04:00
|
|
|
newPasswordEntered = true;
|
|
|
|
confirmingPinCode = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void confirmPincode(){
|
|
|
|
|
|
|
|
confirmingPinCode = false;
|
|
|
|
|
|
|
|
String rText1 = mText1.getText().toString();
|
|
|
|
String rText2 = mText2.getText().toString();
|
|
|
|
String rText3 = mText3.getText().toString();
|
|
|
|
String rText4 = mText4.getText().toString();
|
|
|
|
|
|
|
|
if ( tempText[0].equals(rText1) &&
|
|
|
|
tempText[1].equals(rText2) &&
|
|
|
|
tempText[2].equals(rText3) &&
|
|
|
|
tempText[3].equals(rText4) ) {
|
|
|
|
|
|
|
|
savePincodeAndExit();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2012-07-16 14:59:25 +04:00
|
|
|
Arrays.fill(tempText, null);
|
2012-07-09 13:11:44 +04:00
|
|
|
AlertDialog aDialog = new AlertDialog.Builder(this).create();
|
2012-07-17 17:16:27 +04:00
|
|
|
CharSequence errorSeq = getString(R.string.common_error);
|
|
|
|
aDialog.setTitle(errorSeq);
|
2012-07-13 16:46:40 +04:00
|
|
|
CharSequence cseq = getString(R.string.pincode_mismatch);
|
|
|
|
aDialog.setMessage(cseq);
|
2012-07-17 17:16:27 +04:00
|
|
|
CharSequence okSeq = getString(R.string.common_ok);
|
|
|
|
aDialog.setButton(okSeq, new DialogInterface.OnClickListener(){
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
// TODO Auto-generated method stub("");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
aDialog.show();
|
2012-07-09 17:19:44 +04:00
|
|
|
mPinHdr.setText(R.string.pincode_configure_your_pin);
|
2012-07-09 13:11:44 +04:00
|
|
|
clearBoxes();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-07-11 20:59:59 +04:00
|
|
|
|
|
|
|
protected void pinCodeEnd(boolean state){
|
|
|
|
AlertDialog aDialog = new AlertDialog.Builder(this).create();
|
|
|
|
|
|
|
|
if (state){
|
2012-07-17 17:16:27 +04:00
|
|
|
CharSequence saveSeq = getString(R.string.common_save_exit);
|
|
|
|
aDialog.setTitle(saveSeq);
|
|
|
|
CharSequence cseq = getString(R.string.pincode_stored);
|
|
|
|
aDialog.setMessage(cseq);
|
|
|
|
|
2012-07-11 20:59:59 +04:00
|
|
|
}else{
|
2012-07-17 17:16:27 +04:00
|
|
|
CharSequence saveSeq = getString(R.string.common_save_exit);
|
|
|
|
aDialog.setTitle(saveSeq);
|
|
|
|
CharSequence cseq = getString(R.string.pincode_removed);
|
|
|
|
aDialog.setMessage(cseq);
|
|
|
|
|
2012-07-11 20:59:59 +04:00
|
|
|
}
|
2012-07-17 17:16:27 +04:00
|
|
|
CharSequence okSeq = getString(R.string.common_ok);
|
|
|
|
aDialog.setButton(okSeq, new DialogInterface.OnClickListener(){
|
2012-07-11 20:59:59 +04:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
// TODO Auto-generated method stub("");
|
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
aDialog.show();
|
|
|
|
}
|
|
|
|
|
2012-07-09 13:11:44 +04:00
|
|
|
protected void savePincodeAndExit(){
|
|
|
|
SharedPreferences.Editor appPrefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext()).edit();
|
|
|
|
|
|
|
|
appPrefs.putString("PrefPinCode1", tempText[0]);
|
|
|
|
appPrefs.putString("PrefPinCode2",tempText[1]);
|
|
|
|
appPrefs.putString("PrefPinCode3", tempText[2]);
|
|
|
|
appPrefs.putString("PrefPinCode4", tempText[3]);
|
|
|
|
appPrefs.putBoolean("set_pincode",true);
|
|
|
|
appPrefs.commit();
|
|
|
|
|
2012-07-11 20:59:59 +04:00
|
|
|
pinCodeEnd(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-09 13:11:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void clearBoxes(){
|
|
|
|
|
|
|
|
mText1.setText("");
|
|
|
|
mText2.setText("");
|
|
|
|
mText3.setText("");
|
|
|
|
mText4.setText("");
|
|
|
|
mText1.requestFocus();
|
|
|
|
}
|
2012-07-11 20:59:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event){
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount()== 0){
|
|
|
|
|
2012-07-13 16:46:40 +04:00
|
|
|
if (activity.equals("preferences")){
|
|
|
|
SharedPreferences.Editor appPrefsE = PreferenceManager
|
|
|
|
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext()).edit();
|
|
|
|
|
|
|
|
SharedPreferences appPrefs = PreferenceManager
|
|
|
|
.getDefaultSharedPreferences(getApplicationContext());
|
2012-07-11 20:59:59 +04:00
|
|
|
|
2012-07-13 16:46:40 +04:00
|
|
|
boolean state = appPrefs.getBoolean("set_pincode", false);
|
|
|
|
appPrefsE.putBoolean("set_pincode",!state);
|
|
|
|
appPrefsE.commit();
|
|
|
|
setInitVars();
|
|
|
|
finish();
|
|
|
|
}
|
2012-07-11 20:59:59 +04:00
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
}
|
|
|
|
|
2012-07-17 17:16:27 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-09 13:11:44 +04:00
|
|
|
|
|
|
|
}
|