Fix preview image not having rounded corners in ShareScreenshotUtils.sharePostAsScreenshot.

This commit is contained in:
Docile-Alligator 2025-06-09 23:14:58 -04:00
parent 37ca68f824
commit 69d2865dd9
2 changed files with 13 additions and 7 deletions

View File

@ -21,6 +21,7 @@ import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.MultiTransformation
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions
@ -38,6 +39,7 @@ import com.github.alexzhirkevich.customqrgenerator.vector.style.QrVectorLogoShap
import com.github.alexzhirkevich.customqrgenerator.vector.style.QrVectorPixelShape
import com.github.alexzhirkevich.customqrgenerator.vector.style.QrVectorShapes
import jp.wasabeef.glide.transformations.BlurTransformation
import jp.wasabeef.glide.transformations.RoundedCornersTransformation
import ml.docilealligator.infinityforreddit.R
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy
import ml.docilealligator.infinityforreddit.activities.BaseActivity
@ -56,7 +58,8 @@ fun sharePostAsScreenshot(
locale: Locale, timeFormatPattern: String,
saveMemoryCenterInsideDownsampleStrategy: SaveMemoryCenterInisdeDownsampleStrategy
) {
val binding: SharedPostBinding = SharedPostBinding.inflate(LayoutInflater.from(ContextThemeWrapper(baseActivity, R.style.AppTheme)))
//val binding: SharedPostBinding = SharedPostBinding.inflate(LayoutInflater.from(ContextThemeWrapper(baseActivity, R.style.AppTheme)))
val binding: SharedPostBinding = SharedPostBinding.inflate(LayoutInflater.from(baseActivity))
binding.titleTextViewSharedPost.text = post.title
binding.subredditNameTextViewSharedPost.text = post.subredditNamePrefixed
@ -140,15 +143,18 @@ fun sharePostAsScreenshot(
imageRequestBuilder.apply(
RequestOptions.bitmapTransform(
MultiTransformation(
CenterCrop(),
BlurTransformation(50, 10),
RoundedCorners(16)
RoundedCornersTransformation(4, 0)
)
)
)
.into(binding.imageViewSharedPost)
).into(binding.imageViewSharedPost)
} else {
imageRequestBuilder.centerInside().apply(RequestOptions().transform(
RoundedCorners(50)
imageRequestBuilder.apply(RequestOptions.bitmapTransform(
MultiTransformation(
CenterCrop(),
RoundedCornersTransformation(50, 0)
)
)).downsample(
saveMemoryCenterInsideDownsampleStrategy
).into(binding.imageViewSharedPost)

View File

@ -27,7 +27,7 @@
android:maxLines="4"
android:textSize="20sp" />
<com.google.android.material.imageview.ShapeableImageView
<ImageView
android:id="@+id/image_view_shared_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"