Merge pull request #311 from tobiasKaminsky/develop

Added support for sharing files:
This commit is contained in:
masensio 2014-02-14 14:59:24 +01:00
commit 7ead9a0fe4
9 changed files with 30 additions and 3 deletions

View file

@ -29,5 +29,6 @@
<item android:id="@+id/action_rename_file" android:title="@string/common_rename" android:icon="@android:drawable/ic_menu_set_as" android:orderInCategory="1" />
<item android:id="@+id/action_remove_file" android:title="@string/common_remove" android:icon="@android:drawable/ic_menu_delete" android:orderInCategory="1" />
<item android:id="@+id/action_see_details" android:title="@string/actionbar_see_details" android:icon="@android:drawable/ic_menu_info_details" android:orderInCategory="1" />
<item android:id="@+id/action_share_file" android:title="@string/actionbar_share_file" android:icon="@android:drawable/ic_menu_info_details" android:orderInCategory="1" />
</menu>

View file

@ -10,6 +10,7 @@
<string name="actionbar_mkdir">Ordner anlegen</string>
<string name="actionbar_settings">Einstellungen</string>
<string name="actionbar_see_details">Details</string>
<string name="actionbar_share_file">Teile Datei</string>
<string name="prefs_category_general">Allgemein</string>
<string name="prefs_category_more">Mehr</string>
<string name="prefs_accounts">Konten</string>

View file

@ -10,6 +10,7 @@
<string name="actionbar_mkdir">Ordner anlegen</string>
<string name="actionbar_settings">Einstellungen</string>
<string name="actionbar_see_details">Details</string>
<string name="actionbar_share_file">Teile Datei</string>
<string name="prefs_category_general">Allgemein</string>
<string name="prefs_category_more">Mehr</string>
<string name="prefs_accounts">Konten</string>

View file

@ -10,6 +10,7 @@
<string name="actionbar_mkdir">Ordner anlegen</string>
<string name="actionbar_settings">Einstellungen</string>
<string name="actionbar_see_details">Details</string>
<string name="actionbar_share_file">Teile Datei</string>
<string name="prefs_category_general">Allgemein</string>
<string name="prefs_category_more">Mehr</string>
<string name="prefs_accounts">Konten</string>

View file

@ -10,6 +10,7 @@
<string name="actionbar_mkdir">Create directory</string>
<string name="actionbar_settings">Settings</string>
<string name="actionbar_see_details">Details</string>
<string name="actionbar_share_file">Share</string>
<string name="prefs_category_general">General</string>
<string name="prefs_category_more">More</string>
<string name="prefs_accounts">Accounts</string>

View file

@ -11,7 +11,7 @@
<string name="actionbar_mkdir">Create directory</string>
<string name="actionbar_settings">Settings</string>
<string name="actionbar_see_details">Details</string>
<string name="actionbar_share_file">Share</string>
<string name="prefs_category_general">General</string>
<string name="prefs_category_more">More</string>
<string name="prefs_accounts">Accounts</string>

View file

@ -59,7 +59,7 @@
</style>
<!-- Dialogs -->
<style name="Theme.ownCloud.Dialog" parent="style/Theme.Sherlock.Light.Dialog">
<style name="Theme.ownCloud.Dialog" parent="@android:style/Theme.Dialog">
</style>
<!-- PopDownMenu -->

View file

@ -42,9 +42,10 @@ import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
import com.owncloud.android.utils.Log_OC;
import android.accounts.Account;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.ContextMenu;
@ -221,6 +222,7 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
toHide.add(R.id.action_cancel_upload);
toHide.add(R.id.action_sync_file);
toHide.add(R.id.action_see_details);
toHide.add(R.id.action_share_file);
if ( mContainerActivity.getFileDownloaderBinder().isDownloading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile) ||
mContainerActivity.getFileUploaderBinder().isUploading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile) ) {
toDisable.add(R.id.action_rename_file);
@ -359,6 +361,14 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
((FileFragment.ContainerActivity)getActivity()).showDetails(mTargetFile);
return true;
}
case R.id.action_share_file: {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
// set MimeType
sharingIntent.setType(mTargetFile.getMimetype());
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+mTargetFile.getStoragePath()));
startActivity(Intent.createChooser(sharingIntent, "Share via"));
return true;
}
default:
return super.onContextItemSelected(item);
}

View file

@ -310,11 +310,23 @@ public class PreviewImageFragment extends FileFragment implements OnRemoteOper
seeDetails();
return true;
}
case R.id.action_share_file: {
shareFile();
return true;
}
default:
return false;
}
}
private void shareFile(){
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
// set MimeType
sharingIntent.setType(getFile().getMimetype());
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+getFile().getStoragePath()));
startActivity(Intent.createChooser(sharingIntent, "Share via"));
}