]> git.ktnx.net Git - mobile-ledger.git/commitdiff
add a 'more' button for entering profile edit mode
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 28 Feb 2019 07:09:02 +0000 (07:09 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 28 Feb 2019 07:09:02 +0000 (07:09 +0000)
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
app/src/main/res/anim/fade_in.xml [new file with mode: 0644]
app/src/main/res/drawable-anydpi-v21/ic_more_horiz_black_24dp.xml [new file with mode: 0644]
app/src/main/res/layout/nav_profile_list_head.xml

index 47dc798cbd5a796b4308ab402ef4d87b1d049364..b13281489d460dfb1ba322e23425c731b1bfaa83 100644 (file)
@@ -71,7 +71,7 @@ public class MainActivity extends CrashReportingActivity {
     private static final String BUNDLE_SAVED_STATE = "bundle_savedState";
     DrawerLayout drawer;
     private LinearLayout profileListContainer;
-    private View profileListHeadArrow;
+    private View profileListHeadArrow, profileListHeadMore, profileListHeadCancel;
     private FragmentManager fragmentManager;
     private TextView tvLastUpdate;
     private RetrieveTransactionsTask retrieveTransactionsTask;
@@ -117,6 +117,8 @@ public class MainActivity extends CrashReportingActivity {
         fab = findViewById(R.id.btn_add_transaction);
         profileListContainer = findViewById(R.id.nav_profile_list_container);
         profileListHeadArrow = findViewById(R.id.nav_profiles_arrow);
+        profileListHeadMore = findViewById(R.id.nav_profiles_start_edit);
+        profileListHeadCancel = findViewById(R.id.nav_profiles_cancel_edit);
         drawer = findViewById(R.id.drawer_layout);
         tvLastUpdate = findViewById(R.id.transactions_last_update);
         bTransactionListCancelDownload = findViewById(R.id.transaction_list_cancel_download);
@@ -244,24 +246,28 @@ public class MainActivity extends CrashReportingActivity {
                 if (mProfileListAdapter.isEditingProfiles()) {
                     profileListHeadArrow.clearAnimation();
                     profileListHeadArrow.setVisibility(View.GONE);
+                    profileListHeadMore.setVisibility(View.GONE);
 //                    findViewById(R.id.nav_profiles_arrow).setAlpha(0f);
-                    findViewById(R.id.nav_profiles_cancel_edit).setVisibility(View.VISIBLE);
+                    profileListHeadCancel.setVisibility(View.VISIBLE);
                 }
                 else {
                     profileListHeadArrow.setVisibility(View.VISIBLE);
 //                    findViewById(R.id.nav_profiles_arrow).setAlpha(1f);
-                    findViewById(R.id.nav_profiles_cancel_edit).setVisibility(View.GONE);
+                    profileListHeadCancel.setVisibility(View.GONE);
+                    profileListHeadMore.setVisibility(View.GONE);
+                    profileListHeadMore
+                            .setVisibility(profileListExpanded ? View.VISIBLE : View.GONE);
                 }
             }
         });
 
-        findViewById(R.id.nav_profiles_cancel_edit).setOnClickListener((v) -> {
-            mProfileListAdapter.stopEditingProfiles();
-        });
         LinearLayoutManager llm = new LinearLayoutManager(this);
 
         llm.setOrientation(RecyclerView.VERTICAL);
         root.setLayoutManager(llm);
+
+        profileListHeadMore.setOnClickListener((v) -> mProfileListAdapter.startEditingProfiles());
+        profileListHeadCancel.setOnClickListener((v) -> mProfileListAdapter.stopEditingProfiles());
     }
     private void profileThemeChanged() {
         setupProfileColors();
@@ -474,6 +480,8 @@ public class MainActivity extends CrashReportingActivity {
         profileListContainer.setVisibility(View.VISIBLE);
         profileListContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_down));
         profileListHeadArrow.startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180));
+        profileListHeadMore.setVisibility(View.VISIBLE);
+        profileListHeadMore.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fade_in));
     }
     private void collapseProfileList() {
         profileListExpanded = false;
@@ -496,6 +504,7 @@ public class MainActivity extends CrashReportingActivity {
         profileListContainer.startAnimation(animation);
         profileListHeadArrow
                 .startAnimation(AnimationUtils.loadAnimation(this, R.anim.rotate_180_back));
+        profileListHeadMore.setVisibility(View.GONE);
 
         mProfileListAdapter.stopEditingProfiles();
     }
diff --git a/app/src/main/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml
new file mode 100644 (file)
index 0000000..6739ed1
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+  ~ Copyright © 2019 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
+  ~  the Free Software Foundation, either version 3 of the License, or
+  ~  (at your opinion), any later version.
+  ~
+  ~  MoLe is distributed in the hope that it will be useful,
+  ~  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  ~  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+  ~  GNU General Public License terms for details.
+  ~
+  ~  You should have received a copy of the GNU General Public License
+  ~  along with Mobile-Ledger. If not, see <https://www.gnu.org/licenses/>.
+  -->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+    android:duration="@android:integer/config_mediumAnimTime"
+    android:startOffset="@android:integer/config_shortAnimTime">
+    <alpha
+        android:fromAlpha="0.0"
+        android:toAlpha="1.0" />
+</set>
\ No newline at end of file
diff --git a/app/src/main/res/drawable-anydpi-v21/ic_more_horiz_black_24dp.xml b/app/src/main/res/drawable-anydpi-v21/ic_more_horiz_black_24dp.xml
new file mode 100644 (file)
index 0000000..5c766e0
--- /dev/null
@@ -0,0 +1,21 @@
+<!--
+  ~ Copyright Google Inc.
+  ~
+  ~ Licensed under the Apache License, version 2.0 ("the License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the license at:
+  ~
+  ~ https://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distribution under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<vector android:height="24dp" android:tint="?colorAccent"
+    android:viewportHeight="24.0" android:viewportWidth="24.0"
+    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M6,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"/>
+</vector>
index 2b008dc85f86eee6dc2f437850d3f00b77294705..74b09ba35656b558c165cdc964102d541697afbc 100644 (file)
     android:layout_height="@dimen/thumb_row_height"
     android:paddingEnd="@dimen/activity_horizontal_margin">
 
+    <ImageView
+        android:id="@+id/nav_profiles_arrow"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:background="@drawable/ic_expand_more_black_24dp"
+        android:gravity="start|center_vertical"
+        android:onClick="navProfilesHeadClicked"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintStart_toEndOf="@id/nav_profiles_label"
+        app:layout_constraintTop_toTopOf="parent" />
+
     <LinearLayout
         android:id="@+id/nav_profile_list_head_buttons"
         android:layout_width="wrap_content"
         app:layout_constraintTop_toTopOf="parent">
 
         <ImageView
-            android:id="@+id/nav_profiles_arrow"
+            android:id="@+id/nav_profiles_cancel_edit"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:background="@drawable/ic_expand_more_black_24dp"
+            android:background="@drawable/ic_clear_black_24dp"
             android:gravity="end|center_vertical"
-            android:onClick="navProfilesHeadClicked"
+            android:visibility="gone"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
             app:layout_constraintTop_toTopOf="parent" />
 
         <ImageView
-            android:id="@+id/nav_profiles_cancel_edit"
+            android:id="@+id/nav_profiles_start_edit"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:background="@drawable/ic_clear_black_24dp"
+            android:background="@drawable/ic_more_horiz_black_24dp"
             android:gravity="end|center_vertical"
             android:visibility="gone"
             app:layout_constraintBottom_toBottomOf="parent"
     <TextView
         android:id="@+id/nav_profiles_label"
         style="@style/nav_button"
-        android:layout_width="0dp"
+        android:layout_width="wrap_content"
         android:layout_height="0dp"
-        android:layout_marginEnd="8dp"
         android:drawableStart="@drawable/ic_view_list_black_24dp"
         android:gravity="start|center_vertical"
         android:onClick="navProfilesHeadClicked"
         android:text="@string/profiles"
         app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constraintEnd_toStartOf="@+id/nav_profile_list_head_buttons"
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent" />