-
-
Notifications
You must be signed in to change notification settings - Fork 464
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
Help fragment migration #4174
base: main
Are you sure you want to change the base?
Help fragment migration #4174
Conversation
…with lint checks off
…wixHelpFragment in app module to run Compossables, with addition of Jetpack compose compatibility in gradel app/core
There was a problem hiding this 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 the PR. See the review changes.
@@ -1,7 +1,5 @@ | |||
<component name="ProjectCodeStyleConfiguration"> | |||
<code_scheme name="Project" version="173"> | |||
<option name="USE_SAME_INDENTS" value="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SOUMEN-PAL Please do not include automatic changes in the PR.
@@ -51,7 +51,6 @@ | |||
<inspection_tool class="AndroidLintExportedPreferenceActivity" enabled="true" level="ERROR" enabled_by_default="true" /> | |||
<inspection_tool class="AndroidLintExportedReceiver" enabled="true" level="ERROR" enabled_by_default="true" /> | |||
<inspection_tool class="AndroidLintExportedService" enabled="true" level="ERROR" enabled_by_default="true" /> | |||
<inspection_tool class="AndroidLintExtraText" enabled="true" level="ERROR" enabled_by_default="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this as well.
@@ -15,39 +11,56 @@ | |||
<string name="menu_read_aloud">Чытаць уголас</string> | |||
<string name="menu_read_aloud_stop">Спыніць чытаньне ўголас</string> | |||
<string name="menu_support_kiwix">Падтрымаць Kiwix</string> | |||
<string name="menu_support_kiwix_for_custom_apps">Падтрымка %s</string> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this as well.
@@ -2,7 +2,6 @@ | |||
"_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.", | |||
"_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.", | |||
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.", | |||
"_note4": "The IDs of the entities and properties should not be changed unless there is a change in the corresponding entity.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we changing the json file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
due to some auto imports done by me using Alt+Enter i guess this changes had happen by me by mistake i will fix them right now.
Sorry for the unintended problems.
@@ -11,6 +11,8 @@ import javax.xml.transform.stream.StreamResult | |||
plugins { | |||
android | |||
id("com.github.triplet.play") version Versions.com_github_triplet_play_gradle_plugin | |||
id("org.jetbrains.kotlin.android") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have added this to our core module which is already included in app and custom modules. So why we are again adding this here?
@@ -108,6 +110,13 @@ android { | |||
// is analyzed to provide actionable feedback on potential issues with dependencies. | |||
includeInBundle = true | |||
} | |||
|
|||
buildFeatures { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing this out
Initially, I was testing the composable invocation in one module and faced some import-related issues with the other module, which led to this addition. However, I realize now that the business logic resides in the core module, and the issue can be resolved there directly. I'll fix this to avoid duplication and ensure consistency across the project.
@@ -129,6 +138,23 @@ androidComponents { | |||
dependencies { | |||
androidTestImplementation(Libs.leakcanary_android_instrumentation) | |||
testImplementation(Libs.kotlinx_coroutines_test) | |||
|
|||
implementation("androidx.compose.material3:material3-android:1.3.1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dependencies should be included in one place, we are adding same dependencies here and as well as in core module.
The core
module is the base for both app and custom apps so whatever is common for both modules we should include that in core
module so that it can easily use in both apps. Or you can use the AllProjectConfigure class to declare the dependencies which is common for both modules.
@@ -13,6 +13,8 @@ buildscript { | |||
} | |||
plugins { | |||
`android-library` | |||
id("org.jetbrains.kotlin.android") | |||
id("org.jetbrains.kotlin.plugin.compose") version "2.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do no hardcode version number here, We are managing all the dependencies in Libs
and Versions
class, so define all the dependencies related things there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the information I had experience with TOML files thats why I confused my self I will fix them right away.
class KiwixHelpFragment : HelpFragment() { | ||
override fun rawTitleDescriptionMap() = | ||
if (sharedPreferenceUtil.isPlayStoreBuildWithAndroid11OrAbove()) { | ||
open class KiwixHelpFragment : Fragment() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SOUMEN-PAL Why are we directly extending the Fragment instead of HelpFragment? HelpFragment is the base for both apps module and we should use that for resusability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decision to extend Fragment directly instead of HelpFragment was intentional to align with Compose's architecture and avoid unnecessary coupling. HelpFragment is tightly tied to XML-based UI with responsibilities like managing a RecyclerView, viewBinding, and toolbar setup, which are better handled in Compose using LazyColumn and TopAppBar.
Using HelpFragment would introduce dependencies irrelevant to Compose and disrupt the clean separation Compose promotes. Extending Fragment allowed for a smoother integration of Compose while minimizing changes to the existing codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SOUMEN-PAL We have the same screen for the Custom app(which is missing in this PR so we are only converting the KiwixHelpFragment in compose), and HelpFragment is used as the base class for both screens. The only difference we are showing some additional things in Kiwix app so this is easily achievable by extending the existing HelpFragment. According to the current approach, we have to written the same code for customHelpFragment. Compose also offers reusability and we should make the code reusable. Clean separation is also achieved by extending the HelpFragment
for both KiwixHelpFragment
, and CustomHelpFragment
as the HelpFragment
is the base class that shares the common functionality for both screens and any additional things are written in the classes themselves.
HelpFragment is tightly tied to XML-based UI with responsibilities like managing a RecyclerView, viewBinding, and toolbar setup,
That's why we should convert the HelpFragment in the compose, and KiwixHelpFragment
, and CustomHelpFragment
will be unchanged(as there is no UI logic) and we will provide the additional data to the base class(HelpFragment
) and it will render the UI for both app and custom apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will do the required changes right away.
what I plan to do Is.
commit Back to prev recent stable heads and changing according to it.
.padding(16.dp) | ||
) | ||
Text( | ||
text = "Send Diagnostic Data", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I would be fetching it from the main strings file and do the changes accordingly.
@SOUMEN-PAL For the lint issue, these are the detekt issues since the project is now starting supporting the compose so the detekt rules were not configured according to compose. Here is the doc of detekt https://detekt.dev/docs/introduction/compose/ how we can configure the rules of detekt for compose. |
Fixes #4159
###Changes Made
Added necessary Jetpack Compose dependencies and plugins to both the
app
module andcore
modulebuild.gradle.kts
files.Created two composable Kotlin files:
LazyColumn
andAnimatedVisibility
.Created a data class
HelpScreenItemDataClass
(serving as a replacement for theHelpItem
class in the previousHelpAdapter
) to define the required data items and strings for the HelpScreen.Updated
KiwixHelpFragment.kt
to make it compatible with Jetpack Compose by:ComposeView
instead of inflating XML layouts.HelpFragment
to the defaultFragment
to enable calling composable functions directly.Fetched the existing
navGraph
and integrated it with a newnavController
to support seamless navigation between XML-based UI and Compose-based UI.Screenshots
Earlier vs New UI
Demo Video
MigrationHelp.mp4