From: Damyan Ivanov Date: Mon, 1 Feb 2021 06:38:09 +0000 (+0200) Subject: handle back arrow tap in patterns activity X-Git-Tag: v0.17.0~175 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=0162f26f7b07bf2db15f5cb4026f94655f019618;p=mobile-ledger.git handle back arrow tap in patterns activity --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/patterns/PatternsActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/patterns/PatternsActivity.java index 793a2be2..945123d9 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/patterns/PatternsActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/patterns/PatternsActivity.java @@ -19,6 +19,7 @@ package net.ktnx.mobileledger.ui.patterns; import android.os.Bundle; import android.view.Menu; +import android.view.MenuItem; import androidx.appcompat.app.ActionBar; import androidx.lifecycle.ViewModelProvider; @@ -78,6 +79,20 @@ public class PatternsActivity extends CrashReportingActivity b.fabAdd.setOnClickListener(v -> onEditPattern(null)); b.fabSave.setOnClickListener(v -> onSavePattern()); } + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == android.R.id.home) { + if (navController.getCurrentDestination() + .getId() == R.id.patternDetailsFragment) + navController.popBackStack(); + else + finish(); + + return true; + } + return super.onOptionsItemSelected(item); + } + @Override public void onEditPattern(Long id) { if (id == null) {