Skip to content

Commit

Permalink
Apply the correct reader button style in the empty feed views
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Horta committed Jan 26, 2024
1 parent 7fca92c commit d02fa9e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,7 @@ class ActionableEmptyView : LinearLayout {
bottomImage = layout.findViewById(R.id.bottom_image)
progressBar = layout.findViewById(R.id.actionable_empty_view_progress_bar)

attrs.let {
val typedArray = context.obtainStyledAttributes(
it,
R.styleable.ActionableEmptyView,
0,
0
)

context.obtainStyledAttributes(attrs, R.styleable.ActionableEmptyView, 0, 0).use { typedArray ->
val imageResource = typedArray.getResourceId(
R.styleable.ActionableEmptyView_aevImage,
0
Expand All @@ -83,6 +76,10 @@ class ActionableEmptyView : LinearLayout {
val titleAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevTitle)
val subtitleAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevSubtitle)
val buttonAttribute = typedArray.getString(R.styleable.ActionableEmptyView_aevButton)
val buttonStyleAttribute = typedArray.getInt(
R.styleable.ActionableEmptyView_aevButtonStyle,
BUTTON_STYLE_PRIMARY
)

if (imageResource != 0) {
image.setImageResource(imageResource)
Expand All @@ -107,7 +104,10 @@ class ActionableEmptyView : LinearLayout {
button.visibility = View.VISIBLE
}

typedArray.recycle()
if (buttonStyleAttribute == BUTTON_STYLE_READER) {
button.backgroundTintList = context.getColorStateList(R.color.reader_button_primary_background_selector)
button.setTextColor(context.getColorStateList(R.color.reader_button_primary_text))
}
}
}

Expand Down Expand Up @@ -163,4 +163,9 @@ class ActionableEmptyView : LinearLayout {

announceForAccessibility("${title.text}.$subTitle")
}

companion object {
private const val BUTTON_STYLE_PRIMARY = 0
private const val BUTTON_STYLE_READER = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
app:aevImage="@drawable/illustration_reader_empty"
app:aevSubtitle="@string/reader_discover_no_posts_subscribe_subtitle"
app:aevTitle="@string/reader_discover_no_posts_title"
app:aevButtonStyle="reader"
tools:visibility="visible" />

<org.wordpress.android.util.widgets.CustomSwipeRefreshLayout
Expand Down
1 change: 1 addition & 0 deletions WordPress/src/main/res/layout/reader_empty_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:layout_marginTop="@dimen/toolbar_height"
android:visibility="gone"
app:aevButton="@string/reader_no_followed_blogs_button_discover"
app:aevButtonStyle="reader"
app:aevSubtitle="@string/reader_no_followed_blogs_description"
app:aevTitle="@string/reader_no_followed_blogs_title"
tools:visibility="visible" />
1 change: 1 addition & 0 deletions WordPress/src/main/res/layout/reader_fragment_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:layout_height="match_parent"
android:visibility="gone"
app:aevTitle="@string/reader_no_recommended_blogs_title"
app:aevButtonStyle="reader"
tools:visibility="visible" />

</RelativeLayout>
1 change: 1 addition & 0 deletions WordPress/src/main/res/layout/reader_no_site_to_reblog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
android:layout_height="match_parent"
android:layout_marginTop="@dimen/toolbar_height"
app:aevButton="@string/reader_no_blog_to_reblog_action"
app:aevButtonStyle="reader"
app:aevImage="@drawable/illustration_reader_empty"
app:aevImageHiddenInLandscape="true"
app:aevSubtitle="@string/reader_no_blog_to_reblog_detail"
Expand Down
5 changes: 5 additions & 0 deletions WordPress/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@
<attr name="aevSubtitle" format="string"/>
<!-- Required: string text of title -->
<attr name="aevTitle" format="string"/>
<!-- Optional: style to set the button UI attributes -->
<attr name="aevButtonStyle" format="enum">
<enum name="primary" value="0"/>
<enum name="reader" value="1"/>
</attr>
</declare-styleable>

<!--
Expand Down

0 comments on commit d02fa9e

Please sign in to comment.