Browse Source

remove action button, use checkable menu item for shown/hidden state display

(design review)

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 5 năm trước cách đây
mục cha
commit
74bfe473c4

+ 6 - 21
src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java

@@ -43,7 +43,6 @@ import android.widget.LinearLayout;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
-import com.google.android.material.button.MaterialButton;
 import com.nextcloud.client.account.User;
 import com.nextcloud.client.core.Clock;
 import com.nextcloud.client.device.PowerManagementService;
@@ -125,9 +124,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
     @BindView(R.id.empty_list_view_text)
     public TextView emptyContentMessage;
 
-    @BindView(R.id.empty_list_view_action)
-    public MaterialButton emptyContentActionButton;
-
     @BindView(android.R.id.list)
     public RecyclerView mRecyclerView;
 
@@ -250,8 +246,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         mAdapter = new SyncedFolderAdapter(this, clock, gridWidth, this, lightVersion);
         mSyncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences, clock);
         emptyContentIcon.setImageResource(R.drawable.nav_synced_folders);
-        emptyContentActionButton.setBackgroundColor(ThemeUtils.primaryColor(this));
-        emptyContentActionButton.setTextColor(ThemeUtils.fontColor(this));
 
         final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
         mAdapter.setLayoutManager(lm);
@@ -263,11 +257,13 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         load(gridWidth * 2, false);
     }
 
-    @OnClick(R.id.empty_list_view_action)
+    @OnClick(R.id.empty_list_view_text)
     public void showHiddenItems() {
-        mAdapter.toggleHiddenItemsVisibility();
-        emptyContentContainer.setVisibility(View.GONE);
-        mRecyclerView.setVisibility(View.VISIBLE);
+        if (mAdapter.getSectionCount() == 0 && mAdapter.getUnfilteredSectionCount() > mAdapter.getSectionCount()) {
+            mAdapter.toggleHiddenItemsVisibility();
+            emptyContentContainer.setVisibility(View.GONE);
+            mRecyclerView.setVisibility(View.VISIBLE);
+        }
     }
 
     /**
@@ -535,9 +531,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
                 int hiddenFoldersCount = mAdapter.getHiddenFolderCount();
 
                 showEmptyContent(getString(R.string.drawer_synced_folders),
-                                 getResources().getQuantityString(R.plurals.synced_folders_hidden_folders_count,
-                                                                  hiddenFoldersCount,
-                                                                  hiddenFoldersCount),
                                  getResources().getQuantityString(R.plurals.synced_folders_show_hidden_folders,
                                                                   hiddenFoldersCount,
                                                                   hiddenFoldersCount));
@@ -641,13 +634,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
 
     private void showEmptyContent(String headline, String message) {
         showEmptyContent(headline, message, false);
-        emptyContentActionButton.setVisibility(View.GONE);
-    }
-
-    private void showEmptyContent(String headline, String message, String action) {
-        showEmptyContent(headline, message, false);
-        emptyContentActionButton.setText(action);
-        emptyContentActionButton.setVisibility(View.VISIBLE);
     }
 
     private void showLoadingContent() {
@@ -656,7 +642,6 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
             getString(R.string.synced_folders_loading_folders),
             true
         );
-        emptyContentActionButton.setVisibility(View.GONE);
     }
 
     private void showEmptyContent(String headline, String message, boolean loading) {

+ 4 - 10
src/main/java/com/owncloud/android/ui/adapter/SyncedFolderAdapter.java

@@ -289,17 +289,11 @@ public class SyncedFolderAdapter extends SectionedRecyclerViewAdapter<SectionedV
     private void onOverflowIconClicked(int section, SyncedFolderDisplayItem item, View view) {
         PopupMenu popup = new PopupMenu(context, view);
         popup.inflate(R.menu.synced_folders_adapter);
-        popup.setOnMenuItemClickListener(i -> optionsItemSelected(i,section,item));
+        popup.setOnMenuItemClickListener(i -> optionsItemSelected(i, section, item));
+        popup.getMenu()
+            .findItem(R.id.action_auto_upload_folder_toggle_visibility)
+            .setChecked(item.isHidden());
 
-        if (item.isHidden()) {
-            popup.getMenu()
-                .findItem(R.id.action_auto_upload_folder_toggle_visibility)
-                .setTitle(R.string.autoupload_show_folder);
-        } else {
-            popup.getMenu()
-                .findItem(R.id.action_auto_upload_folder_toggle_visibility)
-                .setTitle(R.string.autoupload_hide_folder);
-        }
         popup.show();
     }
 

+ 0 - 11
src/main/res/layout/empty_list.xml

@@ -19,7 +19,6 @@
   License along with this program. If not, see <http://www.gnu.org/licenses/>.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              xmlns:app="http://schemas.android.com/apk/res-auto"
               android:id="@+id/empty_list_view"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
@@ -64,17 +63,7 @@
         android:ellipsize="end"
         android:gravity="center"
         android:paddingTop="@dimen/standard_half_padding"
-        android:paddingBottom="@dimen/standard_half_padding"
         android:text="@string/file_list_empty"
         android:visibility="gone"/>
 
-    <com.google.android.material.button.MaterialButton
-        android:id="@+id/empty_list_view_action"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:theme="@style/Button.Primary"
-        app:cornerRadius="@dimen/button_corner_radius"
-        android:layout_marginTop="@dimen/standard_double_margin"
-        android:visibility="gone"/>
-
 </LinearLayout>

+ 2 - 1
src/main/res/menu/synced_folders_adapter.xml

@@ -20,7 +20,8 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
     <item
         android:id="@+id/action_auto_upload_folder_toggle_visibility"
-        android:title="@string/autoupload_hide_folder" />
+        android:title="@string/autoupload_hide_folder"
+        android:checkable="true"/>
 
     <item
         android:id="@+id/action_auto_upload_folder_settings"

+ 0 - 5
src/main/res/values/strings.xml

@@ -559,10 +559,6 @@
         <item quantity="one">Show %1$d hidden folder</item>
         <item quantity="other">Show %1$d hidden folders</item>
     </plurals>
-    <plurals name="synced_folders_hidden_folders_count">
-        <item quantity="one">%1$d hidden folder</item>
-        <item quantity="other">%1$d hidden folders</item>
-    </plurals>
     <string name="synced_folders_preferences">Preferences for auto uploading</string>
     <string name="synced_folders_new_info">Instant uploading has been revamped completely. Re-configure your auto upload from within the main menu.\n\nEnjoy the new and extended auto uploading.</string>
     <string name="synced_folders_preferences_folder_path">For %1$s</string>
@@ -635,7 +631,6 @@
     <!-- Auto upload -->
     <string name="autoupload_custom_folder">Set up a custom folder</string>
     <string name="autoupload_create_new_custom_folder">Create new custom folder setup</string>
-    <string name="autoupload_show_folder">Show folder</string>
     <string name="autoupload_hide_folder">Hide folder</string>
     <string name="autoupload_configure">Configure</string>
     <string name="synced_folders_configure_folders">Configure folders</string>