Delegate compose back

pull/214/head
M66B 2 years ago
parent 66d718ffa2
commit 538cc943c6

@ -29,7 +29,9 @@ import android.os.Bundle;
import android.text.Html; import android.text.Html;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.core.app.TaskStackBuilder; import androidx.core.app.TaskStackBuilder;
import androidx.core.net.MailTo; import androidx.core.net.MailTo;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
@ -72,6 +74,15 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
handle(intent, false); 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 @Override
public void onBackStackChanged() { public void onBackStackChanged() {
if (getSupportFragmentManager().getBackStackEntryCount() == 0) { if (getSupportFragmentManager().getBackStackEntryCount() == 0) {

@ -2002,7 +2002,10 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
int itemId = item.getItemId(); 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(); onMenuEncrypt();
return true; return true;
} else if (itemId == R.id.menu_translate) { } else if (itemId == R.id.menu_translate) {

Loading…
Cancel
Save