Skip to content

Conversation

@xanderlmk
Copy link

Description

  • Code refactor for BluetoothMeshService and ChatViewModel.
  • Update BluetoothMeshDelegate and create an implementation which overrides BluetoothMeshDelegate rather than just the ChatVM.
  • Updates to MainActivity
  • Change Theme saving to data store instead of shared preferences
  • Replace Google Gson to native kotlinx Json
  • Add a package directory for application

Why It matters

  • As code grows, it's best to separate components for readability and maintainability.
  • DataStore allows for automatic flows without the need to have two separate variables compared to just SharedPreferences.
  • Kotlin's native kotlinx.serialization library.Serialization is much easier to use and manipulate and is better performing than Google's Gson

TODO

  • Finish migration from SharedPreferences to DataStore
  • Completely remove GSON and use JSON

Suggestions

  • Room is a framework that allows pretty good persistence storage and allows for storing for more complex objects and classes. It is just a wrapper for SQLite.
  • More code refactor for better readability.

Checklist

Implement datastore to migrate from appPref to datastore.
Implement datastore to migrate from appPref to datastore.

interface AppContainer {
val meshService : BluetoothMeshService
val bmd : BluetoothMeshDelegate
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be good if the name was meaningful, like meshDelegate or full bluetoothMeshDelegate

_themeFlow.value = preference
private val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
override val theme = context.dataStore.data.map { preferences ->
(preferences[KEY_THEME] ?: prefs.getString("theme_preference", ThemePreference.System.name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to have data migrations considering that the app is already distributed to users. And could also help removing usage of SharedPreferences completely

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