Merge branch 'hmg_internet_fix' into ZohaibIqbalKambrani

* hmg_internet_fix:
  Wifi internet
  no message
geofencing_wifi
Zohaib Kambrani 5 years ago
commit 96afe340e7

@ -25,9 +25,7 @@ class HMG_Guest(context: MainActivity) {
private lateinit var completionListener: ((status: Boolean, message: String) -> Unit)
fun completionOnUiThread(status: Boolean, message: String){
context.runOnUiThread {
completionListener(status, message)
}
completionListener(status, message)
}
/*
@ -87,9 +85,8 @@ class HMG_Guest(context: MainActivity) {
if(result){
HMGUtils.timer(8000,false){
if(wm.getConnectionInfo().getSSID() == SSID){
FlutterText.with("successConnectingHmgNetwork"){ localized ->
completionOnUiThread(true, localized)
}
completionOnUiThread(true, "successConnectingHmgNetwork")
}else{
errorConnecting()
}
@ -108,9 +105,7 @@ class HMG_Guest(context: MainActivity) {
}
private fun errorConnecting(){
FlutterText.with("errorConnectingHmgNetwork"){ localized ->
completionOnUiThread(false, localized)
}
completionOnUiThread(false, "errorConnectingHmgNetwork")
}
// If CompileSDK is greater and equals to APILevel 29

@ -25,9 +25,13 @@ class HMG_Internet(flutterMainActivity: MainActivity) {
private var PASSWORD = ""
fun completionOnUiThread(status: Boolean, message: String){
context.runOnUiThread {
completionListener(status, message)
}
completionListener(status, message)
// context.runOnUiThread {
//
// FlutterText.with(message){localized ->
// completionListener(status, localized)
// }
// }
}
/*
@ -92,18 +96,14 @@ class HMG_Internet(flutterMainActivity: MainActivity) {
PASSWORD = object_.getString("Password")
success()
}else{
FlutterText.with("somethingWentWrong"){localized ->
completionOnUiThread(false, localized)
}
completionOnUiThread(false, "somethingWentWrong")
}
}
}
}
},failure = { error ->
FlutterText.with("somethingWentWrong"){localized ->
completionOnUiThread(false, error.localizedMessage )
}
completionOnUiThread(false, "somethingWentWrong" )
})
}
}

@ -8,7 +8,6 @@ import android.net.wifi.SupplicantState.ASSOCIATED
import android.net.wifi.SupplicantState.COMPLETED
import android.util.Log
import com.cloud.diplomaticquarterapp.MainActivity
import com.cloud.diplomaticquarterapp.utils.FlutterText
import com.cloud.diplomaticquarterapp.utils.HMGUtils
class WPA(mainActivity: MainActivity, SSID:String) {
@ -24,9 +23,7 @@ class WPA(mainActivity: MainActivity, SSID:String) {
fun connect(identity:String, password:String, completion: (status: Boolean, message: String) -> Unit) {
if(wifiManager_ == null || connectivityManager_ == null){
FlutterText.with("errorConnectingHmgNetwork"){ localized ->
completion(false,localized)
}
completion(false,"errorConnectingHmgNetwork")
return
}
@ -74,21 +71,15 @@ class WPA(mainActivity: MainActivity, SSID:String) {
val successStates = listOf(COMPLETED, ASSOCIATED)
if (successStates.contains(COMPLETED /*supState*/))
FlutterText.with("Connected to internet Wifi"){ localized ->
completion(true,localized)
}
completion(true,"Connected to internet Wifi")
else
FlutterText.with("errorConnectingHmgNetwork"){ localized ->
completion(false,localized)
}
completion(false,"errorConnectingHmgNetwork")
}
} else {
Log.v(TAG, "WifiWizard: cannot connect to network")
FlutterText.with("errorConnectingHmgNetwork"){ localized ->
completion(false,localized)
}
completion(false,"errorConnectingHmgNetwork")
}
}

@ -33,12 +33,16 @@ class HMGUtils {
}
fun popMessage(context:MainActivity, message:String){
Toast.makeText(context,message,Toast.LENGTH_LONG).show()
context.runOnUiThread {
Toast.makeText(context,message,Toast.LENGTH_LONG).show()
}
}
fun popFlutterText(context:MainActivity, key:String){
FlutterText.with(key){
Toast.makeText(context,it,Toast.LENGTH_LONG).show()
context.runOnUiThread {
FlutterText.with(key){
Toast.makeText(context,it,Toast.LENGTH_LONG).show()
}
}
}

@ -3,6 +3,8 @@ package com.cloud.diplomaticquarterapp.utils
import android.content.Context
import android.net.wifi.WifiManager
import android.util.Log
import android.widget.Toast
import androidx.annotation.UiThread
import com.cloud.diplomaticquarterapp.MainActivity
import com.cloud.diplomaticquarterapp.hmgwifi.HMG_Guest
import com.cloud.diplomaticquarterapp.hmgwifi.HMG_Internet
@ -57,30 +59,27 @@ class PlatformBridge(binaryMessenger: BinaryMessenger, flutterMainActivity: Main
val patientId = it[0].toString()
HMG_Internet(mainActivity)
.connectToHMGGuestNetwork(patientId){ status, message ->
result.success(if(status) 1 else 0)
if(status){
HMGUtils.popMessage(mainActivity, message)
}else{
HMGUtils.popMessage(mainActivity,message)
mainActivity.runOnUiThread {
result.success(if(status) 1 else 0)
HMGUtils.popFlutterText(mainActivity, message)
Log.v(this.javaClass.simpleName, "$status | $message")
}
Log.v(this.javaClass.simpleName, "$status | $message")
}
}
}
private fun connectHMGGuestWifi(methodCall: MethodCall, result: MethodChannel.Result){
private fun connectHMGGuestWifi(methodCall: MethodCall, result: MethodChannel.Result){
HMG_Guest(mainActivity).connectToHMGGuestNetwork { status, message ->
result.success(if(status) 1 else 0)
mainActivity.runOnUiThread {
result.success(if(status) 1 else 0)
if(status){
HMGUtils.popMessage(mainActivity, message)
}else{
HMGUtils.popMessage(mainActivity,message)
HMGUtils.popFlutterText(mainActivity, message)
Log.v(this.javaClass.simpleName, "$status | $message")
}
Log.v(this.javaClass.simpleName, "$status | $message")
}
}

@ -5,7 +5,7 @@ description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.6.0 <3.0.0"
sdk: ">=2.9.0 <3.0.0"
dependencies:
flutter:

Loading…
Cancel
Save