Skip to content

Commit

Permalink
Formatting classes
Browse files Browse the repository at this point in the history
  • Loading branch information
captainepoch committed Mar 16, 2024
1 parent 350071a commit ae23f1b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ class ViewImageFragment : ViewMediaFragment() {
swipeStartedWithOneFinger = true
lastY = event.rawY
}

MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
onGestureEnd()
swipeStartedWithOneFinger = false
}

MotionEvent.ACTION_MOVE -> {
if (swipeStartedWithOneFinger &&
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package com.keylesspalace.tusky.fragment

import android.os.Bundle
import android.text.TextUtils
import androidx.annotation.OptIn
import androidx.media3.common.util.UnstableApi
import com.keylesspalace.tusky.ViewMediaActivity
import com.keylesspalace.tusky.entity.Attachment

Expand Down Expand Up @@ -46,8 +48,12 @@ abstract class ViewMediaFragment : BaseFragment() {
@JvmStatic
protected val ARG_AVATAR_URL = "avatarUrl"

@OptIn(UnstableApi::class)
@JvmStatic
fun newInstance(attachment: Attachment, shouldStartPostponedTransition: Boolean): ViewMediaFragment {
fun newInstance(
attachment: Attachment,
shouldStartPostponedTransition: Boolean
): ViewMediaFragment {
val arguments = Bundle(2)
arguments.putParcelable(ARG_ATTACHMENT, attachment)
arguments.putBoolean(ARG_START_POSTPONED_TRANSITION, shouldStartPostponedTransition)
Expand All @@ -57,6 +63,7 @@ abstract class ViewMediaFragment : BaseFragment() {
Attachment.Type.VIDEO,
Attachment.Type.GIFV,
Attachment.Type.AUDIO -> ViewVideoFragment()

else -> ViewImageFragment() // it probably won't show anything, but its better than crashing
}
fragment.arguments = arguments
Expand All @@ -82,7 +89,12 @@ abstract class ViewMediaFragment : BaseFragment() {

showingDescription = !TextUtils.isEmpty(description)
isDescriptionVisible = showingDescription
setupMediaView(url, previewUrl, description, showingDescription && mediaActivity.isToolbarVisible)
setupMediaView(
url,
previewUrl,
description,
showingDescription && mediaActivity.isToolbarVisible
)

toolbarVisibiltyDisposable = (activity as ViewMediaActivity)
.addToolbarVisibilityListener { isVisible ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,14 @@ class ViewVideoFragment : ViewMediaFragment() {
Player.STATE_BUFFERING -> {
binding.progressBar.visibility = View.VISIBLE
}

Player.STATE_READY,
Player.STATE_ENDED -> {
binding.progressBar.visibility = View.GONE
binding.videoControls.show()
binding.videoControls.visibility = View.VISIBLE
}

else -> Unit
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,18 @@ fun reorientBitmap(bitmap: Bitmap?, orientation: Int): Bitmap? {
matrix.setRotate(180.0f)
matrix.postScale(-1.0f, 1.0f)
}

ExifInterface.ORIENTATION_TRANSPOSE -> {
matrix.setRotate(90.0f)
matrix.postScale(-1.0f, 1.0f)
}

ExifInterface.ORIENTATION_ROTATE_90 -> matrix.setRotate(90.0f)
ExifInterface.ORIENTATION_TRANSVERSE -> {
matrix.setRotate(-90.0f)
matrix.postScale(-1.0f, 1.0f)
}

ExifInterface.ORIENTATION_ROTATE_270 -> matrix.setRotate(-90.0f)
else -> return bitmap
}
Expand Down Expand Up @@ -251,9 +254,9 @@ fun deleteStaleCachedMedia(mediaDirectory: File?) {

fun getTemporaryMediaFilename(extension: String): String {
return "${MEDIA_TEMP_PREFIX}_${
SimpleDateFormat(
"yyyyMMdd_HHmmss",
Locale.US
).format(Date())
SimpleDateFormat(
"yyyyMMdd_HHmmss",
Locale.US
).format(Date())
}.$extension"
}

0 comments on commit ae23f1b

Please sign in to comment.