Navigation from session overview to session details
This commit is contained in:
parent
4a89fcea14
commit
a661f9c3fb
|
@ -3266,6 +3266,7 @@
|
|||
<!-- Examples: Last activity Yesterday at 6PM, Last activity Aug 31 at 5:47PM -->
|
||||
<string name="device_manager_session_last_activity">Last activity %1$s</string>
|
||||
<string name="device_manager_session_details_title">Session details</string>
|
||||
<string name="device_manager_session_details_description">Application, device, and activity information.</string>
|
||||
|
||||
<!-- Note to translators: %s will be replaces with selected space name -->
|
||||
<string name="home_empty_space_no_rooms_title">%s\nis looking a little empty.</string>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<declare-styleable name="SessionOverviewEntryView">
|
||||
<attr name="sessionOverviewEntryTitle" format="string" />
|
||||
<attr name="sessionOverviewEntryDescription" format="string" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
|
@ -2,8 +2,8 @@
|
|||
<resources>
|
||||
|
||||
<declare-styleable name="SessionsListHeaderView">
|
||||
<attr name="devicesListHeaderTitle" format="string" />
|
||||
<attr name="devicesListHeaderDescription" format="string" />
|
||||
<attr name="sessionsListHeaderTitle" format="string" />
|
||||
<attr name="sessionsListHeaderDescription" format="string" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
|
@ -1,6 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="TextAppearance.Vector.Subtitle.DevicesManagement">
|
||||
<item name="android:textColor">?vctr_content_primary</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Vector.Subtitle.Medium.DevicesManagement">
|
||||
<item name="android:textColor">?vctr_content_primary</item>
|
||||
</style>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -45,6 +45,8 @@ import javax.inject.Inject
|
|||
class SessionOverviewFragment :
|
||||
VectorBaseFragment<FragmentSessionOverviewBinding>() {
|
||||
|
||||
@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(
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
|
@ -17,4 +17,14 @@
|
|||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<im.vector.app.features.settings.devices.v2.overview.SessionOverviewEntryView
|
||||
android:id="@+id/sessionOverviewEntryDetails"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:sessionOverviewEntryTitle="@string/device_manager_session_details_title"
|
||||
app:sessionOverviewEntryDescription="@string/device_manager_session_details_description"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/sessionOverviewInfo" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sessions_overview_entry_title"
|
||||
style="@style/TextAppearance.Vector.Subtitle.DevicesManagement"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="@dimen/layout_horizontal_margin"
|
||||
android:layout_marginTop="20dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Session details" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sessions_overview_entry_description"
|
||||
style="@style/TextAppearance.Vector.Body.DevicesManagement"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
app:layout_constraintEnd_toEndOf="@id/sessions_overview_entry_title"
|
||||
app:layout_constraintStart_toStartOf="@id/sessions_overview_entry_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/sessions_overview_entry_title"
|
||||
tools:text="Application, device, and activity information." />
|
||||
|
||||
<View
|
||||
android:id="@+id/sessions_overview_entry_divider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:background="@drawable/divider_horizontal"
|
||||
app:layout_constraintEnd_toEndOf="@id/sessions_overview_entry_title"
|
||||
app:layout_constraintStart_toStartOf="@id/sessions_overview_entry_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/sessions_overview_entry_description" />
|
||||
|
||||
</merge>
|
Loading…
Reference in New Issue