From 85b2cea6182e82ec73387a8f8c23881fe5d4eed2 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 7 Jul 2021 18:30:06 +0200 Subject: [PATCH] Add order capabilities to file browser Resolves #919 Signed-off-by: Andy Scherzinger --- .../controllers/BrowserController.java | 305 ----------- .../controllers/BrowserController.kt | 339 ++++++++++++ .../BrowserForAvatarController.java | 2 +- .../BrowserForSharingController.java | 2 +- .../ui/dialog/SortingOrderDialogFragment.java | 198 +++++++ .../nextcloud/talk/utils/DisplayUtils.java | 28 + .../nextcloud/talk/utils/FileSortOrder.java | 108 ++++ .../talk/utils/FileSortOrderByDate.java | 52 ++ .../talk/utils/FileSortOrderByName.java | 63 +++ .../talk/utils/FileSortOrderBySize.java | 64 +++ .../utils/preferences/AppPreferences.java | 18 + .../daveKoeller/AlphanumComparator.java | 188 +++++++ .../third_parties/daveKoeller/lgpl-2.1.txt | 502 ++++++++++++++++++ app/src/main/res/drawable/borderless_btn.xml | 29 + .../main/res/drawable/ic_alphabetical_asc.xml | 25 + .../res/drawable/ic_alphabetical_desc.xml | 26 + .../res/drawable/ic_keyboard_arrow_down.xml | 25 + .../main/res/drawable/ic_modification_asc.xml | 25 + .../res/drawable/ic_modification_desc.xml | 25 + app/src/main/res/drawable/ic_size_asc.xml | 25 + app/src/main/res/drawable/ic_size_desc.xml | 25 + .../main/res/layout/controller_browser.xml | 66 ++- .../res/layout/sorting_order_fragment.xml | 308 +++++++++++ app/src/main/res/values-night/colors.xml | 1 + app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/strings.xml | 9 + app/src/main/res/values/styles.xml | 11 + scripts/analysis/findbugs-results.txt | 2 +- scripts/analysis/lint-results.txt | 2 +- 30 files changed, 2157 insertions(+), 318 deletions(-) delete mode 100644 app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.java create mode 100644 app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.kt create mode 100644 app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java create mode 100644 app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.java create mode 100644 app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByDate.java create mode 100644 app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByName.java create mode 100644 app/src/main/java/com/nextcloud/talk/utils/FileSortOrderBySize.java create mode 100644 app/src/main/java/third_parties/daveKoeller/AlphanumComparator.java create mode 100644 app/src/main/java/third_parties/daveKoeller/lgpl-2.1.txt create mode 100644 app/src/main/res/drawable/borderless_btn.xml create mode 100644 app/src/main/res/drawable/ic_alphabetical_asc.xml create mode 100644 app/src/main/res/drawable/ic_alphabetical_desc.xml create mode 100644 app/src/main/res/drawable/ic_keyboard_arrow_down.xml create mode 100644 app/src/main/res/drawable/ic_modification_asc.xml create mode 100644 app/src/main/res/drawable/ic_modification_desc.xml create mode 100644 app/src/main/res/drawable/ic_size_asc.xml create mode 100644 app/src/main/res/drawable/ic_size_desc.xml create mode 100644 app/src/main/res/layout/sorting_order_fragment.xml diff --git a/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.java b/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.java deleted file mode 100644 index 763d0a2d2..000000000 --- a/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017-2018 Mario Danic - * - * 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 . - */ - -package com.nextcloud.talk.components.filebrowser.controllers; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; - -import com.google.android.material.bottomnavigation.BottomNavigationItemView; -import com.nextcloud.talk.R; -import com.nextcloud.talk.application.NextcloudTalkApplication; -import com.nextcloud.talk.components.filebrowser.adapters.items.BrowserFileItem; -import com.nextcloud.talk.components.filebrowser.interfaces.ListingInterface; -import com.nextcloud.talk.components.filebrowser.models.BrowserFile; -import com.nextcloud.talk.components.filebrowser.models.DavResponse; -import com.nextcloud.talk.components.filebrowser.operations.DavListing; -import com.nextcloud.talk.components.filebrowser.operations.ListingAbstractClass; -import com.nextcloud.talk.controllers.base.BaseController; -import com.nextcloud.talk.interfaces.SelectionInterface; -import com.nextcloud.talk.models.database.UserEntity; -import com.nextcloud.talk.utils.bundle.BundleKeys; -import com.nextcloud.talk.utils.database.user.UserUtils; - -import org.parceler.Parcel; -import org.parceler.Parcels; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import javax.inject.Inject; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; -import autodagger.AutoInjector; -import butterknife.BindView; -import butterknife.OnClick; -import eu.davidea.flexibleadapter.FlexibleAdapter; -import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager; -import eu.davidea.flexibleadapter.items.AbstractFlexibleItem; -import okhttp3.OkHttpClient; - -@AutoInjector(NextcloudTalkApplication.class) -public abstract class BrowserController extends BaseController implements ListingInterface, - FlexibleAdapter.OnItemClickListener, SelectionInterface { - protected final Set selectedPaths; - @Inject - UserUtils userUtils; - @BindView(R.id.recycler_view) - RecyclerView recyclerView; - @BindView(R.id.action_back) - BottomNavigationItemView backMenuItem; - @BindView(R.id.action_refresh) - BottomNavigationItemView actionRefreshMenuItem; - @Inject - Context context; - @Inject - OkHttpClient okHttpClient; - - private MenuItem filesSelectionDoneMenuItem; - private RecyclerView.LayoutManager layoutManager; - - private FlexibleAdapter adapter; - private List recyclerViewItems = new ArrayList<>(); - - private ListingAbstractClass listingAbstractClass; - private BrowserType browserType; - private String currentPath; - protected UserEntity activeUser; - - public BrowserController(Bundle args) { - super(args); - setHasOptionsMenu(true); - NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this); - browserType = Parcels.unwrap(args.getParcelable(BundleKeys.INSTANCE.getKEY_BROWSER_TYPE())); - activeUser = Parcels.unwrap(args.getParcelable(BundleKeys.INSTANCE.getKEY_USER_ENTITY())); - - currentPath = "/"; - if (BrowserType.DAV_BROWSER.equals(browserType)) { - listingAbstractClass = new DavListing(this); - } else { - //listingAbstractClass = new LocalListing(this); - } - - selectedPaths = Collections.synchronizedSet(new TreeSet<>()); - } - - @NonNull - @Override - protected View inflateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) { - return inflater.inflate(R.layout.controller_browser, container, false); - } - - @Override - protected void onViewBound(@NonNull View view) { - super.onViewBound(view); - if (adapter == null) { - adapter = new FlexibleAdapter<>(recyclerViewItems, context, false); - } - - changeEnabledStatusForBarItems(true); - prepareViews(); - } - - abstract void onFileSelectionDone(); - - @Override - public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { - super.onCreateOptionsMenu(menu, inflater); - inflater.inflate(R.menu.menu_share_files, menu); - filesSelectionDoneMenuItem = menu.findItem(R.id.files_selection_done); - filesSelectionDoneMenuItem.setVisible(selectedPaths.size() > 0); - } - - @Override - public boolean onOptionsItemSelected(@NonNull MenuItem item) { - if (item.getItemId() == R.id.files_selection_done) { - onFileSelectionDone(); - return true; - } - return super.onOptionsItemSelected(item); - } - - @Override - protected void onAttach(@NonNull View view) { - super.onAttach(view); - refreshCurrentPath(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - listingAbstractClass.tearDown(); - } - - @Override - protected String getTitle() { - return currentPath; - } - - @OnClick(R.id.action_back) - void goBack() { - fetchPath(new File(currentPath).getParent()); - } - - @OnClick(R.id.action_refresh) - void refreshCurrentPath() { - fetchPath(currentPath); - } - - @SuppressLint("RestrictedApi") - private void changeEnabledStatusForBarItems(boolean shouldBeEnabled) { - if (actionRefreshMenuItem != null) { - actionRefreshMenuItem.setEnabled(shouldBeEnabled); - } - - if (backMenuItem != null) { - backMenuItem.setEnabled(shouldBeEnabled && !currentPath.equals("/")); - } - } - - private void fetchPath(String path) { - listingAbstractClass.cancelAllJobs(); - changeEnabledStatusForBarItems(false); - - listingAbstractClass.getFiles(path, activeUser, BrowserType.DAV_BROWSER.equals(browserType) ? okHttpClient : null); - } - - @Override - public void listingResult(DavResponse davResponse) { - adapter.clear(); - List fileBrowserItems = new ArrayList<>(); - if (davResponse.getData() != null) { - final List objectList = (List) davResponse.getData(); - - currentPath = objectList.get(0).getPath(); - - if (getActivity() != null) { - getActivity().runOnUiThread(() -> setTitle()); - } - - for (int i = 1; i < objectList.size(); i++) { - fileBrowserItems.add(new BrowserFileItem(objectList.get(i), activeUser, this)); - } - } - - adapter.addItems(0, fileBrowserItems); - - if (getActivity() != null) { - getActivity().runOnUiThread(() -> { - adapter.notifyDataSetChanged(); - changeEnabledStatusForBarItems(true); - - }); - } - } - - private boolean shouldPathBeSelectedDueToParent(String currentPath) { - if (selectedPaths.size() > 0) { - File file = new File(currentPath); - if (!file.getParent().equals("/")) { - while (file.getParent() != null) { - String parent = file.getParent(); - if (new File(file.getParent()).getParent() != null) { - parent += "/"; - } - - if (selectedPaths.contains(parent)) { - return true; - } - - file = new File(file.getParent()); - } - } - } - - return false; - } - - private void checkAndRemoveAnySelectedParents(String currentPath) { - File file = new File(currentPath); - selectedPaths.remove(currentPath); - while (file.getParent() != null) { - selectedPaths.remove(file.getParent() + "/"); - file = new File(file.getParent()); - } - - adapter.notifyDataSetChanged(); - } - - @Override - public boolean onItemClick(View view, int position) { - BrowserFile browserFile = ((BrowserFileItem) adapter.getItem(position)).getModel(); - if ("inode/directory".equals((browserFile.getMimeType()))) { - fetchPath(browserFile.getPath()); - return true; - } - - return false; - } - - private void prepareViews() { - if (getActivity() != null) { - layoutManager = new SmoothScrollLinearLayoutManager(getActivity()); - recyclerView.setLayoutManager(layoutManager); - recyclerView.setHasFixedSize(true); - recyclerView.setAdapter(adapter); - adapter.addListener(this); - } - } - - @SuppressLint("RestrictedApi") - @Override - public void toggleBrowserItemSelection(@NonNull String path) { - if (selectedPaths.contains(path) || shouldPathBeSelectedDueToParent(path)) { - checkAndRemoveAnySelectedParents(path); - } else { - // TOOD: if it's a folder, remove all the children we added manually - selectedPaths.add(path); - } - - filesSelectionDoneMenuItem.setVisible(selectedPaths.size() > 0); - } - - @Override - public boolean isPathSelected(@NonNull String path) { - return (selectedPaths.contains(path) || shouldPathBeSelectedDueToParent(path)); - } - - @Override - abstract public boolean shouldOnlySelectOneImageFile(); - - @Parcel - public enum BrowserType { - FILE_BROWSER, - DAV_BROWSER, - } -} diff --git a/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.kt b/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.kt new file mode 100644 index 000000000..fb4c7f88a --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.kt @@ -0,0 +1,339 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * @author Andy Scherzinger + * Copyright (C) 2021 Andy Scherzinger + * Copyright (C) 2017-2018 Mario Danic + * + * 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 . + */ +package com.nextcloud.talk.components.filebrowser.controllers + +import android.annotation.SuppressLint +import android.os.Bundle +import android.util.Log +import android.view.Menu +import android.view.MenuInflater +import android.view.MenuItem +import android.view.View +import androidx.fragment.app.DialogFragment +import androidx.recyclerview.widget.RecyclerView +import autodagger.AutoInjector +import com.nextcloud.talk.R +import com.nextcloud.talk.activities.MainActivity +import com.nextcloud.talk.application.NextcloudTalkApplication +import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication +import com.nextcloud.talk.components.filebrowser.adapters.items.BrowserFileItem +import com.nextcloud.talk.components.filebrowser.interfaces.ListingInterface +import com.nextcloud.talk.components.filebrowser.models.BrowserFile +import com.nextcloud.talk.components.filebrowser.models.DavResponse +import com.nextcloud.talk.components.filebrowser.operations.DavListing +import com.nextcloud.talk.components.filebrowser.operations.ListingAbstractClass +import com.nextcloud.talk.controllers.base.NewBaseController +import com.nextcloud.talk.controllers.util.viewBinding +import com.nextcloud.talk.databinding.ControllerBrowserBinding +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.bundle.BundleKeys.KEY_BROWSER_TYPE +import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_USER_ENTITY +import com.nextcloud.talk.utils.database.user.UserUtils +import eu.davidea.flexibleadapter.FlexibleAdapter +import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager +import eu.davidea.flexibleadapter.items.IFlexible +import net.orange_box.storebox.listeners.OnPreferenceValueChangedListener +import okhttp3.OkHttpClient +import org.parceler.Parcel +import org.parceler.Parcels +import java.io.File +import java.util.ArrayList +import java.util.Collections +import java.util.TreeSet +import javax.inject.Inject + +@AutoInjector(NextcloudTalkApplication::class) +abstract class BrowserController(args: Bundle) : + NewBaseController( + R.layout.controller_browser, + args + ), + ListingInterface, + FlexibleAdapter.OnItemClickListener, + SelectionInterface { + + private val binding: ControllerBrowserBinding by viewBinding(ControllerBrowserBinding::bind) + + @JvmField + protected val selectedPaths: MutableSet + + @JvmField + @Inject + var userUtils: UserUtils? = null + + @JvmField + @Inject + var okHttpClient: OkHttpClient? = null + + @JvmField + protected var activeUser: UserEntity + + private var filesSelectionDoneMenuItem: MenuItem? = null + private var layoutManager: RecyclerView.LayoutManager? = null + private var adapter: FlexibleAdapter? = null + private var recyclerViewItems: List = ArrayList() + private var listingAbstractClass: ListingAbstractClass? = null + private val browserType: BrowserType + private var currentPath: String + + private var sortingChangeListener: OnPreferenceValueChangedListener? = null + + override fun onViewBound(view: View) { + super.onViewBound(view) + if (adapter == null) { + adapter = FlexibleAdapter(recyclerViewItems, context, false) + } + + appPreferences!!.registerSortingChangeListener( + SortingChangeListener(this).also { + sortingChangeListener = it + } + ) + + changeEnabledStatusForBarItems(true) + prepareViews() + } + + abstract fun onFileSelectionDone() + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.menu_share_files, menu) + filesSelectionDoneMenuItem = menu.findItem(R.id.files_selection_done) + filesSelectionDoneMenuItem?.isVisible = selectedPaths.size > 0 + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + if (item.itemId == R.id.files_selection_done) { + onFileSelectionDone() + return true + } + return super.onOptionsItemSelected(item) + } + + override fun onAttach(view: View) { + super.onAttach(view) + + binding.bottomNavigation.menu.findItem(R.id.action_refresh)?.setOnMenuItemClickListener { refreshCurrentPath() } + binding.pathNavigation.menu.findItem(R.id.action_back)?.setOnMenuItemClickListener { goBack() } + binding.sortButton.setOnClickListener { changeSorting() } + + binding.sortButton.setText( + DisplayUtils.getSortOrderStringId(FileSortOrder.getFileSortOrder(appPreferences?.sorting)) + ) + + refreshCurrentPath() + } + + fun changeSorting() { + val newFragment: DialogFragment = SortingOrderDialogFragment + .newInstance(FileSortOrder.getFileSortOrder(appPreferences?.sorting)) + newFragment.show((activity as MainActivity?)!!.supportFragmentManager, "SortingOrderDialogFragment") + } + + public override fun onDestroy() { + super.onDestroy() + listingAbstractClass!!.tearDown() + } + + override val title: String + get() = + currentPath + + fun goBack(): Boolean { + fetchPath(File(currentPath).parent) + return true + } + + fun refreshCurrentPath(): Boolean { + fetchPath(currentPath) + return true + } + + @SuppressLint("RestrictedApi") + private fun changeEnabledStatusForBarItems(shouldBeEnabled: Boolean) { + binding.bottomNavigation.menu.findItem(R.id.action_refresh)?.isEnabled = shouldBeEnabled + binding.pathNavigation.menu.findItem(R.id.action_back)?.isEnabled = shouldBeEnabled && currentPath != "/" + } + + private fun fetchPath(path: String) { + listingAbstractClass!!.cancelAllJobs() + changeEnabledStatusForBarItems(false) + listingAbstractClass!!.getFiles( + path, + activeUser, + if (BrowserType.DAV_BROWSER == browserType) okHttpClient else null + ) + } + + override fun listingResult(davResponse: DavResponse) { + adapter!!.clear() + recyclerViewItems = ArrayList() + if (davResponse.getData() != null) { + val objectList = davResponse.getData() as List + currentPath = objectList[0].getPath() + if (activity != null) { + activity!!.runOnUiThread { setTitle() } + } + for (i in 1 until objectList.size) { + (recyclerViewItems as ArrayList).add(BrowserFileItem(objectList[i], activeUser, this)) + } + } + + FileSortOrder.getFileSortOrder(appPreferences?.sorting).sortCloudFiles(recyclerViewItems) + + adapter!!.addItems(0, recyclerViewItems) + if (activity != null) { + activity!!.runOnUiThread { + adapter!!.notifyDataSetChanged() + changeEnabledStatusForBarItems(true) + } + } + } + + private fun shouldPathBeSelectedDueToParent(currentPath: String): Boolean { + if (selectedPaths.size > 0) { + var file = File(currentPath) + if (file.parent != "/") { + while (file.parent != null) { + var parent = file.parent!! + if (File(file.parent!!).parent != null) { + parent += "/" + } + if (selectedPaths.contains(parent)) { + return true + } + file = File(file.parent!!) + } + } + } + return false + } + + private fun checkAndRemoveAnySelectedParents(currentPath: String) { + var file = File(currentPath) + selectedPaths.remove(currentPath) + while (file.parent != null) { + selectedPaths.remove(file.parent!! + "/") + file = File(file.parent!!) + } + adapter!!.notifyDataSetChanged() + } + + override fun onItemClick(view: View, position: Int): Boolean { + val browserFile = (adapter!!.getItem(position) as BrowserFileItem).model + if ("inode/directory" == browserFile.getMimeType()) { + fetchPath(browserFile.getPath()) + return true + } + return false + } + + private fun prepareViews() { + if (activity != null) { + layoutManager = SmoothScrollLinearLayoutManager(activity) + binding.recyclerView.layoutManager = layoutManager + binding.recyclerView.setHasFixedSize(true) + binding.recyclerView.adapter = adapter + adapter!!.fastScroller = binding.fastScrollerContainer.fastScroller + adapter!!.addListener(this) + binding.fastScrollerContainer.fastScroller.setBubbleTextCreator { position: Int -> + val abstractFlexibleItem: IFlexible<*> = adapter!!.getItem(position)!! + if (abstractFlexibleItem is BrowserFileItem) { + return@setBubbleTextCreator (adapter!!.getItem(position) as BrowserFileItem) + .model + .getDisplayName()[0] + .toString() + } else { + return@setBubbleTextCreator "" + } + } + } + } + + @SuppressLint("RestrictedApi") + override fun toggleBrowserItemSelection(path: String) { + if (selectedPaths.contains(path) || shouldPathBeSelectedDueToParent(path)) { + checkAndRemoveAnySelectedParents(path) + } else { + // TOOD: if it's a folder, remove all the children we added manually + selectedPaths.add(path) + } + filesSelectionDoneMenuItem?.isVisible = selectedPaths.size > 0 + } + + override fun isPathSelected(path: String): Boolean { + return selectedPaths.contains(path) || shouldPathBeSelectedDueToParent(path) + } + + abstract override fun shouldOnlySelectOneImageFile(): Boolean + + @Parcel + enum class BrowserType { + FILE_BROWSER, DAV_BROWSER + } + + init { + setHasOptionsMenu(true) + sharedApplication!!.componentApplication.inject(this) + browserType = Parcels.unwrap(args.getParcelable(KEY_BROWSER_TYPE)) + activeUser = Parcels.unwrap(args.getParcelable(KEY_USER_ENTITY)) + currentPath = "/" + if (BrowserType.DAV_BROWSER == browserType) { + listingAbstractClass = DavListing(this) + } // else { + // listingAbstractClass = new LocalListing(this); + // } + selectedPaths = Collections.synchronizedSet(TreeSet()) + } + + @Suppress("Detekt.TooGenericExceptionCaught") + private class SortingChangeListener(private val browserController: BrowserController) : + OnPreferenceValueChangedListener { + override fun onChanged(newValue: String) { + try { + val sortOrder = FileSortOrder.getFileSortOrder(newValue) + + browserController.binding.sortButton.setText(DisplayUtils.getSortOrderStringId(sortOrder)) + browserController.recyclerViewItems = sortOrder.sortCloudFiles(browserController.recyclerViewItems) + + if (browserController.activity != null) { + browserController.activity!!.runOnUiThread { + browserController.adapter!!.updateDataSet(browserController.recyclerViewItems) + browserController.changeEnabledStatusForBarItems(true) + } + } + } catch (npe: NullPointerException) { + // view binding can be null + // since this is called asynchrously and UI might have been destroyed in the meantime + Log.i(BrowserController.TAG, "UI destroyed - view binding already gone") + } + } + } + + companion object { + private const val TAG = "BrowserController" + } +} diff --git a/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserForAvatarController.java b/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserForAvatarController.java index 6ca11a6da..9075d3788 100644 --- a/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserForAvatarController.java +++ b/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserForAvatarController.java @@ -41,7 +41,7 @@ public class BrowserForAvatarController extends BrowserController { } @Override - void onFileSelectionDone() { + public void onFileSelectionDone() { controller.handleAvatar(selectedPaths.iterator().next()); getRouter().popCurrentController(); diff --git a/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserForSharingController.java b/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserForSharingController.java index 1c045af4b..f0b0e640a 100644 --- a/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserForSharingController.java +++ b/app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserForSharingController.java @@ -43,7 +43,7 @@ public class BrowserForSharingController extends BrowserController { } @Override - void onFileSelectionDone() { + public void onFileSelectionDone() { synchronized (selectedPaths) { Iterator iterator = selectedPaths.iterator(); diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java b/app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java new file mode 100644 index 000000000..715abb9a6 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/SortingOrderDialogFragment.java @@ -0,0 +1,198 @@ +/* + * Nextcloud Talk application + * + * @author Andy Scherzinger + * Copyright (C) 2017-2021 Andy Scherzinger + * Copyright (C) 2017 Nextcloud + * + * 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 . + */ + +package com.nextcloud.talk.ui.dialog; + +import android.annotation.SuppressLint; +import android.app.Dialog; +import android.graphics.Typeface; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import com.google.android.material.button.MaterialButton; +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.preferences.AppPreferences; + +import javax.inject.Inject; + +import androidx.annotation.NonNull; +import androidx.fragment.app.DialogFragment; +import autodagger.AutoInjector; +import kotlin.jvm.JvmField; + +/** + * Dialog to show and choose the sorting order for the file listing. + */ +@AutoInjector(NextcloudTalkApplication.class) +public class SortingOrderDialogFragment extends DialogFragment implements View.OnClickListener { + + private final static String TAG = SortingOrderDialogFragment.class.getSimpleName(); + + public static final String SORTING_ORDER_FRAGMENT = "SORTING_ORDER_FRAGMENT"; + private static final String KEY_SORT_ORDER = "SORT_ORDER"; + + @Inject + @JvmField + AppPreferences appPreferences; + + private SortingOrderFragmentBinding binding; + private View dialogView; + + private View[] taggedViews; + private String currentSortOrderName; + + public static SortingOrderDialogFragment newInstance(FileSortOrder sortOrder) { + SortingOrderDialogFragment dialogFragment = new SortingOrderDialogFragment(); + + Bundle args = new Bundle(); + args.putString(KEY_SORT_ORDER, sortOrder.name); + dialogFragment.setArguments(args); + + return dialogFragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // keep the state of the fragment on configuration changes + setRetainInstance(true); + + if (getArguments() != null) { + currentSortOrderName = getArguments().getString(KEY_SORT_ORDER, FileSortOrder.sort_a_to_z.name); + } + } + + @SuppressLint("InflateParams") + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + binding = SortingOrderFragmentBinding.inflate(LayoutInflater.from(requireContext())); + dialogView = binding.getRoot(); + + return new MaterialAlertDialogBuilder(requireContext()).setView(dialogView).create(); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return dialogView; + } + + @Override + public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + NextcloudTalkApplication.Companion.getSharedApplication().getComponentApplication().inject(this); + + setupDialogElements(); + setupListeners(); + } + + /** + * find all relevant UI elements and set their values. + */ + private void setupDialogElements() { + binding.cancel.setTextColor(getResources().getColor(R.color.colorPrimary)); + + taggedViews = new View[12]; + taggedViews[0] = binding.sortByNameAscending; + taggedViews[0].setTag(FileSortOrder.sort_a_to_z); + taggedViews[1] = binding.sortByNameAZText; + taggedViews[1].setTag(FileSortOrder.sort_a_to_z); + taggedViews[2] = binding.sortByNameDescending; + taggedViews[2].setTag(FileSortOrder.sort_z_to_a); + taggedViews[3] = binding.sortByNameZAText; + taggedViews[3].setTag(FileSortOrder.sort_z_to_a); + taggedViews[4] = binding.sortByModificationDateAscending; + taggedViews[4].setTag(FileSortOrder.sort_old_to_new); + taggedViews[5] = binding.sortByModificationDateOldestFirstText; + taggedViews[5].setTag(FileSortOrder.sort_old_to_new); + taggedViews[6] = binding.sortByModificationDateDescending; + taggedViews[6].setTag(FileSortOrder.sort_new_to_old); + taggedViews[7] = binding.sortByModificationDateNewestFirstText; + taggedViews[7].setTag(FileSortOrder.sort_new_to_old); + taggedViews[8] = binding.sortBySizeAscending; + taggedViews[8].setTag(FileSortOrder.sort_small_to_big); + taggedViews[9] = binding.sortBySizeSmallestFirstText; + taggedViews[9].setTag(FileSortOrder.sort_small_to_big); + taggedViews[10] = binding.sortBySizeDescending; + taggedViews[10].setTag(FileSortOrder.sort_big_to_small); + taggedViews[11] = binding.sortBySizeBiggestFirstText; + taggedViews[11].setTag(FileSortOrder.sort_big_to_small); + + setupActiveOrderSelection(); + } + + /** + * tints the icon reflecting the actual sorting choice in the apps primary color. + */ + private void setupActiveOrderSelection() { + 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)) { + continue; + } + if (view instanceof MaterialButton) { + ((MaterialButton) view).setIconTintResource(R.color.colorPrimary); + } + if (view instanceof TextView) { + ((TextView) view).setTextColor(color); + ((TextView) view).setTypeface(Typeface.DEFAULT_BOLD); + } + } + } + + /** + * setup all listeners. + */ + private void setupListeners() { + binding.cancel.setOnClickListener(view -> dismiss()); + + for (View view : taggedViews) { + Log.i("SortOrder", "view="+view.getTag().toString()); + view.setOnClickListener(this); + } + } + + @Override + public void onDestroyView() { + Log.d(TAG, "destroy SortingOrderDialogFragment view"); + if (getDialog() != null && getRetainInstance()) { + getDialog().setDismissMessage(null); + } + binding = null; + super.onDestroyView(); + } + + @Override + public void onClick(View v) { + appPreferences.setSorting(((FileSortOrder) v.getTag()).name); + dismiss(); + } +} diff --git a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java index 48408670a..552e47d1d 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/DisplayUtils.java @@ -2,6 +2,8 @@ * Nextcloud Talk application * * @author Mario Danic + * @author Andy Scherzinger + * Copyright (C) 2021 Andy Scherzinger * Copyright (C) 2017-2020 Mario Danic * * This program is free software: you can redistribute it and/or modify @@ -94,6 +96,7 @@ import androidx.annotation.ColorRes; import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import androidx.annotation.XmlRes; import androidx.appcompat.widget.AppCompatDrawableManager; import androidx.appcompat.widget.SearchView; @@ -102,6 +105,13 @@ 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; + public class DisplayUtils { private static final String TAG = "DisplayUtils"; @@ -548,5 +558,23 @@ public class DisplayUtils { .build(); avatarImageView.setController(draweeController); } + + public static @StringRes int getSortOrderStringId(FileSortOrder sortOrder) { + switch (sortOrder.name) { + case sort_z_to_a_id: + return R.string.menu_item_sort_by_name_z_a; + case sort_new_to_old_id: + return R.string.menu_item_sort_by_date_newest_first; + case sort_old_to_new_id: + return R.string.menu_item_sort_by_date_oldest_first; + case sort_big_to_small_id: + return R.string.menu_item_sort_by_size_biggest_first; + case sort_small_to_big_id: + return R.string.menu_item_sort_by_size_smallest_first; + case sort_a_to_z_id: + default: + return R.string.menu_item_sort_by_name_a_z; + } + } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.java b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.java new file mode 100644 index 000000000..ec88d0e4a --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrder.java @@ -0,0 +1,108 @@ +/* + * Nextcloud Talk application + * + * @author Sven R. Kunze + * @author Andy Scherzinger + * Copyright (C) 2021 Andy Scherzinger + * Copyright (C) 2017 Sven R. Kunze + * + * 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 . + */ + +package com.nextcloud.talk.utils; + +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; +import java.util.Map; + +import androidx.annotation.Nullable; + +/** + * Sort order + */ +public class FileSortOrder { + 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"; + public static final String sort_new_to_old_id = "sort_new_to_old"; + 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 Map sortOrders; + + static { + HashMap 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); + temp.put(sort_new_to_old.name, sort_new_to_old); + temp.put(sort_small_to_big.name, sort_small_to_big); + temp.put(sort_big_to_small.name, sort_big_to_small); + + sortOrders = Collections.unmodifiableMap(temp); + } + + public String name; + public boolean isAscending; + + public FileSortOrder(String name, boolean ascending) { + this.name = name; + isAscending = ascending; + } + + public static FileSortOrder getFileSortOrder(@Nullable String key) { + if (TextUtils.isEmpty(key) || !sortOrders.containsKey(key)) { + return sort_a_to_z; + } else { + return sortOrders.get(key); + } + } + + public List sortCloudFiles(List files) { + return sortCloudFilesByFavourite(files); + } + + /** + * Sorts list by Favourites. + * + * @param files files to sort + */ + public static List sortCloudFilesByFavourite(List files) { + Collections.sort(files, (o1, o2) -> { + if (o1.getModel().isFavorite() && o2.getModel().isFavorite()) { + return 0; + } else if (o1.getModel().isFavorite()) { + return -1; + } else if (o2.getModel().isFavorite()) { + return 1; + } + return 0; + }); + + return files; + } +} diff --git a/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByDate.java b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByDate.java new file mode 100644 index 000000000..2d24e88b0 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByDate.java @@ -0,0 +1,52 @@ +/* + * Nextcloud Talk application + * + * @author Sven R. Kunze + * @author Andy Scherzinger + * Copyright (C) 2021 Andy Scherzinger + * Copyright (C) 2017 Sven R. Kunze + * + * 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 . + */ + +package com.nextcloud.talk.utils; + +import com.nextcloud.talk.components.filebrowser.adapters.items.BrowserFileItem; + +import java.util.Collections; +import java.util.List; + +/** + * Created by srkunze on 28.08.17. + */ +public class FileSortOrderByDate extends FileSortOrder { + + FileSortOrderByDate(String name, boolean ascending) { + super(name, ascending); + } + + /** + * Sorts list by Date. + * + * @param files list of files to sort + */ + public List sortCloudFiles(List files) { + final int multiplier = isAscending ? 1 : -1; + + Collections.sort(files, (o1, o2) -> + multiplier * Long.compare(o1.getModel().getModifiedTimestamp(), o2.getModel().getModifiedTimestamp())); + + return super.sortCloudFiles(files); + } +} diff --git a/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByName.java b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByName.java new file mode 100644 index 000000000..c5035fd60 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderByName.java @@ -0,0 +1,63 @@ +/* + * Nextcloud Talk application + * + * @author Sven R. Kunze + * @author Andy Scherzinger + * Copyright (C) 2021 Andy Scherzinger + * Copyright (C) 2017 Sven R. Kunze + * + * 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 . + */ + +package com.nextcloud.talk.utils; + +import com.nextcloud.talk.components.filebrowser.adapters.items.BrowserFileItem; + +import java.util.Collections; +import java.util.List; + +import third_parties.daveKoeller.AlphanumComparator; + +/** + * Created by srkunze on 28.08.17. + */ +public class FileSortOrderByName extends FileSortOrder { + + FileSortOrderByName(String name, boolean ascending) { + super(name, ascending); + } + + /** + * Sorts list by Name. + * + * @param files files to sort + */ + @SuppressWarnings("Bx") + public List sortCloudFiles(List files) { + final int multiplier = isAscending ? 1 : -1; + + Collections.sort(files, (o1, o2) -> { + if (!o1.getModel().isFile() && !o2.getModel().isFile()) { + return multiplier * new AlphanumComparator().compare(o1, o2); + } else if (!o1.getModel().isFile()) { + return -1; + } else if (!o2.getModel().isFile()) { + return 1; + } + return multiplier * new AlphanumComparator().compare(o1, o2); + }); + + return super.sortCloudFiles(files); + } +} diff --git a/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderBySize.java b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderBySize.java new file mode 100644 index 000000000..8d1a29d49 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/utils/FileSortOrderBySize.java @@ -0,0 +1,64 @@ +/* + * Nextcloud Talk application + * + * @author Sven R. Kunze + * @author Andy Scherzinger + * Copyright (C) 2021 Andy Scherzinger + * Copyright (C) 2017 Sven R. Kunze + * + * 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 . + */ + +package com.nextcloud.talk.utils; + +import com.nextcloud.talk.components.filebrowser.adapters.items.BrowserFileItem; + +import java.util.Collections; +import java.util.List; + +/** + * Sorts files by sizes + */ +public class FileSortOrderBySize extends FileSortOrder { + + FileSortOrderBySize(String name, boolean ascending) { + super(name, ascending); + } + + /** + * Sorts list by Size. + * + * @param files list of files to sort + */ + public List sortCloudFiles(List files) { + final int multiplier = isAscending ? 1 : -1; + + Collections.sort(files, (o1, o2) -> { + if (!o1.getModel().isFile() && !o2.getModel().isFile()) { + Long obj1 = o1.getModel().size; + return multiplier * obj1.compareTo(o2.getModel().getSize()); + } else if (!o1.getModel().isFile()) { + return -1; + + } else if (!o2.getModel().isFile()) { + return 1; + } else { + Long obj1 = o1.getModel().getSize(); + return multiplier * obj1.compareTo(o2.getModel().getSize()); + } + }); + + return super.sortCloudFiles(files); + } +} diff --git a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java index 321fc233a..cb7398309 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java +++ b/app/src/main/java/com/nextcloud/talk/utils/preferences/AppPreferences.java @@ -2,7 +2,9 @@ * Nextcloud Talk application * * @author Mario Danic + * @author Andy Scherzinger * @author Tim Krüger + * Copyright (C) 2021 Andy Scherzinger * Copyright (C) 2021 Tim Krüger * Copyright (C) 2017 Mario Danic * @@ -23,6 +25,7 @@ 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; @@ -316,6 +319,21 @@ public interface AppPreferences { @UnregisterChangeListenerMethod void unregisterReadPrivacyChangeListener(OnPreferenceValueChangedListener listener); + @KeyByResource(R.string.nc_file_browser_sort_by_key) + void setSorting(String value); + + @KeyByResource(R.string.nc_file_browser_sort_by_key) + @DefaultValue(R.string.nc_file_browser_sort_by_default) + String getSorting(); + + @KeyByResource(R.string.nc_file_browser_sort_by_key) + @RegisterChangeListenerMethod + void registerSortingChangeListener(OnPreferenceValueChangedListener listener); + + @KeyByResource(R.string.nc_file_browser_sort_by_key) + @UnregisterChangeListenerMethod + void unregisterSortingChangeListener(OnPreferenceValueChangedListener listener); + @ClearMethod void clear(); } diff --git a/app/src/main/java/third_parties/daveKoeller/AlphanumComparator.java b/app/src/main/java/third_parties/daveKoeller/AlphanumComparator.java new file mode 100644 index 000000000..5f8dc8756 --- /dev/null +++ b/app/src/main/java/third_parties/daveKoeller/AlphanumComparator.java @@ -0,0 +1,188 @@ +/* + * The Alphanum Algorithm is an improved sorting algorithm for strings + * containing numbers. Instead of sorting numbers in ASCII order like + * a standard sort, this algorithm sorts numbers in numeric order. + * + * The Alphanum Algorithm is discussed at http://www.DaveKoelle.com + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +package third_parties.daveKoeller; + +import java.io.File; +import java.io.Serializable; +import java.math.BigInteger; +import java.text.Collator; +import java.util.Comparator; + +/* + * This is an updated version with enhancements made by Daniel Migowski, Andre Bogus, and David Koelle + * * + * To convert to use Templates (Java 1.5+): + * - Change "implements Comparator" to "implements Comparator" + * - Change "compare(Object o1, Object o2)" to "compare(String s1, String s2)" + * - Remove the type checking and casting in compare(). + * + * To use this class: + * Use the static "sort" method from the java.util.Collections class: + * Collections.sort(your list, new AlphanumComparator()); + * + * Adapted to fit + * https://github.com/nextcloud/server/blob/9a4253ef7c34f9dc71a6a9f7828a10df769f0c32/tests/lib/NaturalSortTest.php + * by Tobias Kaminsky + */ +public class AlphanumComparator implements Comparator, Serializable { + private boolean isDigit(char ch) { + return ch >= 48 && ch <= 57; + } + + private boolean isSpecialChar(char ch) { + return ch <= 47 || ch >= 58 && ch <= 64 || ch >= 91 && ch <= 96 || ch >= 123 && ch <= 126; + } + + /** + * Length of string is passed in for improved efficiency (only need to calculate it once) + **/ + private String getChunk(String string, int stringLength, int marker) { + StringBuilder chunk = new StringBuilder(); + char c = string.charAt(marker); + chunk.append(c); + marker++; + if (isDigit(c)) { + while (marker < stringLength) { + c = string.charAt(marker); + if (!isDigit(c)) { + break; + } + chunk.append(c); + marker++; + } + } else if (!isSpecialChar(c)) { + while (marker < stringLength) { + c = string.charAt(marker); + if (isDigit(c) || isSpecialChar(c)) { + break; + } + chunk.append(c); + marker++; + } + } + return chunk.toString(); + } + + public int compare(File f1, File f2) { + String s1 = f1.getPath(); + String s2 = f2.getPath(); + + return compare(s1, s2); + } + + public int compare(T t1, T t2) { + return compare(t1.toString(), t2.toString()); + } + + public int compare(String s1, String s2) { + int thisMarker = 0; + int thatMarker = 0; + int s1Length = s1.length(); + int s2Length = s2.length(); + + while (thisMarker < s1Length && thatMarker < s2Length) { + String thisChunk = getChunk(s1, s1Length, thisMarker); + thisMarker += thisChunk.length(); + + String thatChunk = getChunk(s2, s2Length, thatMarker); + thatMarker += thatChunk.length(); + + // If both chunks contain numeric characters, sort them numerically + int result = 0; + if (isDigit(thisChunk.charAt(0)) && isDigit(thatChunk.charAt(0))) { + // extract digits + int thisChunkZeroCount = 0; + boolean zero = true; + int countThis = 0; + while (countThis < (thisChunk.length()) && isDigit(thisChunk.charAt(countThis))) { + if (zero) { + if (Character.getNumericValue(thisChunk.charAt(countThis)) == 0) { + thisChunkZeroCount++; + } else { + zero = false; + } + } + countThis++; + } + + + int thatChunkZeroCount = 0; + int countThat = 0; + zero = true; + while (countThat < (thatChunk.length()) && isDigit(thatChunk.charAt(countThat))) { + if (zero) { + if (Character.getNumericValue(thatChunk.charAt(countThat)) == 0) { + thatChunkZeroCount++; + } else { + zero = false; + } + } + countThat++; + } + + BigInteger thisChunkValue = new BigInteger(thisChunk.substring(0, countThis)); + BigInteger thatChunkValue = new BigInteger(thatChunk.substring(0, countThat)); + + result = thisChunkValue.compareTo(thatChunkValue); + + if (result == 0) { + // value is equal, compare leading zeros + result = Integer.compare(thisChunkZeroCount, thatChunkZeroCount); + + if (result != 0) { + return result; + } + } else { + return result; + } + } else if (isSpecialChar(thisChunk.charAt(0)) && isSpecialChar(thatChunk.charAt(0))) { + for (int i = 0; i < thisChunk.length(); i++) { + if (thisChunk.charAt(i) == '.' && thatChunk.charAt(i) != '.') { + return -1; + } else if (thatChunk.charAt(i) == '.' && thisChunk.charAt(i) != '.') { + return 1; + } else { + result = thisChunk.charAt(i) - thatChunk.charAt(i); + if (result != 0) { + return result; + } + } + } + } else if (isSpecialChar(thisChunk.charAt(0)) && !isSpecialChar(thatChunk.charAt(0))) { + return -1; + } else if (!isSpecialChar(thisChunk.charAt(0)) && isSpecialChar(thatChunk.charAt(0))) { + return 1; + } else { + result = Collator.getInstance().compare(thisChunk, thatChunk); + } + + if (result != 0) { + return result; + } + } + + return s1Length - s2Length; + } +} diff --git a/app/src/main/java/third_parties/daveKoeller/lgpl-2.1.txt b/app/src/main/java/third_parties/daveKoeller/lgpl-2.1.txt new file mode 100644 index 000000000..4362b4915 --- /dev/null +++ b/app/src/main/java/third_parties/daveKoeller/lgpl-2.1.txt @@ -0,0 +1,502 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/app/src/main/res/drawable/borderless_btn.xml b/app/src/main/res/drawable/borderless_btn.xml new file mode 100644 index 000000000..a0997b82d --- /dev/null +++ b/app/src/main/res/drawable/borderless_btn.xml @@ -0,0 +1,29 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_alphabetical_asc.xml b/app/src/main/res/drawable/ic_alphabetical_asc.xml new file mode 100644 index 000000000..e7b83f2c9 --- /dev/null +++ b/app/src/main/res/drawable/ic_alphabetical_asc.xml @@ -0,0 +1,25 @@ + + + + diff --git a/app/src/main/res/drawable/ic_alphabetical_desc.xml b/app/src/main/res/drawable/ic_alphabetical_desc.xml new file mode 100644 index 000000000..fd3706809 --- /dev/null +++ b/app/src/main/res/drawable/ic_alphabetical_desc.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_keyboard_arrow_down.xml b/app/src/main/res/drawable/ic_keyboard_arrow_down.xml new file mode 100644 index 000000000..0052b3a31 --- /dev/null +++ b/app/src/main/res/drawable/ic_keyboard_arrow_down.xml @@ -0,0 +1,25 @@ + + + + diff --git a/app/src/main/res/drawable/ic_modification_asc.xml b/app/src/main/res/drawable/ic_modification_asc.xml new file mode 100644 index 000000000..bfb874ec4 --- /dev/null +++ b/app/src/main/res/drawable/ic_modification_asc.xml @@ -0,0 +1,25 @@ + + + + diff --git a/app/src/main/res/drawable/ic_modification_desc.xml b/app/src/main/res/drawable/ic_modification_desc.xml new file mode 100644 index 000000000..59d79f97a --- /dev/null +++ b/app/src/main/res/drawable/ic_modification_desc.xml @@ -0,0 +1,25 @@ + + + + diff --git a/app/src/main/res/drawable/ic_size_asc.xml b/app/src/main/res/drawable/ic_size_asc.xml new file mode 100644 index 000000000..688d6a880 --- /dev/null +++ b/app/src/main/res/drawable/ic_size_asc.xml @@ -0,0 +1,25 @@ + + + + diff --git a/app/src/main/res/drawable/ic_size_desc.xml b/app/src/main/res/drawable/ic_size_desc.xml new file mode 100644 index 000000000..824e03397 --- /dev/null +++ b/app/src/main/res/drawable/ic_size_desc.xml @@ -0,0 +1,25 @@ + + + + diff --git a/app/src/main/res/layout/controller_browser.xml b/app/src/main/res/layout/controller_browser.xml index 934dd3173..4bb100e08 100644 --- a/app/src/main/res/layout/controller_browser.xml +++ b/app/src/main/res/layout/controller_browser.xml @@ -2,6 +2,8 @@ ~ Nextcloud Talk application ~ ~ @author Mario Danic + ~ @author Andy Scherzinger + ~ Copyright (C) 2021 Andy Scherzinger ~ Copyright (C) 2017-2018 Mario Danic ~ ~ This program is free software: you can redistribute it and/or modify @@ -26,6 +28,60 @@ android:background="@color/bg_default" android:orientation="vertical"> + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 501f515c6..622e1a854 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -27,6 +27,7 @@ #0082C9 #006AA3 @color/colorPrimary + #ff6F6F6F #1E1E1E diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 2519f9f27..d8422386c 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -25,6 +25,7 @@ #0082C9 #006AA3 @color/colorPrimary + #ff888888 #ffffff #B3FFFFFF diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 84881fc10..61a76806e 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -62,4 +62,5 @@ 180dp 110dp + 0dp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 807345106..6acfb7fd4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -336,6 +336,15 @@ Refresh %1$s | Last modified: %2$s You are not allowed to re-share this file + Sort by + file_browser_sort_by + sort_a_to_z + A - Z + Z - A + Newest first + Oldest first + Biggest first + Smallest first Webinar diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 7b09c2017..c266cc46d 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -55,6 +55,10 @@ @color/grey950 + + + +