mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-02-16 11:41:16 +01:00
Revert "Merge pull request #667 from ultrasonic/patchBranch"
This reverts commit 41a462708d4a696d988d67f79d59f9424d3b0a05, reversing changes made to fd239e8e72a1361321f1f268d90e3474a2f2685e.
This commit is contained in:
parent
a53d5378bf
commit
586bc51a9c
@ -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, null)
|
||||
val backgroundColor = ServerColor.getBackgroundColor(this, null)
|
||||
val foregroundColor = ServerColor.getForegroundColor(this, activeServer.color)
|
||||
val backgroundColor = ServerColor.getBackgroundColor(this, activeServer.color)
|
||||
|
||||
if (activeServer.index == 0)
|
||||
selectServerButton?.icon =
|
||||
|
@ -108,8 +108,8 @@ internal class ServerRowAdapter(
|
||||
}
|
||||
|
||||
// Set colors
|
||||
icon?.setTint(ServerColor.getForegroundColor(context, null))
|
||||
background?.setTint(ServerColor.getBackgroundColor(context, null))
|
||||
icon?.setTint(ServerColor.getForegroundColor(context, setting?.color))
|
||||
background?.setTint(ServerColor.getBackgroundColor(context, setting?.color))
|
||||
|
||||
// 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 = 3)
|
||||
@Database(entities = [ServerSetting::class], version = 4)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,7 @@ 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,
|
||||
@ -36,9 +37,9 @@ data class ServerSetting(
|
||||
@ColumnInfo(name = "podcastSupport") var podcastSupport: Boolean? = null
|
||||
) {
|
||||
constructor() : this (
|
||||
-1, 0, "", "", "", "", false, false, false, null, null
|
||||
-1, 0, "", "", null, "", "", false, false, false, null, null
|
||||
)
|
||||
constructor(name: String, url: String) : this(
|
||||
-1, 0, name, url, "", "", false, false, false, null, null
|
||||
-1, 0, name, url, null, "", "", false, false, false, null, null
|
||||
)
|
||||
}
|
||||
|
@ -6,13 +6,15 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
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
|
||||
@ -41,6 +43,8 @@ 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
|
||||
*/
|
||||
@ -68,8 +72,6 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
||||
private var currentColor: Int = 0
|
||||
private var selectedColor: Int? = null
|
||||
|
||||
private var editServerColorText: TextView? = null
|
||||
|
||||
@Override
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Util.applyTheme(this.context)
|
||||
@ -97,7 +99,6 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
||||
jukeboxSwitch = view.findViewById(R.id.edit_jukebox)
|
||||
saveButton = view.findViewById(R.id.edit_save)
|
||||
testButton = view.findViewById(R.id.edit_test)
|
||||
editServerColorText = view.findViewById(R.id.edit_server_color_text)
|
||||
|
||||
val index = arguments?.getInt(
|
||||
EDIT_SERVER_INTENT_INDEX,
|
||||
@ -146,7 +147,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()) {
|
||||
@ -162,37 +163,33 @@ 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?.isVisible = false
|
||||
editServerColorText?.isVisible = false
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
private fun updateColor() {
|
||||
private fun updateColor(color: Int?) {
|
||||
val image = ContextCompat.getDrawable(requireContext(), R.drawable.thumb_drawable)
|
||||
currentColor = ServerColor.getBackgroundColor(requireContext(), null)
|
||||
currentColor = ServerColor.getBackgroundColor(requireContext(), color)
|
||||
image?.setTint(currentColor)
|
||||
serverColorImageView?.background = image
|
||||
}
|
||||
@ -257,7 +254,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)
|
||||
@ -276,7 +273,7 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
||||
selfSignedSwitch!!.isChecked = currentServerSetting!!.allowSelfSignedCertificate
|
||||
ldapSwitch!!.isChecked = currentServerSetting!!.ldapSupport
|
||||
jukeboxSwitch!!.isChecked = currentServerSetting!!.jukeboxByDefault
|
||||
// updateColor(currentServerSetting!!.color)
|
||||
updateColor(currentServerSetting!!.color)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -325,7 +322,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,6 +212,7 @@ 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