From 8f218ce773703212ed62879d8f76933c82d55d33 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 11 Aug 2022 11:26:16 +0200 Subject: [PATCH] Custom header view without "Learn more" --- .../stylable_devices_list_header_view.xml | 9 +++ .../res/values/styles_devices_management.xml | 12 ++++ .../devices/v2/list/DevicesListHeaderView.kt | 60 +++++++++++++++++++ .../res/layout/fragment_settings_devices.xml | 14 ++++- .../res/layout/view_devices_list_header.xml | 32 ++++++++++ vector/src/main/res/values/strings.xml | 2 + 6 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 library/ui-styles/src/main/res/values/stylable_devices_list_header_view.xml create mode 100644 library/ui-styles/src/main/res/values/styles_devices_management.xml create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/list/DevicesListHeaderView.kt create mode 100644 vector/src/main/res/layout/view_devices_list_header.xml 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_devices_list_header_view.xml new file mode 100644 index 0000000000..f0807f89c6 --- /dev/null +++ b/library/ui-styles/src/main/res/values/stylable_devices_list_header_view.xml @@ -0,0 +1,9 @@ + + + + + + + + + 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 new file mode 100644 index 0000000000..2a63c2ed36 --- /dev/null +++ b/library/ui-styles/src/main/res/values/styles_devices_management.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/DevicesListHeaderView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/DevicesListHeaderView.kt new file mode 100644 index 0000000000..afcba9d783 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/DevicesListHeaderView.kt @@ -0,0 +1,60 @@ +/* + * 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.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 + ) + + 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) + binding.devicesListHeaderDescription.text = description + } +} diff --git a/vector/src/main/res/layout/fragment_settings_devices.xml b/vector/src/main/res/layout/fragment_settings_devices.xml index 2a77219ad0..2e63ebe86d 100644 --- a/vector/src/main/res/layout/fragment_settings_devices.xml +++ b/vector/src/main/res/layout/fragment_settings_devices.xml @@ -1,5 +1,17 @@ + android:background="?android:colorBackground"> + + + + diff --git a/vector/src/main/res/layout/view_devices_list_header.xml b/vector/src/main/res/layout/view_devices_list_header.xml new file mode 100644 index 0000000000..492c3e7a12 --- /dev/null +++ b/vector/src/main/res/layout/view_devices_list_header.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 7c01eed715..3299e90ccb 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -2337,6 +2337,8 @@ Manage Sessions Sign out of this session Sessions + Other sessions + For best security, verify your sessions and sign out from any session that you don’t recognize or use anymore. Server name Server version