Skip to content
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

[#259, 위젯 기능 추가] #260

Merged
merged 3 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

widget 모듈에서 manifest를 작성하게 되면 app 모듈에서 자연스럽게 병합이 가능할 것으로 보이는데요.
이와 관련해서도 제약사항이 따로 존재하나요?
*이 방법이라면 DroidKnightsWidgetReceiver 를 internal로 만드는 것도 가능함

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application tools:targetApi="31">

        <receiver
            android:name=".DroidKnightsWidgetReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_info" />
        </receiver>

    </application>

</manifest>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 식으로도 처리할 수 있군요 수정해보겠습니다 !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영하였습니다

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glance Library 추가 (targetSDK 버전 제한으로 beta01 버전 적용)

베타를 적용함으로써 이 작업에서 처음 의도한 것과 달리 기능을 모두 드러내지 못한 부분이 있었나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의도했던 부분을 드러내지 못한 것은 없습니다.
실제 제가 개발하고 운영중인 서비스에도 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,4 +1,4 @@
package com.droidknights.app2023
package com.droidknights.app2023.widget

import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp
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