feat: Blur toggle
This commit is contained in:
parent
07662a91f4
commit
8fb6357fb5
7 changed files with 128 additions and 30 deletions
|
@ -1104,13 +1104,19 @@ suspend fun View.pop() {
|
||||||
|
|
||||||
fun blurImage(imageView: ImageView, banner: String?){
|
fun blurImage(imageView: ImageView, banner: String?){
|
||||||
if (banner != null) {
|
if (banner != null) {
|
||||||
val context = imageView.context
|
val radius = PrefManager.getVal<Float>(PrefName.BlurRadius).toInt()
|
||||||
if (!(context as Activity).isDestroyed)
|
val sampling = PrefManager.getVal<Float>(PrefName.BlurSampling).toInt()
|
||||||
Glide.with(context as Context)
|
if (PrefManager.getVal(PrefName.BlurBanners)){
|
||||||
.load(GlideUrl(banner))
|
val context = imageView.context
|
||||||
.diskCacheStrategy(DiskCacheStrategy.ALL).override(400)
|
if (!(context as Activity).isDestroyed)
|
||||||
.apply(RequestOptions.bitmapTransform(BlurTransformation(2, 2)))
|
Glide.with(context as Context)
|
||||||
.into(imageView)
|
.load(GlideUrl(banner))
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.ALL).override(400)
|
||||||
|
.apply(RequestOptions.bitmapTransform(BlurTransformation(radius, sampling)))
|
||||||
|
.into(imageView)
|
||||||
|
}else{
|
||||||
|
imageView.loadImage(banner)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
imageView.setImageResource(R.drawable.linear_gradient_bg)
|
imageView.setImageResource(R.drawable.linear_gradient_bg)
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,7 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
|
||||||
binding.mangaTrendingViewPager.setPageTransformer(MediaPageTransformer())
|
binding.mangaTrendingViewPager.setPageTransformer(MediaPageTransformer())
|
||||||
trendHandler = Handler(Looper.getMainLooper())
|
trendHandler = Handler(Looper.getMainLooper())
|
||||||
trendRun = Runnable {
|
trendRun = Runnable {
|
||||||
binding.mangaTrendingViewPager.currentItem =
|
binding.mangaTrendingViewPager.currentItem += 1
|
||||||
binding.mangaTrendingViewPager.currentItem + 1
|
|
||||||
}
|
}
|
||||||
binding.mangaTrendingViewPager.registerOnPageChangeCallback(
|
binding.mangaTrendingViewPager.registerOnPageChangeCallback(
|
||||||
object : ViewPager2.OnPageChangeCallback() {
|
object : ViewPager2.OnPageChangeCallback() {
|
||||||
|
|
|
@ -187,15 +187,7 @@ class MediaAdaptor(
|
||||||
AccelerateDecelerateInterpolator()
|
AccelerateDecelerateInterpolator()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val banner =
|
blurImage(b.itemCompactBanner, media.banner ?: media.cover)
|
||||||
if (bannerAnimations) b.itemCompactBanner else b.itemCompactBannerNoKen
|
|
||||||
val context = b.itemCompactBanner.context
|
|
||||||
if (!(context as Activity).isDestroyed)
|
|
||||||
Glide.with(context as Context)
|
|
||||||
.load(GlideUrl(media.banner ?: media.cover))
|
|
||||||
.diskCacheStrategy(DiskCacheStrategy.ALL).override(400)
|
|
||||||
.apply(RequestOptions.bitmapTransform(BlurTransformation(2, 3)))
|
|
||||||
.into(banner)
|
|
||||||
b.itemCompactOngoing.visibility =
|
b.itemCompactOngoing.visibility =
|
||||||
if (media.status == currActivity()!!.getString(R.string.status_releasing)) View.VISIBLE else View.GONE
|
if (media.status == currActivity()!!.getString(R.string.status_releasing)) View.VISIBLE else View.GONE
|
||||||
b.itemCompactTitle.text = media.userPreferredName
|
b.itemCompactTitle.text = media.userPreferredName
|
||||||
|
@ -244,15 +236,7 @@ class MediaAdaptor(
|
||||||
AccelerateDecelerateInterpolator()
|
AccelerateDecelerateInterpolator()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
val banner =
|
blurImage(b.itemCompactBanner, media.banner ?: media.cover)
|
||||||
if (bannerAnimations) b.itemCompactBanner else b.itemCompactBannerNoKen
|
|
||||||
val context = b.itemCompactBanner.context
|
|
||||||
if (!(context as Activity).isDestroyed)
|
|
||||||
Glide.with(context as Context)
|
|
||||||
.load(GlideUrl(media.banner ?: media.cover))
|
|
||||||
.diskCacheStrategy(DiskCacheStrategy.ALL).override(400)
|
|
||||||
.apply(RequestOptions.bitmapTransform(BlurTransformation(2, 3)))
|
|
||||||
.into(banner)
|
|
||||||
b.itemCompactOngoing.visibility =
|
b.itemCompactOngoing.visibility =
|
||||||
if (media.status == currActivity()!!.getString(R.string.status_releasing)) View.VISIBLE else View.GONE
|
if (media.status == currActivity()!!.getString(R.string.status_releasing)) View.VISIBLE else View.GONE
|
||||||
b.itemCompactTitle.text = media.userPreferredName
|
b.itemCompactTitle.text = media.userPreferredName
|
||||||
|
|
|
@ -96,8 +96,21 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
|
||||||
PrefManager.setVal(PrefName.AnimationSpeed, map[value] ?: 1f)
|
PrefManager.setVal(PrefName.AnimationSpeed, map[value] ?: 1f)
|
||||||
restartApp()
|
restartApp()
|
||||||
}
|
}
|
||||||
|
binding.uiSettingsBlurBanners.isChecked = PrefManager.getVal(PrefName.BlurBanners)
|
||||||
|
binding.uiSettingsBlurBanners.setOnCheckedChangeListener { _, isChecked ->
|
||||||
|
PrefManager.setVal(PrefName.BlurBanners, isChecked)
|
||||||
|
restartApp()
|
||||||
|
}
|
||||||
|
binding.uiSettingsBlurRadius.value = (PrefManager.getVal(PrefName.BlurRadius) as Float)
|
||||||
|
binding.uiSettingsBlurRadius.addOnChangeListener { _, value, _ ->
|
||||||
|
PrefManager.setVal(PrefName.BlurRadius, value)
|
||||||
|
restartApp()
|
||||||
|
}
|
||||||
|
binding.uiSettingsBlurSampling.value = (PrefManager.getVal(PrefName.BlurSampling) as Float)
|
||||||
|
binding.uiSettingsBlurSampling.addOnChangeListener { _, value, _ ->
|
||||||
|
PrefManager.setVal(PrefName.BlurSampling, value)
|
||||||
|
restartApp()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun restartApp() {
|
private fun restartApp() {
|
||||||
|
|
|
@ -47,6 +47,9 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
||||||
ShowYtButton(Pref(Location.UI, Boolean::class, true)),
|
ShowYtButton(Pref(Location.UI, Boolean::class, true)),
|
||||||
AnimeDefaultView(Pref(Location.UI, Int::class, 0)),
|
AnimeDefaultView(Pref(Location.UI, Int::class, 0)),
|
||||||
MangaDefaultView(Pref(Location.UI, Int::class, 0)),
|
MangaDefaultView(Pref(Location.UI, Int::class, 0)),
|
||||||
|
BlurBanners(Pref(Location.UI, Boolean::class, true)),
|
||||||
|
BlurRadius(Pref(Location.UI, Float::class, 2f)),
|
||||||
|
BlurSampling(Pref(Location.UI, Float::class, 2f)),
|
||||||
ImmersiveMode(Pref(Location.UI, Boolean::class, false)),
|
ImmersiveMode(Pref(Location.UI, Boolean::class, false)),
|
||||||
SmallView(Pref(Location.UI, Boolean::class, true)),
|
SmallView(Pref(Location.UI, Boolean::class, true)),
|
||||||
DefaultStartUpTab(Pref(Location.UI, Int::class, 1)),
|
DefaultStartUpTab(Pref(Location.UI, Int::class, 1)),
|
||||||
|
|
|
@ -264,6 +264,96 @@
|
||||||
app:trackColorActive="?attr/colorSecondary"
|
app:trackColorActive="?attr/colorSecondary"
|
||||||
tools:ignore="SpeakableTextPresentCheck" />
|
tools:ignore="SpeakableTextPresentCheck" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:paddingStart="32dp"
|
||||||
|
android:paddingEnd="32dp"
|
||||||
|
android:text="@string/blur"
|
||||||
|
android:textColor="?attr/colorSecondary"
|
||||||
|
tools:ignore="TextContrastCheck" />
|
||||||
|
|
||||||
|
<com.google.android.material.materialswitch.MaterialSwitch
|
||||||
|
android:id="@+id/uiSettingsBlurBanners"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
|
android:drawableStart="@drawable/ic_round_photo_size_select_actual_24"
|
||||||
|
android:drawablePadding="16dp"
|
||||||
|
android:elegantTextHeight="true"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:minHeight="64dp"
|
||||||
|
android:paddingStart="32dp"
|
||||||
|
android:paddingEnd="32dp"
|
||||||
|
android:text="@string/blur_banners"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textColor="?attr/colorOnBackground"
|
||||||
|
app:cornerRadius="0dp"
|
||||||
|
app:drawableTint="?attr/colorPrimary"
|
||||||
|
app:showText="false"
|
||||||
|
app:thumbTint="@color/button_switch_track">
|
||||||
|
|
||||||
|
</com.google.android.material.materialswitch.MaterialSwitch>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:drawablePadding="16dp"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:paddingStart="32dp"
|
||||||
|
android:paddingEnd="32dp"
|
||||||
|
android:text="@string/radius"
|
||||||
|
app:drawableStartCompat="@drawable/ic_internet"
|
||||||
|
app:drawableTint="?attr/colorPrimary" />
|
||||||
|
|
||||||
|
<com.google.android.material.slider.Slider
|
||||||
|
android:id="@+id/uiSettingsBlurRadius"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:stepSize="1"
|
||||||
|
android:value="2"
|
||||||
|
android:valueFrom="1.0"
|
||||||
|
android:valueTo="10.0"
|
||||||
|
app:labelBehavior="floating"
|
||||||
|
app:labelStyle="@style/fontTooltip"
|
||||||
|
app:thumbColor="?attr/colorSecondary"
|
||||||
|
app:tickColorInactive="?attr/colorSecondary"
|
||||||
|
app:trackColorActive="?attr/colorSecondary"
|
||||||
|
tools:ignore="SpeakableTextPresentCheck" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:drawablePadding="16dp"
|
||||||
|
android:fontFamily="@font/poppins_bold"
|
||||||
|
android:paddingStart="32dp"
|
||||||
|
android:paddingEnd="32dp"
|
||||||
|
android:text="@string/sampling"
|
||||||
|
app:drawableStartCompat="@drawable/ic_globe_24"
|
||||||
|
app:drawableTint="?attr/colorPrimary" />
|
||||||
|
|
||||||
|
<com.google.android.material.slider.Slider
|
||||||
|
android:id="@+id/uiSettingsBlurSampling"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="32dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:stepSize="1"
|
||||||
|
android:value="2"
|
||||||
|
android:valueFrom="1.0"
|
||||||
|
android:valueTo="10.0"
|
||||||
|
app:labelBehavior="floating"
|
||||||
|
app:labelStyle="@style/fontTooltip"
|
||||||
|
app:thumbColor="?attr/colorSecondary"
|
||||||
|
app:tickColorInactive="?attr/colorSecondary"
|
||||||
|
app:trackColorActive="?attr/colorSecondary"
|
||||||
|
tools:ignore="SpeakableTextPresentCheck" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
|
@ -694,5 +694,8 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||||
</string>
|
</string>
|
||||||
<string name="log_to_file">Log to File</string>
|
<string name="log_to_file">Log to File</string>
|
||||||
<string name="logging_warning">Logging to a file will slow down the app. Only enable if you are experiencing issues.</string>
|
<string name="logging_warning">Logging to a file will slow down the app. Only enable if you are experiencing issues.</string>
|
||||||
|
<string name="radius">Radius</string>
|
||||||
|
<string name="sampling">Sampling</string>
|
||||||
|
<string name="blur_banners">Blur Banners</string>
|
||||||
|
<string name="blur">Blur</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue