From: Damyan Ivanov Date: Fri, 30 Nov 2018 18:15:29 +0000 (+0000) Subject: replace add account floating action button with a menu item X-Git-Tag: v0.3~374 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=64c5e27bab910eb9d0730ecafc7933ed4c6963f6;p=mobile-ledger.git replace add account floating action button with a menu item --- diff --git a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java index 1c1f863a..12e8b69e 100644 --- a/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/NewTransactionActivity.java @@ -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(); + } + } diff --git a/app/src/main/res/layout/activity_new_transaction.xml b/app/src/main/res/layout/activity_new_transaction.xml index 69ef23ec..bd73df16 100644 --- a/app/src/main/res/layout/activity_new_transaction.xml +++ b/app/src/main/res/layout/activity_new_transaction.xml @@ -31,16 +31,4 @@ app:backgroundTint="@color/colorPrimary" app:srcCompat="@android:drawable/ic_menu_send" /> - - \ 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 index 00000000..056bfb2c --- /dev/null +++ b/app/src/main/res/menu/new_transaction.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 23d2ee12..e284d05d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,4 +58,5 @@ Account Transaction date amount + Add another acount