diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/account/AccountExtras.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/account/AccountExtras.java index 387bcdacb..ecd3fb9ff 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/model/account/AccountExtras.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/model/account/AccountExtras.java @@ -85,7 +85,7 @@ public interface AccountExtras extends Parcelable { public boolean checkSize(long size, boolean async) { final long limit = async ? getMaxSizeAsync() : getMaxSizeSync(); if (limit <= 0 || size <= 0) return true; - return size < limit; + return size <= limit; } } @@ -303,7 +303,7 @@ public interface AccountExtras extends Parcelable { public boolean checkSize(long size, boolean async) { final long limit = async ? getMaxSizeAsync() : getMaxSizeSync(); if (limit <= 0 || size <= 0) return true; - return size < limit; + return size <= limit; } @SuppressWarnings("RedundantIfStatement") diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/RetweetQuoteDialogFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/RetweetQuoteDialogFragment.kt index 542baf635..b1879c031 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/RetweetQuoteDialogFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/status/RetweetQuoteDialogFragment.kt @@ -165,17 +165,20 @@ class RetweetQuoteDialogFragment : AbsStatusDialogFragment() { if (this !is AlertDialog) return val positiveButton = getButton(AlertDialog.BUTTON_POSITIVE) ?: return - if (status.is_my_retweet) { - positiveButton.setText(R.string.action_cancel_retweet) - positiveButton.isEnabled = true - } else if (canQuoteRetweet(account)) { - if (editComment.empty) { - positiveButton.setText(R.string.action_retweet) - positiveButton.isEnabled = status.can_retweet - } else { + if (canQuoteRetweet(account)) { + if (!editComment.empty) { positiveButton.setText(R.string.action_comment) positiveButton.isEnabled = true + } else if (status.is_my_retweet) { + positiveButton.setText(R.string.action_cancel_retweet) + positiveButton.isEnabled = true + } else { + positiveButton.setText(R.string.action_retweet) + positiveButton.isEnabled = status.can_retweet } + } else if (status.is_my_retweet) { + positiveButton.setText(R.string.action_cancel_retweet) + positiveButton.isEnabled = true } else { positiveButton.setText(R.string.action_retweet) positiveButton.isEnabled = status.can_retweet diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt index 33be7a960..a8dce1353 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt @@ -915,8 +915,8 @@ class UpdateStatusTask( return null } - if (imageLimit == null || imageLimit.checkGeomentry(o.outWidth, o.outHeight) - || imageLimit.checkSize(imageSize, chucked)) return null + if (imageLimit == null || (imageLimit.checkGeomentry(o.outWidth, o.outHeight) + && imageLimit.checkSize(imageSize, chucked))) return null o.inSampleSize = o.calculateInSampleSize(imageLimit.maxWidth, imageLimit.maxHeight) o.inJustDecodeBounds = false // Do actual image decoding @@ -966,6 +966,16 @@ class UpdateStatusTask( videoLimit: AccountExtras.VideoLimit?, chucked: Boolean ): MediaStreamData? { + + // No limit, upload original + if (videoLimit == null) { + return null + } + + if (!videoLimit.isSupported) { + throw IOException(context.getString(R.string.error_message_video_upload_not_supported)) + } + var mediaType = defaultType val geometry = Point() var duration = -1L @@ -991,22 +1001,20 @@ class UpdateStatusTask( retriever.releaseSafe() } - if (videoLimit != null) { - if (geometry.x > 0 && geometry.y > 0 && videoLimit.checkGeometry(geometry.x, geometry.y) - && framerate > 0 && videoLimit.checkFrameRate(framerate) - && size > 0 && videoLimit.checkSize(size, chucked)) { - // Size valid, upload directly - DebugLog.d(LOGTAG, "Upload video directly") - return null - } + if (geometry.x > 0 && geometry.y > 0 && videoLimit.checkGeometry(geometry.x, geometry.y) + && framerate > 0 && videoLimit.checkFrameRate(framerate) + && size > 0 && videoLimit.checkSize(size, chucked)) { + // Size valid, upload directly + DebugLog.d(LOGTAG, "Upload video directly") + return null + } - if (!videoLimit.checkMinDuration(duration, chucked)) { - throw UploadException(context.getString(R.string.message_video_too_short)) - } + if (!videoLimit.checkMinDuration(duration, chucked)) { + throw UploadException(context.getString(R.string.message_video_too_short)) + } - if (!videoLimit.checkMaxDuration(duration, chucked)) { - throw UploadException(context.getString(R.string.message_video_too_long)) - } + if (!videoLimit.checkMaxDuration(duration, chucked)) { + throw UploadException(context.getString(R.string.message_video_too_long)) } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { diff --git a/twidere/src/main/res/values/strings.xml b/twidere/src/main/res/values/strings.xml index 31e0732d0..ee45e68b6 100644 --- a/twidere/src/main/res/values/strings.xml +++ b/twidere/src/main/res/values/strings.xml @@ -1321,4 +1321,5 @@ Blocked these users. %s\'s lists User\'s tweets + Video upload not supported