kopia lustrzana https://github.com/ryukoposting/Signal-Android
Remove seconds from screen lock timeout input for coherence
Configure the TimeDurationPickerDialog to hide seconds. Seconds were already ignored below 1min. This avoids the user expecting it to work. Feature regression: after this change, seconds above 1min will also be impossible to input (ex: 1m30s). But it makes little sense anyway to allow it: they are even less useful for longer durations. Another possibility to reach a point where eveything is coherent would have been to just remove the Math.max(..., 60) that ignored seconds. The duration will be displayed as "xx:xx:00" to make it clear that xx:xx represents minutes. Fixes #10788.fork-5.53.8
rodzic
e2e1200c89
commit
5a91c7e84a
|
@ -72,6 +72,7 @@ import java.util.Objects;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mobi.upod.timedurationpicker.TimeDurationPickerDialog;
|
||||
import mobi.upod.timedurationpicker.TimeDurationPicker;
|
||||
|
||||
public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment {
|
||||
|
||||
|
@ -186,11 +187,10 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
|||
long timeoutSeconds = TextSecurePreferences.getScreenLockTimeout(getContext());
|
||||
long hours = TimeUnit.SECONDS.toHours(timeoutSeconds);
|
||||
long minutes = TimeUnit.SECONDS.toMinutes(timeoutSeconds) - (TimeUnit.SECONDS.toHours(timeoutSeconds) * 60 );
|
||||
long seconds = TimeUnit.SECONDS.toSeconds(timeoutSeconds) - (TimeUnit.SECONDS.toMinutes(timeoutSeconds) * 60);
|
||||
|
||||
findPreference(TextSecurePreferences.SCREEN_LOCK_TIMEOUT)
|
||||
.setSummary(timeoutSeconds <= 0 ? getString(R.string.AppProtectionPreferenceFragment_none) :
|
||||
String.format(Locale.getDefault(), "%02d:%02d:%02d", hours, minutes, seconds));
|
||||
String.format(Locale.getDefault(), "%02d:%02d:00", hours, minutes));
|
||||
}
|
||||
|
||||
private void initializePhoneNumberPrivacyWhoCanSeeSummary() {
|
||||
|
@ -255,15 +255,11 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
|||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
new TimeDurationPickerDialog(getContext(), (view, duration) -> {
|
||||
if (duration == 0) {
|
||||
TextSecurePreferences.setScreenLockTimeout(getContext(), 0);
|
||||
} else {
|
||||
long timeoutSeconds = Math.max(TimeUnit.MILLISECONDS.toSeconds(duration), 60);
|
||||
TextSecurePreferences.setScreenLockTimeout(getContext(), timeoutSeconds);
|
||||
}
|
||||
long timeoutSeconds = TimeUnit.MILLISECONDS.toSeconds(duration);
|
||||
TextSecurePreferences.setScreenLockTimeout(getContext(), timeoutSeconds);
|
||||
|
||||
initializeScreenLockTimeoutSummary();
|
||||
}, 0).show();
|
||||
}, 0, TimeDurationPicker.HH_MM).show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -399,7 +395,7 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
|
|||
|
||||
initializePassphraseTimeoutSummary();
|
||||
|
||||
}, 0).show();
|
||||
}, 0, TimeDurationPicker.HH_MM).show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue