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

Fix scrolling and selection issue in RTL

The following views had scrolling and selection issues if RTL is
activated:

- Conversation list
- File browser
- Contact selection

To fix this issues the fast scroller functionality were removed for
those views.

Signed-off-by: Tim Krüger <t@timkrueger.me>
Tim Krüger 3 жил өмнө
parent
commit
fe989371de

+ 0 - 15
app/src/main/java/com/nextcloud/talk/components/filebrowser/controllers/BrowserController.java

@@ -62,11 +62,9 @@ import androidx.recyclerview.widget.RecyclerView;
 import autodagger.AutoInjector;
 import butterknife.BindView;
 import butterknife.OnClick;
-import eu.davidea.fastscroller.FastScroller;
 import eu.davidea.flexibleadapter.FlexibleAdapter;
 import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager;
 import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
-import eu.davidea.flexibleadapter.items.IFlexible;
 import okhttp3.OkHttpClient;
 
 @AutoInjector(NextcloudTalkApplication.class)
@@ -77,8 +75,6 @@ public abstract class BrowserController extends BaseController implements Listin
     UserUtils userUtils;
     @BindView(R.id.recycler_view)
     RecyclerView recyclerView;
-    @BindView(R.id.fast_scroller)
-    FastScroller fastScroller;
     @BindView(R.id.action_back)
     BottomNavigationItemView backMenuItem;
     @BindView(R.id.action_refresh)
@@ -276,18 +272,7 @@ public abstract class BrowserController extends BaseController implements Listin
             recyclerView.setLayoutManager(layoutManager);
             recyclerView.setHasFixedSize(true);
             recyclerView.setAdapter(adapter);
-
-            adapter.setFastScroller(fastScroller);
             adapter.addListener(this);
-
-            fastScroller.setBubbleTextCreator(position -> {
-                IFlexible abstractFlexibleItem = adapter.getItem(position);
-                if (abstractFlexibleItem instanceof BrowserFileItem) {
-                    return String.valueOf(((BrowserFileItem) adapter.getItem(position)).getModel().getDisplayName().charAt(0));
-                } else {
-                    return "";
-                }
-            });
         }
     }
 

+ 1 - 22
app/src/main/java/com/nextcloud/talk/controllers/ContactsController.java

@@ -102,7 +102,6 @@ import autodagger.AutoInjector;
 import butterknife.BindView;
 import butterknife.OnClick;
 import butterknife.Optional;
-import eu.davidea.fastscroller.FastScroller;
 import eu.davidea.flexibleadapter.FlexibleAdapter;
 import eu.davidea.flexibleadapter.SelectableAdapter;
 import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager;
@@ -116,7 +115,7 @@ import okhttp3.ResponseBody;
 
 @AutoInjector(NextcloudTalkApplication.class)
 public class ContactsController extends BaseController implements SearchView.OnQueryTextListener,
-        FlexibleAdapter.OnItemClickListener, FastScroller.OnScrollStateChangeListener {
+        FlexibleAdapter.OnItemClickListener {
 
     public static final String TAG = "ContactsController";
 
@@ -137,9 +136,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
     @BindView(R.id.swipe_refresh_layout)
     SwipeRefreshLayout swipeRefreshLayout;
 
-    @BindView(R.id.fast_scroller)
-    FastScroller fastScroller;
-
     @BindView(R.id.call_header_layout)
     RelativeLayout conversationPrivacyToogleLayout;
 
@@ -698,19 +694,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
         swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
         swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.refresh_spinner_background);
 
-        fastScroller.addOnScrollStateChangeListener(this);
-        adapter.setFastScroller(fastScroller);
-        fastScroller.setBubbleTextCreator(position -> {
-            IFlexible abstractFlexibleItem = adapter.getItem(position);
-            if (abstractFlexibleItem instanceof UserItem) {
-                return ((UserItem) adapter.getItem(position)).getHeader().getModel();
-            } else if (abstractFlexibleItem instanceof GenericTextHeaderItem) {
-                return ((GenericTextHeaderItem) adapter.getItem(position)).getModel();
-            } else {
-                return "";
-            }
-        });
-
         joinConversationViaLinkImageView
                 .getBackground()
                 .setColorFilter(ResourcesCompat.getColor(getResources(), R.color.colorBackgroundDarker, null),
@@ -819,10 +802,6 @@ public class ContactsController extends BaseController implements SearchView.OnQ
         }
     }
 
-    @Override
-    public void onFastScrollerStateChange(boolean scrolling) {
-        swipeRefreshLayout.setEnabled(!scrolling);
-    }
 
 
     private void prepareAndShowBottomSheetWithBundle(Bundle bundle, boolean showEntrySheet) {

+ 1 - 28
app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java

@@ -122,7 +122,6 @@ import androidx.work.OneTimeWorkRequest;
 import androidx.work.WorkManager;
 import autodagger.AutoInjector;
 import butterknife.BindView;
-import eu.davidea.fastscroller.FastScroller;
 import eu.davidea.flexibleadapter.FlexibleAdapter;
 import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager;
 import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
@@ -133,8 +132,7 @@ import retrofit2.HttpException;
 
 @AutoInjector(NextcloudTalkApplication.class)
 public class ConversationsListController extends BaseController implements SearchView.OnQueryTextListener,
-        FlexibleAdapter.OnItemClickListener, FlexibleAdapter.OnItemLongClickListener, FastScroller
-                .OnScrollStateChangeListener, ConversationMenuInterface {
+        FlexibleAdapter.OnItemClickListener, FlexibleAdapter.OnItemLongClickListener, ConversationMenuInterface {
 
     public static final String TAG = "ConvListController";
     public static final int ID_DELETE_CONVERSATION_DIALOG = 0;
@@ -167,9 +165,6 @@ public class ConversationsListController extends BaseController implements Searc
     @BindView(R.id.emptyLayout)
     RelativeLayout emptyLayoutView;
 
-    @BindView(R.id.fast_scroller)
-    FastScroller fastScroller;
-
     @BindView(R.id.floatingActionButton)
     FloatingActionButton floatingActionButton;
 
@@ -588,23 +583,6 @@ public class ConversationsListController extends BaseController implements Searc
             showNewConversationsScreen();
         });
 
-        fastScroller.addOnScrollStateChangeListener(this);
-        adapter.setFastScroller(fastScroller);
-
-        fastScroller.setBubbleTextCreator(position -> {
-            String displayName;
-            if (shouldUseLastMessageLayout) {
-                displayName = ((ConversationItem) adapter.getItem(position)).getModel().getDisplayName();
-            } else {
-                displayName = ((CallItem) adapter.getItem(position)).getModel().getDisplayName();
-            }
-
-            if (displayName.length() > 8) {
-                displayName = displayName.substring(0, 4) + "...";
-            }
-            return displayName;
-        });
-
         if (getActivity() != null && getActivity() instanceof MainActivity) {
             MainActivity activity = (MainActivity) getActivity();
 
@@ -755,11 +733,6 @@ public class ConversationsListController extends BaseController implements Searc
         return getResources().getString(R.string.nc_app_product_name);
     }
 
-    @Override
-    public void onFastScrollerStateChange(boolean scrolling) {
-        swipeRefreshLayout.setEnabled(!scrolling);
-    }
-
     @Override
     public boolean onItemClick(View view, int position) {
         selectedConversation = getConversation(position);

+ 0 - 7
app/src/main/res/layout/controller_browser.xml

@@ -53,11 +53,4 @@
         app:itemIconTint="@color/fg_default"
         app:menu="@menu/file_browser_bottom" />
 
-    <include
-        layout="@layout/fast_scroller"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignTop="@id/recycler_view"
-        android:layout_alignBottom="@id/recycler_view" />
-
 </RelativeLayout>

+ 0 - 2
app/src/main/res/layout/controller_conversations_rv.xml

@@ -122,6 +122,4 @@
         app:srcCompat="@drawable/ic_add_white_24px"
         app:tint="@color/white" />
 
-    <include layout="@layout/fast_scroller" />
-
 </androidx.coordinatorlayout.widget.CoordinatorLayout>

+ 0 - 2
app/src/main/res/layout/controller_generic_rv.xml

@@ -38,8 +38,6 @@
 
     </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
 
-    <include layout="@layout/fast_scroller" />
-
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/recycler_view"
         android:layout_width="match_parent"

+ 0 - 36
app/src/main/res/layout/fast_scroller.xml

@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?><!--
-  ~ Nextcloud Talk application
-  ~
-  ~ @author Mario Danic
-  ~ Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
-  ~
-  ~ This program is free software: you can redistribute it and/or modify
-  ~ it under the terms of the GNU General Public License as published by
-  ~ the Free Software Foundation, either version 3 of the License, or
-  ~ at your option) any later version.
-  ~
-  ~ This program is distributed in the hope that it will be useful,
-  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
-  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  ~ GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License
-  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
-  -->
-
-<eu.davidea.fastscroller.FastScroller xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:id="@+id/fast_scroller"
-    android:layout_width="wrap_content"
-    android:layout_height="match_parent"
-    android:layout_alignTop="@+id/swipe_refresh_layout"
-    android:layout_alignBottom="@+id/swipe_refresh_layout"
-    android:layout_alignParentEnd="true"
-    android:layout_centerHorizontal="true"
-    app:fastScrollerAutoHideDelayInMillis="1000"
-    app:fastScrollerAutoHideEnabled="true"
-    app:fastScrollerBubbleEnabled="true"
-    app:fastScrollerBubblePosition="adjacent"
-    app:fastScrollerIgnoreTouchesOutsideHandle="false"
-    tools:visibility="visible"></eu.davidea.fastscroller.FastScroller>

+ 1 - 1
scripts/analysis/findbugs-results.txt

@@ -1 +1 @@
-600
+599

+ 1 - 1
scripts/analysis/lint-results.txt

@@ -1,2 +1,2 @@
 DO NOT TOUCH; GENERATED BY DRONE
-      <span class="mdl-layout-title">Lint Report: 3 errors and 269 warnings</span>
+      <span class="mdl-layout-title">Lint Report: 3 errors and 266 warnings</span>