Skip to content

Commit

Permalink
refactor: Use ConstrainedWidth/ConstrainedHeight to enforce WRAP cons…
Browse files Browse the repository at this point in the history
…traints
  • Loading branch information
kaushiknsanji committed Oct 26, 2019
1 parent 419dee3 commit d2557a6
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 25 deletions.
4 changes: 3 additions & 1 deletion app/src/main/res/layout/highlights_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@

<TextView
android:id="@+id/hl_article_section_text_id"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:layout_marginBottom="@dimen/hl_article_section_text_margin_bottom"
android:layout_marginTop="@dimen/hl_article_section_text_margin_top"
android:ellipsize="end"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/nav_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
<TextView
android:id="@+id/nav_item_text_id"
style="@style/ConstraintRightCenterVerticalStyle"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:layout_marginLeft="@dimen/nav_item_text_margin_left"
android:layout_marginStart="@dimen/nav_item_text_margin_left"
android:textColor="@color/nav_item_text_color_selector"
Expand Down
16 changes: 12 additions & 4 deletions app/src/main/res/layout/news_article_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@

<TextView
android:id="@+id/article_title_text_id"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:layout_marginTop="@dimen/news_item_8dip_margin"
android:textColor="@color/newsTitleTextColor"
android:textSize="@dimen/news_title_text_size"
Expand All @@ -77,8 +79,10 @@

<TextView
android:id="@+id/article_trail_text_id"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:ellipsize="end"
android:maxLines="@integer/article_trail_text_max_lines_expanded"
android:textColor="@color/newsTrialTextColor"
Expand All @@ -92,9 +96,11 @@

<TextView
android:id="@+id/article_publisher_text_id"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
android:layout_marginTop="@dimen/news_item_4dip_margin"
app:layout_constraintHorizontal_bias="0"
android:ellipsize="end"
android:maxLines="@integer/article_publisher_text_max_lines_collapsed"
android:textColor="@color/newsPublisherTextColor"
Expand All @@ -110,8 +116,10 @@

<TextView
android:id="@+id/article_published_date_text_id"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:layout_marginBottom="@dimen/news_item_4dip_margin"
android:layout_marginTop="@dimen/news_item_8dip_margin"
android:textColor="@color/newsDateTextColorTeal900"
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/no_feed_help_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@

<TextView
android:id="@+id/nfhi_resolution_text_id"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
android:layout_marginLeft="@dimen/nfhi_internal_margin"
android:layout_marginStart="@dimen/nfhi_internal_margin"
android:textColor="@color/nfhiResolutionTextColor"
Expand Down
22 changes: 10 additions & 12 deletions app/src/main/res/layout/page_number_picker_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,24 @@
android:text="@string/page_number_picker_title_text"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@android:color/white"
android:textStyle="bold" />
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/page_number_picker_id"
app:layout_constraintVertical_chainStyle="spread_inside" />

<NumberPicker
android:id="@+id/page_number_picker_id"
style="@style/ConstraintCenterHorizontalStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
android:layout_marginEnd="@dimen/material_dialog_padding"
android:layout_marginLeft="@dimen/material_dialog_padding"
android:layout_marginRight="@dimen/material_dialog_padding"
android:layout_marginStart="@dimen/material_dialog_padding"
android:layout_marginTop="@dimen/page_number_picker_margin_top"
android:minWidth="@dimen/number_picker_min_width"
android:solidColor="@android:color/white"
app:layout_constraintBottom_toTopOf="@+id/page_number_picker_set_btn_id"
app:layout_constraintTop_toBottomOf="@id/page_number_picker_title_text_id" />

<Button
Expand All @@ -57,28 +61,22 @@
android:layout_marginEnd="@dimen/page_number_picker_cancel_btn_margin_right"
android:layout_marginRight="@dimen/page_number_picker_cancel_btn_margin_right"
android:text="@string/page_number_picker_cancel_button_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toBottomOf="@+id/page_number_picker_set_btn_id"
app:layout_constraintEnd_toStartOf="@+id/page_number_picker_set_btn_id"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/page_number_picker_set_btn_id"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/page_number_picker_id" />
app:layout_constraintTop_toTopOf="@+id/page_number_picker_set_btn_id" />

<Button
android:id="@+id/page_number_picker_set_btn_id"
style="@style/PaginationNumberPickerButtonsStyle"
android:layout_marginEnd="@dimen/page_number_picker_set_btn_margin_right"
android:layout_marginLeft="@dimen/page_number_picker_set_btn_margin_left"
android:layout_marginRight="@dimen/page_number_picker_set_btn_margin_right"
android:layout_marginStart="@dimen/page_number_picker_set_btn_margin_left"
android:layout_marginTop="@dimen/page_number_picker_buttons_margin_top"
android:layout_marginBottom="@dimen/page_number_picker_buttons_margin_bottom"
android:text="@string/page_number_picker_set_button_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toRightOf="@id/page_number_picker_cancel_btn_id"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toEndOf="@id/page_number_picker_cancel_btn_id"
app:layout_constraintTop_toBottomOf="@id/page_number_picker_id" />
app:layout_constraintTop_toBottomOf="@+id/page_number_picker_id" />

</android.support.constraint.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/pref_date_picker_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<DatePicker
android:id="@+id/pref_date_picker_id"
style="@style/ConstraintCenterHorizontalStyle"
android:layout_width="wrap_content"
android:layout_width="@dimen/match_constraint_0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/dp_bottom_space_id"
app:layout_constraintTop_toBottomOf="@id/dp_top_space_id" />
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/pref_number_picker_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
style="@style/ConstraintCenterHorizontalStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedHeight="true"
android:minWidth="@dimen/number_picker_min_width"
android:solidColor="@android:color/darker_gray"
app:layout_constraintBottom_toTopOf="@+id/np_bottom_space_id"
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,11 @@
<dimen name="page_number_picker_title_text_padding_bottom">12dp</dimen>
<dimen name="page_number_picker_button_text_size">15sp</dimen>
<dimen name="page_number_picker_buttons_margin_top">32dp</dimen>
<dimen name="page_number_picker_cancel_btn_margin_right">4dp</dimen>
<dimen name="page_number_picker_cancel_btn_margin_right">8dp</dimen>
<dimen name="page_number_picker_buttons_margin_bottom">8dp</dimen>
<dimen name="page_number_picker_buttons_content_padding">8dp</dimen>
<dimen name="page_number_picker_buttons_min_width">64dp</dimen>
<dimen name="page_number_picker_buttons_height">36dp</dimen>
<dimen name="page_number_picker_set_btn_margin_left">4dp</dimen>
<dimen name="page_number_picker_set_btn_margin_right">8dp</dimen>

<!-- ================= -->
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">@dimen/page_number_picker_buttons_height</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:layout_marginTop">@dimen/page_number_picker_buttons_margin_top</item>
<item name="android:layout_marginBottom">@dimen/page_number_picker_buttons_margin_bottom
</item>
<item name="android:paddingLeft">@dimen/page_number_picker_buttons_content_padding</item>
<item name="android:paddingStart" tools:targetApi="jelly_bean_mr1">
@dimen/page_number_picker_buttons_content_padding
Expand Down

0 comments on commit d2557a6

Please sign in to comment.