mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-16 19:50:35 +01:00
Deactivate custom color and set DB to version 3
This commit is contained in:
parent
fd239e8e72
commit
f68b46678a
@ -208,8 +208,8 @@ class NavigationActivity : AppCompatActivity() {
|
||||
selectServerButton?.text = getString(R.string.main_setup_server, activeServer.name)
|
||||
else selectServerButton?.text = activeServer.name
|
||||
|
||||
val foregroundColor = ServerColor.getForegroundColor(this, activeServer.color)
|
||||
val backgroundColor = ServerColor.getBackgroundColor(this, activeServer.color)
|
||||
val foregroundColor = ServerColor.getForegroundColor(this, null)
|
||||
val backgroundColor = ServerColor.getBackgroundColor(this, null)
|
||||
|
||||
if (activeServer.index == 0)
|
||||
selectServerButton?.icon =
|
||||
|
@ -108,8 +108,8 @@ internal class ServerRowAdapter(
|
||||
}
|
||||
|
||||
// Set colors
|
||||
icon?.setTint(ServerColor.getForegroundColor(context, setting?.color))
|
||||
background?.setTint(ServerColor.getBackgroundColor(context, setting?.color))
|
||||
icon?.setTint(ServerColor.getForegroundColor(context, null))
|
||||
background?.setTint(ServerColor.getBackgroundColor(context, null))
|
||||
|
||||
// Set the final drawables
|
||||
image?.setImageDrawable(icon)
|
||||
|
@ -9,7 +9,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
* Room Database to be used to store global data for the whole app.
|
||||
* This could be settings or data that are not specific to any remote music database
|
||||
*/
|
||||
@Database(entities = [ServerSetting::class], version = 4)
|
||||
@Database(entities = [ServerSetting::class], version = 3)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,6 @@ data class ServerSetting(
|
||||
@ColumnInfo(name = "index") var index: Int,
|
||||
@ColumnInfo(name = "name") var name: String,
|
||||
@ColumnInfo(name = "url") var url: String,
|
||||
@ColumnInfo(name = "color") var color: Int? = null,
|
||||
@ColumnInfo(name = "userName") var userName: String,
|
||||
@ColumnInfo(name = "password") var password: String,
|
||||
@ColumnInfo(name = "jukeboxByDefault") var jukeboxByDefault: Boolean,
|
||||
@ -37,9 +36,9 @@ data class ServerSetting(
|
||||
@ColumnInfo(name = "podcastSupport") var podcastSupport: Boolean? = null
|
||||
) {
|
||||
constructor() : this (
|
||||
-1, 0, "", "", null, "", "", false, false, false, null, null
|
||||
-1, 0, "", "", "", "", false, false, false, null, null
|
||||
)
|
||||
constructor(name: String, url: String) : this(
|
||||
-1, 0, name, url, null, "", "", false, false, false, null, null
|
||||
-1, 0, name, url, "", "", false, false, false, null, null
|
||||
)
|
||||
}
|
||||
|
@ -7,14 +7,11 @@ import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.ImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.skydoves.colorpickerview.ColorPickerDialog
|
||||
import com.skydoves.colorpickerview.flag.BubbleFlag
|
||||
import com.skydoves.colorpickerview.flag.FlagMode
|
||||
import com.skydoves.colorpickerview.listeners.ColorEnvelopeListener
|
||||
import java.io.IOException
|
||||
import java.net.MalformedURLException
|
||||
import java.net.URL
|
||||
@ -43,8 +40,6 @@ import org.moire.ultrasonic.util.Util
|
||||
import retrofit2.Response
|
||||
import timber.log.Timber
|
||||
|
||||
private const val DIALOG_PADDING = 12
|
||||
|
||||
/**
|
||||
* Displays a form where server settings can be created / edited
|
||||
*/
|
||||
@ -147,7 +142,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
||||
} else {
|
||||
// Creating a new server
|
||||
FragmentTitle.setTitle(this, R.string.server_editor_new_label)
|
||||
updateColor(null)
|
||||
// updateColor(null)
|
||||
currentServerSetting = ServerSetting()
|
||||
saveButton!!.setOnClickListener {
|
||||
if (getFields()) {
|
||||
@ -163,33 +158,36 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
||||
}
|
||||
}
|
||||
|
||||
serverColorImageView!!.setOnClickListener {
|
||||
val bubbleFlag = BubbleFlag(context)
|
||||
bubbleFlag.flagMode = FlagMode.LAST
|
||||
ColorPickerDialog.Builder(context).apply {
|
||||
this.colorPickerView.setInitialColor(currentColor)
|
||||
this.colorPickerView.flagView = bubbleFlag
|
||||
}
|
||||
.attachAlphaSlideBar(false)
|
||||
.setPositiveButton(
|
||||
getString(R.string.common_ok),
|
||||
ColorEnvelopeListener { envelope, _ ->
|
||||
selectedColor = envelope.color
|
||||
updateColor(envelope.color)
|
||||
}
|
||||
)
|
||||
.setNegativeButton(getString(R.string.common_cancel)) {
|
||||
dialogInterface, _ ->
|
||||
dialogInterface.dismiss()
|
||||
}
|
||||
.setBottomSpace(DIALOG_PADDING)
|
||||
.show()
|
||||
}
|
||||
// serverColorImageView!!.setOnClickListener {
|
||||
// val bubbleFlag = BubbleFlag(context)
|
||||
// bubbleFlag.flagMode = FlagMode.LAST
|
||||
// ColorPickerDialog.Builder(context).apply {
|
||||
// this.colorPickerView.setInitialColor(currentColor)
|
||||
// this.colorPickerView.flagView = bubbleFlag
|
||||
// }
|
||||
// .attachAlphaSlideBar(false)
|
||||
// .setPositiveButton(
|
||||
// getString(R.string.common_ok),
|
||||
// ColorEnvelopeListener { envelope, _ ->
|
||||
// selectedColor = envelope.color
|
||||
// updateColor(envelope.color)
|
||||
// }
|
||||
// )
|
||||
// .setNegativeButton(getString(R.string.common_cancel)) {
|
||||
// dialogInterface, _ ->
|
||||
// dialogInterface.dismiss()
|
||||
// }
|
||||
// .setBottomSpace(DIALOG_PADDING)
|
||||
// .show()
|
||||
// }
|
||||
|
||||
serverColorImageView?.isVisible = false
|
||||
}
|
||||
|
||||
private fun updateColor(color: Int?) {
|
||||
@Suppress("unused")
|
||||
private fun updateColor() {
|
||||
val image = ContextCompat.getDrawable(requireContext(), R.drawable.thumb_drawable)
|
||||
currentColor = ServerColor.getBackgroundColor(requireContext(), color)
|
||||
currentColor = ServerColor.getBackgroundColor(requireContext(), null)
|
||||
image?.setTint(currentColor)
|
||||
serverColorImageView?.background = image
|
||||
}
|
||||
@ -254,7 +252,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
||||
selfSignedSwitch!!.isChecked = savedInstanceState.getBoolean(::selfSignedSwitch.name)
|
||||
ldapSwitch!!.isChecked = savedInstanceState.getBoolean(::ldapSwitch.name)
|
||||
jukeboxSwitch!!.isChecked = savedInstanceState.getBoolean(::jukeboxSwitch.name)
|
||||
updateColor(savedInstanceState.getInt(::serverColorImageView.name))
|
||||
// updateColor(savedInstanceState.getInt(::serverColorImageView.name))
|
||||
if (savedInstanceState.containsKey(::selectedColor.name))
|
||||
selectedColor = savedInstanceState.getInt(::selectedColor.name)
|
||||
isInstanceStateSaved = savedInstanceState.getBoolean(::isInstanceStateSaved.name)
|
||||
@ -273,7 +271,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
||||
selfSignedSwitch!!.isChecked = currentServerSetting!!.allowSelfSignedCertificate
|
||||
ldapSwitch!!.isChecked = currentServerSetting!!.ldapSupport
|
||||
jukeboxSwitch!!.isChecked = currentServerSetting!!.jukeboxByDefault
|
||||
updateColor(currentServerSetting!!.color)
|
||||
// updateColor(currentServerSetting!!.color)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,7 +320,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
||||
if (isValid) {
|
||||
currentServerSetting!!.name = serverNameEditText!!.editText?.text.toString()
|
||||
currentServerSetting!!.url = serverAddressEditText!!.editText?.text.toString()
|
||||
currentServerSetting!!.color = selectedColor
|
||||
// currentServerSetting!!.color = selectedColor
|
||||
currentServerSetting!!.userName = userNameEditText!!.editText?.text.toString()
|
||||
currentServerSetting!!.password = passwordEditText!!.editText?.text.toString()
|
||||
currentServerSetting!!.allowSelfSignedCertificate = selfSignedSwitch!!.isChecked
|
||||
|
@ -212,7 +212,6 @@ class ServerSettingsModel(
|
||||
serverId,
|
||||
settings.getString(PREFERENCES_KEY_SERVER_NAME + preferenceId, "")!!,
|
||||
url,
|
||||
null,
|
||||
userName,
|
||||
settings.getString(PREFERENCES_KEY_PASSWORD + preferenceId, "")!!,
|
||||
settings.getBoolean(PREFERENCES_KEY_JUKEBOX_BY_DEFAULT + preferenceId, false),
|
||||
|
Loading…
x
Reference in New Issue
Block a user