2018-08-10 13:32:07 +00:00
|
|
|
package eu.faircode.email;
|
|
|
|
|
2018-08-14 05:53:24 +00:00
|
|
|
/*
|
|
|
|
This file is part of FairEmail.
|
|
|
|
|
|
|
|
FairEmail is free software: you can redistribute it and/or modify
|
|
|
|
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-14 05:53:24 +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-14 05:53:24 +00:00
|
|
|
|
2022-01-01 08:46:36 +00:00
|
|
|
Copyright 2018-2022 by Marcel Bokhorst (M66B)
|
2018-08-14 05:53:24 +00:00
|
|
|
*/
|
|
|
|
|
2021-08-15 13:51:22 +00:00
|
|
|
import android.app.ActivityOptions;
|
2019-01-25 17:55:22 +00:00
|
|
|
import android.content.Context;
|
2022-06-06 13:02:11 +00:00
|
|
|
import android.content.DialogInterface;
|
2018-08-10 13:32:07 +00:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
2019-03-27 08:08:06 +00:00
|
|
|
import android.content.res.Configuration;
|
2021-04-11 11:16:19 +00:00
|
|
|
import android.net.Uri;
|
2021-08-26 06:40:33 +00:00
|
|
|
import android.os.Build;
|
2018-08-10 13:32:07 +00:00
|
|
|
import android.os.Bundle;
|
2022-06-06 13:02:11 +00:00
|
|
|
import android.view.LayoutInflater;
|
2021-12-10 14:35:59 +00:00
|
|
|
import android.view.View;
|
|
|
|
import android.widget.Button;
|
2022-06-06 13:02:11 +00:00
|
|
|
import android.widget.TextView;
|
2018-08-10 13:32:07 +00:00
|
|
|
|
2022-06-06 13:02:11 +00:00
|
|
|
import androidx.appcompat.app.AlertDialog;
|
2018-08-10 13:32:07 +00:00
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import androidx.fragment.app.FragmentTransaction;
|
2019-03-15 13:54:25 +00:00
|
|
|
import androidx.preference.PreferenceManager;
|
2018-08-10 13:32:07 +00:00
|
|
|
|
2020-01-23 08:30:08 +00:00
|
|
|
import java.util.Date;
|
2019-04-17 18:21:44 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2019-07-11 05:41:20 +00:00
|
|
|
public class ActivityMain extends ActivityBase implements FragmentManager.OnBackStackChangedListener, SharedPreferences.OnSharedPreferenceChangeListener {
|
2022-06-24 10:15:41 +00:00
|
|
|
static final int RESTORE_STATE_INTERVAL = 3; // minutes
|
|
|
|
|
2020-01-23 14:31:46 +00:00
|
|
|
private static final long SPLASH_DELAY = 1500L; // milliseconds
|
|
|
|
private static final long SERVICE_START_DELAY = 5 * 1000L; // milliseconds
|
|
|
|
|
2018-08-10 13:32:07 +00:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
2021-12-10 14:35:59 +00:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
|
|
|
boolean accept_unsupported = prefs.getBoolean("accept_unsupported", false);
|
|
|
|
|
|
|
|
if (!accept_unsupported &&
|
|
|
|
!Helper.isSupportedDevice() &&
|
|
|
|
Helper.isPlayStoreInstall()) {
|
2019-12-26 13:45:04 +00:00
|
|
|
setTheme(R.style.AppThemeBlueOrangeLight);
|
2019-03-08 07:08:50 +00:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_unsupported);
|
2021-12-10 14:35:59 +00:00
|
|
|
|
|
|
|
Button btnContinue = findViewById(R.id.btnContinue);
|
|
|
|
btnContinue.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
prefs.edit().putBoolean("accept_unsupported", true).commit();
|
|
|
|
ApplicationEx.restart(v.getContext());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-03-08 07:08:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-09-29 14:42:39 +00:00
|
|
|
Intent intent = getIntent();
|
|
|
|
Uri data = (intent == null ? null : intent.getData());
|
|
|
|
if (data != null &&
|
|
|
|
"message".equals(data.getScheme()) &&
|
2021-10-12 11:23:53 +00:00
|
|
|
("email.faircode.eu".equals(data.getHost()) ||
|
|
|
|
BuildConfig.APPLICATION_ID.equals(data.getHost()))) {
|
2021-09-29 14:42:39 +00:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putParcelable("data", data);
|
|
|
|
|
|
|
|
new SimpleTask<EntityMessage>() {
|
|
|
|
@Override
|
|
|
|
protected EntityMessage onExecute(Context context, Bundle args) {
|
|
|
|
Uri data = args.getParcelable("data");
|
2021-10-12 11:23:53 +00:00
|
|
|
long id;
|
|
|
|
if ("email.faircode.eu".equals(data.getHost()))
|
|
|
|
id = Long.parseLong(data.getFragment());
|
|
|
|
else {
|
|
|
|
String path = data.getPath();
|
|
|
|
if (path == null)
|
|
|
|
return null;
|
|
|
|
String[] parts = path.split("/");
|
|
|
|
if (parts.length < 1)
|
|
|
|
return null;
|
|
|
|
id = Long.parseLong(parts[1]);
|
|
|
|
}
|
2021-09-29 14:42:39 +00:00
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
return db.message().getMessage(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onExecuted(Bundle args, EntityMessage message) {
|
2022-01-28 09:38:49 +00:00
|
|
|
finish();
|
2021-09-29 14:42:39 +00:00
|
|
|
|
|
|
|
if (message == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Intent thread = new Intent(ActivityMain.this, ActivityView.class);
|
|
|
|
thread.setAction("thread:" + message.id);
|
2022-06-25 12:27:46 +00:00
|
|
|
thread.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
2021-09-29 14:42:39 +00:00
|
|
|
thread.putExtra("account", message.account);
|
|
|
|
thread.putExtra("folder", message.folder);
|
|
|
|
thread.putExtra("thread", message.thread);
|
|
|
|
thread.putExtra("filter_archive", true);
|
|
|
|
thread.putExtra("pinned", true);
|
|
|
|
thread.putExtra("msgid", message.msgid);
|
|
|
|
|
|
|
|
startActivity(thread);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
// Ignored
|
|
|
|
}
|
|
|
|
}.execute(this, args, "message:linked");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-10 15:58:26 +00:00
|
|
|
boolean eula = prefs.getBoolean("eula", false);
|
2020-12-14 17:55:02 +00:00
|
|
|
boolean sync_on_launch = prefs.getBoolean("sync_on_launch", false);
|
2019-07-10 15:58:26 +00:00
|
|
|
|
2018-08-10 13:32:07 +00:00
|
|
|
prefs.registerOnSharedPreferenceChangeListener(this);
|
|
|
|
|
2019-07-10 15:58:26 +00:00
|
|
|
if (eula) {
|
2021-03-13 07:53:10 +00:00
|
|
|
try {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
} catch (RuntimeException ex) {
|
|
|
|
Log.e(ex);
|
|
|
|
// https://issuetracker.google.com/issues/181805603
|
2022-01-28 09:38:49 +00:00
|
|
|
finish();
|
2021-03-13 07:53:10 +00:00
|
|
|
startActivity(getIntent());
|
|
|
|
return;
|
|
|
|
}
|
2019-06-09 09:22:50 +00:00
|
|
|
|
2020-01-23 08:30:08 +00:00
|
|
|
long start = new Date().getTime();
|
|
|
|
Log.i("Main boot");
|
|
|
|
|
2021-08-24 14:38:22 +00:00
|
|
|
final Runnable splash = new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
getWindow().setBackgroundDrawableResource(R.drawable.splash);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-02-28 08:44:24 +00:00
|
|
|
final SimpleTask<Boolean> boot = new SimpleTask<Boolean>() {
|
2019-06-09 09:47:57 +00:00
|
|
|
@Override
|
2019-07-10 15:58:26 +00:00
|
|
|
protected void onPreExecute(Bundle args) {
|
2021-08-26 06:40:33 +00:00
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S)
|
|
|
|
getMainHandler().postDelayed(splash, SPLASH_DELAY);
|
2021-08-24 14:38:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPostExecute(Bundle args) {
|
2021-08-26 06:40:33 +00:00
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S)
|
|
|
|
getMainHandler().removeCallbacks(splash);
|
2021-08-24 14:38:22 +00:00
|
|
|
getWindow().setBackgroundDrawable(null);
|
2019-06-09 09:47:57 +00:00
|
|
|
}
|
|
|
|
|
2018-08-10 13:32:07 +00:00
|
|
|
@Override
|
2019-06-09 09:22:50 +00:00
|
|
|
protected Boolean onExecute(Context context, Bundle args) {
|
2022-06-25 06:53:12 +00:00
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
2019-06-09 09:22:50 +00:00
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
2022-06-25 06:53:12 +00:00
|
|
|
String last_activity = prefs.getString("last_activity", null);
|
|
|
|
long composing = prefs.getLong("last_composing", -1L);
|
|
|
|
if (ActivityCompose.class.getName().equals(last_activity) && composing >= 0) {
|
|
|
|
EntityMessage draft = db.message().getMessage(composing);
|
|
|
|
if (draft == null || draft.ui_hide)
|
|
|
|
prefs.edit()
|
|
|
|
.remove("last_activity")
|
|
|
|
.remove("last_composing")
|
|
|
|
.apply();
|
|
|
|
}
|
|
|
|
|
2019-06-09 09:22:50 +00:00
|
|
|
if (prefs.getBoolean("has_accounts", false))
|
|
|
|
return true;
|
|
|
|
|
2022-01-27 13:43:55 +00:00
|
|
|
List<EntityAccount> accounts = db.account().getSynchronizingAccounts(null);
|
2019-06-09 09:22:50 +00:00
|
|
|
boolean hasAccounts = (accounts != null && accounts.size() > 0);
|
|
|
|
|
|
|
|
prefs.edit().putBoolean("has_accounts", hasAccounts).apply();
|
|
|
|
|
|
|
|
return hasAccounts;
|
2019-01-25 17:55:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-06-09 09:22:50 +00:00
|
|
|
protected void onExecuted(Bundle args, Boolean hasAccounts) {
|
2021-08-15 17:42:02 +00:00
|
|
|
Bundle options = null;
|
2021-08-15 13:51:22 +00:00
|
|
|
try {
|
2021-08-15 17:42:02 +00:00
|
|
|
if (BuildConfig.DEBUG)
|
|
|
|
options = ActivityOptions.makeCustomAnimation(ActivityMain.this,
|
|
|
|
R.anim.activity_open_enter, 0).toBundle();
|
2021-08-15 13:51:22 +00:00
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(ex);
|
|
|
|
}
|
|
|
|
|
2019-08-03 14:05:30 +00:00
|
|
|
if (hasAccounts) {
|
2021-08-15 13:51:22 +00:00
|
|
|
Intent view = new Intent(ActivityMain.this, ActivityView.class)
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
2019-09-27 08:43:01 +00:00
|
|
|
|
2021-08-23 09:46:46 +00:00
|
|
|
// VX-N3
|
|
|
|
// https://developer.android.com/docs/quality-guidelines/core-app-quality
|
|
|
|
long now = new Date().getTime();
|
|
|
|
long last = prefs.getLong("last_launched", 0L);
|
2022-06-24 10:15:41 +00:00
|
|
|
boolean restore_on_launch = prefs.getBoolean("restore_on_launch", true);
|
|
|
|
if (!restore_on_launch || now - last > RESTORE_STATE_INTERVAL * 60 * 1000L)
|
2021-08-23 09:46:46 +00:00
|
|
|
view.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
2022-06-24 10:15:41 +00:00
|
|
|
else {
|
|
|
|
String last_activity = prefs.getString("last_activity", null);
|
|
|
|
long composing = prefs.getLong("last_composing", -1L);
|
|
|
|
if (ActivityCompose.class.getName().equals(last_activity) && composing >= 0)
|
|
|
|
view = new Intent(ActivityMain.this, ActivityCompose.class)
|
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
|
.putExtra("action", "edit")
|
|
|
|
.putExtra("id", composing);
|
|
|
|
}
|
2021-08-23 09:46:46 +00:00
|
|
|
|
2019-09-27 08:43:01 +00:00
|
|
|
Intent saved = args.getParcelable("intent");
|
2020-12-14 17:55:02 +00:00
|
|
|
if (saved == null) {
|
2021-08-23 09:46:46 +00:00
|
|
|
prefs.edit().putLong("last_launched", now).apply();
|
2021-08-15 17:42:02 +00:00
|
|
|
startActivity(view, options);
|
2020-12-14 17:55:02 +00:00
|
|
|
if (sync_on_launch)
|
|
|
|
ServiceUI.sync(ActivityMain.this, null);
|
|
|
|
} else
|
2019-09-27 08:43:01 +00:00
|
|
|
try {
|
|
|
|
startActivity(saved);
|
|
|
|
} catch (SecurityException ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
startActivity(view);
|
|
|
|
}
|
|
|
|
|
2020-08-23 15:34:14 +00:00
|
|
|
getMainHandler().postDelayed(new Runnable() {
|
2020-01-23 14:31:46 +00:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2021-03-29 18:08:35 +00:00
|
|
|
ServiceSynchronize.watchdog(ActivityMain.this);
|
2020-01-23 14:31:46 +00:00
|
|
|
ServiceSend.watchdog(ActivityMain.this);
|
|
|
|
}
|
|
|
|
}, SERVICE_START_DELAY);
|
2021-08-15 13:51:22 +00:00
|
|
|
} else {
|
|
|
|
Intent setup = new Intent(ActivityMain.this, ActivitySetup.class)
|
2021-09-27 16:57:39 +00:00
|
|
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
2021-08-15 17:42:02 +00:00
|
|
|
startActivity(setup, options);
|
2021-08-15 13:51:22 +00:00
|
|
|
}
|
2020-01-23 08:30:08 +00:00
|
|
|
|
|
|
|
long end = new Date().getTime();
|
|
|
|
Log.i("Main booted " + (end - start) + " ms");
|
|
|
|
|
2022-01-28 09:38:49 +00:00
|
|
|
finish();
|
2018-08-10 13:32:07 +00:00
|
|
|
}
|
2019-01-25 17:55:22 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
2022-06-06 13:02:11 +00:00
|
|
|
// Log.unexpectedError() won't work here
|
|
|
|
Log.e(ex);
|
|
|
|
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(ActivityMain.this);
|
|
|
|
View dview = inflater.inflate(R.layout.dialog_unexpected, null);
|
|
|
|
TextView tvError = dview.findViewById(R.id.tvError);
|
|
|
|
|
|
|
|
String message = Log.formatThrowable(ex, false);
|
|
|
|
tvError.setText(message);
|
|
|
|
|
|
|
|
new AlertDialog.Builder(ActivityMain.this)
|
|
|
|
.setView(dview)
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
.setNeutralButton(R.string.menu_faq, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
Uri uri = Helper.getSupportUri(ActivityMain.this, "Main:error")
|
|
|
|
.buildUpon()
|
|
|
|
.appendQueryParameter("message", Log.formatThrowable(ex, false))
|
|
|
|
.build();
|
|
|
|
Helper.view(ActivityMain.this, uri, true);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
|
|
@Override
|
|
|
|
public void onDismiss(DialogInterface dialog) {
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.show();
|
2019-01-25 17:55:22 +00:00
|
|
|
}
|
2019-07-10 15:58:26 +00:00
|
|
|
};
|
|
|
|
|
2021-10-30 09:10:24 +00:00
|
|
|
if (Helper.shouldAuthenticate(this, false))
|
2020-05-30 13:59:51 +00:00
|
|
|
Helper.authenticate(ActivityMain.this, ActivityMain.this, null,
|
2022-05-01 11:46:06 +00:00
|
|
|
new RunnableEx("auth:succeeded") {
|
2019-07-10 15:58:26 +00:00
|
|
|
@Override
|
2022-05-01 11:46:06 +00:00
|
|
|
public void delegate() {
|
2019-09-18 08:42:13 +00:00
|
|
|
Intent intent = getIntent();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
if (intent.hasExtra("intent"))
|
|
|
|
args.putParcelable("intent", intent.getParcelableExtra("intent"));
|
2020-01-23 08:30:08 +00:00
|
|
|
boot.execute(ActivityMain.this, args, "main:accounts");
|
2019-07-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
},
|
2022-05-01 11:46:06 +00:00
|
|
|
new RunnableEx("auth:cancelled") {
|
2019-07-10 15:58:26 +00:00
|
|
|
@Override
|
2022-05-01 11:46:06 +00:00
|
|
|
public void delegate() {
|
2019-07-11 05:34:02 +00:00
|
|
|
try {
|
2022-01-28 09:38:49 +00:00
|
|
|
finish();
|
2019-07-11 05:34:02 +00:00
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.w(ex);
|
|
|
|
/*
|
|
|
|
java.lang.NullPointerException: Attempt to invoke virtual method 'int com.android.server.fingerprint.ClientMonitor.stop(boolean)' on a null object reference
|
|
|
|
at android.os.Parcel.createException(Parcel.java:1956)
|
|
|
|
at android.os.Parcel.readException(Parcel.java:1918)
|
|
|
|
at android.os.Parcel.readException(Parcel.java:1868)
|
|
|
|
at android.app.IActivityManager$Stub$Proxy.finishActivity(IActivityManager.java:3797)
|
|
|
|
at android.app.Activity.finish(Activity.java:5608)
|
|
|
|
at android.app.Activity.finish(Activity.java:5632)
|
|
|
|
at eu.faircode.email.ActivityMain$3.run(SourceFile:111)
|
|
|
|
at eu.faircode.email.Helper$3$1.run(SourceFile:706)
|
|
|
|
at android.os.Handler.handleCallback(Handler.java:873)
|
|
|
|
at android.os.Handler.dispatchMessage(Handler.java:99)
|
|
|
|
at android.os.Looper.loop(Looper.java:193)
|
|
|
|
at android.app.ActivityThread.main(ActivityThread.java:6718)
|
|
|
|
at java.lang.reflect.Method.invoke(Method.java:-2)
|
|
|
|
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
|
|
|
|
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
|
|
|
|
Caused by: android.os.RemoteException: Remote stack trace:
|
|
|
|
at com.android.server.fingerprint.FingerprintService$5.onTaskStackChanged(FingerprintService.java:239)
|
|
|
|
at com.android.server.am.TaskChangeNotificationController.lambda$new$0(TaskChangeNotificationController.java:70)
|
|
|
|
at com.android.server.am.-$$Lambda$TaskChangeNotificationController$kftD881t3KfWCASQEbeTkieVI2M.accept(Unknown Source:0)
|
|
|
|
at com.android.server.am.TaskChangeNotificationController.forAllLocalListeners(TaskChangeNotificationController.java:263)
|
|
|
|
at com.android.server.am.TaskChangeNotificationController.notifyTaskStackChanged(TaskChangeNotificationController.java:276)
|
|
|
|
*/
|
|
|
|
}
|
2019-07-10 15:58:26 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
else
|
2020-01-23 08:30:08 +00:00
|
|
|
boot.execute(this, new Bundle(), "main:accounts");
|
2018-08-10 13:32:07 +00:00
|
|
|
} else {
|
2021-08-10 07:23:05 +00:00
|
|
|
SharedPreferences.Editor editor = prefs.edit();
|
|
|
|
Configuration config = getResources().getConfiguration();
|
|
|
|
|
|
|
|
// Default enable compact mode for smaller screens
|
2022-02-13 21:16:39 +00:00
|
|
|
if (!config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)) {
|
2021-08-10 07:23:05 +00:00
|
|
|
editor.putBoolean("compact", true);
|
2022-02-13 21:16:39 +00:00
|
|
|
//editor.putBoolean("compact_folders", true);
|
|
|
|
}
|
2021-08-10 07:23:05 +00:00
|
|
|
|
|
|
|
// Default disable landscape columns for small screens
|
|
|
|
if (!config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL)) {
|
|
|
|
editor.putBoolean("landscape", false);
|
|
|
|
editor.putBoolean("landscape3", false);
|
|
|
|
}
|
|
|
|
|
2022-02-24 18:27:34 +00:00
|
|
|
// Default send bubbles off when accessibility enabled
|
|
|
|
if (Helper.isAccessibilityEnabled(this))
|
|
|
|
editor.putBoolean("send_chips", false);
|
|
|
|
|
2021-08-10 07:23:05 +00:00
|
|
|
editor.apply();
|
2019-03-26 19:48:26 +00:00
|
|
|
|
2021-02-28 08:32:21 +00:00
|
|
|
if (Helper.isNight(this))
|
|
|
|
setTheme(R.style.AppThemeBlueOrangeDark);
|
|
|
|
else
|
|
|
|
setTheme(R.style.AppThemeBlueOrangeLight);
|
2021-06-30 09:04:22 +00:00
|
|
|
|
2018-10-30 13:47:10 +00:00
|
|
|
super.onCreate(savedInstanceState);
|
2018-08-10 13:32:07 +00:00
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
2021-06-30 09:04:22 +00:00
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
2021-10-31 16:32:02 +00:00
|
|
|
getSupportFragmentManager().addOnBackStackChangedListener(this);
|
2021-06-30 09:04:22 +00:00
|
|
|
|
2018-08-10 13:32:07 +00:00
|
|
|
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
|
|
|
fragmentTransaction.replace(R.id.content_frame, new FragmentEula()).addToBackStack("eula");
|
|
|
|
fragmentTransaction.commit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
|
|
|
PreferenceManager.getDefaultSharedPreferences(this).unregisterOnSharedPreferenceChangeListener(this);
|
|
|
|
super.onDestroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBackStackChanged() {
|
|
|
|
int count = getSupportFragmentManager().getBackStackEntryCount();
|
|
|
|
if (count == 0)
|
2022-01-28 09:38:49 +00:00
|
|
|
finish();
|
2018-08-10 13:32:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
|
|
|
if ("eula".equals(key))
|
|
|
|
if (prefs.getBoolean(key, false))
|
|
|
|
recreate();
|
|
|
|
}
|
|
|
|
}
|