Skip to content

Commit

Permalink
[droidknights#259, 위젯 추가 보완]
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongth9446 committed Sep 10, 2023
1 parent c529c82 commit 969393a
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
tools:targetApi="31">

<receiver
android:name=".DroidKnightsWidgetReceiver"
android:name=".widget.DroidKnightsWidgetReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.core.view.WindowCompat
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.droidknights.app2023.DroidKnightsWidget.Companion.KEY_SESSION_ID
import com.droidknights.app2023.widget.DroidKnightsWidget.Companion.KEY_SESSION_ID
import com.droidknights.app2023.core.designsystem.theme.KnightsTheme
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.app.Application
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.droidknights.app2023.core.data.repository.SettingsRepository
import com.droidknights.app2023.sendWidgetUpdateCommand
import com.droidknights.app2023.widget.sendWidgetUpdateCommand
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import com.droidknights.app2023.core.model.Room
import com.droidknights.app2023.core.model.Session
import com.droidknights.app2023.core.model.Speaker
import com.droidknights.app2023.core.model.Tag
import com.droidknights.app2023.sendWidgetUpdateCommand
import com.droidknights.app2023.widget.sendWidgetUpdateCommand
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.delay
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ossLicenses = "17.0.1"
ossLicensesPlugin = "0.10.6"

androidxGlance = "1.0.0-beta01"
glanceExperimentalTools = "0.2.2"

[libraries]
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
Expand Down Expand Up @@ -114,6 +115,7 @@ oss-licenses-plugin = { group = "com.google.android.gms", name = "oss-licenses-p

androidx-glance = { group = "androidx.glance", name = "glance", version.ref = "androidxGlance" }
androidx-glance-appwidget = { group = "androidx.glance", name = "glance-appwidget", version.ref = "androidxGlance" }
glance-tools-appwidget-host = { group = "com.google.android.glance.tools", name = "appwidget-host", version.ref = "glanceExperimentalTools"}

[bundles]

Expand Down
1 change: 1 addition & 0 deletions widget/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ android {
dependencies {
implementation(libs.androidx.glance)
implementation(libs.androidx.glance.appwidget)
implementation(libs.glance.tools.appwidget.host)

implementation(projects.core.designsystem)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.droidknights.app2023
package com.droidknights.app2023.widget

import android.content.Context
import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.droidknights.app2023
package com.droidknights.app2023.widget

import android.appwidget.AppWidgetManager
import android.content.Context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.droidknights.app2023
package com.droidknights.app2023.widget

import android.content.Context
import androidx.compose.runtime.LaunchedEffect
Expand All @@ -23,10 +23,10 @@ import androidx.glance.layout.Spacer
import androidx.glance.layout.fillMaxSize
import androidx.glance.layout.height
import androidx.glance.layout.padding
import com.droidknights.app2023.DroidKnightsWidgetReceiver.Companion.KEY_SESSION_IDS
import com.droidknights.app2023.widget.DroidKnightsWidgetReceiver.Companion.KEY_SESSION_IDS
import com.droidknights.app2023.core.designsystem.theme.KnightsGlanceTheme
import com.droidknights.app2023.core.model.Session
import com.droidknights.app2023.di.WidgetModule
import com.droidknights.app2023.widget.di.WidgetModule
import dagger.hilt.EntryPoints

class DroidKnightsWidget : GlanceAppWidget() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.droidknights.app2023
package com.droidknights.app2023.widget

import android.appwidget.AppWidgetManager
import android.content.Context
Expand All @@ -10,7 +10,7 @@ import androidx.glance.appwidget.GlanceAppWidgetReceiver
import androidx.glance.appwidget.state.updateAppWidgetState
import androidx.glance.appwidget.updateAll
import androidx.glance.state.PreferencesGlanceStateDefinition
import com.droidknights.app2023.di.WidgetModule
import com.droidknights.app2023.widget.di.WidgetModule
import dagger.hilt.EntryPoints
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
Expand All @@ -20,10 +20,6 @@ import kotlinx.coroutines.launch
@AndroidEntryPoint
class DroidKnightsWidgetReceiver : GlanceAppWidgetReceiver() {

companion object {
const val KEY_SESSION_IDS = "SESSION_IDS"
}

override val glanceAppWidget: GlanceAppWidget = DroidKnightsWidget()

override fun onUpdate(
Expand All @@ -39,6 +35,10 @@ class DroidKnightsWidgetReceiver : GlanceAppWidgetReceiver() {
getBookmarkedSessionAndUpdateWidget(context, glanceAppWidget)
super.onReceive(context, intent)
}

companion object {
const val KEY_SESSION_IDS = "SESSION_IDS"
}
}

private fun getBookmarkedSessionAndUpdateWidget(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.droidknights.app2023
package com.droidknights.app2023.widget

import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.glance.GlanceModifier
import androidx.glance.GlanceTheme
import androidx.glance.LocalContext
import androidx.glance.LocalGlanceId
import androidx.glance.action.clickable
import androidx.glance.appwidget.cornerRadius
import androidx.glance.background
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.droidknights.app2023
package com.droidknights.app2023.widget

import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.sp
Expand All @@ -8,7 +8,6 @@ import androidx.glance.LocalContext
import androidx.glance.action.clickable
import androidx.glance.text.Text
import androidx.glance.text.TextDefaults
import com.droidknights.app2023.widget.R

@Composable
fun WidgetTitle() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.droidknights.app2023.di
package com.droidknights.app2023.widget.di

import com.droidknights.app2023.core.domain.usecase.GetBookmarkedSessionsUseCase
import com.droidknights.app2023.core.domain.usecase.GetSessionUseCase
Expand Down

0 comments on commit 969393a

Please sign in to comment.