Browse Source

- make image & text clickable
- show snackbar correctly if resharing is not allowed, then also grey out image&text if not folder

tobiasKaminsky 7 years ago
parent
commit
2168e5a344

+ 44 - 9
src/main/java/com/owncloud/android/ui/dialog/SendShareDialog.java

@@ -13,6 +13,7 @@ import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.ImageView;
 import android.widget.TextView;
 
 import com.owncloud.android.R;
@@ -90,21 +91,50 @@ public class SendShareDialog extends BottomSheetDialogFragment {
         view = inflater.inflate(R.layout.send_share_fragment, container, false);
 
         // Share with people
-        TextView sharePeopleButton = (TextView) view.findViewById(R.id.share_people_button);
-
-        sharePeopleButton.setOnClickListener(v -> fileOperationsHelper.showShareFile(file));
+        TextView sharePeopleText = (TextView) view.findViewById(R.id.share_people_button);
+        sharePeopleText.setOnClickListener(v -> shareFile(file));
 
+        ImageView sharePeopleImageView = (ImageView) view.findViewById(R.id.share_people_icon);
+        sharePeopleImageView.setOnClickListener(v -> shareFile(file));
 
         // Share via link button
-        TextView shareLinkButton = (TextView) view.findViewById(R.id.share_link_button);
+        TextView shareLinkText = (TextView) view.findViewById(R.id.share_link_button);
+        shareLinkText.setOnClickListener(v -> fileOperationsHelper.showShareFile(file));
+
+        ImageView shareLinkImageView = (ImageView) view.findViewById(R.id.share_link_icon);
+        shareLinkImageView.setOnClickListener(v -> shareFile(file));
 
         if (file.isSharedWithMe() && !file.canReshare()) {
-            Snackbar.make(view, R.string.resharing_is_not_allowed, Snackbar.LENGTH_LONG).show();
-            shareLinkButton.setVisibility(View.GONE);
-        }
+            Snackbar snackbar = Snackbar.make(view, R.string.resharing_is_not_allowed, Snackbar.LENGTH_LONG);
+            snackbar.addCallback(new Snackbar.Callback() {
+                @Override
+                public void onDismissed(Snackbar transientBottomBar, int event) {
+                    super.onDismissed(transientBottomBar, event);
+
+                    if (file.isFolder()) {
+                        dismiss();
+                    }
+                }
+            });
 
-        shareLinkButton.setOnClickListener(v -> fileOperationsHelper.showShareFile(file));
+            snackbar.show();
 
+            if (file.isFolder()) {
+                shareLinkText.setVisibility(View.GONE);
+                shareLinkImageView.setVisibility(View.GONE);
+                sharePeopleText.setVisibility(View.GONE);
+                sharePeopleImageView.setVisibility(View.GONE);
+            } else {
+                shareLinkText.setEnabled(false);
+                shareLinkText.setAlpha(0.3f);
+                shareLinkImageView.setEnabled(false);
+                shareLinkImageView.setAlpha(0.3f);
+                sharePeopleText.setEnabled(false);
+                sharePeopleText.setAlpha(0.3f);
+                sharePeopleImageView.setEnabled(false);
+                sharePeopleImageView.setAlpha(0.3f);
+            }
+        }
 
         // populate send apps
         Intent sendIntent = new Intent(Intent.ACTION_SEND);
@@ -124,7 +154,7 @@ public class SendShareDialog extends BottomSheetDialogFragment {
         }
 
         if (getContext().getString(R.string.send_files_to_other_apps).equalsIgnoreCase("off")) {
-            sharePeopleButton.setVisibility(View.GONE);
+            sharePeopleText.setVisibility(View.GONE);
         }
 
         SendButtonAdapter.ClickListener clickListener = sendButtonDataData -> {
@@ -159,6 +189,11 @@ public class SendShareDialog extends BottomSheetDialogFragment {
         return view;
     }
 
+    private void shareFile(OCFile file) {
+        fileOperationsHelper.showShareFile(file);
+        dismiss();
+    }
+
     public void setFileOperationsHelper(FileOperationsHelper fileOperationsHelper) {
         this.fileOperationsHelper = fileOperationsHelper;
     }

+ 19 - 13
src/main/res/layout/send_share_fragment.xml

@@ -20,20 +20,25 @@
  along with this program. If not, see <http://www.gnu.org/licenses/>.
 -->
 
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent">
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                                                 android:layout_width="match_parent"
+                                                 android:layout_height="match_parent">
 
-    <LinearLayout
-        android:id="@+id/send_share_buttons"
+    <RelativeLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginEnd="20dp"
-        android:layout_marginLeft="20dp"
-        android:layout_marginRight="20dp"
-        android:layout_marginStart="20dp"
-        android:orientation="horizontal"
-        android:padding="20dp">
+        android:layout_height="match_parent">
+
+        <LinearLayout
+            android:id="@+id/send_share_buttons"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="20dp"
+            android:layout_marginLeft="20dp"
+            android:layout_marginRight="20dp"
+            android:layout_marginStart="20dp"
+            android:orientation="horizontal"
+            android:baselineAligned="false"
+            android:padding="20dp">
 
         <LinearLayout
             android:layout_width="wrap_content"
@@ -99,4 +104,5 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_below="@id/divider"/>
-</RelativeLayout>
+    </RelativeLayout>
+</android.support.design.widget.CoordinatorLayout>