Browse Source

Restored Sharing menu for reshared file with warning if resharing isn't allowed

Victor Nidens 7 years ago
parent
commit
4193dd04ab

+ 10 - 1
src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -24,6 +24,7 @@ package com.owncloud.android.ui.fragment;
 import android.accounts.Account;
 import android.graphics.Bitmap;
 import android.os.Bundle;
+import android.support.design.widget.Snackbar;
 import android.support.v7.widget.SwitchCompat;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -312,8 +313,16 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
             case R.id.action_send_share_file: {
-                mContainerActivity.getFileOperationsHelper().sendShareFile(getFile(),
+                if(getFile().isSharedWithMe() && !getFile().canReshare()){
+                    Snackbar.make(getView(),
+                            R.string.resharing_is_not_allowed,
+                            Snackbar.LENGTH_LONG
+                    )
+                            .show();
+                } else {
+                    mContainerActivity.getFileOperationsHelper().sendShareFile(getFile(),
                         (FileDisplayActivity) mContainerActivity);
+                }
                 return true;
             }
             case R.id.action_open_file_with: {

+ 2 - 2
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -944,8 +944,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             OCFile singleFile = checkedFiles.get(0);
             switch (menuId) {
                 case R.id.action_send_share_file: {
-                    mContainerActivity.getFileOperationsHelper().sendShareFile(singleFile,
-                            (FileDisplayActivity) mContainerActivity);
+                        mContainerActivity.getFileOperationsHelper().sendShareFile(singleFile,
+                    (FileDisplayActivity) mContainerActivity);
                     return true;
                 }
                 case R.id.action_open_file_with: {

+ 9 - 1
src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java

@@ -422,8 +422,16 @@ public class PreviewImageFragment extends FileFragment {
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
             case R.id.action_send_share_file:
-                mContainerActivity.getFileOperationsHelper().sendShareFile(getFile(),
+                if(getFile().isSharedWithMe() && !getFile().canReshare()){
+                    Snackbar.make(getView(),
+                            R.string.resharing_is_not_allowed,
+                            Snackbar.LENGTH_LONG
+                    )
+                            .show();
+                } else {
+                    mContainerActivity.getFileOperationsHelper().sendShareFile(getFile(),
                         (FileDisplayActivity) mContainerActivity);
+                }
                 return true;
 
             case R.id.action_open_file_with:

+ 1 - 0
src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java

@@ -38,6 +38,7 @@ import android.os.Bundle;
 import android.os.IBinder;
 import android.support.annotation.DrawableRes;
 import android.support.annotation.StringRes;
+import android.support.design.widget.Snackbar;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;

+ 10 - 1
src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java

@@ -22,6 +22,7 @@ package com.owncloud.android.ui.preview;
 import android.accounts.Account;
 import android.os.AsyncTask;
 import android.os.Bundle;
+import android.support.design.widget.Snackbar;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -382,8 +383,16 @@ public class PreviewTextFragment extends FileFragment {
     public boolean onOptionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
             case R.id.action_send_share_file: {
-                mContainerActivity.getFileOperationsHelper().sendShareFile(getFile(),
+                if(getFile().isSharedWithMe() && !getFile().canReshare()){
+                    Snackbar.make(getView(),
+                            R.string.resharing_is_not_allowed,
+                            Snackbar.LENGTH_LONG
+                    )
+                            .show();
+                } else {
+                    mContainerActivity.getFileOperationsHelper().sendShareFile(getFile(),
                         (FileDisplayActivity) mContainerActivity);
+                }
                 return true;
             }
             case R.id.action_open_file_with: {