-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from noxasch/feat/android-widget-provider-diff…
…-name FEAT(android): support provider with different package name
- Loading branch information
Showing
21 changed files
with
477 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"flutterSdkVersion": "3.0.5", | ||
"flutterSdkVersion": "3.13.8", | ||
"flavors": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...droid/app/src/main/kotlin/tech/noxasch/app_widget_example/AppWidgetExampleDiffProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tech.noxasch.diff_name | ||
|
||
import android.appwidget.AppWidgetManager | ||
import android.appwidget.AppWidgetProvider | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.util.Log | ||
import android.widget.RemoteViews | ||
import androidx.core.content.ContextCompat.startActivity | ||
import androidx.core.view.accessibility.AccessibilityEventCompat.setAction | ||
import io.flutter.embedding.engine.FlutterEngine | ||
import io.flutter.plugin.common.MethodChannel | ||
import tech.noxasch.app_widget.AppWidgetPlugin | ||
|
||
class AppWidgetExampleDiffProvider : AppWidgetProvider() { | ||
override fun onUpdate( | ||
context: Context?, | ||
appWidgetManager: AppWidgetManager?, | ||
appWidgetIds: IntArray? | ||
) { | ||
super.onUpdate(context, appWidgetManager, appWidgetIds) | ||
Log.d("APP_WIDGET_PLUGIN", "ON_UPDATE") | ||
if (appWidgetIds != null) { | ||
for (widgetId in appWidgetIds) { | ||
Log.d("APP_WIDGET_PLUGIN", "WIDGET_ID: $widgetId") | ||
} | ||
} | ||
|
||
// check if widgetId store sharedPreferences | ||
// fetch data from sharedPreferences | ||
// then update | ||
// for (widgetId in appWidgetIds!!) { | ||
// val remoteViews = RemoteViews(context!!.packageName, R.layout.example_layout).apply() { | ||
// setTextViewText(R.id.widget_title, "Widget Title") | ||
// setTextViewText(R.id.widget_message, "This is my message") | ||
// } | ||
// | ||
// appWidgetManager!!.partiallyUpdateAppWidget(widgetId, remoteViews) | ||
// } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app_widget/example/integration_test/android_test_diff_package.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import 'package:app_widget/app_widget.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
// there is no way to test callback as it need to interact with actual widgets | ||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
group('with androidPackageName', () { | ||
final AppWidgetPlugin appWidgetPlugin = AppWidgetPlugin( | ||
androidPackageName: 'tech.noxasch.app_widget_example', | ||
); | ||
|
||
testWidgets('configureWidget', (tester) async { | ||
final res = await appWidgetPlugin.configureWidget( | ||
androidPackageName: 'tech.noxasch.diff_name', | ||
widgetId: 1, | ||
widgetLayout: 'example_layout', | ||
payload: '{"itemId": 1, "stringUid": "uid"}', | ||
url: 'https://google.come', | ||
); | ||
expect(res, isTrue); | ||
}); | ||
|
||
testWidgets('cancelConfigureWidget', (tester) async { | ||
final res = await appWidgetPlugin.cancelConfigureWidget(); | ||
|
||
expect(res, isTrue); | ||
}); | ||
|
||
testWidgets('updateWidget', (tester) async { | ||
final res = await appWidgetPlugin.updateWidget( | ||
androidPackageName: 'tech.noxasch.diff_name', | ||
widgetId: 1, | ||
widgetLayout: 'example_layout', | ||
payload: '{"itemId": 1, "stringUid": "uid"}', | ||
url: 'https://google.come', | ||
textViews: {'widget_title': 'my title'}, | ||
); | ||
|
||
expect(res, isTrue); | ||
}); | ||
|
||
testWidgets('getWidgetIds', (tester) async { | ||
final res = await appWidgetPlugin.getWidgetIds( | ||
androidPackageName: 'tech.noxasch.diff_name', | ||
androidProviderName: 'AppWidgetExampleDiffProvider', | ||
); | ||
|
||
expect(res, []); | ||
}); | ||
|
||
testWidgets('reloadWidgets', (tester) async { | ||
final res = await appWidgetPlugin.reloadWidgets( | ||
androidPackageName: 'tech.noxasch.diff_name', | ||
androidProviderName: 'AppWidgetExampleDiffProvider', | ||
); | ||
|
||
expect(res, isTrue); | ||
}); | ||
|
||
testWidgets('widgetExist', (tester) async { | ||
final res = await appWidgetPlugin.widgetExist(12); | ||
|
||
expect(res, isFalse); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.