show warning on devices with versions below Android 5

From blabber.im version 3.1.0 only devices with Android 5 or higher are supported
This commit is contained in:
Christian Schneppe 2021-02-28 10:27:17 +01:00
parent 2483230375
commit dda0a3e114
3 changed files with 26 additions and 2 deletions

View file

@ -91,6 +91,7 @@ import eu.siacs.conversations.ui.util.IntroHelper;
import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.ui.util.StyledAttributes;
import eu.siacs.conversations.ui.util.UpdateHelper;
import eu.siacs.conversations.utils.Compatibility;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.MenuDoubleTabUtil;
@ -105,6 +106,7 @@ import me.drakeet.support.toast.ToastCompat;
import static eu.siacs.conversations.ui.ConversationFragment.REQUEST_DECRYPT_PGP;
import static eu.siacs.conversations.ui.SettingsActivity.HIDE_MEMORY_WARNING;
import static eu.siacs.conversations.ui.SettingsActivity.MIN_ANDROID_SDK21_SHOWN;
public class ConversationsActivity extends XmppActivity implements OnConversationSelected, OnConversationArchived, OnConversationsListItemUpdated, OnConversationRead, XmppConnectionService.OnAccountUpdate, XmppConnectionService.OnConversationUpdate, XmppConnectionService.OnRosterUpdate, OnUpdateBlocklist, XmppConnectionService.OnShowErrorToast, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoomDestroy {
@ -277,11 +279,30 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
}
openBatteryOptimizationDialogIfNeeded();
new showMemoryWarning().execute();
showOutdatedVersionWarning();
}
}
private void showOutdatedVersionWarning() {
if (Compatibility.runsTwentyOne() || getPreferences().getBoolean(MIN_ANDROID_SDK21_SHOWN, false)) {
Log.d(Config.LOGTAG, "Device is running Android >= SDK 21");
return;
}
Log.d(Config.LOGTAG, "Device is running Android < SDK 21");
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.oldAndroidVersion);
builder.setMessage(R.string.oldAndroidVersionMessage);
builder.setPositiveButton(R.string.ok, (dialog, which) -> {
getPreferences().edit().putBoolean(MIN_ANDROID_SDK21_SHOWN, true).apply();
});
final AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.show();
}
private String getBatteryOptimizationPreferenceKey() {
@SuppressLint("HardwareIds") String device = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
@SuppressLint("HardwareIds")
String device = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
return "show_battery_optimization" + (device == null ? "" : device);
}

View file

@ -82,6 +82,7 @@ public class SettingsActivity extends XmppActivity implements
public static final String ALLOW_MESSAGE_CORRECTION = "allow_message_correction";
public static final String USE_UNICOLORED_CHATBG = "unicolored_chatbg";
public static final String EASY_DOWNLOADER = "easy_downloader";
public static final String MIN_ANDROID_SDK21_SHOWN = "min_android_sdk21_shown";
public static final int REQUEST_CREATE_BACKUP = 0xbf8701;
Preference multiAccountPreference;

View file

@ -1119,4 +1119,6 @@
<string name="memory_warning">Your messenger is using %1$s (%2$s) of internal memory.\n\nYou can enable automatic message deletion in relation with automatic attachment deletion or delete stored media manually.</string>
<string name="memory_warning_force">Your messenger is using %1$s (%2$s) of internal memory.\n\nYou should enable automatic message deletion in relation with automatic attachment deletion or delete stored media manually. Your device will become out of memory!</string>
<string name="open_settings">Open settings</string>
</resources>
<string name="oldAndroidVersion">Old Android version</string>
<string name="oldAndroidVersionMessage">You are using an old Android version that will no longer be supported in future updates. From blabber.im version 3.1.0 only devices with Android 5 or higher are supported. Please update your device firmware.</string>
</resources>