fixed quote retweet positive button

This commit is contained in:
Mariotaku Lee 2017-06-04 16:53:35 +08:00
parent c66371f710
commit 4ef27bfd58
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
4 changed files with 38 additions and 26 deletions

View File

@ -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")

View File

@ -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

View File

@ -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) {

View File

@ -1321,4 +1321,5 @@
<string name="users_blocked">Blocked these users.</string>
<string name="users_lists_with_name"><xliff:g id="name">%s</xliff:g>\'s lists</string>
<string name="users_statuses">User\'s tweets</string>
<string name="error_message_video_upload_not_supported">Video upload not supported</string>
</resources>