mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-04 20:30:36 +00:00
Display a warning if automatic time sync is not enabled
This'll display a warning to users who don't have automatic time synchronization enabled on their device. Aegis will try to take the user to the right settings menu if they tap "Yes". Users also have the option to silence the warning. [<img width=300 src="https://alexbakker.me/u/jf1o8087lr.png">](https://alexbakker.me/u/jf1o8087lr.png)
This commit is contained in:
parent
8ff817856e
commit
49a7fda932
5 changed files with 74 additions and 0 deletions
|
@ -159,4 +159,12 @@ public class Preferences {
|
|||
public void setBackupsVersionCount(int versions) {
|
||||
_prefs.edit().putInt("pref_backups_versions", versions).apply();
|
||||
}
|
||||
|
||||
public boolean isTimeSyncWarningEnabled() {
|
||||
return _prefs.getBoolean("pref_warn_time_sync", true);
|
||||
}
|
||||
|
||||
public void setIsTimeSyncWarningEnabled(boolean enabled) {
|
||||
_prefs.edit().putBoolean("pref_warn_time_sync", enabled).apply();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.content.ClipData;
|
|||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
|
@ -293,6 +295,31 @@ public class Dialogs {
|
|||
Dialogs.showSecureDialog(dialog);
|
||||
}
|
||||
|
||||
public static void showTimeSyncWarningDialog(Context context, Dialog.OnClickListener listener) {
|
||||
Preferences prefs = new Preferences(context);
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.dialog_time_sync, null);
|
||||
CheckBox checkBox = view.findViewById(R.id.check_warning_disable);
|
||||
|
||||
showSecureDialog(new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.time_sync_warning_title)
|
||||
.setView(view)
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
if (checkBox.isChecked()) {
|
||||
prefs.setIsTimeSyncWarningEnabled(false);
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onClick(dialog, which);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.no, (dialog, which) -> {
|
||||
if (checkBox.isChecked()) {
|
||||
prefs.setIsTimeSyncWarningEnabled(false);
|
||||
}
|
||||
})
|
||||
.create());
|
||||
}
|
||||
|
||||
public interface NumberInputListener {
|
||||
void onNumberInputResult(int number);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.graphics.BitmapFactory;
|
|||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
@ -343,11 +344,23 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
private void onDoIntroResult() {
|
||||
_vault = _app.getVaultManager();
|
||||
loadEntries();
|
||||
checkTimeSyncSetting();
|
||||
}
|
||||
|
||||
private void checkTimeSyncSetting() {
|
||||
boolean autoTime = Settings.Global.getInt(getContentResolver(), Settings.Global.AUTO_TIME, 1) == 1;
|
||||
if (!autoTime && getPreferences().isTimeSyncWarningEnabled()) {
|
||||
Dialogs.showTimeSyncWarningDialog(this, (dialog, which) -> {
|
||||
Intent intent = new Intent(Settings.ACTION_DATE_SETTINGS);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void onDecryptResult() {
|
||||
_vault = _app.getVaultManager();
|
||||
loadEntries();
|
||||
checkTimeSyncSetting();
|
||||
}
|
||||
|
||||
private void startScanActivity() {
|
||||
|
@ -450,6 +463,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
_entryListView.refresh(false);
|
||||
} else {
|
||||
loadEntries();
|
||||
checkTimeSyncSetting();
|
||||
}
|
||||
|
||||
handleDeeplink();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue