From 94d1649ec9a600060a91310747d5f70c667bff4c Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 15:10:48 +0200 Subject: [PATCH] Creation of header and content items --- .../v2/details/SessionDetailsContentItem.kt | 51 +++++++++++++++++++ .../v2/details/SessionDetailsHeaderItem.kt | 40 +++++++++++++++ .../layout/item_session_details_content.xml | 45 ++++++++++++++++ .../layout/item_session_details_header.xml | 22 ++++++++ 4 files changed, 158 insertions(+) create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt create mode 100644 vector/src/main/res/layout/item_session_details_content.xml create mode 100644 vector/src/main/res/layout/item_session_details_header.xml diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt new file mode 100644 index 0000000000..5c3a46475d --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt @@ -0,0 +1,51 @@ +/* + * 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.details + +import android.view.View +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 + +@EpoxyModelClass +abstract class SessionDetailsContentItem : VectorEpoxyModel(R.layout.item_session_details_header) { + + @EpoxyAttribute + var title: String? = null + + @EpoxyAttribute + var description: String? = null + + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var onLongClickListener: View.OnLongClickListener? = null + + override fun bind(holder: Holder) { + super.bind(holder) + holder.sessionDetailsContentTitle.text = title + holder.sessionDetailsContentDescription.text = description + holder.view.isClickable = onLongClickListener != null + holder.view.setOnLongClickListener(onLongClickListener) + } + + class Holder : VectorEpoxyHolder() { + val sessionDetailsContentTitle by bind(R.id.sessionDetailsContentTitle) + val sessionDetailsContentDescription by bind(R.id.sessionDetailsContentDescription) + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt new file mode 100644 index 0000000000..5c21460bd6 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt @@ -0,0 +1,40 @@ +/* + * 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.details + +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 + +@EpoxyModelClass +abstract class SessionDetailsHeaderItem : VectorEpoxyModel(R.layout.item_session_details_header) { + + @EpoxyAttribute + var title: String? = null + + override fun bind(holder: Holder) { + super.bind(holder) + holder.sessionDetailsHeaderTitle.text = title + } + + class Holder : VectorEpoxyHolder() { + val sessionDetailsHeaderTitle by bind(R.id.sessionDetailsHeaderTitle) + } +} diff --git a/vector/src/main/res/layout/item_session_details_content.xml b/vector/src/main/res/layout/item_session_details_content.xml new file mode 100644 index 0000000000..a3b2e42c72 --- /dev/null +++ b/vector/src/main/res/layout/item_session_details_content.xml @@ -0,0 +1,45 @@ + + + + + + + + + + diff --git a/vector/src/main/res/layout/item_session_details_header.xml b/vector/src/main/res/layout/item_session_details_header.xml new file mode 100644 index 0000000000..4cead8acff --- /dev/null +++ b/vector/src/main/res/layout/item_session_details_header.xml @@ -0,0 +1,22 @@ + + + + + +