mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-16 19:50:35 +01:00
Fixed colors and theme changing
Other minor fixes
This commit is contained in:
parent
c4ea2086d2
commit
3dc6df9116
@ -18,7 +18,6 @@ buildscript {
|
||||
classpath gradlePlugins.ktlintGradle
|
||||
classpath gradlePlugins.detekt
|
||||
classpath gradlePlugins.jacoco
|
||||
classpath gradlePlugins.navigationSafeArgs
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ ext.versions = [
|
||||
ktlintGradle : "9.2.1",
|
||||
detekt : "1.0.0.RC6-4",
|
||||
jacoco : "0.8.5",
|
||||
navigationSafeArgs : "2.3.2",
|
||||
preferences : "1.1.1",
|
||||
|
||||
androidSupport : "28.0.0",
|
||||
@ -50,7 +49,6 @@ ext.gradlePlugins = [
|
||||
ktlintGradle : "org.jlleitschuh.gradle:ktlint-gradle:$versions.ktlintGradle",
|
||||
detekt : "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$versions.detekt",
|
||||
jacoco : "org.jacoco:org.jacoco.core:$versions.jacoco",
|
||||
navigationSafeArgs: "androidx.navigation:navigation-safe-args-gradle-plugin:$versions.navigationSafeArgs"
|
||||
]
|
||||
|
||||
ext.androidSupport = [
|
||||
|
@ -2,7 +2,6 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'androidx.navigation.safeargs'
|
||||
apply from: "../gradle_scripts/code_quality.gradle"
|
||||
|
||||
android {
|
||||
|
@ -86,6 +86,7 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
private final Lazy<MediaPlayerController> mediaPlayerControllerLazy = inject(MediaPlayerController.class);
|
||||
private final Lazy<ImageLoaderProvider> imageLoader = inject(ImageLoaderProvider.class);
|
||||
private final Lazy<PermissionUtil> permissionUtil = inject(PermissionUtil.class);
|
||||
private final Lazy<ThemeChangedEventDistributor> themeChangedEventDistributor = inject(ThemeChangedEventDistributor.class);
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@ -195,6 +196,8 @@ public class SettingsFragment extends PreferenceFragmentCompat
|
||||
} else if (Constants.PREFERENCES_KEY_ID3_TAGS.equals(key)) {
|
||||
if (sharedPreferences.getBoolean(key, false)) showArtistPicture.setEnabled(true);
|
||||
else showArtistPicture.setEnabled(false);
|
||||
} else if (Constants.PREFERENCES_KEY_THEME.equals(key)) {
|
||||
themeChangedEventDistributor.getValue().RaiseThemeChangedEvent();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ import org.moire.ultrasonic.util.FileUtil
|
||||
import org.moire.ultrasonic.util.NowPlayingEventDistributor
|
||||
import org.moire.ultrasonic.util.NowPlayingEventListener
|
||||
import org.moire.ultrasonic.util.SubsonicUncaughtExceptionHandler
|
||||
import org.moire.ultrasonic.util.ThemeChangedEventDistributor
|
||||
import org.moire.ultrasonic.util.ThemeChangedEventListener
|
||||
import org.moire.ultrasonic.util.Util
|
||||
import timber.log.Timber
|
||||
|
||||
@ -54,18 +56,19 @@ class NavigationActivity : AppCompatActivity() {
|
||||
var bookmarksMenuItem: MenuItem? = null
|
||||
var sharesMenuItem: MenuItem? = null
|
||||
var podcastsMenuItem: MenuItem? = null
|
||||
private var theme: String? = null
|
||||
var nowPlayingView: FragmentContainerView? = null
|
||||
var nowPlayingHidden = false
|
||||
|
||||
private lateinit var appBarConfiguration : AppBarConfiguration
|
||||
private lateinit var nowPlayingEventListener : NowPlayingEventListener
|
||||
private lateinit var themeChangedEventListener : ThemeChangedEventListener
|
||||
|
||||
private val serverSettingsModel: ServerSettingsModel by viewModel()
|
||||
private val lifecycleSupport: MediaPlayerLifecycleSupport by inject()
|
||||
private val mediaPlayerController: MediaPlayerController by inject()
|
||||
private val imageLoaderProvider: ImageLoaderProvider by inject()
|
||||
private val nowPlayingEventDistributor: NowPlayingEventDistributor by inject()
|
||||
private val themeChangedEventDistributor: ThemeChangedEventDistributor by inject()
|
||||
|
||||
private var infoDialogDisplayed = false
|
||||
private var currentFragmentId: Int = 0
|
||||
@ -118,15 +121,6 @@ class NavigationActivity : AppCompatActivity() {
|
||||
|
||||
// Hides menu items for Offline mode
|
||||
setMenuForServerSetting()
|
||||
|
||||
// TODO: Maybe we can find a better place for theme change. Currently the change occurs when navigating between fragments
|
||||
// but theoretically Settings could request a Navigation Activity recreate instantly when the theme setting changes
|
||||
// Make sure to update theme if it has changed
|
||||
if (theme == null) theme = Util.getTheme(this)
|
||||
else if (theme != Util.getTheme(this)) {
|
||||
theme = Util.getTheme(this)
|
||||
recreate()
|
||||
}
|
||||
}
|
||||
|
||||
// Determine first run and migrate server settings to DB as early as possible
|
||||
@ -154,7 +148,12 @@ class NavigationActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
themeChangedEventListener = object : ThemeChangedEventListener {
|
||||
override fun onThemeChanged() { recreate() }
|
||||
}
|
||||
|
||||
nowPlayingEventDistributor.subscribe(nowPlayingEventListener)
|
||||
themeChangedEventDistributor.subscribe(themeChangedEventListener)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -173,6 +172,7 @@ class NavigationActivity : AppCompatActivity() {
|
||||
super.onDestroy()
|
||||
Util.unregisterMediaButtonEventReceiver(this, false)
|
||||
nowPlayingEventDistributor.unsubscribe(nowPlayingEventListener)
|
||||
themeChangedEventDistributor.unsubscribe(themeChangedEventListener)
|
||||
imageLoaderProvider.clearImageLoader()
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,12 @@ import org.moire.ultrasonic.data.ActiveServerProvider
|
||||
import org.moire.ultrasonic.subsonic.ImageLoaderProvider
|
||||
import org.moire.ultrasonic.util.NowPlayingEventDistributor
|
||||
import org.moire.ultrasonic.util.PermissionUtil
|
||||
import org.moire.ultrasonic.util.ThemeChangedEventDistributor
|
||||
|
||||
val applicationModule = module {
|
||||
single { ActiveServerProvider(get(), androidContext()) }
|
||||
single { ImageLoaderProvider(androidContext()) }
|
||||
single { PermissionUtil(androidContext()) }
|
||||
single { NowPlayingEventDistributor() }
|
||||
single { ThemeChangedEventDistributor() }
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package org.moire.ultrasonic.util
|
||||
|
||||
class ThemeChangedEventDistributor {
|
||||
var eventListenerList: MutableList<ThemeChangedEventListener> = listOf<ThemeChangedEventListener>().toMutableList()
|
||||
|
||||
fun subscribe(listener: ThemeChangedEventListener) {
|
||||
eventListenerList.add(listener)
|
||||
}
|
||||
|
||||
fun unsubscribe(listener: ThemeChangedEventListener) {
|
||||
eventListenerList.remove(listener)
|
||||
}
|
||||
|
||||
fun RaiseThemeChangedEvent() {
|
||||
eventListenerList.forEach{ listener -> listener.onThemeChanged() }
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package org.moire.ultrasonic.util
|
||||
|
||||
interface ThemeChangedEventListener {
|
||||
fun onThemeChanged()
|
||||
}
|
@ -4,6 +4,6 @@
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFF"
|
||||
android:fillColor="#DDD"
|
||||
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
|
||||
</vector>
|
||||
|
@ -4,6 +4,6 @@
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#000"
|
||||
android:fillColor="#222"
|
||||
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
|
||||
</vector>
|
||||
|
@ -4,6 +4,6 @@
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFF"
|
||||
android:fillColor="#DDD"
|
||||
android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z"/>
|
||||
</vector>
|
||||
|
@ -4,6 +4,6 @@
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#000"
|
||||
android:fillColor="#222"
|
||||
android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z"/>
|
||||
</vector>
|
||||
|
@ -44,7 +44,8 @@
|
||||
a:layout_height="match_parent"
|
||||
a:layout_gravity="start"
|
||||
a:fitsSystemWindows="true"
|
||||
a:background="?attr/color_menu_background"
|
||||
a:theme="@style/ThemeOverlay.AppCompat.navTheme"
|
||||
app:headerLayout="@layout/navigation_header"
|
||||
app:menu="@menu/navigation"/>
|
||||
app:menu="@menu/navigation" />
|
||||
</androidx.drawerlayout.widget.DrawerLayout>
|
@ -11,4 +11,9 @@
|
||||
<color name="background_color_light">#fff3f3f3</color>
|
||||
<color name="selected_color_dark">#424242</color>
|
||||
<color name="selected_color_light">#B1B1B1</color>
|
||||
<color name="selected_menu_dark">#fff3f3f3</color>
|
||||
<color name="selected_menu_light">#ff000000</color>
|
||||
<color name="selected_menu_background_dark">#ff333333</color>
|
||||
<color name="selected_menu_background_black">#ff111111</color>
|
||||
<color name="selected_menu_background_light">#fff3f3f3</color>
|
||||
</resources>
|
@ -26,7 +26,7 @@
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.AppCompat.navTheme">
|
||||
<item name="colorPrimary">@color/cyan</item>
|
||||
<item name="colorPrimary">?attr/color_menu_selected</item>
|
||||
<item name="colorControlHighlight">?attr/color_selected</item>
|
||||
</style>
|
||||
|
||||
@ -79,6 +79,8 @@
|
||||
<attr name="button_check_custom" format="reference"/>
|
||||
<attr name="color_background" format="reference"/>
|
||||
<attr name="color_selected" format="reference"/>
|
||||
<attr name="color_menu_selected" format="reference"/>
|
||||
<attr name="color_menu_background" format="reference"/>
|
||||
<attr name="filepicker_create_new_folder" format="reference"/>
|
||||
<attr name="filepicker_folder" format="reference"/>
|
||||
<attr name="filepicker_subdirectory_left" format="reference"/>
|
||||
|
@ -5,6 +5,8 @@
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="color_background">@color/background_color_dark</item>
|
||||
<item name="color_selected">@color/selected_color_dark</item>
|
||||
<item name="color_menu_selected">@color/selected_menu_dark</item>
|
||||
<item name="color_menu_background">@color/selected_menu_background_black</item>
|
||||
<item name="star_hollow">@drawable/ic_star_hollow_dark</item>
|
||||
<item name="star_full">@drawable/ic_star_full_dark</item>
|
||||
<item name="about">@drawable/ic_menu_about_dark</item>
|
||||
@ -65,6 +67,8 @@
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="color_background">@color/background_color_dark</item>
|
||||
<item name="color_selected">@color/selected_color_dark</item>
|
||||
<item name="color_menu_selected">@color/selected_menu_dark</item>
|
||||
<item name="color_menu_background">@color/selected_menu_background_dark</item>
|
||||
<item name="star_hollow">@drawable/ic_star_hollow_dark</item>
|
||||
<item name="star_full">@drawable/ic_star_full_dark</item>
|
||||
<item name="about">@drawable/ic_menu_about_dark</item>
|
||||
@ -125,6 +129,8 @@
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="color_background">@color/background_color_light</item>
|
||||
<item name="color_selected">@color/selected_color_light</item>
|
||||
<item name="color_menu_selected">@color/selected_menu_light</item>
|
||||
<item name="color_menu_background">@color/selected_menu_background_light</item>
|
||||
<item name="star_hollow">@drawable/ic_star_hollow_light</item>
|
||||
<item name="star_full">@drawable/ic_star_full_light</item>
|
||||
<item name="about">@drawable/ic_menu_about_light</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user