diff --git a/android/CustomFlutterFirebaseMessagingService.java b/android/CustomFlutterFirebaseMessagingService.java
index 0a4d83be..113f256f 100644
--- a/android/CustomFlutterFirebaseMessagingService.java
+++ b/android/CustomFlutterFirebaseMessagingService.java
@@ -2,14 +2,33 @@ package io.flutter.plugins.firebasemessaging;
import android.content.Intent;
+import java.util.concurrent.TimeUnit;
+
import com.google.firebase.messaging.RemoteMessage;
+//public class CustomFlutterFirebaseMessagingService extends FlutterFirebaseMessagingService {
+// @Override
+// public void onMessageReceived(RemoteMessage remoteMessage) {
+// if (remoteMessage.getData().containsKey("is_call")) {
+// Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
+// startActivity(intent);
+// super.onMessageReceived(remoteMessage);
+// } else
+// super.onMessageReceived(remoteMessage);
+// }
+//}
+
public class CustomFlutterFirebaseMessagingService extends FlutterFirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if (remoteMessage.getData().containsKey("is_call")) {
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
+ intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
+ try {
+ TimeUnit.SECONDS.sleep(5);
+ } catch (Exception e) {
+ }
super.onMessageReceived(remoteMessage);
} else
super.onMessageReceived(remoteMessage);
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 61472941..4d2c9f8a 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -13,6 +13,7 @@
+
@@ -29,7 +30,7 @@
-
+
@@ -41,6 +42,8 @@
android:name=".Application"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
+ android:showOnLockScreen="true"
+ android:screenOrientation="sensorPortrait"
android:label="Dr. Alhabib">
if (methodCall.method == HMG_INTERNET_WIFI_CONNECT_METHOD) {
- connectHMGInternetWifi(methodCall,result)
-
- }else if (methodCall.method == HMG_GUEST_WIFI_CONNECT_METHOD) {
- connectHMGGuestWifi(methodCall,result)
-
- }else if (methodCall.method == ENABLE_WIFI_IF_NOT) {
- enableWifiIfNot(methodCall,result)
- }else if (methodCall.method == REGISTER_HMG_GEOFENCES) {
- registerHmgGeofences(methodCall,result)
- }else if (methodCall.method == UN_REGISTER_HMG_GEOFENCES) {
- unRegisterHmgGeofences(methodCall,result)
- }else{
-
+ connectHMGInternetWifi(methodCall, result)
+
+ } else if (methodCall.method == HMG_GUEST_WIFI_CONNECT_METHOD) {
+ connectHMGGuestWifi(methodCall, result)
+
+ } else if (methodCall.method == ENABLE_WIFI_IF_NOT) {
+ enableWifiIfNot(methodCall, result)
+ } else if (methodCall.method == REGISTER_HMG_GEOFENCES) {
+ registerHmgGeofences(methodCall, result)
+ } else if (methodCall.method == UN_REGISTER_HMG_GEOFENCES) {
+ unRegisterHmgGeofences(methodCall, result)
+ } else if (methodCall.method == IS_DRAW_OVER_APPS_PERMISSION_ALLOWED) {
+ isDrawOverAppsPermissionAllowed(methodCall, result)
+ } else if (methodCall.method == ASK_DRAW_OVER_APPS_PERMISSION) {
+ askDrawOverAppsPermission(methodCall, result)
+ } else if (methodCall.method == GET_INTENT) {
+ getIntentData(methodCall, result)
+ } else {
result.notImplemented()
}
}
- val res = channel.invokeMethod("localizedValue","errorConnectingHmgNetwork")
+ val res = channel.invokeMethod("localizedValue", "errorConnectingHmgNetwork")
}
- private fun connectHMGInternetWifi(methodCall: MethodCall, result: MethodChannel.Result){
+ private fun connectHMGInternetWifi(methodCall: MethodCall, result: MethodChannel.Result) {
(methodCall.arguments as ArrayList<*>).let {
- require(it.size > 0 && (it[0] is String),lazyMessage = {
+ require(it.size > 0 && (it[0] is String), lazyMessage = {
"Missing or invalid arguments (Must have one argument 'String at 0'"
})
val patientId = it[0].toString()
HMG_Internet(mainActivity)
- .connectToHMGGuestNetwork(patientId){ status, message ->
+ .connectToHMGGuestNetwork(patientId) { status, message ->
mainActivity.runOnUiThread {
- result.success(if(status) 1 else 0)
+ result.success(if (status) 1 else 0)
HMGUtils.popFlutterText(mainActivity, message)
Log.v(this.javaClass.simpleName, "$status | $message")
@@ -76,10 +92,10 @@ class PlatformBridge(private var flutterEngine: FlutterEngine, private var mainA
}
- private fun connectHMGGuestWifi(methodCall: MethodCall, result: MethodChannel.Result){
+ private fun connectHMGGuestWifi(methodCall: MethodCall, result: MethodChannel.Result) {
HMG_Guest(mainActivity).connectToHMGGuestNetwork { status, message ->
mainActivity.runOnUiThread {
- result.success(if(status) 1 else 0)
+ result.success(if (status) 1 else 0)
HMGUtils.popFlutterText(mainActivity, message)
Log.v(this.javaClass.simpleName, "$status | $message")
@@ -89,38 +105,76 @@ class PlatformBridge(private var flutterEngine: FlutterEngine, private var mainA
private fun enableWifiIfNot(methodCall: MethodCall, result: MethodChannel.Result) {
val wm = mainActivity.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager?
- if (wm != null){
+ if (wm != null) {
if (!wm.isWifiEnabled)
wm.isWifiEnabled = true
result.success(true)
- }else
- result.error("101","Error while opening wifi, Please try to open wifi yourself and try again","'WifiManager' service failed");
+ } else
+ result.error("101", "Error while opening wifi, Please try to open wifi yourself and try again", "'WifiManager' service failed");
}
private fun registerHmgGeofences(methodCall: MethodCall, result: MethodChannel.Result) {
- channel.invokeMethod("getGeoZones",null, object : MethodChannel.Result{
+ channel.invokeMethod("getGeoZones", null, object : MethodChannel.Result {
override fun success(result: Any?) {
- if(result is String) {
+ if (result is String) {
val geoZones = GeoZoneModel().listFrom(result)
- HMG_Geofence.shared(mainActivity).register(){ s, e -> }
+ HMG_Geofence.shared(mainActivity).register() { s, e -> }
}
}
- override fun error(errorCode: String?, errorMessage: String?, errorDetails: Any?) { }
- override fun notImplemented() { }
+ override fun error(errorCode: String?, errorMessage: String?, errorDetails: Any?) {}
+ override fun notImplemented() {}
})
}
-
+
private fun unRegisterHmgGeofences(methodCall: MethodCall, result: MethodChannel.Result) {
HMG_Geofence.shared(mainActivity).unRegisterAll { status, exception ->
- if(status)
+ if (status)
result.success(true)
else
result.error("101", exception?.localizedMessage, exception);
}
}
-
+
+ private fun isDrawOverAppsPermissionAllowed(methodCall: MethodCall, result: MethodChannel.Result) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (
+ Settings.canDrawOverlays(mainActivity)
+ ) {
+ result.success(true)
+ } else {
+ result.success(false)
+ }
+ } else {
+ result.success(false)
+ }
+ }
+
+ private fun askDrawOverAppsPermission(methodCall: MethodCall, result: MethodChannel.Result) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION)
+ val uri = Uri.parse("package:" + mainActivity.getPackageName())
+ intent.setData(uri)
+ startActivityForResult(mainActivity, intent, 102, null)
+ result.success(true)
+ } else {
+ result.success(false)
+ }
+ }
+
+ private fun getIntentData(methodCall: MethodCall, result: MethodChannel.Result) {
+
+ val bundle: Bundle? = getIntent("").extras
+ if (bundle != null) {
+ val message = bundle.getString("notification") // 1
+ System.out.println("BundleExtra:" + message)
+ Toast.makeText(this.mainActivity, message + "", Toast.LENGTH_SHORT).show()
+ } else {
+ Toast.makeText(this.mainActivity, "Bundle Null", Toast.LENGTH_SHORT).show();
+ }
+ result.success(true);
+ }
}
diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart
index bdf387d6..7377bcc2 100644
--- a/lib/pages/BookAppointment/BookConfirm.dart
+++ b/lib/pages/BookAppointment/BookConfirm.dart
@@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
+import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
@@ -21,6 +22,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
+import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'book_reminder_page.dart';
@@ -240,6 +242,44 @@ class _BookConfirmState extends State {
);
}
+ Future askVideoCallPermission() async {
+ if (!(await Permission.camera.request().isGranted) || !(await Permission.microphone.request().isGranted)) {
+ return false;
+ }
+ if (!(await PlatformBridge.shared().isDrawOverAppsPermissionAllowed())) {
+ await drawOverAppsMessageDialog(context);
+ return false;
+ }
+ return true;
+ }
+
+ Future drawOverAppsMessageDialog(BuildContext context) async {
+ await showDialog(
+ context: context,
+ builder: (BuildContext context) {
+ return AlertDialog(
+ content: Text("Please select 'Diplomatic Quarter' from the list and allow draw over app permission to use live care."),
+ contentPadding: EdgeInsets.fromLTRB(24.0, 20.0, 24.0, 0.0),
+ actions: [
+ FlatButton(
+ child: Text("Cancel"),
+ onPressed: () {
+ Navigator.pop(context);
+ },
+ ),
+ FlatButton(
+ child: Text("Go to Settings"),
+ onPressed: () async {
+ await PlatformBridge.shared().askDrawOverAppsPermission();
+ Navigator.pop(context);
+ },
+ )
+ ],
+ );
+ },
+ );
+ }
+
cancelAppointment(DoctorList docObject, AppoitmentAllHistoryResultList appo, BuildContext context) {
ConfirmDialog.closeAlertDialog(context);
GifLoaderDialogUtils.showMyDialog(context);
diff --git a/lib/pages/conference/conference_page.dart b/lib/pages/conference/conference_page.dart
index dc00bf6e..c30e7cdf 100644
--- a/lib/pages/conference/conference_page.dart
+++ b/lib/pages/conference/conference_page.dart
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:diplomaticquarterapp/models/LiveCare/room_model.dart';
import 'package:diplomaticquarterapp/pages/conference/conference_button_bar.dart';
import 'package:diplomaticquarterapp/pages/conference/conference_room.dart';
+import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
import 'package:diplomaticquarterapp/pages/conference/draggable_publisher.dart';
import 'package:diplomaticquarterapp/pages/conference/participant_widget.dart';
import 'package:diplomaticquarterapp/pages/conference/widgets/noise_box.dart';
@@ -152,6 +153,7 @@ class _ConferencePageState extends State {
Future _onHangup() async {
print('onHangup');
await _conferenceRoom.disconnect();
+ LandingPage.isOpenCallPage = false;
Navigator.of(context).pop();
}
diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart
index 2bca7a9e..db41840d 100644
--- a/lib/pages/landing/landing_page.dart
+++ b/lib/pages/landing/landing_page.dart
@@ -204,10 +204,15 @@ class _LandingPageState extends State with WidgetsBindingObserver {
AppGlobal.context = context;
if (state == AppLifecycleState.resumed) {
if (LandingPage.isOpenCallPage) {
+ if (Platform.isAndroid) {
+ return;
+ }
if (!isPageNavigated) {
isPageNavigated = true;
Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) {
- isPageNavigated = false;
+ Future.delayed(Duration(seconds: 5), () {
+ isPageNavigated = false;
+ });
});
}
}
@@ -329,12 +334,17 @@ class _LandingPageState extends State with WidgetsBindingObserver {
Map myMap = new Map.from(message['data']);
print(myMap);
+ if (LandingPage.isOpenCallPage) {
+ return;
+ }
LandingPage.isOpenCallPage = true;
LandingPage.incomingCallData = IncomingCallData.fromJson(myMap);
if (!isPageNavigated) {
isPageNavigated = true;
Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) {
- isPageNavigated = false;
+ Future.delayed(Duration(seconds: 5), () {
+ isPageNavigated = false;
+ });
});
}
} else {
diff --git a/lib/pages/livecare/incoming_call.dart b/lib/pages/livecare/incoming_call.dart
index a463fc00..7e586942 100644
--- a/lib/pages/livecare/incoming_call.dart
+++ b/lib/pages/livecare/incoming_call.dart
@@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/models/LiveCare/room_model.dart';
import 'package:diplomaticquarterapp/pages/conference/conference_page.dart';
import 'package:diplomaticquarterapp/pages/conference/web_rtc/call_home_page.dart';
import 'package:diplomaticquarterapp/pages/conference/widgets/platform_exception_alert_dialog.dart';
+import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:just_audio/just_audio.dart';
@@ -135,6 +136,7 @@ class _IncomingCallState extends State with SingleTickerProviderSt
Container(
child: RawMaterialButton(
onPressed: () {
+ LandingPage.isOpenCallPage = false;
backToHome();
},
elevation: 2.0,
diff --git a/lib/uitl/PlatformBridge.dart b/lib/uitl/PlatformBridge.dart
index 56020781..45970e5e 100644
--- a/lib/uitl/PlatformBridge.dart
+++ b/lib/uitl/PlatformBridge.dart
@@ -1,4 +1,3 @@
-
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/localized_values.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
@@ -89,6 +88,9 @@ class PlatformBridge {
static const show_loading_method = "loading";
static const register_Hmg_Geofences = "registerHmgGeofences";
static const un_register_Hmg_Geofences = "unRegisterHmgGeofences";
+ static const IS_DRAW_OVER_APPS_PERMISSION_ALLOWED = "isDrawOverAppsPermissionAllowed";
+ static const ASK_DRAW_OVER_APPS_PERMISSION = "askDrawOverAppsPermission";
+ static const GET_INTENT = "getIntent";
Future