From f295e97de6a9b7005e3fd6425296a5cd9d37af6b Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 28 Jan 2020 01:49:37 +0530 Subject: Allow creating folders (#623) * Introduce EmitExpandableTransformationBehaviour * Implement expand transition * More folder work * Add icons and tweak layout clipping Rishi again with the icon rescue * Theming rework * Dont set tag * Update list and commit after creating folder * Fix theme issues * Add dialog title * Fix hint text color * Remove commit method * Cleanup * Update CHANGELOG Signed-off-by: Harsh Shandilya Co-authored-by: Aditya Wasan --- .../java/com/zeapo/pwdstore/PasswordFragment.kt | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt index 61437731..22bad566 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.kt @@ -70,12 +70,30 @@ class PasswordFragment : Fragment() { recyclerView.adapter = recyclerAdapter // Setup fast scroller FastScrollerBuilder(recyclerView).build() - val fab: FloatingActionButton = view.findViewById(R.id.fab) - fab.setOnClickListener { (requireActivity() as PasswordStore).createPassword() } + val fab = view.findViewById(R.id.fab) + fab.setOnClickListener { + toggleFabExpand(fab) + } + + view.findViewById(R.id.create_folder).setOnClickListener { + (requireActivity() as PasswordStore).createFolder() + toggleFabExpand(fab) + } + + view.findViewById(R.id.create_password).setOnClickListener { + (requireActivity() as PasswordStore).createPassword() + toggleFabExpand(fab) + } registerForContextMenu(recyclerView) return view } + private fun toggleFabExpand(fab: FloatingActionButton) = with(fab) { + isExpanded = !isExpanded + isActivated = isExpanded + animate().rotationBy(if (isExpanded) -45f else 45f).setDuration(100).start() + } + override fun onAttach(context: Context) { super.onAttach(context) try { -- cgit v1.2.3