From 843f24e418868d020f9c06c143f7d179d0986b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Mon, 23 May 2022 19:11:42 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20prvn=C3=AD=20beta=20widget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .huskyrc | 1 + android/app/src/main/AndroidManifest.xml | 20 ++++++++++++ .../hernikplays/opencanteen/WidgetProvider.kt | 32 +++++++++++++++++++ .../app/src/main/res/layout/widget_layout.xml | 32 +++++++++++++++++++ android/app/src/main/res/xml/widget_info.xml | 8 +++++ lib/main.dart | 24 ++++++++++++++ pubspec.lock | 7 ++++ pubspec.yaml | 3 +- 8 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 .huskyrc create mode 100644 android/app/src/main/kotlin/cz/hernikplays/opencanteen/WidgetProvider.kt create mode 100644 android/app/src/main/res/layout/widget_layout.xml create mode 100644 android/app/src/main/res/xml/widget_info.xml diff --git a/.huskyrc b/.huskyrc new file mode 100644 index 0000000..0926705 --- /dev/null +++ b/.huskyrc @@ -0,0 +1 @@ +export PATH="/usr/local/bin:$PATH" \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 8c4a410..1a2342e 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -26,7 +26,27 @@ + + + + + + + + + + + + + + + + + + + val views = RemoteViews(context.packageName, R.layout.widget_layout).apply { + + // Open App on Widget Click + val pendingIntent = HomeWidgetLaunchIntent.getActivity(context, + MainActivity::class.java) + setOnClickPendingIntent(R.id.widget_root, pendingIntent) + + setTextViewText(R.id.obed, widgetData.getString("_obed", "Nic")) + + // Pending intent to update counter on button click + val backgroundIntent = HomeWidgetBackgroundIntent.getBroadcast(context, + Uri.parse("myAppWidget://update")) + setOnClickPendingIntent(R.id.bt_update, backgroundIntent) + } + appWidgetManager.updateAppWidget(widgetId, views) + } + } +} \ No newline at end of file diff --git a/android/app/src/main/res/layout/widget_layout.xml b/android/app/src/main/res/layout/widget_layout.xml new file mode 100644 index 0000000..0f480c1 --- /dev/null +++ b/android/app/src/main/res/layout/widget_layout.xml @@ -0,0 +1,32 @@ + + + + + + +