Эх сурвалжийг харах

fix selection on click for new implementation, move sorting dialog references to new sorting class references

... needs duplication of the layout file

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 жил өмнө
parent
commit
aa353f064f

+ 3 - 2
app/src/main/java/com/nextcloud/talk/components/filebrowser/adapters/items/BrowserFileItem.java

@@ -34,6 +34,7 @@ import com.nextcloud.talk.R;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.components.filebrowser.models.BrowserFile;
 import com.nextcloud.talk.databinding.RvItemBrowserFileBinding;
+import com.nextcloud.talk.databinding.RvItemBrowserFileOldBinding;
 import com.nextcloud.talk.interfaces.SelectionInterface;
 import com.nextcloud.talk.models.database.UserEntity;
 import com.nextcloud.talk.utils.ApiUtils;
@@ -199,11 +200,11 @@ public class BrowserFileItem extends AbstractFlexibleItem<BrowserFileItem.Browse
 
     static class BrowserFileItemViewHolder extends FlexibleViewHolder {
 
-        RvItemBrowserFileBinding binding;
+        RvItemBrowserFileOldBinding binding;
 
         BrowserFileItemViewHolder(View view, FlexibleAdapter adapter) {
             super(view, adapter);
-            binding = RvItemBrowserFileBinding.bind(view);
+            binding = RvItemBrowserFileOldBinding.bind(view);
         }
     }
 }

+ 17 - 17
app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java

@@ -41,7 +41,6 @@ import com.nextcloud.talk.utils.LegacyFileSortOrder;
 import com.nextcloud.talk.utils.preferences.AppPreferences;
 
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 import javax.inject.Inject;
 
@@ -99,7 +98,8 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
         setRetainInstance(true);
 
         if (getArguments() != null) {
-            currentSortOrderName = getArguments().getString(KEY_SORT_ORDER, LegacyFileSortOrder.sort_a_to_z.name);
+            currentSortOrderName = getArguments().getString(KEY_SORT_ORDER,
+                                                            FileSortOrder.Companion.getSort_a_to_z().getName());
         }
     }
 
@@ -135,29 +135,29 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
 
         taggedViews = new View[12];
         taggedViews[0] = binding.sortByNameAscending;
-        taggedViews[0].setTag(LegacyFileSortOrder.sort_a_to_z);
+        taggedViews[0].setTag(FileSortOrder.Companion.getSort_a_to_z());
         taggedViews[1] = binding.sortByNameAZText;
-        taggedViews[1].setTag(LegacyFileSortOrder.sort_a_to_z);
+        taggedViews[1].setTag(FileSortOrder.Companion.getSort_a_to_z());
         taggedViews[2] = binding.sortByNameDescending;
-        taggedViews[2].setTag(LegacyFileSortOrder.sort_z_to_a);
+        taggedViews[2].setTag(FileSortOrder.Companion.getSort_z_to_a());
         taggedViews[3] = binding.sortByNameZAText;
-        taggedViews[3].setTag(LegacyFileSortOrder.sort_z_to_a);
+        taggedViews[3].setTag(FileSortOrder.Companion.getSort_z_to_a());
         taggedViews[4] = binding.sortByModificationDateAscending;
-        taggedViews[4].setTag(LegacyFileSortOrder.sort_old_to_new);
+        taggedViews[4].setTag(FileSortOrder.Companion.getSort_old_to_new());
         taggedViews[5] = binding.sortByModificationDateOldestFirstText;
-        taggedViews[5].setTag(LegacyFileSortOrder.sort_old_to_new);
+        taggedViews[5].setTag(FileSortOrder.Companion.getSort_old_to_new());
         taggedViews[6] = binding.sortByModificationDateDescending;
-        taggedViews[6].setTag(LegacyFileSortOrder.sort_new_to_old);
+        taggedViews[6].setTag(FileSortOrder.Companion.getSort_new_to_old());
         taggedViews[7] = binding.sortByModificationDateNewestFirstText;
-        taggedViews[7].setTag(LegacyFileSortOrder.sort_new_to_old);
+        taggedViews[7].setTag(FileSortOrder.Companion.getSort_new_to_old());
         taggedViews[8] = binding.sortBySizeAscending;
-        taggedViews[8].setTag(LegacyFileSortOrder.sort_small_to_big);
+        taggedViews[8].setTag(FileSortOrder.Companion.getSort_small_to_big());
         taggedViews[9] = binding.sortBySizeSmallestFirstText;
-        taggedViews[9].setTag(LegacyFileSortOrder.sort_small_to_big);
+        taggedViews[9].setTag(FileSortOrder.Companion.getSort_small_to_big());
         taggedViews[10] = binding.sortBySizeDescending;
-        taggedViews[10].setTag(LegacyFileSortOrder.sort_big_to_small);
+        taggedViews[10].setTag(FileSortOrder.Companion.getSort_big_to_small());
         taggedViews[11] = binding.sortBySizeBiggestFirstText;
-        taggedViews[11].setTag(LegacyFileSortOrder.sort_big_to_small);
+        taggedViews[11].setTag(FileSortOrder.Companion.getSort_big_to_small());
 
         setupActiveOrderSelection();
     }
@@ -169,8 +169,8 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
         final int color = getResources().getColor(R.color.colorPrimary);
         Log.i("SortOrder", "currentSortOrderName="+currentSortOrderName);
         for (View view : taggedViews) {
-            Log.i("SortOrder", ((LegacyFileSortOrder) view.getTag()).name);
-            if (!((LegacyFileSortOrder) view.getTag()).name.equals(currentSortOrderName)) {
+            Log.i("SortOrder", ((FileSortOrder) view.getTag()).getName());
+            if (!((FileSortOrder) view.getTag()).getName().equals(currentSortOrderName)) {
                 continue;
             }
             if (view instanceof MaterialButton) {
@@ -207,7 +207,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
 
     @Override
     public void onClick(View v) {
-        appPreferences.setSorting(((LegacyFileSortOrder) v.getTag()).name);
+        appPreferences.setSorting(((FileSortOrder) v.getTag()).getName());
         dismiss();
     }
 }

+ 1 - 1
app/src/main/res/layout/controller_browser.xml

@@ -93,7 +93,7 @@
             android:id="@+id/recycler_view"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            tools:listitem="@layout/rv_item_browser_file" />
+            tools:listitem="@layout/rv_item_browser_file_old" />
 
     </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 

+ 2 - 2
app/src/main/res/layout/rv_item_browser_file.xml

@@ -34,8 +34,8 @@
         android:layout_height="48dp"
         android:layout_alignParentEnd="true"
         android:layout_centerVertical="true"
-        android:clickable="true"
-        android:focusable="true"
+        android:clickable="false"
+        android:focusable="false"
         android:longClickable="false"
         android:visibility="visible" />
 

+ 105 - 0
app/src/main/res/layout/rv_item_browser_file_old.xml

@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+  ~ Nextcloud Talk application
+  ~
+  ~ @author Mario Danic
+  ~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
+  ~
+  ~ This program is free software: you can redistribute it and/or modify
+  ~ it under the terms of the GNU General Public License as published by
+  ~ the Free Software Foundation, either version 3 of the License, or
+  ~ at your option) any later version.
+  ~
+  ~ This program 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 for more details.
+  ~
+  ~ You should have received a copy of the GNU General Public License
+  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+  -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:layout_marginTop="@dimen/standard_margin"
+    android:layout_marginStart="@dimen/standard_margin"
+    android:layout_marginBottom="@dimen/standard_margin"
+    android:background="@color/bg_default">
+
+    <CheckBox
+        android:id="@+id/select_file_checkbox"
+        android:layout_width="48dp"
+        android:layout_height="48dp"
+        android:layout_alignParentEnd="true"
+        android:layout_centerVertical="true"
+        android:clickable="true"
+        android:focusable="true"
+        android:longClickable="false"
+        android:visibility="visible" />
+
+    <ImageView
+        android:id="@+id/fileFavoriteImageView"
+        android:layout_width="16dp"
+        android:layout_height="16dp"
+        android:layout_below="@id/file_icon"
+        android:layout_alignEnd="@id/file_icon"
+        android:contentDescription="@string/starred"
+        android:src="@drawable/ic_star_black_24dp"
+        app:tint="@color/favorite_icon_tint" />
+
+    <ImageView
+        android:id="@+id/fileEncryptedImageView"
+        android:layout_width="16dp"
+        android:layout_height="16dp"
+        android:layout_below="@id/file_icon"
+        android:layout_alignStart="@+id/file_icon"
+        android:contentDescription="@string/encrypted"
+        android:src="@drawable/ic_lock_grey600_24px" />
+
+    <TextView
+        android:id="@+id/file_modified_info"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignWithParentIfMissing="true"
+        android:layout_below="@id/filename_text_view"
+        android:layout_alignParentBottom="true"
+        android:layout_toStartOf="@id/select_file_checkbox"
+        android:layout_toEndOf="@id/file_icon"
+        android:ellipsize="marquee"
+        android:marqueeRepeatLimit="1"
+        android:paddingBottom="6dp"
+        android:singleLine="true"
+        android:textAlignment="viewStart"
+        android:textColor="@color/textColorMaxContrast"
+        android:textSize="14sp"
+        tools:text="3 minutes ago" />
+
+    <TextView
+        android:id="@+id/filename_text_view"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignWithParentIfMissing="true"
+        android:layout_alignParentTop="true"
+        android:layout_toStartOf="@id/select_file_checkbox"
+        android:layout_toEndOf="@id/file_icon"
+        android:ellipsize="marquee"
+        android:marqueeRepeatLimit="1"
+        android:paddingTop="6dp"
+        android:singleLine="true"
+        android:textAlignment="viewStart"
+        android:textColor="@color/conversation_item_header"
+        android:textSize="@dimen/two_line_primary_text_size"
+        tools:text="filename.md" />
+
+    <com.facebook.drawee.view.SimpleDraweeView
+        android:id="@+id/file_icon"
+        android:layout_width="40dp"
+        android:layout_height="40dp"
+        android:layout_centerVertical="true"
+        android:layout_marginEnd="@dimen/standard_margin"
+        app:actualImageScaleType="fitCenter"
+        app:placeholderImageScaleType="fitCenter" />
+
+</RelativeLayout>