mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
show a little message before QR code generation
we already had a confirmation dialog for probably most security-aware users always when the device is protected by a screen lock. this commits adds a more on-point text - and shows the same text in a simple alert in case a device has no screen lock.
This commit is contained in:
@@ -470,6 +470,7 @@
|
||||
<!-- "Second Device" can also be translated as "Another Device", if that is catchier in the destination language. However, make sure to use the term consistently. -->
|
||||
<string name="multidevice_title">Add Second Device</string>
|
||||
<string name="multidevice_same_network_hint">Make sure both devices are on the same Wi-Fi or network</string>
|
||||
<string name="multidevice_this_creates_a_qr_code">This creates a QR code that the second device can scan to copy the account.</string>
|
||||
<string name="multidevice_install_dc_on_other_device">Install Delta Chat on your other device (https://get.delta.chat)</string>
|
||||
<string name="multidevice_tap_scan_on_other_device">Start Delta Chat, tap “Add as Second Device” and scan the code shown here</string>
|
||||
<!-- Shown inside a "QR code card" with very limited space; please formulate the text as short as possible therefore. The placeholder will be replaced by name and/or address eg. "Scan to set up second device for Alice (alice@example.org)" -->
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -275,8 +276,17 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
|
||||
fragment = new ChatsPreferenceFragment();
|
||||
break;
|
||||
case PREFERENCE_CATEGORY_MULTIDEVICE:
|
||||
if (!ScreenLockUtil.applyScreenLock(getActivity(), getString(R.string.multidevice_title), ScreenLockUtil.REQUEST_CODE_CONFIRM_CREDENTIALS)) {
|
||||
((ApplicationPreferencesActivity)getActivity()).showBackupProvider();
|
||||
if (!ScreenLockUtil.applyScreenLock(getActivity(), getString(R.string.multidevice_title),
|
||||
getString(R.string.multidevice_this_creates_a_qr_code) + "\n\n" + getString(R.string.enter_system_secret_to_continue),
|
||||
ScreenLockUtil.REQUEST_CODE_CONFIRM_CREDENTIALS)) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(R.string.multidevice_title)
|
||||
.setMessage(R.string.multidevice_this_creates_a_qr_code)
|
||||
.setPositiveButton(R.string.perm_continue,
|
||||
(dialog, which) -> ((ApplicationPreferencesActivity)getActivity()).showBackupProvider())
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
;
|
||||
}
|
||||
break;
|
||||
case PREFERENCE_CATEGORY_ADVANCED:
|
||||
|
||||
@@ -300,7 +300,7 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
|
||||
private class ManageKeysListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
boolean result = ScreenLockUtil.applyScreenLock(getActivity(), getString(R.string.pref_manage_keys), REQUEST_CODE_CONFIRM_CREDENTIALS_KEYS);
|
||||
boolean result = ScreenLockUtil.applyScreenLock(getActivity(), getString(R.string.pref_manage_keys), getString(R.string.enter_system_secret_to_continue), REQUEST_CODE_CONFIRM_CREDENTIALS_KEYS);
|
||||
if (!result) {
|
||||
exportKeys();
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
||||
private class BackupListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
boolean result = ScreenLockUtil.applyScreenLock(getActivity(), getString(R.string.pref_backup), REQUEST_CODE_CONFIRM_CREDENTIALS_BACKUP);
|
||||
boolean result = ScreenLockUtil.applyScreenLock(getActivity(), getString(R.string.pref_backup), getString(R.string.enter_system_secret_to_continue), REQUEST_CODE_CONFIRM_CREDENTIALS_BACKUP);
|
||||
if (!result) {
|
||||
performBackup();
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ public class ScreenLockUtil {
|
||||
|
||||
public static final int REQUEST_CODE_CONFIRM_CREDENTIALS = 1001;
|
||||
|
||||
public static boolean applyScreenLock(Activity activity, String title, int requestCode) {
|
||||
public static boolean applyScreenLock(Activity activity, String title, String descr, int requestCode) {
|
||||
KeyguardManager keyguardManager = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
Intent intent;
|
||||
if (keyguardManager != null && isScreenLockAvailable()) {
|
||||
intent = keyguardManager.createConfirmDeviceCredentialIntent(title, activity.getString(R.string.enter_system_secret_to_continue));
|
||||
intent = keyguardManager.createConfirmDeviceCredentialIntent(title, descr);
|
||||
if (intent != null) {
|
||||
activity.startActivityForResult(intent, requestCode);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user