|
|
|
@ -84,6 +84,7 @@ import android.widget.FilterQueryProvider;
|
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
import android.widget.MultiAutoCompleteTextView;
|
|
|
|
|
import android.widget.RadioGroup;
|
|
|
|
|
import android.widget.Spinner;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
@ -252,8 +253,8 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
private long[] pgpKeyIds;
|
|
|
|
|
private long pgpSignKeyId;
|
|
|
|
|
|
|
|
|
|
static final int REDUCED_IMAGE_SIZE = 1440; // pixels
|
|
|
|
|
static final int REDUCED_IMAGE_QUALITY = 90; // percent
|
|
|
|
|
private static final int REDUCED_IMAGE_SIZE = 1440; // pixels
|
|
|
|
|
private static final int REDUCED_IMAGE_QUALITY = 90; // percent
|
|
|
|
|
|
|
|
|
|
private static final int ADDRESS_ELLIPSIZE = 50;
|
|
|
|
|
private static final int RECIPIENTS_WARNING = 10;
|
|
|
|
@ -262,17 +263,18 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
private static final int REQUEST_CONTACT_CC = 2;
|
|
|
|
|
private static final int REQUEST_CONTACT_BCC = 3;
|
|
|
|
|
private static final int REQUEST_IMAGE = 4;
|
|
|
|
|
private static final int REQUEST_ATTACHMENT = 5;
|
|
|
|
|
private static final int REQUEST_TAKE_PHOTO = 6;
|
|
|
|
|
private static final int REQUEST_RECORD_AUDIO = 7;
|
|
|
|
|
private static final int REQUEST_OPENPGP = 8;
|
|
|
|
|
private static final int REQUEST_COLOR = 9;
|
|
|
|
|
private static final int REQUEST_CONTACT_GROUP = 10;
|
|
|
|
|
private static final int REQUEST_ANSWER = 11;
|
|
|
|
|
private static final int REQUEST_LINK = 12;
|
|
|
|
|
private static final int REQUEST_DISCARD = 13;
|
|
|
|
|
private static final int REQUEST_SEND = 14;
|
|
|
|
|
private static final int REQUEST_CERTIFICATE = 15;
|
|
|
|
|
private static final int REQUEST_IMAGE_FILE = 5;
|
|
|
|
|
private static final int REQUEST_ATTACHMENT = 6;
|
|
|
|
|
private static final int REQUEST_TAKE_PHOTO = 7;
|
|
|
|
|
private static final int REQUEST_RECORD_AUDIO = 8;
|
|
|
|
|
private static final int REQUEST_OPENPGP = 9;
|
|
|
|
|
private static final int REQUEST_COLOR = 10;
|
|
|
|
|
private static final int REQUEST_CONTACT_GROUP = 11;
|
|
|
|
|
private static final int REQUEST_ANSWER = 12;
|
|
|
|
|
private static final int REQUEST_LINK = 13;
|
|
|
|
|
private static final int REQUEST_DISCARD = 14;
|
|
|
|
|
private static final int REQUEST_SEND = 15;
|
|
|
|
|
private static final int REQUEST_CERTIFICATE = 16;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
@ -456,7 +458,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
etBody.setInputContentListener(new EditTextCompose.IInputContentListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onInputContent(Uri uri) {
|
|
|
|
|
onAddAttachment(uri, true);
|
|
|
|
|
onAddAttachment(uri, true, 0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -602,10 +604,10 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
onActionRecordAudio();
|
|
|
|
|
return true;
|
|
|
|
|
case R.id.menu_take_photo:
|
|
|
|
|
onActionTakePhoto();
|
|
|
|
|
onActionImage(true);
|
|
|
|
|
return true;
|
|
|
|
|
case R.id.menu_image:
|
|
|
|
|
onActionImage();
|
|
|
|
|
onActionImage(false);
|
|
|
|
|
return true;
|
|
|
|
|
case R.id.menu_attachment:
|
|
|
|
|
onActionAttachment();
|
|
|
|
@ -1348,45 +1350,13 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onActionTakePhoto() {
|
|
|
|
|
// https://developer.android.com/training/camera/photobasics
|
|
|
|
|
PackageManager pm = getContext().getPackageManager();
|
|
|
|
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
|
|
|
if (intent.resolveActivity(pm) == null) {
|
|
|
|
|
Snackbar snackbar = Snackbar.make(view, getString(R.string.title_no_camera), Snackbar.LENGTH_LONG);
|
|
|
|
|
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Helper.view(getContext(), Uri.parse(BuildConfig.CAMERA_URI), false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
snackbar.show();
|
|
|
|
|
} else {
|
|
|
|
|
File dir = new File(getContext().getCacheDir(), "photo");
|
|
|
|
|
if (!dir.exists())
|
|
|
|
|
dir.mkdir();
|
|
|
|
|
File file = new File(dir, working + ".jpg");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
photoURI = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID, file);
|
|
|
|
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
|
|
|
|
startActivityForResult(intent, REQUEST_TAKE_PHOTO);
|
|
|
|
|
} catch (SecurityException ex) {
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
Snackbar.make(view, getString(R.string.title_no_viewer, intent.getAction()), Snackbar.LENGTH_LONG).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onActionImage() {
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
|
intent.setType("image/*");
|
|
|
|
|
PackageManager pm = getContext().getPackageManager();
|
|
|
|
|
if (intent.resolveActivity(pm) == null)
|
|
|
|
|
noStorageAccessFramework();
|
|
|
|
|
else
|
|
|
|
|
startActivityForResult(Helper.getChooser(getContext(), intent), REQUEST_IMAGE);
|
|
|
|
|
private void onActionImage(boolean photo) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putBoolean("photo", photo);
|
|
|
|
|
FragmentDialogAddImage fragment = new FragmentDialogAddImage();
|
|
|
|
|
fragment.setArguments(args);
|
|
|
|
|
fragment.setTargetFragment(this, REQUEST_IMAGE);
|
|
|
|
|
fragment.show(getParentFragmentManager(), "compose:image");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onActionAttachment() {
|
|
|
|
@ -1574,20 +1544,21 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
onPickContact(requestCode, data);
|
|
|
|
|
break;
|
|
|
|
|
case REQUEST_IMAGE:
|
|
|
|
|
if (resultCode == RESULT_OK)
|
|
|
|
|
onAddImage(data.getBundleExtra("args").getBoolean("photo"));
|
|
|
|
|
break;
|
|
|
|
|
case REQUEST_IMAGE_FILE:
|
|
|
|
|
case REQUEST_TAKE_PHOTO:
|
|
|
|
|
if (resultCode == RESULT_OK && data != null) {
|
|
|
|
|
Uri uri = data.getData();
|
|
|
|
|
Uri uri = (requestCode == REQUEST_TAKE_PHOTO ? photoURI : data.getData());
|
|
|
|
|
if (uri != null)
|
|
|
|
|
onAddAttachment(uri, true);
|
|
|
|
|
onAddImageFile(uri);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case REQUEST_ATTACHMENT:
|
|
|
|
|
case REQUEST_RECORD_AUDIO:
|
|
|
|
|
case REQUEST_TAKE_PHOTO:
|
|
|
|
|
if (resultCode == RESULT_OK)
|
|
|
|
|
if (requestCode == REQUEST_TAKE_PHOTO)
|
|
|
|
|
onAddMedia(new Intent().setData(photoURI));
|
|
|
|
|
else if (data != null)
|
|
|
|
|
onAddMedia(data);
|
|
|
|
|
if (resultCode == RESULT_OK && data != null)
|
|
|
|
|
onAddMedia(data);
|
|
|
|
|
break;
|
|
|
|
|
case REQUEST_OPENPGP:
|
|
|
|
|
if (resultCode == RESULT_OK && data != null)
|
|
|
|
@ -1718,11 +1689,60 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
}.execute(this, args, "compose:picked");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onAddAttachment(Uri uri, boolean image) {
|
|
|
|
|
private void onAddImage(boolean photo) {
|
|
|
|
|
if (photo) {
|
|
|
|
|
// https://developer.android.com/training/camera/photobasics
|
|
|
|
|
PackageManager pm = getContext().getPackageManager();
|
|
|
|
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
|
|
|
if (intent.resolveActivity(pm) == null) {
|
|
|
|
|
Snackbar snackbar = Snackbar.make(view, getString(R.string.title_no_camera), Snackbar.LENGTH_LONG);
|
|
|
|
|
snackbar.setAction(R.string.title_fix, new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Helper.view(getContext(), Uri.parse(BuildConfig.CAMERA_URI), false);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
snackbar.show();
|
|
|
|
|
} else {
|
|
|
|
|
File dir = new File(getContext().getCacheDir(), "photo");
|
|
|
|
|
if (!dir.exists())
|
|
|
|
|
dir.mkdir();
|
|
|
|
|
File file = new File(dir, working + ".jpg");
|
|
|
|
|
try {
|
|
|
|
|
photoURI = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID, file);
|
|
|
|
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
|
|
|
|
startActivityForResult(intent, REQUEST_TAKE_PHOTO);
|
|
|
|
|
} catch (SecurityException ex) {
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
Snackbar.make(view, getString(R.string.title_no_viewer, intent.getAction()), Snackbar.LENGTH_LONG).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
|
intent.setType("image/*");
|
|
|
|
|
PackageManager pm = getContext().getPackageManager();
|
|
|
|
|
if (intent.resolveActivity(pm) == null)
|
|
|
|
|
noStorageAccessFramework();
|
|
|
|
|
else
|
|
|
|
|
startActivityForResult(Helper.getChooser(getContext(), intent), REQUEST_IMAGE_FILE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onAddImageFile(Uri uri) {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
boolean add_inline = prefs.getBoolean("add_inline", true);
|
|
|
|
|
boolean resize_images = prefs.getBoolean("resize_images", true);
|
|
|
|
|
int resize = prefs.getInt("resize", FragmentCompose.REDUCED_IMAGE_SIZE);
|
|
|
|
|
onAddAttachment(uri, add_inline, resize_images ? resize : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onAddAttachment(Uri uri, boolean image, int resize) {
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", working);
|
|
|
|
|
args.putParcelable("uri", uri);
|
|
|
|
|
args.putBoolean("image", image);
|
|
|
|
|
args.putInt("resize", resize);
|
|
|
|
|
args.putCharSequence("body", etBody.getText());
|
|
|
|
|
args.putInt("start", etBody.getSelectionStart());
|
|
|
|
|
|
|
|
|
@ -1732,8 +1752,9 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
Uri uri = args.getParcelable("uri");
|
|
|
|
|
boolean image = args.getBoolean("image");
|
|
|
|
|
int resize = args.getInt("resize");
|
|
|
|
|
|
|
|
|
|
EntityAttachment attachment = addAttachment(context, id, uri, image);
|
|
|
|
|
EntityAttachment attachment = addAttachment(context, id, uri, image, resize);
|
|
|
|
|
if (!image)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
@ -1796,13 +1817,13 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
if (clipData == null) {
|
|
|
|
|
Uri uri = data.getData();
|
|
|
|
|
if (uri != null)
|
|
|
|
|
onAddAttachment(uri, false);
|
|
|
|
|
onAddAttachment(uri, false, 0);
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < clipData.getItemCount(); i++) {
|
|
|
|
|
ClipData.Item item = clipData.getItemAt(i);
|
|
|
|
|
Uri uri = item.getUri();
|
|
|
|
|
if (uri != null)
|
|
|
|
|
onAddAttachment(uri, false);
|
|
|
|
|
onAddAttachment(uri, false, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2564,9 +2585,9 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
actionLoader.execute(this, args, "compose:action:" + action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static EntityAttachment addAttachment(Context context, long id, Uri uri,
|
|
|
|
|
boolean image) throws IOException {
|
|
|
|
|
Log.w("Add attachment uri=" + uri);
|
|
|
|
|
private static EntityAttachment addAttachment(
|
|
|
|
|
Context context, long id, Uri uri, boolean image, int resize) throws IOException {
|
|
|
|
|
Log.w("Add attachment uri=" + uri + " image=" + image + " resize=" + resize);
|
|
|
|
|
|
|
|
|
|
if (!"content".equals(uri.getScheme()) &&
|
|
|
|
|
!Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
|
|
|
|
@ -2684,7 +2705,8 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
} else
|
|
|
|
|
Log.i("Authority=" + uri.getAuthority());
|
|
|
|
|
|
|
|
|
|
resizeAttachment(context, attachment);
|
|
|
|
|
if (resize > 0)
|
|
|
|
|
resizeAttachment(context, attachment, resize);
|
|
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
// Reset progress on failure
|
|
|
|
@ -2696,23 +2718,14 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
return attachment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void resizeAttachment(Context context, EntityAttachment attachment) throws IOException {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
boolean resize_images = prefs.getBoolean("resize_images", true);
|
|
|
|
|
boolean resize_attachments = prefs.getBoolean("resize_attachments", true);
|
|
|
|
|
|
|
|
|
|
private static void resizeAttachment(Context context, EntityAttachment attachment, int resize) throws IOException {
|
|
|
|
|
File file = attachment.getFile(context);
|
|
|
|
|
|
|
|
|
|
if (((resize_images && Part.INLINE.equals(attachment.disposition)) ||
|
|
|
|
|
(resize_attachments && Part.ATTACHMENT.equals(attachment.disposition))) &&
|
|
|
|
|
file.exists() /* upload cancelled */ &&
|
|
|
|
|
if (file.exists() /* upload cancelled */ &&
|
|
|
|
|
("image/jpeg".equals(attachment.type) || "image/png".equals(attachment.type))) {
|
|
|
|
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
|
|
options.inJustDecodeBounds = true;
|
|
|
|
|
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
|
|
|
|
|
|
|
|
|
|
int resize = prefs.getInt("resize", REDUCED_IMAGE_SIZE);
|
|
|
|
|
|
|
|
|
|
int factor = 1;
|
|
|
|
|
while (options.outWidth / factor > resize ||
|
|
|
|
|
options.outHeight / factor > resize)
|
|
|
|
@ -2767,6 +2780,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
boolean plain_only = prefs.getBoolean("plain_only", false);
|
|
|
|
|
boolean resize_reply = prefs.getBoolean("resize_reply", true);
|
|
|
|
|
String encrypt_method = prefs.getString("default_encrypt_method", "pgp");
|
|
|
|
|
boolean sign_default = prefs.getBoolean("sign_default", false);
|
|
|
|
|
boolean encrypt_default = prefs.getBoolean("encrypt_default", false);
|
|
|
|
@ -3287,7 +3301,7 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
if (uris != null)
|
|
|
|
|
for (Uri uri : uris)
|
|
|
|
|
try {
|
|
|
|
|
addAttachment(context, data.draft.id, uri, false);
|
|
|
|
|
addAttachment(context, data.draft.id, uri, false, 0);
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
}
|
|
|
|
@ -3323,8 +3337,8 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
File target = attachment.getFile(context);
|
|
|
|
|
Helper.copy(source, target);
|
|
|
|
|
|
|
|
|
|
if (!"forward".equals(action))
|
|
|
|
|
resizeAttachment(context, attachment);
|
|
|
|
|
if (resize_reply && !"forward".equals(action))
|
|
|
|
|
resizeAttachment(context, attachment, REDUCED_IMAGE_SIZE);
|
|
|
|
|
} else
|
|
|
|
|
args.putBoolean("incomplete", true);
|
|
|
|
|
}
|
|
|
|
@ -4426,13 +4440,118 @@ public class FragmentCompose extends FragmentBase {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class FragmentDialogSend extends FragmentDialogBase {
|
|
|
|
|
public static class FragmentDialogAddImage extends FragmentDialogBase {
|
|
|
|
|
@NonNull
|
|
|
|
|
@Override
|
|
|
|
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
long id = getArguments().getLong("id");
|
|
|
|
|
final boolean photo = getArguments().getBoolean("photo");
|
|
|
|
|
|
|
|
|
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
|
|
|
|
boolean add_inline = prefs.getBoolean("add_inline", true);
|
|
|
|
|
boolean resize_images = prefs.getBoolean("resize_images", true);
|
|
|
|
|
int resize = prefs.getInt("resize", FragmentCompose.REDUCED_IMAGE_SIZE);
|
|
|
|
|
|
|
|
|
|
final ViewGroup dview = (ViewGroup) LayoutInflater.from(getContext()).inflate(R.layout.dialog_add_image, null);
|
|
|
|
|
final RadioGroup rgAction = dview.findViewById(R.id.rgAction);
|
|
|
|
|
final CheckBox cbResize = dview.findViewById(R.id.cbResize);
|
|
|
|
|
final Spinner spResize = dview.findViewById(R.id.spResize);
|
|
|
|
|
final TextView tvResize = dview.findViewById(R.id.tvResize);
|
|
|
|
|
|
|
|
|
|
rgAction.check(add_inline ? R.id.rbInline : R.id.rbAttach);
|
|
|
|
|
cbResize.setChecked(resize_images);
|
|
|
|
|
spResize.setEnabled(resize_images);
|
|
|
|
|
|
|
|
|
|
final int[] resizeValues = getResources().getIntArray(R.array.resizeValues);
|
|
|
|
|
for (int pos = 0; pos < resizeValues.length; pos++)
|
|
|
|
|
if (resizeValues[pos] == resize) {
|
|
|
|
|
spResize.setSelection(pos);
|
|
|
|
|
tvResize.setText(getString(R.string.title_add_resize_pixels, resizeValues[pos]));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rgAction.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
|
|
prefs.edit().putBoolean("add_inline", checkedId == R.id.rbInline).apply();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cbResize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
|
prefs.edit().putBoolean("resize_images", isChecked).apply();
|
|
|
|
|
spResize.setEnabled(isChecked);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
spResize.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
|
|
|
|
|
prefs.edit().putInt("resize", resizeValues[position]).apply();
|
|
|
|
|
tvResize.setText(getString(R.string.title_add_resize_pixels, resizeValues[position]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
|
|
|
|
prefs.edit().remove("resize").apply();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return new AlertDialog.Builder(getContext())
|
|
|
|
|
.setView(dview)
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
.setPositiveButton(
|
|
|
|
|
photo ? R.string.title_attachment_photo : R.string.title_add_image_select,
|
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
sendResult(RESULT_OK);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent intent) {
|
|
|
|
|
super.onActivityResult(requestCode, resultCode, intent);
|
|
|
|
|
|
|
|
|
|
if (resultCode == RESULT_OK && intent != null) {
|
|
|
|
|
Bundle data = intent.getBundleExtra("args");
|
|
|
|
|
long id = data.getLong("id");
|
|
|
|
|
long duration = data.getLong("duration");
|
|
|
|
|
long time = data.getLong("time");
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("id", id);
|
|
|
|
|
args.putLong("wakeup", duration == 0 ? -1 : time);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<Void>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected Void onExecute(Context context, Bundle args) {
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
long wakeup = args.getLong("wakeup");
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
db.message().setMessageSnoozed(id, wakeup < 0 ? null : wakeup);
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onException(Bundle args, Throwable ex) {
|
|
|
|
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
|
|
|
|
}
|
|
|
|
|
}.execute(this, args, "compose:snooze");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class FragmentDialogSend extends FragmentDialogBase {
|
|
|
|
|
@NonNull
|
|
|
|
|
@Override
|
|
|
|
|
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
Bundle args = getArguments();
|
|
|
|
|
long id = args.getLong("id");
|
|
|
|
|
boolean dialog = args.getBundle("extras").getBoolean("dialog");
|
|
|
|
|
boolean remind_to = args.getBoolean("remind_to", false);
|
|
|
|
|
boolean remind_extra = args.getBoolean("remind_extra", false);
|
|
|
|
|