Widget: changes naming algorithm (align on web)
This commit is contained in:
parent
65c6ce3033
commit
c815c4080d
@ -16,6 +16,7 @@
|
||||
|
||||
package im.vector.matrix.android.api.session.widgets.model
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import im.vector.matrix.android.api.util.JsonDict
|
||||
@ -33,26 +34,8 @@ data class WidgetContent(
|
||||
|
||||
fun isActive() = type != null && url != null
|
||||
|
||||
/**
|
||||
* @return the human name
|
||||
*/
|
||||
@SuppressLint("DefaultLocale")
|
||||
fun getHumanName(): String {
|
||||
return if (!name.isNullOrBlank()) {
|
||||
"$name widget"
|
||||
} else if (!type.isNullOrBlank()) {
|
||||
when {
|
||||
type.contains("widget") -> {
|
||||
type
|
||||
}
|
||||
id != null -> {
|
||||
"$type $id"
|
||||
}
|
||||
else -> {
|
||||
"$type widget"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
"Widget $id"
|
||||
}
|
||||
return (name ?: type ?: "").capitalize()
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package im.vector.riotx.features.home.room.detail.timeline.format
|
||||
|
||||
import im.vector.matrix.android.api.extensions.orFalse
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
import im.vector.matrix.android.api.session.events.model.toModel
|
||||
@ -86,9 +87,13 @@ class NoticeEventFormatter @Inject constructor(private val sessionHolder: Active
|
||||
val previousWidgetContent: WidgetContent? = event.prevContent.toModel()
|
||||
return if (widgetContent.isActive()) {
|
||||
val name = widgetContent.getHumanName()
|
||||
sp.getString(R.string.event_formatter_widget_added, name, disambiguatedDisplayName)
|
||||
if (previousWidgetContent?.isActive().orFalse()) {
|
||||
sp.getString(R.string.event_formatter_widget_modified, name, disambiguatedDisplayName)
|
||||
} else {
|
||||
sp.getString(R.string.event_formatter_widget_added, name, disambiguatedDisplayName)
|
||||
}
|
||||
} else {
|
||||
val name = previousWidgetContent?.getHumanName() ?: sp.getString(R.string.room_widget_activity_title)
|
||||
val name = previousWidgetContent?.getHumanName()
|
||||
sp.getString(R.string.event_formatter_widget_removed, name, disambiguatedDisplayName)
|
||||
}
|
||||
}
|
||||
|
@ -1108,8 +1108,9 @@
|
||||
<!-- Widget-->
|
||||
<string name="widget_no_power_to_manage">You need permission to manage widgets in this room</string>
|
||||
<string name="widget_creation_failure">Widget creation has failed</string>
|
||||
<string name="event_formatter_widget_added">%1$s added by %2$s</string>
|
||||
<string name="event_formatter_widget_removed">%1$s removed by %2$s</string>
|
||||
<string name="event_formatter_widget_added">%1$s widget added by %2$s</string>
|
||||
<string name="event_formatter_widget_removed">%1$s widget removed by %2$s</string>
|
||||
<string name="event_formatter_widget_modified">%1$s widget modified by %2$s</string>
|
||||
<string name="settings_labs_create_conference_with_jitsi">Create conference calls with jitsi</string>
|
||||
<string name="widget_delete_message_confirmation">Are you sure you want to delete the widget from this room?</string>
|
||||
<plurals name="active_widgets">
|
||||
|
Loading…
x
Reference in New Issue
Block a user