Skip to content

Commit

Permalink
Merge pull request #17 from brandy-kay/feature/work_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
brandyodhiambo committed Aug 25, 2023
2 parents ca5f4de + 75f0356 commit 9ec637e
Show file tree
Hide file tree
Showing 156 changed files with 3,303 additions and 875 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/android_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ on:

jobs:
build:
name: 🔨 Build
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout code
uses: actions/[email protected]

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Make gradle executable
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build --stacktrace

- name: Run Tests
run: ./gradlew test
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
"proguard-rules.pro"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
/*
* Copyright (C)2023 Brandy Odhiambo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.brandyodhiambo.quench

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import junit.framework.TestCase.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand All @@ -21,4 +34,4 @@ class ExampleInstrumentedTest {
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.brandyodhiambo.quench", appContext.packageName)
}
}
}
2 changes: 1 addition & 1 deletion app/src/debug/res/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#1F93F8</color>
</resources>
</resources>
13 changes: 12 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
</intent-filter>
</activity>
<receiver android:name=".util.AlarmReceiver" />
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">

<meta-data
android:name="androidx.work.WorkManagerInitializer"
android:value="androidx.startup"
tools:node="remove" />
</provider>
</application>

</manifest>
</manifest>
30 changes: 28 additions & 2 deletions app/src/main/java/com/brandyodhiambo/quench/QuenchApp.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
/*
* Copyright (C)2023 Brandy Odhiambo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.brandyodhiambo.quench

import android.app.Application
import androidx.hilt.work.HiltWorkerFactory
import androidx.work.Configuration
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber
import javax.inject.Inject

@HiltAndroidApp
class QuenchApp: Application() {
class QuenchApp : Application(), Configuration.Provider {
override fun onCreate() {
super.onCreate()
Timber.plant(Timber.DebugTree())
}
}

@Inject
lateinit var workerFactory: HiltWorkerFactory
override fun getWorkManagerConfiguration(): Configuration {
return Configuration.Builder()
.setWorkerFactory(workerFactory)
.build()
}
}
17 changes: 16 additions & 1 deletion app/src/main/java/com/brandyodhiambo/quench/models/TabItem.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
/*
* Copyright (C)2023 Brandy Odhiambo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.brandyodhiambo.quench.models

import androidx.compose.runtime.Composable
import com.brandyodhiambo.home.presentation.home_screen.HomeScreen
import com.brandyodhiambo.home.presentation.homeScreen.HomeScreen
import com.brandyodhiambo.quench.R
import com.brandyodhiambo.settings.presentation.SettingScreen
import com.brandyodhiambo.settings.presentation.SettingsNavigator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
/*
* Copyright (C)2023 Brandy Odhiambo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.brandyodhiambo.quench.navigation

import androidx.navigation.NavController
import com.brandyodhiambo.home.presentation.destinations.SleepAndWakeTimeScreenDestination
import com.brandyodhiambo.home.presentation.sleep_wake_screen.SleepAndWakeUpScreenScreenNavigator
import com.brandyodhiambo.home.presentation.sleepWakeScreen.SleepAndWakeUpScreenScreenNavigator
import com.brandyodhiambo.quench.ui.splash.SplashScreenNavigator
import com.brandyodhiambo.settings.presentation.AddReminderNavigator
import com.brandyodhiambo.settings.presentation.NotificationNavigator
Expand All @@ -14,15 +29,15 @@ import com.ramcosta.composedestinations.spec.NavGraphSpec

class FeatureNavigator(
private val navController: NavController,
private val navGraph: NavGraphSpec,
private val navGraph: NavGraphSpec
) : SplashScreenNavigator,
SleepAndWakeUpScreenScreenNavigator,
SettingsNavigator,
NotificationNavigator,
AddReminderNavigator {
override fun navigateToNotificationScreen() {
navController.navigate(
NavGraphs.settings.route,
NavGraphs.settings.route
)
}

Expand All @@ -40,7 +55,7 @@ class FeatureNavigator(

override fun navigateToMainScreen() {
navController.navigate(
NavGraphs.home.route,
NavGraphs.home.route
) {
popUpTo(NavGraphs.splash.route) {
inclusive = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (C)2023 Brandy Odhiambo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.brandyodhiambo.quench.navigation

import com.brandyodhiambo.home.presentation.destinations.HomeScreenDestination
Expand All @@ -18,15 +33,15 @@ object NavGraphs {
override val startRoute: Route = SplashScreenDestination routedIn this
override val destinationsByRoute = listOf<DestinationSpec<*>>(
SplashScreenDestination,
SleepAndWakeTimeScreenDestination,
SleepAndWakeTimeScreenDestination
).routedIn(this).associateBy { it.route }
}
val home = object : NavGraphSpec {
override val route: String = "home"
override val startRoute: Route = MainScreenDestination routedIn this
override val destinationsByRoute = listOf<DestinationSpec<*>>(
HomeScreenDestination,
MainScreenDestination,
MainScreenDestination
).routedIn(this).associateBy { it.route }
}

Expand All @@ -36,7 +51,7 @@ object NavGraphs {
override val destinationsByRoute = listOf<DestinationSpec<*>>(
SettingScreenDestination,
NotificationScreenDestination,
AddReminderScreenDestination,
AddReminderScreenDestination
).routedIn(this).associateBy { it.route }
}

Expand Down
26 changes: 25 additions & 1 deletion app/src/main/java/com/brandyodhiambo/quench/ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright (C)2023 Brandy Odhiambo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.brandyodhiambo.quench.ui

import android.annotation.SuppressLint
Expand All @@ -15,12 +30,16 @@ import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hierarchy
import com.brandyodhiambo.common.domain.model.AlarmData
import com.brandyodhiambo.designsystem.theme.QuenchTheme
import com.brandyodhiambo.home.presentation.home_screen.HomeViewModel
import com.brandyodhiambo.home.presentation.homeScreen.HomeViewModel
import com.brandyodhiambo.quench.R
import com.brandyodhiambo.quench.navigation.FeatureNavigator
import com.brandyodhiambo.quench.navigation.NavGraphs
import com.brandyodhiambo.quench.util.AlarmSchedularImpl
import com.brandyodhiambo.quench.util.createChannel
import com.brandyodhiambo.statistics.worker.startAchievementOnetimeWorkRequest
import com.brandyodhiambo.statistics.worker.startDailyOnetimeWorkRequest
import com.brandyodhiambo.statistics.worker.startMonthlyOnetimeWorkRequest
import com.brandyodhiambo.statistics.worker.startWeeklyOnetimeWorkRequest
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
import com.ramcosta.composedestinations.DestinationsNavHost
import com.ramcosta.composedestinations.navigation.dependency
Expand All @@ -45,6 +64,11 @@ class MainActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background,
) {
startAchievementOnetimeWorkRequest(applicationContext)
startDailyOnetimeWorkRequest(applicationContext)
startMonthlyOnetimeWorkRequest(applicationContext)
startWeeklyOnetimeWorkRequest(applicationContext)

val reminderTimeFromDb = viewModel.reminderTime.observeAsState()
val hours = reminderTimeFromDb.value?.hour ?: 0
val minutes = reminderTimeFromDb.value?.minute ?: 0
Expand Down
Loading

0 comments on commit 9ec637e

Please sign in to comment.