mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-01 09:16:00 +00:00
Improved compose recreate logic
This commit is contained in:
parent
e22d389596
commit
b11ceea73b
2 changed files with 12 additions and 14 deletions
|
@ -1066,16 +1066,6 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||||
performBack();
|
performBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldUpRecreateTask(Intent targetIntent) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
||||||
ComponentName cn = targetIntent.getComponent();
|
|
||||||
if (cn != null && BuildConfig.APPLICATION_ID.equals(cn.getPackageName()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return super.shouldUpRecreateTask(targetIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Handler getMainHandler() {
|
Handler getMainHandler() {
|
||||||
return ApplicationEx.getMainHandler();
|
return ApplicationEx.getMainHandler();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
||||||
|
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -92,10 +93,16 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
|
||||||
startActivity(setup);
|
startActivity(setup);
|
||||||
} else if (!shared && !widget) {
|
} else if (!shared && !widget) {
|
||||||
Intent parent = getParentActivityIntent();
|
Intent parent = getParentActivityIntent();
|
||||||
Log.i("Compose exit parent=" + parent +
|
if (parent != null) {
|
||||||
" recreate=" + (parent == null ? null : shouldUpRecreateTask(parent)));
|
boolean recreate;
|
||||||
if (parent != null)
|
ComponentName cn = parent.getComponent();
|
||||||
if (shouldUpRecreateTask(parent))
|
if (cn != null && BuildConfig.APPLICATION_ID.equals(cn.getPackageName()))
|
||||||
|
recreate = false;
|
||||||
|
else
|
||||||
|
recreate = shouldUpRecreateTask(parent);
|
||||||
|
|
||||||
|
Log.i("Compose exit parent=" + parent + " recreate=" + recreate);
|
||||||
|
if (recreate)
|
||||||
TaskStackBuilder.create(this)
|
TaskStackBuilder.create(this)
|
||||||
.addNextIntentWithParentStack(parent)
|
.addNextIntentWithParentStack(parent)
|
||||||
.startActivities();
|
.startActivities();
|
||||||
|
@ -103,6 +110,7 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
|
||||||
parent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
parent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
startActivity(parent);
|
startActivity(parent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
Loading…
Reference in a new issue