X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/e183acd650b86e3c2f90f2adedffc71499537f64..cbdcf7d4572d90a76a4042ce6dbb3552e46b5fd0:/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java diff --git a/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java b/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java index 68e1485b..3076e27e 100644 --- a/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java +++ b/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java @@ -97,58 +97,59 @@ public class ShareLinkToDialog extends SherlockDialogFragment { } } - // add activity for copy to clipboard - Intent copyToClipboardIntent = new Intent(getSherlockActivity(), CopyToClipboardActivity.class); - List copyToClipboard = pm.queryIntentActivities(copyToClipboardIntent, 0); - if (!copyToClipboard.isEmpty()) { - activities.add(copyToClipboard.get(0)); + boolean sendAction = mIntent.getBooleanExtra(Intent.ACTION_SEND, false); + + if (!sendAction) { + // add activity for copy to clipboard + Intent copyToClipboardIntent = new Intent(getSherlockActivity(), CopyToClipboardActivity.class); + List copyToClipboard = pm.queryIntentActivities(copyToClipboardIntent, 0); + if (!copyToClipboard.isEmpty()) { + activities.add(copyToClipboard.get(0)); + } } Collections.sort(activities, new ResolveInfo.DisplayNameComparator(pm)); mAdapter = new ActivityAdapter(getSherlockActivity(), pm, activities); - boolean sendAction = mIntent.getBooleanExtra(Intent.ACTION_SEND, false); + return createSelector(sendAction); - if (sendAction) { - - return new AlertDialog.Builder(getSherlockActivity()) - .setTitle(R.string.activity_chooser_send_file_title) - .setAdapter(mAdapter, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // Add the information of the chosen activity to the intent to send - ResolveInfo chosen = mAdapter.getItem(which); - ActivityInfo actInfo = chosen.activityInfo; - ComponentName name=new ComponentName(actInfo.applicationInfo.packageName, actInfo.name); - mIntent.setComponent(name); - - // Send the file - ((FileActivity)getSherlockActivity()).startActivity(mIntent); + } - } - }) - .create(); + private AlertDialog createSelector(final boolean sendAction) { + + int titleId; + if (sendAction) { + titleId = R.string.activity_chooser_send_file_title; } else { - return new AlertDialog.Builder(getSherlockActivity()) - .setTitle(R.string.activity_chooser_title) - .setAdapter(mAdapter, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // Add the information of the chosen activity to the intent to send - ResolveInfo chosen = mAdapter.getItem(which); - ActivityInfo actInfo = chosen.activityInfo; - ComponentName name=new ComponentName(actInfo.applicationInfo.packageName, actInfo.name); - mIntent.setComponent(name); - - // Create a new share resource - FileOperationsHelper foh = new FileOperationsHelper(); - foh.shareFileWithLinkToApp(mFile, mIntent, (FileActivity)getSherlockActivity()); - } - }) - .create(); + titleId = R.string.activity_chooser_title; } - } + + return new AlertDialog.Builder(getSherlockActivity()) + .setTitle(titleId) + .setAdapter(mAdapter, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // Add the information of the chosen activity to the intent to send + ResolveInfo chosen = mAdapter.getItem(which); + ActivityInfo actInfo = chosen.activityInfo; + ComponentName name=new ComponentName(actInfo.applicationInfo.packageName, actInfo.name); + mIntent.setComponent(name); + if (sendAction) { + dialog.dismiss(); // explicitly added for Android 2.x devices + + // Send the file + ((FileActivity)getSherlockActivity()).startActivity(mIntent); + + } else { + // Create a new share resource + FileOperationsHelper foh = new FileOperationsHelper(); + foh.shareFileWithLinkToApp(mFile, mIntent, (FileActivity)getSherlockActivity()); + } + } + }) + .create(); + } class ActivityAdapter extends ArrayAdapter {