diff --git a/android/app/build.gradle b/android/app/build.gradle index 65bb55fe..dc377f5c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -120,7 +120,7 @@ dependencies { implementation 'com.google.android.gms:play-services-basement:17.5.0' - implementation "com.opentok.android:opentok-android-sdk:2.19.1" +// implementation "com.opentok.android:opentok-android-sdk:2.19.1" implementation 'com.facebook.stetho:stetho:1.5.1' implementation 'com.facebook.stetho:stetho-urlconnection:1.5.1' diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/MainActivity.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/MainActivity.kt index 957262c3..0e5e1117 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/MainActivity.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/MainActivity.kt @@ -18,7 +18,7 @@ class MainActivity: FlutterFragmentActivity() { WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) PlatformBridge(flutterEngine, this).create() - OpenTokPlatformBridge(flutterEngine, this).create() +// OpenTokPlatformBridge(flutterEngine, this).create() val time = timeToMillis("04:00:00", "HH:mm:ss") diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/LocalVideo.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/LocalVideo.kt index cfebfe65..960665d5 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/LocalVideo.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/LocalVideo.kt @@ -1,58 +1,58 @@ -package com.ejada.hmg.opentok - -import android.content.Context -import android.util.AttributeSet -import android.view.LayoutInflater -import android.view.View -import android.widget.FrameLayout -import android.widget.LinearLayout -import com.ejada.hmg.R -import io.flutter.plugin.common.StandardMessageCodec -import io.flutter.plugin.platform.PlatformView -import io.flutter.plugin.platform.PlatformViewFactory - -class LocalVideoFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) { - - companion object { - private lateinit var view: LocalVideoPlatformView - - fun getViewInstance(context: Context): LocalVideoPlatformView { - if(!this::view.isInitialized) { - view = LocalVideoPlatformView(context) - } - - return view - } - } - - override fun create(context: Context, viewId: Int, args: Any?): PlatformView { - return getViewInstance(context) - } -} - -class LocalVideoPlatformView(context: Context) : PlatformView { - private val videoContainer: LocalVideoContainer = LocalVideoContainer(context) - - val container get() = videoContainer.publisherContainer - - override fun getView(): View { - return videoContainer - } - - override fun dispose() {} -} - -class LocalVideoContainer @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyle: Int = 0, - defStyleRes: Int = 0 -) : LinearLayout(context, attrs, defStyle, defStyleRes) { - - var publisherContainer: FrameLayout private set - - init { - val view = LayoutInflater.from(context).inflate(R.layout.local_video, this, true) - publisherContainer = view.findViewById(R.id.publisher_container) - } -} \ No newline at end of file +//package com.ejada.hmg.opentok +// +//import android.content.Context +//import android.util.AttributeSet +//import android.view.LayoutInflater +//import android.view.View +//import android.widget.FrameLayout +//import android.widget.LinearLayout +//import com.ejada.hmg.R +//import io.flutter.plugin.common.StandardMessageCodec +//import io.flutter.plugin.platform.PlatformView +//import io.flutter.plugin.platform.PlatformViewFactory +// +//class LocalVideoFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) { +// +// companion object { +// private lateinit var view: LocalVideoPlatformView +// +// fun getViewInstance(context: Context): LocalVideoPlatformView { +// if(!this::view.isInitialized) { +// view = LocalVideoPlatformView(context) +// } +// +// return view +// } +// } +// +// override fun create(context: Context, viewId: Int, args: Any?): PlatformView { +// return getViewInstance(context) +// } +//} +// +//class LocalVideoPlatformView(context: Context) : PlatformView { +// private val videoContainer: LocalVideoContainer = LocalVideoContainer(context) +// +// val container get() = videoContainer.publisherContainer +// +// override fun getView(): View { +// return videoContainer +// } +// +// override fun dispose() {} +//} +// +//class LocalVideoContainer @JvmOverloads constructor( +// context: Context, +// attrs: AttributeSet? = null, +// defStyle: Int = 0, +// defStyleRes: Int = 0 +//) : LinearLayout(context, attrs, defStyle, defStyleRes) { +// +// var publisherContainer: FrameLayout private set +// +// init { +// val view = LayoutInflater.from(context).inflate(R.layout.local_video, this, true) +// publisherContainer = view.findViewById(R.id.publisher_container) +// } +//} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/OpenTok.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/OpenTok.kt index d53d6f9a..6d8e668a 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/OpenTok.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/OpenTok.kt @@ -1,170 +1,170 @@ -package com.ejada.hmg.opentok - -import android.content.Context -import android.os.Handler -import android.os.Looper -import android.util.Log -import android.view.ViewGroup -import com.facebook.stetho.urlconnection.StethoURLConnectionManager -import com.opentok.android.* -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel - - -enum class OpenTokSDKState { - LOGGED_OUT, - LOGGED_IN, - WAIT, - ERROR -} - -class OpenTok(private var context: Context, private var flutterEngine: FlutterEngine){ - private lateinit var remoteVideoPlatformView: RemoteVideoPlatformView - private lateinit var localVideoPlatformView: LocalVideoPlatformView - - init { - remoteVideoPlatformView = RemoteVideoFactory.getViewInstance(context) - flutterEngine - .platformViewsController - .registry - .registerViewFactory("remote-video-container", RemoteVideoFactory()) - - localVideoPlatformView = LocalVideoFactory.getViewInstance(context) - flutterEngine - .platformViewsController - .registry - .registerViewFactory("local-video-container", LocalVideoFactory()) - } - - private var session: Session? = null - private var publisher: Publisher? = null - private var subscriber: Subscriber? = null - - - - private val sessionListener: Session.SessionListener = object: Session.SessionListener { - override fun onConnected(session: Session) { - // Connected to session - Log.d("MainActivity", "Connected to session ${session.sessionId}") - - publisher = Publisher.Builder(context).build().apply { - setPublisherListener(publisherListener) - renderer?.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL) - - view.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) - localVideoPlatformView.container.addView(view) - } - - notifyFlutter(OpenTokSDKState.LOGGED_IN) - session.publish(publisher) - } - - override fun onDisconnected(session: Session) { - notifyFlutter(OpenTokSDKState.LOGGED_OUT) - } - - override fun onStreamReceived(session: Session, stream: Stream) { - Log.d( - "MainActivity", - "onStreamReceived: New Stream Received " + stream.streamId + " in session: " + session.sessionId - ) - if (subscriber == null) { - subscriber = Subscriber.Builder(context, stream).build().apply { - renderer?.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL) - setSubscriberListener(subscriberListener) - session.subscribe(this) - - remoteVideoPlatformView.container.addView(view) - } - } - } - - override fun onStreamDropped(session: Session, stream: Stream) { - Log.d( - "MainActivity", - "onStreamDropped: Stream Dropped: " + stream.streamId + " in session: " + session.sessionId - ) - - if (subscriber != null) { - subscriber = null - - remoteVideoPlatformView.container.removeAllViews() - } - } - - override fun onError(session: Session, opentokError: OpentokError) { - Log.d("MainActivity", "Session error: " + opentokError.message) - notifyFlutter(OpenTokSDKState.ERROR) - } - } - - private val publisherListener: PublisherKit.PublisherListener = object : PublisherKit.PublisherListener { - override fun onStreamCreated(publisherKit: PublisherKit, stream: Stream) { - Log.d("MainActivity", "onStreamCreated: Publisher Stream Created. Own stream " + stream.streamId) - } - - override fun onStreamDestroyed(publisherKit: PublisherKit, stream: Stream) { - Log.d("MainActivity", "onStreamDestroyed: Publisher Stream Destroyed. Own stream " + stream.streamId) - } - - override fun onError(publisherKit: PublisherKit, opentokError: OpentokError) { - Log.d("MainActivity", "PublisherKit onError: " + opentokError.message) - notifyFlutter(OpenTokSDKState.ERROR) - } - } - - var subscriberListener: SubscriberKit.SubscriberListener = object : SubscriberKit.SubscriberListener { - override fun onConnected(subscriberKit: SubscriberKit) { - Log.d("MainActivity", "onConnected: Subscriber connected. Stream: " + subscriberKit.stream.streamId) - } - - override fun onDisconnected(subscriberKit: SubscriberKit) { - Log.d("MainActivity", "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.stream.streamId) - notifyFlutter(OpenTokSDKState.LOGGED_OUT) - } - - override fun onError(subscriberKit: SubscriberKit, opentokError: OpentokError) { - Log.d("MainActivity", "SubscriberKit onError: " + opentokError.message) - notifyFlutter(OpenTokSDKState.ERROR) - } - } - - fun initSession(call: MethodCall, result: MethodChannel.Result) { - - val apiKey = requireNotNull(call.argument("apiKey")) - val sessionId = requireNotNull(call.argument("sessionId")) - val token = requireNotNull(call.argument("token")) - - notifyFlutter(OpenTokSDKState.WAIT) - session = Session.Builder(context, apiKey, sessionId).build() - session?.setSessionListener(sessionListener) - session?.connect(token) - result.success("") - } - - fun swapCamera(call: MethodCall, result: MethodChannel.Result) { - publisher?.cycleCamera() - result.success("") - } - - fun toggleAudio(call: MethodCall, result: MethodChannel.Result) { - val publishAudio = requireNotNull(call.argument("publishAudio")) - publisher?.publishAudio = publishAudio - result.success("") - } - - fun toggleVideo(call: MethodCall, result: MethodChannel.Result) { - val publishVideo = requireNotNull(call.argument("publishVideo")) - publisher?.publishVideo = publishVideo - result.success("") - } - - private fun notifyFlutter(state: OpenTokSDKState) { - Handler(Looper.getMainLooper()).post { - MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "OpenTok-Platform-Bridge") - .invokeMethod("updateState", state.toString()) - } - } -} +//package com.ejada.hmg.opentok +// +//import android.content.Context +//import android.os.Handler +//import android.os.Looper +//import android.util.Log +//import android.view.ViewGroup +//import com.facebook.stetho.urlconnection.StethoURLConnectionManager +//import com.opentok.android.* +//import io.flutter.embedding.engine.FlutterEngine +//import io.flutter.embedding.engine.plugins.util.GeneratedPluginRegister +//import io.flutter.plugin.common.MethodCall +//import io.flutter.plugin.common.MethodChannel +// +// +//enum class OpenTokSDKState { +// LOGGED_OUT, +// LOGGED_IN, +// WAIT, +// ERROR +//} +// +//class OpenTok(private var context: Context, private var flutterEngine: FlutterEngine){ +// private lateinit var remoteVideoPlatformView: RemoteVideoPlatformView +// private lateinit var localVideoPlatformView: LocalVideoPlatformView +// +// init { +// remoteVideoPlatformView = RemoteVideoFactory.getViewInstance(context) +// flutterEngine +// .platformViewsController +// .registry +// .registerViewFactory("remote-video-container", RemoteVideoFactory()) +// +// localVideoPlatformView = LocalVideoFactory.getViewInstance(context) +// flutterEngine +// .platformViewsController +// .registry +// .registerViewFactory("local-video-container", LocalVideoFactory()) +// } +// +// private var session: Session? = null +// private var publisher: Publisher? = null +// private var subscriber: Subscriber? = null +// +// +// +// private val sessionListener: Session.SessionListener = object: Session.SessionListener { +// override fun onConnected(session: Session) { +// // Connected to session +// Log.d("MainActivity", "Connected to session ${session.sessionId}") +// +// publisher = Publisher.Builder(context).build().apply { +// setPublisherListener(publisherListener) +// renderer?.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL) +// +// view.layoutParams = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) +// localVideoPlatformView.container.addView(view) +// } +// +// notifyFlutter(OpenTokSDKState.LOGGED_IN) +// session.publish(publisher) +// } +// +// override fun onDisconnected(session: Session) { +// notifyFlutter(OpenTokSDKState.LOGGED_OUT) +// } +// +// override fun onStreamReceived(session: Session, stream: Stream) { +// Log.d( +// "MainActivity", +// "onStreamReceived: New Stream Received " + stream.streamId + " in session: " + session.sessionId +// ) +// if (subscriber == null) { +// subscriber = Subscriber.Builder(context, stream).build().apply { +// renderer?.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL) +// setSubscriberListener(subscriberListener) +// session.subscribe(this) +// +// remoteVideoPlatformView.container.addView(view) +// } +// } +// } +// +// override fun onStreamDropped(session: Session, stream: Stream) { +// Log.d( +// "MainActivity", +// "onStreamDropped: Stream Dropped: " + stream.streamId + " in session: " + session.sessionId +// ) +// +// if (subscriber != null) { +// subscriber = null +// +// remoteVideoPlatformView.container.removeAllViews() +// } +// } +// +// override fun onError(session: Session, opentokError: OpentokError) { +// Log.d("MainActivity", "Session error: " + opentokError.message) +// notifyFlutter(OpenTokSDKState.ERROR) +// } +// } +// +// private val publisherListener: PublisherKit.PublisherListener = object : PublisherKit.PublisherListener { +// override fun onStreamCreated(publisherKit: PublisherKit, stream: Stream) { +// Log.d("MainActivity", "onStreamCreated: Publisher Stream Created. Own stream " + stream.streamId) +// } +// +// override fun onStreamDestroyed(publisherKit: PublisherKit, stream: Stream) { +// Log.d("MainActivity", "onStreamDestroyed: Publisher Stream Destroyed. Own stream " + stream.streamId) +// } +// +// override fun onError(publisherKit: PublisherKit, opentokError: OpentokError) { +// Log.d("MainActivity", "PublisherKit onError: " + opentokError.message) +// notifyFlutter(OpenTokSDKState.ERROR) +// } +// } +// +// var subscriberListener: SubscriberKit.SubscriberListener = object : SubscriberKit.SubscriberListener { +// override fun onConnected(subscriberKit: SubscriberKit) { +// Log.d("MainActivity", "onConnected: Subscriber connected. Stream: " + subscriberKit.stream.streamId) +// } +// +// override fun onDisconnected(subscriberKit: SubscriberKit) { +// Log.d("MainActivity", "onDisconnected: Subscriber disconnected. Stream: " + subscriberKit.stream.streamId) +// notifyFlutter(OpenTokSDKState.LOGGED_OUT) +// } +// +// override fun onError(subscriberKit: SubscriberKit, opentokError: OpentokError) { +// Log.d("MainActivity", "SubscriberKit onError: " + opentokError.message) +// notifyFlutter(OpenTokSDKState.ERROR) +// } +// } +// +// fun initSession(call: MethodCall, result: MethodChannel.Result) { +// +// val apiKey = requireNotNull(call.argument("apiKey")) +// val sessionId = requireNotNull(call.argument("sessionId")) +// val token = requireNotNull(call.argument("token")) +// +// notifyFlutter(OpenTokSDKState.WAIT) +// session = Session.Builder(context, apiKey, sessionId).build() +// session?.setSessionListener(sessionListener) +// session?.connect(token) +// result.success("") +// } +// +// fun swapCamera(call: MethodCall, result: MethodChannel.Result) { +// publisher?.cycleCamera() +// result.success("") +// } +// +// fun toggleAudio(call: MethodCall, result: MethodChannel.Result) { +// val publishAudio = requireNotNull(call.argument("publishAudio")) +// publisher?.publishAudio = publishAudio +// result.success("") +// } +// +// fun toggleVideo(call: MethodCall, result: MethodChannel.Result) { +// val publishVideo = requireNotNull(call.argument("publishVideo")) +// publisher?.publishVideo = publishVideo +// result.success("") +// } +// +// private fun notifyFlutter(state: OpenTokSDKState) { +// Handler(Looper.getMainLooper()).post { +// MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "OpenTok-Platform-Bridge") +// .invokeMethod("updateState", state.toString()) +// } +// } +//} diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/RemoteVideo.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/RemoteVideo.kt index 9116a1e8..8c822839 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/RemoteVideo.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/opentok/RemoteVideo.kt @@ -1,58 +1,58 @@ -package com.ejada.hmg.opentok - -import android.content.Context -import android.util.AttributeSet -import android.view.LayoutInflater -import android.view.View -import android.widget.FrameLayout -import android.widget.LinearLayout -import com.ejada.hmg.R -import io.flutter.plugin.common.StandardMessageCodec -import io.flutter.plugin.platform.PlatformView -import io.flutter.plugin.platform.PlatformViewFactory - -class RemoteVideoFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) { - - companion object { - private lateinit var view: RemoteVideoPlatformView - - fun getViewInstance(context: Context): RemoteVideoPlatformView { - if(!this::view.isInitialized) { - view = RemoteVideoPlatformView(context) - } - - return view - } - } - - override fun create(context: Context, viewId: Int, args: Any?): PlatformView { - return getViewInstance(context) - } -} - -class RemoteVideoPlatformView(context: Context) : PlatformView { - private val videoContainer: RemoteVideoContainer = RemoteVideoContainer(context) - - val container get() = videoContainer.subscriberContainer - - override fun getView(): View { - return videoContainer - } - - override fun dispose() {} -} - -class RemoteVideoContainer @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyle: Int = 0, - defStyleRes: Int = 0 -) : LinearLayout(context, attrs, defStyle, defStyleRes) { - - var subscriberContainer: FrameLayout private set - - init { - val view = LayoutInflater.from(context).inflate(R.layout.remote_video, this, true) - subscriberContainer = view.findViewById(R.id.subscriber_container) - } -} \ No newline at end of file +//package com.ejada.hmg.opentok +// +//import android.content.Context +//import android.util.AttributeSet +//import android.view.LayoutInflater +//import android.view.View +//import android.widget.FrameLayout +//import android.widget.LinearLayout +//import com.ejada.hmg.R +//import io.flutter.plugin.common.StandardMessageCodec +//import io.flutter.plugin.platform.PlatformView +//import io.flutter.plugin.platform.PlatformViewFactory +// +//class RemoteVideoFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) { +// +// companion object { +// private lateinit var view: RemoteVideoPlatformView +// +// fun getViewInstance(context: Context): RemoteVideoPlatformView { +// if(!this::view.isInitialized) { +// view = RemoteVideoPlatformView(context) +// } +// +// return view +// } +// } +// +// override fun create(context: Context, viewId: Int, args: Any?): PlatformView { +// return getViewInstance(context) +// } +//} +// +//class RemoteVideoPlatformView(context: Context) : PlatformView { +// private val videoContainer: RemoteVideoContainer = RemoteVideoContainer(context) +// +// val container get() = videoContainer.subscriberContainer +// +// override fun getView(): View { +// return videoContainer +// } +// +// override fun dispose() {} +//} +// +//class RemoteVideoContainer @JvmOverloads constructor( +// context: Context, +// attrs: AttributeSet? = null, +// defStyle: Int = 0, +// defStyleRes: Int = 0 +//) : LinearLayout(context, attrs, defStyle, defStyleRes) { +// +// var subscriberContainer: FrameLayout private set +// +// init { +// val view = LayoutInflater.from(context).inflate(R.layout.remote_video, this, true) +// subscriberContainer = view.findViewById(R.id.subscriber_container) +// } +//} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/utils/OpenTokPlatformBridge.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/utils/OpenTokPlatformBridge.kt index 6ac62546..33d9ff0a 100644 --- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/utils/OpenTokPlatformBridge.kt +++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/utils/OpenTokPlatformBridge.kt @@ -1,42 +1,42 @@ -package com.ejada.hmg.utils - -import com.ejada.hmg.MainActivity -import com.ejada.hmg.opentok.OpenTok -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel - -class OpenTokPlatformBridge(private var flutterEngine: FlutterEngine, private var mainActivity: MainActivity) { - - private lateinit var channel: MethodChannel - private lateinit var openTok: OpenTok - - companion object { - private const val CHANNEL = "OpenTok-Platform-Bridge" - } - - fun create(){ - openTok = OpenTok(mainActivity, flutterEngine) - channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL) - channel.setMethodCallHandler { call: MethodCall, result: MethodChannel.Result -> - when (call.method) { - "initSession" -> { - openTok.initSession(call, result) - } - "swapCamera" -> { - openTok.swapCamera(call, result) - } - "toggleAudio" -> { - openTok.toggleAudio(call, result) - } - "toggleVideo" -> { - openTok.toggleVideo(call, result) - } - else -> { - result.notImplemented() - } - } - } - } - -} +//package com.ejada.hmg.utils +// +//import com.ejada.hmg.MainActivity +//import com.ejada.hmg.opentok.OpenTok +//import io.flutter.embedding.engine.FlutterEngine +//import io.flutter.plugin.common.MethodCall +//import io.flutter.plugin.common.MethodChannel +// +//class OpenTokPlatformBridge(private var flutterEngine: FlutterEngine, private var mainActivity: MainActivity) { +// +// private lateinit var channel: MethodChannel +// private lateinit var openTok: OpenTok +// +// companion object { +// private const val CHANNEL = "OpenTok-Platform-Bridge" +// } +// +// fun create(){ +// openTok = OpenTok(mainActivity, flutterEngine) +// channel = MethodChannel(flutterEngine.dartExecutor.binaryMessenger, CHANNEL) +// channel.setMethodCallHandler { call: MethodCall, result: MethodChannel.Result -> +// when (call.method) { +// "initSession" -> { +// openTok.initSession(call, result) +// } +// "swapCamera" -> { +// openTok.swapCamera(call, result) +// } +// "toggleAudio" -> { +// openTok.toggleAudio(call, result) +// } +// "toggleVideo" -> { +// openTok.toggleVideo(call, result) +// } +// else -> { +// result.notImplemented() +// } +// } +// } +// } +// +//} diff --git a/android/build.gradle b/android/build.gradle index e4985a55..b514b78d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -44,3 +44,9 @@ subprojects { task clean(type: Delete) { delete rootProject.buildDir } + +configurations.all { + resolutionStrategy { + force 'androidx.core:core-ktx:1.6.0' + } +} diff --git a/ios/Podfile b/ios/Podfile index 1e8c3c90..10f3c9b4 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +platform :ios, '13.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements index be2e0283..38553e31 100644 --- a/ios/Runner/Runner.entitlements +++ b/ios/Runner/Runner.entitlements @@ -2,13 +2,20 @@ - - aps-environment development + com.apple.developer.healthkit + + com.apple.developer.healthkit.access + com.apple.developer.networking.HotspotConfiguration com.apple.developer.networking.wifi-info + com.apple.developer.nfc.readersession.formats + + NDEF + TAG + diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 49c8d0d6..984f64bf 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -1,4 +1,3 @@ -import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/appointment_rate_view_model.dart'; @@ -8,7 +7,6 @@ import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; -import 'package:diplomaticquarterapp/models/Authentication/checkpatient_for_registration.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/login/confirm-login.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart'; @@ -315,7 +313,7 @@ class _Login extends State { projectViewModel.setPrivilege(privilegeList: result); result = CheckActivationCode.fromJson(result); result.list.isFamily = false; - this.sharedPref.setString(BLOOD_TYPE, result.patientBloodType); + this.sharedPref.setString(BLOOD_TYPE, result.patientBloodType != null ? result.patientBloodType : ""); this.sharedPref.setObject(USER_PROFILE, result.list); this.sharedPref.setObject(MAIN_USER, result.list); this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID); diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 3d759ce6..dc3a5813 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -468,12 +468,12 @@ class AuthProvider with ChangeNotifier { Future getDashboard() async { Map request = {}; - request['VersionID'] = VERSION_ID; - request['Channel'] = CHANNEL; - request['IPAdress'] = IP_ADDRESS; - request['generalid'] = GENERAL_ID; - request['LanguageID'] = LANGUAGE_ID; - request['DeviceTypeID'] = DeviceTypeID; + // request['VersionID'] = VERSION_ID; + // request['Channel'] = CHANNEL; + // request['IPAdress'] = IP_ADDRESS; + // request['generalid'] = GENERAL_ID; + // request['LanguageID'] = LANGUAGE_ID; + // request['DeviceTypeID'] = DeviceTypeID; dynamic localRes; try { diff --git a/lib/services/family_files/family_files_provider.dart b/lib/services/family_files/family_files_provider.dart index cc151c7b..2ca4ee8a 100644 --- a/lib/services/family_files/family_files_provider.dart +++ b/lib/services/family_files/family_files_provider.dart @@ -40,11 +40,9 @@ class FamilyFilesProvider with ChangeNotifier { dynamic localRes; try { var request = GetAllSharedRecordsByStatusReq(); - var result = await sharedPref.getObject(MAIN_USER); - request.status = 0; - - request.patientID = result["PatientID"]; - + // var result = await sharedPref.getObject(MAIN_USER); + // request.status = 0; + // request.patientID = result["PatientID"]; await new BaseAppClient().post(GET_SHARED_RECORD_BY_STATUS, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { diff --git a/lib/uitl/app_shared_preferences.dart b/lib/uitl/app_shared_preferences.dart index f90a2f98..517bfee7 100644 --- a/lib/uitl/app_shared_preferences.dart +++ b/lib/uitl/app_shared_preferences.dart @@ -7,49 +7,63 @@ class AppSharedPreferences { /// Save String [key] the key for save value [value] the value we need to save it setString(String key, String value) async { - final SharedPreferences prefs = await _prefs; - return prefs.setString(key, value); + if (value != null) { + final SharedPreferences prefs = await _prefs; + return prefs.setString(key, value); + } } /// Save List of String [key] the key for save value [value] the value we need to save it setStringList(String key, List value) async { - final SharedPreferences prefs = await _prefs; - return prefs.setStringList(key, value); + if (value != null) { + final SharedPreferences prefs = await _prefs; + return prefs.setStringList(key, value); + } } /// Save Double [key] the key for save value [value] the value we need to save it setDouble(String key, double value) async { - final SharedPreferences prefs = await _prefs; - return prefs.setDouble(key, value); + if (value != null) { + final SharedPreferences prefs = await _prefs; + return prefs.setDouble(key, value); + } } /// Save Bool [key] the key for save value [value] the value we need to save it setBool(String key, bool value) async { - final SharedPreferences prefs = await _prefs; - return prefs.setBool(key, value); + if (value != null) { + final SharedPreferences prefs = await _prefs; + return prefs.setBool(key, value); + } } /// Save int [key] the key for save value [value] the value we need to save it setInt(String key, int value) async { - final SharedPreferences prefs = await _prefs; - return prefs.setInt(key, value); + if (value != null) { + final SharedPreferences prefs = await _prefs; + return prefs.setInt(key, value); + } } /// save Object [key] the key for save value [value] the value we need to save it setObject(String key, value) async { - final SharedPreferences prefs = await _prefs; - return prefs.setString(key, json.encode(value)); + if (value != null) { + final SharedPreferences prefs = await _prefs; + return await prefs.setString(key, json.encode(value)); + } } /// Get String [key] the key was saved getString(String key) async { final SharedPreferences prefs = await _prefs; + await prefs.reload(); return prefs.getString(key); } /// Get String [key] the key was saved getStringWithDefaultValue(String key, String defaultVal) async { final SharedPreferences prefs = await _prefs; + await prefs.reload(); String value = prefs.getString(key); return value == null ? defaultVal : value; } @@ -57,35 +71,45 @@ class AppSharedPreferences { /// Get List of String [key] the key was saved getStringList(String key) async { final SharedPreferences prefs = await _prefs; + await prefs.reload(); return prefs.getStringList(key); } /// Get Double [key] the key was saved getDouble(String key) async { final SharedPreferences prefs = await _prefs; + await prefs.reload(); return prefs.getDouble(key); } /// Get Bool [key] the key was saved getBool(String key) async { final SharedPreferences prefs = await _prefs; + await prefs.reload(); return prefs.getBool(key); } /// Get Int [key] the key was saved getInt(String key) async { final SharedPreferences prefs = await _prefs; + await prefs.reload(); return prefs.getInt(key); } /// Get Object [key] the key was saved Future getObject(String key) async { - final SharedPreferences prefs = await _prefs; - var string = prefs.getString(key); - if (string == null) { - return null; + try { + final SharedPreferences prefs = await _prefs; + await prefs.reload(); + var string = prefs.getString(key); + if (string == null) { + return null; + } + return json.decode(string); + } catch (ex) { + print(ex); + print(ex.toString()); } - return json.decode(string); } /// clear all saved values in shared preferences diff --git a/pubspec.yaml b/pubspec.yaml index a7996dc8..2a581ac5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -52,7 +52,7 @@ dependencies: localstorage: ^4.0.0+1 maps_launcher: ^2.0.1 url_launcher: ^6.0.15 - shared_preferences: ^2.0.9 + shared_preferences: ^2.0.0 # flutter_flexible_toast: ^0.1.4 fluttertoast: ^8.0.8 firebase_messaging: ^11.1.0 @@ -198,6 +198,7 @@ dependency_overrides: provider : ^5.0.0 permission_handler : ^6.0.1+1 + dev_dependencies: flutter_test: sdk: flutter