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;
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 -> {
<?xml version="1.0" encoding="utf-8"?><!--
- ~ Copyright © 2019 Damyan Ivanov.
+ ~ Copyright © 2021 Damyan Ivanov.
~ This file is part of MoLe.
~ MoLe is free software: you can distribute it and/or modify it
~ under the term of the GNU General Public License as published by
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
- <item
- android:id="@+id/action_simulate_crash"
- android:title="@string/crash_app_label"
- android:titleCondensed="@string/crash_app_condensed_label"
- android:onClick="simulateCrash"
- android:visible="false"
- app:showAsAction="never" />
- <item
- android:id="@+id/action_simulate_save"
- android:checkable="true"
- android:checked="false"
- android:onClick="toggleSimulateSave"
- android:title="@string/simulate_save_label"
- android:titleCondensed="@string/simulate_save_condensed_label"
- android:visible="false"
- app:showAsAction="never" />
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ >
+ <group android:id="@+id/new_transaction_debug_menu_items">
+ <item
+ android:id="@+id/action_simulate_crash"
+ android:onClick="simulateCrash"
+ android:title="@string/crash_app_label"
+ android:titleCondensed="@string/crash_app_condensed_label"
+ app:showAsAction="never"
+ />
+ <item
+ android:id="@+id/action_simulate_save"
+ android:checkable="true"
+ android:checked="false"
+ android:onClick="toggleSimulateSave"
+ android:title="@string/simulate_save_label"
+ android:titleCondensed="@string/simulate_save_condensed_label"
+ app:showAsAction="never"
+ />
+ </group>
</menu>
\ No newline at end of file
-<?xml version="1.0" encoding="utf-8"?>
-<!--
+<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright © 2021 Damyan Ivanov.
~ This file is part of MoLe.
~ MoLe is free software: you can distribute it and/or modify it
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
- <item
- android:id="@+id/scan_qr"
- android:icon="@drawable/ic_baseline_qr_code_scanner_24"
- android:title="@string/scan_qr"
- app:showAsAction="ifRoom"
- />
- <item
- android:id="@+id/toggle_currency"
- android:title="@string/show_currency_input"
- android:checkable="true"
- android:checked="false"
- app:actionLayout="@layout/switch_item"
- app:showAsAction="never"
- />
- <item
- android:id="@+id/toggle_comments"
- android:checkable="true"
- android:title="@string/show_comments_switch"
- app:actionLayout="@layout/switch_item"
- app:showAsAction="never" />
- <item
- android:id="@+id/action_reset_new_transaction_activity"
- android:icon="@drawable/ic_refresh_white_24dp"
- android:title="@string/action_reset_new_transaction_activity_title"
- app:showAsAction="never" />
-
+ <group android:id="@+id/new_transaction_fragment_menu_items">
+ <item
+ android:id="@+id/scan_qr"
+ android:icon="@drawable/ic_baseline_qr_code_scanner_24"
+ android:title="@string/scan_qr"
+ app:showAsAction="ifRoom"
+ />
+ <item
+ android:id="@+id/toggle_currency"
+ android:checkable="true"
+ android:checked="false"
+ android:title="@string/show_currency_input"
+ app:actionLayout="@layout/switch_item"
+ app:showAsAction="never"
+ />
+ <item
+ android:id="@+id/toggle_comments"
+ android:checkable="true"
+ android:title="@string/show_comments_switch"
+ app:actionLayout="@layout/switch_item"
+ app:showAsAction="never"
+ />
+ <item
+ android:id="@+id/action_reset_new_transaction_activity"
+ android:icon="@drawable/ic_refresh_white_24dp"
+ android:title="@string/action_reset_new_transaction_activity_title"
+ app:showAsAction="never"
+ />
+ </group>
</menu>
\ No newline at end of file