feat: add permission_handler and TileService (wip)

master
hoba_razor 4 years ago
parent 08ad4ab5f1
commit 0e3124cba0
  1. 14
      android/app/src/main/AndroidManifest.xml
  2. 35
      android/app/src/main/kotlin/com/example/contact_tracing/MainTileService.kt
  3. 3
      android/app/src/main/res/values/styles.xml
  4. 7
      lib/main.dart
  5. 35
      pubspec.lock
  6. 1
      pubspec.yaml
  7. 3
      windows/flutter/generated_plugin_registrant.cc
  8. 1
      windows/flutter/generated_plugins.cmake

@ -25,12 +25,24 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service
android:name=".MainTileService"
android:exported="true"
android:icon="@drawable/launch_background"
android:label="@string/tile_service_name"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</application>
<queries>
<!-- If your sends SMS messages -->
<intent>

@ -0,0 +1,35 @@
package com.example.contact_tracing
import android.service.quicksettings.TileService
class MainTileService: TileService(){
/*
override fun onClick() {
super.onClick()
}
override fun onTileRemoved() {
super.onTileRemoved()
// Do something when the user removes the Tile
}
override fun onTileAdded() {
super.onTileAdded()
// Do something when the user add the Tile
}
override fun onStartListening() {
super.onStartListening()
// Called when the Tile becomes visible
}
override fun onStopListening() {
super.onStopListening()
// Called when the tile is no longer visible
}
*/
}

@ -15,4 +15,7 @@
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
<string
name="tile_service_name"
>Contact Tracing</string>
</resources>

@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:flutter_sms/flutter_sms.dart';
import 'package:permission_handler/permission_handler.dart';
void main() {
runApp(const AnalyzeView());
@ -26,6 +27,12 @@ class AnalyzeViewState extends State<AnalyzeView>
);
void _sendSMS(String message, List<String> recipents) async {
var status = await Permission.sms.status;
if (status.isDenied) {
Map<Permission, PermissionStatus> statuses = await [
Permission.sms,
].request();
}
String _result =
await sendSMS(message: message, recipients: recipents, sendDirect: true)
.catchError((onError) {

@ -172,6 +172,41 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
url: "https://pub.dartlang.org"
source: hosted
version: "9.2.0"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
url: "https://pub.dartlang.org"
source: hosted
version: "9.0.2+1"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
url: "https://pub.dartlang.org"
source: hosted
version: "9.0.3"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.7.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
petitparser:
dependency: transitive
description:

@ -35,6 +35,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
mobile_scanner: ^0.0.3
permission_handler: ^9.2.0
# flutter_sms: ^2.3.2
flutter_sms:
git:

@ -6,9 +6,12 @@
#include "generated_plugin_registrant.h"
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
permission_handler_windows
url_launcher_windows
)