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

4159 migrate help fragment to compose #4217

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

Conversation

SOUMEN-PAL
Copy link

Fixes #4159

📌 Summary

Migrated HelpFragment from XML-based UI to Jetpack Compose.

🔄 Changes Made

  1. Created new Composable components

    • Added HomeScreen.kt and HomeScreenItem.kt to handle the UI logic in Jetpack Compose.
  2. Updated HelpFragment.kt

    • Converted HelpFragment to return a Composable UI instead of using View Binding.
  3. Updated dependencies

    • Added necessary Jetpack Compose dependencies and versions in Libs.kt and Versions.kt in buildSrc.
  4. Handled Navigation

    • Introduced a variable for navigation, which is overridden in KiwixHelpFragment.kt, as the host fragment ID is required for Composable-to-Fragment and vice versa navigation.

🖼️ Screenshots / GIFs

@SOUMEN-PAL
Copy link
Author

@MohitMaliFtechiz sir I would like to put a thing in notice that whenever i sync the gradel using sync now after sync some string.xml files are automatically changed or updated. I am not able to know why.
Screenshot from 2025-02-07 20-47-40

The above image shows before sync and after sync status of the files.

@MohitMaliFtechiz
Copy link
Collaborator

@SOUMEN-PAL This is due to our gradle task, which we have added to fix #3176. Please do not include this automate change in commit.

task("renameTarakFile") {

@kelson42
Copy link
Collaborator

@SOUMEN-PAL Any update?

@SOUMEN-PAL
Copy link
Author

@SOUMEN-PAL Any update?

The ui is working I ensured the version and gradel dependencies the only problem is the strings that are getting updated in gradel sync and I am not able to fix the changes the jetpack compose code is working seemlesly. I am not able to figure out the Tarak file thing

@MohitMaliFtechiz
Copy link
Collaborator

The ui is working I ensured the version and gradel dependencies the only problem is the strings that are getting updated in gradel sync and I am not able to fix the changes the jetpack compose code is working seemlesly. I am not able to figure out the Tarak file thing

@SOUMEN-PAL Apart from the tarask file-related issue, the PR is ready for review? I will have a look at the tarask file-related issue and will push the fix for this.

@SOUMEN-PAL
Copy link
Author

The ui is working I ensured the version and gradel dependencies the only problem is the strings that are getting updated in gradel sync and I am not able to fix the changes the jetpack compose code is working seemlesly. I am not able to figure out the Tarak file thing

@SOUMEN-PAL Apart from the tarask file-related issue, the PR is ready for review? I will have a look at the tarask file-related issue and will push the fix for this.

Yes The UI is ready for review.

@MohitMaliFtechiz MohitMaliFtechiz self-requested a review February 18, 2025 05:55
@MohitMaliFtechiz MohitMaliFtechiz force-pushed the 4159-migrate-help-fragment-to-compose branch from b81ad3c to 6873bd5 Compare February 18, 2025 11:08
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz left a comment

Choose a reason for hiding this comment

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

@SOUMEN-PAL Thanks for your changes. Please see the review comments.

val isDarkTheme = isSystemInDarkTheme()
val itemColor = if (isDarkTheme) Color.White else Color.Black
val arrowRotation by animateFloatAsState(
targetValue = if (isOpen) 180f else 0f,
Copy link
Collaborator

Choose a reason for hiding this comment

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

@SOUMEN-PAL This is giving the MagicNumber lint error. Please fix it.


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HelpScreen(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here lint is giving the LongMethod error, please fix it.

throw IllegalArgumentException("Invalid description resource type for title: $title")
}
}
protected abstract val navHostFragmentId: Int
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is abstract so why we are not implementing it in CustomHelpFragment like we are doing it in KiwixHelpFragment? It will not allow us to build the Custom module without implementing this in CustomHelpFragment.

implementation(Libs.androidx_compose_material3)
implementation(Libs.androidx_activity_compose)

implementation(Libs.androidx_compose_ui)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we have added androidx.compose.ui:ui-android:1.7.7 in our project. Due to this, we are facing a PrivateResouce lint issue for our close_drawer string. Can you please fix that? IMO add this in in lintConfig file since our app can have the same resource name, and we are getting this name from our R package so it will not conflict with compose internal string.

<issue id="PrivateResource" severity="warning" />

image

navigationIcon = {
IconButton(onClick = navController::popBackStack) {
Icon(
imageVector = Icons.Filled.ArrowBack,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Icons.Filled.ArrowBack is deprecated we should use Icons.AutoMirrored.Filled.ArrowBack instead.

topBar = {
TopAppBar(
title = {
Text(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This text should be a little bold to align with the toolbar's default title. See the difference in below images.

Toolbar's title This title
13908d59-91a9-4646-899a-f62b954000f2 9b51bfa5-f9b0-466a-8ea9-593f575d0dea

) {
Image(
painter = painterResource(R.drawable.ic_feedback_orange_24dp),
contentDescription = "Feedback",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The contentDescription should be Send diagnostic report as it is for "Send diagnostic report" we have a string for this send_report which we are using in the fragment_help.xml so we should use that.

fragmentHelpBinding?.activityHelpRecyclerView?.addItemDecoration(
DividerItemDecoration(activity, DividerItemDecoration.VERTICAL)
)
fragmentHelpBinding?.activityHelpRecyclerView?.adapter = HelpAdapter(titleDescriptionMap)
Copy link
Collaborator

Choose a reason for hiding this comment

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

After moving HelpScreen to compose our HelpAdapter is unused so we should remove the unused code.

.padding(start = 16.dp, end = 16.dp)
) {
Text(
text = data.description,
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz Feb 18, 2025

Choose a reason for hiding this comment

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

The internal text is showing bigger and looks different from the previous one. Also, the side image for opening and closing the menu items is bigger which does not look good. See the difference:

Previous design Current design
PreviousDesign CurrentDesign

You can take the reference from xml design how we have used sizes, margins, paddings, etc, for text and images.

@MohitMaliFtechiz
Copy link
Collaborator

the only problem is the strings that are getting updated in gradel sync

@SOUMEN-PAL I have rebased the PR and resolved the tarask file conflicts. Now only add the files in which you have made the changes.

Yes The UI is ready for review.

I have reviewed your PR, please have a look at the review changes.

@SOUMEN-PAL
Copy link
Author

the only problem is the strings that are getting updated in gradel sync

@SOUMEN-PAL I have rebased the PR and resolved the tarask file conflicts. Now only add the files in which you have made the changes.

Yes The UI is ready for review.

I have reviewed your PR, please have a look at the review changes.

I more question regarding the workflow I mean I was thinking for getting the upstream then updating my branch to the branch that is added after rebase from https://github.com/kiwix/kiwix-android/tree/4159-migrate-help-fragment-to-compose

Other wise i wont be able to see the changes in my forked repository.

I just want to confirm my workflow for the post rebase step
1st step
git remote add upstream https://github.com/kiwix/kiwix-android.git
2d Step
git fetch upstream
3rd step
git checkout 4159-migrate-help-fragment-to-compose
git reset --hard upstream/4159-migrate-help-fragment-to-compose

@MohitMaliFtechiz
Copy link
Collaborator

@SOUMEN-PAL Your branch has the latest code, so you can directly get it via running git pull in your current branch(4159-migrate-help-fragment-to-compose).

I just want to confirm my workflow for the post rebase step
1st step
git remote add upstream https://github.com/kiwix/kiwix-android.git
2d Step
git fetch upstream
3rd step
git checkout 4159-migrate-help-fragment-to-compose
git reset --hard upstream/4159-migrate-help-fragment-to-compose

If your local branch does not have the origin, you can do it.

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.

Migrate HelpFragment to jetpack.
3 participants