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 Mapbox SDK dependency issue #2918

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Conversation

avazirna
Copy link
Contributor

@avazirna avazirna commented Dec 11, 2024

Summary

After the JCenter sunsetting we had to exclude some group dependencies from Kujaku as they were not resolving, and we added the dependecies aars and jars to the project structure. It seems that we missed one, ReLinker, a native libraries loader used by Mapbox SDK, causing CommCare to crash whenever a feature that uses that SDK is used. This PR adds that to the project.

Here's a stackstrace of one of the crashes:

FATAL EXCEPTION: main
Process: org.commcare.dalvik, PID: 14448
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/getkeepsafe/relinker/ReLinker;
	at io.realm.internal.RealmCore.loadLibrary(SourceFile:60)
	at io.realm.Realm.init(SourceFile:247)
	at io.ona.kujaku.data.realm.RealmDatabase.<init>(SourceFile:34)
	at io.ona.kujaku.data.realm.RealmDatabase.init(SourceFile:26)
	at io.ona.kujaku.KujakuLibrary.init(SourceFile:54)
	at org.commcare.gis.BaseMapboxActivity.onCreate(SourceFile:22)
	at org.commcare.gis.DrawingBoundaryActivity.onCreate(SourceFile:74)
	at android.app.Activity.performCreate(Activity.java:9001)
	at android.app.Activity.performCreate(Activity.java:8970)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4154)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4330)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2693)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:230)
	at android.os.Looper.loop(Looper.java:319)
	at android.app.ActivityThread.main(ActivityThread.java:9063)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.getkeepsafe.relinker.ReLinker" on path: DexPathList[[zip file "/data/app/~~ABKa3SgP-unHBnZtScwuMA==/org.commcare.dalvik-8qkBQ3hoPTNBufK8sdmOBw==/base.apk"],nativeLibraryDirectories=[/data/app/~~ABKa3SgP-unHBnZtScwuMA==/org.commcare.dalvik-8qkBQ3hoPTNBufK8sdmOBw==/lib/arm64, /data/app/~~ABKa3SgP-unHBnZtScwuMA==/org.commcare.dalvik-8qkBQ3hoPTNBufK8sdmOBw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:637)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
	at io.realm.internal.RealmCore.loadLibrary(SourceFile:60) 
	at io.realm.Realm.init(SourceFile:247) 
	at io.ona.kujaku.data.realm.RealmDatabase.<init>(SourceFile:34) 
	at io.ona.kujaku.data.realm.RealmDatabase.init(SourceFile:26) 
	at io.ona.kujaku.KujakuLibrary.init(SourceFile:54) 
	at org.commcare.gis.BaseMapboxActivity.onCreate(SourceFile:22) 
	at org.commcare.gis.DrawingBoundaryActivity.onCreate(SourceFile:74) 
....

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.

Safety story

I tested this fix locally and the features relying on Mapbox SDK are now working as expected.

This is needed by Realm Android Library 4.1.1 which is a dependency of Mapbox SDK
@avazirna avazirna added this to the 2.55 milestone Dec 11, 2024
@avazirna avazirna changed the base branch from master to pm_rounded_button December 11, 2024 17:36
@avazirna avazirna marked this pull request as ready for review December 11, 2024 17:36
Copy link

coderabbitai bot commented Dec 11, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request involve updates across several files, primarily focusing on the Android layout and resource files. In the AndroidManifest.xml, theme attributes have been removed from multiple activities, and the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions have been updated to include a maxSdkVersion of 32. The build.gradle file sees the addition of a new dependency for the Relinker library. New color selector XML files for button backgrounds have been created, while several drawable XML files have been introduced or modified to define various visual elements, including vector graphics and shapes. The layout files have undergone significant updates, replacing standard buttons with MaterialButton components, enhancing styling and functionality, and adjusting attributes for several UI elements. Overall, the modifications streamline the codebase, improve visual consistency, and align with Material Design principles.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant AndroidManifest
    participant BuildGradle
    participant Layouts
    participant Drawables

    User->>App: Launch Application
    App->>AndroidManifest: Load Manifest
    AndroidManifest-->>App: Apply Permissions and Activities
    App->>BuildGradle: Load Dependencies
    BuildGradle-->>App: Include Relinker Library
    App->>Layouts: Load UI Layouts
    Layouts-->>App: Render UI with MaterialButtons
    App->>Drawables: Load Visual Elements
    Drawables-->>App: Apply Styles and Colors
    User->>App: Interact with UI
Loading

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. (Experiment)
  • @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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 8

🧹 Outside diff range and nitpick comments (33)
app/res/layout/recording_fragment.xml (1)

Line range hint 71-84: LGTM with suggestions for accessibility improvements

The MaterialButton implementation follows Material Design guidelines with proper spacing and layout attributes. However, consider adding the following accessibility improvements:

 <com.google.android.material.button.MaterialButton
     android:id="@+id/action_button"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:padding="4dp"
     android:layout_marginStart="15dp"
     android:layout_marginLeft="15dp"
     android:layout_marginEnd="15dp"
     android:layout_marginRight="15dp"
     android:layout_marginBottom="15dp"
     android:layout_marginTop="15dp"
     android:gravity="center"
     tools:text="Finish"
-    android:visibility="invisible" />
+    android:visibility="invisible"
+    android:contentDescription="@string/finish_recording"
+    android:minHeight="48dp" />
app/res/layout/multiple_apps_limit_view.xml (1)

Line range hint 17-25: Enhance maintainability and accessibility of the MaterialButton.

While the migration to MaterialButton is good, consider these improvements:

  1. Move the hardcoded text to string resources
  2. Add content description for accessibility
  3. Consider applying a consistent style across all MaterialButtons

Apply this diff:

 <com.google.android.material.button.MaterialButton
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:id="@+id/back_to_manager_button"
     android:layout_marginBottom="@dimen/standard_spacer_large"
-    android:text="Go to App Manager"
+    android:text="@string/go_to_app_manager"
+    android:contentDescription="@string/go_to_app_manager_description"
     android:textSize="19sp"
     android:layout_alignParentBottom="true"
-    android:layout_centerHorizontal="true"/>
+    android:layout_centerHorizontal="true"
+    style="@style/Widget.App.MaterialButton"/>
app/res/layout/recording.xml (1)

Line range hint 1-31: Consider adding state handling for recording in progress

The layout includes a ProgressBar but could benefit from proper state management for the buttons:

 <com.google.android.material.button.MaterialButton
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:id="@+id/startrecording"
+    android:id="@+id/startrecording"
+    android:enabled="true"
     ... />

 <ProgressBar
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:visibility="gone"
     android:indeterminate="true"
     android:id="@+id/recordingprogress"
     android:background="@color/blue"/>

 <com.google.android.material.button.MaterialButton
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:id="@+id/stoprecording"
+    android:id="@+id/stoprecording"
+    android:enabled="false"
     ... />

Also, consider adding a recording duration TextView between the buttons to show the elapsed time.

app/res/layout/list_gregorian_widget.xml (3)

54-56: Consider consolidating button styles into a custom style resource.

The day increment/decrement buttons mix direct attribute settings with a base style. To improve maintainability and consistency, consider extracting these common attributes into a custom style that extends CommCare.Button.Default.

Create a new style in styles.xml:

<style name="CommCare.Button.DatePicker" parent="CommCare.Button.Default">
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">@dimen/text_largest</item>
    <item name="android:backgroundTint">@color/cc_brand_color</item>
    <item name="android:elevation">@dimen/button_elevation</item>
</style>

<style name="CommCare.Button.DatePicker.Top">
    <item name="android:background">@drawable/date_button_top</item>
</style>

<style name="CommCare.Button.DatePicker.Bottom">
    <item name="android:background">@drawable/date_button_bottom</item>
</style>

Then simplify the button declarations:

-                style="@style/CommCare.Button.Default"
-                android:background="@drawable/date_button_top"
-                android:backgroundTint="@color/cc_brand_color"
-                android:textColor="@color/white"
+                style="@style/CommCare.Button.DatePicker.Top"

Also applies to: 78-81


102-104: Maintain consistent attribute ordering across similar elements.

The month increment/decrement buttons have the same attributes but in different orders. Consider maintaining a consistent attribute ordering pattern across all similar elements for better maintainability.

Example consistent ordering:

  1. style
  2. android:background
  3. android:backgroundTint
  4. android:textColor
  5. android:elevation

Also applies to: 121-125


Line range hint 1-201: Add content descriptions for better accessibility.

The layout is well-structured, but missing content descriptions for interactive elements could impact accessibility for users with screen readers.

Add content descriptions to all buttons and image buttons:

 <Button
     android:id="@+id/dayupbtn"
+    android:contentDescription="@string/increment_day"
     ... />

 <Button
     android:id="@+id/daydownbtn"
+    android:contentDescription="@string/decrement_day"
     ... />

 <ImageButton
     android:id="@+id/clear_all"
+    android:contentDescription="@string/clear_date_selection"
     ... />

 <ImageButton
     android:id="@+id/open_calendar_bottom"
+    android:contentDescription="@string/open_calendar"
     ... />
app/res/drawable/startup_url.xml (1)

4-5: Remove unnecessary decimal points in viewport dimensions

The .0 and .5 decimal points in the viewport dimensions are unnecessary since integers would work just as well here. Consider simplifying them:

-    android:viewportWidth="300.0"
-    android:viewportHeight="232.5"
+    android:viewportWidth="300"
+    android:viewportHeight="233"
app/res/layout/blank_missing_multimedia_layout.xml (2)

Line range hint 11-14: Replace deprecated pixel units with density-independent units.

The layout uses deprecated px units which can cause inconsistent rendering across different screen densities. Consider using dp (density-independent pixels) instead.

-        android:paddingLeft="20px"
-        android:layout_marginRight="20px"
-        android:paddingTop="20px"
-        android:paddingBottom="0px"
+        android:paddingLeft="10dp"
+        android:layout_marginRight="10dp"
+        android:paddingTop="10dp"
+        android:paddingBottom="0dp"
-        android:layout_marginEnd="20px"
-        android:paddingStart="20px"
+        android:layout_marginEnd="10dp"
+        android:paddingStart="10dp"

Also applies to: 21-22


Line range hint 1-7: Consider migrating to ConstraintLayout.

While RelativeLayout works, ConstraintLayout would provide better performance and easier maintenance for complex layouts. This is a good-to-have improvement for future updates.

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

41-48: Migration to MaterialButton looks good but needs refinements.

The switch to MaterialButton aligns with Material Design best practices. However, consider these improvements:

 <com.google.android.material.button.MaterialButton
     android:id="@+id/request_button"
-    android:layout_margin="10dp"
+    android:layout_margin="@dimen/content_min_margin"
     android:layout_width="wrap_content"
     android:layout_gravity="center"
     android:layout_height="wrap_content"
     android:paddingBottom="@dimen/content_start"
+    android:paddingStart="@dimen/content_start"
+    android:paddingEnd="@dimen/content_start"
     android:paddingTop="@dimen/content_start"
+    android:contentDescription="@string/request_button_description"
+    android:text="@string/request_button_text" />

Changes suggested:

  1. Use dimension resource for margin to maintain consistency
  2. Add missing horizontal padding
  3. Add content description for accessibility
  4. Add button text
app/res/layout/custom_alert_dialog.xml (1)

74-85: Consider optimizing button attributes for better maintainability.

While the MaterialButton implementation is correct, consider these improvements:

  • Remove redundant marginRight since marginEnd serves the same purpose in RTL-aware layouts.
  • Group related attributes together (layout params, margins, styling).

Apply this diff to optimize the attributes:

 <com.google.android.material.button.MaterialButton
     android:id="@+id/positive_button"
     android:layout_width="wrap_content"
     android:layout_height="@dimen/min_button_height"
     android:layout_alignParentEnd="true"
-    android:layout_alignParentRight="true"
     android:layout_marginEnd="@dimen/standard_spacer"
-    android:layout_marginRight="@dimen/standard_spacer"
     android:layout_marginStart="@dimen/standard_spacer"
-    android:layout_marginLeft="@dimen/standard_spacer"
     android:padding="@dimen/standard_spacer"
     android:visibility="gone"
     app:strokeColor="@color/cc_brand_color"/>
app/res/layout/draw_layout.xml (2)

Line range hint 23-27: Add required MaterialButton attributes

The MaterialButton is missing essential attributes:

  • android:text or android:contentDescription for accessibility
  • style attribute to maintain consistent appearance
  • android:onClick or click handling

Apply these changes:

 <com.google.android.material.button.MaterialButton
     android:id="@+id/btnFinishDraw"
     android:layout_width="wrap_content"
     android:enabled="false"
-    android:layout_height="wrap_content"/>
+    android:layout_height="wrap_content"
+    android:text="@string/finish_drawing"
+    android:contentDescription="@string/finish_drawing_description"
+    style="@style/Widget.MaterialComponents.Button"
+    android:onClick="onFinishDrawing"/>

35-39: Consider using layout_marginEnd instead of horizontal margin

Since this button is in a LinearLayout and the parent already has horizontal margins, consider:

  1. Using only layout_marginEnd for spacing between buttons
  2. Moving margin handling to the LinearLayout level
 <com.google.android.material.button.MaterialButton
     android:id="@+id/btnResetDraw"
     android:layout_width="wrap_content"
-    android:layout_marginHorizontal="16dp"
+    android:layout_marginEnd="16dp"
     android:layout_height="wrap_content"/>
app/res/layout/screen_form_entry.xml (2)

240-249: Consider separating UI changes from SDK dependency fix

While the MaterialButton implementation follows proper Material Design guidelines, this UI change appears unrelated to the PR's primary objective of fixing Mapbox SDK dependency issues. Mixing UI changes with critical SDK fixes could:

  1. Make it harder to isolate and revert changes if issues arise
  2. Increase the risk of introducing UI regressions

Consider:

  • Moving these UI changes to a separate PR focused on Material Design updates
  • If keeping these changes, ensure thorough UI testing across different screen sizes and orientations

Line range hint 1-258: Review PR scope and separation of concerns

This file contains UI modernization changes that appear unrelated to the PR's stated objective of fixing Mapbox SDK dependency issues. While the changes themselves are technically sound, mixing UI updates with critical SDK fixes complicates:

  • Code review
  • Testing
  • Potential rollback scenarios
  • Root cause analysis if issues arise

Recommendation: Consider extracting these UI changes into a separate PR focused on Material Design updates.

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

18-27: Improve layout attributes consistency and RTL support

The ImageView attributes can be optimized for better maintainability and RTL support:

-            android:paddingLeft="8dp"
-            android:layout_marginRight="8dp"
-            android:paddingTop="8dp"
-            android:paddingBottom="0dp"
-            android:maxHeight="83dp"
-            android:maxWidth="442dp"
-            app:srcCompat="@drawable/commcare_by_dimagi"
-            android:layout_marginEnd="8dp"
-            android:paddingStart="8dp"></ImageView>
+            android:paddingHorizontal="8dp"
+            android:layout_marginEnd="8dp"
+            android:paddingTop="8dp"
+            android:maxHeight="83dp"
+            android:maxWidth="442dp"
+            app:srcCompat="@drawable/commcare_by_dimagi"
+            tools:ignore="ContentDescription" />

Changes:

  • Consolidated padding using paddingHorizontal
  • Removed redundant right/end attributes
  • Replaced empty closing tag with self-closing tag
  • Added content description ignore for accessibility

Line range hint 48-62: Enhance accessibility and maintainability of MaterialButtons

While the migration to MaterialButtons is good, there are several improvements that can be made:

  1. Add content descriptions for accessibility
  2. Move text strings to resources
  3. Consider using styles for consistent theming
             <com.google.android.material.button.MaterialButton
                 android:id="@+id/screen_bulk_form_dump"
                 android:layout_width="match_parent"
                 android:layout_margin="10dp"
                 android:layout_height="wrap_content"
                 android:layout_below="@+id/screen_bulk_form_prompt"
-                android:text="Dump Forms"/>
+                android:text="@string/dump_forms"
+                android:contentDescription="@string/dump_forms_description"
+                style="@style/Widget.App.Button"/>

             <com.google.android.material.button.MaterialButton
                 android:id="@+id/screen_bulk_form_submit"
                 android:layout_margin="10dp"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_below="@+id/screen_bulk_form_dump"
-                android:text="Submit Forms"/>
+                android:text="@string/submit_forms"
+                android:contentDescription="@string/submit_forms_description"
+                style="@style/Widget.App.Button"/>

Consider simplifying the layout hierarchy by replacing the RelativeLayout with LinearLayout since the buttons are already in a vertical arrangement. This would improve layout performance and readability.

app/res/drawable/home_logout.xml (1)

2-8: Part of systematic UI standardization

This file is part of a broader UI standardization effort, changing dimensions to 300x233dp and using @color/square_button_icon_color. While the changes are well-structured, they should be moved to a dedicated UI improvement PR to:

  1. Reduce the risk of the critical Mapbox SDK fix
  2. Allow proper UI/UX review
  3. Enable focused testing of the icon changes
app/res/drawable/home_incomplete.xml (1)

2-8: Recommend splitting UI standardization work

This file, along with the others, shows a consistent pattern of UI updates:

  • Standardizing dimensions to 300x233dp
  • Moving to resource-based colors
  • Updating vector paths

While these changes improve UI consistency, they increase the scope and testing surface of what should be a focused Mapbox SDK dependency fix. Consider:

  1. Reverting these UI changes from this PR
  2. Creating a new PR specifically for UI standardization
  3. Adding before/after screenshots in the UI-focused PR for easier review

This will help maintain the principle of single responsibility and reduce the risk of the critical SDK fix.

app/AndroidManifest.xml (1)

363-363: Consider adding exported flag to MapboxLocationPickerActivity.

For better security, consider explicitly declaring the exported attribute.

-        <activity android:name="org.commcare.gis.MapboxLocationPickerActivity" />
+        <activity 
+            android:name="org.commcare.gis.MapboxLocationPickerActivity"
+            android:exported="false" />
app/res/layout/square_button_text.xml (1)

Line range hint 1-1: Major discrepancy between PR objective and changes

The PR's objective is to fix Mapbox SDK dependency issues by including the ReLinker library, but the provided files only contain UI changes. Please:

  1. Provide the relevant build configuration changes that address the SDK dependency
  2. Explain why these UI changes are necessary for the SDK fix
  3. Consider splitting unrelated UI changes into a separate PR

This will help maintain clear traceability between the changes and their intended purpose.

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

13-18: Consider using MaterialButton for consistency

While the styling changes improve the button's appearance, other files in this PR are using MaterialButton components. For consistency across the UI, consider converting this Button to MaterialButton as well.

-    <Button
+    <com.google.android.material.button.MaterialButton
         style="@style/ScreenPinnedButton"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         app:backgroundTint="@color/cc_attention_positive_bg"
         android:textColor="@color/cc_attention_positive_text"
         android:id="@+id/entity_select_button"
         android:text="Continue"
         android:layout_below="@+id/universal_frame_tile"/>
app/res/layout/app_manager.xml (1)

Line range hint 1-1: Major discrepancy between PR objectives and actual changes

The PR objectives state this is meant to "Fix Mapbox SDK dependency issue" by including the ReLinker library. However, the changes only show UI updates (Button to MaterialButton conversions) with no modifications related to dependencies, Mapbox SDK, or the ReLinker library. Please clarify this discrepancy or ensure all necessary changes are included in the PR.

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

Line range hint 41-48: Consider applying consistent MaterialButton styling

While the transition to MaterialButton is good, consider applying a consistent style across all MaterialButtons in the app for better maintainability.

#!/bin/bash
# Search for MaterialButton style patterns across the app
rg -A 1 "MaterialButton" --type xml

Also applies to: 51-59

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

Line range hint 18-23: Add content description for accessibility

The ImageButton is missing a content description, which is required for accessibility.

Add the following attribute to the ImageButton:

 <ImageButton
     android:id="@+id/screen_multimedia_inflater_filefetch"
+    android:contentDescription="@string/multimedia_file_selector"
     ... />
app/res/layout/single_app_view.xml (2)

Line range hint 39-70: Consider separating UI updates from Mapbox SDK fixes

The MaterialButton conversions in this view appear unrelated to the PR's primary objective of fixing Mapbox SDK dependency issues. While the changes themselves are correct, consider:

  1. Separating these UI updates into a different PR to maintain focused scope
  2. Ensuring these changes don't introduce unnecessary complexity to the Mapbox SDK fix

PR scope and description mismatch needs attention

Based on the verification results:

  1. The only actual change is adding the ReLinker library dependency in build.gradle
  2. There are no changes to any Mapbox-related files in the GIS directory
  3. The UI changes in single_app_view.xml are not present in the diff, suggesting they might be from a different PR or branch

The PR description appears to be inaccurate or mixed up with another PR since:

  • No Mapbox SDK dependency issues are being addressed
  • While ReLinker is added, there are no implementation changes
  • The mentioned UI updates are not part of this PR's changes

Please:

  1. Update the PR description to accurately reflect the ReLinker library addition
  2. Create a separate PR for UI changes if needed
  3. If Mapbox SDK fixes are still needed, they should be in their own PR
🔗 Analysis chain

Line range hint 1-1: Clarify relationship between UI changes and Mapbox SDK fix

The PR description mentions fixing Mapbox SDK dependency issues and ReLinker library integration, but the provided files show primarily UI updates (Button → MaterialButton conversions). Please clarify:

  1. How do these UI changes relate to fixing the Mapbox SDK dependency issues?
  2. Where are the ReLinker library integration changes?
  3. Should these UI updates be in a separate PR to maintain clear separation of concerns?

Run this script to locate Mapbox SDK and ReLinker related changes:


Let me verify the relationship between UI changes and the dependency updates by checking for any Mapbox-related UI components.


Let me check the actual changes in this PR by looking at the git diff to understand the full scope of changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Mapbox SDK and ReLinker related changes
echo "Searching for Mapbox SDK related files..."
rg -l "mapbox|kujaku" --type gradle
rg -l "relinker" --type gradle

echo "Searching for dependency changes..."
git diff HEAD~1 -- "**/build.gradle" "**/build.gradle.kts"

Length of output: 856


Script:

#!/bin/bash
# Search for Mapbox-related UI components and usage
echo "Searching for Mapbox UI components in layout files..."
rg -l "mapbox|com\.mapbox" --type xml

echo "Searching for Mapbox imports and usage in Java/Kotlin files..."
rg -l "import.*mapbox" --type java --type kotlin

echo "Checking single_app_view.xml content..."
cat app/res/layout/single_app_view.xml

Length of output: 3728


Script:

#!/bin/bash
# Get the full diff of changes in this PR
git diff HEAD~1 --name-status

# Check if there are any changes to Mapbox-related files
echo "Checking changes in Mapbox-related files..."
git diff HEAD~1 -- app/src/org/commcare/gis/

# Check build.gradle changes in detail
echo "Checking detailed build.gradle changes..."
git diff HEAD~1 app/build.gradle

Length of output: 841

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

61-66: Consider Mapbox-specific troubleshooting options

The settings and report buttons look good with MaterialButton styling. However, since Mapbox SDK issues are a known problem, consider adding Mapbox-specific troubleshooting options in the settings or reporting flow.

Also applies to: 68-73

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

Line range hint 56-85: Unrelated UI changes in recovery screen

Multiple changes from Button to MaterialButton and layout adjustments appear unrelated to fixing the Mapbox SDK dependency issue. While these UI improvements are valuable:

  1. They increase the scope of changes in a critical fix
  2. They make it harder to isolate and test the SDK dependency fix
  3. They introduce additional risk in a recovery-related screen

Strongly recommend:

  1. Separating UI changes into a different PR
  2. Keeping this PR focused on the ReLinker library integration and Mapbox SDK fix
  3. Adding specific tests for the SDK dependency fix
app/res/layout/scrolling_calendar_widget.xml (1)

Line range hint 137-144: Externalize string and add content description

The button text should use a string resource instead of hardcoded text, and needs accessibility support:

Apply this diff:

 <com.google.android.material.button.MaterialButton
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:text="Today"
+    android:text="@string/calendar_today"
     android:id="@+id/today"
     android:layout_centerHorizontal="true"
     android:layout_marginTop="@dimen/standard_spacer"
-    android:layout_marginBottom="@dimen/standard_spacer"/>
+    android:layout_marginBottom="@dimen/standard_spacer"
+    android:contentDescription="@string/calendar_today_description"/>
app/res/layout/user_get_available_apps.xml (1)

137-142: Consider adding click feedback and accessibility attributes

While the MaterialButton implementation is correct, consider enhancing it with:

  • Content description for accessibility
  • Ripple effect for better touch feedback
 <com.google.android.material.button.MaterialButton
     android:id="@+id/get_apps_button"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/see_available_apps"
     android:paddingHorizontal="@dimen/standard_spacer_large"
-    android:layout_marginTop="@dimen/standard_spacer_double" />
+    android:layout_marginTop="@dimen/standard_spacer_double"
+    android:contentDescription="@string/see_available_apps"
+    android:stateListAnimator="@null"
+    app:rippleColor="?attr/colorControlHighlight" />
app/res/layout/missing_multimedia_layout.xml (2)

19-22: Convert px units to dp and standardize spacing attributes

While the image resource update looks good, there are some layout improvements needed:

-        android:paddingLeft="20px"
-        android:layout_marginRight="20px"
-        android:paddingTop="20px"
-        android:paddingBottom="0px"
-        android:maxHeight="135px"
-        android:maxWidth="663px"
-        android:paddingStart="20px"
-        android:layout_marginEnd="20px"
+        android:padding="16dp"
+        android:layout_marginHorizontal="16dp"
+        android:maxHeight="90dp"
+        android:maxWidth="442dp"

Rationale:

  • Replace deprecated px units with dp for consistent sizing across different screen densities
  • Use consistent spacing with padding/margin
  • Simplified horizontal spacing using layout_marginHorizontal

Line range hint 33-40: Remove redundant layout_gravity attribute

The button upgrade looks good, but there's a minor improvement needed:

         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        android:layout_gravity="bottom"
         android:text="@string/retry_button_text"

The layout_gravity attribute has no effect in a RelativeLayout and layout_alignParentBottom already handles the positioning.

🛑 Comments failed to post (8)
app/res/layout/recording.xml (2)

12-15: 🛠️ Refactor suggestion

Add essential attributes to the start recording button

The MaterialButton is missing several important attributes that would improve usability and accessibility:

 <com.google.android.material.button.MaterialButton
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:id = "@+id/startrecording"/>
+    android:id="@+id/startrecording"
+    android:text="@string/start_recording"
+    android:contentDescription="@string/start_recording_description"
+    android:layout_margin="@dimen/button_margin"
+    style="@style/Widget.MaterialComponents.Button.Icon"
+    app:icon="@drawable/ic_record"/>

Committable suggestion skipped: line range outside the PR's diff.


26-29: 🛠️ Refactor suggestion

Add essential attributes to the stop recording button

Similar to the start button, this MaterialButton needs proper attributes for better user experience:

 <com.google.android.material.button.MaterialButton
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
-    android:id="@+id/stoprecording"/>
+    android:id="@+id/stoprecording"
+    android:text="@string/stop_recording"
+    android:contentDescription="@string/stop_recording_description"
+    android:layout_margin="@dimen/button_margin"
+    style="@style/Widget.MaterialComponents.Button.Icon"
+    app:icon="@drawable/ic_stop"/>

Committable suggestion skipped: line range outside the PR's diff.

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

20-22: 💡 Codebase verification

Style conflict confirmed - backgroundTint will override custom drawable states

The current changes create a styling conflict:

  • The existing drawables (date_button_top.xml and date_button_bottom.xml) define custom gradient backgrounds with different states (pressed, focused, default) and rounded corners
  • Setting backgroundTint="@color/cc_brand_color" will overlay a solid color on top of these drawables, effectively hiding their gradient and state-based styling
  • The CommCare.Button.Default style explicitly sets backgroundTint="@null" to allow custom backgrounds, but this is being overridden

Recommendations:

  • Remove the backgroundTint attribute to preserve the existing state-based styling with gradients
  • If a solid brand color is desired, remove the background drawables instead and keep the backgroundTint
  • Consider updating the drawable definitions directly if brand colors should be incorporated into the state-based styling
🔗 Analysis chain

Potential style conflict between background drawable and backgroundTint

Each button has both a background drawable (e.g., @drawable/date_button_top) and a backgroundTint. This combination might lead to unexpected visual results as both attributes affect the button's background appearance. Consider either:

  1. Removing the background drawables if the new styling is intended to replace them
  2. Removing the backgroundTint if the drawable styling should be preserved

Let's check the drawable definitions:

Also applies to: 24-24, 43-45, 47-47, 58-60, 62-62, 88-90, 92-92, 103-105, 107-107, 133-135, 137-137


Let me check the content of these drawable files to understand their styling and potential conflicts with backgroundTint.


Let me check the CommCare.Button.Default style definition to fully understand the styling conflict.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the content of the button background drawables
for drawable in date_button_top date_button_bottom date_edit; do
  echo "=== $drawable ==="
  fd -e xml "$drawable" app/res/drawable
done

Length of output: 593


Script:

#!/bin/bash
# Check the content of the drawable XML files
echo "=== date_button_top.xml ==="
cat app/res/drawable/date_button_top.xml

echo -e "\n=== date_button_bottom.xml ==="
cat app/res/drawable/date_button_bottom.xml

echo -e "\n=== date_edit.xml ==="
cat app/res/drawable/date_edit.xml

# Also let's check the CommCare.Button.Default style definition
echo -e "\n=== Looking for CommCare.Button.Default style ==="
rg -l "CommCare\.Button\.Default" app/res/values/

Length of output: 5257


Script:

#!/bin/bash
# Check the content of themes.xml for the CommCare.Button.Default style
echo "=== CommCare.Button.Default style definition ==="
rg -A 10 "CommCare\.Button\.Default" app/res/values/themes.xml

Length of output: 685

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

98-111: 💡 Codebase verification

Remove redundant strokeColor attribute from MaterialButton

The strokeColor attribute is already defined in the NegativeButtonShapeAppearanceStyle style, which is referenced by NegativeButtonStyle. This creates unnecessary duplication that could lead to maintenance issues.

  • Remove app:strokeColor="@color/cc_brand_color" from custom_alert_dialog.xml
  • Also clean up the deprecated RTL attributes as suggested
🔗 Analysis chain

Review style implementation and attribute redundancy.

While the MaterialButton implementation is correct, there are a few considerations:

  1. The strokeColor might be redundantly defined if it's already part of NegativeButtonStyle.
  2. The same attribute optimization suggestions from previous buttons apply here.

Let's verify the style definition:

If strokeColor is defined in the style, apply this diff:

 <com.google.android.material.button.MaterialButton
     android:id="@+id/negative_button"
     style="@style/NegativeButtonStyle"
     android:layout_width="wrap_content"
     android:layout_height="@dimen/min_button_height"
     android:layout_marginEnd="@dimen/standard_spacer"
-    android:layout_marginRight="@dimen/standard_spacer"
     android:layout_marginStart="@dimen/standard_spacer"
-    android:layout_marginLeft="@dimen/standard_spacer"
     android:layout_toStartOf="@id/neutral_button"
-    android:layout_toLeftOf="@id/neutral_button"
     android:padding="@dimen/standard_spacer"
     android:visibility="gone"
-    app:strokeColor="@color/cc_brand_color"/>
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if strokeColor is defined in the style
rg -A 10 "style name=\"NegativeButtonStyle\"" app/res/values/styles.xml

Length of output: 844

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

41-44: ⚠️ Potential issue

Maintain consistency with MaterialButton attributes

Similar to btnFinishDraw, this button needs essential attributes for proper functionality and accessibility.

Apply these changes:

 <com.google.android.material.button.MaterialButton
     android:id="@+id/btnCancelDraw"
     android:layout_width="wrap_content"
-    android:layout_height="wrap_content"/>
+    android:layout_height="wrap_content"
+    android:text="@string/cancel_drawing"
+    android:contentDescription="@string/cancel_drawing_description"
+    style="@style/Widget.MaterialComponents.Button"
+    android:onClick="onCancelDrawing"/>

Committable suggestion skipped: line range outside the PR's diff.

app/build.gradle (1)

108-108: 💡 Codebase verification

ReLinker dependency added but implementation missing

The ReLinker library has been added as a dependency, but there's no evidence of its actual implementation in the codebase. For proper native library loading with Mapbox SDK, ReLinker needs to be initialized in the Application class.

  • Add ReLinker initialization in your Application class
  • Example usage: ReLinker.loadLibrary(this, "your-native-library")
🔗 Analysis chain

LGTM: ReLinker dependency added correctly.

The addition of ReLinker library (v1.4.4) is appropriate for handling native library loading for the Mapbox SDK. This addresses the core issue mentioned in the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify ReLinker usage in the codebase
# Check if ReLinker is properly initialized in Application class
ast-grep --pattern 'class $_ extends Application {
  $$$
  onCreate() {
    $$$
    ReLinker.$$$
    $$$
  }
  $$$
}'

Length of output: 119


Script:

#!/bin/bash
# Search for any ReLinker usage in the codebase
rg -i "ReLinker" -A 3

# Also check for any Application class that might be using different ReLinker initialization pattern
ast-grep --pattern 'class $_ extends Application {
  $$$
  onCreate($$$) {
    $$$
  }
}'

Length of output: 479

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

67-72: 💡 Codebase verification

Apply consistent MaterialButton styling with predefined styles

The cancel button in activity_mapbox_location_picker.xml lacks a style attribute while other Mapbox-related screens use predefined styles like @style/MapButtonGreen, @style/MapButtonRed, and @style/MapButtonOrange for their MaterialButtons. Consider applying an appropriate predefined style to maintain consistency.

  • In activity_mapbox_location_picker.xml, add a suitable style attribute to the cancel button (e.g., style="@style/MapButtonRed" for cancel actions)
🔗 Analysis chain

Consider consistent styling across Mapbox screens

The MaterialButton migration looks good. However, ensure this styling is consistent across all Mapbox-related screens for a unified user experience.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all layout files containing Mapbox-related views
rg -l "KujakuMapView" app/res/layout/

Length of output: 175


Script:

#!/bin/bash
# Check button styling in Mapbox-related layouts
rg -A 5 "MaterialButton|Button" app/res/layout/activity_drawing_boundary.xml app/res/layout/activity_entity_mapbox.xml

Length of output: 2706

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

96-101: 🛠️ Refactor suggestion

Add missing text and content description attributes

The MaterialButton is missing required attributes:

  • android:text to display the button label
  • android:contentDescription for accessibility support

Apply this diff:

 <com.google.android.material.button.MaterialButton
     android:id="@+id/RestartCommCare"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
-    android:layout_margin="@dimen/content_min_margin"/>
+    android:layout_margin="@dimen/content_min_margin"
+    android:text="@string/restart_commcare"
+    android:contentDescription="@string/restart_commcare_description"/>

Committable suggestion skipped: line range outside the PR's diff.

Base automatically changed from pm_rounded_button to master December 11, 2024 23:56
@avazirna
Copy link
Contributor Author

@damagatchi retest this please

@avazirna avazirna merged commit 1f6925a into master Dec 12, 2024
6 of 11 checks passed
@avazirna avazirna deleted the fix-mapbox-sdk-dependency-issue branch December 12, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants