diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index 966b603..16960f4 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,17 +1,27 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 909f4a5..da3c593 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,13 +1,15 @@ - + + + + - + + + + + + @@ -45,9 +53,17 @@ - - + + + + + + + + + + - + \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 5e71c2e..dba1ff0 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -27,7 +27,7 @@ apply plugin: 'kotlin-android' android { compileSdkVersion 30 defaultConfig { - minSdkVersion 16 + minSdkVersion 19 targetSdkVersion 30 } compileOptions { @@ -47,4 +47,5 @@ dependencies { implementation 'com.facebook.rebound:rebound:0.3.8' implementation 'androidx.core:core-ktx:1.3.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation 'com.github.tntkhang:gmail-sender-library:1.2.0' } diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index b76afb7..7b4fbe6 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -5,6 +5,7 @@ + , retries: IntArray) { channel.invokeMethod(method, arguments, object : MethodChannel.Result { override fun success(o: Any?) { - Log.i("TAG", "Invoke call back success") + Log.i("TAG", "Invoke call back successs from Floaty Head Plugin") + Log.i("TAG", "channel :${channel}, method : $method , arguments: ${arguments.toString()}, retries : ${retries.toString()} ") + var tag: String = arguments[2].toString().split(":")[0] + if (tag == "alarm_btn") { + var numbersInString: String = arguments[2].toString().split(":")[1]; + var numbers: List = numbersInString.subSequence(1, numbersInString.length - 1).split(",") + Log.i("TAG", "Sending Alarm to following contacts : " + numbers.toString()) + + } else if (tag == "message_only") { + var numbersInString: String = arguments[2].toString().split(":")[1]; + var numbers: List = numbersInString.subSequence(1, numbersInString.length - 1).split(",") + Log.i("TAG", "Sending Messages to following contacts : " + numbers.toString()) + for ( elem in numbers) + sendSMSMessage(elem, "HI") + } else if (tag == "open_app") { + val url = "http://www.epicare.com/home" + val intent = Intent(Intent.ACTION_VIEW) + intent.data = Uri.parse(url) + activity?.startActivity(intent) + } } override fun error(s: String?, s1: String?, o: Any?) { @@ -182,7 +218,7 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:$packageName")), CODE_DRAW_OVER_OTHER_APP_PERMISSION) } else { - if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { val subIntent = Intent(activity?.applicationContext, FloatyContentJobService::class.java) subIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) subIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) @@ -198,11 +234,11 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH } "isOpen" -> result.success(mBound) "close" -> { - if(mBound){ + if (mBound) { FloatyContentJobService.instance!!.closeWindow(true) - if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q){ + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { activity?.stopService(Intent(activity?.applicationContext, FloatyContentJobService::class.java)) - }else{ + } else { activity?.startForegroundService(Intent(activity?.applicationContext, FloatyContentJobService::class.java)) } mBound = false @@ -257,18 +293,18 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH } } - private fun setNotificationTitle(title: String):Int { + private fun setNotificationTitle(title: String): Int { var result = -1 try { Managment.notificationTitle = title result = 1 - }catch (e: IOException) { + } catch (e: IOException) { e.printStackTrace() } return result } - private fun setNotificationIcon(assetPath: String):Int { + private fun setNotificationIcon(assetPath: String): Int { var result = -1 try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { @@ -284,13 +320,13 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH Managment.notificationIcon = BitmapFactory.decodeStream(inputStream) result = 1 } - }catch (e: IOException) { + } catch (e: IOException) { e.printStackTrace() } return result } - private fun setBackgroundCloseIconFromAsset(assetPath: String):Int { + private fun setBackgroundCloseIconFromAsset(assetPath: String): Int { var result = -1 try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { @@ -298,8 +334,7 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH val bitmap = BitmapFactory.decodeStream(inputStream) Managment.backgroundCloseIcon = bitmap result = 1 - } - else { + } else { val assetLookupKey = FlutterLoader.getInstance().getLookupKeyForAsset(assetPath) val assetManager = activity!!.applicationContext.assets val assetFileDescriptor = assetManager.openFd(assetLookupKey) @@ -307,22 +342,21 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH Managment.backgroundCloseIcon = BitmapFactory.decodeStream(inputStream) result = 1 } - }catch (e: IOException) { + } catch (e: IOException) { e.printStackTrace() } return result } - private fun setCloseIconFromAsset(assetPath: String):Int { + private fun setCloseIconFromAsset(assetPath: String): Int { var result = -1 try { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N){ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { val inputStream = activity!!.applicationContext.assets.open("flutter_assets/" + assetPath) val bitmap = BitmapFactory.decodeStream(inputStream) Managment.closeIcon = bitmap result = 1 - } - else { + } else { val assetLookupKey = FlutterLoader.getInstance().getLookupKeyForAsset(assetPath) val assetManager = activity!!.applicationContext.assets val assetFileDescriptor = assetManager.openFd(assetLookupKey) @@ -330,13 +364,13 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH Managment.closeIcon = BitmapFactory.decodeStream(inputStream) result = 1 } - }catch (e: IOException) { + } catch (e: IOException) { e.printStackTrace() } return result } - private fun setIconFromAsset(assetPath: String):Int { + private fun setIconFromAsset(assetPath: String): Int { var result = -1 try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { @@ -344,8 +378,7 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH val bitmap = BitmapFactory.decodeStream(inputStream) Managment.floatingIcon = bitmap result = 1 - } - else { + } else { val assetLookupKey = FlutterLoader.getInstance().getLookupKeyForAsset(assetPath) val assetManager = activity!!.applicationContext.assets val assetFileDescriptor = assetManager.openFd(assetLookupKey) @@ -353,7 +386,7 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH Managment.floatingIcon = BitmapFactory.decodeStream(inputStream) result = 1 } - }catch (e: IOException) { + } catch (e: IOException) { e.printStackTrace() } return result @@ -364,28 +397,28 @@ class FloatyHeadPlugin : ActivityAware, FlutterPlugin, MethodChannel.MethodCallH //release() } - override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { - channel = MethodChannel(flutterPluginBinding.binaryMessenger, METHOD_CHANNEL) - channel?.setMethodCallHandler(this) - } + override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { + channel = MethodChannel(flutterPluginBinding.binaryMessenger, METHOD_CHANNEL) + channel?.setMethodCallHandler(this) + } - override fun onAttachedToActivity(binding: ActivityPluginBinding) { - activity = binding.activity - Managment.activity = binding.activity - instance = this@FloatyHeadPlugin - } + override fun onAttachedToActivity(binding: ActivityPluginBinding) { + activity = binding.activity + Managment.activity = binding.activity + instance = this@FloatyHeadPlugin + } - override fun onDetachedFromActivity() { - //release() - } + override fun onDetachedFromActivity() { + //release() + } - override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { - activity = binding.activity - Managment.activity = binding.activity - instance = this@FloatyHeadPlugin - } + override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { + activity = binding.activity + Managment.activity = binding.activity + instance = this@FloatyHeadPlugin + } - override fun onDetachedFromActivityForConfigChanges() { - //release() - } + override fun onDetachedFromActivityForConfigChanges() { + //release() + } } diff --git a/android/src/main/res/drawable/bot.jpg b/android/src/main/res/drawable/bot.jpg old mode 100755 new mode 100644 index 3f9fcc2..d8adc4f Binary files a/android/src/main/res/drawable/bot.jpg and b/android/src/main/res/drawable/bot.jpg differ diff --git a/android/src/main/res/drawable/bot1.jpg b/android/src/main/res/drawable/bot1.jpg new file mode 100755 index 0000000..3f9fcc2 Binary files /dev/null and b/android/src/main/res/drawable/bot1.jpg differ diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index c538f55..93e7830 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -27,6 +27,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion 29 + ndkVersion '21.3.6528147' sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -39,7 +40,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "ni.devotion.floaty_head_example" - minSdkVersion 16 + minSdkVersion 19 targetSdkVersion 29 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/example/lib/main.dart b/example/lib/main.dart index 1c91409..31e0566 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -41,11 +41,15 @@ class _Home extends State { ), textColor: Colors.black87, ), - decoration: FloatyHeadDecoration(startColor: Colors.grey[100]), + decoration: FloatyHeadDecoration( + startColor: Colors.white, + endColor: Colors.amber, + borderColor: Colors.red, + ), button: FloatyHeadButton( text: FloatyHeadText( fontWeight: FontWeight.bold, - text: "Personal", + text: "Peronal", fontSize: 10, textColor: Colors.black45, padding: FloatyHeadPadding( @@ -189,7 +193,30 @@ class _Home extends State { endColor: Color.fromRGBO(247, 28, 88, 1), borderWidth: 0, borderRadius: 30.0), - ) + ), + FloatyHeadButton( + text: FloatyHeadText( + fontWeight: FontWeight.normal, + padding: FloatyHeadPadding( + bottom: 4, + left: 5, + right: 5, + top: 5, + ), + text: "Focus button", + fontSize: 12, + textColor: Colors.white, + ), + tag: "focus_button", + width: 0, + padding: FloatyHeadPadding(left: 10, right: 10, bottom: 10, top: 10), + height: FloatyHeadButton.WRAP_CONTENT, + decoration: FloatyHeadDecoration( + startColor: Color.fromRGBO(250, 139, 97, 1), + endColor: Color.fromRGBO(247, 28, 88, 1), + borderWidth: 0, + borderRadius: 30.0), + ), ], padding: FloatyHeadPadding(left: 16, right: 16, bottom: 12), decoration: FloatyHeadDecoration(startColor: Colors.white), diff --git a/example/pubspec.lock b/example/pubspec.lock index 05e98c7..ff9976f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -28,7 +28,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -63,7 +63,7 @@ packages: path: ".." relative: true source: path - version: "2.0.0-nullsafety.0" + version: "2.1.0" flutter: dependency: "direct main" description: flutter @@ -87,7 +87,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: transitive description: @@ -106,7 +106,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -141,7 +141,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.4.2" typed_data: dependency: transitive description: diff --git a/floaty_head.iml b/floaty_head.iml index 73e7ebd..ff4397e 100644 --- a/floaty_head.iml +++ b/floaty_head.iml @@ -13,7 +13,7 @@ - + \ No newline at end of file diff --git a/lib/floaty_head.dart b/lib/floaty_head.dart index 8280c4f..aa117f0 100644 --- a/lib/floaty_head.dart +++ b/lib/floaty_head.dart @@ -152,15 +152,14 @@ class FloatyHead { ///Set a custom [icon] for the chathead. Future setIcon(String assetPath) async { - final int result = - await (_platform.invokeMethod('setIcon', assetPath) as FutureOr); + final int result = await (_platform.invokeMethod('setIcon', assetPath)); return result > 0 ? "Icon set" : "There was an error."; } ///Set a custom [Title] to be displayed in the notification bar for the chathead. Future setNotificationTitle(String title) async { - final int result = await (_platform.invokeMethod( - 'setNotificationTitle', title) as FutureOr); + final int result = + await (_platform.invokeMethod('setNotificationTitle', title)); return result > 0 ? "Notification Title set" : "There was an error."; } @@ -168,22 +167,22 @@ class FloatyHead { /// Please note that in some cases, this is gonna ignore any asset given, and instead /// use the default icon launcher. Future setNotificationIcon(String assetPath) async { - final int result = await (_platform.invokeMethod( - 'setNotificationIcon', assetPath) as FutureOr); + final int result = + await (_platform.invokeMethod('setNotificationIcon', assetPath)); return result > 0 ? "NotificationIcon set" : "There was an error."; } /// Set a custom [Close Icon] to be displayed when the chathead is dragged. Future setCloseIcon(String assetPath) async { - final int result = await (_platform.invokeMethod('setCloseIcon', assetPath) - as FutureOr); + final int result = + await (_platform.invokeMethod('setCloseIcon', assetPath)); return result > 0 ? "Close Icon set" : "There was an error."; } /// Set a custom [Close Background] to be displayed behind the [Close Icon]. Future setCloseBackgroundIcon(String assetPath) async { - final int result = await (_platform.invokeMethod( - 'setBackgroundCloseIcon', assetPath) as FutureOr); + final int result = + await (_platform.invokeMethod('setBackgroundCloseIcon', assetPath)); return result > 0 ? "Close Icon Background set" : "There was an error."; } diff --git a/pubspec.lock b/pubspec.lock deleted file mode 100644 index 96b4a33..0000000 --- a/pubspec.lock +++ /dev/null @@ -1,147 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.5.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.15.0" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.10" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.2.19" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" -sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index c98477e..5debe02 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: floaty_head description: A flutter plugin to create custom chatheads with hidden content displayed on tap, like Messenger. -version: 2.0.0-nullsafety.0 +version: 2.1.0 homepage: https://github.com/Crdzbird/floaty_chathead environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" flutter: ">=1.20.0" dependencies: @@ -22,4 +22,4 @@ flutter: package: ni.devotion.floaty_head pluginClass: FloatyHeadPlugin ios: - pluginClass: FloatyHeadPlugin \ No newline at end of file + pluginClass: FloatyHeadPlugin