Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1449913b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Controls UI - Persist subtitles" into rvc-dev am: 6b70283f

Change-Id: I3be94480bd344da463808b0545dfa6c17d89ac99
parents 4bdc2090 6b70283f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -71,6 +71,8 @@
        android:paddingRight="@dimen/control_padding_adjustment"
        android:clickable="false"
        android:focusable="false"
        android:maxLines="1"
        android:ellipsize="end"
        app:layout_constraintBottom_toTopOf="@+id/subtitle"
        app:layout_constraintStart_toStartOf="parent" />

@@ -84,6 +86,8 @@
        android:paddingBottom="@dimen/control_padding_adjustment"
        android:clickable="false"
        android:focusable="false"
        android:maxLines="1"
        android:ellipsize="end"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"/>

+4 −1
Original line number Diff line number Diff line
@@ -27,11 +27,13 @@ import android.service.controls.DeviceTypes
 *
 * @property controlId unique identifier for this [Control].
 * @property controlTitle last title reported for this [Control].
 * @property controlSubtitle last subtitle reported for this [Control].
 * @property deviceType last reported type for this [Control].
 */
data class ControlInfo(
    val controlId: String,
    val controlTitle: CharSequence,
    val controlSubtitle: CharSequence,
    @DeviceTypes.DeviceType val deviceType: Int
) {

@@ -51,8 +53,9 @@ data class ControlInfo(
    class Builder {
        lateinit var controlId: String
        lateinit var controlTitle: CharSequence
        lateinit var controlSubtitle: CharSequence
        var deviceType: Int = DeviceTypes.TYPE_UNKNOWN

        fun build() = ControlInfo(controlId, controlTitle, deviceType)
        fun build() = ControlInfo(controlId, controlTitle, controlSubtitle, deviceType)
    }
}
+5 −2
Original line number Diff line number Diff line
@@ -328,7 +328,8 @@ class ControlsControllerImpl @Inject constructor (
                            val structure = it.structure ?: ""
                            val list = structureToControls.get(structure)
                                ?: mutableListOf<ControlInfo>()
                            list.add(ControlInfo(it.controlId, it.title, it.deviceType))
                            list.add(
                                ControlInfo(it.controlId, it.title, it.subtitle, it.deviceType))
                            structureToControls.put(structure, list)
                        }

@@ -518,10 +519,12 @@ private object Favorites {
            s.controls.forEach { c ->
                val (sName, ci) = controlsById.get(c.controlId)?.let { updatedControl ->
                    val controlInfo = if (updatedControl.title != c.controlTitle ||
                        updatedControl.subtitle != c.controlSubtitle ||
                        updatedControl.deviceType != c.deviceType) {
                        changed = true
                        c.copy(
                            controlTitle = updatedControl.title,
                            controlSubtitle = updatedControl.subtitle,
                            deviceType = updatedControl.deviceType
                        )
                    } else { c }
+4 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ class ControlsFavoritePersistenceWrapper(
        private const val TAG_COMPONENT = "component"
        private const val TAG_ID = "id"
        private const val TAG_TITLE = "title"
        private const val TAG_SUBTITLE = "subtitle"
        private const val TAG_TYPE = "type"
        private const val TAG_VERSION = "version"

@@ -102,6 +103,7 @@ class ControlsFavoritePersistenceWrapper(
                            startTag(null, TAG_CONTROL)
                            attribute(null, TAG_ID, c.controlId)
                            attribute(null, TAG_TITLE, c.controlTitle.toString())
                            attribute(null, TAG_SUBTITLE, c.controlSubtitle.toString())
                            attribute(null, TAG_TYPE, c.deviceType.toString())
                            endTag(null, TAG_CONTROL)
                        }
@@ -168,9 +170,10 @@ class ControlsFavoritePersistenceWrapper(
            } else if (type == XmlPullParser.START_TAG && tagName == TAG_CONTROL) {
                val id = parser.getAttributeValue(null, TAG_ID)
                val title = parser.getAttributeValue(null, TAG_TITLE)
                val subtitle = parser.getAttributeValue(null, TAG_SUBTITLE) ?: ""
                val deviceType = parser.getAttributeValue(null, TAG_TYPE)?.toInt()
                if (id != null && title != null && deviceType != null) {
                    controls.add(ControlInfo(id, title, deviceType))
                    controls.add(ControlInfo(id, title, subtitle, deviceType))
                }
            } else if (type == XmlPullParser.END_TAG && tagName == TAG_STRUCTURE) {
                infos.add(StructureInfo(lastComponent!!, lastStructure!!, controls.toList()))
+2 −1
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ class AllModel(
                ControlInfo.Builder().apply {
                    controlId = it.controlId
                    controlTitle = it.title
                    controlSubtitle = it.subtitle
                    deviceType = it.deviceType
                }
            }
Loading