2018-08-02 13:33:06 +00:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
|
|
|
|
|
/*
|
2018-08-14 05:53:24 +00:00
|
|
|
This file is part of FairEmail.
|
2018-08-02 13:33:06 +00:00
|
|
|
|
2018-08-14 05:53:24 +00:00
|
|
|
FairEmail is free software: you can redistribute it and/or modify
|
2018-08-02 13:33:06 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
2018-10-29 10:46:49 +00:00
|
|
|
FairEmail is distributed in the hope that it will be useful,
|
2018-08-02 13:33:06 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2018-10-29 10:46:49 +00:00
|
|
|
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-02 13:33:06 +00:00
|
|
|
|
2020-01-05 18:32:53 +01:00
|
|
|
Copyright 2018-2020 by Marcel Bokhorst (M66B)
|
2018-08-02 13:33:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import android.app.Application;
|
2020-04-01 22:08:54 +02:00
|
|
|
import android.content.BroadcastReceiver;
|
2018-12-09 18:49:52 +01:00
|
|
|
import android.content.Context;
|
2020-04-01 22:08:54 +02:00
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
2019-03-27 10:37:27 +00:00
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.content.res.Configuration;
|
2020-05-27 11:40:38 +02:00
|
|
|
import android.os.Build;
|
2020-08-23 17:34:14 +02:00
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.os.Looper;
|
2020-04-04 09:19:19 +02:00
|
|
|
import android.util.Printer;
|
2019-03-13 13:42:33 +00:00
|
|
|
import android.webkit.CookieManager;
|
2018-08-03 18:07:12 +00:00
|
|
|
|
2019-05-06 13:59:26 +02:00
|
|
|
import androidx.preference.PreferenceManager;
|
2019-04-17 20:21:44 +02:00
|
|
|
|
2020-01-23 09:30:08 +01:00
|
|
|
import java.util.Date;
|
2019-08-12 13:30:33 +02:00
|
|
|
import java.util.HashMap;
|
2019-03-27 10:37:27 +00:00
|
|
|
import java.util.Locale;
|
2019-08-12 13:30:33 +02:00
|
|
|
import java.util.Map;
|
2019-05-10 15:44:36 +02:00
|
|
|
|
2020-10-05 21:09:13 +02:00
|
|
|
public class ApplicationEx extends Application implements SharedPreferences.OnSharedPreferenceChangeListener {
|
2018-08-03 18:07:12 +00:00
|
|
|
private Thread.UncaughtExceptionHandler prev = null;
|
|
|
|
|
|
2019-03-27 10:37:27 +00:00
|
|
|
@Override
|
|
|
|
|
protected void attachBaseContext(Context base) {
|
|
|
|
|
super.attachBaseContext(getLocalizedContext(base));
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-23 08:46:38 +01:00
|
|
|
static Context getLocalizedContext(Context context) {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
|
2020-10-05 21:09:13 +02:00
|
|
|
if (prefs.contains("english")) {
|
|
|
|
|
boolean english = prefs.getBoolean("english", false);
|
|
|
|
|
if (english)
|
|
|
|
|
prefs.edit()
|
|
|
|
|
.remove("english")
|
|
|
|
|
.putString("language", Locale.US.toLanguageTag())
|
2020-10-21 08:09:24 +02:00
|
|
|
.commit(); // apply won't work here
|
2020-10-05 21:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String language = prefs.getString("language", null);
|
|
|
|
|
if (language != null) {
|
|
|
|
|
Locale locale = Locale.forLanguageTag(language);
|
|
|
|
|
Locale.setDefault(locale);
|
2020-01-23 08:46:38 +01:00
|
|
|
Configuration config = new Configuration(context.getResources().getConfiguration());
|
2020-10-05 21:09:13 +02:00
|
|
|
config.setLocale(locale);
|
2020-01-23 08:46:38 +01:00
|
|
|
return context.createConfigurationContext(config);
|
2020-10-05 21:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return context;
|
2020-01-23 08:46:38 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-03 18:07:12 +00:00
|
|
|
@Override
|
|
|
|
|
public void onCreate() {
|
|
|
|
|
super.onCreate();
|
2019-05-10 08:53:45 +02:00
|
|
|
|
2020-01-23 09:30:08 +01:00
|
|
|
long start = new Date().getTime();
|
2019-08-12 13:17:55 +02:00
|
|
|
Log.logMemory(this, "App create version=" + BuildConfig.VERSION_NAME);
|
2018-08-03 18:07:12 +00:00
|
|
|
|
2020-04-04 09:19:19 +02:00
|
|
|
getMainLooper().setMessageLogging(new Printer() {
|
|
|
|
|
@Override
|
|
|
|
|
public void println(String msg) {
|
2020-07-26 09:37:03 +02:00
|
|
|
if (BuildConfig.DEBUG)
|
|
|
|
|
Log.d("Loop: " + msg);
|
2020-04-04 09:19:19 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2019-08-11 13:36:18 +02:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
|
final boolean crash_reports = prefs.getBoolean("crash_reports", false);
|
2020-11-08 20:51:44 +01:00
|
|
|
|
2018-08-03 18:07:12 +00:00
|
|
|
prev = Thread.getDefaultUncaughtExceptionHandler();
|
|
|
|
|
|
|
|
|
|
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
|
|
|
|
@Override
|
|
|
|
|
public void uncaughtException(Thread thread, Throwable ex) {
|
2019-08-12 16:18:41 +02:00
|
|
|
if (!crash_reports && Log.isOwnFault(ex)) {
|
2018-12-24 12:27:45 +00:00
|
|
|
Log.e(ex);
|
2018-12-18 17:06:54 +01:00
|
|
|
|
2018-12-28 09:56:40 +00:00
|
|
|
if (BuildConfig.BETA_RELEASE ||
|
2019-09-10 09:05:21 +02:00
|
|
|
!Helper.isPlayStoreInstall())
|
2019-08-12 16:18:41 +02:00
|
|
|
Log.writeCrashLog(ApplicationEx.this, ex);
|
2018-08-08 13:05:43 +00:00
|
|
|
|
2018-09-14 08:31:49 +00:00
|
|
|
if (prev != null)
|
|
|
|
|
prev.uncaughtException(thread, ex);
|
|
|
|
|
} else {
|
2018-12-24 12:27:45 +00:00
|
|
|
Log.w(ex);
|
2018-09-14 08:31:49 +00:00
|
|
|
System.exit(1);
|
2018-08-03 18:07:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-08-15 07:40:18 +00:00
|
|
|
|
2020-04-05 14:10:42 +02:00
|
|
|
Log.setup(this);
|
2019-05-10 15:18:53 +02:00
|
|
|
|
|
|
|
|
upgrade(this);
|
|
|
|
|
|
2020-11-18 08:25:20 +01:00
|
|
|
try {
|
|
|
|
|
boolean tcp_keep_alive = prefs.getBoolean("tcp_keep_alive", false);
|
|
|
|
|
System.setProperty("fairemail.tcp_keep_alive", Boolean.toString(tcp_keep_alive));
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
|
|
|
|
|
2020-10-09 15:22:38 +02:00
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)
|
|
|
|
|
NotificationHelper.createNotificationChannels(this);
|
2019-05-10 15:18:53 +02:00
|
|
|
|
2020-04-14 08:32:54 +02:00
|
|
|
DB.setupViewInvalidation(this);
|
2020-01-23 08:46:38 +01:00
|
|
|
|
2019-05-10 15:18:53 +02:00
|
|
|
if (Helper.hasWebView(this))
|
|
|
|
|
CookieManager.getInstance().setAcceptCookie(false);
|
|
|
|
|
|
2019-07-26 17:57:40 +02:00
|
|
|
MessageHelper.setSystemProperties(this);
|
2019-07-24 08:52:38 +02:00
|
|
|
ContactInfo.init(this);
|
2019-06-18 21:20:03 +02:00
|
|
|
|
2020-07-19 15:50:24 +02:00
|
|
|
DisconnectBlacklist.init(this);
|
|
|
|
|
|
2020-10-27 08:39:52 +01:00
|
|
|
boolean watchdog = prefs.getBoolean("watchdog", true);
|
|
|
|
|
boolean enabled = prefs.getBoolean("enabled", true);
|
|
|
|
|
if (watchdog && enabled)
|
|
|
|
|
WorkerWatchdog.init(this);
|
|
|
|
|
else {
|
|
|
|
|
ServiceSynchronize.watchdog(this);
|
|
|
|
|
ServiceSend.watchdog(this);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-17 15:57:01 +02:00
|
|
|
WorkerCleanup.init(this);
|
2020-01-22 16:18:21 +01:00
|
|
|
|
2020-04-01 22:08:54 +02:00
|
|
|
registerReceiver(onScreenOff, new IntentFilter(Intent.ACTION_SCREEN_OFF));
|
|
|
|
|
|
2020-04-16 18:09:55 +02:00
|
|
|
if (BuildConfig.DEBUG)
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
DnsHelper.test(ApplicationEx.this);
|
|
|
|
|
}
|
|
|
|
|
}).start();
|
|
|
|
|
|
2020-01-23 09:30:08 +01:00
|
|
|
long end = new Date().getTime();
|
|
|
|
|
Log.i("App created " + (end - start) + " ms");
|
2019-05-10 15:18:53 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-05 21:09:13 +02:00
|
|
|
@Override
|
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
2020-10-25 18:21:20 +01:00
|
|
|
switch (key) {
|
|
|
|
|
case "enabled":
|
|
|
|
|
ServiceSynchronize.reschedule(this);
|
|
|
|
|
WorkerCleanup.init(this);
|
|
|
|
|
WorkerWatchdog.init(this);
|
|
|
|
|
break;
|
|
|
|
|
case "poll_interval":
|
|
|
|
|
case "schedule":
|
|
|
|
|
case "schedule_start":
|
|
|
|
|
case "schedule_end":
|
|
|
|
|
case "schedule_day0":
|
|
|
|
|
case "schedule_day1":
|
|
|
|
|
case "schedule_day2":
|
|
|
|
|
case "schedule_day3":
|
|
|
|
|
case "schedule_day4":
|
|
|
|
|
case "schedule_day5":
|
|
|
|
|
case "schedule_day6":
|
|
|
|
|
ServiceSynchronize.reschedule(this);
|
|
|
|
|
break;
|
|
|
|
|
case "watchdog":
|
|
|
|
|
WorkerWatchdog.init(this);
|
|
|
|
|
break;
|
|
|
|
|
case "secure": // privacy
|
|
|
|
|
case "shortcuts": // misc
|
|
|
|
|
case "language": // misc
|
|
|
|
|
case "query_threads": // misc
|
|
|
|
|
restart();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-10-05 21:09:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void restart() {
|
|
|
|
|
Intent intent = new Intent(this, ActivityMain.class);
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
Runtime.getRuntime().exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-10 15:18:53 +02:00
|
|
|
@Override
|
|
|
|
|
public void onTrimMemory(int level) {
|
2019-08-12 13:17:55 +02:00
|
|
|
Log.logMemory(this, "Trim memory level=" + level);
|
2019-08-12 13:30:33 +02:00
|
|
|
Map<String, String> crumb = new HashMap<>();
|
|
|
|
|
crumb.put("level", Integer.toString(level));
|
|
|
|
|
crumb.put("free", Integer.toString(Log.getFreeMemMb()));
|
|
|
|
|
Log.breadcrumb("trim", crumb);
|
2019-05-10 15:18:53 +02:00
|
|
|
super.onTrimMemory(level);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onLowMemory() {
|
2019-08-12 13:17:55 +02:00
|
|
|
Log.logMemory(this, "Low memory");
|
2019-08-12 13:30:33 +02:00
|
|
|
Map<String, String> crumb = new HashMap<>();
|
|
|
|
|
crumb.put("free", Integer.toString(Log.getFreeMemMb()));
|
|
|
|
|
Log.breadcrumb("low", crumb);
|
2020-09-27 10:42:12 +02:00
|
|
|
|
|
|
|
|
ContactInfo.clearCache(this, false);
|
|
|
|
|
|
2019-05-10 15:18:53 +02:00
|
|
|
super.onLowMemory();
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-06 13:59:26 +02:00
|
|
|
static void upgrade(Context context) {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
2019-07-26 10:23:34 +02:00
|
|
|
int version = prefs.getInt("version", BuildConfig.VERSION_CODE);
|
2020-08-26 10:25:50 +02:00
|
|
|
if (version != BuildConfig.VERSION_CODE)
|
|
|
|
|
EntityLog.log(context, "Upgrading from " + version + " to " + BuildConfig.VERSION_CODE);
|
2019-07-26 10:23:34 +02:00
|
|
|
|
2019-07-22 12:31:30 +02:00
|
|
|
SharedPreferences.Editor editor = prefs.edit();
|
|
|
|
|
|
2020-08-28 08:54:11 +02:00
|
|
|
if (version < BuildConfig.VERSION_CODE)
|
|
|
|
|
editor.remove("crash_report_count");
|
|
|
|
|
|
2019-05-21 14:28:38 +02:00
|
|
|
if (version < 468) {
|
2019-05-06 13:59:26 +02:00
|
|
|
editor.remove("notify_trash");
|
|
|
|
|
editor.remove("notify_archive");
|
|
|
|
|
editor.remove("notify_reply");
|
|
|
|
|
editor.remove("notify_flag");
|
|
|
|
|
editor.remove("notify_seen");
|
|
|
|
|
|
2019-07-22 12:31:30 +02:00
|
|
|
} else if (version < 601) {
|
|
|
|
|
editor.putBoolean("contact_images", prefs.getBoolean("autoimages", true));
|
|
|
|
|
editor.remove("autoimages");
|
2019-07-26 10:23:34 +02:00
|
|
|
|
|
|
|
|
} else if (version < 612) {
|
|
|
|
|
if (prefs.getBoolean("autonext", false))
|
|
|
|
|
editor.putString("onclose", "next");
|
|
|
|
|
editor.remove("autonext");
|
2019-09-09 09:31:55 +02:00
|
|
|
|
2019-09-07 17:53:06 +02:00
|
|
|
} else if (version < 693) {
|
|
|
|
|
editor.remove("message_swipe");
|
|
|
|
|
editor.remove("message_select");
|
2019-09-09 09:31:55 +02:00
|
|
|
|
|
|
|
|
} else if (version < 696) {
|
|
|
|
|
String theme = prefs.getString("theme", "light");
|
|
|
|
|
if ("grey".equals(theme))
|
|
|
|
|
editor.putString("theme", "grey_dark");
|
2019-09-09 09:46:54 +02:00
|
|
|
|
|
|
|
|
if (prefs.contains("ascending")) {
|
|
|
|
|
editor.putBoolean("ascending_list", prefs.getBoolean("ascending", false));
|
|
|
|
|
editor.remove("ascending");
|
|
|
|
|
}
|
2019-09-12 17:33:33 +02:00
|
|
|
|
|
|
|
|
} else if (version < 701) {
|
|
|
|
|
if (prefs.getBoolean("suggest_local", false)) {
|
|
|
|
|
editor.putBoolean("suggest_sent", true);
|
|
|
|
|
editor.remove("suggest_local");
|
|
|
|
|
}
|
2019-09-13 11:00:31 +02:00
|
|
|
|
|
|
|
|
} else if (version < 703) {
|
|
|
|
|
if (!prefs.getBoolean("style_toolbar", true)) {
|
|
|
|
|
editor.putBoolean("compose_media", false);
|
|
|
|
|
editor.remove("style_toolbar");
|
|
|
|
|
}
|
2019-09-17 11:31:28 +02:00
|
|
|
|
|
|
|
|
} else if (version < 709) {
|
|
|
|
|
if (prefs.getBoolean("swipe_reversed", false)) {
|
|
|
|
|
editor.putBoolean("reversed", true);
|
|
|
|
|
editor.remove("swipe_reversed");
|
|
|
|
|
}
|
2019-07-02 10:32:06 +02:00
|
|
|
|
2019-10-02 09:26:32 +02:00
|
|
|
} else if (version < 741)
|
|
|
|
|
editor.remove("send_dialog");
|
2019-09-26 20:44:32 +02:00
|
|
|
|
2019-10-06 21:01:01 +02:00
|
|
|
else if (version < 751) {
|
|
|
|
|
if (prefs.contains("notify_snooze_duration")) {
|
|
|
|
|
int minutes = prefs.getInt("notify_snooze_duration", 60);
|
|
|
|
|
int hours = (int) Math.ceil(minutes / 60.0);
|
|
|
|
|
editor.putInt("default_snooze", hours);
|
|
|
|
|
editor.remove("notify_snooze_duration");
|
|
|
|
|
}
|
2019-11-15 14:27:28 +01:00
|
|
|
|
|
|
|
|
} else if (version < 819) {
|
|
|
|
|
if (prefs.contains("no_history")) {
|
|
|
|
|
editor.putBoolean("secure", prefs.getBoolean("no_history", false));
|
|
|
|
|
editor.remove("no_history");
|
|
|
|
|
}
|
2019-11-15 16:08:03 +01:00
|
|
|
|
|
|
|
|
if (prefs.contains("zoom")) {
|
|
|
|
|
int zoom = prefs.getInt("zoom", 1);
|
|
|
|
|
editor.putInt("view_zoom", zoom);
|
|
|
|
|
editor.putInt("compose_zoom", zoom);
|
|
|
|
|
editor.remove("zoom");
|
|
|
|
|
}
|
2019-12-12 17:51:39 +01:00
|
|
|
|
|
|
|
|
} else if (version < 844) {
|
|
|
|
|
if (prefs.getBoolean("schedule", false))
|
|
|
|
|
editor.putBoolean("enabled", true);
|
2019-12-30 11:44:09 +01:00
|
|
|
|
|
|
|
|
} else if (version < 874) {
|
|
|
|
|
if (prefs.contains("experiments") &&
|
|
|
|
|
prefs.getBoolean("experiments", false))
|
|
|
|
|
editor.putBoolean("quick_filter", true);
|
|
|
|
|
editor.remove("experiments");
|
2020-01-07 15:49:34 +01:00
|
|
|
|
|
|
|
|
} else if (version < 889) {
|
|
|
|
|
if (prefs.contains("autoresize")) {
|
|
|
|
|
boolean autoresize = prefs.getBoolean("autoresize", true);
|
|
|
|
|
editor.putBoolean("resize_images", autoresize);
|
|
|
|
|
editor.putBoolean("resize_attachments", autoresize);
|
|
|
|
|
editor.remove("autoresize");
|
|
|
|
|
}
|
2020-01-28 12:43:56 +01:00
|
|
|
} else if (version < 930) {
|
|
|
|
|
boolean large = context.getResources().getConfiguration()
|
|
|
|
|
.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE);
|
|
|
|
|
editor.putBoolean("landscape3", large);
|
2020-02-07 13:01:33 +01:00
|
|
|
} else if (version < 949) {
|
|
|
|
|
if (prefs.contains("automove")) {
|
|
|
|
|
boolean automove = prefs.getBoolean("automove", false);
|
|
|
|
|
editor.putBoolean("move_1_confirmed", automove);
|
|
|
|
|
editor.remove("automove");
|
|
|
|
|
}
|
2020-02-16 13:29:19 +01:00
|
|
|
} else if (version < 972) {
|
|
|
|
|
if (prefs.contains("signature_end")) {
|
|
|
|
|
boolean signature_end = prefs.getBoolean("signature_end", false);
|
|
|
|
|
if (signature_end)
|
|
|
|
|
editor.putInt("signature_location", 2);
|
|
|
|
|
editor.remove("signature_end");
|
|
|
|
|
}
|
2020-02-23 18:39:42 +01:00
|
|
|
} else if (version < 978) {
|
|
|
|
|
if (!prefs.contains("poll_interval"))
|
|
|
|
|
editor.putInt("poll_interval", 0);
|
2020-02-23 19:16:50 +01:00
|
|
|
editor.remove("first");
|
2020-03-08 21:25:20 +01:00
|
|
|
} else if (version < 1021) {
|
|
|
|
|
boolean highlight_unread = prefs.getBoolean("highlight_unread", false);
|
|
|
|
|
if (!highlight_unread)
|
2020-03-20 08:25:01 +01:00
|
|
|
editor.putBoolean("highlight_unread", highlight_unread);
|
2020-04-26 10:02:24 +02:00
|
|
|
} else if (version < 1121) {
|
|
|
|
|
if (!Helper.isPlayStoreInstall())
|
|
|
|
|
editor.putBoolean("experiments", true);
|
2020-04-27 17:50:58 +02:00
|
|
|
} else if (version < 1124) {
|
|
|
|
|
editor.remove("experiments");
|
2020-05-27 11:40:38 +02:00
|
|
|
} else if (version < 1181) {
|
2020-10-16 13:02:32 +02:00
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
2020-05-27 11:40:38 +02:00
|
|
|
editor.remove("background_service");
|
2020-07-08 15:35:57 +02:00
|
|
|
} else if (version < 1195)
|
|
|
|
|
editor.remove("auto_optimize");
|
|
|
|
|
else if (version < 1229) {
|
2020-06-30 09:48:42 +02:00
|
|
|
boolean monospaced = prefs.getBoolean("monospaced", false);
|
|
|
|
|
if (monospaced && !BuildConfig.DEBUG)
|
|
|
|
|
editor.putBoolean("text_font", false);
|
2020-07-04 09:26:11 +02:00
|
|
|
} else if (version < 1238) {
|
|
|
|
|
if (!prefs.contains("subject_ellipsize"))
|
|
|
|
|
editor.putString("subject_ellipsize", "middle");
|
2020-07-04 21:01:04 +02:00
|
|
|
if (!prefs.contains("auto_optimize"))
|
|
|
|
|
editor.putBoolean("auto_optimize", false);
|
2020-07-11 17:22:45 +02:00
|
|
|
} else if (version < 1253) {
|
|
|
|
|
int threads = prefs.getInt("query_threads", 4);
|
|
|
|
|
if (threads == 4)
|
|
|
|
|
editor.remove("query_threads");
|
2020-07-22 08:26:05 +02:00
|
|
|
} else if (version < 1264) {
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N ||
|
|
|
|
|
"Blackview".equalsIgnoreCase(Build.MANUFACTURER) ||
|
|
|
|
|
"OnePlus".equalsIgnoreCase(Build.MANUFACTURER) ||
|
|
|
|
|
"HUAWEI".equalsIgnoreCase(Build.MANUFACTURER))
|
|
|
|
|
editor.putInt("query_threads", 2);
|
2020-07-28 17:23:07 +02:00
|
|
|
} else if (version < 1274)
|
|
|
|
|
ContactInfo.clearCache(context); // Favicon background
|
2020-09-25 10:19:15 +02:00
|
|
|
else if (version < 1336) {
|
|
|
|
|
if (!prefs.contains("beige"))
|
|
|
|
|
editor.putBoolean("beige", false);
|
2020-11-13 20:48:43 +01:00
|
|
|
} else if (version < 1385)
|
2020-11-09 18:24:50 +01:00
|
|
|
editor.remove("parse_classes");
|
2020-11-18 08:25:20 +01:00
|
|
|
else if (version < 1401)
|
|
|
|
|
editor.remove("tcp_keep_alive");
|
2020-11-22 11:34:49 +01:00
|
|
|
else if (version < 1407)
|
|
|
|
|
editor.remove("print_html_confirmed");
|
2019-10-06 21:01:01 +02:00
|
|
|
|
2020-10-16 13:02:32 +02:00
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)
|
2020-10-12 08:25:09 +02:00
|
|
|
editor.remove("background_service");
|
|
|
|
|
|
2019-12-22 08:47:32 +01:00
|
|
|
if (version < BuildConfig.VERSION_CODE)
|
|
|
|
|
editor.putInt("previous_version", version);
|
2019-07-22 12:31:30 +02:00
|
|
|
editor.putInt("version", BuildConfig.VERSION_CODE);
|
|
|
|
|
|
|
|
|
|
editor.apply();
|
2019-05-06 13:59:26 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-01 22:08:54 +02:00
|
|
|
private BroadcastReceiver onScreenOff = new BroadcastReceiver() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
|
Log.i("Received " + intent);
|
|
|
|
|
Log.logExtras(intent);
|
|
|
|
|
Helper.clearAuthentication(ApplicationEx.this);
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-08-23 17:34:14 +02:00
|
|
|
|
|
|
|
|
private static Handler handler = null;
|
|
|
|
|
|
|
|
|
|
synchronized static Handler getMainHandler() {
|
|
|
|
|
if (handler == null)
|
|
|
|
|
handler = new Handler(Looper.getMainLooper());
|
|
|
|
|
return handler;
|
|
|
|
|
}
|
2018-08-02 13:33:06 +00:00
|
|
|
}
|