Browse Source

Merge pull request #6354 from nextcloud/noShare

Enhance FileDetailSharingFragment
Andy Scherzinger 4 năm trước cách đây
mục cha
commit
dfc94f4505

+ 26 - 13
src/main/java/com/owncloud/android/ui/fragment/FileDetailSharingFragment.java

@@ -31,6 +31,7 @@ import android.content.res.Resources;
 import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
+import android.text.InputType;
 import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -111,9 +112,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
     @BindView(R.id.shareUsersList)
     RecyclerView usersList;
 
-    @BindView(R.id.shareNoUsers)
-    TextView noList;
-
     @BindView(R.id.share_by_link)
     AppCompatCheckBox shareByLink;
 
@@ -138,6 +136,9 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
     @BindView(R.id.shared_with_you_username)
     TextView sharedWithYouUsername;
 
+    @BindView(R.id.shared_with_you_note_container)
+    View sharedWithYouNoteContainer;
+
     @BindView(R.id.shared_with_you_note)
     TextView sharedWithYouNote;
 
@@ -239,17 +240,31 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
     private void setupView() {
         setShareWithYou();
 
+        FileDetailSharingFragmentHelper.setupSearchView(
+            (SearchManager) fileActivity.getSystemService(Context.SEARCH_SERVICE), searchView,
+            fileActivity.getComponentName());
+        ThemeUtils.themeSearchView(searchView, requireContext());
+
         if (file.canReshare()) {
             setShareByLinkInfo(file.isSharedViaLink());
             setShareWithUserInfo();
-            FileDetailSharingFragmentHelper.setupSearchView(
-                (SearchManager) fileActivity.getSystemService(Context.SEARCH_SERVICE), searchView,
-                fileActivity.getComponentName());
-            ThemeUtils.themeSearchView(searchView, requireContext());
         } else {
-            searchView.setVisibility(View.GONE);
+            searchView.setQueryHint(getResources().getString(R.string.reshare_not_allowed));
+            searchView.setInputType(InputType.TYPE_NULL);
+            disableSearchView(searchView);
             shareByLinkContainer.setVisibility(View.GONE);
-            noList.setText(R.string.reshare_not_allowed);
+        }
+    }
+
+    private void disableSearchView(View view) {
+        view.setEnabled(false);
+
+        if (view instanceof ViewGroup) {
+            ViewGroup viewGroup = (ViewGroup) view;
+
+            for (int i = 0; i < viewGroup.getChildCount(); i++) {
+                disableSearchView(viewGroup.getChildAt(i));
+            }
         }
     }
 
@@ -309,9 +324,9 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
 
             if (!TextUtils.isEmpty(note)) {
                 sharedWithYouNote.setText(file.getNote());
-                sharedWithYouNote.setVisibility(View.VISIBLE);
+                sharedWithYouNoteContainer.setVisibility(View.VISIBLE);
             } else {
-                sharedWithYouNote.setVisibility(View.GONE);
+                sharedWithYouNoteContainer.setVisibility(View.GONE);
             }
         }
     }
@@ -334,10 +349,8 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
                                                        userId));
             usersList.setLayoutManager(new LinearLayoutManager(getContext()));
             usersList.addItemDecoration(new SimpleListItemDividerDecoration(getContext()));
-            noList.setVisibility(View.GONE);
         } else {
             usersList.setVisibility(View.GONE);
-            noList.setVisibility(View.VISIBLE);
         }
     }
 

+ 31 - 26
src/main/res/layout/file_details_sharing_fragment.xml

@@ -18,10 +18,11 @@
   License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-            xmlns:app="http://schemas.android.com/apk/res-auto"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_weight="1">
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_weight="1">
 
     <LinearLayout
         android:id="@+id/shareContainer"
@@ -59,26 +60,41 @@
             <LinearLayout
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:orientation="vertical">
+                android:orientation="vertical"
+                android:paddingLeft="@dimen/standard_padding"
+                android:paddingTop="@dimen/standard_half_padding"
+                android:paddingRight="@dimen/standard_padding">
 
                 <TextView
                     android:id="@+id/shared_with_you_username"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
-                    android:paddingLeft="@dimen/standard_padding"
-                    android:paddingTop="@dimen/standard_half_padding"
-                    android:paddingRight="@dimen/standard_padding"
                     android:text="@string/shared_with_you_by"
-                    android:textSize="16sp"/>
+                    android:textSize="16sp" />
 
-                <TextView
-                    android:id="@+id/shared_with_you_note"
+                <LinearLayout
+                    android:id="@+id/shared_with_you_note_container"
                     android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:paddingLeft="@dimen/standard_padding"
+                    android:layout_height="match_parent"
+                    android:orientation="horizontal"
                     android:paddingTop="@dimen/standard_half_padding"
-                    android:paddingRight="@dimen/standard_padding"
-                    android:textSize="16sp"/>
+                    tools:ignore="UseCompoundDrawables">
+
+                    <ImageView
+                        android:layout_width="16dp"
+                        android:layout_height="16dp"
+                        android:src="@drawable/file_text"
+                        android:contentDescription="@string/note_icon_hint" />
+
+                    <TextView
+                        android:id="@+id/shared_with_you_note"
+                        android:layout_width="0dp"
+                        android:layout_height="wrap_content"
+                        android:paddingStart="@dimen/standard_half_padding"
+                        android:paddingEnd="@dimen/standard_half_padding"
+                        android:textSize="16sp"
+                        android:layout_weight="1" />
+                </LinearLayout>
 
             </LinearLayout>
         </LinearLayout>
@@ -146,7 +162,6 @@
                 android:src="@drawable/ic_dots_vertical"/>
         </LinearLayout>
 
-
         <androidx.recyclerview.widget.RecyclerView
             android:id="@+id/shareUsersList"
             android:layout_width="match_parent"
@@ -155,16 +170,6 @@
             android:divider="@drawable/divider"
             android:dividerHeight="1dp" />
 
-        <TextView
-            android:id="@+id/shareNoUsers"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:paddingLeft="@dimen/standard_padding"
-            android:paddingTop="@dimen/standard_half_padding"
-            android:paddingRight="@dimen/standard_padding"
-            android:text="@string/share_no_users"
-            android:textSize="16sp" />
-
         <LinearLayout
             android:id="@+id/copy_internal_container"
             android:layout_width="match_parent"

+ 1 - 1
src/main/res/values/strings.xml

@@ -464,7 +464,6 @@
 
     <string name="share_dialog_title">Sharing</string>
     <string name="share_file">Share %1$s</string>
-    <string name="share_no_users">No data shared with users yet</string>
     <string name="share_via_link_menu_password_label">Password protect (%1$s)</string>
     <string name="share_expiration_date_label">Expires %1$s</string>
     <string name="share_no_expiration_date_label">Set expiration date</string>
@@ -926,4 +925,5 @@
     <string name="invalid_url">Invalid URL</string>
     <string name="conflict_dialog_error">Error creating conflict dialog!</string>
     <string name="qr_could_not_be_read">QR Code could not be read!</string>
+    <string name="note_icon_hint">Note icon</string>
 </resources>