mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: Colour profile selector
This commit is contained in:
parent
97cc80c967
commit
25d1954e8a
3 changed files with 17 additions and 5 deletions
|
@ -9,6 +9,10 @@
|
|||
-->
|
||||
## Additions
|
||||
- Added cutout support for some pre-Android P devices
|
||||
- Added option to add custom colour profile
|
||||
|
||||
## Changes
|
||||
- Permanently enable 32-bit colour mode
|
||||
|
||||
## Fixes
|
||||
- Fixed cutout behaviour for Android P
|
||||
|
|
|
@ -208,14 +208,16 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
private val basePreferences: BasePreferences by injectLazy()
|
||||
|
||||
// Ideally we want this to be inside the controller itself, but Conductor doesn't support the new ActivityResult API
|
||||
// Should be fine once we moved completely to Compose..... someday....
|
||||
// REF: https://github.com/bluelinelabs/Conductor/issues/612
|
||||
private fun requestColourProfile(context: Context, basePreferences: BasePreferences) =
|
||||
private val requestColourProfile =
|
||||
registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
|
||||
uri?.let {
|
||||
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||
context.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
applicationContext.contentResolver.takePersistableUriPermission(uri, flags)
|
||||
basePreferences.displayProfile().set(uri.toString())
|
||||
}
|
||||
}
|
||||
|
@ -1009,9 +1011,9 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
fun showColourProfilePicker(context: Context, basePreferences: BasePreferences) {
|
||||
fun showColourProfilePicker() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
|
||||
requestColourProfile(context, basePreferences).launch(arrayOf("*/*"))
|
||||
requestColourProfile.launch(arrayOf("*/*"))
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import androidx.lifecycle.lifecycleScope
|
|||
import androidx.preference.PreferenceScreen
|
||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||
import com.google.firebase.ktx.Firebase
|
||||
import com.hippo.unifile.UniFile
|
||||
import dev.yokai.domain.base.BasePreferences.ExtensionInstaller
|
||||
import dev.yokai.domain.extension.TrustExtension
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
|
@ -407,7 +408,12 @@ class SettingsAdvancedController : SettingsController() {
|
|||
key = "pref_display_profile"
|
||||
titleRes = R.string.pref_display_profile
|
||||
onClick {
|
||||
(activity as? MainActivity)?.showColourProfilePicker(context, basePreferences)
|
||||
(activity as? MainActivity)?.showColourProfilePicker()
|
||||
}
|
||||
|
||||
basePreferences.displayProfile().changesIn(viewScope) { path ->
|
||||
val actualPath = UniFile.fromUri(context, path.toUri()).filePath ?: path
|
||||
if (actualPath.isNotEmpty()) summary = actualPath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue