mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
OC-3196: Rewrite according to comments in PR#420
This commit is contained in:
parent
c86d3cedec
commit
517bde6aae
2 changed files with 45 additions and 48 deletions
|
@ -111,12 +111,21 @@ public class ShareLinkToDialog extends SherlockDialogFragment {
|
|||
Collections.sort(activities, new ResolveInfo.DisplayNameComparator(pm));
|
||||
mAdapter = new ActivityAdapter(getSherlockActivity(), pm, activities);
|
||||
|
||||
return createSelector(sendAction);
|
||||
|
||||
}
|
||||
|
||||
private AlertDialog createSelector(final boolean sendAction) {
|
||||
|
||||
int titleId;
|
||||
if (sendAction) {
|
||||
titleId = R.string.activity_chooser_send_file_title;
|
||||
} else {
|
||||
titleId = R.string.activity_chooser_title;
|
||||
}
|
||||
|
||||
return new AlertDialog.Builder(getSherlockActivity())
|
||||
.setTitle(R.string.activity_chooser_send_file_title)
|
||||
.setTitle(titleId)
|
||||
.setAdapter(mAdapter, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
@ -126,36 +135,21 @@ public class ShareLinkToDialog extends SherlockDialogFragment {
|
|||
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);
|
||||
|
||||
}
|
||||
})
|
||||
.create();
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ActivityAdapter extends ArrayAdapter<ResolveInfo> {
|
||||
|
||||
|
|
|
@ -256,12 +256,15 @@ public class FileDetailFragment extends FileFragment implements
|
|||
// Send file
|
||||
item = menu.findItem(R.id.action_send_file);
|
||||
boolean sendEnabled = getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on");
|
||||
if (item != null && sendEnabled) {
|
||||
if (item != null) {
|
||||
if (sendEnabled) {
|
||||
item.setVisible(true);
|
||||
item.setEnabled(true);
|
||||
} else {
|
||||
item.setVisible(false);
|
||||
item.setEnabled(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue