mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-05-03 09:01:33 +03:00
Merge branch 'feature/bunch-of-fixes' into 'develop'
Fixed DI to make the widget work See merge request ultrasonic/ultrasonic!1204
This commit is contained in:
commit
006c554456
@ -13,7 +13,7 @@ buildscript {
|
|||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven { url "https://plugins.gradle.org/m2/" }
|
maven { url = "https://plugins.gradle.org/m2/" }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath libs.gradle
|
classpath libs.gradle
|
||||||
@ -55,6 +55,6 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wrapper {
|
wrapper {
|
||||||
gradleVersion(libs.versions.gradle.get())
|
gradleVersion = libs.versions.gradle.get()
|
||||||
distributionType("all")
|
distributionType = "all"
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'org.moire.ultrasonic.subsonic.domain'
|
namespace = 'org.moire.ultrasonic.subsonic.domain'
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_21
|
sourceCompatibility JavaVersion.VERSION_21
|
||||||
targetCompatibility JavaVersion.VERSION_21
|
targetCompatibility JavaVersion.VERSION_21
|
||||||
|
@ -34,10 +34,10 @@ android {
|
|||||||
'minify/proguard-kotlin.pro'
|
'minify/proguard-kotlin.pro'
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
minifyEnabled false
|
minifyEnabled = false
|
||||||
multiDexEnabled true
|
multiDexEnabled = true
|
||||||
testCoverageEnabled true
|
testCoverageEnabled = true
|
||||||
applicationIdSuffix '.debug'
|
applicationIdSuffix = '.debug'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,9 +57,9 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding = true
|
||||||
dataBinding true
|
dataBinding = true
|
||||||
buildConfig true
|
buildConfig = true
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
@ -73,8 +73,8 @@ android {
|
|||||||
|
|
||||||
lint {
|
lint {
|
||||||
baseline = file("lint-baseline.xml")
|
baseline = file("lint-baseline.xml")
|
||||||
abortOnError true
|
abortOnError = true
|
||||||
warningsAsErrors true
|
warningsAsErrors = true
|
||||||
warning 'ImpliedQuantity'
|
warning 'ImpliedQuantity'
|
||||||
disable 'IconMissingDensityFolder', 'VectorPath'
|
disable 'IconMissingDensityFolder', 'VectorPath'
|
||||||
disable 'MissingTranslation', 'UnusedQuantity', 'MissingQuantity'
|
disable 'MissingTranslation', 'UnusedQuantity', 'MissingQuantity'
|
||||||
@ -82,10 +82,10 @@ android {
|
|||||||
// We manage dependencies on Gitlab with RenovateBot
|
// We manage dependencies on Gitlab with RenovateBot
|
||||||
disable 'GradleDependency'
|
disable 'GradleDependency'
|
||||||
disable 'AndroidGradlePluginVersion'
|
disable 'AndroidGradlePluginVersion'
|
||||||
textReport true
|
textReport = true
|
||||||
checkDependencies true
|
checkDependencies = true
|
||||||
}
|
}
|
||||||
namespace 'org.moire.ultrasonic'
|
namespace = 'org.moire.ultrasonic'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import android.content.Intent
|
|||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.provider.SearchRecentSuggestions
|
import android.provider.SearchRecentSuggestions
|
||||||
@ -96,6 +95,7 @@ class NavigationActivity : ScopeActivity() {
|
|||||||
private var drawerLayout: DrawerLayout? = null
|
private var drawerLayout: DrawerLayout? = null
|
||||||
private var host: NavHostFragment? = null
|
private var host: NavHostFragment? = null
|
||||||
private var selectServerButton: MaterialButton? = null
|
private var selectServerButton: MaterialButton? = null
|
||||||
|
private var selectServerDropdownImage: ImageView? = null
|
||||||
private var headerBackgroundImage: ImageView? = null
|
private var headerBackgroundImage: ImageView? = null
|
||||||
|
|
||||||
// We store the last search string in this variable.
|
// We store the last search string in this variable.
|
||||||
@ -165,7 +165,7 @@ class NavigationActivity : ScopeActivity() {
|
|||||||
drawerLayout
|
drawerLayout
|
||||||
)
|
)
|
||||||
|
|
||||||
setupActionBar(navController, appBarConfiguration)
|
setupActionBarWithNavController(navController, appBarConfiguration)
|
||||||
|
|
||||||
setupNavigationMenu(navController)
|
setupNavigationMenu(navController)
|
||||||
|
|
||||||
@ -333,9 +333,6 @@ class NavigationActivity : ScopeActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateNavigationHeaderForServer() {
|
private fun updateNavigationHeaderForServer() {
|
||||||
// Only show the vector graphic on Android 11 or earlier
|
|
||||||
val showVectorBackground = (Build.VERSION.SDK_INT < Build.VERSION_CODES.S)
|
|
||||||
|
|
||||||
val activeServer = activeServerProvider.getActiveServer()
|
val activeServer = activeServerProvider.getActiveServer()
|
||||||
|
|
||||||
if (cachedServerCount == 0) {
|
if (cachedServerCount == 0) {
|
||||||
@ -345,7 +342,7 @@ class NavigationActivity : ScopeActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val foregroundColor =
|
val foregroundColor =
|
||||||
ServerColor.getForegroundColor(this, activeServer.color, showVectorBackground)
|
ServerColor.getForegroundColor(this, activeServer.color)
|
||||||
val backgroundColor =
|
val backgroundColor =
|
||||||
ServerColor.getBackgroundColor(this, activeServer.color)
|
ServerColor.getBackgroundColor(this, activeServer.color)
|
||||||
|
|
||||||
@ -359,12 +356,8 @@ class NavigationActivity : ScopeActivity() {
|
|||||||
|
|
||||||
selectServerButton?.iconTint = ColorStateList.valueOf(foregroundColor)
|
selectServerButton?.iconTint = ColorStateList.valueOf(foregroundColor)
|
||||||
selectServerButton?.setTextColor(foregroundColor)
|
selectServerButton?.setTextColor(foregroundColor)
|
||||||
|
selectServerDropdownImage?.imageTintList = ColorStateList.valueOf(foregroundColor)
|
||||||
headerBackgroundImage?.setBackgroundColor(backgroundColor)
|
headerBackgroundImage?.setBackgroundColor(backgroundColor)
|
||||||
|
|
||||||
// Hide the vector graphic on Android 12 or later
|
|
||||||
if (!showVectorBackground) {
|
|
||||||
headerBackgroundImage?.setImageDrawable(null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupNavigationMenu(navController: NavController) {
|
private fun setupNavigationMenu(navController: NavController) {
|
||||||
@ -409,7 +402,7 @@ class NavigationActivity : ScopeActivity() {
|
|||||||
|
|
||||||
selectServerButton =
|
selectServerButton =
|
||||||
navigationView?.getHeaderView(0)?.findViewById(R.id.header_select_server)
|
navigationView?.getHeaderView(0)?.findViewById(R.id.header_select_server)
|
||||||
val dropDownButton: ImageView? =
|
selectServerDropdownImage =
|
||||||
navigationView?.getHeaderView(0)?.findViewById(R.id.edit_server_button)
|
navigationView?.getHeaderView(0)?.findViewById(R.id.edit_server_button)
|
||||||
|
|
||||||
val onClick: (View) -> Unit = {
|
val onClick: (View) -> Unit = {
|
||||||
@ -420,16 +413,12 @@ class NavigationActivity : ScopeActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectServerButton?.setOnClickListener(onClick)
|
selectServerButton?.setOnClickListener(onClick)
|
||||||
dropDownButton?.setOnClickListener(onClick)
|
selectServerDropdownImage?.setOnClickListener(onClick)
|
||||||
|
|
||||||
headerBackgroundImage =
|
headerBackgroundImage =
|
||||||
navigationView?.getHeaderView(0)?.findViewById(R.id.img_header_bg)
|
navigationView?.getHeaderView(0)?.findViewById(R.id.img_header_bg)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupActionBar(navController: NavController, appBarConfig: AppBarConfiguration) {
|
|
||||||
setupActionBarWithNavController(navController, appBarConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val closeNavigationDrawerOnBack = object : OnBackPressedCallback(true) {
|
private val closeNavigationDrawerOnBack = object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
drawerLayout?.closeDrawer(GravityCompat.START)
|
drawerLayout?.closeDrawer(GravityCompat.START)
|
||||||
@ -446,13 +435,21 @@ class NavigationActivity : ScopeActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
// Skip android.R.id.home so the drawer button doesn't get wrongly routed
|
||||||
|
if (item.itemId == android.R.id.home) {
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
return item.onNavDestinationSelected(findNavController(R.id.nav_host_fragment)) ||
|
return item.onNavDestinationSelected(findNavController(R.id.nav_host_fragment)) ||
|
||||||
super.onOptionsItemSelected(item)
|
super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Why is this needed? Shouldn't it just work by default?
|
|
||||||
override fun onSupportNavigateUp(): Boolean {
|
override fun onSupportNavigateUp(): Boolean {
|
||||||
return findNavController(R.id.nav_host_fragment).navigateUp(appBarConfiguration)
|
// This override is required by design when using setupActionBarWithNavController()
|
||||||
|
// with an AppBarConfiguration. It ensures that the Up button behavior is correctly
|
||||||
|
// delegated — either navigating "up" in the back stack, or opening the drawer if
|
||||||
|
// we're at a top-level destination.
|
||||||
|
return findNavController(R.id.nav_host_fragment).navigateUp(appBarConfiguration) ||
|
||||||
|
super.onSupportNavigateUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.moire.ultrasonic.di
|
package org.moire.ultrasonic.di
|
||||||
|
|
||||||
import org.koin.dsl.module
|
import org.koin.dsl.module
|
||||||
import org.moire.ultrasonic.activity.NavigationActivity
|
|
||||||
import org.moire.ultrasonic.service.ExternalStorageMonitor
|
import org.moire.ultrasonic.service.ExternalStorageMonitor
|
||||||
import org.moire.ultrasonic.service.MediaPlayerLifecycleSupport
|
import org.moire.ultrasonic.service.MediaPlayerLifecycleSupport
|
||||||
import org.moire.ultrasonic.service.MediaPlayerManager
|
import org.moire.ultrasonic.service.MediaPlayerManager
|
||||||
@ -20,8 +19,7 @@ val mediaPlayerModule = module {
|
|||||||
single { NetworkAndStorageChecker() }
|
single { NetworkAndStorageChecker() }
|
||||||
single { ShareHandler() }
|
single { ShareHandler() }
|
||||||
|
|
||||||
scope<NavigationActivity> {
|
// These MUST be singletons, for the media playback must work headless (without an activity)
|
||||||
scoped { MediaPlayerManager(get(), get()) }
|
single { MediaPlayerManager(get(), get()) }
|
||||||
scoped { MediaPlayerLifecycleSupport(get(), get(), get(), get()) }
|
single { MediaPlayerLifecycleSupport(get(), get(), get(), get()) }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import androidx.core.graphics.ColorUtils
|
|||||||
import com.google.android.material.color.MaterialColors
|
import com.google.android.material.color.MaterialColors
|
||||||
|
|
||||||
private const val LUMINANCE_LIMIT = 0.5
|
private const val LUMINANCE_LIMIT = 0.5
|
||||||
private const val LUMINANCE_CORRECTION = -0.25
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains functions for computing server display colors
|
* Contains functions for computing server display colors
|
||||||
@ -31,17 +30,9 @@ object ServerColor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun getForegroundColor(
|
fun getForegroundColor(context: Context, serverColor: Int?): Int {
|
||||||
context: Context,
|
|
||||||
serverColor: Int?,
|
|
||||||
showVectorBackground: Boolean = false
|
|
||||||
): Int {
|
|
||||||
val backgroundColor = getBackgroundColor(context, serverColor)
|
val backgroundColor = getBackgroundColor(context, serverColor)
|
||||||
var luminance = ColorUtils.calculateLuminance(backgroundColor)
|
val luminance = ColorUtils.calculateLuminance(backgroundColor)
|
||||||
|
|
||||||
// The actual luminance is a good bit lower
|
|
||||||
// when the background color is being overlayed by the vector
|
|
||||||
if (showVectorBackground) luminance += LUMINANCE_CORRECTION
|
|
||||||
|
|
||||||
return if (luminance < LUMINANCE_LIMIT) {
|
return if (luminance < LUMINANCE_LIMIT) {
|
||||||
ContextCompat.getColor(context, org.moire.ultrasonic.R.color.selected_menu_dark)
|
ContextCompat.getColor(context, org.moire.ultrasonic.R.color.selected_menu_dark)
|
||||||
|
@ -52,11 +52,10 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
a:id="@+id/edit_server_button"
|
a:id="@+id/edit_server_button"
|
||||||
style="@style/Widget.Material3.Button.TextButton.Icon"
|
a:layout_width="40dp"
|
||||||
a:layout_width="wrap_content"
|
|
||||||
a:layout_height="0dp"
|
a:layout_height="0dp"
|
||||||
a:layout_marginTop="6dp"
|
a:layout_marginVertical="6dp"
|
||||||
a:layout_marginBottom="6dp"
|
a:layout_marginHorizontal="20dp"
|
||||||
a:contentDescription="@string/server_menu.edit"
|
a:contentDescription="@string/server_menu.edit"
|
||||||
a:maxHeight="32dp"
|
a:maxHeight="32dp"
|
||||||
a:src="@drawable/arrow_drop_down"
|
a:src="@drawable/arrow_drop_down"
|
||||||
@ -65,7 +64,6 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/header_select_server"
|
app:layout_constraintStart_toEndOf="@id/header_select_server"
|
||||||
app:layout_constraintTop_toTopOf="@id/header_select_server"
|
app:layout_constraintTop_toTopOf="@id/header_select_server"
|
||||||
app:strokeColor="@null"
|
|
||||||
app:tint="@color/selected_menu_dark" />
|
app:tint="@color/selected_menu_dark" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
x
Reference in New Issue
Block a user