Skip to content

Kaluga 1.0.0 Migration Guide

Tijl edited this page May 16, 2023 · 6 revisions

Migrating to Kaluga 1.0

This is an overview of all the breaking changes made in Kaluga 1.0.0

Common Code

Kaluga 1.0.0 moves to Kotlin 1.8 and enables the New Memory Model.

  • Migrate from Coroutines native-mt dependencies to regular Coroutines dependencies.
  • Dependencies to Stately have been removed. For atomicity use AtomicFU.
  • Remove all freeze() calls as they no longer work.

Base

  • TimeZone has been renamed to KalugaTimeZone.
  • Locale has been renamed to KalugaLocale.
  • ServiceMonitor has been moved to the service Module.
  • Concurrent Collections (com.splendo.kaluga.base.ConcurrentMutableList) can be used instead of Stately.
    • Create using concurrentMutableListOf()/concurrentMutableMapOf()/concurrentMutableSetOf().
  • KalugaDate.epoch and KalugaDate.now now take a Duration as offset. Legacy offsetInMilliseconds can still be used but requires importing com.splendo.kaluga.base.utils.DefaultKalugaDate.Companion.epoch or com.splendo.kaluga.base.utils.DefaultKalugaDate.Companion.now explicitly.

Alerts

  • BaseAlertPresenter.Builder.buildAlert now takes a closure of Alert.Builder() -> Unit instead of AlertPresenter.Builder() -> Unit.

Architecture

  • LifecycleSubscribableMarker has been renamed to LifecycleSubscribable.
  • BaseLifecycleViewModel exposes a list of LifecycleSubscribable via activeLifecycleSubscribables. To be used for Lifecycle binding instead of reflection (see also Android Architecture). These can be added through the constructor or via addLifecycleSubscribables().
  • Navigator may now throw a NavigatorException if navigation fails.
    • Use navigateWithSuccess() to catch the exception and get a success state instead.
    • Use navigateOrElse() to catch the exception and provide a fallback.

Beacons

  • Beacons is now an interface. Use DefaultBeacons to get a class implementation.
  • BeaconInfo.seenMs() has been deprecated in favour of BeaconInfo.timeSinceLastSeen.

Bluetooth

  • Bluetooth.Builder has been replaced by BaseBluetoothBuilder.

Date-Time

  • RecurringTimer.state is now a Flow instead of a StateFlow. Use RecurringTimer.currentState to get the current state.

Date-Time Picker

  • BaseDateTimePickerPresenter.Builder.buildDatePicker now takes a closure of DateTimePicker.Builder() -> Unit instead of BaseDateTimePickerPresenter.Builder() -> Unit.

HUD

  • BaseHUD.Builder.build now takes a closure of HudConfig.Builder() -> Unit instead of BaseHUD.Builder() -> Unit.

Keyboard

  • BaseKeyboardManager now needs to be provided a type of FocusHandler to handle focus events.
  • FocusHandler is now a common interface.

See Android Keyboard and iOS Keyboard on how to handle this per platform.

Links

  • Links has been removed. Use a LinksManager instead.
  • LinksManager has been moved to com.splendo.kaluga.links and is now the primary access point of this library.
    • Use DefaultLinksManager to get a default implementation.
  • LinksHandler has been moved to com.splendo.kaluga.links.handler.

Location

  • KnownLocation.time now returns a KalugaDate.
  • Flow<Location>.known() now returns a Flow<KnownLocation?> instead of Flow<KnownLocation> and can be provided a maxAge.
  • LocationStateRepo.Builder has been removed. Use BaseLocationStateRepoBuilder instead.

Permissions

  • PermissionsBuilder will throw PermissionsBuilderError when getting a BasePermissionsBuilder for a Permission if it has not been registered.
  • Only one BasePermissionsBuilder can be registered to PermissionsBuilder for a Permission. When attempting to register a different builder, PermissionsBuilderError will be thrown.
    • Use unregister to remove the currently registered BasePermissionsBuilder, or registerOrGet to only register if no builder has been registered yet.
  • The same applies for registerPermissionStateRepoBuilder.
  • All register<TYPE>Permission() extensions can only be used once. Calling them twice will result in a PermissionsBuilderError.
    • Use register<TYPE>PermissionIfNotRegistered() to only register a permission if it was not registered yet.

Resources

  • BackgroundStyle has been renamed to KalugaBackgroundStyle.
  • ButtonStyle has been renamed to KalugaButtonStyle.
  • Font has been renamed to KalugaFont.
  • Image has been renamed to KalugaImage.
  • TextAlignment has been renamed to KalugaTextAlignment.
  • TextStyle has been renamed to KalugaTextStyle.
  • KalugaImage.tinted() now returns the newly created TintedImage.

Scientific

  • DimensionlessScientificValue has been removed. To get decimalFraction of a ScientificValue with PhysicalQuantity.Dimensionless, import com.splendo.kaluga.scientific.decimalFraction.

System

  • Network has been renamed to NetworkConnectionType.
    • NetworkConnectionType.Cellular is now an object.
    • NetworkConnectionType.Wifi takes a isExpensive parameter.
  • BaseNetworkManager has been removed.
  • NetworkManager is now an interface that can be started/stopped using startMonitoring/stopMonitoring.
    • A platform specific DefaultNetworkManager exists.
  • To monitor the NetworkState use a BaseNetworkStateRepo.
  • NetworkStateRepo.Builder has been removed. Use BaseNetworkStateRepoBuilder instead.

Android

Android Specific Changes:

Alerts

  • AppCompatActivity.alertPresenterBuilder() has been moved to test-utils-alerts to prevent misuse on UI code.

Architecture

  • Since LifecycleSubscribable is now a common interface, the Android interface has been renamed to ActivityLifecycleSubscribable.
  • LifecycleSubscriber has been renamed to DefaultActivityLifecycleSubscribable.
  • AppCompatActivity.lifecycleManagerObserver() has been moved to test-utils-architecture to prevent misuse on UI code.
  • Since getOrPutAndRemoveOnDestroyFromCache() is no longer needed, it has been moved to test-utils-architecture as well.
  • BaseLifecycleViewModel.bind will no longer use reflection to automatically subscribe to ActivityLifecycleSubscribable classes. Instead add any ActivityLifecycleSubscribable to BaseLifecycleViewModel.activeLifecycleSubscribables (either via the constructor or addLifecycleSubscribables()).
  • ActivityNavigator may now set a Fragment Result for the RemoveFragment, PopFragment, PopFragmentTo, and DismissDialog NavigationSpec.

Architecture Compose

  • store() and storeAndRemember() and store and remember have been deprecated since they do not account for configuration changes.
  • RouteNavigator, CombinedNavigator, and ModalBottomSheetNavigator have been removed.
    • Instead use a ComposableNavigator or BottomSheetNavigator.
    • To make these work, the LifecycleViewModel should be attached to the Composable view using ViewModelComposable.
  • KalugaViewModelComposeActivity.Layout(VM) has been changed to KalugaViewModelComposeActivity.ViewModel.Layout().
  • KalugaViewModelComposeActivity.viewModel has been changed to KalugaViewModelComposeActivity.createViewModel().
  • ViewModelComposable now automatically binds to all ActivityLifecycleSubscribable and the newly introduced ComposableLifecycleSubscribable.
  • See Architecture Compose ReadMe for more information.

Bluetooth

  • When writing a characteristic, the value will no longer be automatically read, in accordance with the latest Android api's. This behaviour was already inaccurate. Perform a Read/Notifying action on a characteristic to get its value after a write.
  • CharacteristicWrapper.writeType now returns a CharacteristicWrapper.WriteType instead of an Int.
  • DeviceWrapper.bondState now returns a DeviceWrapper.BondState instead of an Int.
  • ServiceWrapper.type now returns a ServiceWrapper.Type instead of an Int.

Date-Time Picker

  • AppCompatActivity.datePickerPresenterBuilder() has been moved to test-utils-date-time-picker to prevent misuse on UI code.

HUD

  • AppCompatActivity.hudBuilder() has been moved to test-utils-hud to prevent misuse on UI code.

Keyboard

  • Since KeyboardManager is now an interface, use ViewKeyboardManager to manage the keyboard for an XML View.
  • ClearFocusHandler and ViewClearFocusHandler have been removed.

For managing the keyboard on Compose, use the new Keyboard Compose Module.

Permissions

  • Notification permissions will now be requested on Android API 33 or higher.
    • Make sure to add android.permission.POST_NOTIFICATIONS to your manifest.

Resources

  • Convert a TintedImage to a Drawable using the drawable extension method.

A new Resources Data Binding module has been introduced to use resources from XML View with Data Binding.

Resources Compose

  • KalugaImageand TintedImage should be converted to an androidx.compose.foundation.Image using the Composable() method.

Review

  • AppCompatActivity.reviewManager() has been removed to prevent misuse on UI code.

iOS

iOS Specific Changes:

When using SwiftUI make sure you use the latest Kaluga SwiftUI.

Architecture

  • The RoutingState from Kaluga SwiftUI now properly works with animation. However it may modify UINavigationBar.areAnimationsEnabled during screen transitions. Make sure you dont change this value while navigating to a different route.

Keyboard

  • Since KeyboardManager is now an interface, use UIKitKeyboardManager to manage the keyboard for a UIView.
  • On SwiftUI make sure to enable the includeKeyboard setting and export the Keyboard Module to your iOS code.
  • On SwiftUI use a ValueKeyboardManager. The Kaluga SwiftUI scripts offer a SwiftUIKeyboardManagerBuilder that can be bound to a SwiftUI View.

Resources

  • KalugaButton.toButton() now takes a ButtonFrame to modify the size of the button
  • TintedImage can be converted into a UIImage using the uiImage extension method
  • TintedImage can be converted into an Image using the swiftUI and resizableSwiftUI extension methods