-
Notifications
You must be signed in to change notification settings - Fork 939
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
Remove Java dependencies from uhabits-core #1075
Comments
Interesting seeing the work done in Is there a reason to prefer a DIY LocalDate vs using a multiplatform library like kotlinx-datetime? Same question for: All for common abstractions, but for these lower level libraries, would it be a better developer experience to leverage community driven multiplatform projects and their well-thought-out APIs? |
I am not sure
If
I am deliberately avoiding high-level APIs or wrappers for SQL. We went through a couple of these libraries since the app was first released, and there have always been subtle issues. |
Description
In previous refactorings, we moved most of the application code from
uhabits-android
(a module with dependencies to Android classes) touhabits-core
(a Java module without any Android dependencies). While this made the application more portable and much faster to test, it is still not sufficient to make it run on iOS or the web. To leverage Kotlin Multiplatform, we need to remove all dependencies not only to Android, but also to Java classes! For example, any Kotlin classes that importjava.util
orjava.math
cannot be reused in other platforms.This task is to remove Java dependencies from as many classes in
uhabits-core
as possible.Notes
uhabits-core/src/jvmMain
touhabits-core/src/commonMain
. This will also prevent Java dependencies from being accidentally reintroduced in future code changes.java.util.Calendar
andjava.util.Date
. These classes should switch toorg.isoron.platform.time.LocalDate
, a pure-Kotlin implementation.uhabits-core-legacy
. In includes an abstract Database class, as well as concrete iOS, JavaScript and JVM implementations. This code needs to be ported touhabits-core
and the currentdatabase/*.kt
files need to be removed.org.isoron.platform.io.Files
. We already have concrete iOS, JavaScript and JVM implementations for these classes inuhabits-core-legacy
.javax.inject
annotations are fine, and can be kept, but we should double check.Subtasks
Deprecated
The files below should be removed, and replaced by existing implementations (see notes above):
database/Cursor.kt
database/Database.kt
database/DatabaseOpener.kt
database/JdbcCursor.kt
database/JdbcDatabase.kt
database/MigrationHelper.kt
database/Repository.kt
database/SQLParser.kt
models/Timestamp.kt
Direct dependencies to
java.*
The files below need to be modified, and all references to
java.*
classes should be replaced by existing Kotlin classes, or by new pure-Kotlin implementations:commands/CommandRunner.kt
io/AbstractImporter.kt
io/GenericImporter.kt
io/HabitBullCSVImporter.kt
io/HabitsCSVExporter.kt
io/LoopDBImporter.kt
io/RewireDBImporter.kt
io/TickmateDBImporter.kt
models/EntryList.kt
models/Habit.kt
models/HabitList.kt
models/HabitType.kt
models/memory/MemoryHabitList.kt
models/ModelObservable.kt
models/NumericalHabitType.kt
models/ScoreList.kt
models/sqlite/records/HabitRecord.kt
models/Streak.kt
models/WeekdayList.kt
preferences/Preferences.kt
preferences/PropertiesStorage.kt
reminders/ReminderScheduler.kt
tasks/ExportCSVTaskFactory.kt
tasks/ExportCSVTask.kt
tasks/SingleThreadTaskRunner.kt
ui/NotificationTray.kt
ui/screens/habits/list/HabitCardListCache.kt
ui/screens/habits/list/ListHabitsBehavior.kt
ui/screens/habits/show/ShowHabitMenuPresenter.kt
ui/screens/habits/show/views/FrequencyCard.kt
ui/screens/habits/show/views/TargetCard.kt
ui/views/NumberButton.kt
ui/views/Ring.kt
utils/DateFormats.kt
utils/DateUtils.kt
utils/FileExtensions.kt
utils/MidnightTimer.kt
utils/StringUtils.kt
No direct dependencies to
java.*
The files below need to be moved to
commonMain
. While they don't have any direct references tojava.*
classes, they may still indirectly depend on these classes.AppScope.kt
commands/ArchiveHabitsCommand.kt
commands/ChangeHabitColorCommand.kt
commands/Command.kt
commands/CreateHabitCommand.kt
commands/CreateRepetitionCommand.kt
commands/DeleteHabitsCommand.kt
commands/EditHabitCommand.kt
commands/UnarchiveHabitsCommand.kt
Constants.kt
database/Column.kt
database/Table.kt
database/UnsupportedDatabaseVersionException.kt
io/Logging.kt
models/Entry.kt
models/Frequency.kt
models/HabitMatcherBuilder.kt
models/HabitMatcher.kt
models/HabitNotFoundException.kt
models/memory/MemoryModelFactory.kt
models/ModelFactory.kt
models/PaletteColor.kt
models/Reminder.kt
models/Score.kt
models/sqlite/records/EntryRecord.kt
models/sqlite/SQLiteEntryList.kt
models/sqlite/SQLiteHabitList.kt
models/sqlite/SQLModelFactory.kt
models/StreakList.kt
preferences/WidgetPreferences.kt
tasks/Task.kt
tasks/TaskRunner.kt
test/HabitFixtures.kt
ui/callbacks/OnColorPickedCallback.kt
ui/callbacks/OnConfirmedCallback.kt
ui/callbacks/OnFinishedCallback.kt
ui/callbacks/OnToggleCheckmarkListener.kt
ui/screens/habits/list/HintListFactory.kt
ui/screens/habits/list/HintList.kt
ui/screens/habits/list/ListHabitsMenuBehavior.kt
ui/screens/habits/list/ListHabitsSelectionMenuBehavior.kt
ui/screens/habits/show/ShowHabit.kt
ui/screens/habits/show/views/BarCard.kt
ui/screens/habits/show/views/HistoryCard.kt
ui/screens/habits/show/views/NotesCard.kt
ui/screens/habits/show/views/OverviewCard.kt
ui/screens/habits/show/views/ScoreCard.kt
ui/screens/habits/show/views/StreakCart.kt
ui/screens/habits/show/views/SubtitleCard.kt
ui/ThemeSwitcher.kt
ui/views/BarChart.kt
ui/views/CheckmarkButton.kt
ui/views/HabitListHeader.kt
ui/views/HistoryChart.kt
ui/views/Themes.kt
ui/widgets/WidgetBehavior.kt
The text was updated successfully, but these errors were encountered: