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 #3972: Added TextViewStyleCheck script #5599

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

manas-yu
Copy link
Collaborator

@manas-yu manas-yu commented Dec 16, 2024

Explanation

Fix #3972

This PR adds a script, TextViewStyleCheck.kt, which ensures that all TextView elements in the layout XML files use centrally managed styles. If any TextView does not have a style attribute that starts with @style/, an error is reported, indicating the file path where the violation occurs.

bazel run //scripts:check_textview_styles -- $(pwd)

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

@manas-yu manas-yu requested review from a team as code owners December 16, 2024 19:24
@manas-yu
Copy link
Collaborator Author

manas-yu commented Dec 16, 2024

@adhiamboperes PTAL. I've added the TextViewStyleCheck.kt script, and it's identifying TextView elements in some layout files that do not have the style attribute (i.e., they are missing the @style/ reference).

Could you please confirm if this output is appropriate? If there’s an issue with the script or if you’d like any adjustments, please let me know!

Here is the current output:

Files being reported

bazel run //scripts:check_textview_styles -- $(pwd)
INFO: Analyzed target //scripts:check_textview_styles (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //scripts:check_textview_styles up-to-date:
  bazel-bin/scripts/check_textview_styles.jar
  bazel-bin/scripts/check_textview_styles.jdeps
INFO: Elapsed time: 1.388s, Critical Path: 1.09s
INFO: 3 processes: 1 internal, 1 linux-sandbox, 1 worker.
INFO: Build completed successfully, 3 total actions
INFO: Running command line: bazel-bin/scripts/check_textview_styles /home/manas/opensource/oppia-android
TextView Style Check FAILED:
/home/manas/opensource/oppia-android/app/src/main/res/layout-land/question_player_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-land/profile_progress_header.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-land/create_profile_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-land/walkthrough_final_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-port/onboarding_app_language_selection_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-port/question_player_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-port/onboarding_profile_type_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-port/create_profile_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/feedback_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/test_text_view_for_int_with_data_binding.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/beta_notice_dialog_content.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/story_header_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/drawer_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/test_margin_bindable_adapter_activity.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/selection_interaction_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/question_player_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/multiple_choice_interaction_items.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/profile_reset_pin_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/onboarding_language_dropdown_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/lessons_completed_chapter_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/audio_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/app_version_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/state_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/test_text_view_for_live_data_with_data_binding.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/app_language_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/content_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/onboarding_profile_type_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/bottom_sheet_options_menu_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/submitted_answer_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/lessons_in_progress_chapter_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/coming_soon_topic_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/revision_card_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/profile_list_sync_status_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/lessons_locked_chapter_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/license_text_viewer_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/create_profile_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/walkthrough_welcome_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/test_text_view_bindable_adapter_activity.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/story_chapter_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/item_selection_interaction_items.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/profile_picture_edit_dialog.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/audio_language_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/walkthrough_topic_summary_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/walkthrough_final_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/lessons_not_started_chapter_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/promoted_story_card.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/profile_list_learner_id_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/survey_multiple_choice_item.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/general_availability_upgrade_notice_dialog_content.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout/welcome.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-land/onboarding_app_language_selection_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-land/question_player_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-land/onboarding_profile_type_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-land/create_profile_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-land/topic_info_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp-land/resume_lesson_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp/option_activity.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp/options_without_drawer_activity.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp/profile_progress_header.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp/administrator_controls_activity.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp/revision_card_fragment.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp/story_chapter_view.xml
/home/manas/opensource/oppia-android/app/src/main/res/layout-sw600dp/profile_chooser_fragment.xml
Exception in thread "main" java.lang.Exception: Some TextView elements do not have centrally managed styles.
        at org.oppia.android.scripts.xml.TextViewStyleCheckKt.main(TextViewStyleCheck.kt:55)

Copy link

Coverage Report

Results

Number of files assessed: 1
Overall Coverage: 0.00%
Coverage Analysis: FAIL

Failure Cases

File Failure Reason Status
TextViewStyleCheck.ktscripts/src/java/org/oppia/android/scripts/xml/TextViewStyleCheck.kt
No appropriate test file found for scripts/src/java/org/oppia/android/scripts/xml/TextViewStyleCheck.kt.

To learn more, visit the Oppia Android Code Coverage wiki page

Copy link

APK & AAB differences analysis

Note that this is a summarized snapshot. See the CI artifacts for detailed differences.

Dev

Expand to see flavor specifics

Universal APK

APK file size: 19 MiB (old), 19 MiB (new), 0 bytes (No change)

APK download size (estimated): 17 MiB (old), 17 MiB (new), 6 bytes (Added)

Method count: 260195 (old), 260195 (new), 0 (No change)

Features: 2 (old), 2 (new), 0 (No change)

Permissions: 6 (old), 6 (new), 0 (No change)

Resources: 6818 (old), 6818 (new), 0 (No change)

  • Anim: 43 (old), 43 (new), 0 (No change)
  • Animator: 26 (old), 26 (new), 0 (No change)
  • Array: 15 (old), 15 (new), 0 (No change)
  • Attr: 922 (old), 922 (new), 0 (No change)
  • Bool: 9 (old), 9 (new), 0 (No change)
  • Color: 967 (old), 967 (new), 0 (No change)
  • Dimen: 1048 (old), 1048 (new), 0 (No change)
  • Drawable: 380 (old), 380 (new), 0 (No change)
  • Id: 1275 (old), 1275 (new), 0 (No change)
  • Integer: 37 (old), 37 (new), 0 (No change)
  • Interpolator: 11 (old), 11 (new), 0 (No change)
  • Layout: 380 (old), 380 (new), 0 (No change)
  • Menu: 3 (old), 3 (new), 0 (No change)
  • Mipmap: 1 (old), 1 (new), 0 (No change)
  • Plurals: 10 (old), 10 (new), 0 (No change)
  • Raw: 2 (old), 2 (new), 0 (No change)
  • String: 852 (old), 852 (new), 0 (No change)
  • Style: 831 (old), 831 (new), 0 (No change)
  • Xml: 6 (old), 6 (new), 0 (No change)

Lesson assets: 111 (old), 111 (new), 0 (No change)

AAB differences

Expand to see AAB specifics

Supported configurations:

  • hdpi (same)
  • ldpi (same)
  • mdpi (same)
  • tvdpi (same)
  • xhdpi (same)
  • xxhdpi (same)
  • xxxhdpi (same)

Base APK

APK file size: 18 MiB (old), 18 MiB (new), 0 bytes (No change)
APK download size (estimated): 17 MiB (old), 17 MiB (new), 5 bytes (Added)

Configuration hdpi

APK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change)
APK download size (estimated): 18 KiB (old), 18 KiB (new), 0 bytes (No change)

Configuration ldpi

APK file size: 49 KiB (old), 49 KiB (new), 0 bytes (No change)
APK download size (estimated): 14 KiB (old), 14 KiB (new), 0 bytes (No change)

Configuration mdpi

APK file size: 45 KiB (old), 45 KiB (new), 0 bytes (No change)
APK download size (estimated): 14 KiB (old), 14 KiB (new), 0 bytes (No change)

Configuration tvdpi

APK file size: 86 KiB (old), 86 KiB (new), 0 bytes (No change)
APK download size (estimated): 29 KiB (old), 29 KiB (new), 0 bytes (No change)

Configuration xhdpi

APK file size: 57 KiB (old), 57 KiB (new), 0 bytes (No change)
APK download size (estimated): 21 KiB (old), 21 KiB (new), 0 bytes (No change)

Configuration xxhdpi

APK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change)
APK download size (estimated): 29 KiB (old), 29 KiB (new), 0 bytes (No change)

Configuration xxxhdpi

APK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change)
APK download size (estimated): 28 KiB (old), 28 KiB (new), 0 bytes (No change)

Alpha

Expand to see flavor specifics

Universal APK

APK file size: 11 MiB (old), 11 MiB (new), 4 bytes (Removed)

APK download size (estimated): 10 MiB (old), 10 MiB (new), 0 bytes (No change)

Method count: 116265 (old), 116265 (new), 0 (No change)

Features: 2 (old), 2 (new), 0 (No change)

Permissions: 6 (old), 6 (new), 0 (No change)

Resources: 5786 (old), 5786 (new), 0 (No change)

  • Anim: 33 (old), 33 (new), 0 (No change)
  • Animator: 24 (old), 24 (new), 0 (No change)
  • Array: 14 (old), 14 (new), 0 (No change)
  • Attr: 888 (old), 888 (new), 0 (No change)
  • Bool: 8 (old), 8 (new), 0 (No change)
  • Color: 820 (old), 820 (new), 0 (No change)
  • Dimen: 780 (old), 780 (new), 0 (No change)
  • Drawable: 342 (old), 342 (new), 0 (No change)
  • Id: 1221 (old), 1221 (new), 0 (No change)
  • Integer: 32 (old), 32 (new), 0 (No change)
  • Interpolator: 11 (old), 11 (new), 0 (No change)
  • Layout: 343 (old), 343 (new), 0 (No change)
  • Menu: 1 (old), 1 (new), 0 (No change)
  • Mipmap: 1 (old), 1 (new), 0 (No change)
  • Plurals: 10 (old), 10 (new), 0 (No change)
  • String: 785 (old), 785 (new), 0 (No change)
  • Style: 472 (old), 472 (new), 0 (No change)
  • Xml: 1 (old), 1 (new), 0 (No change)

Lesson assets: 111 (old), 111 (new), 0 (No change)

AAB differences

Expand to see AAB specifics

Supported configurations:

  • hdpi (same)
  • ldpi (same)
  • mdpi (same)
  • tvdpi (same)
  • xhdpi (same)
  • xxhdpi (same)
  • xxxhdpi (same)

Base APK

APK file size: 11 MiB (old), 11 MiB (new), 0 bytes (No change)
APK download size (estimated): 10 MiB (old), 10 MiB (new), 11 bytes (Removed)

Configuration hdpi

APK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change)
APK download size (estimated): 17 KiB (old), 17 KiB (new), 0 bytes (No change)

Configuration ldpi

APK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change)
APK download size (estimated): 13 KiB (old), 13 KiB (new), 0 bytes (No change)

Configuration mdpi

APK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change)
APK download size (estimated): 13 KiB (old), 13 KiB (new), 0 bytes (No change)

Configuration tvdpi

APK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change)
APK download size (estimated): 27 KiB (old), 27 KiB (new), 0 bytes (No change)

Configuration xhdpi

APK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change)
APK download size (estimated): 20 KiB (old), 20 KiB (new), 0 bytes (No change)

Configuration xxhdpi

APK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change)
APK download size (estimated): 28 KiB (old), 28 KiB (new), 0 bytes (No change)

Configuration xxxhdpi

APK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change)
APK download size (estimated): 27 KiB (old), 27 KiB (new), 0 bytes (No change)

Beta

Expand to see flavor specifics

Universal APK

APK file size: 11 MiB (old), 11 MiB (new), 0 bytes (No change)

APK download size (estimated): 10 MiB (old), 10 MiB (new), 0 bytes (No change)

Method count: 116271 (old), 116271 (new), 0 (No change)

Features: 2 (old), 2 (new), 0 (No change)

Permissions: 6 (old), 6 (new), 0 (No change)

Resources: 5786 (old), 5786 (new), 0 (No change)

  • Anim: 33 (old), 33 (new), 0 (No change)
  • Animator: 24 (old), 24 (new), 0 (No change)
  • Array: 14 (old), 14 (new), 0 (No change)
  • Attr: 888 (old), 888 (new), 0 (No change)
  • Bool: 8 (old), 8 (new), 0 (No change)
  • Color: 820 (old), 820 (new), 0 (No change)
  • Dimen: 780 (old), 780 (new), 0 (No change)
  • Drawable: 342 (old), 342 (new), 0 (No change)
  • Id: 1221 (old), 1221 (new), 0 (No change)
  • Integer: 32 (old), 32 (new), 0 (No change)
  • Interpolator: 11 (old), 11 (new), 0 (No change)
  • Layout: 343 (old), 343 (new), 0 (No change)
  • Menu: 1 (old), 1 (new), 0 (No change)
  • Mipmap: 1 (old), 1 (new), 0 (No change)
  • Plurals: 10 (old), 10 (new), 0 (No change)
  • String: 785 (old), 785 (new), 0 (No change)
  • Style: 472 (old), 472 (new), 0 (No change)
  • Xml: 1 (old), 1 (new), 0 (No change)

Lesson assets: 111 (old), 111 (new), 0 (No change)

AAB differences

Expand to see AAB specifics

Supported configurations:

  • hdpi (same)
  • ldpi (same)
  • mdpi (same)
  • tvdpi (same)
  • xhdpi (same)
  • xxhdpi (same)
  • xxxhdpi (same)

Base APK

APK file size: 11 MiB (old), 11 MiB (new), 0 bytes (No change)
APK download size (estimated): 10 MiB (old), 10 MiB (new), 41 bytes (Added)

Configuration hdpi

APK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change)
APK download size (estimated): 17 KiB (old), 17 KiB (new), 0 bytes (No change)

Configuration ldpi

APK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change)
APK download size (estimated): 13 KiB (old), 13 KiB (new), 0 bytes (No change)

Configuration mdpi

APK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change)
APK download size (estimated): 13 KiB (old), 13 KiB (new), 0 bytes (No change)

Configuration tvdpi

APK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change)
APK download size (estimated): 27 KiB (old), 27 KiB (new), 0 bytes (No change)

Configuration xhdpi

APK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change)
APK download size (estimated): 20 KiB (old), 20 KiB (new), 0 bytes (No change)

Configuration xxhdpi

APK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change)
APK download size (estimated): 28 KiB (old), 28 KiB (new), 0 bytes (No change)

Configuration xxxhdpi

APK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change)
APK download size (estimated): 27 KiB (old), 27 KiB (new), 0 bytes (No change)

Ga

Expand to see flavor specifics

Universal APK

APK file size: 11 MiB (old), 11 MiB (new), 4 bytes (Removed)

APK download size (estimated): 10 MiB (old), 10 MiB (new), 8 bytes (Added)

Method count: 116271 (old), 116271 (new), 0 (No change)

Features: 2 (old), 2 (new), 0 (No change)

Permissions: 6 (old), 6 (new), 0 (No change)

Resources: 5786 (old), 5786 (new), 0 (No change)

  • Anim: 33 (old), 33 (new), 0 (No change)
  • Animator: 24 (old), 24 (new), 0 (No change)
  • Array: 14 (old), 14 (new), 0 (No change)
  • Attr: 888 (old), 888 (new), 0 (No change)
  • Bool: 8 (old), 8 (new), 0 (No change)
  • Color: 820 (old), 820 (new), 0 (No change)
  • Dimen: 780 (old), 780 (new), 0 (No change)
  • Drawable: 342 (old), 342 (new), 0 (No change)
  • Id: 1221 (old), 1221 (new), 0 (No change)
  • Integer: 32 (old), 32 (new), 0 (No change)
  • Interpolator: 11 (old), 11 (new), 0 (No change)
  • Layout: 343 (old), 343 (new), 0 (No change)
  • Menu: 1 (old), 1 (new), 0 (No change)
  • Mipmap: 1 (old), 1 (new), 0 (No change)
  • Plurals: 10 (old), 10 (new), 0 (No change)
  • String: 785 (old), 785 (new), 0 (No change)
  • Style: 472 (old), 472 (new), 0 (No change)
  • Xml: 1 (old), 1 (new), 0 (No change)

Lesson assets: 111 (old), 111 (new), 0 (No change)

AAB differences

Expand to see AAB specifics

Supported configurations:

  • hdpi (same)
  • ldpi (same)
  • mdpi (same)
  • tvdpi (same)
  • xhdpi (same)
  • xxhdpi (same)
  • xxxhdpi (same)

Base APK

APK file size: 11 MiB (old), 11 MiB (new), 4 bytes (Removed)
APK download size (estimated): 10 MiB (old), 10 MiB (new), 2 bytes (Removed)

Configuration hdpi

APK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change)
APK download size (estimated): 17 KiB (old), 17 KiB (new), 0 bytes (No change)

Configuration ldpi

APK file size: 44 KiB (old), 44 KiB (new), 0 bytes (No change)
APK download size (estimated): 13 KiB (old), 13 KiB (new), 0 bytes (No change)

Configuration mdpi

APK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change)
APK download size (estimated): 13 KiB (old), 13 KiB (new), 0 bytes (No change)

Configuration tvdpi

APK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change)
APK download size (estimated): 27 KiB (old), 27 KiB (new), 0 bytes (No change)

Configuration xhdpi

APK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change)
APK download size (estimated): 20 KiB (old), 20 KiB (new), 0 bytes (No change)

Configuration xxhdpi

APK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change)
APK download size (estimated): 28 KiB (old), 28 KiB (new), 0 bytes (No change)

Configuration xxxhdpi

APK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change)
APK download size (estimated): 27 KiB (old), 27 KiB (new), 0 bytes (No change)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CI check to ensure all TextViews have a style check
1 participant