update ktlint plugin to 11.3.1, format code (#3442)
This commit is contained in:
parent
774d79d666
commit
d839f18267
141 changed files with 589 additions and 428 deletions
|
|
@ -812,25 +812,26 @@ class ComposeActivity :
|
|||
}
|
||||
|
||||
private fun onMediaPick() {
|
||||
addMediaBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
// Wait until bottom sheet is not collapsed and show next screen after
|
||||
if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
addMediaBehavior.removeBottomSheetCallback(this)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && ContextCompat.checkSelfPermission(this@ComposeActivity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this@ComposeActivity,
|
||||
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
|
||||
PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
pickMediaFile.launch(true)
|
||||
addMediaBehavior.addBottomSheetCallback(
|
||||
object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onStateChanged(bottomSheet: View, newState: Int) {
|
||||
// Wait until bottom sheet is not collapsed and show next screen after
|
||||
if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
|
||||
addMediaBehavior.removeBottomSheetCallback(this)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q && ContextCompat.checkSelfPermission(this@ComposeActivity, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(
|
||||
this@ComposeActivity,
|
||||
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),
|
||||
PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE
|
||||
)
|
||||
} else {
|
||||
pickMediaFile.launch(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {}
|
||||
}
|
||||
override fun onSlide(bottomSheet: View, slideOffset: Float) {}
|
||||
}
|
||||
)
|
||||
addMediaBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||
}
|
||||
|
|
@ -953,7 +954,6 @@ class ComposeActivity :
|
|||
binding.composeEditField.error = getString(R.string.error_empty)
|
||||
enableButtons(true, viewModel.editing)
|
||||
} else if (characterCount <= maximumTootCharacters) {
|
||||
|
||||
lifecycleScope.launch {
|
||||
viewModel.sendStatus(contentText, spoilerText)
|
||||
deleteDraftAndFinish()
|
||||
|
|
@ -972,7 +972,8 @@ class ComposeActivity :
|
|||
pickMediaFile.launch(true)
|
||||
} else {
|
||||
Snackbar.make(
|
||||
binding.activityCompose, R.string.error_media_upload_permission,
|
||||
binding.activityCompose,
|
||||
R.string.error_media_upload_permission,
|
||||
Snackbar.LENGTH_SHORT
|
||||
).apply {
|
||||
setAction(R.string.action_retry) { onMediaPick() }
|
||||
|
|
@ -1006,9 +1007,13 @@ class ComposeActivity :
|
|||
private fun enableButton(button: ImageButton, clickable: Boolean, colorActive: Boolean) {
|
||||
button.isEnabled = clickable
|
||||
setDrawableTint(
|
||||
this, button.drawable,
|
||||
if (colorActive) android.R.attr.textColorTertiary
|
||||
else R.attr.textColorDisabled
|
||||
this,
|
||||
button.drawable,
|
||||
if (colorActive) {
|
||||
android.R.attr.textColorTertiary
|
||||
} else {
|
||||
R.attr.textColorDisabled
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -1016,8 +1021,11 @@ class ComposeActivity :
|
|||
binding.addPollTextActionTextView.isEnabled = enable
|
||||
val textColor = MaterialColors.getColor(
|
||||
binding.addPollTextActionTextView,
|
||||
if (enable) android.R.attr.textColorTertiary
|
||||
else R.attr.textColorDisabled
|
||||
if (enable) {
|
||||
android.R.attr.textColorTertiary
|
||||
} else {
|
||||
R.attr.textColorDisabled
|
||||
}
|
||||
)
|
||||
binding.addPollTextActionTextView.setTextColor(textColor)
|
||||
binding.addPollTextActionTextView.compoundDrawablesRelative[0].colorFilter = PorterDuffColorFilter(textColor, PorterDuff.Mode.SRC_IN)
|
||||
|
|
@ -1193,8 +1201,11 @@ class ComposeActivity :
|
|||
lifecycleScope.launch {
|
||||
val dialog = if (viewModel.shouldShowSaveDraftDialog()) {
|
||||
ProgressDialog.show(
|
||||
this@ComposeActivity, null,
|
||||
getString(R.string.saving_draft), true, false
|
||||
this@ComposeActivity,
|
||||
null,
|
||||
getString(R.string.saving_draft),
|
||||
true,
|
||||
false
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ class ComposeViewModel @Inject constructor(
|
|||
failedToSendAlert = false,
|
||||
scheduledAt = scheduledAt.value,
|
||||
language = postLanguage,
|
||||
statusId = originalStatusId,
|
||||
statusId = originalStatusId
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -286,7 +286,6 @@ class ComposeViewModel @Inject constructor(
|
|||
content: String,
|
||||
spoilerText: String
|
||||
) {
|
||||
|
||||
if (!scheduledTootId.isNullOrEmpty()) {
|
||||
api.deleteScheduledStatus(scheduledTootId!!)
|
||||
}
|
||||
|
|
@ -405,7 +404,6 @@ class ComposeViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
fun setup(composeOptions: ComposeActivity.ComposeOptions?) {
|
||||
|
||||
if (setupComplete) {
|
||||
return
|
||||
}
|
||||
|
|
@ -440,14 +438,16 @@ class ComposeViewModel @Inject constructor(
|
|||
pickMedia(attachment.uri, attachment.description, attachment.focus)
|
||||
}
|
||||
}
|
||||
} else composeOptions?.mediaAttachments?.forEach { a ->
|
||||
// when coming from redraft or ScheduledTootActivity
|
||||
val mediaType = when (a.type) {
|
||||
Attachment.Type.VIDEO, Attachment.Type.GIFV -> QueuedMedia.Type.VIDEO
|
||||
Attachment.Type.UNKNOWN, Attachment.Type.IMAGE -> QueuedMedia.Type.IMAGE
|
||||
Attachment.Type.AUDIO -> QueuedMedia.Type.AUDIO
|
||||
} else {
|
||||
composeOptions?.mediaAttachments?.forEach { a ->
|
||||
// when coming from redraft or ScheduledTootActivity
|
||||
val mediaType = when (a.type) {
|
||||
Attachment.Type.VIDEO, Attachment.Type.GIFV -> QueuedMedia.Type.VIDEO
|
||||
Attachment.Type.UNKNOWN, Attachment.Type.IMAGE -> QueuedMedia.Type.IMAGE
|
||||
Attachment.Type.AUDIO -> QueuedMedia.Type.AUDIO
|
||||
}
|
||||
addUploadedMedia(a.id, mediaType, a.url.toUri(), a.description, a.meta?.focus)
|
||||
}
|
||||
addUploadedMedia(a.id, mediaType, a.url.toUri(), a.description, a.meta?.focus)
|
||||
}
|
||||
|
||||
draftId = composeOptions?.draftId ?: 0
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ fun downsizeImage(
|
|||
contentResolver: ContentResolver,
|
||||
tempFile: File
|
||||
): Boolean {
|
||||
|
||||
val decodeBoundsInputStream = try {
|
||||
contentResolver.openInputStream(uri)
|
||||
} catch (e: FileNotFoundException) {
|
||||
|
|
|
|||
|
|
@ -90,10 +90,11 @@ class MediaPreviewAdapter(
|
|||
val imageView = holder.progressImageView
|
||||
val focus = item.focus
|
||||
|
||||
if (focus != null)
|
||||
if (focus != null) {
|
||||
imageView.setFocalPoint(focus)
|
||||
else
|
||||
} else {
|
||||
imageView.removeFocalPoint() // Probably unnecessary since we have no UI for removal once added.
|
||||
}
|
||||
|
||||
var glide = Glide.with(holder.itemView.context)
|
||||
.load(item.uri)
|
||||
|
|
@ -101,8 +102,9 @@ class MediaPreviewAdapter(
|
|||
.dontAnimate()
|
||||
.centerInside()
|
||||
|
||||
if (focus != null)
|
||||
if (focus != null) {
|
||||
glide = glide.addListener(imageView)
|
||||
}
|
||||
|
||||
glide.into(imageView)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ class MediaUploader @Inject constructor(
|
|||
try {
|
||||
when (inUri.scheme) {
|
||||
ContentResolver.SCHEME_CONTENT -> {
|
||||
|
||||
mimeType = contentResolver.getType(uri)
|
||||
|
||||
val suffix = "." + MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType ?: "tmp")
|
||||
|
|
@ -278,7 +277,8 @@ class MediaUploader @Inject constructor(
|
|||
|
||||
var lastProgress = -1
|
||||
val fileBody = ProgressRequestBody(
|
||||
stream!!, media.mediaSize,
|
||||
stream!!,
|
||||
media.mediaSize,
|
||||
mimeType.toMediaTypeOrNull()!!
|
||||
) { percentage ->
|
||||
if (percentage != lastProgress) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ fun showAddPollDialog(
|
|||
maxDuration: Int,
|
||||
onUpdatePoll: (NewPoll) -> Unit
|
||||
) {
|
||||
|
||||
val binding = DialogAddPollBinding.inflate(LayoutInflater.from(context))
|
||||
|
||||
val dialog = AlertDialog.Builder(context)
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ class CaptionDialog : DialogFragment() {
|
|||
input = EditText(context)
|
||||
input.hint = resources.getQuantityString(
|
||||
R.plurals.hint_describe_for_visually_impaired,
|
||||
MEDIA_DESCRIPTION_CHARACTER_LIMIT, MEDIA_DESCRIPTION_CHARACTER_LIMIT
|
||||
MEDIA_DESCRIPTION_CHARACTER_LIMIT,
|
||||
MEDIA_DESCRIPTION_CHARACTER_LIMIT
|
||||
)
|
||||
dialogLayout.addView(input)
|
||||
(input.layoutParams as LinearLayout.LayoutParams).setMargins(margin, margin, margin, margin)
|
||||
|
|
@ -105,7 +106,7 @@ class CaptionDialog : DialogFragment() {
|
|||
|
||||
override fun onResourceReady(
|
||||
resource: Drawable,
|
||||
transition: Transition<in Drawable>?,
|
||||
transition: Transition<in Drawable>?
|
||||
) {
|
||||
imageView.setImageDrawable(resource)
|
||||
}
|
||||
|
|
@ -122,7 +123,7 @@ class CaptionDialog : DialogFragment() {
|
|||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
savedInstanceState?.getString(DESCRIPTION_KEY)?.let {
|
||||
input.setText(it)
|
||||
|
|
@ -143,12 +144,12 @@ class CaptionDialog : DialogFragment() {
|
|||
fun newInstance(
|
||||
localId: Int,
|
||||
existingDescription: String?,
|
||||
previewUri: Uri,
|
||||
previewUri: Uri
|
||||
) = CaptionDialog().apply {
|
||||
arguments = bundleOf(
|
||||
LOCAL_ID_ARG to localId,
|
||||
EXISTING_DESCRIPTION_ARG to existingDescription,
|
||||
PREVIEW_URI_ARG to previewUri,
|
||||
PREVIEW_URI_ARG to previewUri
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,14 +27,16 @@ class FocusIndicatorView
|
|||
|
||||
fun setImageSize(width: Int, height: Int) {
|
||||
this.imageSize = Point(width, height)
|
||||
if (focus != null)
|
||||
if (focus != null) {
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
fun setFocus(focus: Attachment.Focus) {
|
||||
this.focus = focus
|
||||
if (imageSize != null)
|
||||
if (imageSize != null) {
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
// Assumes setFocus called first
|
||||
|
|
@ -46,8 +48,9 @@ class FocusIndicatorView
|
|||
// so base it on the view width/height whenever the first access occurs.
|
||||
private fun getCircleRadius(): Float {
|
||||
val circleRadius = this.circleRadius
|
||||
if (circleRadius != null)
|
||||
if (circleRadius != null) {
|
||||
return circleRadius
|
||||
}
|
||||
val newCircleRadius = min(this.width, this.height).toFloat() / 4.0f
|
||||
this.circleRadius = newCircleRadius
|
||||
return newCircleRadius
|
||||
|
|
@ -67,8 +70,9 @@ class FocusIndicatorView
|
|||
|
||||
@SuppressLint("ClickableViewAccessibility") // Android Studio wants us to implement PerformClick for accessibility, but that unfortunately cannot be made meaningful for this widget.
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
if (event.actionMasked == MotionEvent.ACTION_CANCEL)
|
||||
if (event.actionMasked == MotionEvent.ACTION_CANCEL) {
|
||||
return false
|
||||
}
|
||||
|
||||
val imageSize = this.imageSize ?: return false
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ class TootButton
|
|||
|
||||
fun setStatusVisibility(visibility: Status.Visibility) {
|
||||
if (!smallStyle) {
|
||||
|
||||
icon = when (visibility) {
|
||||
Status.Visibility.PUBLIC -> {
|
||||
setText(R.string.action_send_public)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue