From: Damyan Ivanov Date: Sun, 7 Mar 2021 09:09:03 +0000 (+0200) Subject: add divider after debug items in the new transaction menu X-Git-Tag: v0.17.0~17 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=2e887ef85ee3a367f252f2ac1efd21d1309fb1fd;p=mobile-ledger.git 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 --- 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 @@ - -