parent
780b880c9d
commit
7716e4ad3f
6 changed files with 128 additions and 2 deletions
|
@ -47,6 +47,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
|
|
||||||
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -67,6 +69,7 @@ import com.leinardi.android.speeddial.SpeedDialActionItem;
|
||||||
import com.leinardi.android.speeddial.SpeedDialView;
|
import com.leinardi.android.speeddial.SpeedDialView;
|
||||||
|
|
||||||
import org.shadowice.flocke.andotp.Database.Entry;
|
import org.shadowice.flocke.andotp.Database.Entry;
|
||||||
|
import org.shadowice.flocke.andotp.Dialogs.HideableDialog;
|
||||||
import org.shadowice.flocke.andotp.R;
|
import org.shadowice.flocke.andotp.R;
|
||||||
import org.shadowice.flocke.andotp.Utilities.Constants;
|
import org.shadowice.flocke.andotp.Utilities.Constants;
|
||||||
import org.shadowice.flocke.andotp.Utilities.EncryptionHelper;
|
import org.shadowice.flocke.andotp.Utilities.EncryptionHelper;
|
||||||
|
@ -173,6 +176,13 @@ public class MainActivity extends BaseActivity
|
||||||
adapter.filterByTags(tagsDrawerAdapter.getActiveTags());
|
adapter.filterByTags(tagsDrawerAdapter.getActiveTags());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkAutomaticTime() {
|
||||||
|
int autoTime = Settings.Global.getInt(getContentResolver(), Settings.Global.AUTO_TIME, 0);
|
||||||
|
|
||||||
|
if (autoTime == 0)
|
||||||
|
HideableDialog.ShowHidableDialog(this, R.string.dialog_title_auto_time, R.string.dialog_msg_auto_time, R.string.settings_key_dialog_hide_auto_time);
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the main application
|
// Initialize the main application
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -210,6 +220,8 @@ public class MainActivity extends BaseActivity
|
||||||
showFirstTimeWarning();
|
showFirstTimeWarning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkAutomaticTime();
|
||||||
|
|
||||||
speedDial = findViewById(R.id.speedDial);
|
speedDial = findViewById(R.id.speedDial);
|
||||||
speedDial.inflate(R.menu.menu_fab);
|
speedDial.inflate(R.menu.menu_fab);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
package org.shadowice.flocke.andotp.Dialogs;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatDialog;
|
||||||
|
|
||||||
|
import org.shadowice.flocke.andotp.R;
|
||||||
|
import org.shadowice.flocke.andotp.Utilities.Settings;
|
||||||
|
import org.shadowice.flocke.andotp.Utilities.Tools;
|
||||||
|
|
||||||
|
public class HideableDialog extends AppCompatDialog
|
||||||
|
implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
|
|
||||||
|
private final Settings settings;
|
||||||
|
private final int hideSettingId;
|
||||||
|
|
||||||
|
public HideableDialog(@NonNull Context context, int titleId, int msgId, int hideSettingId) {
|
||||||
|
super(context, Tools.getThemeResource(context, R.attr.dialogTheme));
|
||||||
|
|
||||||
|
this.settings = new Settings(context);
|
||||||
|
this.hideSettingId = hideSettingId;
|
||||||
|
|
||||||
|
setTitle(titleId);
|
||||||
|
setContentView(R.layout.dialog_dont_show_again);
|
||||||
|
|
||||||
|
TextView content = findViewById(R.id.dialogContent);
|
||||||
|
CheckBox dontShowAgain = findViewById(R.id.dontShowAgain);
|
||||||
|
Button buttonOk = findViewById(R.id.buttonOk);
|
||||||
|
|
||||||
|
assert content != null;
|
||||||
|
assert dontShowAgain != null;
|
||||||
|
assert buttonOk != null;
|
||||||
|
|
||||||
|
content.setText(msgId);
|
||||||
|
|
||||||
|
dontShowAgain.setOnCheckedChangeListener(this);
|
||||||
|
buttonOk.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||||
|
if (settings != null && hideSettingId > 0)
|
||||||
|
settings.setBoolean(hideSettingId, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ShowHidableDialog(Context context, int titleId, int msgId, int hideSettingId) {
|
||||||
|
Settings settings = new Settings(context);
|
||||||
|
|
||||||
|
if (!settings.getBoolean(hideSettingId, false)) {
|
||||||
|
HideableDialog dialog = new HideableDialog(context, titleId, msgId, hideSettingId);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -129,7 +129,7 @@ public class Settings {
|
||||||
return settings.getString(getResString(keyId), defaultValue);
|
return settings.getString(getResString(keyId), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getBoolean(int keyId, boolean defaultValue) {
|
public boolean getBoolean(int keyId, boolean defaultValue) {
|
||||||
return settings.getBoolean(getResString(keyId), defaultValue);
|
return settings.getBoolean(getResString(keyId), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ public class Settings {
|
||||||
return new HashSet<>(settings.getStringSet(getResString(keyId), defaultValue));
|
return new HashSet<>(settings.getStringSet(getResString(keyId), defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBoolean(int keyId, boolean value) {
|
public void setBoolean(int keyId, boolean value) {
|
||||||
settings.edit()
|
settings.edit()
|
||||||
.putBoolean(getResString(keyId), value)
|
.putBoolean(getResString(keyId), value)
|
||||||
.apply();
|
.apply();
|
||||||
|
|
40
app/src/main/res/layout/dialog_dont_show_again.xml
Normal file
40
app/src/main/res/layout/dialog_dont_show_again.xml
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/activity_margin"
|
||||||
|
android:layout_marginStart="@dimen/activity_margin_small"
|
||||||
|
android:layout_marginEnd="@dimen/activity_margin_small"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="@null"
|
||||||
|
android:padding="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dialogContent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/dontShowAgain"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="@dimen/activity_margin"
|
||||||
|
android:text="@string/dialog_hint_dont_show_again"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="end">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/buttonOk"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog"
|
||||||
|
android:text="@android:string/ok" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -75,6 +75,8 @@
|
||||||
<string name="settings_key_last_used_dialog_shown" translatable="false">pref_last_used_dialog_shown</string>
|
<string name="settings_key_last_used_dialog_shown" translatable="false">pref_last_used_dialog_shown</string>
|
||||||
<string name="settings_key_android21_deprecation_notice_shown" translatable="false">pref_android21_deprecation_notice_shown</string> <!-- Deprecated -->
|
<string name="settings_key_android21_deprecation_notice_shown" translatable="false">pref_android21_deprecation_notice_shown</string> <!-- Deprecated -->
|
||||||
|
|
||||||
|
<string name="settings_key_dialog_hide_auto_time" translatable="false">pref_dialog_hide_auto_time</string>
|
||||||
|
|
||||||
<!-- Default values -->
|
<!-- Default values -->
|
||||||
<integer name="settings_default_tap_to_reveal_timeout">30</integer>
|
<integer name="settings_default_tap_to_reveal_timeout">30</integer>
|
||||||
<integer name="settings_default_auth_inactivity_delay">30</integer>
|
<integer name="settings_default_auth_inactivity_delay">30</integer>
|
||||||
|
|
|
@ -98,6 +98,7 @@
|
||||||
<string name="dialog_title_pin">PIN</string>
|
<string name="dialog_title_pin">PIN</string>
|
||||||
|
|
||||||
<string name="dialog_title_enter_password">Enter password</string>
|
<string name="dialog_title_enter_password">Enter password</string>
|
||||||
|
<string name="dialog_title_auto_time">Automatic time</string>
|
||||||
|
|
||||||
<string name="dialog_label_enter_password">Enter password</string>
|
<string name="dialog_label_enter_password">Enter password</string>
|
||||||
<string name="dialog_label_confirm_password">Confirm password</string>
|
<string name="dialog_label_confirm_password">Confirm password</string>
|
||||||
|
@ -113,6 +114,12 @@
|
||||||
<b>Any entries that are added will be lost.</b>\n\nTo continue using andOTP, you can go
|
<b>Any entries that are added will be lost.</b>\n\nTo continue using andOTP, you can go
|
||||||
to the <b>Settings</b> and switch the <b>Database encryption</b> to <b>Password / PIN</b>.</string>
|
to the <b>Settings</b> and switch the <b>Database encryption</b> to <b>Password / PIN</b>.</string>
|
||||||
|
|
||||||
|
<string name="dialog_msg_auto_time">Please enable the <b>Automatic date & time</b> option in
|
||||||
|
your phones <b>Settings</b> to ensure the correct generation of time-based
|
||||||
|
one-time-passwords (TOTP).</string>
|
||||||
|
|
||||||
|
<string name="dialog_hint_dont_show_again">Don\'t show this message again.</string>
|
||||||
|
|
||||||
<!-- Shortcuts -->
|
<!-- Shortcuts -->
|
||||||
<string name="shortcut_name_scan_qr">Scan QR code</string>
|
<string name="shortcut_name_scan_qr">Scan QR code</string>
|
||||||
<string name="shortcut_name_import_qr">Import QR code</string>
|
<string name="shortcut_name_import_qr">Import QR code</string>
|
||||||
|
|
Loading…
Reference in a new issue