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

Refactor: Apply insets and update app theme #1347

Merged
merged 6 commits into from
Mar 9, 2025

Conversation

iamarjun
Copy link
Contributor

@iamarjun iamarjun commented Mar 6, 2025

This commit refactors the application to handle window insets correctly, ensuring that the UI does not overlap with system bars. It also updates the application theme to remove the action bar. Addresses issue

  • styles.xml: Changed the parent theme of AppTheme to Theme.MaterialComponents.DayNight.NoActionBar to remove the default action bar.
  • MainActivity.kt (library): Added applyInsets() to handle system window insets, ensuring content is displayed properly around system bars. Added call to applyInsets() in onCreate
  • TransactionActivity.kt: Added applyInsets() to handle system window insets, ensuring content is displayed properly around system bars. Added call to applyInsets() in onCreate
  • activity_main_sample.xml: Added AppBarLayout and MaterialToolbar for a custom toolbar implementation.
  • chucker_activity_transaction.xml: Added id to appBarLayout
  • MainActivity.kt (sample): Added applyInsets() to handle system window insets, ensuring content is displayed properly around system bars. Added call to applyInsets() in onCreate
  • Added toolbar subtitle for sample and library MainActivity

📷 Screenshots

📄 Context

📝 Changes

📎 Related PR

🚫 Breaking

🛠️ How to test

⏱️ Next steps

This commit refactors the application to handle window insets correctly, ensuring that the UI does not overlap with system bars. It also updates the application theme to remove the action bar.

-   `styles.xml`: Changed the parent theme of `AppTheme` to `Theme.MaterialComponents.DayNight.NoActionBar` to remove the default action bar.
-   `MainActivity.kt` (library): Added `applyInsets()` to handle system window insets, ensuring content is displayed properly around system bars. Added call to `applyInsets()` in `onCreate`
-   `TransactionActivity.kt`: Added `applyInsets()` to handle system window insets, ensuring content is displayed properly around system bars. Added call to `applyInsets()` in `onCreate`
-   `activity_main_sample.xml`: Added `AppBarLayout` and `MaterialToolbar` for a custom toolbar implementation.
-   `chucker_activity_transaction.xml`: Added id to `appBarLayout`
-   `MainActivity.kt` (sample): Added `applyInsets()` to handle system window insets, ensuring content is displayed properly around system bars. Added call to `applyInsets()` in `onCreate`
-   Added toolbar subtitle for sample and library `MainActivity`
iamarjun added 3 commits March 6, 2025 11:46
This commit refactors the main layout files in both the library and sample modules by:

-   Removing `app:popupTheme` from `AppBarLayout` in `chucker_activity_main.xml`.
-   Moving `app:popupTheme` to `Toolbar` inside the sample's `activity_main_sample.xml`.
-   Adding missing margins to improve the UI layout consistency of `activity_main_sample.xml`.
-   Reordering views in the `activity_main_sample.xml`.
-   Adding layout horizontal margins to UI components in the `activity_main_sample.xml` such as: `description`, `interceptor_type_label`, `interceptor_type_group`, `do_http`, `do_graphql`, `launch_chucker_directly`, `export_to_file`, and `export_to_file_har`.
-   Adding a bottom margin to the `description` view in `activity_main_sample.xml`.
The `app:popupTheme` attribute was removed from the `Toolbar` in `activity_main_sample.xml`. This change aligns the toolbar's popup theme with the application's default theme, removing a redundant setting. Based on research `content_main.xml` is used to display content, and `activity_main.xml` is used for main UI elements such as the `coordinatorLayout`. In this case, `activity_main_sample.xml` contains a `Toolbar`.
This commit applies the `Chucker.BaseTheme` style to the popup theme of the main activity's toolbar. This change ensures a consistent appearance for popups within the Chucker UI.
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintWidth_max="@dimen/max_width" />

<RadioGroup
android:id="@+id/interceptor_type_group"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
Copy link
Member

Choose a reason for hiding this comment

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

can we use a resource here rather than hardcoding 16dp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

This commit updates the horizontal margin values in the `activity_main_sample.xml` layout file to use `@dimen/doub_grid_size` instead of hardcoded `16dp`. This change makes the layout more consistent and maintainable. Additionally, it sets the bottom margin for export buttons.
Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

This is great! I've tested it an dit works flawlessy.

Also nit: can you add a line in the CHANGELOG.md file @iamarjun ?

android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="4dp"
Copy link
Member

Choose a reason for hiding this comment

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

also here please reference one of the resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

…droid 15

This commit addresses an issue where list and scrollable data were obscured by the bottom navigation bar on Android 15. The fix ensures that the content now scrolls to above the bottom navigation bar. The issue was resolved by updating the toolbar padding to use a defined dimension.
@cortinico cortinico merged commit 6084107 into ChuckerTeam:main Mar 9, 2025
7 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