mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-22 12:21:29 +00:00
Make save attachment task toast location instead of snackbar
This commit is contained in:
parent
f100137e0f
commit
f315b1db80
@ -1,4 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<paths>
|
<paths>
|
||||||
<external-cache-path name="external_cache" path="." />
|
<external-cache-path name="external_cache" path="." />
|
||||||
|
|
||||||
|
<external-path name="external_pictures" path="Pictures"/>
|
||||||
|
<external-path name="external_video" path="Movies"/>
|
||||||
|
<external-path name="external_audio" path="Music"/>
|
||||||
|
<external-path name="external_download" path="Download"/>
|
||||||
</paths>
|
</paths>
|
@ -1,5 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
@ -24,6 +25,7 @@ import java.lang.ref.WeakReference;
|
|||||||
|
|
||||||
public class ConversationTitleView extends RelativeLayout {
|
public class ConversationTitleView extends RelativeLayout {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static final String TAG = ConversationTitleView.class.getSimpleName();
|
private static final String TAG = ConversationTitleView.class.getSimpleName();
|
||||||
|
|
||||||
private View content;
|
private View content;
|
||||||
@ -118,6 +120,7 @@ public class ConversationTitleView extends RelativeLayout {
|
|||||||
this.subtitle.setVisibility(View.VISIBLE);
|
this.subtitle.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
private void setNonContactRecipientTitle(Recipient recipient) {
|
private void setNonContactRecipientTitle(Recipient recipient) {
|
||||||
this.title.setText(recipient.getAddress().serialize());
|
this.title.setText(recipient.getAddress().serialize());
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ import java.io.OutputStream;
|
|||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTask.Attachment, Void, Pair<Integer, File>> {
|
public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTask.Attachment, Void, Pair<Integer, String>> {
|
||||||
private static final String TAG = SaveAttachmentTask.class.getSimpleName();
|
private static final String TAG = SaveAttachmentTask.class.getSimpleName();
|
||||||
|
|
||||||
protected static final int SUCCESS = 0;
|
protected static final int SUCCESS = 0;
|
||||||
@ -57,7 +57,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<Integer, File> doInBackground(SaveAttachmentTask.Attachment... attachments) {
|
protected Pair<Integer, String> doInBackground(SaveAttachmentTask.Attachment... attachments) {
|
||||||
if (attachments == null || attachments.length == 0) {
|
if (attachments == null || attachments.length == 0) {
|
||||||
throw new AssertionError("must pass in at least one attachment");
|
throw new AssertionError("must pass in at least one attachment");
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
|||||||
try {
|
try {
|
||||||
Context context = contextReference.get();
|
Context context = contextReference.get();
|
||||||
MasterSecret masterSecret = masterSecretReference.get();
|
MasterSecret masterSecret = masterSecretReference.get();
|
||||||
File directory = null;
|
String directory = null;
|
||||||
|
|
||||||
if (!StorageUtil.canWriteInSignalStorageDir()) {
|
if (!StorageUtil.canWriteInSignalStorageDir()) {
|
||||||
return new Pair<>(WRITE_ACCESS_FAILURE, null);
|
return new Pair<>(WRITE_ACCESS_FAILURE, null);
|
||||||
@ -90,7 +90,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable File saveAttachment(Context context, MasterSecret masterSecret, Attachment attachment)
|
private @Nullable String saveAttachment(Context context, MasterSecret masterSecret, Attachment attachment)
|
||||||
throws NoExternalStorageException, IOException
|
throws NoExternalStorageException, IOException
|
||||||
{
|
{
|
||||||
String contentType = MediaUtil.getCorrectedMimeType(attachment.contentType);
|
String contentType = MediaUtil.getCorrectedMimeType(attachment.contentType);
|
||||||
@ -113,7 +113,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
|||||||
MediaScannerConnection.scanFile(context, new String[]{mediaFile.getAbsolutePath()},
|
MediaScannerConnection.scanFile(context, new String[]{mediaFile.getAbsolutePath()},
|
||||||
new String[]{contentType}, null);
|
new String[]{contentType}, null);
|
||||||
|
|
||||||
return mediaFile.getParentFile();
|
return outputDirectory.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private File createOutputDirectoryFromContentType(@NonNull String contentType)
|
private File createOutputDirectoryFromContentType(@NonNull String contentType)
|
||||||
@ -184,7 +184,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(final Pair<Integer, File> result) {
|
protected void onPostExecute(final Pair<Integer, String> result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
final Context context = contextReference.get();
|
final Context context = contextReference.get();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
@ -197,26 +197,7 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
|||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
break;
|
break;
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
Snackbar snackbar = Snackbar.make(view.get(),
|
Toast.makeText(context, String.format("Saved to %s", result.second()), Toast.LENGTH_LONG).show();
|
||||||
context.getResources().getQuantityText(R.plurals.ConversationFragment_files_saved_successfully, attachmentCount),
|
|
||||||
Snackbar.LENGTH_SHORT);
|
|
||||||
|
|
||||||
if (result.second() != null) {
|
|
||||||
snackbar.setDuration(Snackbar.LENGTH_LONG);
|
|
||||||
snackbar.setAction(R.string.SaveAttachmentTask_open_directory, new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
||||||
intent.setDataAndType(Uri.fromFile(result.second()), "resource/folder");
|
|
||||||
if (intent.resolveActivityInfo(context.getPackageManager(), 0) != null)
|
|
||||||
{
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
snackbar.show();
|
|
||||||
break;
|
break;
|
||||||
case WRITE_ACCESS_FAILURE:
|
case WRITE_ACCESS_FAILURE:
|
||||||
Toast.makeText(context, R.string.ConversationFragment_unable_to_write_to_sd_card_exclamation,
|
Toast.makeText(context, R.string.ConversationFragment_unable_to_write_to_sd_card_exclamation,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user