Merge pull request #6807 from vector-im/feature/mna/device-management-header-list
[Devices Management] Header view for sessions lists in new layout (PSG-668)
This commit is contained in:
commit
6c65b0a9e0
|
@ -0,0 +1 @@
|
||||||
|
[Devices management] Other sessions section in new layout
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<declare-styleable name="DevicesListHeaderView">
|
||||||
|
<attr name="devicesListHeaderTitle" format="string" />
|
||||||
|
<attr name="devicesListHeaderDescription" format="string" />
|
||||||
|
</declare-styleable>
|
||||||
|
|
||||||
|
</resources>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
|
||||||
|
<style name="TextAppearance.Vector.Subtitle.Medium.DevicesManagement">
|
||||||
|
<item name="android:textColor">?vctr_content_primary</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="TextAppearance.Vector.Body.DevicesManagement">
|
||||||
|
<item name="android:textColor">?vctr_content_secondary</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</resources>
|
|
@ -553,7 +553,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||||
showDeviceListPref.summary = resources.getQuantityString(R.plurals.settings_active_sessions_count, devices.size, devices.size)
|
showDeviceListPref.summary = resources.getQuantityString(R.plurals.settings_active_sessions_count, devices.size, devices.size)
|
||||||
|
|
||||||
showDevicesListV2Pref.isVisible = vectorFeatures.isNewDeviceManagementEnabled()
|
showDevicesListV2Pref.isVisible = vectorFeatures.isNewDeviceManagementEnabled()
|
||||||
showDevicesListV2Pref.title = showDevicesListV2Pref.title.toString() + " (V2, WIP)"
|
showDevicesListV2Pref.title = getString(R.string.device_manager_settings_active_sessions_show_all)
|
||||||
showDevicesListV2Pref.summary = resources.getQuantityString(R.plurals.settings_active_sessions_count, devices.size, devices.size)
|
showDevicesListV2Pref.summary = resources.getQuantityString(R.plurals.settings_active_sessions_count, devices.size, devices.size)
|
||||||
|
|
||||||
val userId = session.myUserId
|
val userId = session.myUserId
|
||||||
|
|
|
@ -17,8 +17,11 @@
|
||||||
package im.vector.app.features.settings.devices.v2
|
package im.vector.app.features.settings.devices.v2
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
|
@ -46,4 +49,24 @@ class VectorSettingsDevicesFragment @Inject constructor() : VectorBaseFragment<F
|
||||||
?.supportActionBar
|
?.supportActionBar
|
||||||
?.setTitle(R.string.settings_sessions_list)
|
?.setTitle(R.string.settings_sessions_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
initLearnMoreButtons()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroyView() {
|
||||||
|
cleanUpLearnMoreButtonsListeners()
|
||||||
|
super.onDestroyView()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initLearnMoreButtons() {
|
||||||
|
views.devicesListHeaderSectionOther.onLearnMoreClickListener = {
|
||||||
|
Toast.makeText(context, "Learn more other", Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cleanUpLearnMoreButtonsListeners() {
|
||||||
|
views.devicesListHeaderSectionOther.onLearnMoreClickListener = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* 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.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.setTextWithColoredPart
|
||||||
|
import im.vector.app.databinding.ViewDevicesListHeaderBinding
|
||||||
|
|
||||||
|
class DevicesListHeaderView @JvmOverloads constructor(
|
||||||
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
|
defStyleAttr: Int = 0
|
||||||
|
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
|
private val binding = ViewDevicesListHeaderBinding.inflate(
|
||||||
|
LayoutInflater.from(context),
|
||||||
|
this
|
||||||
|
)
|
||||||
|
|
||||||
|
var onLearnMoreClickListener: (() -> Unit)? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
context.obtainStyledAttributes(
|
||||||
|
attrs,
|
||||||
|
R.styleable.DevicesListHeaderView,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
).use {
|
||||||
|
setTitle(it)
|
||||||
|
setDescription(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setTitle(typedArray: TypedArray) {
|
||||||
|
val title = typedArray.getString(R.styleable.DevicesListHeaderView_devicesListHeaderTitle)
|
||||||
|
binding.devicesListHeaderTitle.text = title
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setDescription(typedArray: TypedArray) {
|
||||||
|
val description = typedArray.getString(R.styleable.DevicesListHeaderView_devicesListHeaderDescription)
|
||||||
|
val learnMore = context.getString(R.string.action_learn_more)
|
||||||
|
val stringBuilder = StringBuilder()
|
||||||
|
stringBuilder.append(description)
|
||||||
|
stringBuilder.append(" ")
|
||||||
|
stringBuilder.append(learnMore)
|
||||||
|
|
||||||
|
binding.devicesListHeaderDescription.setTextWithColoredPart(
|
||||||
|
fullText = stringBuilder.toString(),
|
||||||
|
coloredPart = learnMore,
|
||||||
|
underline = false
|
||||||
|
) {
|
||||||
|
onLearnMoreClickListener?.invoke()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="?android:colorBackground" />
|
|
||||||
|
<im.vector.app.features.settings.devices.v2.list.DevicesListHeaderView
|
||||||
|
android:id="@+id/devices_list_header_section_other"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:devicesListHeaderDescription="@string/settings_sessions_other_description"
|
||||||
|
app:devicesListHeaderTitle="@string/settings_sessions_other_title"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?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/devices_list_header_title"
|
||||||
|
style="@style/TextAppearance.Vector.Subtitle.Medium.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="Other sessions" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/devices_list_header_description"
|
||||||
|
style="@style/TextAppearance.Vector.Body.DevicesManagement"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="18.5dp"
|
||||||
|
android:layout_marginEnd="40dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/devices_list_header_title"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/devices_list_header_title"
|
||||||
|
tools:text="For best security, verify your sessions and sign out from any session that you don’t recognize or use anymore. Learn More." />
|
||||||
|
</merge>
|
|
@ -2342,6 +2342,8 @@
|
||||||
<string name="settings_active_sessions_manage">Manage Sessions</string>
|
<string name="settings_active_sessions_manage">Manage Sessions</string>
|
||||||
<string name="settings_active_sessions_signout_device">Sign out of this session</string>
|
<string name="settings_active_sessions_signout_device">Sign out of this session</string>
|
||||||
<string name="settings_sessions_list">Sessions</string>
|
<string name="settings_sessions_list">Sessions</string>
|
||||||
|
<string name="settings_sessions_other_title">Other sessions</string>
|
||||||
|
<string name="settings_sessions_other_description">For best security, verify your sessions and sign out from any session that you don’t recognize or use anymore.</string>
|
||||||
|
|
||||||
<string name="settings_server_name">Server name</string>
|
<string name="settings_server_name">Server name</string>
|
||||||
<string name="settings_server_version">Server version</string>
|
<string name="settings_server_version">Server version</string>
|
||||||
|
@ -3201,4 +3203,7 @@
|
||||||
<!-- Element Call Widget -->
|
<!-- Element Call Widget -->
|
||||||
<string name="labs_enable_element_call_permission_shortcuts">Enable Element Call permission shortcuts</string>
|
<string name="labs_enable_element_call_permission_shortcuts">Enable Element Call permission shortcuts</string>
|
||||||
<string name="labs_enable_element_call_permission_shortcuts_summary">Auto-approve Element Call widgets and grant camera / mic access</string>
|
<string name="labs_enable_element_call_permission_shortcuts_summary">Auto-approve Element Call widgets and grant camera / mic access</string>
|
||||||
|
|
||||||
|
<!-- Device Manager -->
|
||||||
|
<string name="device_manager_settings_active_sessions_show_all">Show All Sessions (V2, WIP)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue