Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaling cover image instead of cropping #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import android.util.Size
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.SeekBar
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.postDelayed
Expand Down Expand Up @@ -220,7 +222,8 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener {
// change cover image manually only once loaded successfully to avoid blinking at fails and placeholders
loadGlideResource(
model = coverArt,
options = RequestOptions().centerCrop(),
//show full "audiobook" covers
options = RequestOptions().fitCenter(),
size = Size(wantedWidth, wantedHeight),
onLoadFailed = {
val drawable = resources.getDrawable(R.drawable.ic_headset)
Expand All @@ -239,6 +242,8 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener {

runOnUiThread {
binding.activityTrackImage.setImageDrawable(it)
//TODO: possibly add a toggle to see cover fullscreen vs scaled and centered
// binding.activityTrackImage.setOnClickListener(CoverExpander())
}
}
)
Expand Down Expand Up @@ -433,4 +438,20 @@ class TrackActivity : SimpleControllerActivity(), PlaybackSpeedListener {
private fun updatePlayPause(isPlaying: Boolean) {
binding.activityTrackPlayPause.updatePlayPauseIcon(isPlaying, getProperTextColor())
}

private class CoverExpander : View.OnClickListener {
override fun onClick(view: View) {
val img: ImageView = view as ImageView
if (img.scaleType == ImageView.ScaleType.CENTER_CROP) {
img.setScaleType(ImageView.ScaleType.FIT_CENTER)
img.layoutParams.height = R.dimen.top_art_height
//Log.w("click image", "click go small")
} else {
img.setScaleType(ImageView.ScaleType.CENTER_CROP)
img.layoutParams.height = RelativeLayout.LayoutParams.WRAP_CONTENT

//Log.w("click image", "click go big")
}
}
}
}