Removed close on autolock/nav

pull/194/merge
M66B 4 years ago
parent 3c55af0552
commit 9fcd007b5a

@ -370,26 +370,24 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
if (this.getClass().equals(ActivityMain.class)) if (this.getClass().equals(ActivityMain.class))
return; return;
if (Helper.shouldAuthenticate(this, !auth)) { if (!Helper.shouldAuthenticate(this, !auth))
lock(); return;
if (auth) { lock();
if (this instanceof ActivityWidget ||
this instanceof ActivityWidgetSync || if (auth) {
this instanceof ActivityWidgetUnified) { if (this instanceof ActivityWidget ||
Toast.makeText(this, R.string.title_notification_redacted, Toast.LENGTH_LONG).show(); this instanceof ActivityWidgetSync ||
} else { this instanceof ActivityWidgetUnified) {
Intent intent = getIntent(); Toast.makeText(this, R.string.title_notification_redacted, Toast.LENGTH_LONG).show();
processStreams(intent); } else {
Intent main = new Intent(this, ActivityMain.class) Intent intent = getIntent();
.putExtra("intent", intent); processStreams(intent);
main.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); Intent main = new Intent(this, ActivityMain.class)
startActivity(main); .putExtra("intent", intent);
} main.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(main);
} }
} else {
if (!auth && Helper.shouldAutoLockNav(this))
getMainHandler().postDelayed(autoLockNav, Helper.AUTOLOCK_GRACE * 1000L);
} }
} }
@ -399,18 +397,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
finishAffinity(); finishAffinity();
} }
private final Runnable autoLockNav = new Runnable() {
@Override
public void run() {
try {
if (Helper.willAuthenticate(ActivityBase.this))
lock();
} catch (Throwable ex) {
Log.e(ex);
}
}
};
private void processStreams(Intent intent) { private void processStreams(Intent intent) {
intent.setClipData(null); intent.setClipData(null);

@ -2012,14 +2012,6 @@ public class Helper {
return false; return false;
} }
static boolean willAuthenticate(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
long now = new Date().getTime();
long last_authentication = prefs.getLong("last_authentication", 0);
long biometrics_timeout = prefs.getInt("biometrics_timeout", 2) * 60 * 1000L;
return (last_authentication + biometrics_timeout < now);
}
static boolean shouldAutoLock(Context context) { static boolean shouldAutoLock(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean biometrics = prefs.getBoolean("biometrics", false); boolean biometrics = prefs.getBoolean("biometrics", false);
@ -2028,14 +2020,6 @@ public class Helper {
return (autolock && (biometrics || !TextUtils.isEmpty(pin))); return (autolock && (biometrics || !TextUtils.isEmpty(pin)));
} }
static boolean shouldAutoLockNav(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean biometrics = prefs.getBoolean("biometrics", false);
String pin = prefs.getString("pin", null);
boolean autolock_nav = prefs.getBoolean("autolock_nav", false);
return (autolock_nav && (biometrics || !TextUtils.isEmpty(pin)));
}
static void authenticate(final FragmentActivity activity, final LifecycleOwner owner, static void authenticate(final FragmentActivity activity, final LifecycleOwner owner,
Boolean enabled, final Boolean enabled, final
Runnable authenticated, final Runnable cancelled) { Runnable authenticated, final Runnable cancelled) {

Loading…
Cancel
Save