Skip to content

Commit

Permalink
persist delay
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Feb 10, 2025
1 parent b3acccf commit bd78477
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,7 @@ default void onDarkThemeModeChanged(DarkMode mode) {

boolean isAutoUploadGPlayNotificationShown();
void setAutoUploadGPlayNotificationShown(boolean value);

int getPassCodeDelay();
void setPassCodeDelay(int value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public final class AppPreferencesImpl implements AppPreferences {
private static final String PREF__AUTO_UPLOAD_GPLAY_WARNING2_SHOWN = "auto_upload_gplay_warning2_shown";
private static final String PREF__AUTO_UPLOAD_GPLAY_NOTIFICATION_SHOWN = "auto_upload_gplay_notification_shown";

private static final String PREF__PASSCODE_DELAY_IN_SECONDS = "passcode_delay_in_seconds";

private static final String LOG_ENTRY = "log_entry";

private final Context context;
Expand Down Expand Up @@ -859,4 +861,14 @@ public boolean isAutoUploadGPlayNotificationShown() {
public void setAutoUploadGPlayNotificationShown(boolean value) {
preferences.edit().putBoolean(PREF__AUTO_UPLOAD_GPLAY_NOTIFICATION_SHOWN, value).apply();
}

@Override
public int getPassCodeDelay() {
return preferences.getInt(PREF__PASSCODE_DELAY_IN_SECONDS, 0);
}

@Override
public void setPassCodeDelay(int value) {
preferences.edit().putInt(PREF__PASSCODE_DELAY_IN_SECONDS, value).apply();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
private var passCodeDigits: Array<String> = arrayOf("", "", "", "")
private var confirmingPassCode = false
private var changed = true // to control that only one blocks jump
private var delayTimeInSeconds = 0
private var delayTimeInSeconds: Int = 0

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
delayTimeInSeconds = preferences.passCodeDelay
binding = PasscodelockBinding.inflate(layoutInflater)
setContentView(binding.root)

Expand Down Expand Up @@ -340,12 +341,13 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
}

@Suppress("MagicNumber")
private fun increaseDelayTime() {
private fun increaseAndSaveDelayTime() {
val maxDelayTimeInSeconds = 300
val delayIncrementation = 15

if (delayTimeInSeconds < maxDelayTimeInSeconds) {
delayTimeInSeconds += delayIncrementation
preferences.passCodeDelay = delayTimeInSeconds
}
}

Expand Down Expand Up @@ -406,7 +408,7 @@ class PassCodeActivity : AppCompatActivity(), Injectable {

enableInputFields(true)
focusFirstInputField()
increaseDelayTime()
increaseAndSaveDelayTime()
}
}

Expand Down

0 comments on commit bd78477

Please sign in to comment.