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: Android build fixes #4984

Merged
merged 2 commits into from
Mar 18, 2025

Conversation

vaxi87
Copy link
Contributor

@vaxi87 vaxi87 commented Mar 18, 2025

What does this PR do?

Fixes for the following:

  • App crash fix for older kotlin version (some annotations)
  • Dialog closing prevented on scroll
  • proguard fixes

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues
  • First PR at Formbricks? Please sign the CLA! Without it we wont be able to merge it 🙏

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Summary by CodeRabbit

  • New Features

    • Main screen now features an updated layout with a centered “Click me!” button.
    • The application adopts a refreshed light theme without an action bar for a modern look.
  • Refactor

    • Switched from a dynamic UI approach to a traditional layout for a more consistent user experience.
    • Adjusted dialog behavior so that prompts now require direct engagement without accidental dismissal.
  • Chores

    • Upgraded underlying dependencies and library versions to enhance performance and stability.

Copy link

vercel bot commented Mar 18, 2025

@vaxi87 is attempting to deploy a commit to the formbricks Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

github-actions bot commented Mar 18, 2025

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

coderabbitai bot commented Mar 18, 2025

Walkthrough

The pull request introduces several changes across the Android project. In the build configuration, four new dependencies have been added to the Gradle file, and new library version references have been set in the version catalog. The AndroidManifest.xml has been updated to modify the main activity’s theme and remove an unused attribute. The main activity’s implementation has been refactored from a Compose-based UI to a traditional XML layout approach, with adjustments made to window insets handling and SDK configuration. Additionally, multiple UI theme files (related to color, typography, and theming) have been removed. ProGuard rules have been updated to modify class retention policies for several classes in the Formbricks SDK. A new layout file (activity_main.xml) has been introduced, and several model files in the SDK have been cleaned up by removing experimental serialization annotations and unused imports.

Possibly related PRs

  • fix: Fix Android build setting #4967: The changes in the main PR, which involve adding new dependencies in the build.gradle.kts file, are related to the modifications in the retrieved PR that also affects the build.gradle.kts file by changing the minSdk version, indicating both PRs are focused on configuration adjustments within the same file.

Suggested labels

bug, 🕹️ oss.gg, 🕹️ 50 points

Suggested reviewers

  • Dhruwang

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc8a51 and dbb70ad.

📒 Files selected for processing (2)
  • packages/android/app/src/main/java/com/formbricks/demo/MainActivity.kt (1 hunks)
  • packages/android/gradle/libs.versions.toml (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Run Linters / Linters
  • GitHub Check: Run E2E Tests / Run E2E Tests
🔇 Additional comments (5)
packages/android/gradle/libs.versions.toml (1)

29-30: LGTM - Appropriate dependencies for traditional XML layout approach!

The addition of androidx.activity (1.10.1) and androidx.constraintlayout (2.1.4) supports the transition from Compose-based UI to traditional XML layouts. Both versions match the current stable releases.

Also applies to: 63-64

packages/android/app/src/main/java/com/formbricks/demo/MainActivity.kt (4)

4-9: LGTM - Good transition to AppCompatActivity and traditional XML layouts!

The change from FragmentActivity to AppCompatActivity with the corresponding imports provides better compatibility across different Android versions. This aligns with the PR objective to fix issues with older Kotlin versions.

Also applies to: 13-13, 16-16


18-18: Configuration values should be externalized

The API host and environment ID are still hardcoded as string literals ("[appUrl]","[environmentId]"). Consider externalizing these values to BuildConfig or a configuration file.

-        val config = FormbricksConfig.Builder("[appUrl]","[environmentId]")
+        val config = FormbricksConfig.Builder(BuildConfig.API_HOST, BuildConfig.ENVIRONMENT_ID)

26-31: LGTM - Proper edge-to-edge display handling!

The implementation correctly sets up window insets listeners to handle edge-to-edge content display while accounting for system UI elements (status bar, navigation bar). This prevents UI elements from being cut off.


33-36: LGTM - Button click tracking properly implemented!

The button click handler is properly implemented with the Formbricks tracking call, which matches the PR objectives for fixing dialog issues when scrolling.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @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
Contributor

@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: 2

🧹 Nitpick comments (1)
packages/android/app/src/main/res/layout/activity_main.xml (1)

1-21: Layout looks good but needs minor improvements

The layout structure is solid, using ConstraintLayout properly for positioning the button. However, there are a few best practices that could be implemented:

  1. The button text should use a string resource rather than hardcoded text for better internationalization support
  2. The tools:layout_editor_absoluteX and tools:layout_editor_absoluteY attributes are unnecessary when using constraints
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
-        android:text="Click me!"
+        android:text="@string/button_click_me"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
-        tools:layout_editor_absoluteX="158dp"
-        tools:layout_editor_absoluteY="336dp" />
</androidx.constraintlayout.widget.ConstraintLayout>

Also, don't forget to add the string resource to your strings.xml file:

<string name="button_click_me">Click me!</string>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6a123a2 and 7fc8a51.

📒 Files selected for processing (18)
  • packages/android/app/build.gradle.kts (1 hunks)
  • packages/android/app/src/main/AndroidManifest.xml (2 hunks)
  • packages/android/app/src/main/java/com/formbricks/demo/MainActivity.kt (1 hunks)
  • packages/android/app/src/main/java/com/formbricks/demo/ui/theme/Color.kt (0 hunks)
  • packages/android/app/src/main/java/com/formbricks/demo/ui/theme/Theme.kt (0 hunks)
  • packages/android/app/src/main/java/com/formbricks/demo/ui/theme/Type.kt (0 hunks)
  • packages/android/app/src/main/res/layout/activity_main.xml (1 hunks)
  • packages/android/formbricksSDK/consumer-rules.pro (1 hunks)
  • packages/android/formbricksSDK/proguard-rules.pro (1 hunks)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/ActionClass.kt (0 hunks)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/ActionClassReference.kt (0 hunks)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/EnvironmentData.kt (0 hunks)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/EnvironmentResponseData.kt (0 hunks)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/Project.kt (0 hunks)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/Survey.kt (0 hunks)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/network/FormbricksApiService.kt (2 hunks)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/webview/FormbricksFragment.kt (1 hunks)
  • packages/android/gradle/libs.versions.toml (2 hunks)
💤 Files with no reviewable changes (9)
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/EnvironmentResponseData.kt
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/Project.kt
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/EnvironmentData.kt
  • packages/android/app/src/main/java/com/formbricks/demo/ui/theme/Type.kt
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/ActionClass.kt
  • packages/android/app/src/main/java/com/formbricks/demo/ui/theme/Color.kt
  • packages/android/app/src/main/java/com/formbricks/demo/ui/theme/Theme.kt
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/ActionClassReference.kt
  • packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/model/environment/Survey.kt
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run Linters / Linters
  • GitHub Check: Build Formbricks-web / Build Formbricks-web
  • GitHub Check: Run E2E Tests / Run E2E Tests
🔇 Additional comments (13)
packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/webview/FormbricksFragment.kt (1)

140-140: Good fix for preventing dialogs from closing unexpectedly!

Setting setCancelable(false) on the dialog prevents it from closing when users tap outside or scroll on the dialog, which directly addresses one of the PR objectives. This is a simple but effective solution to improve the user experience.

packages/android/formbricksSDK/consumer-rules.pro (1)

2-3: ProGuard rules properly configured

Good addition of the ProGuard rules to keep the Formbricks and FormbricksConfig classes. This prevents obfuscation and optimization of these classes, which is crucial for proper SDK functionality, especially with older Kotlin versions that might have issues with certain annotations.

packages/android/app/build.gradle.kts (1)

55-58: Dependencies appropriately added for XML layout approach

The added dependencies are necessary for the traditional XML layout approach:

  • androidx.appcompat for compatibility features
  • material for Material Design components
  • androidx.activity for activity functionality
  • androidx.constraintlayout for the ConstraintLayout used in the new layout

These additions align with the transition from Compose to XML layouts described in the PR.

packages/android/app/src/main/AndroidManifest.xml (2)

17-18: Theme changed to AppCompat.Light.NoActionBar

Good change to use an AppCompat theme instead of a custom theme. This is likely related to the main activity implementation changes and helps with compatibility issues.


15-18: Removed windowSoftInputMode="adjustPan" attribute

The removal of the android:windowSoftInputMode="adjustPan" attribute will change how the soft keyboard behaves. This appears to address the PR objective of "preventing dialogs from closing unexpectedly when the user scrolls" since the default behavior is typically adjustResize, which may handle dialogs and scrolling better.

packages/android/formbricksSDK/src/main/java/com/formbricks/formbrickssdk/network/FormbricksApiService.kt (1)

31-34: Added ignoreUnknownKeys for JSON parsing

Great improvement! Setting ignoreUnknownKeys = true makes the JSON parsing more resilient to API changes by ignoring unexpected fields in the response. This directly addresses the PR objective of fixing crashes with older Kotlin versions, as JSON serialization exceptions are a common source of such crashes.

packages/android/formbricksSDK/proguard-rules.pro (1)

34-36: Added ProGuard keep rules for critical SDK classes

Excellent addition of ProGuard rules to preserve important SDK classes. This directly addresses the PR objective of "implementing fixes for ProGuard configurations" and will prevent runtime issues when ProGuard is enabled by ensuring these classes aren't obfuscated or removed:

  1. DataBinderMapperImpl - Required for data binding to work correctly
  2. Formbricks - The main SDK class
  3. FormbricksConfig - Configuration class
packages/android/app/src/main/java/com/formbricks/demo/MainActivity.kt (6)

4-4: Import properly added for View-based UI approach.

The addition of this import supports the migration from Compose to traditional View-based UI approach.


6-8: Appropriate imports for AppCompat and window insets.

These imports correctly support the migration to AppCompatActivity and proper window insets handling.


13-13: Good base class change to AppCompatActivity.

Changing from FragmentActivity to AppCompatActivity is appropriate for traditional View-based UI and provides better compatibility across Android versions.


16-16: Edge-to-edge display properly maintained.

The enableEdgeToEdge() call is correctly preserved to utilize the full screen space.


26-31: Proper implementation of content view with window insets handling.

The migration to XML-based layout with proper window insets handling is correctly implemented. This approach correctly adjusts padding based on system bars for edge-to-edge display.


33-36: Button click handling properly implemented.

The button retrieval using findViewById and click listener setup is correctly implemented, maintaining the same tracking functionality as before.

Copy link
Member

@mattinannt mattinannt left a comment

Choose a reason for hiding this comment

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

thank you very much for fixing these issues :-)

@mattinannt mattinannt merged commit 07dba90 into formbricks:main Mar 18, 2025
12 of 15 checks passed
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