"Learn more" button with click listener
This commit is contained in:
parent
8f218ce773
commit
60eb9b428d
@ -17,8 +17,11 @@
|
||||
package im.vector.app.features.settings.devices.v2
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
@ -46,4 +49,24 @@ class VectorSettingsDevicesFragment @Inject constructor() : VectorBaseFragment<F
|
||||
?.supportActionBar
|
||||
?.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
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ 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(
|
||||
@ -36,6 +37,8 @@ class DevicesListHeaderView @JvmOverloads constructor(
|
||||
this
|
||||
)
|
||||
|
||||
var onLearnMoreClickListener: (() -> Unit)? = null
|
||||
|
||||
init {
|
||||
context.obtainStyledAttributes(
|
||||
attrs,
|
||||
@ -55,6 +58,18 @@ class DevicesListHeaderView @JvmOverloads constructor(
|
||||
|
||||
private fun setDescription(typedArray: TypedArray) {
|
||||
val description = typedArray.getString(R.styleable.DevicesListHeaderView_devicesListHeaderDescription)
|
||||
binding.devicesListHeaderDescription.text = description
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user