Add headerSubtitle to ActionHeaderLayout

This commit is contained in:
Rahul Patel
2024-07-21 15:52:24 +05:30
parent afe9affa05
commit 3be0812dd0
6 changed files with 34 additions and 29 deletions

View File

@@ -51,19 +51,30 @@ class ActionHeaderLayout : RelativeLayout {
binding = ViewActionHeaderBinding.bind(view)
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ActionHeaderLayout)
val textPrimary = typedArray.getString(R.styleable.ActionHeaderLayout_headerTitle)
val textTitle = typedArray.getString(R.styleable.ActionHeaderLayout_headerTitle)
val textSubtitle = typedArray.getString(R.styleable.ActionHeaderLayout_headerSubtitle)
typedArray.recycle()
textPrimary?.let {
textTitle?.let {
binding.txtTitle.text = it
}
textSubtitle?.let {
binding.txtSubtitle.visibility = View.VISIBLE
binding.txtSubtitle.text = it
}
}
fun setHeader(header: String?) {
fun setTitle(header: String?) {
binding.txtTitle.text = header
}
fun setSubTitle(subHeader: String?) {
binding.txtSubtitle.visibility = View.VISIBLE
binding.txtSubtitle.text = subHeader
}
fun addClickListener(onclickListener: OnClickListener?) {
binding.imgAction.visibility = View.VISIBLE
binding.imgAction.setOnClickListener(onclickListener)

View File

@@ -952,7 +952,7 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
)
}
}
txtPermissionCount.text = ("${app.permissions.size} permissions")
headerPermission.setSubTitle(("${app.permissions.size} permissions"))
}
}

View File

@@ -34,14 +34,6 @@
android:id="@+id/header_permission"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:headerTitle="@string/details_permission" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_permission_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/padding_xsmall"
android:paddingEnd="@dimen/padding_xsmall"
android:textAppearance="@style/TextAppearance.Aurora.Line1"
tools:text="16 permissions" />
app:headerTitle="@string/details_permission"
tools:headerSubtitle="36 permissions" />
</LinearLayout>

View File

@@ -34,23 +34,14 @@
android:id="@+id/header_privacy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:headerSubtitle="@string/exodus_powered"
app:headerTitle="@string/details_privacy" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/header_privacy"
android:text="@string/exodus_powered"
android:textAppearance="@style/TextAppearance.Aurora.Line3" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txt_subtitle"
android:layout_alignStart="@id/txt_subtitle"
android:layout_alignEnd="@id/txt_subtitle"
android:layout_below="@id/header_privacy"
android:text="@string/exodus_progress"
android:textAppearance="@style/TextAppearance.Aurora.Line1" />
@@ -60,8 +51,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txt_status"
android:layout_alignStart="@id/txt_subtitle"
android:layout_alignEnd="@id/txt_subtitle"
android:layout_gravity="center_vertical"
android:text="@string/action_request_analysis"
app:cornerRadius="@dimen/margin_small" />

View File

@@ -31,11 +31,23 @@
style="@style/AuroraTextStyle.Subtitle.Alt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_toStartOf="@id/img_action"
android:ellipsize="end"
android:maxLines="1"
tools:text="Header" />
tools:text="Title" />
<TextView
android:id="@+id/txt_subtitle"
style="@style/AuroraTextStyle.Line2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/txt_title"
android:layout_toStartOf="@id/img_action"
android:ellipsize="end"
android:maxLines="1"
android:visibility="gone"
tools:text="Subtitle"
tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/img_action"

View File

@@ -29,6 +29,7 @@
<declare-styleable name="ActionHeaderLayout">
<attr name="headerTitle" format="string" />
<attr name="headerSubtitle" format="string" />
</declare-styleable>
<declare-styleable name="StateButton">