فهرست منبع

fix send menu action + send/share dialog extension

AndyScherzinger 7 سال پیش
والد
کامیت
4a22b932b1

+ 13 - 2
src/main/java/com/owncloud/android/ui/dialog/SendShareDialog.java

@@ -16,6 +16,7 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import com.owncloud.android.R;
@@ -53,20 +54,23 @@ import java.util.List;
 public class SendShareDialog extends BottomSheetDialogFragment {
 
     private static final String KEY_OCFILE = "KEY_OCFILE";
+    private static final String KEY_HIDE_NCSHARING_OPTIONS = "KEY_HIDE_NCSHARING_OPTIONS";
     private static final String TAG = SendShareDialog.class.getSimpleName();
     public static final String PACKAGE_NAME = "PACKAGE_NAME";
     public static final String ACTIVITY_NAME = "ACTIVITY_NAME";
 
     private View view;
     private OCFile file;
+    private boolean hideNcSharingOptions;
     private FileOperationsHelper fileOperationsHelper;
 
-    public static SendShareDialog newInstance(OCFile file) {
+    public static SendShareDialog newInstance(OCFile file, boolean hideNcSharingOptions) {
 
         SendShareDialog dialogFragment = new SendShareDialog();
 
         Bundle args = new Bundle();
         args.putParcelable(KEY_OCFILE, file);
+        args.putBoolean(KEY_HIDE_NCSHARING_OPTIONS, hideNcSharingOptions);
         dialogFragment.setArguments(args);
 
         return dialogFragment;
@@ -81,6 +85,7 @@ public class SendShareDialog extends BottomSheetDialogFragment {
         view = null;
 
         file = getArguments().getParcelable(KEY_OCFILE);
+        hideNcSharingOptions = getArguments().getBoolean(KEY_HIDE_NCSHARING_OPTIONS, false);
     }
 
     @Nullable
@@ -89,6 +94,9 @@ public class SendShareDialog extends BottomSheetDialogFragment {
 
         view = inflater.inflate(R.layout.send_share_fragment, container, false);
 
+        LinearLayout sendShareButtons = view.findViewById(R.id.send_share_buttons);
+        View divider = view.findViewById(R.id.divider);
+
         // Share with people
         TextView sharePeopleText = view.findViewById(R.id.share_people_button);
         sharePeopleText.setOnClickListener(v -> shareFile(file));
@@ -105,7 +113,10 @@ public class SendShareDialog extends BottomSheetDialogFragment {
         themeShareButtonImage(shareLinkImageView);
         shareLinkImageView.setOnClickListener(v -> shareFile(file));
 
-        if (file.isSharedWithMe() && !file.canReshare()) {
+        if (hideNcSharingOptions) {
+            sendShareButtons.setVisibility(View.GONE);
+            divider.setVisibility(View.GONE);
+        } else if (file.isSharedWithMe() && !file.canReshare()) {
             showResharingNotAllowedSnackbar();
 
             if (file.isFolder()) {

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

@@ -27,7 +27,6 @@ import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
-import android.support.design.widget.Snackbar;
 import android.support.design.widget.TabLayout;
 import android.support.v4.view.ViewPager;
 import android.view.LayoutInflater;
@@ -345,6 +344,12 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             mf.filter(menu, true);
         }
 
+        if (getFile().isFolder()) {
+            FileMenuFilter.hideMenuItems(
+                    menu.findItem(R.id.action_send_file)
+            );
+        }
+
         // dual pane restrictions
         if (!getResources().getBoolean(R.bool.large_land_layout)){
             FileMenuFilter.hideMenuItems(
@@ -353,17 +358,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         }
     }
 
-    public boolean optionsItemSelected(MenuItem item) {
+    private boolean optionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
             case R.id.action_send_file: {
-                if(getFile().isSharedWithMe() && !getFile().canReshare()){
-                    Snackbar.make(getView(),
-                            R.string.resharing_is_not_allowed,
-                            Snackbar.LENGTH_LONG
-                    ).show();
-                } else {
-                    mContainerActivity.getFileOperationsHelper().sendShareFile(getFile());
-                }
+                mContainerActivity.getFileOperationsHelper().sendShareFile(getFile(), true);
                 return true;
             }
             case R.id.action_open_file_with: {

+ 6 - 2
src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java

@@ -615,17 +615,21 @@ public class FileOperationsHelper {
         return false;
     }
 
-    public void sendShareFile(OCFile file) {
+    public void sendShareFile(OCFile file, boolean hideNcSharingOptions) {
         // Show dialog
         FragmentManager fm = mFileActivity.getSupportFragmentManager();
         FragmentTransaction ft = fm.beginTransaction();
         ft.addToBackStack(null);
 
-        SendShareDialog mSendShareDialog = SendShareDialog.newInstance(file);
+        SendShareDialog mSendShareDialog = SendShareDialog.newInstance(file, hideNcSharingOptions);
         mSendShareDialog.setFileOperationsHelper(this);
         mSendShareDialog.show(ft, "TAG_SEND_SHARE_DIALOG");
     }
 
+    public void sendShareFile(OCFile file) {
+        sendShareFile(file, false);
+    }
+
     public void syncFiles(Collection<OCFile> files) {
         for (OCFile file : files) {
             syncFile(file);

+ 10 - 10
src/main/res/menu/file_details_actions_menu.xml

@@ -1,21 +1,21 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  ownCloud Android client application
+  Nextcloud Android client application
 
-  Copyright (C) 2012  Bartek Przybylski
-  Copyright (C) 2015 ownCloud Inc.
+  Copyright (C) 2018 Andy Scherzinger
 
-  This program is free software: you can redistribute it and/or modify
-  it under the terms of the GNU General Public License version 2,
-  as published by the Free Software Foundation.
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+  License as published by the Free Software Foundation; either
+  version 3 of the License, or 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.
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU AFFERO 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/>.
+  You should have received a copy of the GNU Affero General Public
+  License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 -->
 <menu xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res-auto"