Merge pull request #1627 from deltachat/remove-app-protection

tune down usage of screen-lock
This commit is contained in:
bjoern
2020-09-19 13:28:41 +02:00
committed by GitHub
4 changed files with 42 additions and 16 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
android:summary="@string/pref_incognito_keyboard_explain"
android:title="@string/pref_incognito_keyboard" />
<PreferenceCategory android:title="@string/screenlock_title">
<PreferenceCategory android:key="pref_android_screen_lock_category" android:title="@string/screenlock_title">
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
@@ -176,8 +176,6 @@ public class ApplicationPreferencesActivity extends PassphraseRequiredActionBarA
this.findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS)
.setSummary(NotificationsPreferenceFragment.getSummary(getActivity()));
this.findPreference(PREFERENCE_CATEGORY_APP_PROTECTION)
.setSummary(AppProtectionPreferenceFragment.getSummary(getActivity()));
this.findPreference(PREFERENCE_CATEGORY_APPEARANCE)
.setSummary(AppearancePreferenceFragment.getSummary(getActivity()));
this.findPreference(PREFERENCE_CATEGORY_CHATS)
@@ -62,6 +62,35 @@ public class ApplicationDcContext extends DcContext {
// if ui-based migrations are needed, this is a good place
// (see eg. https://github.com/deltachat/deltachat-android/pull/1618 for an example)
// screen-lock is deprecated, inform users still using it
try {
if (!Prefs.getBooleanPreference(context, "pref_android_screen_lock_checked", false)) {
Prefs.setBooleanPreference(context, "pref_android_screen_lock_checked", true);
if (Prefs.isScreenLockEnabled(context)) {
Prefs.setBooleanPreference(context, "pref_android_screen_lock_keep_for_now", true);
DcMsg msg = new DcMsg(this, DcMsg.DC_MSG_TEXT);
msg.setText("⚠️ You are using the function \"Screen lock\" " +
"that will be removed in one of the next versions for the following reasons:\n" +
"\n" +
"• It does not add much protection as one just has to repeat the system secret.\n" +
"\n" +
"• It is hard to maintain across different Android versions and is not even doable on some." +
" We like to put the resources to other things.\n" +
"\n" +
"• It is not planned/possible on iOS or Desktop this way" +
" and stands in the way of moving towards unified solutions.\n" +
"\n" +
"• Same or even better functionality is available by other apps or maybe by the device itself.\n" +
"\n" +
"\uD83D\uDC49 For the future, we suggest to keep your phone locked " +
"or use an appropriate app or check the device settings.");
addDeviceMsg("android-screen-lock-deprecated14", msg);
}
}
} catch (Exception e) {
e.printStackTrace();
}
new Thread(() -> {
DcEventEmitter emitter = getEventEmitter();
while (true) {
@@ -7,18 +7,14 @@ import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.preference.CheckBoxPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import android.widget.Toast;
import com.b44t.messenger.DcContext;
import org.thoughtcrime.securesms.ApplicationPreferencesActivity;
import org.thoughtcrime.securesms.BlockedAndShareContactsActivity;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.components.SwitchPreferenceCompat;
import org.thoughtcrime.securesms.connect.ApplicationDcContext;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.util.Prefs;
import org.thoughtcrime.securesms.util.ScreenLockUtil;
@@ -73,6 +69,16 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
if (!screenLockPreference.isChecked()) {
manageScreenLockChildren(false);
}
// screen-lock is deprecated
try {
if (!Prefs.getBooleanPreference(getContext(), "pref_android_screen_lock_keep_for_now", false)) {
PreferenceCategory screenLockCategory = findPreference("pref_android_screen_lock_category");
screenLockCategory.setVisible(false);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void manageScreenLockChildren(boolean enable) {
@@ -105,13 +111,6 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment
}
}
public static CharSequence getSummary(Context context) {
final String onRes = context.getString(R.string.on);
final String offRes = context.getString(R.string.off);
String screenLockState = Prefs.isScreenLockEnabled(context) ? onRes : offRes;
return context.getString(R.string.screenlock_title) + " " + screenLockState;
}
private class ChangePassphraseClickListener implements Preference.OnPreferenceClickListener {
@Override
public boolean onPreferenceClick(Preference preference) {