fix bug where media is not uploaded after ComposeActivity recreation
This commit is contained in:
parent
e8c79cce65
commit
67cf199b03
1 changed files with 16 additions and 8 deletions
|
@ -84,7 +84,6 @@ import com.keylesspalace.tusky.adapter.EmojiAdapter;
|
||||||
import com.keylesspalace.tusky.adapter.MentionAutoCompleteAdapter;
|
import com.keylesspalace.tusky.adapter.MentionAutoCompleteAdapter;
|
||||||
import com.keylesspalace.tusky.adapter.OnEmojiSelectedListener;
|
import com.keylesspalace.tusky.adapter.OnEmojiSelectedListener;
|
||||||
import com.keylesspalace.tusky.db.AccountEntity;
|
import com.keylesspalace.tusky.db.AccountEntity;
|
||||||
import com.keylesspalace.tusky.db.AccountManager;
|
|
||||||
import com.keylesspalace.tusky.db.InstanceEntity;
|
import com.keylesspalace.tusky.db.InstanceEntity;
|
||||||
import com.keylesspalace.tusky.di.Injectable;
|
import com.keylesspalace.tusky.di.Injectable;
|
||||||
import com.keylesspalace.tusky.entity.Account;
|
import com.keylesspalace.tusky.entity.Account;
|
||||||
|
@ -525,7 +524,7 @@ public final class ComposeActivity
|
||||||
} else if (savedMediaQueued != null) {
|
} else if (savedMediaQueued != null) {
|
||||||
for (SavedQueuedMedia item : savedMediaQueued) {
|
for (SavedQueuedMedia item : savedMediaQueued) {
|
||||||
Bitmap preview = MediaUtils.getImageThumbnail(getContentResolver(), item.uri, THUMBNAIL_SIZE);
|
Bitmap preview = MediaUtils.getImageThumbnail(getContentResolver(), item.uri, THUMBNAIL_SIZE);
|
||||||
addMediaToQueue(item.type, preview, item.uri, item.mediaSize, item.readyStage, item.description);
|
addMediaToQueue(item.id, item.type, preview, item.uri, item.mediaSize, item.readyStage, item.description);
|
||||||
}
|
}
|
||||||
} 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
|
||||||
|
@ -585,7 +584,7 @@ public final class ComposeActivity
|
||||||
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,
|
savedMediaQueued.add(new SavedQueuedMedia(item.id, item.type, item.uri,
|
||||||
item.mediaSize, item.readyStage, item.description));
|
item.mediaSize, item.readyStage, item.description));
|
||||||
}
|
}
|
||||||
outState.putParcelableArrayList("savedMediaQueued", savedMediaQueued);
|
outState.putParcelableArrayList("savedMediaQueued", savedMediaQueued);
|
||||||
|
@ -1009,10 +1008,15 @@ public final class ComposeActivity
|
||||||
colorActive ? android.R.attr.textColorTertiary : R.attr.compose_media_button_disabled_tint);
|
colorActive ? android.R.attr.textColorTertiary : 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, @Nullable String description) {
|
addMediaToQueue(null, type, preview, uri, mediaSize, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMediaToQueue(@Nullable String id, QueuedMedia.Type type, Bitmap preview, Uri uri,
|
||||||
|
long mediaSize, QueuedMedia.ReadyStage readyStage, @Nullable String description) {
|
||||||
final QueuedMedia item = new QueuedMedia(type, uri, new ProgressImageView(this),
|
final QueuedMedia item = new QueuedMedia(type, uri, new ProgressImageView(this),
|
||||||
mediaSize, description);
|
mediaSize, description);
|
||||||
|
item.id = id;
|
||||||
item.readyStage = readyStage;
|
item.readyStage = readyStage;
|
||||||
ImageView view = item.preview;
|
ImageView view = item.preview;
|
||||||
Resources resources = getResources();
|
Resources resources = getResources();
|
||||||
|
@ -1322,7 +1326,7 @@ public final class ComposeActivity
|
||||||
}
|
}
|
||||||
Bitmap bitmap = MediaUtils.getVideoThumbnail(this, uri, THUMBNAIL_SIZE);
|
Bitmap bitmap = MediaUtils.getVideoThumbnail(this, uri, THUMBNAIL_SIZE);
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
addMediaToQueue(QueuedMedia.Type.VIDEO, bitmap, uri, mediaSize, null, null);
|
addMediaToQueue(QueuedMedia.Type.VIDEO, bitmap, uri, mediaSize);
|
||||||
} else {
|
} else {
|
||||||
displayTransientError(R.string.error_media_upload_opening);
|
displayTransientError(R.string.error_media_upload_opening);
|
||||||
}
|
}
|
||||||
|
@ -1331,7 +1335,7 @@ public final class ComposeActivity
|
||||||
case "image": {
|
case "image": {
|
||||||
Bitmap bitmap = MediaUtils.getImageThumbnail(contentResolver, uri, THUMBNAIL_SIZE);
|
Bitmap bitmap = MediaUtils.getImageThumbnail(contentResolver, uri, THUMBNAIL_SIZE);
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
addMediaToQueue(QueuedMedia.Type.IMAGE, bitmap, uri, mediaSize, null, null);
|
addMediaToQueue(QueuedMedia.Type.IMAGE, bitmap, uri, mediaSize);
|
||||||
} else {
|
} else {
|
||||||
displayTransientError(R.string.error_media_upload_opening);
|
displayTransientError(R.string.error_media_upload_opening);
|
||||||
}
|
}
|
||||||
|
@ -1514,13 +1518,15 @@ public final class ComposeActivity
|
||||||
return new SavedQueuedMedia[size];
|
return new SavedQueuedMedia[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
String id;
|
||||||
QueuedMedia.Type type;
|
QueuedMedia.Type type;
|
||||||
Uri uri;
|
Uri uri;
|
||||||
long mediaSize;
|
long mediaSize;
|
||||||
QueuedMedia.ReadyStage readyStage;
|
QueuedMedia.ReadyStage readyStage;
|
||||||
String description;
|
String description;
|
||||||
|
|
||||||
SavedQueuedMedia(QueuedMedia.Type type, Uri uri, long mediaSize, QueuedMedia.ReadyStage readyStage, String description) {
|
SavedQueuedMedia(String id, QueuedMedia.Type type, Uri uri, long mediaSize, QueuedMedia.ReadyStage readyStage, String description) {
|
||||||
|
this.id = id;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.mediaSize = mediaSize;
|
this.mediaSize = mediaSize;
|
||||||
|
@ -1529,6 +1535,7 @@ public final class ComposeActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
SavedQueuedMedia(Parcel parcel) {
|
SavedQueuedMedia(Parcel parcel) {
|
||||||
|
id = parcel.readString();
|
||||||
type = (QueuedMedia.Type) parcel.readSerializable();
|
type = (QueuedMedia.Type) parcel.readSerializable();
|
||||||
uri = parcel.readParcelable(Uri.class.getClassLoader());
|
uri = parcel.readParcelable(Uri.class.getClassLoader());
|
||||||
mediaSize = parcel.readLong();
|
mediaSize = parcel.readLong();
|
||||||
|
@ -1543,6 +1550,7 @@ public final class ComposeActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
|
dest.writeString(id);
|
||||||
dest.writeSerializable(type);
|
dest.writeSerializable(type);
|
||||||
dest.writeParcelable(uri, flags);
|
dest.writeParcelable(uri, flags);
|
||||||
dest.writeLong(mediaSize);
|
dest.writeLong(mediaSize);
|
||||||
|
|
Loading…
Reference in a new issue