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
|
|
|
|
2021-01-01 07:56:36 +00:00
|
|
|
Copyright 2018-2021 by Marcel Bokhorst (M66B)
|
2018-08-02 13:33:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import android.app.Application;
|
2020-04-01 20:08:54 +00:00
|
|
|
import android.content.BroadcastReceiver;
|
2018-12-09 17:49:52 +00:00
|
|
|
import android.content.Context;
|
2020-04-01 20:08:54 +00: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 09:40:38 +00:00
|
|
|
import android.os.Build;
|
2020-08-23 15:34:14 +00:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Looper;
|
2020-04-04 07:19:19 +00: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 11:59:26 +00:00
|
|
|
import androidx.preference.PreferenceManager;
|
2019-04-17 18:21:44 +00:00
|
|
|
|
2020-01-23 08:30:08 +00:00
|
|
|
import java.util.Date;
|
2019-08-12 11:30:33 +00:00
|
|
|
import java.util.HashMap;
|
2019-03-27 10:37:27 +00:00
|
|
|
import java.util.Locale;
|
2019-08-12 11:30:33 +00:00
|
|
|
import java.util.Map;
|
2019-05-10 13:44:36 +00:00
|
|
|
|
2020-10-05 19:09:13 +00: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 07:46:38 +00:00
|
|
|
static Context getLocalizedContext(Context context) {
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
2020-10-05 19:09:13 +00: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 06:09:24 +00:00
|
|
|
.commit(); // apply won't work here
|
2020-10-05 19:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String language = prefs.getString("language", null);
|
|
|
|
if (language != null) {
|
|
|
|
Locale locale = Locale.forLanguageTag(language);
|
|
|
|
Locale.setDefault(locale);
|
2020-01-23 07:46:38 +00:00
|
|
|
Configuration config = new Configuration(context.getResources().getConfiguration());
|
2020-10-05 19:09:13 +00:00
|
|
|
config.setLocale(locale);
|
2020-01-23 07:46:38 +00:00
|
|
|
return context.createConfigurationContext(config);
|
2020-10-05 19:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return context;
|
2020-01-23 07:46:38 +00:00
|
|
|
}
|
|
|
|
|
2018-08-03 18:07:12 +00:00
|
|
|
@Override
|
|
|
|
public void onCreate() {
|
|
|
|
super.onCreate();
|
2019-05-10 06:53:45 +00:00
|
|
|
|
2020-01-23 08:30:08 +00:00
|
|
|
long start = new Date().getTime();
|
2019-08-12 11:17:55 +00:00
|
|
|
Log.logMemory(this, "App create version=" + BuildConfig.VERSION_NAME);
|
2018-08-03 18:07:12 +00:00
|
|
|
|
2020-04-04 07:19:19 +00:00
|
|
|
getMainLooper().setMessageLogging(new Printer() {
|
|
|
|
@Override
|
|
|
|
public void println(String msg) {
|
2020-07-26 07:37:03 +00:00
|
|
|
if (BuildConfig.DEBUG)
|
|
|
|
Log.d("Loop: " + msg);
|
2020-04-04 07:19:19 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-08-11 11:36:18 +00:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
final boolean crash_reports = prefs.getBoolean("crash_reports", false);
|
2020-11-08 19:51:44 +00: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 14:18:41 +00:00
|
|
|
if (!crash_reports && Log.isOwnFault(ex)) {
|
2018-12-24 12:27:45 +00:00
|
|
|
Log.e(ex);
|
2018-12-18 16:06:54 +00:00
|
|
|
|
2018-12-28 09:56:40 +00:00
|
|
|
if (BuildConfig.BETA_RELEASE ||
|
2019-09-10 07:05:21 +00:00
|
|
|
!Helper.isPlayStoreInstall())
|
2019-08-12 14:18:41 +00: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 12:10:42 +00:00
|
|
|
Log.setup(this);
|
2019-05-10 13:18:53 +00:00
|
|
|
|
|
|
|
upgrade(this);
|
|
|
|
|
2020-11-18 07:25:20 +00: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 13:22:38 +00:00
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O)
|
|
|
|
NotificationHelper.createNotificationChannels(this);
|
2019-05-10 13:18:53 +00:00
|
|
|
|
2020-04-14 06:32:54 +00:00
|
|
|
DB.setupViewInvalidation(this);
|
2020-01-23 07:46:38 +00:00
|
|
|
|
2019-05-10 13:18:53 +00:00
|
|
|
if (Helper.hasWebView(this))
|
|
|
|
CookieManager.getInstance().setAcceptCookie(false);
|
|
|
|
|
2019-07-26 15:57:40 +00:00
|
|
|
MessageHelper.setSystemProperties(this);
|
2019-07-24 06:52:38 +00:00
|
|
|
ContactInfo.init(this);
|
2019-06-18 19:20:03 +00:00
|
|
|
|
2020-07-19 13:50:24 +00:00
|
|
|
DisconnectBlacklist.init(this);
|
|
|
|
|
2020-10-27 07:39:52 +00: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 13:57:01 +00:00
|
|
|
WorkerCleanup.init(this);
|
2020-01-22 15:18:21 +00:00
|
|
|
|
2020-04-01 20:08:54 +00:00
|
|
|
registerReceiver(onScreenOff, new IntentFilter(Intent.ACTION_SCREEN_OFF));
|
|
|
|
|
2020-04-16 16:09:55 +00:00
|
|
|
if (BuildConfig.DEBUG)
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
DnsHelper.test(ApplicationEx.this);
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
|
2020-01-23 08:30:08 +00:00
|
|
|
long end = new Date().getTime();
|
|
|
|
Log.i("App created " + (end - start) + " ms");
|
2019-05-10 13:18:53 +00:00
|
|
|
}
|
|
|
|
|
2020-10-05 19:09:13 +00:00
|
|
|
@Override
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
2020-10-25 17:21:20 +00: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
|
2020-12-09 17:17:19 +00:00
|
|
|
// Should be excluded for import
|
2020-10-25 17:21:20 +00:00
|
|
|
restart();
|
|
|
|
break;
|
|
|
|
}
|
2020-10-05 19:09:13 +00: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 13:18:53 +00:00
|
|
|
@Override
|
|
|
|
public void onTrimMemory(int level) {
|
2019-08-12 11:17:55 +00:00
|
|
|
Log.logMemory(this, "Trim memory level=" + level);
|
2019-08-12 11:30:33 +00: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 13:18:53 +00:00
|
|
|
super.onTrimMemory(level);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLowMemory() {
|
2019-08-12 11:17:55 +00:00
|
|
|
Log.logMemory(this, "Low memory");
|
2019-08-12 11:30:33 +00:00
|
|
|
Map<String, String> crumb = new HashMap<>();
|
|
|
|
crumb.put("free", Integer.toString(Log.getFreeMemMb()));
|
|
|
|
Log.breadcrumb("low", crumb);
|
2020-09-27 08:42:12 +00:00
|
|
|
|
|
|
|
ContactInfo.clearCache(this, false);
|
|
|
|
|
2019-05-10 13:18:53 +00:00
|
|
|
super.onLowMemory();
|
|
|
|
}
|
|
|
|
|
2019-05-06 11:59:26 +00:00
|
|
|
static void upgrade(Context context) {
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
2019-07-26 08:23:34 +00:00
|
|
|
int version = prefs.getInt("version", BuildConfig.VERSION_CODE);
|
2020-08-26 08:25:50 +00:00
|
|
|
if (version != BuildConfig.VERSION_CODE)
|
|
|
|
EntityLog.log(context, "Upgrading from " + version + " to " + BuildConfig.VERSION_CODE);
|
2019-07-26 08:23:34 +00:00
|
|
|
|
2019-07-22 10:31:30 +00:00
|
|
|
SharedPreferences.Editor editor = prefs.edit();
|
|
|
|
|
2020-08-28 06:54:11 +00:00
|
|
|
if (version < BuildConfig.VERSION_CODE)
|
|
|
|
editor.remove("crash_report_count");
|
|
|
|
|
2019-05-21 12:28:38 +00:00
|
|
|
if (version < 468) {
|
2019-05-06 11:59:26 +00:00
|
|
|
editor.remove("notify_trash");
|
|
|
|
editor.remove("notify_archive");
|
|
|
|
editor.remove("notify_reply");
|
|
|
|
editor.remove("notify_flag");
|
|
|
|
editor.remove("notify_seen");
|
|
|
|
|
2019-07-22 10:31:30 +00:00
|
|
|
} else if (version < 601) {
|
|
|
|
editor.putBoolean("contact_images", prefs.getBoolean("autoimages", true));
|
|
|
|
editor.remove("autoimages");
|
2019-07-26 08:23:34 +00:00
|
|
|
|
|
|
|
} else if (version < 612) {
|
|
|
|
if (prefs.getBoolean("autonext", false))
|
|
|
|
editor.putString("onclose", "next");
|
|
|
|
editor.remove("autonext");
|
2019-09-09 07:31:55 +00:00
|
|
|
|
2019-09-07 15:53:06 +00:00
|
|
|
} else if (version < 693) {
|
|
|
|
editor.remove("message_swipe");
|
|
|
|
editor.remove("message_select");
|
2019-09-09 07:31:55 +00:00
|
|
|
|
|
|
|
} else if (version < 696) {
|
|
|
|
String theme = prefs.getString("theme", "light");
|
|
|
|
if ("grey".equals(theme))
|
|
|
|
editor.putString("theme", "grey_dark");
|
2019-09-09 07:46:54 +00:00
|
|
|
|
|
|
|
if (prefs.contains("ascending")) {
|
|
|
|
editor.putBoolean("ascending_list", prefs.getBoolean("ascending", false));
|
|
|
|
editor.remove("ascending");
|
|
|
|
}
|
2019-09-12 15:33:33 +00:00
|
|
|
|
|
|
|
} else if (version < 701) {
|
|
|
|
if (prefs.getBoolean("suggest_local", false)) {
|
|
|
|
editor.putBoolean("suggest_sent", true);
|
|
|
|
editor.remove("suggest_local");
|
|
|
|
}
|
2019-09-13 09:00:31 +00:00
|
|
|
|
|
|
|
} else if (version < 703) {
|
|
|
|
if (!prefs.getBoolean("style_toolbar", true)) {
|
|
|
|
editor.putBoolean("compose_media", false);
|
|
|
|
editor.remove("style_toolbar");
|
|
|
|
}
|
2019-09-17 09:31:28 +00:00
|
|
|
|
|
|
|
} else if (version < 709) {
|
|
|
|
if (prefs.getBoolean("swipe_reversed", false)) {
|
|
|
|
editor.putBoolean("reversed", true);
|
|
|
|
editor.remove("swipe_reversed");
|
|
|
|
}
|
2019-07-02 08:32:06 +00:00
|
|
|
|
2019-10-02 07:26:32 +00:00
|
|
|
} else if (version < 741)
|
|
|
|
editor.remove("send_dialog");
|
2019-09-26 18:44:32 +00:00
|
|
|
|
2019-10-06 19:01:01 +00: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 13:27:28 +00: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 15:08:03 +00: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 16:51:39 +00:00
|
|
|
|
|
|
|
} else if (version < 844) {
|
|
|
|
if (prefs.getBoolean("schedule", false))
|
|
|
|
editor.putBoolean("enabled", true);
|
2019-12-30 10:44:09 +00:00
|
|
|
|
|
|
|
} else if (version < 874) {
|
|
|
|
if (prefs.contains("experiments") &&
|
|
|
|
prefs.getBoolean("experiments", false))
|
|
|
|
editor.putBoolean("quick_filter", true);
|
|
|
|
editor.remove("experiments");
|
2020-01-07 14:49:34 +00: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 11:43:56 +00:00
|
|
|
} else if (version < 930) {
|
|
|
|
boolean large = context.getResources().getConfiguration()
|
|
|
|
.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE);
|
|
|
|
editor.putBoolean("landscape3", large);
|
2020-02-07 12:01:33 +00: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 12:29:19 +00: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 17:39:42 +00:00
|
|
|
} else if (version < 978) {
|
|
|
|
if (!prefs.contains("poll_interval"))
|
|
|
|
editor.putInt("poll_interval", 0);
|
2020-02-23 18:16:50 +00:00
|
|
|
editor.remove("first");
|
2020-03-08 20:25:20 +00:00
|
|
|
} else if (version < 1021) {
|
|
|
|
boolean highlight_unread = prefs.getBoolean("highlight_unread", false);
|
|
|
|
if (!highlight_unread)
|
2020-03-20 07:25:01 +00:00
|
|
|
editor.putBoolean("highlight_unread", highlight_unread);
|
2020-04-26 08:02:24 +00:00
|
|
|
} else if (version < 1121) {
|
|
|
|
if (!Helper.isPlayStoreInstall())
|
|
|
|
editor.putBoolean("experiments", true);
|
2020-04-27 15:50:58 +00:00
|
|
|
} else if (version < 1124) {
|
|
|
|
editor.remove("experiments");
|
2020-05-27 09:40:38 +00:00
|
|
|
} else if (version < 1181) {
|
2020-10-16 11:02:32 +00:00
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
2020-05-27 09:40:38 +00:00
|
|
|
editor.remove("background_service");
|
2020-07-08 13:35:57 +00:00
|
|
|
} else if (version < 1195)
|
|
|
|
editor.remove("auto_optimize");
|
|
|
|
else if (version < 1229) {
|
2020-06-30 07:48:42 +00:00
|
|
|
boolean monospaced = prefs.getBoolean("monospaced", false);
|
|
|
|
if (monospaced && !BuildConfig.DEBUG)
|
|
|
|
editor.putBoolean("text_font", false);
|
2020-07-04 07:26:11 +00:00
|
|
|
} else if (version < 1238) {
|
|
|
|
if (!prefs.contains("subject_ellipsize"))
|
|
|
|
editor.putString("subject_ellipsize", "middle");
|
2020-07-04 19:01:04 +00:00
|
|
|
if (!prefs.contains("auto_optimize"))
|
|
|
|
editor.putBoolean("auto_optimize", false);
|
2020-07-11 15:22:45 +00:00
|
|
|
} else if (version < 1253) {
|
|
|
|
int threads = prefs.getInt("query_threads", 4);
|
|
|
|
if (threads == 4)
|
|
|
|
editor.remove("query_threads");
|
2020-07-22 06:26:05 +00: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 15:23:07 +00:00
|
|
|
} else if (version < 1274)
|
|
|
|
ContactInfo.clearCache(context); // Favicon background
|
2020-09-25 08:19:15 +00:00
|
|
|
else if (version < 1336) {
|
|
|
|
if (!prefs.contains("beige"))
|
|
|
|
editor.putBoolean("beige", false);
|
2020-11-13 19:48:43 +00:00
|
|
|
} else if (version < 1385)
|
2020-11-09 17:24:50 +00:00
|
|
|
editor.remove("parse_classes");
|
2020-11-18 07:25:20 +00:00
|
|
|
else if (version < 1401)
|
|
|
|
editor.remove("tcp_keep_alive");
|
2020-11-22 10:34:49 +00:00
|
|
|
else if (version < 1407)
|
|
|
|
editor.remove("print_html_confirmed");
|
2020-12-02 13:39:48 +00:00
|
|
|
else if (version < 1413)
|
|
|
|
editor.remove("experiments");
|
2019-10-06 19:01:01 +00:00
|
|
|
|
2020-10-16 11:02:32 +00:00
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)
|
2020-10-12 06:25:09 +00:00
|
|
|
editor.remove("background_service");
|
|
|
|
|
2019-12-22 07:47:32 +00:00
|
|
|
if (version < BuildConfig.VERSION_CODE)
|
|
|
|
editor.putInt("previous_version", version);
|
2019-07-22 10:31:30 +00:00
|
|
|
editor.putInt("version", BuildConfig.VERSION_CODE);
|
|
|
|
|
|
|
|
editor.apply();
|
2019-05-06 11:59:26 +00:00
|
|
|
}
|
|
|
|
|
2020-04-01 20:08:54 +00: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 15:34:14 +00: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
|
|
|
}
|