Moved more deps to catalogue. fixed issue with rotation on main activity

This commit is contained in:
michael-bailey 2025-04-14 23:10:48 +01:00
parent 3764abfa85
commit 46dbd20e73
8 changed files with 149 additions and 185 deletions

View File

@ -1,12 +1,21 @@
[versions]
android_version = "8.9.1"
composeBomVersion = "2025.04.00"
composeMaterialVersion = "1.4.1"
coreSplashscreenVersion = "1.0.1"
espresso_core_version = "3.6.1"
horologistComposeToolsVersion = "0.6.23"
junit = "1.2.1"
junit-version = "4.13.2"
kotlin_android_version = "1.9.22"
hilt_version = "2.56.1"
crypto_version = "1.0.0"
lifecycleRuntimeKtxVersion = "2.8.7"
materialIconsExtendedVersion = "1.7.8"
material_version = "1.12.0"
mockitoCoreVersion = "5.17.0"
navigation-fragment-version = "2.8.9"
playServicesWearableVersion = "19.0.0"
serialisation_plugin_version = "2.1.10"
compose_version = "2.0.21"
@ -30,6 +39,13 @@ json_serialisation_version = "1.8.1"
nav_version = "2.8.9"
gson_version = "2.9.0"
tilesMaterialVersion = "1.4.1"
tilesToolingPreviewVersion = "1.4.1"
tilesVersion = "1.4.1"
uiTestJunit4Version = "1.7.8"
uiTestManifestVersion = "1.7.8"
uiToolingVersion = "1.7.8"
watchfaceComplicationsDataSourceKtxVersion = "1.2.1"
work_version = "2.10.0"
security_version = "1.0.0"
workRuntimeVersion = "2.10.0"
@ -41,6 +57,13 @@ androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "android_
android-crypto = { module = "androidx.security:security-crypto", version.ref = "crypto_version" }
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version.ref = "coreSplashscreenVersion" }
androidx-tiles = { module = "androidx.wear.tiles:tiles", version.ref = "tilesVersion" }
androidx-tiles-material = { module = "androidx.wear.tiles:tiles-material", version.ref = "tilesMaterialVersion" }
androidx-tiles-tooling-preview = { module = "androidx.wear.tiles:tiles-tooling-preview", version.ref = "tilesToolingPreviewVersion" }
navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigation-fragment-version" }
navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigation-fragment-version" }
livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx" }
lifecycle-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtxVersion" }
androidx-livedata = { module = "androidx.compose.runtime:runtime-livedata" }
@ -67,6 +90,7 @@ compose-material-icons-extended = { module = "androidx.compose.material:material
navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation_version" }
navigation-runtime = { module = "androidx.navigation:navigation-runtime-ktx", version.ref = "navigation_version" }
play-services-wearable = { module = "com.google.android.gms:play-services-wearable", version.ref = "playServicesWearableVersion" }
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room_version" }
room-ktx = { module = "androidx.room:room-ktx", version.ref = "room_version" }
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room_version" }
@ -75,6 +99,25 @@ serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-jso
work-manager = { module = "androidx.work:work-runtime", version.ref = "workRuntimeVersion" }
wear-compose-foundation = { module = "androidx.wear.compose:compose-foundation", version.ref = "composeMaterialVersion" }
wear-compose-material = { module = "androidx.wear.compose:compose-material", version.ref = "composeMaterialVersion" }
androidx-watchface-complications-data-source-ktx = { module = "androidx.wear.watchface:watchface-complications-data-source-ktx", version.ref = "watchfaceComplicationsDataSourceKtxVersion" }
horologist-compose-tools = { module = "com.google.android.horologist:horologist-compose-tools", version.ref = "horologistComposeToolsVersion" }
horologist-tiles = { module = "com.google.android.horologist:horologist-tiles", version.ref = "horologistComposeToolsVersion" }
# unti testing deps
junit = { module = "junit:junit", version.ref = "junit-version" }
junit-android = { module = "androidx.test.ext:junit", version.ref = "junit" }
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "uiTestJunit4Version" }
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "uiTestManifestVersion" }
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "uiToolingVersion" }
espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso_core_version" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockitoCoreVersion" }
[bundles]
compose = ["compose-activity", "compose-ui", "compose-ui-graphics", "compose-ui-tooling-preview"]
hilt = ["hilt-android", "hilt-navigation"]
@ -89,4 +132,4 @@ android-library = { id = "com.android.library", version.ref = "android_version"
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin_android_version" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt_version" }
serialisation = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serialisation_plugin_version" }
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "compose_version" }
compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "compose_version" }

View File

@ -1,10 +1,11 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.hilt)
alias(libs.plugins.serialisation)
alias(libs.plugins.compose)
id("kotlin-kapt")
id("com.google.dagger.hilt.android")
id("org.jetbrains.kotlin.plugin.serialization")
id("org.jetbrains.kotlin.plugin.compose")
}
android {
@ -40,31 +41,32 @@ android {
dependencies {
val compose_version = "1.7.8"
val room_version = "2.7.0"
val nav_version = "2.8.9"
val gson_version = "2.9.0"
val work_version = "2.10.0"
val security_version = "1.0.0"
val hilt_version = "2.56.1"
api(kotlin("reflect", version = "2.1.20"))
implementation("androidx.core:core-ktx:1.16.0")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.compose.material)
implementation(platform(libs.compose.bom))
// material design
implementation(libs.material)
implementation(libs.bundles.material.design)
// room database deps
implementation("androidx.room:room-runtime:$room_version")
implementation("androidx.room:room-ktx:$room_version")
kapt("androidx.room:room-compiler:$room_version")
api(libs.bundles.room)
kapt(libs.room.compiler)
// work manager deps
api(libs.work.manager)
// hilt deps
implementation("com.google.dagger:hilt-android:$hilt_version")
kapt("com.google.dagger:hilt-android-compiler:$hilt_version")
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
api(libs.bundles.hilt)
kapt(libs.hilt.compiler)
// serialisation
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2")
implementation(libs.serialization.json)
implementation(libs.datetime)
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")

View File

@ -68,26 +68,14 @@ android {
dependencies {
val compose_version = "1.7.8"
val room_version = "2.7.0"
val nav_version = "2.8.9"
val gson_version = "2.9.0"
val work_version = "2.10.0"
val security_version = "1.0.0"
val hilt_version = "2.56.1"
implementation(project(":gym_library"))
// reflection
implementation(kotlin("reflect", version = "2.1.20"))
// android deps
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.constraintlayout)
implementation("androidx.navigation:navigation-fragment-ktx:$nav_version")
implementation("androidx.navigation:navigation-ui-ktx:$nav_version")
implementation(libs.navigation.fragment.ktx)
implementation(libs.navigation.ui.ktx)
// compose deps
implementation(platform(libs.compose.bom))
@ -128,11 +116,11 @@ dependencies {
// bcrypt deps
implementation(libs.jbcrypt)
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version")
debugImplementation("androidx.compose.ui:ui-tooling:$compose_version")
debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version")
testImplementation("org.mockito:mockito-core:5.17.0")
testImplementation(libs.junit)
androidTestImplementation(libs.junit.android)
androidTestImplementation(libs.espresso.core)
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
testImplementation(libs.mockito.core)
}

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
@ -21,13 +20,13 @@
<!-- Main activity -->
<activity
android:name=".activity.main_activity.MainActivity"
android:exported="true"
android:label="@string/main_activity_title"
android:launchMode="standard"
android:label="@string/title_activity_main"
android:launchMode="singleInstance"
android:resizeableActivity="true"
android:enableOnBackInvokedCallback="true"
android:theme="@style/Theme.Gym_Log_Book"
tools:ignore="LockedOrientationActivity">
android:theme="@style/Theme.Gym_Log_Book">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -58,8 +57,7 @@
android:launchMode="singleInstance"
android:resizeableActivity="true"
android:enableOnBackInvokedCallback="true"
android:theme="@style/Theme.Gym_Log_Book"
tools:ignore="LockedOrientationActivity">
android:theme="@style/Theme.Gym_Log_Book">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View File

@ -1,12 +1,10 @@
package org.british_information_technologies.gym_log_book.activity.main_activity
import android.Manifest
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.runtime.CompositionLocalProvider
import androidx.core.app.ActivityCompat
import androidx.navigation.compose.rememberNavController
import dagger.hilt.android.AndroidEntryPoint
import org.british_information_technologies.gym_log_book.activity.onboarding_activity.OnboardingActivityIntentUtils
@ -25,15 +23,7 @@ class MainActivity : ComponentActivity() {
OnboardingActivityIntentUtils.startActivity(applicationContext)
}
ActivityCompat.requestPermissions(
this,
arrayOf(
Manifest.permission.POST_NOTIFICATIONS,
Manifest.permission.READ_CALENDAR,
Manifest.permission.WRITE_CALENDAR
),
100
)
lifecycle.addObserver(vm)
setContent {
val nav = rememberNavController()
@ -47,5 +37,10 @@ class MainActivity : ComponentActivity() {
}
}
}
override fun onDestroy() {
super.onDestroy()
lifecycle.removeObserver(vm)
}
}

View File

@ -1,77 +0,0 @@
//package org.british_information_technologies.gym_log_book.activity.main_activity
//
//
//import androidx.compose.material.icons.Icons
//import androidx.compose.material.icons.outlined.Add
//import androidx.compose.material.icons.outlined.Edit
//import androidx.compose.material.icons.outlined.List
//import androidx.compose.material.icons.outlined.Menu
//import androidx.compose.runtime.Composable
//import androidx.compose.ui.graphics.vector.ImageVector
//import io.github.michael_bailey.android_chat_kit.extension.any.log
//import io.github.michael_bailey.android_chat_kit.utils.page.FabConfig
//import io.github.michael_bailey.android_chat_kit.utils.page.PageNavigation
//import io.github.michael_bailey.gym_log_book.activity.main_activity.ExerciseTypeListPage
//import org.british_information_technologies.gym_log_book.R
//import org.british_information_technologies.gym_log_book.activity.main_activity.exercise_page.ExerciseListPage
//import org.british_information_technologies.gym_log_book.activity.main_activity.weight_page.WeightListPage
//
//sealed class MainActivityPage(
// route: String,
// label: Int,
// icon: ImageVector
//) : PageNavigation<MainActivityViewModel>(route, label, icon) {
// object ExercisePage : MainActivityPage(
// "exercise_page",
// R.string.exercise_page_nav_button_label,
// Icons.Outlined.List
// ) {
// override val pageFunction: @Composable (MainActivityViewModel) -> Unit
// get() = {
// ExerciseListPage(vm = it)
// }
// override val fab
// get() = FabConfig<MainActivityViewModel>(
// label = R.string.exercise_page_nav_button_label,
// icon = Icons.Outlined.Add,
// exec = {
// it.startExerciseSetGuideActivity()
// }
// )
// }
//
// object WeightPage : MainActivityPage(
// route = "weight_page",
// label = R.string.weight_page_nav_button_label,
// icon = Icons.Outlined.Menu,
// ) {
// override val pageFunction: @Composable (MainActivityViewModel) -> Unit
// get() = { WeightListPage(vm = it) }
// override val fab
// get() = FabConfig<MainActivityViewModel>(
// label = R.string.weight_page_nav_button_label,
// icon = Icons.Outlined.Add,
// exec = {
// log("Add method to add new weight")
// }
// )
// }
//
// object ExerciseTypePage : MainActivityPage(
// route = "exercise_type_page",
// label = R.string.exercise_type_page_nav_button_label,
// icon = Icons.Outlined.Edit
// ) {
// override val pageFunction: @Composable (MainActivityViewModel) -> Unit
// get() = { ExerciseTypeListPage(vm = it) }
//
// override val fab: FabConfig<MainActivityViewModel>
// get() = FabConfig(
// label = R.string.exercise_type_page_nav_button_label,
// icon = Icons.Outlined.Edit,
// exec = {
// it.showAddTypeDialogue()
// }
// )
// }
//}

View File

@ -4,6 +4,8 @@ import android.app.Application
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
@ -35,7 +37,9 @@ class MainActivityViewModel @Inject constructor(
private val weightEntryRepository: WeightEntryRepository,
private val reminderRepository: ReminderRepository,
application: Application,
) : AndroidViewModel(application), IExerciseEntryListViewModel {
) : AndroidViewModel(application),
IExerciseEntryListViewModel,
DefaultLifecycleObserver {
// preference state
private val _onboardingOneShot = OneShotPreference("onboarding_complete")
@ -61,18 +65,18 @@ class MainActivityViewModel @Inject constructor(
// ui state
override val exerciseListState = LazyListState(
0,
0
firstVisibleItemIndex = 0,
firstVisibleItemScrollOffset = 0
)
val exerciseTypeListState = LazyListState(
0,
0
firstVisibleItemIndex = 0,
firstVisibleItemScrollOffset = 0
)
val weightListState = LazyListState(
0,
0
firstVisibleItemIndex = 0,
firstVisibleItemScrollOffset = 0
)
val removedID = mutableStateOf<UUID?>(null)
@ -100,10 +104,11 @@ class MainActivityViewModel @Inject constructor(
selectedReplacementType.value = id
}
fun initiateExerciseTypeDeletion(id: UUID) =
viewModelScope.launch(Dispatchers.IO) {
removedID.value = id
}
fun initiateExerciseTypeDeletion(
id: UUID
) = viewModelScope.launch(Dispatchers.IO) {
removedID.value = id
}
fun clearExerciseTypeDeletion() {
removedID.value = null
@ -129,7 +134,6 @@ class MainActivityViewModel @Inject constructor(
weightEntryRepository.delete(uuid)
}
fun createNewType(
exerciseName: String,
usingUserWeight: Boolean,
@ -140,7 +144,7 @@ class MainActivityViewModel @Inject constructor(
usingUserWeight,
equipmentClass = equipmentClass
)
}
}
fun getTypeFlow(id: UUID): Flow<EntExerciseType> =
exerciseTypeRepository.genType(id)
@ -161,4 +165,20 @@ class MainActivityViewModel @Inject constructor(
fun getWeightFlow(id: UUID): LiveData<EntWeightEntry?> {
return weightEntryRepository.genWeight(id).asLiveData()
}
override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
viewModelScope.launch(Dispatchers.IO) {
// this needs to be moved to onboarding, and put behind button presses.
// ActivityCompat.requestPermissions(
// owner as Activity,
// arrayOf(
// Manifest.permission.POST_NOTIFICATIONS,
// Manifest.permission.READ_CALENDAR,
// Manifest.permission.WRITE_CALENDAR
// ),
// 100
// )
}
}
}

View File

@ -60,53 +60,48 @@ dependencies {
implementation(project(":gym_library"))
// android deps
implementation("androidx.core:core-ktx:1.16.0")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.7")
implementation("androidx.lifecycle:lifecycle-livedata-ktx")
implementation(libs.androidx.core.ktx)
implementation(libs.bundles.lifecycle)
implementation(libs.androidx.core.splashscreen)
// google play deps
implementation("com.google.android.gms:play-services-wearable:19.0.0")
implementation(libs.play.services.wearable)
// compose deps
implementation(platform("androidx.compose:compose-bom:2025.04.00"))
implementation(platform(libs.compose.bom))
implementation(libs.bundles.compose)
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.wear.compose:compose-material:1.4.1")
implementation("androidx.wear.compose:compose-foundation:1.4.1")
implementation(libs.wear.compose.material)
implementation(libs.wear.compose.foundation)
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.runtime:runtime-livedata")
implementation("androidx.activity:activity-compose:1.10.1")
implementation("androidx.compose.material:material-icons-extended:$compose_version")
debugImplementation(libs.compose.ui.tooling.preview)
implementation(libs.compose.material3)
implementation(libs.compose.material.icons.extended)
// tile deps
implementation("androidx.wear.tiles:tiles:1.4.1")
implementation("androidx.wear.tiles:tiles-material:1.4.1")
implementation("androidx.wear.tiles:tiles-tooling-preview:1.4.1")
implementation(libs.androidx.tiles)
implementation(libs.androidx.tiles.material)
implementation(libs.androidx.tiles.tooling.preview)
// horologist deps
implementation("com.google.android.horologist:horologist-compose-tools:0.6.23")
implementation("com.google.android.horologist:horologist-tiles:0.6.23")
implementation("androidx.wear.watchface:watchface-complications-data-source-ktx:1.2.1")
implementation(libs.horologist.compose.tools)
implementation(libs.horologist.tiles)
implementation(libs.androidx.watchface.complications.data.source.ktx)
// compose navigation
implementation("androidx.navigation:navigation-compose:$nav_version")
implementation("androidx.navigation:navigation-runtime-ktx:$nav_version")
implementation(libs.bundles.navigation)
// room database deps
implementation("androidx.room:room-runtime:$room_version")
implementation("androidx.room:room-ktx:$room_version")
kapt("androidx.room:room-compiler:$room_version")
implementation(libs.bundles.room)
kapt(libs.room.compiler)
// work manager deps
implementation(libs.work.manager)
// hilt deps
implementation("com.google.dagger:hilt-android:$hilt_version")
kapt("com.google.dagger:hilt-android-compiler:$hilt_version")
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
implementation(libs.bundles.hilt)
kapt(libs.hilt.compiler)
// debug deps
implementation("androidx.wear:wear-tooling-preview:1.0.0")