Implemented collapsing
This commit is contained in:
parent
f4c7fad039
commit
73d8570997
|
@ -15,6 +15,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import kotlinx.android.synthetic.main.dialog_enter_tan.*
|
import kotlinx.android.synthetic.main.dialog_enter_tan.*
|
||||||
import kotlinx.android.synthetic.main.dialog_enter_tan.view.*
|
import kotlinx.android.synthetic.main.dialog_enter_tan.view.*
|
||||||
|
import kotlinx.android.synthetic.main.view_collapsible_text.view.*
|
||||||
import net.dankito.banking.ui.android.R
|
import net.dankito.banking.ui.android.R
|
||||||
import net.dankito.banking.ui.android.adapter.TanMediumAdapter
|
import net.dankito.banking.ui.android.adapter.TanMediumAdapter
|
||||||
import net.dankito.banking.ui.android.adapter.TanProceduresAdapter
|
import net.dankito.banking.ui.android.adapter.TanProceduresAdapter
|
||||||
|
@ -85,8 +86,7 @@ open class EnterTanDialog : DialogFragment() {
|
||||||
|
|
||||||
setupTanView(rootView)
|
setupTanView(rootView)
|
||||||
|
|
||||||
rootView.txtTanDescriptionToShowToUser.text = tanChallenge.messageToShowToUser.getSpannedFromHtml()
|
rootView.txtvwCollapsibleText.text = tanChallenge.messageToShowToUser.getSpannedFromHtml()
|
||||||
rootView.lytTanDescriptionToShowToUser.setMaxHeightInDp(145)
|
|
||||||
|
|
||||||
if (tanChallenge.tanProcedure.allowedTanFormat == AllowedTanFormat.Numeric) {
|
if (tanChallenge.tanProcedure.allowedTanFormat == AllowedTanFormat.Numeric) {
|
||||||
rootView.edtxtEnteredTan.inputType = InputType.TYPE_CLASS_NUMBER
|
rootView.edtxtEnteredTan.inputType = InputType.TYPE_CLASS_NUMBER
|
||||||
|
|
|
@ -10,6 +10,7 @@ import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import net.dankito.banking.ui.android.R
|
import net.dankito.banking.ui.android.R
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package net.dankito.banking.ui.android.views
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.widget.ScrollView
|
||||||
|
import kotlinx.android.synthetic.main.view_collapsible_text.view.*
|
||||||
|
import net.dankito.banking.ui.android.R
|
||||||
|
|
||||||
|
|
||||||
|
open class CollapsibleTextView @JvmOverloads constructor(
|
||||||
|
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||||
|
) : ScrollView(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
|
protected var isCollapsed = true
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
setupUi(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupUi(context: Context) {
|
||||||
|
val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
|
||||||
|
val rootView = inflater.inflate(R.layout.view_collapsible_text, this, true)
|
||||||
|
|
||||||
|
rootView.txtvwCollapsibleText.setOnClickListener { toggleIsCollapsed() }
|
||||||
|
rootView.btnExpandCollapseTextView.setOnClickListener { toggleIsCollapsed() }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected open fun toggleIsCollapsed() {
|
||||||
|
if (isCollapsed) {
|
||||||
|
txtvwCollapsibleText.maxLines = Int.MAX_VALUE
|
||||||
|
btnExpandCollapseTextView.setImageResource(R.drawable.ic_baseline_expand_less_24)
|
||||||
|
|
||||||
|
isCollapsed = false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
txtvwCollapsibleText.maxLines = 3
|
||||||
|
btnExpandCollapseTextView.setImageResource(R.drawable.ic_baseline_expand_more_24)
|
||||||
|
|
||||||
|
isCollapsed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/>
|
||||||
|
</vector>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
|
||||||
|
</vector>
|
|
@ -95,19 +95,11 @@
|
||||||
android:text="@string/dialog_enter_tan_tan_description_label"
|
android:text="@string/dialog_enter_tan_tan_description_label"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<net.dankito.banking.ui.android.views.MaxHeightScrollView
|
<net.dankito.banking.ui.android.views.CollapsibleTextView
|
||||||
android:id="@+id/lytTanDescriptionToShowToUser"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
>
|
|
||||||
|
|
||||||
<TextView
|
</net.dankito.banking.ui.android.views.CollapsibleTextView>
|
||||||
android:id="@+id/txtTanDescriptionToShowToUser"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</net.dankito.banking.ui.android.views.MaxHeightScrollView>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView
|
||||||
|
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_height="match_parent"
|
||||||
|
>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/lytCollapsibleText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvwCollapsibleText"
|
||||||
|
android:maxLines="3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/btnExpandCollapseTextView"
|
||||||
|
android:layout_width="@dimen/view_collapsible_text_collapse_expand_icon_size"
|
||||||
|
android:layout_height="@dimen/view_collapsible_text_collapse_expand_icon_size"
|
||||||
|
android:layout_below="@+id/txtvwCollapsibleText"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_marginTop="@dimen/view_collapsible_text_collapse_expand_icon_margin_top"
|
||||||
|
android:background="@null"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
app:srcCompat="@drawable/ic_baseline_expand_more_24"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
|
@ -121,4 +121,7 @@
|
||||||
<dimen name="dialog_send_message_log_message_log_label_bottom_margin">8dp</dimen>
|
<dimen name="dialog_send_message_log_message_log_label_bottom_margin">8dp</dimen>
|
||||||
<dimen name="dialog_send_message_log_buttons_width">120dp</dimen>
|
<dimen name="dialog_send_message_log_buttons_width">120dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="view_collapsible_text_collapse_expand_icon_size">36dp</dimen>
|
||||||
|
<dimen name="view_collapsible_text_collapse_expand_icon_margin_top">-8dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue