From 2e887ef85ee3a367f252f2ac1efd21d1309fb1fd Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 7 Mar 2021 11:09:03 +0200 Subject: [PATCH] add divider after debug items in the new transaction menu also, call super.onCreateOptionsMenu to let the system put any system menu items if needed also, don't bother with debug menu items in the release build --- .../NewTransactionActivity.java | 13 +++-- app/src/main/res/menu/new_transaction.xml | 39 +++++++------ .../res/menu/new_transaction_fragment.xml | 58 ++++++++++--------- 3 files changed, 58 insertions(+), 52 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java index 3e177260..5bba06e1 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java @@ -31,6 +31,7 @@ import android.view.View; import androidx.activity.result.ActivityResultLauncher; import androidx.annotation.NonNull; +import androidx.core.view.MenuCompat; import androidx.lifecycle.LiveData; import androidx.lifecycle.ViewModelProvider; import androidx.navigation.NavController; @@ -159,15 +160,15 @@ public class NewTransactionActivity extends ProfileThemedActivity new AsyncCrasher().execute(); } public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + + if (!BuildConfig.DEBUG) + return true; + // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.new_transaction, menu); - if (BuildConfig.DEBUG) { - menu.findItem(R.id.action_simulate_crash) - .setVisible(true); - menu.findItem(R.id.action_simulate_save) - .setVisible(true); - } + MenuCompat.setGroupDividerEnabled(menu, true); model.getSimulateSave() .observe(this, state -> { diff --git a/app/src/main/res/menu/new_transaction.xml b/app/src/main/res/menu/new_transaction.xml index 06075080..15fe57b0 100644 --- a/app/src/main/res/menu/new_transaction.xml +++ b/app/src/main/res/menu/new_transaction.xml @@ -1,5 +1,5 @@ - - + xmlns:app="http://schemas.android.com/apk/res-auto" + > + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/new_transaction_fragment.xml b/app/src/main/res/menu/new_transaction_fragment.xml index 1fe38243..b9a34687 100644 --- a/app/src/main/res/menu/new_transaction_fragment.xml +++ b/app/src/main/res/menu/new_transaction_fragment.xml @@ -1,5 +1,4 @@ - -