Takeaway of This Session - Why the migration is inevitable - Migration plan plays a big role to protect user experience - Our learning when migrating from Anko to Jetpack Compose
LINE Sticker Maker - Creating LINE Stickers on smartphone with simple edit flow - Create for scratch, existing image or LINE Avatar - Various image editing tools - Concluding the flow of creating sticker to requesting for sale all on one device/app
LINE Sticker Maker History 2021.05 Rebranding to LINE Sticker Maker 2018.10 Image Auto Trimming Feature with OpenCV 2021.12 LINE Avatar Sticker Creation 2018.11 Sticker Campaign Frame Feature 2017.06 Service Launched as LINE Creators Studio
The Technical Debt As we decided to continue to self-maintain Anko Layout - diff Anko-Layout Android-Support-Library - Anko Layout is lack of UI Preview feature
The Technical Debt As we decided to continue to self-maintain Anko Layout - diff Anko-Layout Android-Support-Library - Bottleneck for introducing new-comers - Anko Layout is lack of UI Preview feature
To Jetpack Compose The Declarative UI Framework for Android - Migration was considered soon after the deprecation of Anko Layout - Jetpack Compose stable-release in July 2021 - The Team proceed to migrate in March 2022
Migration is Inevitable What if…? User get Affected " Migration Side Effect ❌ Migration Started for Developer Needs Developer Experience x User Experience
Developer Experience x User Experience Migration is Inevitable What if…? User get Affected " Migration Side Effect ❌ Migration Started for Developer Needs A Proper Migration Plan is Important
Migration Goal Keep in mind what the most important goal is Refactor Legacy Code For Maintainability 1st Priority Replace Anko UI Performance Keep minimal Avoid over-tuning
Migration Goal Keep in mind what the most important goal is Refactor Legacy Code For Maintainability 1st Priority Replace Anko UI Performance Keep minimal Avoid over-tuning Keep in Sync, Aiming for the Same Goal
Migration Plan Refactor and recreate the same UI in Compose After QA, enable Compose in release build Release Remove Improve Implement Remove Anko completely Replace Fragment-based structure
LINE Sticker Maker Code Structure Feature-based Multi-Module - Features are independent from each other - Create a `common-ui` module with no other dependency for common UI components :app :feature:a :feature:b :feature:c :core :common-ui
Keep Most of the Fragments For now - Migrate to Navigation Compose at one go is risky - Speedy iteration of screen-based migration and quality assurance - Have the Screen Composable ready for future improvement
Same Data, Different UI Implementation class SampleScreenFragment : Fragment() { override fun onCreateView(): View = if (FeatureFlag.FEATURE_SAMPLE_USE_COMPOSE) { } else { SampleScreenUi().createView(AnkoContext.create(requireContext(), this)) } }
- With Clear Layering, switching UI at runtime become possible - Allow Developers to easily validate implementation - Simplify QA process without several build configs Runtime UI switching
View Event Does Not Align With Compose class TrimmingView { var baseMatrix = Matrix() }; private fun loadImageAndBaseMatrixFromViewModel() { ui.trimmingView.imageBitmap = editImageViewModel.loadImage() ui.trimmingView.baseMatrix = editImageViewModel.baseMatrix }
View Event Does Not Align With Compose class TrimmingView { var baseMatrix = Matrix() }; private fun loadImageAndBaseMatrixFromViewModel() { ui.trimmingView.imageBitmap = editImageViewModel.loadImage() ui.trimmingView.baseMatrix = editImageViewModel.baseMatrix }
View Event Does Not Align With Compose class TrimmingView { var baseMatrix = Matrix() }; private fun loadImageAndBaseMatrixFromViewModel() { ui.trimmingView.imageBitmap = editImageViewModel.loadImage() ui.trimmingView.baseMatrix = editImageViewModel.baseMatrix }
View Event Does Not Align With Compose class TrimmingView { var baseMatrix = Matrix() override fun onSizeChanged() { super.onSizeChanged() resetMatrix() } }
Anko Compose Create View Set Bitmap Set Base Matrix OnSizeChanged Reset Matrix Create View Data Binding Create View OnSizeChanged Reset Matrix Set Bitmap Set Base Matrix Update Block
Android View Internal State Restoration @Composable fun SampleComposable( modifier: Modifier = Modifier, ) { val stateToPreserved = rememberSaveable { } } Will be restored when recreation
Android View Internal State Restoration class TrimmingView { val transformMatrix = Matrix() override fun onSaveInstanceState(): Parcelable { val parentState: Parcelable? = super.onSaveInstanceState() return bundleOf( KEY_TRANSFORM_MATRIX to transformMatrix.getValues(), KEY_PARENT_STATE to parentState ) } override fun onRestoreInstanceState(state: Parcelable?) { // … val transform = (state as Bundle).getFloatArray(KEY_TRANSFORM_MATRIX) transformMatrix.setValues(transform) // … } };
Developer Experience x User Experience Migration is Inevitable What if…? User get Affected " Migration Side Effect ❌ Migration Started for Developer Needs
The Technical Debt - diff Anko-Layout Android-Support-Library - Bottleneck for introducing new-comers - Anko Layout is lack of UI Preview feature - Compose Preview
The Technical Debt - diff Anko-Layout Android-Support-Library - Jetpack Library Support - Bottleneck for introducing new-comers - Anko Layout is lack of UI Preview feature - Compose Preview
The Technical Debt - diff Anko-Layout Android-Support-Library - Jetpack Library Support - Bottleneck for introducing new-comers - Spotlighted topic in Android community - Anko Layout is lack of UI Preview feature - Compose Preview
Migration is Inevitable - Plan from the beginning and plan for the worst case - Developers are the main beneficiary of the migration, but we should keep user in mind We should…
Migration is Inevitable - Plan from the beginning and plan for the worst case - Focus on the goal as a team - Developers are the main beneficiary of the migration, but we should keep user in mind We should…
Migration is Tough " - Tidying up Fragment class with 1000+ lines of code % - Facing bug with no previous case study & - Trying to understand mysterious legacy code $
Migration Can Also Be … Fun! ' - Knowledge sharing between developers has become more proactive - Enjoy the Challenges - Developers get their hands on the newest technology