diff --git a/.gitignore b/.gitignore
index f9bd15f8..97b5c03c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -79,4 +79,6 @@ android/key.properties
tm.json
# FVM Version Cache
-.fvm/
\ No newline at end of file
+.fvm/
+
+android/build
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 11fae610..1f47bada 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -27,5 +27,5 @@
"README.md": "LICENSE,CODE_OF_CONDUCT.md,CONTRIBUTING.md,SECURITY.md,CONTRIBUTION.md,CHANGELOG.md,PRIVACY_POLICY.md",
"*.dart": "${capture}.g.dart,${capture}.freezed.dart"
},
- "dart.flutterSdkPath": ".fvm/flutter_sdk"
+ "dart.flutterSdkPath": ".fvm/versions/3.27.0"
}
\ No newline at end of file
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 7c1a6356..3221ef1d 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -28,8 +28,10 @@ if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
+def composeVersion = "1.4.8"
+
android {
- namespace "dev.krtirtho.spotube"
+ namespace "oss.krtirtho.spotube"
compileSdkVersion 35
@@ -48,6 +50,14 @@ android {
main.java.srcDirs += 'src/main/kotlin'
}
+ buildFeatures {
+ compose true
+ }
+
+ composeOptions {
+ kotlinCompilerExtensionVersion "$composeVersion" // Correlates with org.jetbrains.kotlin.android plugin in settings.gradle
+ }
+
defaultConfig {
applicationId "oss.krtirtho.spotube"
minSdkVersion 24
@@ -65,6 +75,7 @@ android {
storePassword keystoreProperties['storePassword']
}
}
+
buildTypes {
release {
signingConfig signingConfigs.release
@@ -104,9 +115,14 @@ flutter {
source '../..'
}
+def glanceVersion = "1.1.1"
dependencies {
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
-
// other deps so just ignore
implementation 'com.android.support:multidex:2.0.1'
+
+ implementation "androidx.glance:glance-appwidget:$glanceVersion"
+ implementation "androidx.glance:glance-appwidget-preview:$glanceVersion"
+ implementation "androidx.glance:glance-preview:$glanceVersion"
+ implementation "androidx.work:work-runtime-ktx:2.8.1"
}
\ No newline at end of file
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 78f744c4..eab0f448 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -99,6 +99,18 @@
+
+
+
+
+
+
+
+
+
diff --git a/android/app/src/main/kotlin/oss/krtirtho/spotube/glance/HomePlayerWidget.kt b/android/app/src/main/kotlin/oss/krtirtho/spotube/glance/HomePlayerWidget.kt
new file mode 100644
index 00000000..2444c3fc
--- /dev/null
+++ b/android/app/src/main/kotlin/oss/krtirtho/spotube/glance/HomePlayerWidget.kt
@@ -0,0 +1,48 @@
+package oss.krtirtho.spotube.glance
+
+import HomeWidgetGlanceState
+import HomeWidgetGlanceStateDefinition
+import android.content.Context
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.unit.dp
+import androidx.glance.GlanceId
+import androidx.glance.GlanceModifier
+import androidx.glance.appwidget.GlanceAppWidget
+import androidx.glance.appwidget.provideContent
+import androidx.glance.background
+import androidx.glance.currentState
+import androidx.glance.layout.Box
+import androidx.glance.layout.Column
+import androidx.glance.layout.padding
+import androidx.glance.preview.ExperimentalGlancePreviewApi
+import androidx.glance.preview.Preview
+import androidx.glance.state.GlanceStateDefinition
+import androidx.glance.text.Text
+
+class HomePlayerWidget : GlanceAppWidget() {
+ override val stateDefinition: GlanceStateDefinition<*>?
+ get() = HomeWidgetGlanceStateDefinition()
+
+ override suspend fun provideGlance(context: Context, id: GlanceId) {
+ provideContent {
+ GlanceContent(context, currentState())
+ }
+ }
+
+ @OptIn(ExperimentalGlancePreviewApi::class)
+ @Preview(widthDp = 200, heightDp = 150)
+ @Composable
+ private fun GlanceContent(context: Context, currentState: HomeWidgetGlanceState) {
+ val prefs = currentState.preferences
+ val counter = prefs.getInt("counter", 0)
+ Box(modifier = GlanceModifier.background(Color.White).padding(16.dp)) {
+ Column() {
+ Text("Counter")
+ Text(
+ counter.toString()
+ )
+ }
+ }
+ }
+}
diff --git a/android/app/src/main/kotlin/oss/krtirtho/spotube/glance/HomePlayerWidgetReceiver.kt b/android/app/src/main/kotlin/oss/krtirtho/spotube/glance/HomePlayerWidgetReceiver.kt
new file mode 100644
index 00000000..2d23c64f
--- /dev/null
+++ b/android/app/src/main/kotlin/oss/krtirtho/spotube/glance/HomePlayerWidgetReceiver.kt
@@ -0,0 +1,7 @@
+package oss.krtirtho.spotube.glance
+
+import HomeWidgetGlanceWidgetReceiver
+
+class HomePlayerWidgetReceiver : HomeWidgetGlanceWidgetReceiver() {
+ override val glanceAppWidget = HomePlayerWidget()
+}
diff --git a/android/app/src/main/res/xml/home_player_widget_config.xml b/android/app/src/main/res/xml/home_player_widget_config.xml
new file mode 100644
index 00000000..0b33ead7
--- /dev/null
+++ b/android/app/src/main/res/xml/home_player_widget_config.xml
@@ -0,0 +1,7 @@
+
+
diff --git a/android/settings.gradle b/android/settings.gradle
index a1961f52..b3629757 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -18,8 +18,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
- id "com.android.application" version "8.7.0" apply false
+ id "com.android.application" version '8.7.0' apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}
-include ":app"
\ No newline at end of file
diff --git a/pubspec.lock b/pubspec.lock
index e6e365a6..33913eb1 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1095,6 +1095,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
+ home_widget:
+ dependency: "direct main"
+ description:
+ name: home_widget
+ sha256: b313e3304c0429669fddf1286e1fbf61a64b873f38ba30b3eb890ef0d7560b12
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.7.0"
hooks_riverpod:
dependency: "direct main"
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 072c9a0a..af68abed 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -71,6 +71,7 @@ dependencies:
google_fonts: ^6.2.1
hive: ^2.2.3
hive_flutter: ^1.1.0
+ home_widget: ^0.7.0
hooks_riverpod: ^2.5.1
html: ^0.15.1
html_unescape: ^2.0.0