feat: AMOLED dark theme (#282)

* Add AMOLED dark theme

* Minor Fix

* Add compatibility with dynamic colors

* remove onused switch logic

Co-authored-by: Yash Garg <ben10.yashgarg@gmail.com>

* Remove unnecessary statements

* refactor: rename unused variable to `_`

---------

Co-authored-by: Yash Garg <ben10.yashgarg@gmail.com>
Co-authored-by: Jarne Demeulemeester <jarnedemeulemeester@gmail.com>
This commit is contained in:
Xavier Xiong 2023-02-11 15:03:48 +01:00 committed by GitHub
parent e3ea6a1549
commit 2049a857a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 0 deletions

View file

@ -38,6 +38,10 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (appPreferences.amoledTheme) {
setTheme(R.style.Theme_FindroidAMOLED)
}
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

View file

@ -4,6 +4,7 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.ListPreference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import dev.jdtech.jellyfin.R
@Suppress("unused")
@ -19,5 +20,10 @@ class SettingsAppearanceFragment : PreferenceFragmentCompat() {
}
true
}
findPreference<SwitchPreferenceCompat>("pref_amoled_theme")?.setOnPreferenceChangeListener { _, _ ->
requireActivity().recreate()
true
}
}
}

View file

@ -19,4 +19,10 @@
<!-- Extra -->
<item name="dolbyColor">#FFF</item>
</style>
<style name="Theme.FindroidAMOLED" parent="Theme.Findroid">
<!-- Surface -->
<item name="android:colorBackground">@android:color/black</item>
<item name="colorSurface">@android:color/black</item>
</style>
</resources>

View file

@ -130,6 +130,8 @@
<string name="seek_forward_increment">Seek forward increment (ms)</string>
<string name="dynamic_colors">Dynamic colors</string>
<string name="dynamic_colors_summary">Use Material You Dynamic colors (only available on Android 12+)</string>
<string name="amoled_theme">AMOLED dark theme</string>
<string name="amoled_theme_summary">Use AMOLED theme with a pure black background</string>
<string name="subtitles">Subtitles</string>
<string name="subtitles_summary">Customize subtitles appearance</string>
<string name="theme_system">Follow system</string>

View file

@ -12,6 +12,11 @@
app:key="dynamic_colors"
app:summary="@string/dynamic_colors_summary"
app:title="@string/dynamic_colors" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_amoled_theme"
app:summary="@string/amoled_theme_summary"
app:title="@string/amoled_theme" />
<SwitchPreferenceCompat
app:defaultValue="false"
app:key="pref_display_extra_info"

View file

@ -24,6 +24,7 @@ constructor(
// Appearance
val theme get() = sharedPreferences.getString(Constants.PREF_THEME, null)
val dynamicColors get() = sharedPreferences.getBoolean(Constants.PREF_DYNAMIC_COLORS, true)
val amoledTheme get() = sharedPreferences.getBoolean(Constants.PREF_AMOLED_THEME, false)
var displayExtraInfo: Boolean
get() = sharedPreferences.getBoolean(Constants.PREF_DISPLAY_EXTRA_INFO, false)
set(value) {

View file

@ -31,6 +31,7 @@ object Constants {
const val PREF_IMAGE_CACHE_SIZE = "pref_image_cache_size"
const val PREF_THEME = "theme"
const val PREF_DYNAMIC_COLORS = "dynamic_colors"
const val PREF_AMOLED_THEME = "pref_amoled_theme"
const val PREF_NETWORK_REQUEST_TIMEOUT = "pref_network_request_timeout"
const val PREF_NETWORK_CONNECT_TIMEOUT = "pref_network_connect_timeout"
const val PREF_NETWORK_SOCKET_TIMEOUT = "pref_network_socket_timeout"