fix(android): resolve compilation errors and add missing resources
All checks were successful
continuous-integration/drone/push Build is passing

- Add missing imports for Column, dp, and Color
- Fix Hilt dependency injection for AppWidgetProvider
- Remove experimental Material API usage
- Fix DataStore type mismatch error
- Add application icon resources for all densities
- Update gitignore to exclude IDE files and build artifacts
This commit is contained in:
Ching 2025-11-23 02:34:49 +08:00
parent c790cee472
commit 3f4d62fde0
22 changed files with 376 additions and 18 deletions

99
.gitignore vendored
View File

@ -169,4 +169,101 @@ cython_debug/
#.idea/
tasks.db
credentials.json
credentials.json
# ---> Android
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/
# Google Services (e.g. APIs or Firebase)
# google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
# Version control
vcs.xml
# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
# ---> IDEs
# IDE configuration files
.idea/
.vscode/
*.swp
*.swo
*~
# Claude AI
.claude/

View File

@ -1,7 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("com.google.devtools.ksp")
id("com.google.dagger.hilt.android")
}
@ -60,6 +60,9 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.activity:activity-compose:1.8.0")
// Material Components
implementation("com.google.android.material:material:1.10.0")
// Compose
implementation(platform("androidx.compose:compose-bom:2023.10.01"))
implementation("androidx.compose.ui:ui")
@ -80,13 +83,13 @@ dependencies {
// Hilt
implementation("com.google.dagger:hilt-android:2.48")
kapt("com.google.dagger:hilt-compiler:2.48")
ksp("com.google.dagger:hilt-compiler:2.48")
implementation("androidx.hilt:hilt-navigation-compose:1.1.0")
// Room
implementation("androidx.room:room-runtime:2.6.0")
implementation("androidx.room:room-ktx:2.6.0")
kapt("androidx.room:room-compiler:2.6.0")
ksp("androidx.room:room-compiler:2.6.0")
// Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")

View File

@ -1,7 +1,13 @@
package com.tunpok.calendarwidget
import android.app.Application
import com.tunpok.calendarwidget.data.repository.TaskRepository
import dagger.hilt.android.HiltAndroidApp
import javax.inject.Inject
@HiltAndroidApp
class CalendarWidgetApplication : Application()
class CalendarWidgetApplication : Application() {
@Inject
lateinit var taskRepository: TaskRepository
}

View File

@ -3,6 +3,7 @@ package com.tunpok.calendarwidget
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
@ -12,6 +13,7 @@ import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavDestination.Companion.hierarchy
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.compose.NavHost

View File

@ -1,6 +1,7 @@
package com.tunpok.calendarwidget.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
@ -121,10 +122,10 @@ fun TaskDisplayCard(
modifier: Modifier = Modifier
) {
Card(
onClick = onClick,
modifier = modifier
.fillMaxWidth()
.height(80.dp),
.height(80.dp)
.clickable { onClick() },
shape = RoundedCornerShape(16.dp),
colors = CardDefaults.cardColors(
containerColor = SurfaceColor

View File

@ -10,6 +10,7 @@ import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView

View File

@ -8,19 +8,18 @@ import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.widget.RemoteViews
import com.tunpok.calendarwidget.CalendarWidgetApplication
import com.tunpok.calendarwidget.R
import com.tunpok.calendarwidget.data.repository.TaskRepository
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject
@AndroidEntryPoint
class TaskWidgetProvider : AppWidgetProvider() {
@Inject
lateinit var repository: TaskRepository
private fun getRepository(context: Context): TaskRepository {
return (context.applicationContext as CalendarWidgetApplication).taskRepository
}
override fun onUpdate(
context: Context,
@ -124,6 +123,7 @@ class TaskWidgetProvider : AppWidgetProvider() {
}
private fun handleTaskClick(context: Context, taskId: Int) {
val repository = getRepository(context)
CoroutineScope(Dispatchers.IO).launch {
repository.scheduleTask(taskId)
refreshWidget(context)

View File

@ -6,6 +6,7 @@ import androidx.datastore.preferences.core.*
import androidx.datastore.preferences.preferencesDataStore
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import javax.inject.Inject
import javax.inject.Singleton
@ -35,7 +36,7 @@ class AppSettings @Inject constructor(
.map { preferences ->
preferences[PreferenceKeys.API_KEY] ?: "change-me"
}
.collect { it }
.first()
}
suspend fun saveApiHost(apiHost: String) {

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
</vector>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108L99,108L99,0L9,0ZM93,6L93,102L15,102L15,6L93,6Z" />
<path
android:fillColor="#00000000"
android:pathData="M54,19C65.05,19 74,27.95 74,39S65.05,59 54,59S34,50.05 34,39S42.95,19 54,19Z" />
<path
android:fillColor="#00000000"
android:pathData="M54,25L61,32L51,42L57,48L69,36L69,48L45,48L45,25L54,25Z" />
<path
android:fillColor="#00000000"
android:pathData="M24,64L84,64L84,89L24,89L24,64Z" />
<path
android:fillColor="#00000000"
android:pathData="M30,70L42,70L42,83L30,83L30,70Z" />
<path
android:fillColor="#00000000"
android:pathData="M48,70L60,70L60,83L48,83L48,70Z" />
<path
android:fillColor="#00000000"
android:pathData="M66,70L78,70L78,83L66,83L66,70Z" />
</vector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h48v48h-48z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M8,8h32v32h-32z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,12c6.6,0 12,5.4 12,12s-5.4,12 -12,12s-12,-5.4 -12,-12s5.4,-12 12,-12z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,18h8v2h-8z M20,22h8v2h-8z M20,26h8v2h-8z" />
<path
android:fillColor="#26A69A"
android:pathData="M10,32h28v4h-28z" />
</vector>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M24,24m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0" />
<path
android:fillColor="#FFFFFF"
android:pathData="M12,12h24v24h-24z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,16c4.4,0 8,3.6 8,8s-3.6,8 -8,8s-8,-3.6 -8,-8s3.6,-8 8,-8z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,20h8v2h-8z M20,23h8v2h-8z M20,26h8v2h-8z" />
</vector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h48v48h-48z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M8,8h32v32h-32z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,12c6.6,0 12,5.4 12,12s-5.4,12 -12,12s-12,-5.4 -12,-12s5.4,-12 12,-12z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,18h8v2h-8z M20,22h8v2h-8z M20,26h8v2h-8z" />
<path
android:fillColor="#26A69A"
android:pathData="M10,32h28v4h-28z" />
</vector>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M24,24m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0" />
<path
android:fillColor="#FFFFFF"
android:pathData="M12,12h24v24h-24z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,16c4.4,0 8,3.6 8,8s-3.6,8 -8,8s-8,-3.6 -8,-8s3.6,-8 8,-8z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,20h8v2h-8z M20,23h8v2h-8z M20,26h8v2h-8z" />
</vector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h48v48h-48z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M8,8h32v32h-32z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,12c6.6,0 12,5.4 12,12s-5.4,12 -12,12s-12,-5.4 -12,-12s5.4,-12 12,-12z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,18h8v2h-8z M20,22h8v2h-8z M20,26h8v2h-8z" />
<path
android:fillColor="#26A69A"
android:pathData="M10,32h28v4h-28z" />
</vector>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M24,24m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0" />
<path
android:fillColor="#FFFFFF"
android:pathData="M12,12h24v24h-24z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,16c4.4,0 8,3.6 8,8s-3.6,8 -8,8s-8,-3.6 -8,-8s3.6,-8 8,-8z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,20h8v2h-8z M20,23h8v2h-8z M20,26h8v2h-8z" />
</vector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h48v48h-48z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M8,8h32v32h-32z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,12c6.6,0 12,5.4 12,12s-5.4,12 -12,12s-12,-5.4 -12,-12s5.4,-12 12,-12z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,18h8v2h-8z M20,22h8v2h-8z M20,26h8v2h-8z" />
<path
android:fillColor="#26A69A"
android:pathData="M10,32h28v4h-28z" />
</vector>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M24,24m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0" />
<path
android:fillColor="#FFFFFF"
android:pathData="M12,12h24v24h-24z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,16c4.4,0 8,3.6 8,8s-3.6,8 -8,8s-8,-3.6 -8,-8s3.6,-8 8,-8z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,20h8v2h-8z M20,23h8v2h-8z M20,26h8v2h-8z" />
</vector>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h48v48h-48z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M8,8h32v32h-32z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,12c6.6,0 12,5.4 12,12s-5.4,12 -12,12s-12,-5.4 -12,-12s5.4,-12 12,-12z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,18h8v2h-8z M20,22h8v2h-8z M20,26h8v2h-8z" />
<path
android:fillColor="#26A69A"
android:pathData="M10,32h28v4h-28z" />
</vector>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#26A69A"
android:pathData="M24,24m-24,0a24,24 0,1 1,48 0a24,24 0,1 1,-48 0" />
<path
android:fillColor="#FFFFFF"
android:pathData="M12,12h24v24h-24z" />
<path
android:fillColor="#26A69A"
android:pathData="M24,16c4.4,0 8,3.6 8,8s-3.6,8 -8,8s-8,-3.6 -8,-8s3.6,-8 8,-8z" />
<path
android:fillColor="#FFFFFF"
android:pathData="M20,20h8v2h-8z M20,23h8v2h-8z M20,26h8v2h-8z" />
</vector>

View File

@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.2.0" apply false
id("com.android.application") version "8.13.1" apply false
id("org.jetbrains.kotlin.android") version "1.9.20" apply false
id("com.google.dagger.hilt.android") version "2.48" apply false
id("com.google.devtools.ksp") version "1.9.20-1.0.14" apply false
}

View File

@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists