Browse Source

Show the layout to hsare with user in phone and tablet

masensio 9 years ago
parent
commit
f28faf0c26

+ 110 - 0
res/layout/share_file_dialog.xml

@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ownCloud Android client application
+  Copyright (C) 2015 ownCloud Inc.
+
+  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 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.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="com.owncloud.android.ui.dialog.ShareFileDialogFragment">
+
+    <ScrollView
+        android:id="@+id/shareScrollView"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:fillViewport="true">
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:layout_marginBottom="8dp">
+
+            <RelativeLayout
+                android:id="@+id/shareHeaderContainer"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_margin="8dp">
+
+                <ImageView
+                    android:id="@+id/shareFileIcon"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:src="@drawable/file"
+                    android:layout_margin="8dp"
+                    android:maxHeight="96dp"
+                    android:maxWidth="96dp"/>
+
+                <TextView
+                    android:id="@+id/shareFileName"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/placeholder_filename"
+                    android:textAppearance="?android:attr/textAppearanceLarge"
+                    android:layout_marginTop="39dp"
+                    android:layout_alignParentTop="true"
+                    android:layout_toRightOf="@+id/shareFileIcon"
+                    android:layout_toEndOf="@+id/shareFileIcon" />
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:textAppearance="?android:attr/textAppearanceMedium"
+                    android:text="@string/placeholder_filesize"
+                    android:id="@+id/shareFileSize"
+                    android:layout_below="@+id/shareFileName"
+                    android:layout_toRightOf="@+id/shareFileIcon"
+                    android:layout_toEndOf="@+id/shareFileIcon"
+                    android:layout_marginTop="12dp" />
+
+            </RelativeLayout>
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:text="@string/share_with_user_section_title"
+                android:id="@+id/shareWithUsersSectionTitle"
+                android:layout_gravity="left"
+                android:padding="8dp"
+                android:background="@color/actionbar_start_color"
+                android:textColor="@color/white"/>
+
+            <ListView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/shareUsersList"
+                android:visibility="gone" />
+
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:id="@+id/shareNoUsers"
+                android:text="@string/share_no_users"
+                android:padding="12dp" />
+
+            <android.support.v7.widget.AppCompatButton
+                android:id="@+id/addUserButton"
+                style="@style/ownCloud.Button"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:text="@string/share_add_user_or_group"
+                android:contentDescription="shareAddUserButton"/>
+        </LinearLayout>
+    </ScrollView>
+</FrameLayout>

+ 0 - 101
res/layout/share_layout.xml

@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ownCloud Android client application
-  Copyright (C) 2015 ownCloud Inc.
-
-  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 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.
-
-  You should have received a copy of the GNU General Public License
-  along with this program.  If not, see <http://www.gnu.org/licenses/>.
--->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/shareScrollView"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:fillViewport="true"
-    style="Theme.owncloud">
-  <LinearLayout
-      android:layout_width="match_parent"
-      android:layout_height="wrap_content"
-      android:background="@color/background_material_light"
-      android:orientation="vertical">
-
-    <RelativeLayout
-        android:id="@+id/shareHeaderContainer"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="8dp"
-        android:layout_marginBottom="8dp"
-        android:background="@color/background_color">
-
-      <ImageView
-          android:id="@+id/shareFileIcon"
-          android:layout_width="wrap_content"
-          android:layout_height="wrap_content"
-          android:src="@drawable/file" />
-
-      <TextView
-          android:id="@+id/shareFileName"
-          android:layout_width="wrap_content"
-          android:layout_height="wrap_content"
-          android:text="@string/placeholder_filename"
-          android:textAppearance="?android:attr/textAppearanceLarge"
-          android:layout_marginTop="39dp"
-          android:layout_alignParentTop="true"
-          android:layout_toRightOf="@+id/shareFileIcon"
-          android:layout_toEndOf="@+id/shareFileIcon" />
-
-      <TextView
-          android:layout_width="wrap_content"
-          android:layout_height="wrap_content"
-          android:textAppearance="?android:attr/textAppearanceMedium"
-          android:text="@string/placeholder_filesize"
-          android:id="@+id/shareFileSize"
-          android:layout_below="@+id/shareFileName"
-          android:layout_toRightOf="@+id/shareFileIcon"
-          android:layout_toEndOf="@+id/shareFileIcon"
-          android:layout_marginTop="12dp" />
-
-    </RelativeLayout>
-
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:text="@string/share_with_user_section_title"
-        android:id="@+id/shareWithUsersSectionTitle"
-        android:layout_gravity="left"
-        android:padding="8dp"
-        android:background="@color/actionbar_start_color"
-        android:textColor="@color/white"/>
-
-    <ListView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:id="@+id/shareUsersList"
-        android:visibility="gone" />
-
-     <TextView
-         android:layout_width="match_parent"
-         android:layout_height="wrap_content"
-         android:id="@+id/shareNoUsers"
-         android:text="@string/share_no_users"
-         android:padding="12dp" />
-
-    <android.support.v7.widget.AppCompatButton
-        android:id="@+id/addUserButton"
-        style="@style/ownCloud.Button"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center_horizontal"
-        android:text="@string/share_add_user_or_group"
-        android:contentDescription="shareAddUserButton"/>
-  </LinearLayout>
-</ScrollView>

+ 4 - 0
res/values/strings.xml

@@ -367,8 +367,12 @@
     <string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
     <string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
 
+    <string name="share_link_title">Share link</string>
     <string name="share_with_user_section_title">Share with Users and Groups</string>
     <string name="share_no_users">No data shared with users yet</string>
     <string name="share_add_user_or_group">Add User or Group</string>
 
+<!-- TODO: Remove or change this placeholder text -->
+    <string name="hello_blank_fragment">Hello blank fragment</string>
+
 </resources>

+ 28 - 9
src/com/owncloud/android/files/FileOperationsHelper.java

@@ -43,6 +43,7 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.services.OperationsService;
 import com.owncloud.android.services.observer.FileObserverService;
 import com.owncloud.android.ui.activity.FileActivity;
+import com.owncloud.android.ui.dialog.ShareFileDialogFragment;
 import com.owncloud.android.ui.dialog.ShareLinkToDialog;
 
 import org.apache.http.protocol.HTTP;
@@ -74,7 +75,8 @@ public class FileOperationsHelper {
             String encodedStoragePath = WebdavUtils.encodePath(storagePath);
 
             Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW);
-            intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath), file.getMimetype());
+            intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath),
+                    file.getMimetype());
             intentForSavedMimeType.setFlags(
                     Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
             );
@@ -86,9 +88,12 @@ public class FileOperationsHelper {
                 );
                 if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) {
                     intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW);
-                    intentForGuessedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath), guessedMimeType);
+                    intentForGuessedMimeType.
+                            setDataAndType(Uri.parse("file://"+ encodedStoragePath),
+                                    guessedMimeType);
                     intentForGuessedMimeType.setFlags(
-                            Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
+                            Intent.FLAG_GRANT_READ_URI_PERMISSION |
+                                    Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                     );
                 }
             }
@@ -140,7 +145,8 @@ public class FileOperationsHelper {
                 String link = "https://fake.url";
                 Intent intent = createShareWithLinkIntent(link);
                 String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
-                DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent, packagesToExclude, file);
+                DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent,
+                        packagesToExclude, file);
                 chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
 
             } else {
@@ -150,7 +156,8 @@ public class FileOperationsHelper {
         } else {
             // Show a Message
             Toast t = Toast.makeText(
-                    mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG
+                    mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api),
+                    Toast.LENGTH_LONG
             );
             t.show();
         }
@@ -210,12 +217,21 @@ public class FileOperationsHelper {
 
         } else {
             // Show a Message
-            Toast t = Toast.makeText(mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
+            Toast t = Toast.makeText(mFileActivity,
+                    mFileActivity.getString(R.string.share_link_no_support_share_api),
+                    Toast.LENGTH_LONG);
             t.show();
 
         }
     }
 
+    public void showShareFile(OCFile file){
+        ShareFileDialogFragment dialog =
+                ShareFileDialogFragment.newInstance(file, mFileActivity.getAccount());
+        dialog.show(mFileActivity.getSupportFragmentManager(), mFileActivity.DIALOG_SHARE_FILE);
+
+    }
+
     public void sendDownloadedFile(OCFile file) {
         if (file != null) {
             String storagePath = file.getStoragePath();
@@ -228,7 +244,8 @@ public class FileOperationsHelper {
 
             // Show dialog, without the own app
             String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
-            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
+            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent,
+                    packagesToExclude, file);
             chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
 
         } else {
@@ -324,7 +341,8 @@ public class FileOperationsHelper {
     public void cancelTransference(OCFile file) {
         Account account = mFileActivity.getAccount();
         if (file.isFolder()) {
-            OperationsService.OperationsServiceBinder opsBinder = mFileActivity.getOperationsServiceBinder();
+            OperationsService.OperationsServiceBinder opsBinder =
+                    mFileActivity.getOperationsServiceBinder();
             if (opsBinder != null) {
                 opsBinder.cancel(account, file);
             }
@@ -391,7 +409,8 @@ public class FileOperationsHelper {
      */
     public boolean isVersionWithForbiddenCharacters() {
         if (mFileActivity.getAccount() != null) {
-            OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
+            OwnCloudVersion serverVersion =
+                    AccountUtils.getServerVersion(mFileActivity.getAccount());
             return (serverVersion != null && serverVersion.isVersionWithForbiddenCharacters());
         }
         return false;

+ 2 - 0
src/com/owncloud/android/ui/activity/FileActivity.java

@@ -100,6 +100,8 @@ public class FileActivity extends AppCompatActivity
     public static final String TAG = FileActivity.class.getSimpleName();
 
     private static final String DIALOG_WAIT_TAG = "DIALOG_WAIT";
+    public static final String DIALOG_SHARE_FILE = "DIALOG_SHARE_FILE";
+
     private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID";
     private static final String DIALOG_SHARE_PASSWORD = "DIALOG_SHARE_PASSWORD";
     private static final String KEY_TRY_SHARE_AGAIN = "TRY_SHARE_AGAIN";

+ 15 - 2
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -90,6 +90,8 @@ import com.owncloud.android.services.observer.FileObserverService;
 import com.owncloud.android.syncadapter.FileSyncAdapter;
 import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
 import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
+import com.owncloud.android.ui.dialog.ShareFileDialogFragment;
+import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;
 import com.owncloud.android.ui.dialog.UploadSourceDialogFragment;
@@ -116,8 +118,6 @@ public class FileDisplayActivity extends HookActivity
         implements FileFragment.ContainerActivity,
         OnSslUntrustedCertListener, OnEnforceableRefreshListener {
 
-
-
     private SyncBroadcastReceiver mSyncBroadcastReceiver;
     private UploadFinishReceiver mUploadFinishReceiver;
     private DownloadFinishReceiver mDownloadFinishReceiver;
@@ -1229,6 +1229,19 @@ public class FileDisplayActivity extends HookActivity
         setFile(file);
     }
 
+    /**
+     * Shows the share view for sharing  {@link OCFile} received as a
+     * parameter in the second fragment.
+     *
+     * @param file {@link OCFile}  File to share with
+     */
+    @Override
+    public void showShareFile(OCFile file) {
+        ShareFileDialogFragment dialog =
+                ShareFileDialogFragment.newInstance(file, getAccount());
+        dialog.show(getSupportFragmentManager(), DIALOG_SHARE_FILE);
+    }
+
     @Override
     protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) {
         if (mDualPane) {

+ 17 - 6
src/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -350,9 +350,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
         actionBar.setDisplayHomeAsUpEnabled(!atRoot);
         actionBar.setHomeButtonEnabled(!atRoot);
         actionBar.setTitle(
-            atRoot 
-                ? getString(R.string.default_display_name_for_root_folder) 
-                : currentDir.getFileName()
+                atRoot
+                        ? getString(R.string.default_display_name_for_root_folder)
+                        : currentDir.getFileName()
         );
     }
 
@@ -390,7 +390,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
         super.onRemoteOperationFinish(operation, result);
         
         if (operation instanceof CreateFolderOperation) {
-            onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
+            onCreateFolderOperationFinish((CreateFolderOperation) operation, result);
             
         }
     }
@@ -542,9 +542,9 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
     
 
     /**
-     * Shows the information of the {@link OCFile} received as a 
+     * Shows the information of the {@link OCFile} received as a
      * parameter in the second fragment.
-     * 
+     *
      * @param file          {@link OCFile} whose details will be shown
      */
     @Override
@@ -560,6 +560,17 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
             
     }
 
+    /**
+     * Shows the share view for sharing  {@link OCFile} received as a
+     * parameter in the second fragment.
+     *
+     * @param file {@link OCFile}  File to share with
+     */
+    @Override
+    public void showShareFile(OCFile file) {
+
+    }
+
     @Override
     public void onRefresh() {
         refreshList(true);

+ 158 - 0
src/com/owncloud/android/ui/dialog/ShareFileDialogFragment.java

@@ -0,0 +1,158 @@
+/**
+ *   ownCloud Android client application
+ *
+ *   @author masensio
+ *   Copyright (C) 2015 ownCloud Inc.
+ *
+ *   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 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.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.ui.dialog;
+
+import android.accounts.Account;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.Bundle;
+import android.app.Fragment;
+import android.support.v4.app.DialogFragment;
+import android.support.v7.app.AlertDialog;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.owncloud.android.R;
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.datamodel.ThumbnailsCacheManager;
+import com.owncloud.android.utils.DisplayUtils;
+import com.owncloud.android.utils.MimetypeIconUtil;
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Activities that contain this fragment must implement the
+ * {@link ShareFileDialogFragment.OnFragmentInteractionListener} interface
+ * to handle interaction events.
+ * Use the {@link ShareFileDialogFragment#newInstance} factory method to
+ * create an instance of this fragment.
+ *
+ * Dialog Fragment to show the share options of a file/folder
+ *
+ * Search the users and share with them
+ */
+public class ShareFileDialogFragment extends DialogFragment
+        implements DialogInterface.OnClickListener{
+    private static final String TAG = ShareFileDialogFragment.class.getSimpleName();
+
+    // the fragment initialization parameters
+    private static final String ARG_FILE = "FILE";
+    private static final String ARG_ACCOUNT = "ACCOUNT";
+
+    // Parameters
+    private OCFile mFile;
+    private Account mAccount;
+
+    private OnFragmentInteractionListener mListener;
+
+    /**
+     * Public factory method to create new ShareFileDialogFragment instances.
+     *
+     * @param fileToShare   An {@link OCFile} to show in the fragment
+     * @param account       An ownCloud account
+     * @return A new instance of fragment ShareFragment.
+     */
+    public static ShareFileDialogFragment newInstance(OCFile fileToShare, Account account) {
+        ShareFileDialogFragment fragment = new ShareFileDialogFragment();
+        Bundle args = new Bundle();
+        args.putParcelable(ARG_FILE, fileToShare);
+        args.putParcelable(ARG_ACCOUNT, account);
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    public ShareFileDialogFragment() {
+        // Required empty public constructor
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        if (getArguments() != null) {
+            mFile = getArguments().getParcelable(ARG_FILE);
+            mAccount = getArguments().getParcelable(ARG_ACCOUNT);
+        }
+    }
+
+    @Override
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+
+        // Inflate the layout for the dialog
+        LayoutInflater inflater = getActivity().getLayoutInflater();
+        View view = inflater.inflate(R.layout.share_file_dialog, null);
+
+        // Setup layout
+        // Image
+        ImageView icon = (ImageView) view.findViewById(R.id.shareFileIcon);
+        icon.setImageResource(MimetypeIconUtil.getFileTypeIconId(mFile.getMimetype(),
+                mFile.getFileName()));
+        if (mFile.isImage()) {
+            String remoteId = String.valueOf(mFile.getRemoteId());
+            Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(remoteId);
+            if (thumbnail != null){
+                icon.setImageBitmap(thumbnail);
+            }
+        }
+        // Name
+        TextView filename = (TextView) view.findViewById(R.id.shareFileName);
+        filename.setText(mFile.getFileName());
+        // Size
+        TextView size = (TextView) view.findViewById(R.id.shareFileSize);
+        if (mFile.isFolder()){
+            size.setVisibility(View.GONE);
+        } else {
+            size.setText(DisplayUtils.bytesToHumanReadable(mFile.getFileLength()));
+        }
+
+        // Build the dialog
+        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+        builder.setView(view)
+                .setPositiveButton(R.string.common_ok, this)
+                .setTitle(R.string.share_link_title);
+
+        Dialog d = builder.create();
+        return d;
+    }
+
+    @Override
+    public void onClick(DialogInterface dialog, int which) {
+
+    }
+
+    /**
+     * This interface must be implemented by activities that contain this
+     * fragment to allow an interaction in this fragment to be communicated
+     * to the activity and potentially other fragments contained in that
+     * activity.
+     * <p/>
+     * See the Android Training lesson <a href=
+     * "http://developer.android.com/training/basics/fragments/communicating.html"
+     * >Communicating with Other Fragments</a> for more information.
+     */
+    public interface OnFragmentInteractionListener {
+        // TODO: Update argument type and name
+        public void onFragmentInteraction(Uri uri);
+    }
+
+}

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

@@ -230,10 +230,15 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                 mContainerActivity.getFileOperationsHelper().shareFileWithLink(getFile());
                 return true;
             }
+            case R.id.action_share_with_users: {
+                mContainerActivity.getFileOperationsHelper().showShareFile(getFile());
+                return true;
+            }
             case R.id.action_unshare_file: {
                 mContainerActivity.getFileOperationsHelper().unshareFileWithLink(getFile());
                 return true;
             }
+
             case R.id.action_open_file_with: {
                 mContainerActivity.getFileOperationsHelper().openFile(getFile());
                 return true;
@@ -262,7 +267,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                 if (!getFile().isDown()) {  // Download the file                    
                     Log_OC.d(TAG, getFile().getRemotePath() + " : File must be downloaded");
                     ((FileDisplayActivity) mContainerActivity).startDownloadForSending(getFile());
-
                 }
                 else {
                     mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());

+ 7 - 2
src/com/owncloud/android/ui/fragment/FileFragment.java

@@ -141,9 +141,14 @@ public class FileFragment extends Fragment {
          * @param downloading   Flag signaling if the file is now downloading.
          * @param uploading     Flag signaling if the file is now uploading.
          */
-        public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading); 
+        public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading);
 
-        
+        /**
+         * Request the parent activity to show the view for sharing an {@link OCFile}.
+         *
+         * @param file      File to share
+         */
+        public void showShareFile(OCFile file);
     }
 
 }

+ 10 - 3
src/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -63,7 +63,8 @@ import java.io.File;
  *
  * TODO refactor to get rid of direct dependency on FileDisplayActivity
  */
-public class OCFileListFragment extends ExtendedListFragment implements FileActionsDialogFragment.FileActionsDialogFragmentListener {
+public class OCFileListFragment extends ExtendedListFragment
+        implements FileActionsDialogFragment.FileActionsDialogFragmentListener {
     
     private static final String TAG = OCFileListFragment.class.getSimpleName();
 
@@ -193,7 +194,8 @@ public class OCFileListFragment extends ExtendedListFragment implements FileActi
                 }
             }
 
-            FileActionsDialogFragment dialog = FileActionsDialogFragment.newInstance(menu, fileIndex, targetFile.getFileName());
+            FileActionsDialogFragment dialog = FileActionsDialogFragment.newInstance(menu,
+                    fileIndex, targetFile.getFileName());
             dialog.setTargetFragment(this, 0);
             dialog.show(getFragmentManager(), FileActionsDialogFragment.FTAG_FILE_ACTIONS);
         }
@@ -345,6 +347,10 @@ public class OCFileListFragment extends ExtendedListFragment implements FileActi
                 mContainerActivity.getFileOperationsHelper().shareFileWithLink(mTargetFile);
                 return true;
             }
+            case R.id.action_share_with_users: {
+                mContainerActivity.showShareFile(mTargetFile);
+                return true;
+            }
             case R.id.action_open_file_with: {
                 mContainerActivity.getFileOperationsHelper().openFile(mTargetFile);
                 return true;
@@ -421,7 +427,8 @@ public class OCFileListFragment extends ExtendedListFragment implements FileActi
     @Override
     public boolean onContextItemSelected (MenuItem item) {
         AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
-        boolean matched = onFileActionChosen(item.getItemId(), ((AdapterContextMenuInfo) item.getMenuInfo()).position);
+        boolean matched = onFileActionChosen(item.getItemId(),
+                ((AdapterContextMenuInfo) item.getMenuInfo()).position);
         if(!matched) {
             return super.onContextItemSelected(item);
         } else {

+ 13 - 3
src/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -26,7 +26,6 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
-import android.graphics.drawable.ColorDrawable;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Handler;
@@ -60,8 +59,8 @@ import com.owncloud.android.operations.SynchronizeFileOperation;
 import com.owncloud.android.operations.UnshareLinkOperation;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
+import com.owncloud.android.ui.dialog.ShareFileDialogFragment;
 import com.owncloud.android.ui.fragment.FileFragment;
-import com.owncloud.android.utils.DisplayUtils;
 
 
 /**
@@ -400,7 +399,18 @@ public class PreviewImageActivity extends FileActivity implements
         
     }
 
-    
+    /**
+     * Shows the share view for sharing  {@link OCFile} received as a
+     * parameter in the second fragment.
+     *
+     * @param file {@link OCFile}  File to share with
+     */
+    @Override
+    public void showShareFile(OCFile file) {
+        ShareFileDialogFragment dialog =
+                ShareFileDialogFragment.newInstance(file, getAccount());
+        dialog.show(getSupportFragmentManager(), DIALOG_SHARE_FILE);
+    }
     private void requestForDownload(OCFile file) {
         if (mDownloaderBinder == null) {
             Log_OC.d(TAG, "requestForDownload called without binder to download service");

+ 7 - 0
src/com/owncloud/android/ui/preview/PreviewImageFragment.java

@@ -289,6 +289,10 @@ public class PreviewImageFragment extends FileFragment {
                 mContainerActivity.getFileOperationsHelper().shareFileWithLink(getFile());
                 return true;
             }
+            case R.id.action_share_with_users: {
+                seeShareFile();
+                return true;
+            }
             case R.id.action_unshare_file: {
                 mContainerActivity.getFileOperationsHelper().unshareFileWithLink(getFile());
                 return true;
@@ -332,6 +336,9 @@ public class PreviewImageFragment extends FileFragment {
         mContainerActivity.showDetails(getFile());
     }
 
+    private void seeShareFile(){
+        mContainerActivity.showShareFile(getFile());
+    }
 
     @Override
     public void onResume() {

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

@@ -355,6 +355,10 @@ public class PreviewMediaFragment extends FileFragment implements
                 mContainerActivity.getFileOperationsHelper().shareFileWithLink(getFile());
                 return true;
             }
+            case R.id.action_share_with_users: {
+                seeShareFile();
+                return true;
+            }
             case R.id.action_unshare_file: {
                 stopPreview(false);
                 mContainerActivity.getFileOperationsHelper().unshareFileWithLink(getFile());
@@ -415,6 +419,10 @@ public class PreviewMediaFragment extends FileFragment implements
         mContainerActivity.showDetails(getFile());
     }
 
+    private void seeShareFile() {
+        stopPreview(false);
+        mContainerActivity.showShareFile(getFile());
+    }
 
     private void prepareVideo() {
         // create helper to get more control on the playback

+ 8 - 0
src/com/owncloud/android/ui/preview/PreviewTextFragment.java

@@ -302,6 +302,10 @@ public class PreviewTextFragment extends FileFragment {
                 mContainerActivity.getFileOperationsHelper().shareFileWithLink(getFile());
                 return true;
             }
+            case R.id.action_share_with_users: {
+                seeShareFile();
+                return true;
+            }
             case R.id.action_unshare_file: {
                 mContainerActivity.getFileOperationsHelper().unshareFileWithLink(getFile());
                 return true;
@@ -350,6 +354,10 @@ public class PreviewTextFragment extends FileFragment {
         mContainerActivity.showDetails(getFile());
     }
 
+    private void seeShareFile(){
+        mContainerActivity.showShareFile(getFile());
+    }
+
     @Override
     public void onPause() {
         Log_OC.e(TAG, "onPause");