Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix part of #5661: Add Missing style Attributes to TextViews #5682

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
19 changes: 5 additions & 14 deletions app/src/main/res/layout-land/walkthrough_final_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@

<TextView
android:id="@+id/walkthrough_final_no_text_view"
style="@style/WalkthroughFinalNoTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif"
android:text="@string/no"
android:textColor="@color/component_color_shared_primary_text_color"
android:textSize="20sp" />
android:text="@string/no" />

<TextView
android:id="@+id/walkthrough_final_no_center_text_view"
Expand Down Expand Up @@ -88,13 +86,11 @@

<TextView
android:id="@+id/walkthrough_final_yes_text_view"
style="@style/WalkthroughFinalYesTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif"
android:text="@string/yes"
android:textColor="@color/component_color_shared_secondary_6_text_color"
android:textSize="20sp" />
android:text="@string/yes" />

<TextView
android:id="@+id/walkthrough_final_yes_center_text_view"
Expand Down Expand Up @@ -127,12 +123,7 @@

<TextView
android:id="@+id/walkthrough_final_title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:text="@string/great"
android:textColor="@color/component_color_shared_primary_text_color"
android:textSize="24sp"
style="@style/WalkthroughFinalTitleTextViewStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/walkthrough_final_image_view"
app:layout_constraintTop_toTopOf="@+id/walkthrough_final_image_view" />
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/drawer_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@

<TextView
android:id="@+id/developer_options_text_view"
style="@style/DeveloperOptionsTextViewStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dp"
android:fontFamily="sans-serif-medium"
android:text="@string/developer_options"
android:textColor="@{footerViewModel.isDeveloperOptionsSelected ? @color/component_color_drawer_fragment_developer_options_selected_text_color : @color/component_color_shared_primary_dark_text_color}"
android:textSize="14sp" />
android:textColor="@{footerViewModel.isDeveloperOptionsSelected ? @color/component_color_drawer_fragment_developer_options_selected_text_color : @color/component_color_shared_primary_dark_text_color}" />
</LinearLayout>

<LinearLayout
Expand Down
11 changes: 1 addition & 10 deletions app/src/main/res/layout/lessons_completed_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,12 @@

<TextView
android:id="@+id/chapter_index"
android:layout_width="wrap_content"
android:layout_height="match_parent"
style="@style/ChapterIndexTextViewStyle"
android:background="@color/component_color_lessons_tab_activity_lessons_completed_chapter_index_background_color"
android:fontFamily="sans-serif"
android:gravity="center"
android:importantForAccessibility="yes"
android:minWidth="60dp"
android:minHeight="48dp"
android:paddingStart="8dp"
android:paddingTop="12dp"
android:paddingEnd="8dp"
android:paddingBottom="12dp"
android:text="@{viewModel.computePlayChapterIndexText()}"
android:textColor="@color/component_color_shared_secondary_4_text_color"
android:textSize="20sp"
android:contentDescription="@{viewModel.computeChapterPlayStateIconContentDescription()}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,14 @@

<TextView
android:id="@+id/chapter_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/ChapterIndexTextViewStyle"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:fontFamily="sans-serif"
android:importantForAccessibility="no"
android:minWidth="20dp"
android:minHeight="20dp"
android:text="@{viewModel.computePlayChapterIndexText()}"
android:textAlignment="center"
android:textColor="@color/component_color_shared_secondary_4_text_color"
android:textSize="16sp" />
android:textAlignment="center" />

<ImageView
android:id="@+id/chapter_play_state_icon"
Expand Down
8 changes: 2 additions & 6 deletions app/src/main/res/layout/lessons_locked_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,14 @@

<TextView
android:id="@+id/chapter_index"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/ChapterIndexTextViewStyle"
android:layout_gravity="center"
android:layout_marginStart="10dp"
android:fontFamily="sans-serif"
android:importantForAccessibility="no"
android:minWidth="20dp"
android:minHeight="20dp"
android:text="@{viewModel.computePlayChapterIndexText()}"
android:textAlignment="center"
android:textColor="@color/component_color_shared_secondary_4_text_color"
android:textSize="16sp" />
android:textAlignment="center" />

<ImageView
android:id="@+id/chapter_play_state_icon"
Expand Down
11 changes: 1 addition & 10 deletions app/src/main/res/layout/lessons_not_started_chapter_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,11 @@

<TextView
android:id="@+id/chapter_index"
android:layout_width="wrap_content"
android:layout_height="match_parent"
style="@style/ChapterIndexTextViewStyle"
android:layout_marginStart="0dp"
android:background="@drawable/chapter_dark_green_bg_with_bright_green_border"
android:fontFamily="sans-serif"
android:gravity="center"
android:importantForAccessibility="no"
android:minWidth="60dp"
android:minHeight="48dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:text="@{viewModel.computePlayChapterIndexText()}"
android:textColor="@color/component_color_shared_secondary_4_text_color"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

<TextView
android:id="@+id/onboarding_language_text_view"
style="@style/OnboardingLanguageTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:padding="@dimen/onboarding_shared_padding_medium"
android:textColor="@color/component_color_onboarding_shared_text_color"
android:textSize="@dimen/onboarding_shared_text_size_medium"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is preferrable to keep constraints here instead of in styles, because it makes maintenance easier, and for reusability. Another vioew using this style will likely not have the same constraints.

android:text="Language"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hardcoded string was not part of the original attributes. Why has it been added?

/>
</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

<TextView
android:id="@+id/test_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:padding="10dp"
android:text="@string/app_name"
android:textSize="18sp" />
</layout>
style="@style/TestTextViewStyle"
android:text="@string/app_name" />
</layout>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an extra line at the end of the file, same for the rest.

22 changes: 7 additions & 15 deletions app/src/main/res/layout/walkthrough_final_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@

<TextView
android:id="@+id/walkthrough_final_no_text_view"
style="@style/WalkthroughFinalNoTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif"
android:text="@string/no"
android:textColor="@color/component_color_shared_primary_text_color"
android:textSize="20sp" />
android:text="@string/no" />

<TextView
android:id="@+id/walkthrough_final_no_center_text_view"
Expand Down Expand Up @@ -93,13 +91,12 @@

<TextView
android:id="@+id/walkthrough_final_yes_text_view"
style="@style/WalkthroughFinalYesTextViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:fontFamily="sans-serif"
android:text="@string/yes"
android:textColor="@color/component_color_shared_secondary_6_text_color"
android:textSize="20sp" />
android:text="@string/yes" />


<TextView
android:id="@+id/walkthrough_final_yes_center_text_view"
Expand Down Expand Up @@ -134,16 +131,11 @@

<TextView
android:id="@+id/walkthrough_final_title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/WalkthroughFinalTitleTextViewStyle"
android:layout_marginTop="32dp"
android:fontFamily="sans-serif"
android:text="@string/great"
android:textColor="@color/component_color_shared_primary_text_color"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</layout>
</layout>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always add an extra line at the end of the file

58 changes: 58 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -826,4 +826,62 @@
<item name="endIconDrawable">@drawable/ic_arrow_drop_down_black_24dp</item>
<item name="endIconTint">@color/component_color_shared_black_background_color</item>
</style>

<style name="WalkthroughFinalNoTextViewStyle" parent="TextView.Common1">
<item name="android:fontFamily">sans-serif</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/component_color_shared_primary_text_color</item>
</style>

<style name="WalkthroughFinalYesTextViewStyle" parent="TextView.Common1">
<item name="android:fontFamily">sans-serif</item>
<item name="android:textSize">20sp</item>
<item name="android:textColor">@color/component_color_shared_secondary_6_text_color</item>
</style>

<style name="DeveloperOptionsTextViewStyle" parent="TextView.Common1">
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@color/component_color_shared_primary_dark_text_color</item>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textColor is not needed

</style>

<style name="OnboardingLanguageTextViewStyle" parent="TextView.Common1">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
Comment on lines +849 to +850
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These attributes are duplicated in the view using this style. Android will prioritize the attributes added directly to the view over the ones from the style, and if they are the same, then these here become redudant

<item name="android:textSize">16sp</item>
<item name="android:textColor">@color/component_color_shared_primary_text_color</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:padding">8dp</item>
</style>

<style name="WalkthroughFinalTitleTextViewStyle" parent="TextView.Common1">
Copy link
Collaborator

@manas-yu manas-yu Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android:text="@string/great" need to be included

<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">24sp</item>
<item name="android:textColor">@color/component_color_shared_primary_text_color</item>
<item name="android:fontFamily">sans-serif</item>
</style>

<style name="ChapterIndexTextViewStyle" parent="TextView.Common1">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This style is used in 4 places, but it contains some attributes that dont have the same values for the different screens, e.g minWidth and minHeight, as well as padding values, are not consistent. The style should be trimmed down to what is similar accross all 4 views, and whatever is different should be maintained directly in the view.

<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item>
<item name="android:textSize">20sp</item>
<item name="android:textColor">@color/component_color_shared_secondary_4_text_color</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:gravity">center</item>
<item name="android:minWidth">60dp</item>
<item name="android:minHeight">48dp</item>
<item name="android:paddingStart">8dp</item>
<item name="android:paddingEnd">8dp</item>
</style>

<style name="TestTextViewStyle" parent="TextView.Common1">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:padding">10dp</item>
<item name="android:textSize">18sp</item>
<item name="android:textColor">@color/component_color_shared_primary_text_color</item>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textColor attribute not needed

</style>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,6 @@ private class TextViewStyleCheck {

// TODO(#5661): Add missing styles for TextView IDs.
private val attributeIds = listOf(
"@+id/developer_options_text_view",
"@+id/onboarding_language_text_view",
"@+id/walkthrough_final_no_text_view",
"@+id/walkthrough_final_yes_text_view",
"@+id/walkthrough_final_title_text_view",
"@+id/chapter_index",
"@+id/chapter_index",
"@+id/test_text_view",
"@+id/feedback_text_view",
"@+id/item_selection_contents_text_view",
"@+id/learner_analytics_sync_status_text_view",
Expand Down
Loading