diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 8ccfd2bf38..5eaec2c84b 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3266,6 +3266,7 @@ Last activity %1$s Session details + Application, device, and activity information. %s\nis looking a little empty. diff --git a/library/ui-styles/src/main/res/values/stylable_session_overview_entry_view.xml b/library/ui-styles/src/main/res/values/stylable_session_overview_entry_view.xml new file mode 100644 index 0000000000..d3884f247d --- /dev/null +++ b/library/ui-styles/src/main/res/values/stylable_session_overview_entry_view.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/library/ui-styles/src/main/res/values/stylable_devices_list_header_view.xml b/library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml similarity index 51% rename from library/ui-styles/src/main/res/values/stylable_devices_list_header_view.xml rename to library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml index 97e0290815..d3b931e44a 100644 --- a/library/ui-styles/src/main/res/values/stylable_devices_list_header_view.xml +++ b/library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml @@ -2,8 +2,8 @@ - - + + diff --git a/library/ui-styles/src/main/res/values/styles_devices_management.xml b/library/ui-styles/src/main/res/values/styles_devices_management.xml index 6fb236d3e6..6b42b85ffd 100644 --- a/library/ui-styles/src/main/res/values/styles_devices_management.xml +++ b/library/ui-styles/src/main/res/values/styles_devices_management.xml @@ -1,6 +1,10 @@ + + diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt index 547ed93f24..bea8b74b01 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt @@ -53,12 +53,12 @@ class SessionsListHeaderView @JvmOverloads constructor( } private fun setTitle(typedArray: TypedArray) { - val title = typedArray.getString(R.styleable.SessionsListHeaderView_devicesListHeaderTitle) + val title = typedArray.getString(R.styleable.SessionsListHeaderView_sessionsListHeaderTitle) binding.sessionsListHeaderTitle.text = title } private fun setDescription(typedArray: TypedArray) { - val description = typedArray.getString(R.styleable.SessionsListHeaderView_devicesListHeaderDescription) + val description = typedArray.getString(R.styleable.SessionsListHeaderView_sessionsListHeaderDescription) if (description.isNullOrEmpty()) { binding.sessionsListHeaderDescription.isVisible = false return diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewEntryView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewEntryView.kt new file mode 100644 index 0000000000..5c4f0047ce --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewEntryView.kt @@ -0,0 +1,66 @@ +/* + * 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.overview + +import android.content.Context +import android.content.res.TypedArray +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.res.use +import im.vector.app.R +import im.vector.app.core.extensions.setAttributeBackground +import im.vector.app.databinding.ViewSessionOverviewEntryBinding + +class SessionOverviewEntryView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + private val binding = ViewSessionOverviewEntryBinding.inflate( + LayoutInflater.from(context), + this + ) + + init { + initBackground() + context.obtainStyledAttributes( + attrs, + R.styleable.SessionOverviewEntryView, + 0, + 0 + ).use { + setTitle(it) + setDescription(it) + } + } + + private fun initBackground() { + binding.root.setAttributeBackground(android.R.attr.selectableItemBackground) + } + + private fun setTitle(typedArray: TypedArray) { + val title = typedArray.getString(R.styleable.SessionOverviewEntryView_sessionOverviewEntryTitle) + binding.sessionsOverviewEntryTitle.text = title + } + + private fun setDescription(typedArray: TypedArray) { + val description = typedArray.getString(R.styleable.SessionOverviewEntryView_sessionOverviewEntryDescription) + binding.sessionsOverviewEntryDescription.text = description + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt index c5cd80bd3c..3fea7a9316 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt @@ -45,6 +45,8 @@ import javax.inject.Inject class SessionOverviewFragment : VectorBaseFragment() { + @Inject lateinit var viewNavigator: SessionOverviewViewNavigator + @Inject lateinit var dateFormatter: VectorDateFormatter @Inject lateinit var drawableProvider: DrawableProvider @@ -79,6 +81,7 @@ class SessionOverviewFragment : override fun invalidate() = withState(viewModel) { state -> updateToolbar(state.isCurrentSession) + updateEntryDetails(state.deviceId) if (state.deviceInfo is Success) { renderSessionInfo(state.isCurrentSession, state.deviceInfo.invoke()) } else { @@ -93,6 +96,12 @@ class SessionOverviewFragment : ?.setTitle(titleResId) } + private fun updateEntryDetails(deviceId: String) { + views.sessionOverviewEntryDetails.setOnClickListener { + viewNavigator.navigateToSessionDetails(requireContext(), deviceId) + } + } + private fun renderSessionInfo(isCurrentSession: Boolean, deviceFullInfo: DeviceFullInfo) { views.sessionOverviewInfo.isVisible = true val viewState = SessionInfoViewState( diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt new file mode 100644 index 0000000000..d6e94238ed --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt @@ -0,0 +1,29 @@ +/* + * 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.overview + +import android.content.Context +import im.vector.app.features.settings.devices.v2.details.SessionDetailsActivity +import javax.inject.Inject + +// TODO add unit tests +class SessionOverviewViewNavigator @Inject constructor() { + + fun navigateToSessionDetails(context: Context, deviceId: String) { + context.startActivity(SessionDetailsActivity.newIntent(context, deviceId)) + } +} diff --git a/vector/src/main/res/layout/fragment_session_overview.xml b/vector/src/main/res/layout/fragment_session_overview.xml index 156e61673b..3e4a88bd75 100644 --- a/vector/src/main/res/layout/fragment_session_overview.xml +++ b/vector/src/main/res/layout/fragment_session_overview.xml @@ -17,4 +17,14 @@ app:layout_constraintTop_toTopOf="parent" tools:visibility="visible" /> + + diff --git a/vector/src/main/res/layout/fragment_settings_devices.xml b/vector/src/main/res/layout/fragment_settings_devices.xml index 9cefd6aa24..b53aef33d7 100644 --- a/vector/src/main/res/layout/fragment_settings_devices.xml +++ b/vector/src/main/res/layout/fragment_settings_devices.xml @@ -12,8 +12,8 @@ android:id="@+id/deviceListHeaderSectionSecurityRecommendations" android:layout_width="0dp" android:layout_height="wrap_content" - app:devicesListHeaderDescription="@string/device_manager_header_section_security_recommendations_description" - app:devicesListHeaderTitle="@string/device_manager_header_section_security_recommendations_title" + app:sessionsListHeaderDescription="@string/device_manager_header_section_security_recommendations_description" + app:sessionsListHeaderTitle="@string/device_manager_header_section_security_recommendations_title" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -60,8 +60,8 @@ android:id="@+id/deviceListHeaderCurrentSession" android:layout_width="0dp" android:layout_height="wrap_content" - app:devicesListHeaderDescription="" - app:devicesListHeaderTitle="@string/device_manager_current_session_title" + app:sessionsListHeaderDescription="" + app:sessionsListHeaderTitle="@string/device_manager_current_session_title" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/deviceListSecurityRecommendationsDivider" /> @@ -90,8 +90,8 @@ android:id="@+id/deviceListHeaderOtherSessions" android:layout_width="0dp" android:layout_height="wrap_content" - app:devicesListHeaderDescription="@string/settings_sessions_other_description" - app:devicesListHeaderTitle="@string/settings_sessions_other_title" + app:sessionsListHeaderDescription="@string/settings_sessions_other_description" + app:sessionsListHeaderTitle="@string/settings_sessions_other_title" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/deviceListDividerCurrentSession" /> diff --git a/vector/src/main/res/layout/view_session_overview_entry.xml b/vector/src/main/res/layout/view_session_overview_entry.xml new file mode 100644 index 0000000000..4a0071d72d --- /dev/null +++ b/vector/src/main/res/layout/view_session_overview_entry.xml @@ -0,0 +1,42 @@ + + + + + + + + + +