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();
|
||||
}
|
||||
|
||||
@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() {
|
||||
return ApplicationEx.getMainHandler();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package eu.faircode.email;
|
|||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ClipData;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -92,10 +93,16 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
|
|||
startActivity(setup);
|
||||
} else if (!shared && !widget) {
|
||||
Intent parent = getParentActivityIntent();
|
||||
Log.i("Compose exit parent=" + parent +
|
||||
" recreate=" + (parent == null ? null : shouldUpRecreateTask(parent)));
|
||||
if (parent != null)
|
||||
if (shouldUpRecreateTask(parent))
|
||||
if (parent != null) {
|
||||
boolean recreate;
|
||||
ComponentName cn = parent.getComponent();
|
||||
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)
|
||||
.addNextIntentWithParentStack(parent)
|
||||
.startActivities();
|
||||
|
@ -104,6 +111,7 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
|
|||
startActivity(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
prefs.edit().remove("last_composing").apply();
|
||||
|
|
Loading…
Reference in a new issue