From 395309e39e591c7ae76c27027b696456efd5b21a Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Fri, 17 Jul 2015 22:18:41 -0400 Subject: Use android support library (for fab) --- .../java/com/zeapo/pwdstore/PasswordFragment.java | 11 +++++--- .../java/com/zeapo/pwdstore/PasswordStore.java | 2 +- app/src/main/res/layout/password_recycler_view.xml | 29 +++++++++++----------- app/src/main/res/values-v21/dimens.xml | 4 +++ app/src/main/res/values/dimens.xml | 1 + 5 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/values-v21/dimens.xml (limited to 'app/src/main') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java index 07ed9895..7d54edf2 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java @@ -5,6 +5,7 @@ import android.app.Fragment; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.design.widget.FloatingActionButton; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; @@ -13,7 +14,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import com.melnykov.fab.FloatingActionButton; import com.zeapo.pwdstore.utils.PasswordItem; import com.zeapo.pwdstore.utils.PasswordRecyclerAdapter; import com.zeapo.pwdstore.utils.PasswordRepository; @@ -78,8 +78,13 @@ public class PasswordFragment extends Fragment{ // // Set the adapter recyclerView.setAdapter(recyclerAdapter); - FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab); - fab.attachToRecyclerView(recyclerView); + final FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ((PasswordStore) getActivity()).createPassword(); + } + }); registerForContextMenu(recyclerView); return view; diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 5562f0b9..57386c00 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -353,7 +353,7 @@ public class PasswordStore extends AppCompatActivity { startActivityForResult(intent, PgpHandler.REQUEST_CODE_DECRYPT_AND_VERIFY); } - public void createPassword(View v) { + public void createPassword() { if (!PasswordRepository.isInitialized()) { new AlertDialog.Builder(this) .setMessage(this.getResources().getString(R.string.creation_dialog_text)) diff --git a/app/src/main/res/layout/password_recycler_view.xml b/app/src/main/res/layout/password_recycler_view.xml index b9a4231f..1b922a17 100644 --- a/app/src/main/res/layout/password_recycler_view.xml +++ b/app/src/main/res/layout/password_recycler_view.xml @@ -1,11 +1,11 @@ + xmlns:tools="http://schemas.android.com/tools" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + tools:context="com.zeapo.pwdstore.PasswordFragment"> - + android:layout_alignParentRight="true"/> diff --git a/app/src/main/res/values-v21/dimens.xml b/app/src/main/res/values-v21/dimens.xml new file mode 100644 index 00000000..daaecce2 --- /dev/null +++ b/app/src/main/res/values-v21/dimens.xml @@ -0,0 +1,4 @@ + + + 16dp + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 47c82246..8a517840 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -2,4 +2,5 @@ 16dp 16dp + 0dp -- cgit v1.2.3