Improved compose recreate logic

pull/215/head
M66B 3 months ago
parent e22d389596
commit b11ceea73b

@ -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();
@ -103,6 +110,7 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
parent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(parent);
}
}
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

Loading…
Cancel
Save