replace add account floating action button with a menu item
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 30 Nov 2018 18:15:29 +0000 (18:15 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Fri, 30 Nov 2018 18:15:29 +0000 (18:15 +0000)
app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java
app/src/main/res/layout/activity_new_transaction.xml
app/src/main/res/menu/new_transaction.xml [new file with mode: 0644]
app/src/main/res/values/strings.xml

index 1c1f863a7033161a006a98a75b7a782303364096..12e8b69eecdb4b98287999cb67f0351fa7205041 100644 (file)
@@ -6,6 +6,8 @@ import android.support.design.widget.Snackbar;
 import android.support.v4.app.DialogFragment;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.widget.Toolbar;
+import android.view.Menu;
+import android.view.MenuItem;
 import android.view.View;
 
 import java.util.Objects;
@@ -30,6 +32,13 @@ public class NewTransactionActivity extends AppCompatActivity {
         Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
     }
 
+    public boolean onCreateOptionsMenu(Menu menu) {
+        // Inflate the menu; this adds items to the action bar if it is present.
+        getMenuInflater().inflate(R.menu.new_transaction, menu);
+
+        return true;
+    }
+
     public void pickTransactionDate(View view) {
         DialogFragment picker = new DatePickerFragment();
         picker.show(getSupportFragmentManager(), "datePicker");
@@ -37,4 +46,9 @@ public class NewTransactionActivity extends AppCompatActivity {
 //                .setAction("Action", null).show();
     }
 
+    public void addTransactionAccountFromMenu(MenuItem item) {
+        Snackbar.make(getCurrentFocus(), "Not implemented yet", Snackbar.LENGTH_LONG)
+                .setAction("Action", null).show();
+    }
+
 }
index 69ef23ec3cdabf636c47114a6ff1887b8b3554a4..bd73df16ebfa497419ae03fd9eab9946ff1a07a7 100644 (file)
         app:backgroundTint="@color/colorPrimary"
         app:srcCompat="@android:drawable/ic_menu_send" />
 
-    <android.support.design.widget.FloatingActionButton
-        android:id="@+id/fab_add_account"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_gravity="top|end"
-        android:layout_marginBottom="80dp"
-        android:clickable="true"
-        android:focusable="auto"
-        app:layout_anchor="@id/fab"
-        app:layout_anchorGravity="top"
-        app:srcCompat="@drawable/svg_thick_plus_white" />
-
 </android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/menu/new_transaction.xml b/app/src/main/res/menu/new_transaction.xml
new file mode 100644 (file)
index 0000000..056bfb2
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+    <menu xmlns:android="http://schemas.android.com/apk/res/android"
+        xmlns:app="http://schemas.android.com/apk/res-auto">
+        <item
+            android:id="@+id/action_add_account"
+            android:icon="@drawable/svg_thick_plus_white"
+            android:onClick="addTransactionAccountFromMenu"
+            android:orderInCategory="100"
+            android:title="@string/menu_add_account"
+            app:showAsAction="never|ifRoom" />
+</menu>
\ No newline at end of file
index 23d2ee12c2a350985e87387f8293ed6863cf4a44..e284d05d97b9ada5a8dd7c9065f0dc9ff015372e 100644 (file)
@@ -58,4 +58,5 @@
     <string name="new_transaction_account_label">Account</string>
     <string name="new_transaction_date_hint">Transaction date</string>
     <string name="new_transaction_amount_hint">amount</string>
+    <string name="menu_add_account">Add another acount</string>
 </resources>