Deactivate custom color and set DB to version 3

This commit is contained in:
tzugen 2022-01-13 15:31:21 +01:00
parent fd239e8e72
commit f68b46678a
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
6 changed files with 39 additions and 43 deletions

View File

@ -208,8 +208,8 @@ class NavigationActivity : AppCompatActivity() {
selectServerButton?.text = getString(R.string.main_setup_server, activeServer.name) selectServerButton?.text = getString(R.string.main_setup_server, activeServer.name)
else selectServerButton?.text = activeServer.name else selectServerButton?.text = activeServer.name
val foregroundColor = ServerColor.getForegroundColor(this, activeServer.color) val foregroundColor = ServerColor.getForegroundColor(this, null)
val backgroundColor = ServerColor.getBackgroundColor(this, activeServer.color) val backgroundColor = ServerColor.getBackgroundColor(this, null)
if (activeServer.index == 0) if (activeServer.index == 0)
selectServerButton?.icon = selectServerButton?.icon =

View File

@ -108,8 +108,8 @@ internal class ServerRowAdapter(
} }
// Set colors // Set colors
icon?.setTint(ServerColor.getForegroundColor(context, setting?.color)) icon?.setTint(ServerColor.getForegroundColor(context, null))
background?.setTint(ServerColor.getBackgroundColor(context, setting?.color)) background?.setTint(ServerColor.getBackgroundColor(context, null))
// Set the final drawables // Set the final drawables
image?.setImageDrawable(icon) image?.setImageDrawable(icon)

View File

@ -9,7 +9,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase
* Room Database to be used to store global data for the whole app. * 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 * 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() { abstract class AppDatabase : RoomDatabase() {
/** /**

View File

@ -23,7 +23,6 @@ data class ServerSetting(
@ColumnInfo(name = "index") var index: Int, @ColumnInfo(name = "index") var index: Int,
@ColumnInfo(name = "name") var name: String, @ColumnInfo(name = "name") var name: String,
@ColumnInfo(name = "url") var url: String, @ColumnInfo(name = "url") var url: String,
@ColumnInfo(name = "color") var color: Int? = null,
@ColumnInfo(name = "userName") var userName: String, @ColumnInfo(name = "userName") var userName: String,
@ColumnInfo(name = "password") var password: String, @ColumnInfo(name = "password") var password: String,
@ColumnInfo(name = "jukeboxByDefault") var jukeboxByDefault: Boolean, @ColumnInfo(name = "jukeboxByDefault") var jukeboxByDefault: Boolean,
@ -37,9 +36,9 @@ data class ServerSetting(
@ColumnInfo(name = "podcastSupport") var podcastSupport: Boolean? = null @ColumnInfo(name = "podcastSupport") var podcastSupport: Boolean? = null
) { ) {
constructor() : this ( constructor() : this (
-1, 0, "", "", null, "", "", false, false, false, null, null -1, 0, "", "", "", "", false, false, false, null, null
) )
constructor(name: String, url: String) : this( 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
) )
} }

View File

@ -7,14 +7,11 @@ import android.view.ViewGroup
import android.widget.Button import android.widget.Button
import android.widget.ImageView import android.widget.ImageView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController import androidx.navigation.fragment.findNavController
import com.google.android.material.switchmaterial.SwitchMaterial import com.google.android.material.switchmaterial.SwitchMaterial
import com.google.android.material.textfield.TextInputLayout 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.io.IOException
import java.net.MalformedURLException import java.net.MalformedURLException
import java.net.URL import java.net.URL
@ -43,8 +40,6 @@ import org.moire.ultrasonic.util.Util
import retrofit2.Response import retrofit2.Response
import timber.log.Timber import timber.log.Timber
private const val DIALOG_PADDING = 12
/** /**
* Displays a form where server settings can be created / edited * Displays a form where server settings can be created / edited
*/ */
@ -147,7 +142,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
} else { } else {
// Creating a new server // Creating a new server
FragmentTitle.setTitle(this, R.string.server_editor_new_label) FragmentTitle.setTitle(this, R.string.server_editor_new_label)
updateColor(null) // updateColor(null)
currentServerSetting = ServerSetting() currentServerSetting = ServerSetting()
saveButton!!.setOnClickListener { saveButton!!.setOnClickListener {
if (getFields()) { if (getFields()) {
@ -163,33 +158,36 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
} }
} }
serverColorImageView!!.setOnClickListener { // serverColorImageView!!.setOnClickListener {
val bubbleFlag = BubbleFlag(context) // val bubbleFlag = BubbleFlag(context)
bubbleFlag.flagMode = FlagMode.LAST // bubbleFlag.flagMode = FlagMode.LAST
ColorPickerDialog.Builder(context).apply { // ColorPickerDialog.Builder(context).apply {
this.colorPickerView.setInitialColor(currentColor) // this.colorPickerView.setInitialColor(currentColor)
this.colorPickerView.flagView = bubbleFlag // this.colorPickerView.flagView = bubbleFlag
} // }
.attachAlphaSlideBar(false) // .attachAlphaSlideBar(false)
.setPositiveButton( // .setPositiveButton(
getString(R.string.common_ok), // getString(R.string.common_ok),
ColorEnvelopeListener { envelope, _ -> // ColorEnvelopeListener { envelope, _ ->
selectedColor = envelope.color // selectedColor = envelope.color
updateColor(envelope.color) // updateColor(envelope.color)
} // }
) // )
.setNegativeButton(getString(R.string.common_cancel)) { // .setNegativeButton(getString(R.string.common_cancel)) {
dialogInterface, _ -> // dialogInterface, _ ->
dialogInterface.dismiss() // dialogInterface.dismiss()
} // }
.setBottomSpace(DIALOG_PADDING) // .setBottomSpace(DIALOG_PADDING)
.show() // .show()
} // }
serverColorImageView?.isVisible = false
} }
private fun updateColor(color: Int?) { @Suppress("unused")
private fun updateColor() {
val image = ContextCompat.getDrawable(requireContext(), R.drawable.thumb_drawable) val image = ContextCompat.getDrawable(requireContext(), R.drawable.thumb_drawable)
currentColor = ServerColor.getBackgroundColor(requireContext(), color) currentColor = ServerColor.getBackgroundColor(requireContext(), null)
image?.setTint(currentColor) image?.setTint(currentColor)
serverColorImageView?.background = image serverColorImageView?.background = image
} }
@ -254,7 +252,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
selfSignedSwitch!!.isChecked = savedInstanceState.getBoolean(::selfSignedSwitch.name) selfSignedSwitch!!.isChecked = savedInstanceState.getBoolean(::selfSignedSwitch.name)
ldapSwitch!!.isChecked = savedInstanceState.getBoolean(::ldapSwitch.name) ldapSwitch!!.isChecked = savedInstanceState.getBoolean(::ldapSwitch.name)
jukeboxSwitch!!.isChecked = savedInstanceState.getBoolean(::jukeboxSwitch.name) jukeboxSwitch!!.isChecked = savedInstanceState.getBoolean(::jukeboxSwitch.name)
updateColor(savedInstanceState.getInt(::serverColorImageView.name)) // updateColor(savedInstanceState.getInt(::serverColorImageView.name))
if (savedInstanceState.containsKey(::selectedColor.name)) if (savedInstanceState.containsKey(::selectedColor.name))
selectedColor = savedInstanceState.getInt(::selectedColor.name) selectedColor = savedInstanceState.getInt(::selectedColor.name)
isInstanceStateSaved = savedInstanceState.getBoolean(::isInstanceStateSaved.name) isInstanceStateSaved = savedInstanceState.getBoolean(::isInstanceStateSaved.name)
@ -273,7 +271,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
selfSignedSwitch!!.isChecked = currentServerSetting!!.allowSelfSignedCertificate selfSignedSwitch!!.isChecked = currentServerSetting!!.allowSelfSignedCertificate
ldapSwitch!!.isChecked = currentServerSetting!!.ldapSupport ldapSwitch!!.isChecked = currentServerSetting!!.ldapSupport
jukeboxSwitch!!.isChecked = currentServerSetting!!.jukeboxByDefault jukeboxSwitch!!.isChecked = currentServerSetting!!.jukeboxByDefault
updateColor(currentServerSetting!!.color) // updateColor(currentServerSetting!!.color)
} }
/** /**
@ -322,7 +320,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
if (isValid) { if (isValid) {
currentServerSetting!!.name = serverNameEditText!!.editText?.text.toString() currentServerSetting!!.name = serverNameEditText!!.editText?.text.toString()
currentServerSetting!!.url = serverAddressEditText!!.editText?.text.toString() currentServerSetting!!.url = serverAddressEditText!!.editText?.text.toString()
currentServerSetting!!.color = selectedColor // currentServerSetting!!.color = selectedColor
currentServerSetting!!.userName = userNameEditText!!.editText?.text.toString() currentServerSetting!!.userName = userNameEditText!!.editText?.text.toString()
currentServerSetting!!.password = passwordEditText!!.editText?.text.toString() currentServerSetting!!.password = passwordEditText!!.editText?.text.toString()
currentServerSetting!!.allowSelfSignedCertificate = selfSignedSwitch!!.isChecked currentServerSetting!!.allowSelfSignedCertificate = selfSignedSwitch!!.isChecked

View File

@ -212,7 +212,6 @@ class ServerSettingsModel(
serverId, serverId,
settings.getString(PREFERENCES_KEY_SERVER_NAME + preferenceId, "")!!, settings.getString(PREFERENCES_KEY_SERVER_NAME + preferenceId, "")!!,
url, url,
null,
userName, userName,
settings.getString(PREFERENCES_KEY_PASSWORD + preferenceId, "")!!, settings.getString(PREFERENCES_KEY_PASSWORD + preferenceId, "")!!,
settings.getBoolean(PREFERENCES_KEY_JUKEBOX_BY_DEFAULT + preferenceId, false), settings.getBoolean(PREFERENCES_KEY_JUKEBOX_BY_DEFAULT + preferenceId, false),