Browse Source

mark deprecated and rename legacy sort implementation

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 years ago
parent
commit
c71d1da334

+ 5 - 5
app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.kt

@@ -50,7 +50,7 @@ import com.nextcloud.talk.interfaces.SelectionInterface
 import com.nextcloud.talk.models.database.UserEntity
 import com.nextcloud.talk.ui.dialog.SortingOrderDialogFragment
 import com.nextcloud.talk.utils.DisplayUtils
-import com.nextcloud.talk.utils.FileSortOrder
+import com.nextcloud.talk.utils.LegacyFileSortOrder
 import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_BROWSER_TYPE
 import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY
 import com.nextcloud.talk.utils.database.user.UserUtils
@@ -142,7 +142,7 @@ abstract class BrowserController(args: Bundle) :
         binding.sortButton.setOnClickListener { changeSorting() }
 
         binding.sortButton.setText(
-            DisplayUtils.getSortOrderStringId(FileSortOrder.getFileSortOrder(appPreferences?.sorting))
+            DisplayUtils.getSortOrderStringId(LegacyFileSortOrder.getFileSortOrder(appPreferences?.sorting))
         )
 
         refreshCurrentPath()
@@ -154,7 +154,7 @@ abstract class BrowserController(args: Bundle) :
 
     fun changeSorting() {
         val newFragment: DialogFragment = SortingOrderDialogFragment
-            .newInstance(FileSortOrder.getFileSortOrder(appPreferences?.sorting))
+            .newInstance(LegacyFileSortOrder.getFileSortOrder(appPreferences?.sorting))
         newFragment.show(
             (activity as MainActivity?)!!.supportFragmentManager,
             SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT
@@ -208,7 +208,7 @@ abstract class BrowserController(args: Bundle) :
             }
         }
 
-        FileSortOrder.getFileSortOrder(appPreferences?.sorting).sortCloudFiles(recyclerViewItems)
+        LegacyFileSortOrder.getFileSortOrder(appPreferences?.sorting).sortCloudFiles(recyclerViewItems)
 
         if (activity != null) {
             activity!!.runOnUiThread {
@@ -319,7 +319,7 @@ abstract class BrowserController(args: Bundle) :
         OnPreferenceValueChangedListener<String> {
         override fun onChanged(newValue: String) {
             try {
-                val sortOrder = FileSortOrder.getFileSortOrder(newValue)
+                val sortOrder = LegacyFileSortOrder.getFileSortOrder(newValue)
 
                 browserController.binding.sortButton.setText(DisplayUtils.getSortOrderStringId(sortOrder))
                 browserController.recyclerViewItems = sortOrder.sortCloudFiles(browserController.recyclerViewItems)

+ 2 - 2
app/src/main/java/com/nextcloud/talk/remotefilebrowser/activities/RemoteFileBrowserActivity.kt

@@ -43,7 +43,7 @@ import com.nextcloud.talk.remotefilebrowser.adapters.RemoteFileBrowserItemsAdapt
 import com.nextcloud.talk.remotefilebrowser.viewmodels.RemoteFileBrowserItemsViewModel
 import com.nextcloud.talk.ui.dialog.SortingOrderDialogFragment
 import com.nextcloud.talk.utils.DisplayUtils
-import com.nextcloud.talk.utils.FileSortOrder
+import com.nextcloud.talk.utils.LegacyFileSortOrder
 import com.nextcloud.talk.utils.database.user.UserUtils
 import javax.inject.Inject
 
@@ -175,7 +175,7 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
 
     private fun changeSorting() {
         val newFragment: DialogFragment = SortingOrderDialogFragment
-            .newInstance(FileSortOrder.getFileSortOrder(viewModel.fileSortOrder.value!!.name))
+            .newInstance(LegacyFileSortOrder.getFileSortOrder(viewModel.fileSortOrder.value!!.name))
         newFragment.show(
             supportFragmentManager,
             SortingOrderDialogFragment.SORTING_ORDER_FRAGMENT

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

@@ -36,7 +36,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
 import com.nextcloud.talk.R;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.databinding.SortingOrderFragmentBinding;
-import com.nextcloud.talk.utils.FileSortOrder;
+import com.nextcloud.talk.utils.LegacyFileSortOrder;
 import com.nextcloud.talk.utils.preferences.AppPreferences;
 
 import javax.inject.Inject;
@@ -67,7 +67,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
     private View[] taggedViews;
     private String currentSortOrderName;
 
-    public static SortingOrderDialogFragment newInstance(FileSortOrder sortOrder) {
+    public static SortingOrderDialogFragment newInstance(LegacyFileSortOrder sortOrder) {
         SortingOrderDialogFragment dialogFragment = new SortingOrderDialogFragment();
 
         Bundle args = new Bundle();
@@ -84,7 +84,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
         setRetainInstance(true);
 
         if (getArguments() != null) {
-            currentSortOrderName = getArguments().getString(KEY_SORT_ORDER, FileSortOrder.sort_a_to_z.name);
+            currentSortOrderName = getArguments().getString(KEY_SORT_ORDER, LegacyFileSortOrder.sort_a_to_z.name);
         }
     }
 
@@ -120,29 +120,29 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
 
         taggedViews = new View[12];
         taggedViews[0] = binding.sortByNameAscending;
-        taggedViews[0].setTag(FileSortOrder.sort_a_to_z);
+        taggedViews[0].setTag(LegacyFileSortOrder.sort_a_to_z);
         taggedViews[1] = binding.sortByNameAZText;
-        taggedViews[1].setTag(FileSortOrder.sort_a_to_z);
+        taggedViews[1].setTag(LegacyFileSortOrder.sort_a_to_z);
         taggedViews[2] = binding.sortByNameDescending;
-        taggedViews[2].setTag(FileSortOrder.sort_z_to_a);
+        taggedViews[2].setTag(LegacyFileSortOrder.sort_z_to_a);
         taggedViews[3] = binding.sortByNameZAText;
-        taggedViews[3].setTag(FileSortOrder.sort_z_to_a);
+        taggedViews[3].setTag(LegacyFileSortOrder.sort_z_to_a);
         taggedViews[4] = binding.sortByModificationDateAscending;
-        taggedViews[4].setTag(FileSortOrder.sort_old_to_new);
+        taggedViews[4].setTag(LegacyFileSortOrder.sort_old_to_new);
         taggedViews[5] = binding.sortByModificationDateOldestFirstText;
-        taggedViews[5].setTag(FileSortOrder.sort_old_to_new);
+        taggedViews[5].setTag(LegacyFileSortOrder.sort_old_to_new);
         taggedViews[6] = binding.sortByModificationDateDescending;
-        taggedViews[6].setTag(FileSortOrder.sort_new_to_old);
+        taggedViews[6].setTag(LegacyFileSortOrder.sort_new_to_old);
         taggedViews[7] = binding.sortByModificationDateNewestFirstText;
-        taggedViews[7].setTag(FileSortOrder.sort_new_to_old);
+        taggedViews[7].setTag(LegacyFileSortOrder.sort_new_to_old);
         taggedViews[8] = binding.sortBySizeAscending;
-        taggedViews[8].setTag(FileSortOrder.sort_small_to_big);
+        taggedViews[8].setTag(LegacyFileSortOrder.sort_small_to_big);
         taggedViews[9] = binding.sortBySizeSmallestFirstText;
-        taggedViews[9].setTag(FileSortOrder.sort_small_to_big);
+        taggedViews[9].setTag(LegacyFileSortOrder.sort_small_to_big);
         taggedViews[10] = binding.sortBySizeDescending;
-        taggedViews[10].setTag(FileSortOrder.sort_big_to_small);
+        taggedViews[10].setTag(LegacyFileSortOrder.sort_big_to_small);
         taggedViews[11] = binding.sortBySizeBiggestFirstText;
-        taggedViews[11].setTag(FileSortOrder.sort_big_to_small);
+        taggedViews[11].setTag(LegacyFileSortOrder.sort_big_to_small);
 
         setupActiveOrderSelection();
     }
@@ -154,8 +154,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", ((FileSortOrder) view.getTag()).name);
-            if (!((FileSortOrder) view.getTag()).name.equals(currentSortOrderName)) {
+            Log.i("SortOrder", ((LegacyFileSortOrder) view.getTag()).name);
+            if (!((LegacyFileSortOrder) view.getTag()).name.equals(currentSortOrderName)) {
                 continue;
             }
             if (view instanceof MaterialButton) {
@@ -192,7 +192,7 @@ public class SortingOrderDialogFragment extends DialogFragment implements View.O
 
     @Override
     public void onClick(View v) {
-        appPreferences.setSorting(((FileSortOrder) v.getTag()).name);
+        appPreferences.setSorting(((LegacyFileSortOrder) v.getTag()).name);
         dismiss();
     }
 }

+ 7 - 7
app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java

@@ -110,12 +110,12 @@ import androidx.core.graphics.ColorUtils;
 import androidx.core.graphics.drawable.DrawableCompat;
 import androidx.emoji.text.EmojiCompat;
 
-import static com.nextcloud.talk.utils.FileSortOrder.sort_a_to_z_id;
-import static com.nextcloud.talk.utils.FileSortOrder.sort_big_to_small_id;
-import static com.nextcloud.talk.utils.FileSortOrder.sort_new_to_old_id;
-import static com.nextcloud.talk.utils.FileSortOrder.sort_old_to_new_id;
-import static com.nextcloud.talk.utils.FileSortOrder.sort_small_to_big_id;
-import static com.nextcloud.talk.utils.FileSortOrder.sort_z_to_a_id;
+import static com.nextcloud.talk.utils.LegacyFileSortOrder.sort_a_to_z_id;
+import static com.nextcloud.talk.utils.LegacyFileSortOrder.sort_big_to_small_id;
+import static com.nextcloud.talk.utils.LegacyFileSortOrder.sort_new_to_old_id;
+import static com.nextcloud.talk.utils.LegacyFileSortOrder.sort_old_to_new_id;
+import static com.nextcloud.talk.utils.LegacyFileSortOrder.sort_small_to_big_id;
+import static com.nextcloud.talk.utils.LegacyFileSortOrder.sort_z_to_a_id;
 
 public class DisplayUtils {
 
@@ -618,7 +618,7 @@ public class DisplayUtils {
     }
 
     public static @StringRes
-    int getSortOrderStringId(FileSortOrder sortOrder) {
+    int getSortOrderStringId(LegacyFileSortOrder sortOrder) {
         switch (sortOrder.name) {
             case sort_z_to_a_id:
                 return R.string.menu_item_sort_by_name_z_a;

+ 12 - 12
app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.java → app/src/main/java/com/nextcloud/talk/utils/LegacyFileSortOrder.java

@@ -26,7 +26,6 @@ import android.text.TextUtils;
 
 import com.nextcloud.talk.components.filebrowser.adapters.items.BrowserFileItem;
 
-import java.io.File;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -37,7 +36,8 @@ import androidx.annotation.Nullable;
 /**
  * Sort order
  */
-public class FileSortOrder {
+@Deprecated
+public class LegacyFileSortOrder {
     public static final String sort_a_to_z_id = "sort_a_to_z";
     public static final String sort_z_to_a_id = "sort_z_to_a";
     public static final String sort_old_to_new_id = "sort_old_to_new";
@@ -45,17 +45,17 @@ public class FileSortOrder {
     public static final String sort_small_to_big_id = "sort_small_to_big";
     public static final String sort_big_to_small_id = "sort_big_to_small";
 
-    public static final FileSortOrder sort_a_to_z = new FileSortOrderByName(sort_a_to_z_id, true);
-    public static final FileSortOrder sort_z_to_a = new FileSortOrderByName(sort_z_to_a_id, false);
-    public static final FileSortOrder sort_old_to_new = new FileSortOrderByDate(sort_old_to_new_id, true);
-    public static final FileSortOrder sort_new_to_old = new FileSortOrderByDate(sort_new_to_old_id, false);
-    public static final FileSortOrder sort_small_to_big = new FileSortOrderBySize(sort_small_to_big_id, true);
-    public static final FileSortOrder sort_big_to_small = new FileSortOrderBySize(sort_big_to_small_id, false);
+    public static final LegacyFileSortOrder sort_a_to_z = new LegacyFileSortOrderByName(sort_a_to_z_id, true);
+    public static final LegacyFileSortOrder sort_z_to_a = new LegacyFileSortOrderByName(sort_z_to_a_id, false);
+    public static final LegacyFileSortOrder sort_old_to_new = new LegacyFileSortOrderByDate(sort_old_to_new_id, true);
+    public static final LegacyFileSortOrder sort_new_to_old = new LegacyFileSortOrderByDate(sort_new_to_old_id, false);
+    public static final LegacyFileSortOrder sort_small_to_big = new LegacyFileSortOrderBySize(sort_small_to_big_id, true);
+    public static final LegacyFileSortOrder sort_big_to_small = new LegacyFileSortOrderBySize(sort_big_to_small_id, false);
 
-    public static final Map<String, FileSortOrder> sortOrders;
+    public static final Map<String, LegacyFileSortOrder> sortOrders;
 
     static {
-        HashMap<String, FileSortOrder> temp = new HashMap<>();
+        HashMap<String, LegacyFileSortOrder> temp = new HashMap<>();
         temp.put(sort_a_to_z.name, sort_a_to_z);
         temp.put(sort_z_to_a.name, sort_z_to_a);
         temp.put(sort_old_to_new.name, sort_old_to_new);
@@ -69,12 +69,12 @@ public class FileSortOrder {
     public String name;
     public boolean isAscending;
 
-    public FileSortOrder(String name, boolean ascending) {
+    public LegacyFileSortOrder(String name, boolean ascending) {
         this.name = name;
         isAscending = ascending;
     }
 
-    public static FileSortOrder getFileSortOrder(@Nullable String key) {
+    public static LegacyFileSortOrder getFileSortOrder(@Nullable String key) {
         if (TextUtils.isEmpty(key) || !sortOrders.containsKey(key)) {
             return sort_a_to_z;
         } else {

+ 3 - 2
app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByDate.java → app/src/main/java/com/nextcloud/talk/utils/LegacyFileSortOrderByDate.java

@@ -30,9 +30,10 @@ import java.util.List;
 /**
  * Created by srkunze on 28.08.17.
  */
-public class FileSortOrderByDate extends FileSortOrder {
+@Deprecated
+public class LegacyFileSortOrderByDate extends LegacyFileSortOrder {
 
-    FileSortOrderByDate(String name, boolean ascending) {
+    LegacyFileSortOrderByDate(String name, boolean ascending) {
         super(name, ascending);
     }
 

+ 3 - 2
app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByName.java → app/src/main/java/com/nextcloud/talk/utils/LegacyFileSortOrderByName.java

@@ -32,9 +32,10 @@ import third_parties.daveKoeller.AlphanumComparator;
 /**
  * Created by srkunze on 28.08.17.
  */
-public class FileSortOrderByName extends FileSortOrder {
+@Deprecated
+public class LegacyFileSortOrderByName extends LegacyFileSortOrder {
 
-    FileSortOrderByName(String name, boolean ascending) {
+    LegacyFileSortOrderByName(String name, boolean ascending) {
         super(name, ascending);
     }
 

+ 3 - 2
app/src/main/java/com/nextcloud/talk/utils/FileSortOrderBySize.java → app/src/main/java/com/nextcloud/talk/utils/LegacyFileSortOrderBySize.java

@@ -30,9 +30,10 @@ import java.util.List;
 /**
  * Sorts files by sizes
  */
-public class FileSortOrderBySize extends FileSortOrder {
+@Deprecated
+public class LegacyFileSortOrderBySize extends LegacyFileSortOrder {
 
-    FileSortOrderBySize(String name, boolean ascending) {
+    LegacyFileSortOrderBySize(String name, boolean ascending) {
         super(name, ascending);
     }
 

+ 0 - 1
app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java

@@ -25,7 +25,6 @@
 package com.nextcloud.talk.utils.preferences;
 
 import com.nextcloud.talk.R;
-import com.nextcloud.talk.utils.FileSortOrder;
 
 import net.orange_box.storebox.annotations.method.ClearMethod;
 import net.orange_box.storebox.annotations.method.DefaultValue;