mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
Better policy to show PIN Code
This commit is contained in:
parent
271a4ba1df
commit
3e4f8b4f0d
6 changed files with 96 additions and 84 deletions
|
@ -18,7 +18,7 @@
|
|||
-->
|
||||
<manifest package="eu.alefzero.owncloud"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.1.152B" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:versionName="0.1.153B" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||
|
|
|
@ -1,63 +1,63 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
ownCloud Android client application
|
||||
|
||||
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/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:oc="http://schemas.android.com/apk/res/eu.alefzero.owncloud"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp" >
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pinHdr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Enter pin code"
|
||||
android:textColor="@android:color/black"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt1"
|
||||
android:focusable="true"
|
||||
style="@style/PassCodeStyle" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt2"
|
||||
style="@style/PassCodeStyle" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt3"
|
||||
style="@style/PassCodeStyle" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt4"
|
||||
style="@style/PassCodeStyle" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Cancel"
|
||||
android:textColor="@android:color/black"
|
||||
android:id="@+id/cancel"/>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
ownCloud Android client application
|
||||
|
||||
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/>.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:oc="http://schemas.android.com/apk/res/eu.alefzero.owncloud"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:padding="20dp" >
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pinHdr"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pincode_enter_pin_code"
|
||||
android:textColor="@android:color/black"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal" >
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt1"
|
||||
android:focusable="true"
|
||||
style="@style/PassCodeStyle" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt2"
|
||||
style="@style/PassCodeStyle" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt3"
|
||||
style="@style/PassCodeStyle" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt4"
|
||||
style="@style/PassCodeStyle" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@android:string/cancel"
|
||||
android:textColor="@android:color/black"
|
||||
android:id="@+id/cancel"/>
|
||||
</LinearLayout>
|
|
@ -75,6 +75,8 @@
|
|||
<string name="use_ssl">Use Secure Connection</string>
|
||||
<string name="location_no_provider">ownCloud cannot track your device. Please check your location settings</string>
|
||||
|
||||
<string name="pincode_enter_pin_code">Enter pin code</string>
|
||||
|
||||
<string-array name="prefs_trackmydevice_intervall_keys">
|
||||
<item>15 Minutes</item>
|
||||
<item>30 Minutes</item>
|
||||
|
|
|
@ -131,18 +131,13 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
|
|||
|
||||
initDelayedTilAccountAvailabe();
|
||||
|
||||
// PIN CODE request
|
||||
// best location is to decide; let's try this first
|
||||
boolean pinStart = false;
|
||||
SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
pinStart = appPrefs.getBoolean("set_passcode", false);
|
||||
|
||||
if (pinStart) {
|
||||
Intent i = new Intent(getApplicationContext(), PinCodeActivity.class);
|
||||
i.putExtra("activity", "splash");
|
||||
startActivity(i);
|
||||
// PIN CODE request ; best location is to decide, let's try this first
|
||||
//if (savedInstanceState == null) {
|
||||
if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) {
|
||||
requestPinCode();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
setContentView(R.layout.no_account_available);
|
||||
|
@ -769,6 +764,21 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Launch an intent to request the PIN code to the user before letting him use the app
|
||||
*/
|
||||
private void requestPinCode() {
|
||||
boolean pinStart = false;
|
||||
SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
pinStart = appPrefs.getBoolean("set_pincode", false);
|
||||
if (pinStart) {
|
||||
Intent i = new Intent(getApplicationContext(), PinCodeActivity.class);
|
||||
i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "FileDisplayActivity");
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@ import android.widget.TextView;
|
|||
public class PinCodeActivity extends SherlockFragmentActivity {
|
||||
|
||||
|
||||
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";
|
||||
|
||||
Button bCancel;
|
||||
TextView mPinHdr;
|
||||
|
@ -66,7 +68,7 @@ public class PinCodeActivity extends SherlockFragmentActivity {
|
|||
setContentView(R.layout.pincodelock);
|
||||
|
||||
Intent intent = getIntent();
|
||||
activity = intent.getStringExtra("activity");
|
||||
activity = intent.getStringExtra(EXTRA_ACTIVITY);
|
||||
|
||||
bCancel = (Button) findViewById(R.id.cancel);
|
||||
mPinHdr = (TextView) findViewById(R.id.pinHdr);
|
||||
|
@ -111,7 +113,6 @@ public class PinCodeActivity extends SherlockFragmentActivity {
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
@ -296,7 +297,7 @@ public class PinCodeActivity extends SherlockFragmentActivity {
|
|||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before,
|
||||
int count) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (s.length() > 0) {
|
||||
|
||||
if (!confirmingPinCode){
|
||||
|
@ -308,33 +309,31 @@ public class PinCodeActivity extends SherlockFragmentActivity {
|
|||
pinCodeChecked = checkPincode();
|
||||
}
|
||||
|
||||
if (pinCodeChecked && activity.equals("splash")){
|
||||
if (pinCodeChecked && activity.equals("FileDisplayActivity")){
|
||||
finish();
|
||||
} else if (pinCodeChecked){
|
||||
|
||||
Intent intent = getIntent();
|
||||
String newState = intent.getStringExtra("pinNewState");
|
||||
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();
|
||||
|
||||
// TODO Alert Message que salte y vuelva a la pantalla anterior
|
||||
|
||||
finish();
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
if (!confirmingPinCode && !newPasswordEntered){
|
||||
pinCodeChangeRequest();
|
||||
}else if (newPasswordEntered && !confirmingPinCode){
|
||||
} else if (newPasswordEntered && !confirmingPinCode){
|
||||
mPinHdr.setText("Confirm your PINCode, please");
|
||||
confirmingPinCode = true;
|
||||
clearBoxes();
|
||||
}else {
|
||||
} else {
|
||||
confirmPincode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import eu.alefzero.owncloud.OwnCloudSession;
|
|||
import eu.alefzero.owncloud.R;
|
||||
import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
|
||||
import eu.alefzero.owncloud.db.DbHandler;
|
||||
import eu.alefzero.owncloud.syncadapter.FileSyncAdapter;
|
||||
|
||||
/**
|
||||
* An Activity that allows the user to change the application's settings.
|
||||
|
@ -94,8 +95,8 @@ public class Preferences extends SherlockPreferenceActivity implements
|
|||
|
||||
|
||||
Intent i = new Intent(getApplicationContext(), PinCodeActivity.class);
|
||||
i.putExtra("activity", "preferences");
|
||||
i.putExtra("pinNewState",newValue.toString());
|
||||
i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "preferences");
|
||||
i.putExtra(PinCodeActivity.EXTRA_NEW_STATE, newValue.toString());
|
||||
startActivity(i);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue