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

CCCT-625 || Improve cards UI #2925

Open
wants to merge 1 commit into
base: connect_qa
Choose a base branch
from

Conversation

j13panchal
Copy link

Improve cards UI

Summary

https://dimagi.atlassian.net/browse/CCCT-625

Feature Flag

Product Description

PR Checklist

  • If I think the PR is high risk, "High Risk" label is set
  • I have confidence that this PR will not introduce a regression for the reasons below
  • Do we need to enhance manual QA test coverage ? If yes, "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, "Release Note" label is set and a "Release Note" is specified in PR description.

Automated test coverage

Safety story

Improve cards UI
Copy link

coderabbitai bot commented Dec 17, 2024

📝 Walkthrough

Walkthrough

This pull request introduces significant UI modifications across multiple layout files and corresponding Java classes in the CommCare Connect application. The primary changes involve transitioning from ConstraintLayout to CardView for alert tiles, replacing ConnectMediumTextView with RoundedButton for interactive elements, and updating various text views and layout parameters.

The modifications span several key files:

  • Layout files for home screen, jobs list, and delivery progress
  • Fragment classes for connect jobs and delivery progress
  • The ConnectManager utility class

The changes reflect a comprehensive UI enhancement strategy, focusing on improving visual presentation, interactivity, and component styling. The new implementation introduces more sophisticated UI components like CardView with shadow and elevation attributes, and RoundedButton with custom styling options. These changes suggest a move towards a more modern and visually consistent user interface design.

The modifications maintain the existing functional logic while updating the UI components and their interactions, indicating a careful approach to UI refactoring.

Suggested labels

release-ui-update, android-layout-refactor, component-styling

Suggested reviewers

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (6)
app/res/layout-land/home_screen.xml (1)

8-13: Consider using ConstraintLayout for better performance.

The use of multiple layout_alignParent* attributes suggests this layout could benefit from using ConstraintLayout as the root element for better performance and easier maintenance.

app/res/layout/fragment_connect_delivery_progress.xml (2)

63-66: Consider removing redundant shadow attributes

The shadow attributes (android:shadowColor, android:shadowDx, android:shadowDy, android:shadowRadius) are redundant since CardView already provides elevation-based shadows through the app:cardElevation attribute.

-    android:shadowColor="@color/connect_light_grey_transparent"
-    android:shadowDx="30"
-    android:shadowDy="30"
-    android:shadowRadius="50"

107-108: Standardize text size attributes

There's an inconsistency between android:textSize (18sp) and app:roundButtonTextSize (5.0sp). Consider standardizing to use either one of these attributes consistently.

-    android:textSize="18sp"
-    app:roundButtonTextSize="5.0sp"
+    android:textSize="18sp"

Also applies to: 113-114, 123-124, 131-132

app/res/layout/fragment_connect_jobs_list.xml (2)

32-48: Consider optimizing elevation and shadow values

While the CardView implementation is good, the current values might be too aggressive:

  • Shadow radius of 50 is quite large
  • Shadow offset of 30dp in both directions is excessive
  • CardView elevation of 5dp combined with large shadows might create an overly dramatic effect

Consider these more subtle values:

-        android:shadowRadius="50"
-        android:shadowDx="30"
-        android:shadowDy="30"
+        android:shadowRadius="20"
+        android:shadowDx="10"
+        android:shadowDy="10"
         app:cardElevation="5dp"

78-110: Fix text size inconsistency and button styling

There are several inconsistencies in the button implementations:

  1. Text size mismatch: android:textSize="18sp" vs app:roundButtonTextSize="5.0sp"
  2. Both buttons have android:textColor="@color/blue" but different app:roundButtonTextColor

Apply consistent styling:

         android:layout_height="35dp"
-        android:textSize="18sp"
-        android:textColor="@color/blue"
+        android:textSize="16sp"
+        android:textColor="@color/white"
-        app:roundButtonTextSize="5.0sp"
+        app:roundButtonTextSize="16sp"

Also, consider following Material Design guidelines for button pairs:

  • Primary action (Yes): Filled button (current implementation is correct)
  • Secondary action (No): Outlined button (current implementation is correct)
app/res/layout/home_screen.xml (1)

Line range hint 135-143: Remove commented-out button code

Keeping commented-out code can lead to confusion and maintenance issues. If this feature is planned for future implementation, it should be tracked in the issue tracker instead.

-<!--                    <org.commcare.views.connect.RoundedButton-->
-<!--                        android:id="@+id/btnOverLimit"-->
-<!--                        android:layout_width="wrap_content"-->
-<!--                        android:layout_height="30dp"-->
-<!--                        android:text="@string/connect_job_tile_daily_limit"-->
-<!--                        app:layout_constraintBottom_toBottomOf="parent"-->
-<!--                        app:layout_constraintEnd_toEndOf="parent"-->
-<!--                        app:layout_constraintTop_toTopOf="parent"-->
-<!--                        app:roundButtonTextSize="4sp" />-->
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b28dcc and 355ac2a.

📒 Files selected for processing (7)
  • app/res/layout-land/home_screen.xml (2 hunks)
  • app/res/layout/fragment_connect_delivery_progress.xml (4 hunks)
  • app/res/layout/fragment_connect_jobs_list.xml (2 hunks)
  • app/res/layout/home_screen.xml (1 hunks)
  • app/src/org/commcare/connect/ConnectManager.java (3 hunks)
  • app/src/org/commcare/fragments/connect/ConnectDeliveryProgressFragment.java (3 hunks)
  • app/src/org/commcare/fragments/connect/ConnectJobsListsFragment.java (2 hunks)
🔇 Additional comments (10)
app/src/org/commcare/fragments/connect/ConnectJobsListsFragment.java (3)

22-22: LGTM: Import addition aligns with UI improvements

The addition of CardView import is consistent with the UI enhancement objectives.


65-65: Verify smooth visual transitions with CardView

The migration from ConstraintLayout to CardView is a good improvement for visual hierarchy. However, please ensure:

  1. Any existing animations or transitions still work smoothly
  2. The elevation and shadows are consistent with other cards in the app
✅ Verification successful

CardView migration appears safe - no animation dependencies found

The change from ConstraintLayout to CardView appears safe as there are no animations or transitions tied to this view. The search across the codebase shows that CardView is consistently used in other connect-related fragments, making this change align with the existing pattern. Since no animation or transition code was found in the fragment or related layout files, the migration should not cause any visual disruption.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for animation-related code for the connect_alert_tile
rg -l "connect_alert_tile.*\.(animate|transition)" 

# Search for other CardView usage patterns in the codebase
rg "CardView.*connect" 

Length of output: 624


Script:

#!/bin/bash
# Search for any animation or transition code in the ConnectJobsListsFragment
ast-grep --pattern 'animate($$$)' app/src/org/commcare/fragments/connect/ConnectJobsListsFragment.java
rg "transition|animation" app/src/org/commcare/fragments/connect/ConnectJobsListsFragment.java

# Check layout XML for any animation or transition attributes
fd "connect.*\.xml" app/res/layout --exec rg "android:animation|android:transition|@anim|@transition" {}

Length of output: 310


Line range hint 164-171: Verify ConnectManager compatibility with CardView

The updateSecondaryPhoneConfirmationTile method interacts with ConnectManager. Please ensure:

  1. ConnectManager.updateSecondaryPhoneConfirmationTile properly handles CardView attributes
  2. Click handlers and visibility changes work as expected with the new CardView
✅ Verification successful

CardView handling is properly implemented and compatible

The verification shows that ConnectManager correctly handles the CardView:

  1. ConnectManager.updateSecondaryPhoneConfirmationTile() properly manages visibility with tile.setVisibility()
  2. Click handlers are correctly set up and passed through from the fragment
  3. The view hierarchy is maintained with proper view finding using tile.findViewById()
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check ConnectManager implementation for CardView compatibility
ast-grep --pattern 'class ConnectManager {
  $$$
  updateSecondaryPhoneConfirmationTile($_, $_, $_, $_) {
    $$$
  }
  $$$
}'

# Search for any similar CardView visibility patterns
rg "CardView.*setVisibility|visibility.*CardView"

Length of output: 180


Script:

#!/bin/bash
# Let's try a broader search for ConnectManager class and its methods
rg -A 5 "class ConnectManager"

# Search for updateSecondaryPhoneConfirmationTile method
rg -A 10 "updateSecondaryPhoneConfirmationTile"

# Look for CardView related code in the fragment
fd -e java ConnectJobsListsFragment.java --exec cat {}

Length of output: 23595

app/res/layout-land/home_screen.xml (1)

36-37: Verify visibility state handling.

The CardView has android:visibility="gone" while its child ConstraintLayout has android:visibility="visible". This might cause unexpected behavior.

Also applies to: 47-47

app/res/layout/fragment_connect_delivery_progress.xml (1)

Line range hint 202-210: LGTM! TabLayout implementation follows Material Design guidelines

The TabLayout implementation is well-structured with appropriate styling and custom indicator.

app/src/org/commcare/fragments/connect/ConnectDeliveryProgressFragment.java (1)

50-50: LGTM! Type changes align with UI improvements

The variable type changes from TextView to ConnectRegularTextView and RoundedButton are consistent with the UI improvements in the layout file.

Also applies to: 97-97, 103-103

app/src/org/commcare/connect/ConnectManager.java (1)

Line range hint 297-315: LGTM! Method changes improve flexibility and UI consistency

The changes to updateSecondaryPhoneConfirmationTile are well-implemented:

  • More flexible parameter type (View instead of ConstraintLayout)
  • Consistent use of RoundedButton matching the UI improvements
app/res/layout/fragment_connect_jobs_list.xml (2)

8-8: LGTM: Proper background color implementation

Using a color resource for the background is the correct approach.


127-134: LGTM: Well-configured RecyclerView

The RecyclerView implementation follows best practices with proper constraints and preview support.

app/res/layout/home_screen.xml (1)

12-30: Maintain consistent card styling across layouts

The shadow and elevation values should be optimized similar to the suggestion in fragment_connect_jobs_list.xml.

Comment on lines +38 to +46
<ImageView
android:id="@+id/connect_secondary_phone_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/phone_heart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/black" />
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add content description for phone icon

The ImageView is missing a content description, which is important for accessibility.

         <ImageView
             android:id="@+id/connect_secondary_phone_icon"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
+            android:contentDescription="@string/connect_secondary_phone_icon_description"
             android:src="@drawable/phone_heart"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintStart_toStartOf="parent"
             app:layout_constraintTop_toTopOf="parent"
             app:tint="@color/black" />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<ImageView
android:id="@+id/connect_secondary_phone_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/phone_heart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/black" />
<ImageView
android:id="@+id/connect_secondary_phone_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/connect_secondary_phone_icon_description"
android:src="@drawable/phone_heart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="@color/black" />

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.

2 participants