Merge pull request #390 from LizardWithHat/reauthenticate_after_inactivity
added ability to ask for reauthentification after device inactivity
This commit is contained in:
commit
e7748e7979
5 changed files with 67 additions and 0 deletions
|
@ -33,6 +33,7 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -108,6 +109,8 @@ public class MainActivity extends BaseActivity
|
|||
private ActionBarDrawerToggle tagsToggle;
|
||||
private String filterString;
|
||||
|
||||
private CountDownTimer countDownTimer;
|
||||
|
||||
// QR code scanning
|
||||
private void scanQRCode(){
|
||||
new IntentIntegrator(MainActivity.this)
|
||||
|
@ -353,6 +356,8 @@ public class MainActivity extends BaseActivity
|
|||
}
|
||||
checkIntent();
|
||||
}
|
||||
|
||||
if(setCountDownTimerNow()) countDownTimer.start();
|
||||
}
|
||||
|
||||
if (filterString != null) {
|
||||
|
@ -378,6 +383,7 @@ public class MainActivity extends BaseActivity
|
|||
});
|
||||
super.onPause();
|
||||
stopUpdater();
|
||||
countDownTimer.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -751,6 +757,32 @@ public class MainActivity extends BaseActivity
|
|||
adapter.filterByTags(tagsDrawerAdapter.getActiveTags());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserInteraction(){
|
||||
super.onUserInteraction();
|
||||
|
||||
// Refresh Blackout Timer
|
||||
if(countDownTimer != null) countDownTimer.cancel();
|
||||
if(setCountDownTimerNow()) countDownTimer.start();
|
||||
}
|
||||
|
||||
private boolean setCountDownTimerNow() {
|
||||
int secondsToBlackout = 1000 * settings.getAuthInactivityDelay();
|
||||
if(settings.getAuthMethod() == AuthMethod.NONE || !settings.getAuthInactivity() || secondsToBlackout == 0 ) return false;
|
||||
countDownTimer = new CountDownTimer(secondsToBlackout, 1000) {
|
||||
@Override
|
||||
public void onTick(long millisUntilFinished) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
authenticate(R.string.auth_msg_authenticate);
|
||||
this.cancel();
|
||||
}
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
private void openFileWithPermissions(int intentId){
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
showOpenFileSelector(intentId);
|
||||
|
@ -778,6 +810,7 @@ public class MainActivity extends BaseActivity
|
|||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
}
|
||||
|
||||
private void addQRCode(String result){
|
||||
if(!TextUtils.isEmpty(result)) {
|
||||
try {
|
||||
|
|
|
@ -546,6 +546,14 @@ public class Settings {
|
|||
public boolean getIsAppendingDateTimeToBackups() {
|
||||
return getBoolean(R.string.settings_key_backup_append_date_time, false);
|
||||
}
|
||||
|
||||
public int getAuthInactivityDelay() {
|
||||
return getIntValue(R.string.settings_key_auth_inactivity_delay, 0);
|
||||
}
|
||||
|
||||
public boolean getAuthInactivity() {
|
||||
return getBoolean(R.string.settings_key_auth_inactivity, false);
|
||||
}
|
||||
|
||||
public boolean isMinimizeAppOnCopyEnabled() {
|
||||
return getBoolean(R.string.settings_key_minimize_on_copy, false);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<string name="settings_key_encryption" translatable="false">pref_encryption</string>
|
||||
<string name="settings_key_panic" translatable="false">pref_panic</string>
|
||||
<string name="settings_key_relock_screen_off" translatable="false">pref_relock_screen_off</string>
|
||||
<string name="settings_key_auth_inactivity" translatable="false">pref_auth_inactivity</string>
|
||||
<string name="settings_key_auth_inactivity_delay" translatable="false">pref_auth_inactivity_timeout</string>
|
||||
<string name="settings_key_block_accessibility" translatable="false">pref_block_accessibility</string>
|
||||
|
||||
<string name="settings_key_lang" translatable="false">pref_lang</string> <!-- Deprecated -->
|
||||
|
@ -60,6 +62,7 @@
|
|||
|
||||
<!-- Default values -->
|
||||
<integer name="settings_default_tap_to_reveal_timeout">30</integer>
|
||||
<integer name="settings_default_auth_inactivity_delay">30</integer>
|
||||
<string name="settings_default_encryption" translatable="false">keystore</string>
|
||||
<string name="settings_default_locale" translatable="false">system</string>
|
||||
<string name="settings_default_theme" translatable="false">light</string>
|
||||
|
@ -210,4 +213,6 @@
|
|||
<integer name="settings_max_tap_to_reveal_timeout">60</integer>
|
||||
<integer name="settings_min_label_size">12</integer>
|
||||
<integer name="settings_max_label_size">24</integer>
|
||||
<integer name="settings_auth_min_inactivity_delay">10</integer>
|
||||
<integer name="settings_auth_max_inactivity_delay">360</integer>
|
||||
</resources>
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<string name="settings_title_encryption">Database encryption</string>
|
||||
<string name="settings_title_panic">Panic Trigger</string>
|
||||
<string name="settings_title_relock_screen_off">Re-lock on screen off</string>
|
||||
<string name="settings_title_auth_inactivity">Re-lock on inactivity</string>
|
||||
<string name="settings_title_auth_inactivity_delay">Delay for inactivity re-lock</string>
|
||||
<string name="settings_title_block_accessibility">Block accessibility services</string>
|
||||
|
||||
<string name="settings_title_lang">Language</string>
|
||||
|
@ -55,6 +57,10 @@
|
|||
<string name="settings_desc_panic">Decide what happens when a Panic Trigger is received</string>
|
||||
<string name="settings_desc_relock_screen_off">Require authentication after the devices screen
|
||||
has been turned off</string>
|
||||
<string name="settings_desc_auth_inactivity">Require authenticication after the device has been
|
||||
inactive</string>
|
||||
<string name="settings_desc_auth_inactivity_delay">Select the time (in sec) after which to
|
||||
require reauthentication</string>
|
||||
<string name="settings_desc_block_accessibility">Hide sensitive fields from the accessibility
|
||||
services. <b>DO NOT enable this if you rely on the accessibility services!</b></string>
|
||||
|
||||
|
|
|
@ -48,6 +48,21 @@
|
|||
android:summary="@string/settings_desc_relock_screen_off"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/settings_key_auth_inactivity"
|
||||
android:title="@string/settings_title_auth_inactivity"
|
||||
android:summary="@string/settings_desc_auth_inactivity"
|
||||
android:defaultValue="false" />
|
||||
|
||||
<com.vanniktech.vntnumberpickerpreference.VNTNumberPickerPreference
|
||||
android:key="@string/settings_key_auth_inactivity_delay"
|
||||
android:title="@string/settings_title_auth_inactivity_delay"
|
||||
android:dialogMessage="@string/settings_desc_auth_inactivity_delay"
|
||||
android:defaultValue="@integer/settings_default_auth_inactivity_delay"
|
||||
android:dependency="@string/settings_key_auth_inactivity"
|
||||
app:vnt_minValue="@integer/settings_auth_min_inactivity_delay"
|
||||
app:vnt_maxValue="@integer/settings_auth_max_inactivity_delay" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="@string/settings_key_block_accessibility"
|
||||
android:title="@string/settings_title_block_accessibility"
|
||||
|
|
Loading…
Reference in a new issue