Delegate compose back

This commit is contained in:
M66B 2023-09-11 19:38:05 +02:00
parent 66d718ffa2
commit 538cc943c6
2 changed files with 15 additions and 1 deletions

View File

@ -29,7 +29,9 @@ import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.core.app.TaskStackBuilder;
import androidx.core.net.MailTo;
import androidx.fragment.app.Fragment;
@ -72,6 +74,15 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
handle(intent, false);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int itemId = item.getItemId();
if (itemId == android.R.id.home &&
getSupportFragmentManager().getBackStackEntryCount() > 0)
return false; // Delegate to fragment
return super.onOptionsItemSelected(item);
}
@Override
public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {

View File

@ -2002,7 +2002,10 @@ public class FragmentCompose extends FragmentBase {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.menu_encrypt) {
if (itemId == android.R.id.home) {
onExit();
return true;
} else if (itemId == R.id.menu_encrypt) {
onMenuEncrypt();
return true;
} else if (itemId == R.id.menu_translate) {