From: David A. Velasco Date: Wed, 11 Jul 2012 16:59:59 +0000 (+0200) Subject: Some fixes to PIN code X-Git-Tag: oc-android-1.4.3~288 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/f757b74ced1c8370850bba7fbf97673663197a5e?ds=inline;hp=--cc Some fixes to PIN code --- f757b74ced1c8370850bba7fbf97673663197a5e diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 0372a96e..db414b6b 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -18,7 +18,7 @@ --> + android:versionName="0.1.155B" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/src/eu/alefzero/owncloud/ui/activity/PinCodeActivity.java b/src/eu/alefzero/owncloud/ui/activity/PinCodeActivity.java index bd81913a..d2ad198d 100644 --- a/src/eu/alefzero/owncloud/ui/activity/PinCodeActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/PinCodeActivity.java @@ -21,7 +21,6 @@ import com.actionbarsherlock.app.SherlockFragmentActivity; import eu.alefzero.owncloud.R; -import android.app.ActionBar.LayoutParams; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; @@ -84,14 +83,29 @@ public class PinCodeActivity extends SherlockFragmentActivity { SharedPreferences appPrefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); - // Not PIN Code defined yet - if ( appPrefs.getString("PrefPinCode1", null) == null ){ - setChangePincodeView(); + + // Not PIN Code defined yet. + // In a previous version settings is allow from start + if ( (appPrefs.getString("PrefPinCode1", null) == null ) ){ + setInitView(); pinCodeChecked = true; newPasswordEntered = true; - } else { - setInitView(); + }else if (appPrefs.getBoolean("set_pincode", false)){ + if (activity.equals("preferences")){ + mPinHdr.setText(R.string.pincode_configure_your_pin); + setChangePincodeView(true); + }else{ + bCancel.setVisibility(View.INVISIBLE); + bCancel.setVisibility(View.GONE); + mPinHdr.setText(R.string.pincode_enter_pin_code); + setChangePincodeView(false); + } + + }else { + mPinHdr.setText(R.string.pincode_enter_pin_code); + pinCodeChecked = true; + setChangePincodeView(true); } @@ -107,20 +121,34 @@ public class PinCodeActivity extends SherlockFragmentActivity { mPinHdr.setText(R.string.pincode_enter_pin_code); } - - - protected void setChangePincodeView(){ - mPinHdr.setText(R.string.pincode_configure_your_pin); + + protected void setChangePincodeView(boolean state){ + + if(state){ + bCancel.setVisibility(View.VISIBLE); bCancel.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - finish(); + @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(); + + finish(); } }); + } } + + /* * */ @@ -323,9 +351,7 @@ public class PinCodeActivity extends SherlockFragmentActivity { .getDefaultSharedPreferences(getApplicationContext()).edit(); appPrefs.putBoolean("set_pincode",false); appPrefs.commit(); - // TODO Alert Message que salte y vuelva a la pantalla anterior - - finish(); + pinCodeEnd(false); }else{ @@ -404,37 +430,9 @@ public class PinCodeActivity extends SherlockFragmentActivity { protected void pinCodeChangeRequest(){ - AlertDialog.Builder aBuilder = new AlertDialog.Builder(this); - aBuilder.setMessage("Do yo want to set a new PIN Code") - .setCancelable(false) - .setPositiveButton("Yes", new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - // TODO Auto-generated method stub - setChangePincodeView(); - mPinHdr.setText(R.string.pincode_enter_new_pin_code); - clearBoxes(); - newPasswordEntered = true; - } - }) - .setNegativeButton("No", new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - // TODO Auto-generated method stub - SharedPreferences.Editor appPrefs = PreferenceManager - .getDefaultSharedPreferences(getApplicationContext()).edit(); - appPrefs.putBoolean("set_pincode",false); - appPrefs.commit(); - finish(); - } - }); - - AlertDialog alert =aBuilder.create(); - - alert.show(); - + clearBoxes(); + mPinHdr.setText(R.string.pincode_confirm_your_pincode); + confirmingPinCode =true; } @@ -520,6 +518,31 @@ public class PinCodeActivity extends SherlockFragmentActivity { } + + protected void pinCodeEnd(boolean state){ + AlertDialog aDialog = new AlertDialog.Builder(this).create(); + + if (state){ + aDialog.setTitle("SAVE & EXIT"); + aDialog.setMessage("PIN Code Activated"); + }else{ + aDialog.setTitle("SAVE & EXIT"); + aDialog.setMessage("PIN Code Removed"); + } + + aDialog.setButton("OK", new DialogInterface.OnClickListener(){ + + @Override + public void onClick(DialogInterface dialog, int which) { + // TODO Auto-generated method stub(""); + finish(); + return; + } + + }); + aDialog.show(); + } + protected void savePincodeAndExit(){ SharedPreferences.Editor appPrefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()).edit(); @@ -531,7 +554,10 @@ public class PinCodeActivity extends SherlockFragmentActivity { appPrefs.putBoolean("set_pincode",true); appPrefs.commit(); - finish(); + pinCodeEnd(true); + + + } @@ -543,6 +569,20 @@ public class PinCodeActivity extends SherlockFragmentActivity { mText4.setText(""); mText1.requestFocus(); } + + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event){ + if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount()== 0){ + + + return true; + + } + + return super.onKeyDown(keyCode, event); + } + } diff --git a/src/eu/alefzero/owncloud/ui/activity/Preferences.java b/src/eu/alefzero/owncloud/ui/activity/Preferences.java index ffc13976..e71dbdf0 100644 --- a/src/eu/alefzero/owncloud/ui/activity/Preferences.java +++ b/src/eu/alefzero/owncloud/ui/activity/Preferences.java @@ -22,10 +22,12 @@ import java.util.Vector; import android.accounts.Account; import android.accounts.AccountManager; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; +import android.preference.PreferenceManager; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; import android.util.Log; @@ -54,7 +56,7 @@ import eu.alefzero.owncloud.syncadapter.FileSyncAdapter; * */ public class Preferences extends SherlockPreferenceActivity implements - OnPreferenceChangeListener { + OnPreferenceChangeListener{ private static final String TAG = "OwnCloudPreferences"; private final int mNewSession = 47; private final int mEditSession = 48; @@ -64,6 +66,7 @@ public class Preferences extends SherlockPreferenceActivity implements private ListPreference mAccountList; private ListPreference mTrackingUpdateInterval; private CheckBoxPreference mDeviceTracking; + private CheckBoxPreference pCode; private int mSelectedMenuItem; @Override @@ -86,17 +89,19 @@ public class Preferences extends SherlockPreferenceActivity implements } }); - CheckBoxPreference pCode = (CheckBoxPreference) findPreference("set_pincode"); + pCode = (CheckBoxPreference) findPreference("set_pincode"); + + if (pCode != null){ pCode.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - - + Intent i = new Intent(getApplicationContext(), PinCodeActivity.class); i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "preferences"); i.putExtra(PinCodeActivity.EXTRA_NEW_STATE, newValue.toString()); + startActivity(i); return true; @@ -107,6 +112,21 @@ public class Preferences extends SherlockPreferenceActivity implements } + + @Override + protected void onResume() { + // TODO Auto-generated method stub + SharedPreferences appPrefs = PreferenceManager + .getDefaultSharedPreferences(getApplicationContext()); + + boolean state = appPrefs.getBoolean("set_pincode", false); + pCode.setChecked(state); + + super.onResume(); + } + + + /** * Populates the account selector */ @@ -133,6 +153,8 @@ public class Preferences extends SherlockPreferenceActivity implements mAccountList.setEntryValues(accNames); } + + @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); @@ -185,6 +207,8 @@ public class Preferences extends SherlockPreferenceActivity implements super.onDestroy(); } + + @Override /** * Updates various summaries after updates. Also starts and stops @@ -213,8 +237,10 @@ public class Preferences extends SherlockPreferenceActivity implements locationServiceIntent.putExtra("TRACKING_SETTING", (Boolean) newValue); sendBroadcast(locationServiceIntent); - } + } return true; } + + }