-
Notifications
You must be signed in to change notification settings - Fork 756
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6946 from vector-im/feature/ons/device_manager_ot…
…her_session_list [Device Manager] Render other sessions (PSG-668)
- Loading branch information
Showing
16 changed files
with
511 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Device Manager] Other Sessions Section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
vector/src/main/java/im/vector/app/features/settings/devices/v2/list/DeviceType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.settings.devices.v2.list | ||
|
||
enum class DeviceType { | ||
MOBILE, | ||
WEB, | ||
DESKTOP, | ||
UNKNOWN, | ||
} |
79 changes: 79 additions & 0 deletions
79
vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.settings.devices.v2.list | ||
|
||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import com.airbnb.epoxy.EpoxyAttribute | ||
import com.airbnb.epoxy.EpoxyModelClass | ||
import im.vector.app.R | ||
import im.vector.app.core.epoxy.VectorEpoxyHolder | ||
import im.vector.app.core.epoxy.VectorEpoxyModel | ||
import im.vector.app.core.resources.StringProvider | ||
import im.vector.app.core.ui.views.ShieldImageView | ||
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel | ||
|
||
@EpoxyModelClass | ||
abstract class OtherSessionItem : VectorEpoxyModel<OtherSessionItem.Holder>(R.layout.item_other_session) { | ||
|
||
@EpoxyAttribute | ||
var deviceType: DeviceType = DeviceType.UNKNOWN | ||
|
||
@EpoxyAttribute | ||
var roomEncryptionTrustLevel: RoomEncryptionTrustLevel? = null | ||
|
||
@EpoxyAttribute | ||
var sessionName: String? = null | ||
|
||
@EpoxyAttribute | ||
var sessionDescription: String? = null | ||
|
||
@EpoxyAttribute | ||
lateinit var stringProvider: StringProvider | ||
|
||
override fun bind(holder: Holder) { | ||
super.bind(holder) | ||
when (deviceType) { | ||
DeviceType.MOBILE -> { | ||
holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_mobile) | ||
holder.otherSessionDeviceTypeImageView.contentDescription = stringProvider.getString(R.string.a11y_device_manager_device_type_mobile) | ||
} | ||
DeviceType.WEB -> { | ||
holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_web) | ||
holder.otherSessionDeviceTypeImageView.contentDescription = stringProvider.getString(R.string.a11y_device_manager_device_type_web) | ||
} | ||
DeviceType.DESKTOP -> { | ||
holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_desktop) | ||
holder.otherSessionDeviceTypeImageView.contentDescription = stringProvider.getString(R.string.a11y_device_manager_device_type_desktop) | ||
} | ||
DeviceType.UNKNOWN -> { | ||
holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_unknown) | ||
holder.otherSessionDeviceTypeImageView.contentDescription = stringProvider.getString(R.string.a11y_device_manager_device_type_unknown) | ||
} | ||
} | ||
holder.otherSessionVerificationStatusImageView.render(roomEncryptionTrustLevel) | ||
holder.otherSessionNameTextView.text = sessionName | ||
holder.otherSessionDescriptionTextView.text = sessionDescription | ||
} | ||
|
||
class Holder : VectorEpoxyHolder() { | ||
val otherSessionDeviceTypeImageView by bind<ImageView>(R.id.otherSessionDeviceTypeImageView) | ||
val otherSessionVerificationStatusImageView by bind<ShieldImageView>(R.id.otherSessionVerificationStatusImageView) | ||
val otherSessionNameTextView by bind<TextView>(R.id.otherSessionNameTextView) | ||
val otherSessionDescriptionTextView by bind<TextView>(R.id.otherSessionDescriptionTextView) | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
.../src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2022 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package im.vector.app.features.settings.devices.v2.list | ||
|
||
import com.airbnb.epoxy.TypedEpoxyController | ||
import im.vector.app.R | ||
import im.vector.app.core.date.DateFormatKind | ||
import im.vector.app.core.date.VectorDateFormatter | ||
import im.vector.app.core.epoxy.noResultItem | ||
import im.vector.app.core.resources.StringProvider | ||
import im.vector.app.features.settings.devices.DeviceFullInfo | ||
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel | ||
import javax.inject.Inject | ||
|
||
class OtherSessionsController @Inject constructor( | ||
private val stringProvider: StringProvider, | ||
private val dateFormatter: VectorDateFormatter, | ||
) : TypedEpoxyController<List<DeviceFullInfo>>() { | ||
|
||
override fun buildModels(data: List<DeviceFullInfo>?) { | ||
val host = this | ||
|
||
if (data.isNullOrEmpty()) { | ||
noResultItem { | ||
id("empty") | ||
text(host.stringProvider.getString(R.string.no_result_placeholder)) | ||
} | ||
} else { | ||
data.take(NUMBER_OF_OTHER_DEVICES_TO_RENDER).forEach { device -> | ||
val formattedLastActivityDate = host.dateFormatter.format(device.deviceInfo.lastSeenTs, DateFormatKind.DEFAULT_DATE_AND_TIME) | ||
val description = if (device.trustLevelForShield == RoomEncryptionTrustLevel.Trusted) { | ||
stringProvider.getString(R.string.device_manager_other_sessions_description_verified, formattedLastActivityDate) | ||
} else { | ||
stringProvider.getString(R.string.device_manager_other_sessions_description_unverified, formattedLastActivityDate) | ||
} | ||
|
||
otherSessionItem { | ||
id(device.deviceInfo.deviceId) | ||
deviceType(DeviceType.UNKNOWN) // TODO. We don't have this info yet. Update accordingly. | ||
roomEncryptionTrustLevel(device.trustLevelForShield) | ||
sessionName(device.deviceInfo.displayName) | ||
sessionDescription(description) | ||
stringProvider(this@OtherSessionsController.stringProvider) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.