Skip to content

Commit f40b6b7

Browse files
committed
discard the change by #440
1 parent 257b646 commit f40b6b7

File tree

9 files changed

+178
-394
lines changed

9 files changed

+178
-394
lines changed
Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,59 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.ccextractor.taskwarriorflutter">
3-
<uses-permission android:name="android.permission.INTERNET" />
3+
<uses-permission android:name="android.permission.INTERNET" />
44
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
55
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
6-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7-
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
8-
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
9-
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
10-
<uses-permission android:name="android.permission.VIBRATE" />
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7+
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
8+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
9+
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
10+
<uses-permission android:name="android.permission.VIBRATE" />
11+
1112
<application
1213
android:label="Taskwarrior"
1314
android:name="${applicationName}"
1415
android:icon="@mipmap/launcher_icon"
1516
android:enableOnBackInvokedCallback="true">
17+
1618
<activity
1719
android:name=".MainActivity"
1820
android:exported="true"
19-
android:launchMode="singleTop"
21+
android:launchMode="singleTask"
2022
android:theme="@style/LaunchTheme"
2123
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
2224
android:hardwareAccelerated="true"
2325
android:windowSoftInputMode="adjustResize">
24-
<!-- Specifies an Android theme to apply to this Activity as soon as
25-
the Android process has started. This theme is visible to the user
26-
while the Flutter UI initializes. After that, this theme continues
27-
to determine the Window background behind the Flutter UI. -->
26+
2827
<meta-data
2928
android:name="io.flutter.embedding.android.NormalTheme"
3029
android:resource="@style/NormalTheme"
3130
/>
31+
3232
<intent-filter>
3333
<action android:name="android.intent.action.MAIN"/>
3434
<category android:name="android.intent.category.LAUNCHER"/>
3535
</intent-filter>
36-
<intent-filter>
37-
<action android:name="es.antonborri.home_widget.action.LAUNCH" />
38-
</intent-filter>
39-
</activity>
40-
41-
<receiver android:name=".TaskWarriorWidgetProvider"
42-
android:exported="true">
36+
4337
<intent-filter>
44-
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
38+
<action android:name="es.antonborri.home_widget.action.LAUNCH" />
4539
</intent-filter>
46-
<meta-data android:name="android.appwidget.provider"
47-
android:resource="@xml/taskwarriorconfig" />
48-
</receiver>
49-
50-
<receiver android:name=".WidgetUpdateReceiver"
51-
android:exported="true">
40+
5241
<intent-filter>
53-
<action android:name="UPDATE_WIDGET" />
42+
<action android:name="android.intent.action.VIEW" />
43+
<category android:name="android.intent.category.DEFAULT" />
44+
<category android:name="android.intent.category.BROWSABLE" />
45+
<data android:scheme="taskwarrior" />
5446
</intent-filter>
55-
</receiver>
56-
57-
<receiver android:name=".BurndownChartProvider"
47+
</activity>
48+
49+
<receiver android:name=".TaskWarriorWidgetProvider"
5850
android:exported="true">
5951
<intent-filter>
6052
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
6153
</intent-filter>
6254
<meta-data android:name="android.appwidget.provider"
63-
android:resource="@xml/burndownchartconfig" />
55+
android:resource="@xml/taskwarriorconfig" />
6456
</receiver>
65-
66-
<!-- Used for Background Work -->
6757
<receiver android:name="es.antonborri.home_widget.HomeWidgetBackgroundReceiver"
6858
android:exported="true">
6959
<intent-filter>
@@ -72,17 +62,15 @@
7262
</receiver>
7363
<service android:name="es.antonborri.home_widget.HomeWidgetBackgroundService"
7464
android:permission="android.permission.BIND_JOB_SERVICE" android:exported="true"/>
75-
<service
65+
<service
7666
android:name=".ListViewRemoteViewsService"
7767
android:permission="android.permission.BIND_REMOTEVIEWS" />
78-
<!-- Don't delete the meta-data below.
79-
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
68+
8069
<meta-data
8170
android:name="flutterEmbedding"
8271
android:value="2" />
83-
84-
85-
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
72+
73+
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
8674
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
8775
<intent-filter>
8876
<action android:name="android.intent.action.BOOT_COMPLETED"/>
@@ -92,4 +80,4 @@
9280
</intent-filter>
9381
</receiver>
9482
</application>
95-
</manifest>
83+
</manifest>

android/app/src/main/kotlin/com/ccextractor/taskwarriorflutter/BurndownChart.kt

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,7 @@
11
package com.ccextractor.taskwarriorflutter
22

3-
import android.content.Intent
4-
import android.os.Bundle
53
import io.flutter.embedding.android.FlutterActivity
6-
import io.flutter.embedding.engine.FlutterEngine
7-
import io.flutter.plugin.common.MethodChannel
8-
import android.content.Context
9-
import android.content.IntentFilter
10-
import android.appwidget.AppWidgetManager
11-
import android.content.ComponentName
124

135
class MainActivity: FlutterActivity() {
14-
private val channel = "com.ccextractor.taskwarriorflutter/widget"
15-
16-
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
17-
super.configureFlutterEngine(flutterEngine)
18-
19-
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, channel).setMethodCallHandler {
20-
call, result ->
21-
if (call.method == "updateWidget") {
22-
updateWidget()
23-
result.success("Widget updated")
24-
} else {
25-
result.notImplemented()
26-
}
27-
}
28-
}
29-
30-
private fun updateWidget() {
31-
val intent = Intent(this, WidgetUpdateReceiver::class.java).apply {
32-
action = "UPDATE_WIDGET"
33-
}
34-
sendBroadcast(intent)
35-
}
6+
// No custom code needed! The home_widget plugin attaches automatically.
367
}

android/app/src/main/kotlin/com/ccextractor/taskwarriorflutter/TaskWarriorWidgetProvider.kt

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,33 @@ import android.os.Build
2323
class TaskWarriorWidgetProvider : AppWidgetProvider() {
2424

2525
override fun onReceive(context: Context, intent: Intent) {
26-
// val myaction = intent.action
27-
if (intent.action == "TASK_ACTION") {
28-
val extras = intent.extras
29-
if(extras!=null){
30-
val uuid = extras.getString("uuid")?:""
31-
val add_task = extras.getString("launchedFor")
32-
val host = if(add_task == "ADD_TASK"){context.getString(R.string.app_widget_add_clicked_uri)}else{context.getString(R.string.app_widget_card_clicked_uri)}
33-
val launchIntent = Intent(context, MainActivity::class.java).apply {
34-
action = context.getString(R.string.app_widget_launch_action)
35-
data = Uri.parse("$host?uuid=$uuid")
36-
flags = Intent. FLAG_ACTIVITY_NEW_TASK
37-
context?.startActivity(this)
38-
}
39-
// HomeWidgetLaunchIntent.getActivity(context, MainActivity::class.java, Uri.parse("TaskWarrior://taskView?taskId=$uuid"))
40-
}
41-
}
42-
super.onReceive(context, intent)
43-
}
26+
// Handle the custom action from your Widget buttons/list
27+
if (intent.action == "TASK_ACTION") {
28+
val uuid = intent.getStringExtra("uuid") ?: ""
29+
val launchedFor = intent.getStringExtra("launchedFor")
30+
31+
// 1. Construct the URI exactly as Flutter expects it
32+
// Scheme: taskwarrior://
33+
// Host: cardclicked OR addclicked
34+
val deepLinkUri = if (launchedFor == "ADD_TASK") {
35+
Uri.parse("taskwarrior://addclicked")
36+
} else {
37+
// For list items, we attach the UUID
38+
Uri.parse("taskwarrior://cardclicked?uuid=$uuid")
39+
}
40+
41+
// 2. Create the Intent to open MainActivity
42+
val launchIntent = Intent(context, MainActivity::class.java).apply {
43+
action = Intent.ACTION_VIEW
44+
data = deepLinkUri
45+
// These flags ensure the app opens correctly whether running or not
46+
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
47+
}
48+
49+
context.startActivity(launchIntent)
50+
}
51+
super.onReceive(context, intent)
52+
}
4453
fun getLayoutId(context: Context) : Int{
4554
val sharedPrefs = HomeWidgetPlugin.getData(context)
4655
val theme = sharedPrefs.getString("themeMode", "")

android/app/src/main/kotlin/com/ccextractor/taskwarriorflutter/WidgetUpdateReceiver.kt

Lines changed: 0 additions & 68 deletions
This file was deleted.

android/app/src/main/res/xml/burndownchartconfig.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)