|
|
|
@ -8,11 +8,9 @@ package com.todoroo.astrid.files;
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.content.ActivityNotFoundException;
|
|
|
|
import android.content.ActivityNotFoundException;
|
|
|
|
import android.content.ClipData;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.media.MediaPlayer;
|
|
|
|
import android.media.MediaPlayer;
|
|
|
|
import android.net.Uri;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
@ -33,6 +31,7 @@ import com.todoroo.astrid.data.TaskAttachment;
|
|
|
|
import org.tasks.R;
|
|
|
|
import org.tasks.R;
|
|
|
|
import org.tasks.activities.AddAttachmentActivity;
|
|
|
|
import org.tasks.activities.AddAttachmentActivity;
|
|
|
|
import org.tasks.dialogs.DialogBuilder;
|
|
|
|
import org.tasks.dialogs.DialogBuilder;
|
|
|
|
|
|
|
|
import org.tasks.files.FileHelper;
|
|
|
|
import org.tasks.injection.ForActivity;
|
|
|
|
import org.tasks.injection.ForActivity;
|
|
|
|
import org.tasks.injection.FragmentComponent;
|
|
|
|
import org.tasks.injection.FragmentComponent;
|
|
|
|
import org.tasks.ui.TaskEditControlFragment;
|
|
|
|
import org.tasks.ui.TaskEditControlFragment;
|
|
|
|
@ -47,8 +46,6 @@ import butterknife.BindView;
|
|
|
|
import butterknife.OnClick;
|
|
|
|
import butterknife.OnClick;
|
|
|
|
import timber.log.Timber;
|
|
|
|
import timber.log.Timber;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastLollipop;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class FilesControlSet extends TaskEditControlFragment {
|
|
|
|
public class FilesControlSet extends TaskEditControlFragment {
|
|
|
|
|
|
|
|
|
|
|
|
public static final int TAG = R.string.TEA_ctrl_files_pref;
|
|
|
|
public static final int TAG = R.string.TEA_ctrl_files_pref;
|
|
|
|
@ -212,14 +209,7 @@ public class FilesControlSet extends TaskEditControlFragment {
|
|
|
|
play(m.getFilePath(), () -> showFromIntent(filePath, fileType));
|
|
|
|
play(m.getFilePath(), () -> showFromIntent(filePath, fileType));
|
|
|
|
} else if (fileType.startsWith(TaskAttachment.FILE_TYPE_IMAGE)) {
|
|
|
|
} else if (fileType.startsWith(TaskAttachment.FILE_TYPE_IMAGE)) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
|
Intent intent = FileHelper.getReadableActionView(context, filePath, TaskAttachment.FILE_TYPE_IMAGE + "*");
|
|
|
|
Uri uri = Uri.fromFile(new File(filePath));
|
|
|
|
|
|
|
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
|
|
|
|
|
intent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
|
|
|
|
|
|
|
intent.setDataAndType(uri, TaskAttachment.FILE_TYPE_IMAGE + "*");
|
|
|
|
|
|
|
|
if (atLeastLollipop()) {
|
|
|
|
|
|
|
|
intent.setClipData(ClipData.newRawUri(null, uri));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getActivity().startActivity(intent);
|
|
|
|
getActivity().startActivity(intent);
|
|
|
|
} catch(ActivityNotFoundException e) {
|
|
|
|
} catch(ActivityNotFoundException e) {
|
|
|
|
Timber.e(e, e.getMessage());
|
|
|
|
Timber.e(e, e.getMessage());
|
|
|
|
@ -247,9 +237,7 @@ public class FilesControlSet extends TaskEditControlFragment {
|
|
|
|
|
|
|
|
|
|
|
|
private void showFromIntent(String file, String type) {
|
|
|
|
private void showFromIntent(String file, String type) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
|
Intent intent = FileHelper.getReadableActionView(context, file, type);
|
|
|
|
intent.setDataAndType(Uri.fromFile(new File(file)), type);
|
|
|
|
|
|
|
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
|
|
|
|
|
|
|
getActivity().startActivity(intent);
|
|
|
|
getActivity().startActivity(intent);
|
|
|
|
} catch (ActivityNotFoundException e) {
|
|
|
|
} catch (ActivityNotFoundException e) {
|
|
|
|
Timber.e(e, e.getMessage());
|
|
|
|
Timber.e(e, e.getMessage());
|
|
|
|
|