Add custom view into the layout.

This commit is contained in:
Onuray Sahin 2022-08-19 12:26:12 +03:00
parent 986bc920fe
commit 6c725a1a75
3 changed files with 59 additions and 4 deletions

View File

@ -61,12 +61,12 @@ class VectorSettingsDevicesFragment @Inject constructor() : VectorBaseFragment<F
}
private fun initLearnMoreButtons() {
views.devicesListHeaderSectionOther.onLearnMoreClickListener = {
views.deviceListHeaderSectionOther.onLearnMoreClickListener = {
Toast.makeText(context, "Learn more other", Toast.LENGTH_LONG).show()
}
}
private fun cleanUpLearnMoreButtonsListeners() {
views.devicesListHeaderSectionOther.onLearnMoreClickListener = null
views.deviceListHeaderSectionOther.onLearnMoreClickListener = null
}
}

View File

@ -0,0 +1,35 @@
/*
* 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.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import im.vector.app.databinding.ViewCurrentSessionBinding
class CurrentSessionView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
private val binding = ViewCurrentSessionBinding.inflate(
LayoutInflater.from(context),
this
)
}

View File

@ -5,13 +5,33 @@
android:layout_height="match_parent">
<im.vector.app.features.settings.devices.v2.list.DevicesListHeaderView
android:id="@+id/devices_list_header_section_other"
android:id="@+id/deviceListHeaderSectionCurrent"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:devicesListHeaderDescription=""
app:devicesListHeaderTitle="@string/device_manager_header_section_current_session"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<im.vector.app.features.settings.devices.v2.list.CurrentSessionView
android:id="@+id/deviceListCurrentSession"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginVertical="24dp"
android:layout_marginHorizontal="16dp"
app:layout_constraintTop_toBottomOf="@id/deviceListHeaderSectionCurrent" />
<im.vector.app.features.settings.devices.v2.list.DevicesListHeaderView
android:id="@+id/deviceListHeaderSectionOther"
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" />
app:layout_constraintTop_toBottomOf="@id/deviceListCurrentSession" />
</androidx.constraintlayout.widget.ConstraintLayout>