This commit is contained in:
parent
671957da5a
commit
bc59d4d938
|
@ -27,7 +27,6 @@ import android.content.res.AssetFileDescriptor;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.media.MediaMetadataRetriever;
|
import android.media.MediaMetadataRetriever;
|
||||||
import android.media.ThumbnailUtils;
|
import android.media.ThumbnailUtils;
|
||||||
|
@ -408,7 +407,8 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
}
|
}
|
||||||
} else if (savedMediaQueued != null) {
|
} else if (savedMediaQueued != null) {
|
||||||
for (SavedQueuedMedia item : savedMediaQueued) {
|
for (SavedQueuedMedia item : savedMediaQueued) {
|
||||||
addMediaToQueue(item.type, item.preview, item.uri, item.mediaSize);
|
Bitmap preview = getImageThumbnail(getContentResolver(), item.uri);
|
||||||
|
addMediaToQueue(item.type, preview, item.uri, item.mediaSize, item.readyStage);
|
||||||
}
|
}
|
||||||
} else if (intent != null && savedInstanceState == null) {
|
} else if (intent != null && savedInstanceState == null) {
|
||||||
/* Get incoming images being sent through a share action from another app. Only do this
|
/* Get incoming images being sent through a share action from another app. Only do this
|
||||||
|
@ -464,8 +464,8 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
ArrayList<SavedQueuedMedia> savedMediaQueued = new ArrayList<>();
|
ArrayList<SavedQueuedMedia> savedMediaQueued = new ArrayList<>();
|
||||||
for (QueuedMedia item : mediaQueued) {
|
for (QueuedMedia item : mediaQueued) {
|
||||||
savedMediaQueued.add(new SavedQueuedMedia(item.type, item.uri, item.preview,
|
savedMediaQueued.add(new SavedQueuedMedia(item.type, item.uri,
|
||||||
item.mediaSize));
|
item.mediaSize, item.readyStage));
|
||||||
}
|
}
|
||||||
outState.putParcelableArrayList("savedMediaQueued", savedMediaQueued);
|
outState.putParcelableArrayList("savedMediaQueued", savedMediaQueued);
|
||||||
outState.putBoolean("showMarkSensitive", showMarkSensitive);
|
outState.putBoolean("showMarkSensitive", showMarkSensitive);
|
||||||
|
@ -605,8 +605,12 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
File directory;
|
File directory;
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
default:
|
default:
|
||||||
case IMAGE: directory = imageDirectory; break;
|
case IMAGE:
|
||||||
case VIDEO: directory = videoDirectory; break;
|
directory = imageDirectory;
|
||||||
|
break;
|
||||||
|
case VIDEO:
|
||||||
|
directory = videoDirectory;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US)
|
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US)
|
||||||
.format(new Date());
|
.format(new Date());
|
||||||
|
@ -1145,8 +1149,9 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
R.attr.compose_media_button_disabled_tint);
|
R.attr.compose_media_button_disabled_tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMediaToQueue(QueuedMedia.Type type, Bitmap preview, Uri uri, long mediaSize) {
|
private void addMediaToQueue(QueuedMedia.Type type, Bitmap preview, Uri uri, long mediaSize, QueuedMedia.ReadyStage readyStage) {
|
||||||
final QueuedMedia item = new QueuedMedia(type, uri, new ImageView(this), mediaSize);
|
final QueuedMedia item = new QueuedMedia(type, uri, new ImageView(this), mediaSize);
|
||||||
|
item.readyStage = readyStage;
|
||||||
ImageView view = item.preview;
|
ImageView view = item.preview;
|
||||||
Resources resources = getResources();
|
Resources resources = getResources();
|
||||||
int side = resources.getDimensionPixelSize(R.dimen.compose_media_preview_side);
|
int side = resources.getDimensionPixelSize(R.dimen.compose_media_preview_side);
|
||||||
|
@ -1186,11 +1191,13 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
if (queuedCount >= 1) {
|
if (queuedCount >= 1) {
|
||||||
showMarkSensitive(true);
|
showMarkSensitive(true);
|
||||||
}
|
}
|
||||||
waitForMediaLatch.countUp();
|
if (item.readyStage != QueuedMedia.ReadyStage.UPLOADED) {
|
||||||
if (mediaSize > STATUS_MEDIA_SIZE_LIMIT && type == QueuedMedia.Type.IMAGE) {
|
waitForMediaLatch.countUp();
|
||||||
downsizeMedia(item);
|
if (mediaSize > STATUS_MEDIA_SIZE_LIMIT && type == QueuedMedia.Type.IMAGE) {
|
||||||
} else {
|
downsizeMedia(item);
|
||||||
uploadMedia(item);
|
} else {
|
||||||
|
uploadMedia(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1309,6 +1316,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
|
|
||||||
private void onUploadSuccess(final QueuedMedia item, Media media) {
|
private void onUploadSuccess(final QueuedMedia item, Media media) {
|
||||||
item.id = media.id;
|
item.id = media.id;
|
||||||
|
item.readyStage = QueuedMedia.ReadyStage.UPLOADED;
|
||||||
|
|
||||||
/* Add the upload URL to the text field. Also, keep a reference to the span so if the user
|
/* Add the upload URL to the text field. Also, keep a reference to the span so if the user
|
||||||
* chooses to remove the media, the URL is also automatically removed. */
|
* chooses to remove the media, the URL is also automatically removed. */
|
||||||
|
@ -1427,7 +1435,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
}
|
}
|
||||||
Bitmap bitmap = getVideoThumbnail(this, uri);
|
Bitmap bitmap = getVideoThumbnail(this, uri);
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
addMediaToQueue(QueuedMedia.Type.VIDEO, bitmap, uri, mediaSize);
|
addMediaToQueue(QueuedMedia.Type.VIDEO, bitmap, uri, mediaSize, null);
|
||||||
} else {
|
} else {
|
||||||
displayTransientError(R.string.error_media_upload_opening);
|
displayTransientError(R.string.error_media_upload_opening);
|
||||||
}
|
}
|
||||||
|
@ -1436,7 +1444,7 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
case "image": {
|
case "image": {
|
||||||
Bitmap bitmap = getImageThumbnail(contentResolver, uri);
|
Bitmap bitmap = getImageThumbnail(contentResolver, uri);
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
addMediaToQueue(QueuedMedia.Type.IMAGE, bitmap, uri, mediaSize);
|
addMediaToQueue(QueuedMedia.Type.IMAGE, bitmap, uri, mediaSize, null);
|
||||||
} else {
|
} else {
|
||||||
displayTransientError(R.string.error_media_upload_opening);
|
displayTransientError(R.string.error_media_upload_opening);
|
||||||
}
|
}
|
||||||
|
@ -1532,7 +1540,8 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
|
|
||||||
enum ReadyStage {
|
enum ReadyStage {
|
||||||
DOWNSIZING,
|
DOWNSIZING,
|
||||||
UPLOADING
|
UPLOADING,
|
||||||
|
UPLOADED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1552,21 +1561,21 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
};
|
};
|
||||||
QueuedMedia.Type type;
|
QueuedMedia.Type type;
|
||||||
Uri uri;
|
Uri uri;
|
||||||
Bitmap preview;
|
|
||||||
long mediaSize;
|
long mediaSize;
|
||||||
|
QueuedMedia.ReadyStage readyStage;
|
||||||
|
|
||||||
SavedQueuedMedia(QueuedMedia.Type type, Uri uri, ImageView view, long mediaSize) {
|
SavedQueuedMedia(QueuedMedia.Type type, Uri uri, long mediaSize, QueuedMedia.ReadyStage readyStage) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.preview = ((BitmapDrawable) view.getDrawable()).getBitmap();
|
|
||||||
this.mediaSize = mediaSize;
|
this.mediaSize = mediaSize;
|
||||||
|
this.readyStage = readyStage;
|
||||||
}
|
}
|
||||||
|
|
||||||
SavedQueuedMedia(Parcel parcel) {
|
SavedQueuedMedia(Parcel parcel) {
|
||||||
type = (QueuedMedia.Type) parcel.readSerializable();
|
type = (QueuedMedia.Type) parcel.readSerializable();
|
||||||
uri = parcel.readParcelable(Uri.class.getClassLoader());
|
uri = parcel.readParcelable(Uri.class.getClassLoader());
|
||||||
preview = parcel.readParcelable(Bitmap.class.getClassLoader());
|
|
||||||
mediaSize = parcel.readLong();
|
mediaSize = parcel.readLong();
|
||||||
|
readyStage = QueuedMedia.ReadyStage.valueOf(parcel.readString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1578,8 +1587,8 @@ public class ComposeActivity extends BaseActivity implements ComposeOptionsFragm
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeSerializable(type);
|
dest.writeSerializable(type);
|
||||||
dest.writeParcelable(uri, flags);
|
dest.writeParcelable(uri, flags);
|
||||||
dest.writeParcelable(preview, flags);
|
|
||||||
dest.writeLong(mediaSize);
|
dest.writeLong(mediaSize);
|
||||||
|
dest.writeString(readyStage.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue