mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 14:07:28 +01:00
Merge light and dark themes (#5470)
* Merge AMOLED and regular dark themes This allows all variants of dark themes to use black backgrounds as a separate preference. * Merge light and dark themes * Fix ReaderSeekBar color on Dark Blue theme * Color fixes * Fix Dark Blue bars ripple * Simplify night mode check
This commit is contained in:
@@ -11,6 +11,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Color
|
||||
import android.net.ConnectivityManager
|
||||
@@ -38,7 +39,6 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.lang.truncateCenter
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.File
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -277,3 +277,10 @@ fun Context.createFileInCacheDir(name: String): File {
|
||||
fun Context.isTablet(): Boolean {
|
||||
return resources.configuration.smallestScreenWidthDp >= 720
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if current context is in night mode
|
||||
*/
|
||||
fun Context.isNightMode(): Boolean {
|
||||
return resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
|
||||
}
|
||||
|
||||
@@ -25,10 +25,8 @@ import com.google.android.material.elevation.ElevationOverlayProvider
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import eu.kanade.tachiyomi.util.system.isNightMode
|
||||
|
||||
/**
|
||||
* Returns coordinates of view.
|
||||
@@ -186,7 +184,7 @@ inline fun ChipGroup.setChips(
|
||||
* Applies elevation overlay to a MaterialCardView
|
||||
*/
|
||||
inline fun MaterialCardView.applyElevationOverlay() {
|
||||
if (Injekt.get<PreferencesHelper>().isDarkMode()) {
|
||||
if (context.isNightMode()) {
|
||||
val provider = ElevationOverlayProvider(context)
|
||||
setCardBackgroundColor(provider.compositeOverlay(cardBackgroundColor.defaultColor, cardElevation))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user