diff --git a/Mohem/config.xml b/Mohem/config.xml index ec6bcc6d..587ec14b 100644 --- a/Mohem/config.xml +++ b/Mohem/config.xml @@ -127,7 +127,6 @@ - diff --git a/Mohem/install-plugins.bat b/Mohem/install-plugins.bat index c30636f6..b16635ec 100644 --- a/Mohem/install-plugins.bat +++ b/Mohem/install-plugins.bat @@ -78,10 +78,6 @@ call npm install @ionic-native/globalization call ionic cordova plugin add cordova-plugin-android-permissions call npm install @ionic-native/android-permissions -@echo sms reader https://www.npmjs.com/package/cordova-plugin-sms-receive -call npm i cordova-plugin-sms-receive -call cordova plugin add cordova-plugin-sms-receive - @echo device information call ionic cordova plugin add cordova-plugin-device call npm install @ionic-native/device @@ -90,10 +86,6 @@ call npm install @ionic-native/device call ionic cordova plugin add cordova-plugin-local-notification call npm install @ionic-native/local-notifications -@echo call phone number -call ionic cordova plugin add call-number -call npm install @ionic-native/call-number - @echo badge call ionic cordova plugin add cordova-plugin-badge call npm install @ionic-native/badge diff --git a/Mohem/install-plugins.sh b/Mohem/install-plugins.sh index 72dc540f..8b6a1e8c 100644 --- a/Mohem/install-plugins.sh +++ b/Mohem/install-plugins.sh @@ -81,10 +81,6 @@ echo android permissions plugin ionic cordova plugin add cordova-plugin-android-permissions npm install @ionic-native/android-permissions -echo sms reader https://www.npmjs.com/package/cordova-plugin-sms-receive - npm i cordova-plugin-sms-receive - cordova plugin add cordova-plugin-sms-receive - echo device information§ ionic cordova plugin add cordova-plugin-device npm install @ionic-native/device @@ -93,10 +89,6 @@ echo local notifications ionic cordova plugin add cordova-plugin-local-notification npm install @ionic-native/local-notifications -echo call phone number - ionic cordova plugin add call-number - npm install @ionic-native/call-number - echo badge ionic cordova plugin add cordova-plugin-badge npm install @ionic-native/badge diff --git a/Mohem/package.json b/Mohem/package.json index 9b2304f5..5fc0f5ed 100644 --- a/Mohem/package.json +++ b/Mohem/package.json @@ -29,7 +29,6 @@ "@ionic-native/barcode-scanner": "^5.18.0", "@ionic-native/base64": "^5.18.0", "@ionic-native/ble": "^5.18.0", - "@ionic-native/call-number": "^5.18.0", "@ionic-native/camera": "^5.18.0", "@ionic-native/core": "^5.8.0", "@ionic-native/date-picker": "^5.10.0", @@ -53,13 +52,13 @@ "@ionic-native/sqlite": "^5.18.0", "@ionic-native/status-bar": "^5.0.0", "@ionic-native/themeable-browser": "^5.18.0", + "@ionic-native/wifi-wizard-2": "^5.31.1", "@ionic-native/zbar": "^5.10.0", "@ionic/angular": "^4.1.0", "@ng-bootstrap/ng-bootstrap": "^4.2.2", "@swimlane/ngx-charts": "^10.1.0", "angular-calendar": "^0.26.11", "app": "0.1.0", - "call-number": "~0.0.2", "chart.js": "^2.9.3", "com-badrit-base64": "^0.2.0", "cordova-android": "^8.1.0", @@ -96,11 +95,13 @@ "cordova-plugin-statusbar": "^2.4.3", "cordova-plugin-themeablebrowser": "^0.2.18", "cordova-plugin-whitelist": "^1.3.4", + "cordova-plugin-wifiwizard2": "^3.1.1", "cordova-sqlite-storage": "^3.4.0", "cordova-support-google-services": "^1.3.2", "cordova.plugins.diagnostic": "^5.0.1", "core-js": "^2.5.4", "date-fns": "^1.30.1", + "es6-promise-plugin": "^4.1.0", "ionic2-calendar": "^0.5.8", "mx.ferreyra.callnumber": "0.0.2", "ng-circle-progress": "^1.5.1", @@ -192,7 +193,6 @@ "cordova-plugin-themeablebrowser": {}, "cordova-plugin-inappbrowser": {}, "cordova-plugin-local-notification": {}, - "call-number": {}, "cordova-opentok-android-permissions": {}, "cordova-plugin-appavailability": {}, "cordova-plugin-apprate": { @@ -222,7 +222,8 @@ "cordova-plugin-background-geolocation": { "GOOGLE_PLAY_SERVICES_VERSION": "+" }, - "phonegap-nfc": {} + "phonegap-nfc": {}, + "wifiwizard2": {} }, "platforms": [ "browser", diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index 28334dde..028fef98 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -1,28 +1,22 @@ -import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { Platform, Events, MenuController } from '@ionic/angular'; import { TranslatorService } from './hmg-common/services/translator/translator.service'; import { CommonService } from './hmg-common/services/common/common.service'; import { AuthenticationService } from './hmg-common/services/authentication/authentication.service'; import { AuthenticatedUser } from './hmg-common/services/authentication/models/authenticated-user'; -import { TabsBarComponent } from './hmg-common/ui/tabs-bar/tabs-bar.component'; import { KeyboardService } from './hmg-common/services/keyboard/keyboard.service'; -import { SMSCheckResponse } from 'src/app/hmg-common/services/authentication/models/smscheck.response'; import { PushService } from '../../src/app/hmg-common/services/push/push.service'; import { LazyLoadingService } from './hmg-common/services/lazy-loading/lazy-loading.service'; import { DomSanitizer } from '@angular/platform-browser'; -// import { SplashScreen } from '@ionic-native/splash-screen'; import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { Router } from '@angular/router'; -import { rejects } from 'assert'; @Component({ selector: 'app-root', styleUrls: ['./app.component.scss'], templateUrl: 'app.component.html' }) -export class AppComponent implements OnInit, AfterViewInit { - // rootPage:any = LoginPage; - // @ViewChild(Nav) nav: Nav; +export class AppComponent implements OnInit { start: any = false; menuList: any = []; User_name_Emp = ''; @@ -34,13 +28,15 @@ export class AppComponent implements OnInit, AfterViewInit { direction = 'ltr'; User_Job_name: string; public logoutFlage: any = false; - requestGetLoginInfo: { - DeviceType: string; DeviceToken: string; // this.deviceToken - }; user: boolean; deviceToken: string; TeamFlag: string = 'false'; isIOS = false; + public requestGetLoginInfo: { + DeviceType: string; + DeviceToken: string; // this.deviceToken + }; + constructor( public ts: TranslatorService, private cs: CommonService, @@ -57,25 +53,30 @@ export class AppComponent implements OnInit, AfterViewInit { ) { this.events.subscribe('img-change', displayImg => { console.log('app compont: ' + displayImg); - // this.user_image = "data:image/png;base64"+displayImg; this.user_image = this.sanitizer.bypassSecurityTrustUrl('data:Image/*;base64,' + displayImg); - }); - } + ngOnInit() { this.initializeApp(); } - ngAfterViewInit() {} - initializeApp() { + + private hideSplashScreen() { + setTimeout(() => { + this.splashScreen.hide(); + }, 1000); +} + + public initializeApp() { + this.cs.startLoading(); this.start = false; this.menu.enable(false); this.lazyLoadingService.monitorLazyLoading(15, true); this.platform.ready().then(() => { + this.hideSplashScreen(); this.ts.loadResources(() => { this.isIOS = this.platform.is('ios') ? true : false; this.initializeDirection(); - // this.statusBar.styleDefault(); this.start = true; if (this.isIOS) { this.monitUrlChange(); @@ -88,7 +89,7 @@ export class AppComponent implements OnInit, AfterViewInit { }); } - private monitUrlChange() { + private monitUrlChange() { this.router.events.subscribe((val) => { if (this.router.isActive('/authentication/login', true)) { this.direction = 'ltr'; @@ -96,62 +97,43 @@ export class AppComponent implements OnInit, AfterViewInit { this.direction = TranslatorService.getCurrentDirection(); } }); - } private startReceivingPushService() { - console.log('platform.ready'); this.pushService.startReceiving(); setTimeout(() => { console.log(' in setTimeout startReceiving'); this.getLastLoginInfo(); }, 4000); + } -} - subscribeEvents() { + public subscribeEvents() { this.platform.backButton.subscribe(() => { if (this.router.isActive('/authentication/login', true)) { - // tslint:disable-next-line: no-string-literal navigator['app'].exitApp(); } }); this.events.subscribe('setMenu', () => { - const user = this.authService - .loadAuthenticatedUser() - .subscribe((user: AuthenticatedUser) => { + const user = this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => { if (user) { - this.companyUrl = user.CompanyImageURL - ? user.CompanyImageURL - : '../assets/imgs/CSLogo.png'; - - this.companyDesc = user.CompanyImageDescription - ? user.CompanyImageDescription - : 'Powered By Cloud Solutions'; + this.companyUrl = user.CompanyImageURL ? user.CompanyImageURL : '../assets/imgs/CSLogo.png'; + this.companyDesc = user.CompanyImageDescription ? user.CompanyImageDescription : 'Powered By Cloud Solutions'; this.User_name_Emp = user.EMPLOYEE_DISPLAY_NAME; if (this.cs.getUpdateImage().status) { this.user_image = this.sanitizer.bypassSecurityTrustUrl('data:image/png;base64,' + this.cs.getUpdateImage().img); - } else { - this.user_image = user.EMPLOYEE_IMAGE - ? 'data:image/png;base64,' + user.EMPLOYEE_IMAGE - : '../assets/imgs/profile.png'; - } + } else { + this.user_image = user.EMPLOYEE_IMAGE ? 'data:image/png;base64,' + user.EMPLOYEE_IMAGE : '../assets/imgs/profile.png'; + } this.User_Job_name = user.JOB_NAME; - - console.log(user); } else { console.log(user); } }); }); - this.events.subscribe('getNotCount', badge => { - this.notBadge = badge; - }); - - this.events.subscribe('myTeamFlag', myTeamFlag => { - this.TeamFlag = myTeamFlag; - }); - console.log("this.TeamFlag>>>>>>>>>"+ this.TeamFlag); + this.events.subscribe('getNotCount', badge => { this.notBadge = badge; }); + this.events.subscribe('myTeamFlag', myTeamFlag => { this.TeamFlag = myTeamFlag; }); } + private initializeDirection() { if (this.isIOS) { if (this.router.isActive('/authentication/login', true)) { @@ -162,14 +144,8 @@ export class AppComponent implements OnInit, AfterViewInit { } else { this.direction = TranslatorService.getCurrentDirection(); } - - } - private watchUserLoginChangeEvents() { - this.events.subscribe( - AuthenticationService.LOGIN_EVENT, - (user: AuthenticatedUser, time: Date) => {} - ); } + private watchLanguageChangeEvents() { this.events.subscribe(TranslatorService.CHANGE_EVENT, () => { this.start = false; @@ -179,91 +155,68 @@ export class AppComponent implements OnInit, AfterViewInit { }, 100); }); } - logout() { + + public logout() { this.cs.sharedService.clearAll(); - // this.menu.toggle(); this.menu.enable(false); this.logoutFlage = true; this.events.publish('logoutFlage', this.logoutFlage); - this.cs.setUpdateImage('', false); this.TeamFlag = 'false'; this.getLastLoginInfo(); - // this.cs.openLogin(); - - } - openMyTeamPage() { + public openMyTeamPage() { this.menu.toggle(); this.cs.openMyTeamPage(); - } - // profile() { - // this.cs.openProfile(); - // this.menu.toggle(); - // } - profile() { + public profile() { this.cs.openEditProfile(); this.menu.toggle(); } - openNotification() { + public openNotification() { this.cs.openNotificationPage(); this.menu.toggle(); } - openChangePassword() { + public openChangePassword() { this.cs.openChangePassword(); this.menu.toggle(); } -// openPayslipPage(){ -// this.cs.openPayslipPage(); -// this.menu.toggle(); -// } - private changeImage() { this.cs.openChangeImagePage(); this.menu.toggle(); } - closeMenu() { + public closeMenu() { this.menu.toggle(); } - getLastLoginInfo() { + public getLastLoginInfo() { this.deviceToken = this.cs.getDeviceToken(); - // this.cs.sharedService.getSharedData("new-device-token",false);// localStorage.getItem('devicyeToken'); - if (this.deviceToken) { console.log('login enabled first time: ' + this.deviceToken); } else { - this.pushService.startReceiving(); - setTimeout(() => { - this.deviceToken = localStorage.getItem('deviceToken'); - }, 1000); + this.pushService.startReceiving(); + setTimeout(() => { + this.deviceToken = localStorage.getItem('deviceToken'); + }, 1000); } this.requestGetLoginInfo = { - DeviceType: this.cs.getDeviceType(), // 'Android', - DeviceToken: this.deviceToken// "5ca8a69cf1804db55264c349edffb99b9d63acd9fa9b6b18956bcb2ad3f2ba36"//this.deviceToken + DeviceType: this.cs.getDeviceType(), + DeviceToken: this.deviceToken }; this.authService.getLoginInfo(this.requestGetLoginInfo, () => {}, this.ts.trPK('general', 'ok')).subscribe(res => { if (this.cs.validResponse(res)) { if (res.Mohemm_GetMobileLoginInfoList.length > 0) { - this.cs.sharedService.setSharedData( - // res.Patient_SELECTDeviceIMEIbyIMEIList[0], - res.Mohemm_GetMobileLoginInfoList[0], - AuthenticationService.IMEI_USER_DATA - ); + this.cs.sharedService.setSharedData(res.Mohemm_GetMobileLoginInfoList[0], AuthenticationService.IMEI_USER_DATA); this.user = true; this.events.publish('user', this.user); - setTimeout(() => { - this.splashScreen.hide(); - }, 3000); if (this.logoutFlage) { this.cs.openLogin(); @@ -271,21 +224,12 @@ export class AppComponent implements OnInit, AfterViewInit { } else { this.user = false; this.events.publish('user', this.user); - setTimeout(() => { - this.splashScreen.hide(); - }, 3000); + if (this.logoutFlage) { this.cs.openLogin(); } } - } else { - // this.user = false; - // this.splashScreen.hide(); - // if(this.logoutFlage){ - // this.cs.openLogin(); - // } - } + } else {} }); } - } diff --git a/Mohem/src/app/app.module.ts b/Mohem/src/app/app.module.ts index da9c0637..b1632d6c 100644 --- a/Mohem/src/app/app.module.ts +++ b/Mohem/src/app/app.module.ts @@ -17,6 +17,7 @@ import { Base64 } from '@ionic-native/base64/ngx'; import { FirebaseX } from '@ionic-native/firebase-x/ngx'; import { NgCalendarModule } from 'ionic2-calendar'; import { NFC, Ndef} from "@ionic-native/nfc/ngx" +import { WifiWizard2 } from "@ionic-native/wifi-wizard-2/ngx"; @NgModule({ declarations: [AppComponent], @@ -43,7 +44,8 @@ import { NFC, Ndef} from "@ionic-native/nfc/ngx" FirebaseX, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, NFC, - Ndef + Ndef, + WifiWizard2 ], bootstrap: [AppComponent] }) diff --git a/Mohem/src/app/attendance-tracking/home/home.component.html b/Mohem/src/app/attendance-tracking/home/home.component.html index e9b87275..98c3e6dd 100644 --- a/Mohem/src/app/attendance-tracking/home/home.component.html +++ b/Mohem/src/app/attendance-tracking/home/home.component.html @@ -1,31 +1,11 @@ - - - - -
{{curentDate}}
{{ts.trPK('attendance-tracking','today-time-left')}} diff --git a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts index 23bcf302..065e2fb1 100644 --- a/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts +++ b/Mohem/src/app/authentication/confirm-login/confirm-login.component.ts @@ -360,6 +360,11 @@ export class ConfirmLoginComponent implements OnInit { this.authService.checkSMS(request, () => {}, this.ts.trPK('general', 'ok')) .subscribe((result: SMSCheckResponse) => { if (this.cs.validResponse(result)) { + + // Wifi Credientials + CommonService.MOHEMM_WIFI_SSID = result.Mohemm_Wifi_SSID; + CommonService.MOHEMM_WIFI_PASSWORD = result.Mohemm_Wifi_Password; + AuthenticationService.servicePrivilage = result.Privilege_List; this.authService.setAuthenticatedUser(result).subscribe(() => { localStorage.setItem('emp-name', result.MemberInformationList[0].EMPLOYEE_NAME); diff --git a/Mohem/src/app/authentication/login/login.component.ts b/Mohem/src/app/authentication/login/login.component.ts index e85917ac..88a625f5 100644 --- a/Mohem/src/app/authentication/login/login.component.ts +++ b/Mohem/src/app/authentication/login/login.component.ts @@ -100,8 +100,7 @@ export class LoginComponent implements OnInit, OnDestroy { ngOnInit() { this.monitorKeyboardChange(); this.currentLang = TranslatorService.getCurrentLanguageCode(); - console.log(TranslatorService.CURRENT_LANGUAGE) - console.log(TranslatorService.EN) + if (TranslatorService.CURRENT_LANGUAGE == TranslatorService.EN) { this.language = "US"; this.changeLanguage('2') @@ -109,11 +108,9 @@ export class LoginComponent implements OnInit, OnDestroy { this.language = "AR"; this.changeLanguage('1') } - console.log("current lang: "+this.currentLang); - this.events.subscribe('user', user => { - this.user = user; - }); - this.deviceToken =this.cs.getDeviceToken(); + + this.events.subscribe('user', user => { this.user = user; }); + this.deviceToken = this.cs.getDeviceToken(); if (this.deviceToken) { console.log('login enabled first time: ' + this.deviceToken); } else { diff --git a/Mohem/src/app/authentication/sms-page/sms-page.page.ts b/Mohem/src/app/authentication/sms-page/sms-page.page.ts index 2659c184..5bdfe570 100644 --- a/Mohem/src/app/authentication/sms-page/sms-page.page.ts +++ b/Mohem/src/app/authentication/sms-page/sms-page.page.ts @@ -192,6 +192,11 @@ export class SmsPageComponent implements OnInit { request.IsDeviceNFC = this.isNFCAvailable; this.authService.checkSMS(request, () => {}, this.translate.trPK('general', 'ok')).subscribe((result: SMSCheckResponse) => { if (this.common.validResponse(result)) { + + // Wifi Credientials + CommonService.MOHEMM_WIFI_SSID = result.Mohemm_Wifi_SSID; + CommonService.MOHEMM_WIFI_PASSWORD = result.Mohemm_Wifi_Password; + AuthenticationService.servicePrivilage = result.Privilege_List; this.authService.setAuthenticatedUser(result).subscribe(() => { localStorage.setItem('emp-name', result.MemberInformationList[0].EMPLOYEE_NAME); diff --git a/Mohem/src/app/hmg-common/hmg-common.module.ts b/Mohem/src/app/hmg-common/hmg-common.module.ts index 2ba34058..7d6e752e 100644 --- a/Mohem/src/app/hmg-common/hmg-common.module.ts +++ b/Mohem/src/app/hmg-common/hmg-common.module.ts @@ -4,7 +4,7 @@ import { Globalization } from '@ionic-native/globalization/ngx'; import { NumberRangeComponent } from './ui/number-range/number-range.component'; import { IonicModule } from '@ionic/angular'; import { CommonModule } from '@angular/common'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { FormsModule } from '@angular/forms'; import { SSpacerComponent } from './ui/spacer/s-spacer/s-spacer.component'; import { MSpacerComponent } from './ui/spacer/m-spacer/m-spacer.component'; import { LSpacerComponent } from './ui/spacer/l-spacer/l-spacer.component'; @@ -33,7 +33,6 @@ import { KeysPipe } from './pipes/keys/keys.pipe'; import { SegmentContentComponent } from './ui/segment-content/segment-content.component'; import { GraphComponent } from './ui/graph/graph.component'; import { NgxChartsModule } from '@swimlane/ngx-charts'; - import { ExpandableComponent } from './ui/expandable/expandable.component'; import { ProjectsService } from './services/projects/projects.service'; import { NationalityService } from './services/nationality/nationality.service'; @@ -43,8 +42,6 @@ import { NativeStorage } from '@ionic-native/native-storage/ngx'; import { ProgressLoadingService } from './ui/progressLoading/progress-loading.service'; import { BarChartComponent } from './ui/bar-chart/bar-chart.component'; import { DonutChartComponent } from './ui/donut-chart/donut-chart.component'; -// import { UserLocalNotificationService } from './services/user-local-notification/user-local-notification.service'; -// import { LocalNotifications } from '@ionic-native/local-notifications/ngx'; import { EmailComponent } from './ui/email/email.component'; import { Badge } from '@ionic-native/badge/ngx'; import { PushService } from './services/push/push.service'; @@ -53,15 +50,12 @@ import { HmgBrowserService } from './services/hmg-browser/hmg-browser.service'; import { GuidService } from './services/guid/guid.service'; import { TabsBarComponent } from './ui/tabs-bar/tabs-bar.component'; import { PageTrailerComponent } from './ui/spacer/page-trailer/page-trailer.component'; -// import { GeofencingService } from './services/geofencing/geofencing.service'; -// import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'; import { ButtonComponent, Modal } from './ui/button/button.component'; import { ToolbarButtonComponent } from './ui/toolbar-button/toolbar-button.component'; import { ListboxModule } from 'primeng/listbox'; import { GenderSelectComponent } from './ui/gender-select/gender-select.component'; import { DateSelectComponent } from './ui/date-select/date-select.component'; import { ToggleButtonComponent } from './ui/toggle-button/toggle-button.component'; -import { Footer } from 'primeng/components/common/shared'; import { FooterComponent } from './ui/footer/footer.component'; import { ScrollContentComponent } from './ui/scroll-content/scroll-content.component'; import { ScrollSegmentContentComponent } from './ui/scroll-segment-content/scroll-segment-content.component'; @@ -82,20 +76,16 @@ import { Diagnostic } from '@ionic-native/diagnostic/ngx'; import { DetailButtonComponent } from './ui/detail-button/detail-button.component'; import { RouterModule } from '@angular/router'; import { HeaderButtonComponent } from './ui/header-button/header-button.component'; -// import { CallNumber } from '@ionic-native/call-number/ngx'; import { AppRate } from '@ionic-native/app-rate/ngx'; import { RatingService } from './services/rating/rating.service'; import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; import { RateService } from './services/rate/rate.service'; -// import { PaymentComponent } from './ui/payment/payment.component'; -// import { PaymentService } from './ui/payment/service/payment.service'; import { MenuService } from './services/menu/menuservice.service'; import { ReplacementListComponent } from '../vacation-rule/replacement-list/replacement-list.component'; import { FileUploadModule } from 'ng2-file-upload'; -// import { FileSelectDirective } from 'ng2-file-upload'; import { PdfViewerModule } from 'ng2-pdf-viewer'; import { WorkListAttachViewComponent } from '../notification/work-list-attach-view/work-list-attach-view.component'; -import {Camera, CameraOptions, PictureSourceType} from '@ionic-native/Camera/ngx'; +import {Camera} from '@ionic-native/Camera/ngx'; import {File} from '@ionic-native/file/ngx'; import {FileUploderProfileComponent} from './ui/file-uploder-profile/file-uploder-profile.component'; import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx'; @@ -120,6 +110,7 @@ import { ChartModule } from 'primeng/chart'; import { GenericHeaderComponent } from './ui/generic-header/generic-header.component'; import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx'; import { AttendanceOptionsComponent } from '../home/attendance-options/attendance-options.component'; + @NgModule({ imports: [ CommonModule, @@ -153,7 +144,6 @@ import { AttendanceOptionsComponent } from '../home/attendance-options/attendanc DatePipeTransform, DateTimePipe, SafeHtmlPipe, - // TurncatePipe, BackButtonComponent, IfDatePipe, DynamicTableComponent, @@ -188,7 +178,6 @@ import { AttendanceOptionsComponent } from '../home/attendance-options/attendanc DetailButtonComponent, HeaderButtonComponent, ReplacementListComponent, - // FileSelectDirective, WorkListAttachViewComponent, FileUploderProfileComponent, AccordinTabCustomComponent, @@ -219,7 +208,6 @@ import { AttendanceOptionsComponent } from '../home/attendance-options/attendanc DividerComponent, NavButtonsComponent, DatePipeTransform, - // TurncatePipe, TranslatePipe, DateTimePipe, SafeHtmlPipe, @@ -254,7 +242,6 @@ import { AttendanceOptionsComponent } from '../home/attendance-options/attendanc DetailButtonComponent, HeaderButtonComponent, ReplacementListComponent, - // FileSelectDirective, WorkListAttachViewComponent, FileUploderProfileComponent, AccordinTabCustomComponent, @@ -293,14 +280,10 @@ import { AttendanceOptionsComponent } from '../home/attendance-options/attendanc NativeStorage, ProgressLoadingService, PushService, - // UserLocalNotificationService, - // LocalNotifications, Badge, LifeCycleService, HmgBrowserService, GuidService, - // BackgroundGeolocation, - // GeofencingService, Keyboard, KeyboardService, Diagnostic, @@ -315,7 +298,6 @@ import { AttendanceOptionsComponent } from '../home/attendance-options/attendanc RateService, Camera, File, - // PaymentService, MenuService, OpenNativeSettings, BarcodeScanner, diff --git a/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts index c1bdc43a..2bdcc8cf 100644 --- a/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts +++ b/Mohem/src/app/hmg-common/services/attend-services/attend-scan.service.ts @@ -70,6 +70,7 @@ export class AttendScanService { this.lat = resp.latitude; this.longt = resp.longitude; this.attendance(); + } else { this.common.presentAlert(this.ts.trPK('home', 'position-error')); } @@ -82,6 +83,7 @@ export class AttendScanService { this.lat = resp.coords.latitude; this.longt = resp.coords.longitude; this.attendance(); + } else { this.common.presentAlert(this.ts.trPK('home', 'position-error')); } @@ -96,13 +98,12 @@ export class AttendScanService { } public attendance() { - this.permissions.requestCameraAutherization().then(granted => { - this.camera = granted as boolean; - if (this.camera) { - this.scanCode(); - } + this.permissions.requestCameraAutherization().then(granted => { + this.camera = granted as boolean; + if (this.camera) { + this.scanCode(); } - ); + }); } scanCode() { diff --git a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts index 5573721f..c1d7c20c 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -38,9 +38,6 @@ import { SendActivationByType } from 'src/app/authentication/models/sendActivati }) export class AuthenticationService { - - public static MOBILE_USER = 102; - /* login methods */ public static loginURL = 'Services/Authentication.svc/REST/CheckPatientAuthentication'; public static checkUserAuthURL = 'Services/Authentication.svc/REST/CheckPatientAuthentication'; @@ -133,8 +130,10 @@ export class AuthenticationService { mobileType = 'android'; } else if (isIOS) { mobileType = 'ios'; + }else{ + mobileType = 'android'; } - request.VersionID = 2.6; + request.VersionID = 2.7; request.Channel = 33; request.LanguageID = TranslatorService.getCurrentLanguageCode(); request.MobileType = mobileType; diff --git a/Mohem/src/app/hmg-common/services/authentication/models/smscheck.response.ts b/Mohem/src/app/hmg-common/services/authentication/models/smscheck.response.ts index 660b8a28..7c703fb2 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/smscheck.response.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/smscheck.response.ts @@ -17,5 +17,7 @@ export class SMSCheckResponse extends Response { public CompanyImageURL:string; public EMPLOYEE_MOBILE_NUMBER:string; public EMPLOYEE_NAME:string; + public Mohemm_Wifi_SSID:string; + public Mohemm_Wifi_Password:string; } diff --git a/Mohem/src/app/hmg-common/services/common/common.service.ts b/Mohem/src/app/hmg-common/services/common/common.service.ts index 610147d1..8e7fce00 100644 --- a/Mohem/src/app/hmg-common/services/common/common.service.ts +++ b/Mohem/src/app/hmg-common/services/common/common.service.ts @@ -26,13 +26,16 @@ import { SharedDataService } from '../shared-data-service/shared-data.service'; import { Badge } from '@ionic-native/badge/ngx'; import { LifeCycleService } from '../life-cycle/life-cycle.service'; import { Diagnostic } from '@ionic-native/diagnostic/ngx'; -//import { CallNumber } from "@ionic-native/call-number/ngx"; import { InAppBrowser } from '@ionic-native/in-app-browser/ngx'; @Injectable({ providedIn: 'root' }) export class CommonService { + + public static MOHEMM_WIFI_SSID = ""; + public static MOHEMM_WIFI_PASSWORD = ""; + public static months_en_long = [ 'January', 'February', @@ -100,7 +103,6 @@ export class CommonService { public badge: Badge, public lifeCycle: LifeCycleService, public diagnostic: Diagnostic, - //public callNumber: CallNumber, public iab: InAppBrowser, private menu: MenuController, ) {} @@ -237,7 +239,6 @@ public getMonthNameAr(value: number): string { public mobileNumber(number: string) { return number.substr(1, number.length - 1); } - public testFunction() {} public stopLoading() { this.progressLoadingService.dismiss(); @@ -1321,20 +1322,6 @@ public getMonthNameAr(value: number): string { }); } - // public callPhoneNumber(phoneNumber: string) { - // this.platform.ready().then(() => { - // if (this.isCordova()) { - // this.callNumber - // .callNumber(phoneNumber, true) - // .then(res => {}) - // .catch(err => {}); - // } else { - // window.open("tel:" + phoneNumber); - // // this.presentAlert(this.ts.trPK('error', 'call')); - // } - // }); - // } - list_to_tree(list) { let map = {}, node, diff --git a/Mohem/src/app/hmg-common/services/push/push.service.ts b/Mohem/src/app/hmg-common/services/push/push.service.ts index 0df0af0b..b75b052b 100644 --- a/Mohem/src/app/hmg-common/services/push/push.service.ts +++ b/Mohem/src/app/hmg-common/services/push/push.service.ts @@ -1,21 +1,15 @@ import { Injectable, NgZone } from '@angular/core'; -// import { Push, PushObject, PushOptions } from '@ionic-native/push/ngx'; import { CommonService } from '../common/common.service'; import { TranslatorService } from '../translator/translator.service'; import { NotificationModel } from './models/notification.model'; import { SharedDataService } from '../shared-data-service/shared-data.service'; import { ConnectorService } from '../connector/connector.service'; -//import { Response } from '../models/response'; import { Response } from 'src/app/hmg-common/services/models/response'; import { RegisterAuthenticatedUserRequest } from './models/register-authenticated-user.request'; import { Platform, Events } from '@ionic/angular'; import { RegisterNormalUserRequest } from './models/register-normal-user.request'; import { AuthenticationService } from '../authentication/authentication.service'; -// import { AppointmentModel } from 'src/app/eservices/appointments/service/models/appointment.model'; import { SessionModel } from './models/session.model'; -import { AuthenticatedUser } from '../authentication/models/authenticated-user'; -// import { NotificationsCenterService } from 'src/app/eservices/notifications-center/service/notifications-center.service'; -// import { NotificationsComponent } from 'src/app/eservices/notifications-center/notifications/notifications.component'; import { FirebaseX } from '@ionic-native/firebase-x/ngx'; @Injectable({ @@ -28,7 +22,6 @@ export class PushService { public static CHANNEL_ID = '679409052782';//'815750722565'; constructor( - // public push: Push, public cs: CommonService, public ts: TranslatorService, public sharedService: SharedDataService, @@ -36,72 +29,14 @@ export class PushService { private platform: Platform, private authService: AuthenticationService, public ngZone: NgZone, - // public notifyService: NotificationsCenterService, public events: Events, - public firebasex: FirebaseX, - + public firebasex: FirebaseX ) { } public startReceiving() { console.log("startReceiving"); - // this.processStartReceiving(); this.processStartReceivingWithFirebase(); } - private processStartReceiving1() { - // if (this.cs.isCordova()) { - // this.stopNotifications(() => { - // this.push.hasPermission() - // .then((res: any) => { - // if (res.isEnabled) { - // this.createChannel(); - // } else { - // this.cs.presentAlert(this.ts.trPK('push', 'no-permiss')); - // } - // }); - // }); - // } - } - - private createChannel() { - // Create a channel (Android O and above). You'll need to provide the id, description and importance properties. - // this.push.createChannel({ - // id: PushService.CHANNEL_ID, - // description: 'HMG push notifications', - // importance: 3 - // }).then(() => { - // this.initialize(); - // }); - } - - private initialize() { - // const options: PushOptions = { - // android: { - // senderID: PushService.CHANNEL_ID, - // sound: true, - // forceShow: true - // }, - // ios: { - // alert: true, - // badge: true, - // sound: true - // }, - // windows: {}, - // browser: { - // pushServiceURL: 'http://push.api.phonegap.com/v1/push' - // } - // }; - // const pushObject: PushObject = this.push.init(options); - // pushObject.on('notification').subscribe((notification: any) => { - // this.processNotification(notification); - // }); - - // pushObject.on('registration').subscribe((data: any) => { - // this.registerInBackend(data); - // }); - - // pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error)); - - } private processNotification(data: any) { const notification = new NotificationModel(); @@ -120,12 +55,9 @@ export class PushService { const type = Number(data.additionalData.NotificationType); if (type === NotificationModel.TYPE_APPOINTMENT) { this.sharedService.setSharedData(notification, NotificationModel.SHARED_DATA); - // this.ngZone.run(() => this.cs.openAppointmentDetails()); } else if (type === NotificationModel.TYPE_CONFERENCE) { const session = data.additionalData.sessionId; - // console.log('session Id Recieved>>>>>'+ session); this.sharedService.setSharedData( new SessionModel(session) , SessionModel.SHARED_DATA); - // this.ngZone.run( () => this.cs.openConference() ); } else { if (type === NotificationModel.TYPE_VIDEO) { notification.MessageType = 'video'; @@ -137,28 +69,11 @@ export class PushService { notification.MessageType = 'text'; } this.sharedService.setSharedData(notification, NotificationModel.SHARED_DATA); - //this.ngZone.run(async () => this.cs.openNotificationDetails()); } } private setAsReadNotification(notification: NotificationModel) { notification.IsRead = true; - // this.notifyService.setNotificationRead(notification, () => { - // }).subscribe((result: Response) => { - // if (this.cs.validResponse(result)) { - // this.events.publish( NotificationsCenterService.NOTIFICATIONS_COUNT_EVENT, notification.count); - // } - // }); - - - } - public stopNotifications(done: any) { - // Delete a channel (Android O and above) - // if (this.cs.isCordova()) { - // this.push.deleteChannel(PushService.CHANNEL_ID).then(() => { - // done(); - // }); - // } } private registerInBackend(data: any) { @@ -166,14 +81,7 @@ export class PushService { if (data) { this.cs.sharedService.setSharedData(data, AuthenticationService.DEVICE_TOKEN); localStorage.setItem('deviceToken', data); - } - // - // if (this.authService.isAuthenticated()) { - // this.registerAuthenticatedUser(data); - // } else { - // this.registerNotAuthenticatedUser(data); - // } } @@ -198,7 +106,6 @@ export class PushService { }); } - private registerNotAuthenticatedUser(deviceToken: any) { const request = new RegisterNormalUserRequest(); this.authService.setPublicFields(request); @@ -220,26 +127,13 @@ export class PushService { private processStartReceivingWithFirebase() { console.log("processStartReceivingWithFirebase"); - this.firebasex.getToken().then(token => { // alert("token: "+ token); this.cs.sharedService.setSharedData(token, "new-device-token"); localStorage.setItem('deviceToken', token); this.cs.setDeviceToken(token); //last way to set the device Token to get it through getDeviceToken - this.registerInBackend(token); - }).catch(error => console.error('Error getting token', error)); - - - // this.firebase.getToken() - // .then(token => console.log(`The token is ${token}`)) - // .catch(error => console.error('Error getting token', error)); - - // this.firebasex.onTokenRefresh().subscribe(token => { - // alert("token: "+ token); - // this.registerInBackend(token); - // }); } public onPushReceived(payload: any) { @@ -253,10 +147,4 @@ export class PushService { console.log("onPushOpened openConference"); this.processNotification(payload); } - - - - - - } diff --git a/Mohem/src/app/home/attendance-options/attendance-options.component.html b/Mohem/src/app/home/attendance-options/attendance-options.component.html index 49f1b330..7622aa12 100644 --- a/Mohem/src/app/home/attendance-options/attendance-options.component.html +++ b/Mohem/src/app/home/attendance-options/attendance-options.component.html @@ -38,6 +38,17 @@
+ + + + +
+ +

{{ "general, wifi-text" | translate }}

+
+
+ +
diff --git a/Mohem/src/app/home/attendance-options/attendance-options.component.ts b/Mohem/src/app/home/attendance-options/attendance-options.component.ts index 33c06bab..f655dcb9 100644 --- a/Mohem/src/app/home/attendance-options/attendance-options.component.ts +++ b/Mohem/src/app/home/attendance-options/attendance-options.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, NgZone } from "@angular/core"; +import { Component, OnInit, NgZone, VERSION } from "@angular/core"; import { NFC } from "@ionic-native/nfc/ngx"; import { CommonService } from "src/app/hmg-common/services/common/common.service"; import { Platform } from "@ionic/angular"; @@ -6,12 +6,18 @@ import { AttendScanService } from "../../hmg-common/services/attend-services/att import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; import { ModalController } from "@ionic/angular"; import { NfcModalComponent } from "../nfc-modal/nfc-modal.component"; +import { WifiModalComponent } from "../wifi-model/wifi-modal.component"; import { AuthenticatedUser } from "../../hmg-common/services/authentication/models/authenticated-user"; import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; import { attendanceSwipeScannerRequest } from "src/app/home/models/attendanceSwipe.Request"; import { Device } from "@ionic-native/device/ngx"; import { AttendanceService } from "src/app/home/services/attendance.services"; import { Response } from "src/app/hmg-common/services/models/response"; +import { WifiWizard2 } from "@ionic-native/wifi-wizard-2/ngx"; +import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx'; +import { DevicePermissionsService } from 'src/app/hmg-common/services/device-permissions/device-permissions.service'; + + @Component({ selector: "app-attendance-options", @@ -25,6 +31,7 @@ export class AttendanceOptionsComponent implements OnInit { public priviligeList: any; public serviceEnableNFC = false; public serviceEnableQR = false; + public serviceEnableWifi = false; public deviceNFC = false; public nfcIOSSuccess = false; @@ -37,7 +44,10 @@ export class AttendanceOptionsComponent implements OnInit { public modalController: ModalController, private device: Device, private attendance_service: AttendanceService, - public ngZone: NgZone + public ngZone: NgZone, + private wifiWizard2: WifiWizard2, + private openNativeSettings: OpenNativeSettings, + private devicePermissionsService:DevicePermissionsService ) {} ngOnInit() { @@ -49,6 +59,7 @@ export class AttendanceOptionsComponent implements OnInit { this.priviligeList = AuthenticationService.servicePrivilage; this.setServicesPrivilage(); this.checkNFCStatus("one"); + } async checkNFCStatus(checkValue: string) { @@ -93,6 +104,12 @@ export class AttendanceOptionsComponent implements OnInit { ) { this.serviceEnableQR = true; } + if ( + servicePrivilage.Previlege && + servicePrivilage.ServiceName === "enableWIFI" + ) { + this.serviceEnableWifi = true; + } } } @@ -156,4 +173,55 @@ export class AttendanceOptionsComponent implements OnInit { public startQRCode() { this.attendScanService.getDeviceLocation(); } + + + // Wifi Attendance + public async startWifi() { + const isAndroid = this.platform.is("android"); + const isIOS = this.platform.is("ios"); + const isWifiEnabled = await this.wifiWizard2.isWifiEnabled(); + + if(isIOS){ + if(!isWifiEnabled){ + this.showWifiNotEnabled(); + return; + } + + }else if(isAndroid){ + let locationPermission = await this.devicePermissionsService.requestLocationAutherization(); + if(!locationPermission){ + return; + } + + if(!isWifiEnabled){ + this.wifiWizard2.setWifiEnabled(true).then(()=>{ + this.startWifi(); + }).catch((err) => { + console.debug(err); + this.showWifiNotEnabled(); + }); + return; + } + } + + // opening wifi dailog if all above conditions are passed (isWifiEnabled == true) + let modal = await this.modalController.create({ + component: WifiModalComponent, + showBackdrop: true, + backdropDismiss: false, + }); + modal.cssClass = "wifi-modal"; + await modal.present(); + } + + + + showWifiNotEnabled(){ + this.common.showErrorMessageDialog(()=>{ + // this.openNativeSettings.open('wifi').then(()=>{}); + }, + this.ts.trPK("general", "ok"), + this.ts.trPK("general","wifi-not-enable-text")); + } + } diff --git a/Mohem/src/app/home/home.module.ts b/Mohem/src/app/home/home.module.ts index 32ba2bad..6232673c 100644 --- a/Mohem/src/app/home/home.module.ts +++ b/Mohem/src/app/home/home.module.ts @@ -9,6 +9,7 @@ import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx'; import { WorklistMainService } from '../notification/service/work-list.main.service'; import { AttendanceOptionsComponent } from './attendance-options/attendance-options.component'; import { NfcModalComponent } from './nfc-modal/nfc-modal.component'; +import { WifiModalComponent } from './wifi-model/wifi-modal.component'; const routes: Routes = [ { path: '', @@ -31,12 +32,16 @@ const routes: Routes = [ ], declarations: [ HomePage, - NfcModalComponent + NfcModalComponent, + WifiModalComponent ], providers: [ BarcodeScanner, WorklistMainService ], - entryComponents: [NfcModalComponent] + entryComponents: [ + NfcModalComponent, + WifiModalComponent + ] }) export class HomePageModule { } diff --git a/Mohem/src/app/home/home.page.html b/Mohem/src/app/home/home.page.html index 05491459..5cc9479e 100644 --- a/Mohem/src/app/home/home.page.html +++ b/Mohem/src/app/home/home.page.html @@ -26,14 +26,14 @@ {{menuItem.PROMPT}} + - - - + + - - + + @@ -55,8 +55,8 @@ - + diff --git a/Mohem/src/app/home/models/attendanceSwipe.Request.ts b/Mohem/src/app/home/models/attendanceSwipe.Request.ts index a75fe7ff..c6a1e8bd 100644 --- a/Mohem/src/app/home/models/attendanceSwipe.Request.ts +++ b/Mohem/src/app/home/models/attendanceSwipe.Request.ts @@ -17,6 +17,7 @@ export class attendanceSwipeScannerRequest extends Request{ public UserID: string; public PointType: number; public NFCValue: string; + public WifiValue: string; } diff --git a/Mohem/src/app/home/nfc-modal/nfc-modal.component.scss b/Mohem/src/app/home/nfc-modal/nfc-modal.component.scss index 9e51eeaf..f36ce704 100644 --- a/Mohem/src/app/home/nfc-modal/nfc-modal.component.scss +++ b/Mohem/src/app/home/nfc-modal/nfc-modal.component.scss @@ -17,12 +17,12 @@ .ripple-div { display: block; text-align: center; - margin-top: -20%; + margin-top: -5%; p { font-size: 16px; color: #bbbbbb; font-family: 'WorkSans-Bold'; - margin-top: -20%; + // margin-top: -20%; padding-right: 10px; } ion-button { @@ -33,6 +33,12 @@ } } +.wifi-div { + display: block; + text-align: center; + margin-top: -5%; +} + .checked-img { display: block; text-align: center; diff --git a/Mohem/src/app/home/nfc-modal/nfc-modal.component.ts b/Mohem/src/app/home/nfc-modal/nfc-modal.component.ts index 1117ea7c..605b3e87 100644 --- a/Mohem/src/app/home/nfc-modal/nfc-modal.component.ts +++ b/Mohem/src/app/home/nfc-modal/nfc-modal.component.ts @@ -72,7 +72,8 @@ export class NfcModalComponent implements OnInit { }); setTimeout(() => { this.modalController.dismiss(); - this.common.openHome(); + // this.common.openHome(); + this.common.openAttenTrackingpage(); }, 4000); } }); diff --git a/Mohem/src/app/home/wifi-model/wifi-modal.component.html b/Mohem/src/app/home/wifi-model/wifi-modal.component.html new file mode 100644 index 00000000..5a87fce4 --- /dev/null +++ b/Mohem/src/app/home/wifi-model/wifi-modal.component.html @@ -0,0 +1,15 @@ + +
+

+
+ +
+ +

{{ "general, wifi-connect-message" | translate }}

+
+ +
+ +

{{ "general, success-attendance" | translate }}

+
+
\ No newline at end of file diff --git a/Mohem/src/app/home/wifi-model/wifi-modal.component.scss b/Mohem/src/app/home/wifi-model/wifi-modal.component.scss new file mode 100644 index 00000000..f56315b0 --- /dev/null +++ b/Mohem/src/app/home/wifi-model/wifi-modal.component.scss @@ -0,0 +1,45 @@ +.centerDiv { + margin: auto; + text-align: center; + display: block; +} + +.heading-div { + display: block; + text-align: center; +} +.heading-text { + font-size: 16px; + color: #bbbbbb; + font-family: 'WorkSans-Bold'; + margin-top: 7%; +} +.ripple-div { + display: block; + text-align: center; + margin-top: -20%; + p { + font-size: 16px; + color: #bbbbbb; + font-family: 'WorkSans-Bold'; + margin-top: -20%; + padding-right: 10px; + } + ion-button { + --background: #282f42; + color: var(--light); + border-radius: 33px; + width: 270px; + } +} +.wifi-div { + display: block; + text-align: center; + margin-top: 0%; +} + +.checked-img { + display: block; + text-align: center; + margin-top: 10%; +} \ No newline at end of file diff --git a/Mohem/src/app/home/wifi-model/wifi-modal.component.spec.ts b/Mohem/src/app/home/wifi-model/wifi-modal.component.spec.ts new file mode 100644 index 00000000..72adf22a --- /dev/null +++ b/Mohem/src/app/home/wifi-model/wifi-modal.component.spec.ts @@ -0,0 +1,27 @@ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WifiModalComponent } from './wifi-modal.component'; + +describe('WifiModalComponent', () => { + let component: WifiModalComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WifiModalComponent ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WifiModalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Mohem/src/app/home/wifi-model/wifi-modal.component.ts b/Mohem/src/app/home/wifi-model/wifi-modal.component.ts new file mode 100644 index 00000000..208682cf --- /dev/null +++ b/Mohem/src/app/home/wifi-model/wifi-modal.component.ts @@ -0,0 +1,184 @@ +import { Component, OnInit, NgZone } from '@angular/core'; +import { CommonService } from 'src/app/hmg-common/services/common/common.service'; +import { attendanceSwipeScannerRequest } from 'src/app/home/models/attendanceSwipe.Request'; +import { Device } from '@ionic-native/device/ngx'; +import { AuthenticatedUser } from '../../hmg-common/services/authentication/models/authenticated-user'; +import { AttendanceService } from 'src/app/home/services/attendance.services'; +import { Response } from 'src/app/hmg-common/services/models/response'; +import { ModalController } from '@ionic/angular'; +import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; +import { Platform } from "@ionic/angular"; +import { WifiWizard2 } from "@ionic-native/wifi-wizard-2/ngx"; +import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx'; + +@Component({ + selector: 'app-wifi-modal', + templateUrl: './wifi-modal.component.html', + styleUrls: ['./wifi-modal.component.scss'], +}) +export class WifiModalComponent implements OnInit { + public userData: any = {}; + public gifStatus = false; + private ssid = CommonService.MOHEMM_WIFI_SSID; + private password = CommonService.MOHEMM_WIFI_PASSWORD; + private algo = 'WPA'; + + constructor( + public common: CommonService, + private device: Device, + private attendance_service: AttendanceService, + public modalController: ModalController, + public ts: TranslatorService, + public ngZone: NgZone, + private wifiWizard2: WifiWizard2, + private openNativeSettings: OpenNativeSettings, + private platform: Platform, + ) { } + + ngOnInit() { + this.userData = this.common.sharedService.getSharedData(AuthenticatedUser.SHARED_DATA, false); + setTimeout(() => { + this.startWifiConnection(); + }, 1000); + } + + async startWifiConnection() { + const isAndroid = this.platform.is("android"); + const isIOS = this.platform.is("ios"); + + if (isAndroid) { + let isWifiAvailable = await this.isWifiAvailable(this.ssid); + console.debug("isWifiAvailable: " + isWifiAvailable); + if(isWifiAvailable){ + console.debug("Wifi Credientials: " + this.ssid + " | " + this.password); + this.wifiWizard2.connect(this.ssid, true, this.password, this.algo).then(async (value) =>{ + let ssid_ = await this.wifiWizard2.getConnectedSSID(); + if(ssid_ == this.ssid){ + console.debug("Wifi Connected: Verified Access | " + value + " | " + ssid_); + setTimeout(() => { + this.swipeAttendanceWifi(ssid_); + },2000); + }else{ + this.showErrorInvalidWorkspace(); + } + }) + .catch((err) => { + console.debug(err); + this.showErrorForgetWifiConfiguration(); + }); + }else{ + console.debug("Wifi is not available considered your device is not in range"); + this.showErrorInvalidWorkspace(); + } + } else if (isIOS) { + this.wifiWizard2.iOSConnectNetwork(this.ssid,this.password).then(async (value) => { + let ssid_ = await this.wifiWizard2.getConnectedSSID(); + if(ssid_ == this.ssid){ + console.debug("Wifi Connected: Verified Access | " + value + " | " + ssid_); + setTimeout(() => { + this.swipeAttendanceWifi(ssid_); + },2000); + }else{ + this.showErrorInvalidWorkspace(); + } + }) + .catch((err) => { + console.debug(err); + this.showErrorInvalidWorkspace(); + }); + if(this.wifiWizard2.isWifiEnabled){ + } else{ + this.showWifiNotEnabled(); + } + } + }​ + + showWifiNotEnabled(){ + this.common.showErrorMessageDialog(()=>{ + this.openNativeSettings.open('wifi').then(()=>{}); + }, + this.ts.trPK("general", "ok"), + this.ts.trPK("general","wifi-not-enable-text")); + } + + showErrorInvalidWorkspace() { + this.closeModal(); + this.common.showErrorMessageDialog(()=>{ + }, + this.ts.trPK("general", "ok"), + this.ts.trPK("general","wifi-connection-failed-text")); + this.disconnectWifi(); + } + + showErrorForgetWifiConfiguration() { + this.closeModal(); + this.common.confirmAlertDialog(() => { + this.openNativeSettings.open('wifi').then(()=>{}); + }, this.ts.trPK('general', 'settings'), () => { + }, this.ts.trPK('general', 'cancel'), this.ts.trPK('vacation-rule', 'confirmation'), this.ts.trPK("general","forget-wifi-connection-text")); + this.disconnectWifi(); + } + + async disconnectWifi() { + const isAndroid = this.platform.is("android"); + const isIOS = this.platform.is("ios"); + if(isAndroid){ + await this.wifiWizard2.disconnect(this.ssid).catch((error)=>{ console.error(error) }); + await this.wifiWizard2.remove(this.ssid).catch((error)=>{ console.error(error) }); + console.debug("Wifi Removed"); + }else if(isIOS){ + await this.wifiWizard2.iOSDisconnectNetwork(this.ssid); + } + } + + async swipeAttendanceWifi(code:any) { + const request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest(); + request.PointType = 3; + request.Latitude = 0; + request.Longitude = 0; + request.QRValue = ""; + request.NFCValue = ""; + request.WifiValue = "100"; + request.UID = this.device.uuid; + request.UserName = this.userData.EMPLOYEE_NUMBER; + + this.attendance_service + .attendanceSwipeScanner(request, () => { + console.debug("Error inside in swipe attendance"); + this.closeModal(); + this.disconnectWifi(); + }) + .subscribe((result: Response) => { + this.disconnectWifi(); + if (this.common.validResponse(result)) { + this.ngZone.run(() => { + this.gifStatus = true; + }); + setTimeout(() => { + this.closeModal(); + // this.common.openAttenTrackingpage(); + }, 4000); + }else{ + console.debug(result); + this.closeModal(); + } + }); + } + + public closeModal() { + this.modalController.dismiss(); + } + + async isWifiAvailable(ssid:string){ + let avaialble_wifi = await this.wifiWizard2.scan(); + let find = avaialble_wifi.find(element => { + return element.SSID == ssid; + }); + + if (find === undefined) { + return false; + } else { + return find.SSID == ssid; + } + } +} diff --git a/Mohem/src/app/notification/home/home.component.html b/Mohem/src/app/notification/home/home.component.html index 124e0f0b..fe0b6141 100644 --- a/Mohem/src/app/notification/home/home.component.html +++ b/Mohem/src/app/notification/home/home.component.html @@ -19,7 +19,7 @@ {{ts.trPK('work-list','total')}}
{{ts.trPK('work-list','open-reqest')}}
- + @@ -90,13 +90,15 @@ -
- {{ts.trPK('work-list','No-data-available')}} +
+
+ {{ts.trPK('work-list','No-data-available')}} +
+
+ {{ts.trPK('work-list','No-data-available')}} +
-
- {{ts.trPK('work-list','No-data-available')}}
-
diff --git a/Mohem/src/app/notification/home/home.component.scss b/Mohem/src/app/notification/home/home.component.scss index 8ed6074c..c1faeb72 100644 --- a/Mohem/src/app/notification/home/home.component.scss +++ b/Mohem/src/app/notification/home/home.component.scss @@ -355,17 +355,18 @@ z-index: 99; ion-col{ background: white; border-radius: 12px; - padding-right: 10px; + padding-right: 30px; flex: none; ion-icon{ margin-right: 3px; - font-size: 14px; + font-size: 20px; margin-left: 3px; vertical-align: middle; } span{ - font-size: 12px; + font-size: 14px; vertical-align: middle; + margin: 5px; } } } @@ -439,21 +440,23 @@ font-size: 15px; font-size: 12px; color: #888; background-color: white; -width: 93%; -height: 30px; +width: auto; +height: 40px; border: 1px solid; -border-radius: 15px; +border-radius: 30px; +padding: 10px 30px; } .text-span-active{ font-size: 12px; -color: #888; +color:white; background-color:#269DB8; -width: 93%; -height: 30px; +width: auto; +height: 40px; border: 1px solid; -border-radius: 15px; +border-radius: 30px; +padding: 10px 30px; } .slideCss{ -width: 200px !important; +width: auto !important; } \ No newline at end of file diff --git a/Mohem/src/app/notification/home/home.component.ts b/Mohem/src/app/notification/home/home.component.ts index 5fc32b0e..ec019152 100644 --- a/Mohem/src/app/notification/home/home.component.ts +++ b/Mohem/src/app/notification/home/home.component.ts @@ -29,6 +29,7 @@ export class HomeComponent implements OnInit { private WorkListObj: WorkListRequest; WorkListResObj: any; notificationType = '1'; + public isLoading: boolean; pageNum = 1; rowsNo: number; noOfrows: number; @@ -49,7 +50,6 @@ export class HomeComponent implements OnInit { public noData = false; public isITG = false; public isSearch = false; - // public direction = 'ltr'; public direction: string; public ITGCount = 0; public ITGSegment: { name: string, code: any, data: any, style: boolean, names?: any }[] = []; @@ -176,6 +176,7 @@ export class HomeComponent implements OnInit { ngOnInit() { this.common.startLoading(); + this.isLoading = true; } ionViewWillEnter() { @@ -185,6 +186,7 @@ export class HomeComponent implements OnInit { this.receivedITGCount = false; this.showChart = false; this.common.startLoading(); + this.isLoading = true; if (this.infiniteScroll) { this.infiniteScroll.complete(); } @@ -202,7 +204,6 @@ export class HomeComponent implements OnInit { } callWorkListServices() { - // this.Details(); this.Count(); this.getAllPushNotificationFun(); } @@ -221,6 +222,27 @@ export class HomeComponent implements OnInit { assignDataToFilters() { this.filters[0].value = this.worklistNotifications.P_OPEN_NTF_NUMBER; + this.filters[1].value = this.totalHR; + this.filters[2].value = this.totalPO; + this.filters[3].value = this.totalPR; + this.filters[4].value = this.totalMR; + + if (this.totalHR === 0) { + this.data.datasets[0].data[0] = 0; + } + + if (this.totalPO === 0) { + this.data.datasets[0].data[1] = 0; + } + + if (this.totalPR === 0) { + this.data.datasets[0].data[2] = 0; + } + + if (this.totalMR === 0) { + this.data.datasets[0].data[3] = 0; + } + const openNotificationsArray = this.worklistNotifications.GetOpenNotificationsList; for (const notification of openNotificationsArray) { @@ -240,7 +262,17 @@ export class HomeComponent implements OnInit { } // this.data.datasets[0].data[4] = this.ITGCount; this.showChart = true; - this.common.stopLoading(); + // this.common.stopLoading(); + this.isLoading = false; + } + + checkLoadingStatus () { + if (this.showChart && this.receivedITGCount) { + this.common.stopLoading(); + return true; + } else { + return false; + } } activeFilter(index: number) { @@ -292,6 +324,7 @@ export class HomeComponent implements OnInit { if (result.data) { if (result.data.notificationType !== '' || result.data.selectedValue !== '' || result.data.itemType !== '') { this.common.startLoading(); + this.isLoading = true; this.showSearchButton = true; this.itemType = result.data.itemType; this.notificationType = result.data.notificationType; @@ -459,7 +492,8 @@ export class HomeComponent implements OnInit { this.newWorkListResponse = []; this.data.datasets[0].data[4] = this.ITGCount; this.showChart = true; - this.common.stopLoading(); + // this.common.stopLoading(); + this.isLoading =false; } } @@ -501,6 +535,7 @@ export class HomeComponent implements OnInit { clearSearch() { this.common.startLoading(); + this.isLoading = true; this.itemType = ''; this.selectedFilter = 'ALL'; this.isPostNoLoad = true; @@ -563,11 +598,11 @@ export class HomeComponent implements OnInit { Details() { this.workListService.getITGDetails('', '', this.isPostNoLoad) .subscribe((result: any) => { - this.receivedITGCount = true; this.ITGCount = result.TotalCount; this.totalRequestCount = this.totalRequestCount + result.TotalCount; this.data.datasets[0].data[4] = this.ITGCount; this.filters[5].value = result.TotalCount; + this.receivedITGCount = true; }); } @@ -612,6 +647,7 @@ export class HomeComponent implements OnInit { let count = 0; let ITEM: any; let NAME: any; + console.log(this.ITGSegment) for (let i = 1; i < this.ITGSegment.length; i++) { // tslint:disable-next-line: prefer-for-of for (let j = 0; j < this.ITGSegment[i].data.length; j++) { diff --git a/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.html b/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.html index 99ad265e..198a2606 100644 --- a/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.html +++ b/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.html @@ -1,97 +1,192 @@ - + - + - {{segmentVal.name}} +

{{segmentVal.name}}

- - - - - - -
- - -
- -
- -
- - -
-
-
- -
- - -
+ + + + + + + + + +
+ + +
+ +
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+
+
-
-
-
- - -
+ + +
+ + + + + +
+ + +
+
+ + + + + + + + + + + +
+ +
+
+ + + +
+

{{approvalInfo.Action}}

+
+
+
+

{{approvalInfo.Name}}

+
+

{{ 'submitAbsence, comments' | translate}}:

+

{{approvalInfo.Notes}}

+
+ +
-
+ + + + + + + + + - - - +
+ + +
+
+
+ +
+ + +
+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+ + + + + +
+ + +
+
+ + + +
@@ -107,7 +202,7 @@ - +
- - + --> + - -

Comment

-
- - - - {{object.Label}} - - - {{value}} - - - - {{value}} - - + +

Comment

+
+ + + + {{object.Label}} + + + {{value}} + + + + {{value}} + +
+ + + + + + diff --git a/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.ts b/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.ts index 1bd380f1..90162fe0 100644 --- a/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.ts +++ b/Mohem/src/app/notification/work-list-main-itg/work-list-main-itg.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { CommonService } from 'src/app/hmg-common/services/common/common.service'; import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service'; import { HomeComponent } from '../home/home.component'; @@ -7,7 +7,7 @@ import { itgRequest } from '../models/itgFormDetailsRequest'; import { ModalController } from '@ionic/angular'; import { WorkListReplacementRollComponent } from '../work-list-replacement-roll/work-list-replacement-roll.component'; import { WorkListReplacementItgComponent } from '../work-list-replacement-itg/work-list-replacement-itg.component'; - +import { IonSlides } from '@ionic/angular'; @Component({ selector: 'app-work-list-main-itg', @@ -15,6 +15,7 @@ import { WorkListReplacementItgComponent } from '../work-list-replacement-itg/wo styleUrls: ['./work-list-main-itg.component.scss'], }) export class WorkListMainItgComponent implements OnInit { + @ViewChild('slides') slides: IonSlides; public static APPROVAL = "Services/COCWS.svc/REST/ITGApproveRequest" public static REJECT = 'Services/COCWS.svc/REST/ITGRejectRequest' @@ -56,6 +57,7 @@ export class WorkListMainItgComponent implements OnInit { index2: number; direction: string; defaultSegment = ''; + public slideIndex = 0; constructor( public common: CommonService, public ts: TranslatorService, @@ -84,6 +86,8 @@ export class WorkListMainItgComponent implements OnInit { this.request.Comments = this.request_info.Comments; this.request.NewUserEMPId = this.request_info.NewUserEMPId; this.workListService.getITGFormDetails(this.request).subscribe((result: any) => { + console.log(this.request); + console.log(result); this.request_details = result.ITGRequest; this.grantInfo = result.ITGRequest.GrantFields; let count =0; @@ -160,10 +164,22 @@ export class WorkListMainItgComponent implements OnInit { } public segmentChangedClick(event: any) { - this.activeSegment = event.detail.value; + for(let i=0; i< this.segmentsArray.length; i++){ + if(this.segmentsArray[i].name === event.detail.value){ + this.slides.slideTo(i); + this.activeSegment = event.detail.value; + } + } + } + + slideChanged(event: any) { + this.slides.getActiveIndex().then(index => { + this.activeSegment = this.segmentsArray[index].name; + }); } skip() { + //check if the user clicked on all type of request if (this.is_all_items_sents) { for (let i = 1; i < this.all_request_names.length; i++) { for (let j = 0; j < this.all_request_names[i].data.length; j++) { @@ -187,24 +203,37 @@ export class WorkListMainItgComponent implements OnInit { } } } - } else { + } + //if user clicked on spicific type of ITG request + else { + console.log(this.all_request); for (let i = 0; i < this.all_request.length; i++) { // search for the request that clicked on all request + console.log("IF statment check the IDs:"); + console.log(this.request_info.ID); + console.log(this.all_request[i].ID); if (this.request_info.ID == this.all_request[i].ID) { // check if the ID for the request is found. this.index = i + 1; + console.log("value of i: "+i); + console.log("value of index: "+this.index); if (this.index !== this.all_request.length) { // check if its last one to redirecte to home otherwise to next request. this.clearDataArray(); + console.log(this.all_request[this.index]); + console.log(this.request_name) this.changeITGForm(this.all_request[this.index], this.request_name); - break; + return; } else { + console.log("no 1"); this.common.sharedService.setSharedData(true, 'loadWorkList'); this.common.openNotificationPage(); - break; + return; } - } else { - this.common.sharedService.setSharedData(true, 'loadWorkList'); - this.common.openNotificationPage(); - break; - } + } + // else { + // console.log("no 2"); + // this.common.sharedService.setSharedData(true, 'loadWorkList'); + // this.common.openNotificationPage(); + // return; + // } } } } @@ -468,5 +497,4 @@ export class WorkListMainItgComponent implements OnInit { } } - } diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.html b/Mohem/src/app/notification/worklist-main/worklist-main.component.html index 2adc87d2..c4ac77fc 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.html +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.html @@ -1,471 +1,400 @@ - + - -
- -
{{getPassNotificationDetails.SUBJECT}}
- + +
+ +
{{getPassNotificationDetails.SUBJECT}}
+ - - {{'worklistMain, details-emp'| translate}} + + {{'worklistMain, details-emp'| translate}} - - - {{'worklistMain, action' | translate}} - + + + {{'worklistMain, action' | translate}} + - - {{'worklistMain, attach-file' | translate}} + + {{'worklistMain, attach-file' | translate}} - - - {{'worklistMain, info'| translate}} - - + + + {{'worklistMain, info'| translate}} + + - - -
{{pInformation}}
- -
- - - - - - - - -
- - - - - - - -
- -
-
-
-
- -
-
- - -
- {{ts.trPK('worklistMain','employee-on-leave')}}
- - - - - -
- - - - - -
- - - - -
-
-
- - - - -
-
- - - -
- -
- - -
- -
-
-
- -
- - -
- - - - - - - -
- - - - -
- - -
- - - -
- - -
-
- - - - -
- - -
- - - -
- - -
-
- - - -
- - -
- - - -
- - -
-
- - - -
- -
-
-
- - - - -
- - - - - - -
{{'userProfile, emp-detail' | translate}}
- -
- - - -
- -
-
- - - -
- -
-
- - - -
- -
-
- - - -
- -
-
- - - -
- -
-
- - - -
- -
-
- - - -
- -
-
- - - -
- -
-
- - + + + + + - -
- - + + +
+ + + + +
+ +
+ + +
+ +
+
+ + + + +
+ +
+ + +
+ +
+
+ + + +
+ +
+ + +
+ +
+
+
+ +
+
+
- -
+ - + +
+ {{'userProfile, emp-detail' | translate}}
+ +
+ + + +
+ +
+
+ + + +
+ +
+
+ + + +
+ +
+
+ + + +
+ +
+
+ + + +
+ +
+
+ + + +
+ +
+
+ + + +
+ +
+
+ + + +
+ +
+
+ + + + +
+ + +
+
+ + + +
+ + +
+
+
+
+ +
-
-
+ + + -
-
-
- - - -
-

{{ 'general, empty' | translate}}

-
-
- -
- - -
-
- -
-
- - - {{actionHistory.NAME}} - - -
-
-
- Note: {{actionHistory.NOTE}} -
-
-
+ + + + -
- Note: {{actionHistory.NOTE}} + + +
+

{{ 'general, empty' | translate}}

+
+
+ +
+ +
+
+ +
- + + + {{actionHistory.NAME}} + -
-
- {{actionHistory.ACTION}} +
+
+
+ Note: {{actionHistory.NOTE}} +
+
- - {{actionHistory.NOTIFICATION_DATE| dateString }} - -
- -
- -
+
- +
+ Note: {{actionHistory.NOTE}} - - - - - - +
+ -
-

{{ 'general, notAttch' | translate}}

-
+
+
+ {{actionHistory.ACTION}} - -
+ + {{actionHistory.NOTIFICATION_DATE| dateString }} + +
+ +
+ +
+ + + + + + + + + + + + + +
+

{{ 'general, notAttch' | translate}}

+
+ + + +
+ + + + + {{i+1 }}. {{attachList.FILE_NAME}} + + + + + + + + +
+
+
+
+
+ + +
{{pInformation}}
+ +
+ + +
+ + + +
+ +
+
+
+
- - - - - {{i+1 }}. {{attachList.FILE_NAME}} - - +
+ {{ts.trPK('worklistMain','employee-on-leave')}}
+ -
-
- - -
+ +
+ + +
+ + + +
+
+
- + + + +
+
+ + - - -
-
-
-
+
+ +
+ + +
+ +
+
+
+
+ + + + + + +
+
+
+
- +
-
{{'worklistMain, Tran_Succ' | translate}}
-
+ +
{{'worklistMain, Tran_Succ' | translate}}
+
+
@@ -511,41 +440,41 @@ - {{approve_label}} + {{approve_label}} - {{close_label}} + {{close_label}} - {{reject_label}} + {{reject_label}} - {{reqInfo_label}} + {{reqInfo_label}} - {{'worklistMain, skip' | translate}} + {{'worklistMain, skip' | translate}} - {{'worklistMain, more' | translate}} + {{'worklistMain, more' | translate}} - + diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.scss b/Mohem/src/app/notification/worklist-main/worklist-main.component.scss index 785d9226..ecf60347 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.scss +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.scss @@ -292,3 +292,14 @@ ion-card{ .tabBar{ height:70px } + +.cardAlignTextEn{ + text-align: left; +} +.cardAlignTextAr{ + text-align: right; +} + +.padding-zero { + padding: 0px !important; +} \ No newline at end of file diff --git a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts index 6b31e493..4297bb79 100644 --- a/Mohem/src/app/notification/worklist-main/worklist-main.component.ts +++ b/Mohem/src/app/notification/worklist-main/worklist-main.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ElementRef } from "@angular/core"; +import { Component, OnInit, ElementRef, ViewChild } from "@angular/core"; import { CommonService } from "src/app/hmg-common/services/common/common.service"; import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; import { WorkListBodyRequest } from "../models/NotificationBodyReq"; @@ -7,9 +7,7 @@ import { AbsenceNotificatonBodyResponse } from "../models/AbsenceNotificationBod import { NotificatonButtonResponse } from "../models/NotificationButtonRes"; import { WorkListActionRequest } from "../models/NotificationActionReq"; import { WorkListButtonRequest } from "../models/NotificationButtonReq"; -// import { isDate } from 'angular6-json-schema-form'; import { MenuResponse } from "src/app/hmg-common/services/menu/models/menu-response"; -import { LoginRequest } from "src/app/hmg-common/services/authentication/models/login.request"; import { WorklistMainService } from "../service/work-list.main.service"; import { HomeComponent } from "src/app/notification/home/home.component"; import { TextInput } from 'src/app/uI-elements/text.input'; @@ -36,8 +34,7 @@ import { WorkListReplacementRollComponent } from '../work-list-replacement-roll/ import { WorkListRfcComponent } from '../work-list-rfc/work-list-rfc.component'; import { ApplyActionModalComponent } from '../apply-action-modal/apply-action-modal.component'; import { GetOpenNotificationsResponse } from 'src/app/hmg-common/services/dashbored/models/GetOpenNotificationsResponse'; - - +import { IonSlides } from '@ionic/angular'; @Component({ selector: "app-worklist-main", @@ -45,6 +42,7 @@ import { GetOpenNotificationsResponse } from 'src/app/hmg-common/services/dashbo styleUrls: ["./worklist-main.component.scss"] }) export class WorklistMainComponent implements OnInit { + @ViewChild('slides') slides: IonSlides; private WorkListBodyObj: WorkListBodyRequest; private WorkListButtonsObj: WorkListButtonRequest; private WorkListActionObj: WorkListActionRequest; @@ -78,7 +76,7 @@ export class WorklistMainComponent implements OnInit { P_PAGE_NUM: number = 1; P_PAGE_LIMIT: number = 100; notificationCount: any; - activeSegment: any = "item-req"; + activeSegment: any = 'item-req'; lines_note_limit: any = 24; attachmentRes: any = []; private WorkListActionHistoryObj: WorkListActionHistoryRequest; @@ -119,18 +117,15 @@ export class WorklistMainComponent implements OnInit { private modalCtrl: ModalController, public dashboredService: DashboredService, public authService: AuthenticationService - - - ) { + ) { this.direction = TranslatorService.getCurrentLanguageName() + console.log("ENAD TEST LANG: "+this.direction); this.WorkListActionHistoryObj = new WorkListActionHistoryRequest(); this.WorkListActionHistoryObj.P_PAGE_NUM = 1; this.WorkListActionHistoryObj.P_PAGE_LIMIT = this.P_PAGE_LIMIT; - } ngOnInit() { - this.selEmp = this.common.sharedService.getSharedData( MenuResponse.SHARED_SEL_EMP, false @@ -139,38 +134,64 @@ export class WorklistMainComponent implements OnInit { this.authService.loadAuthenticatedUser().subscribe((user: AuthenticatedUser) => { if (user) { this.selEmp = user.ASSIGNMENT_NUMBER; - } }); } - //name=document.getElementById('notificationDynamicFields').value; - //removeElement('parentDiv', name);" - - - //var navbar = document.getElementById("notificationDynamicFields").value; - // document.querySelector('svg .gauge.chart > text').remove(); - // var inputValue = (document.getElementById("notificationDynamicFields")).value; - - console.log(" this.selEmp" + this.selEmp); this.intializeNotificationDetail(); - - } + public segmentChanged(event: any) { this.activeSegment = event.detail.value; + if(this.activeSegment === 'item-req') + { + this.slides.slideTo(0); + } + else if(this.activeSegment === 'action-history') + { + this.slides.slideTo(1); + } + else if(this.activeSegment === 'attach') + { + this.slides.slideTo(2); + } + else if(this.activeSegment === 'info') + { + this.slides.slideTo(3); + } console.log(" event.detail.value: " + event.detail.value); } - intializeNotificationDetail() { + public slideChanged(event: any) { + this.slides.getActiveIndex().then(index => { + console.log(index); + console.log(event); + if(index === 0) + { + this.activeSegment = 'item-req'; + } + else if(index === 1) + { + this.activeSegment = 'action-history'; + } + else if(index === 2) + { + this.activeSegment = 'attach'; + } + else if(index === 3) + { + this.activeSegment = 'info'; + } + console.log(this.activeSegment); + }); + } + + public intializeNotificationDetail() { this.approveDis = false; this.rejectDis = false; this.requestDis = false; this.moreDisabled = true; this.closeDis = false; - // this.approve_label=""; - // this.reject_label=""; - // this.reqInfo_label=""; if (this.messageSuccess) { document.getElementById("notificationDynamicFields").innerHTML = ""; @@ -181,7 +202,6 @@ export class WorklistMainComponent implements OnInit { false ); - console.log("for next()" + this.getPassNotificationDetails.ROW_NUM); this.notificationArray = [] this.subordinatesleaveList = []; this.notificationArray = this.common.sharedService.getSharedData( @@ -255,7 +275,6 @@ export class WorklistMainComponent implements OnInit { this.worklistMainService .getMONotificationBody(notificationBodyObj) .subscribe((result: MONotificatonBodyResponse) => { - //this.handleWorkListBodyResult(result, "MO"); }); } @@ -263,8 +282,6 @@ export class WorklistMainComponent implements OnInit { this.worklistMainService .getPONotificationBody(notificationBodyObj) .subscribe((result: PONotificatonBodyResponse) => { - // console.log(result.GetPoNotificationBodyList.POHeader[0].BUYER); - // this.handleWorkListBodyResult(result, "PO"); }); } @@ -307,13 +324,10 @@ export class WorklistMainComponent implements OnInit { console.log(this.notificationBodyRes[0].Collection_Notification); } - // getDimensions(this.notificationBodyRes) { let obj = (this.notificationBodyRes[0].Collection_Notification).filter(function (list) { return list.SEGMENT_NAME === "END_DATE" || list.SEGMENT_NAME === "START_DATE"; }); - // return obj; - // } this.getSubordinatesleave(obj) } } else if (Type == "PR") { @@ -325,8 +339,6 @@ export class WorklistMainComponent implements OnInit { } } //End handleWorkListBodyResult - - getNotificationButtons(notificationButtonsObj) { this.notificationButtonRes = []; this.worklistMainService @@ -365,7 +377,7 @@ export class WorklistMainComponent implements OnInit { this.moreDisabled = false; } - } // valid it + } } } } // End handleWorkListButtonsResult @@ -398,8 +410,6 @@ export class WorklistMainComponent implements OnInit { // this.openNotificationsDashboard(); this.nextNotfification(); }, 5000); - - } } // valid it } @@ -430,11 +440,8 @@ export class WorklistMainComponent implements OnInit { public nextNotfification() { - //let itemExist = false; if (document.getElementById("notificationDynamicFields") != null) { - document.getElementById("notificationDynamicFields").innerHTML = ""; - } let itemNo = this.getPassNotificationDetails.ROW_NUM; console.log(itemNo); @@ -455,10 +462,8 @@ export class WorklistMainComponent implements OnInit { if (this.notificationArray[index].REQUEST_TYPE == "MO") { this.common.openWorklistMainMRPage() } else { - this.intializeNotificationDetail(); } - } else { this.common.openNotificationPage(); @@ -483,9 +488,6 @@ export class WorklistMainComponent implements OnInit { if (this.notificationDynamicAttributeArr[i].ATTRIBUTE_TYPE === "number") { obj.ATTRIBUTE_NUMBER_VALUE = (document.getElementById(this.notificationDynamicAttributeArr[i].ATTRIBUTE_NAME) as HTMLInputElement).value; } - // else if (isDate(responseAttrDic[key])) { - // obj.ATTRIBUTE_DATE_VALUE = responseAttrDic[key]; - // } else if (this.notificationDynamicAttributeArr[i].ATTRIBUTE_TYPE == "VARCHAR2") { obj.ATTRIBUTE_TEXT_VALUE = (document.getElementById(this.notificationDynamicAttributeArr[i].ATTRIBUTE_NAME) as HTMLInputElement).value; } @@ -502,8 +504,6 @@ export class WorklistMainComponent implements OnInit { this.P_RESPOND_ATTRIBUTES_TBL.push(obj); } - console.log("b" + this.P_RESPOND_ATTRIBUTES_TBL); - if ( ButtonAction == "APPROVED" || ButtonAction == "REJECTED" || @@ -528,7 +528,6 @@ export class WorklistMainComponent implements OnInit { this.P_RESPOND_ATTRIBUTES_TBL, WorklistMainComponent.PASS_RES_ATTR ); - // this.applyAction(this.WorkListActionObj); if (ButtonAction === "APPROVED") { this.confirmMsg = this.ts.trPK('worklistMain', 'approveMsg') @@ -543,7 +542,6 @@ export class WorklistMainComponent implements OnInit { } else if (ButtonAction === "CLOSE") { this.confirmMsg = this.ts.trPK('worklistMain', 'closeMsg') - } this.common.confirmAlertDialogAction( @@ -553,15 +551,8 @@ export class WorklistMainComponent implements OnInit { () => { }, this.ts.trPK('general', 'cancel'), this.ts.trPK('vacation-rule', 'confirmation'), this.confirmMsg) - - // this.openApplyModal(this.WorkListActionObj); - - } - - - if (ButtonAction == "RFC") { // alert("Return For Correction"); this.WorkListActionObj.P_ACTION_MODE = ButtonAction; @@ -581,12 +572,6 @@ export class WorklistMainComponent implements OnInit { //this.common.openWorklistRFCPage(); this.openRFCModal(); } else if (ButtonAction == "ANSWER_INFO") { - // this.navCtrl.push("WorkListReplacmentRollPage", { - // pQuestion: this.pQuestion, - // passNotificationInfo: this.getPassNotificationDetails, - // passActionMode: ButtonAction, - // passResAttr: this.P_RESPOND_ATTRIBUTES_TBL - // }); this.common.sharedService.setSharedData(this.pQuestion, "pQuestion"); this.common.sharedService.setSharedData( this.getPassNotificationDetails, @@ -610,11 +595,6 @@ export class WorklistMainComponent implements OnInit { ) { // alert("multi option: "+ ButtonAction); this.WorkListActionObj.P_ACTION_MODE = ButtonAction; - // this.navCtrl.push("WorkListReplacmentRollPage", { - // passNotificationInfo: this.getPassNotificationDetails, - // passActionMode: ButtonAction, - // passResAttr: this.P_RESPOND_ATTRIBUTES_TBL - // }); this.common.sharedService.setSharedData( this.getPassNotificationDetails, WorklistMainComponent.PASS_NOTIFICATION_INFO @@ -628,8 +608,6 @@ export class WorklistMainComponent implements OnInit { WorklistMainComponent.PASS_RES_ATTR ); console.log("c" + this.P_RESPOND_ATTRIBUTES_TBL); - - // this.common.openWorklistRollReplacement(); this.openRepRolModal(); } else if ( ButtonAction == "UPDATE_ACTION" || @@ -655,11 +633,6 @@ export class WorklistMainComponent implements OnInit { this.getPassNotificationDetails, AbsenceNotificatonBodyResponse.NOT_WORKLIST ); - // this.navCtrl.push("SubmitAbsencePage", { - // dirfromNotificationPage: true, - // submitAbsObjList: this.notificationBodyRes[0].Collection_Notification - // }); - //this.common.openConfirmAbsece(); this.dirfromNotificationPage = true, this.common.sharedService.setSharedData( this.dirfromNotificationPage, @@ -689,9 +662,6 @@ export class WorklistMainComponent implements OnInit { } openActionHistory() { - // this.navCtrl.push("WorkListActionHistoryPage", { - // passNotificationInfo: this.getPassNotificationDetails - // }); this.common.sharedService.setSharedData( this.getPassNotificationDetails, WorklistMainComponent.PASS_NOTIFICATION_INFO @@ -699,12 +669,7 @@ export class WorklistMainComponent implements OnInit { this.common.openWorklistHistoryPage(); } - - openSupportDocuments() { - // this.navCtrl.push("WorkListAttachPage", { - // passNotificationInfo: this.getPassNotificationDetails - // }); this.common.sharedService.setSharedData( this.getPassNotificationDetails, WorklistMainComponent.PASS_NOTIFICATION_INFO @@ -723,8 +688,6 @@ export class WorklistMainComponent implements OnInit { handleNotificationResAttrResult(result) { if (this.common.validResponse(result)) { - // this.sharedData.setSharedData(result, WorKListResponse.SHARED_DATA); - this.NotRespondAttributeList = []; result.NotificationGetRespondAttributesList; if ( @@ -859,52 +822,32 @@ export class WorklistMainComponent implements OnInit { } public checkLines(note) { - - if (note && note != null) { - - return (note.length > this.lines_note_limit) ? true : false; - - } - - - return false; }; - public turnCateFun(actionHis) { for (let i = 0; i < actionHis.length; i++) { actionHis[i].visible = false; - } - this.actionHistoryRes = actionHis; console.log("test"); } async openMoreActions() { - - - - const modal = await this.modalCtrl.create({ component: MoreActionModalComponent, backdropDismiss: false, - }); modal.cssClass = 'note-modal'; - modal.onDidDismiss() .then((data) => { console.log(data.data); - if (data.data == "cancel" || data.data == undefined) { return; } else { - // this.selectedAction = data.data; this.actionType = data.data.BUTTON_ACTION; console.log(this.actionType); @@ -912,21 +855,14 @@ export class WorklistMainComponent implements OnInit { this.actionButton(this.actionType); } }); - return await modal.present(); - - - - } - async OpenAttachFiles(value, Type) { - + async OpenAttachFiles(value, Type) { this.common.sharedService.setSharedData({ displayData: value, TypeData: Type }, 'WorkListAttachViewPage') const modal = await this.modalCtrl.create({ component: WorkListAttachViewComponent }); - return await modal.present(); } @@ -934,7 +870,6 @@ export class WorklistMainComponent implements OnInit { ///calling getSubleave getSubordinatesleave(list) { - console.log(list); let to; let from; @@ -946,33 +881,20 @@ export class WorklistMainComponent implements OnInit { from = list[i].DATE_VALUE; } } - console.log(new Date(to)); - console.log(new Date(from)); - - - - const request = new GetSubordinatesLeavesRequest(); request.P_DATE_FROM = "/Date(" + Date.parse(from) + '+0300' + ")/";//new Date(from); request.P_DATE_TO = "/Date(" + Date.parse(to) + '+0300' + ")/" //new Date(to); request.P_SELECTED_EMPLOYEE_NUMBER = this.selEmp; - // ="'/Date(" + Date.parse(from) + ")'" - - this.dashboredService.getSubordinatesLeaves(request). subscribe((result: any) => { - this.handleSubordinatesLeavesResult(result); }); } + public handleSubordinatesLeavesResult(result) { if (this.common.validResponse(result)) { - // GetSubordinatesLeavesList it used in dashbored - // if (this.common.hasData(result.GetSubordinatesLeavesList)) { if (this.common.hasData(result.SubordinatesOnLeavesList)) { - this.subordinatesleaveList = result.SubordinatesOnLeavesList; - } } } @@ -984,6 +906,7 @@ export class WorklistMainComponent implements OnInit { this.handleSubmitterInfoResult(result); }); } + handleSubmitterInfoResult(result) { if (this.common.validResponse(result)) { // this.sharedData.setSharedData(result, WorKListResponse.SHARED_DATA); @@ -995,107 +918,66 @@ export class WorklistMainComponent implements OnInit { }// End handleWorkListButtonsResult async openRepRolModal() { - const modal = await this.modalCtrl.create({ component: WorkListReplacementRollComponent, backdropDismiss: false, - }); modal.cssClass = 'replaceRoll-modal'; - modal.onDidDismiss() .then((data) => { console.log(data.data); - if (data.data == "cancel" || data.data == undefined) { return; } else if (data.data == "Success") { - // this.openNotificationsDashboard(); this.nextNotfification(); - } }); - return await modal.present(); - - - - } async openRFCModal() { - - - - const modal = await this.modalCtrl.create({ component: WorkListRfcComponent, backdropDismiss: false, - }); modal.cssClass = 'replaceRoll-modal'; - modal.onDidDismiss() .then((data) => { console.log(data.data); - if (data.data == "cancel" || data.data == undefined) { return; } else if (data.data == "Success") { // this.openNotificationsDashboard(); this.nextNotfification(); - } }); - return await modal.present(); - - - - } - async openApplyModal(WorkListActionObj) { - this.common.sharedService.setSharedData(this.getPassNotificationDetails, WorklistMainComponent.PASS_NOTIFICATION_INFO); this.common.sharedService.setSharedData(WorkListActionObj, 'ApplyActionModalPage') - // this.common.sharedService.setSharedData( - // this.WorkListActionObj, - // WorklistMainPRComponent.PASS_NOTIFICATION_INFO - // ); - const modal = await this.modalCtrl.create({ component: ApplyActionModalComponent, backdropDismiss: false, - }); modal.cssClass = 'note-modal'; - modal.onDidDismiss() .then((data) => { console.log(data); // Here's your selected user! }); - - return await modal.present(); - } - - loadMoreActionHistory() { - if (!this.IsReachEnd) { console.log("doInfinite action history MR"); - this.worklistService.getActionHistory(this.WorkListActionHistoryObj). subscribe((result: any) => { if (this.common.validResponse(result)) { if (result.GetActionHistoryList != undefined) { this.P_PAGE_NUM++; this.WorkListActionHistoryObj.P_PAGE_NUM = this.P_PAGE_NUM; - (result.GetActionHistoryList).forEach(element => { if (element.ROW_NUM == element.NO_OF_ROWS) { this.IsReachEnd = true; @@ -1113,17 +995,12 @@ export class WorklistMainComponent implements OnInit { }// if response == 1 //this.pageNum++; // infiniteScroll.target.complete(); - }); } else { console.log("no doInfinite action history MR"); - - //if (infiniteScroll) - //infiniteScroll.target.complete(); } }//end infiniteScroll - openNotificationsDashboard() { this.dashboredService.getOpenNotifications('', '', this.isPostNoLoad).subscribe((result: GetOpenNotificationsResponse) => { if (this.common.validResponse(result)) { @@ -1133,5 +1010,4 @@ export class WorklistMainComponent implements OnInit { } }); } - } diff --git a/Mohem/src/app/profile/home/home.component.html b/Mohem/src/app/profile/home/home.component.html index 261988e0..86ee5a08 100644 --- a/Mohem/src/app/profile/home/home.component.html +++ b/Mohem/src/app/profile/home/home.component.html @@ -20,7 +20,8 @@
diff --git a/Mohem/src/app/profile/home/home.component.scss b/Mohem/src/app/profile/home/home.component.scss index d60f3b9c..23f91321 100644 --- a/Mohem/src/app/profile/home/home.component.scss +++ b/Mohem/src/app/profile/home/home.component.scss @@ -18,21 +18,13 @@ ion-col.colBold, ion-col.colBold > label{ // background-color: #d9d7d7 !important; -.menubutton{ - white-space: normal; - color: var(--light); - text-transform: capitalize; - min-height: 39px; - background: #f0ecec; - font-size: 2rem; - position: absolute; - width: 35px !important; - height: 19px; - box-shadow: 3px 0px 7px 0px #c5c2c2; - border-radius: 50%; - - - } +.menubutton { + background: #f0ecec; + min-height: 39px; + width: 35px !important; + height: 20px; + border-radius: 50%; +} .changeIcon{ /* background: #c1c1c1; */ diff --git a/Mohem/src/assets/imgs/check_padding.png b/Mohem/src/assets/imgs/check_padding.png new file mode 100644 index 00000000..9434b89c Binary files /dev/null and b/Mohem/src/assets/imgs/check_padding.png differ diff --git a/Mohem/src/assets/imgs/edit-image.svg b/Mohem/src/assets/imgs/edit-image.svg new file mode 100644 index 00000000..fc5a615a --- /dev/null +++ b/Mohem/src/assets/imgs/edit-image.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/Mohem/src/assets/imgs/rippleNFC.gif b/Mohem/src/assets/imgs/rippleNFC.gif index 85454c24..5ed39424 100644 Binary files a/Mohem/src/assets/imgs/rippleNFC.gif and b/Mohem/src/assets/imgs/rippleNFC.gif differ diff --git a/Mohem/src/assets/imgs/wifiConnect.gif b/Mohem/src/assets/imgs/wifiConnect.gif new file mode 100644 index 00000000..cdf56666 Binary files /dev/null and b/Mohem/src/assets/imgs/wifiConnect.gif differ diff --git a/Mohem/src/assets/imgs/wifi_icon.png b/Mohem/src/assets/imgs/wifi_icon.png new file mode 100644 index 00000000..9d112b82 Binary files /dev/null and b/Mohem/src/assets/imgs/wifi_icon.png differ diff --git a/Mohem/src/assets/localization/i18n.json b/Mohem/src/assets/localization/i18n.json index d47d9752..ac593c6b 100644 --- a/Mohem/src/assets/localization/i18n.json +++ b/Mohem/src/assets/localization/i18n.json @@ -887,6 +887,22 @@ "en": "NFC", "ar": "NFC" }, + "wifi-not-enable-text": { + "en": "The Wi-Fi is not enabled. Please enable it", + "ar": "يرجى تفعيل خدمة الواي فاي" + }, + "wifi-text": { + "en": "Wi-Fi", + "ar": "واي فاي" + }, + "wifi-connection-failed-text": { + "en": "Failed to validate, please visit the nearest receptions in the branch", + "ar": "فشل التحقق ، يرجى زيارة أقرب مكتب استقبال في الفرع" + }, + "forget-wifi-connection-text": { + "en": "Invalid Wi-Fi configuration exists with 'HMG-MOHEMM', please forget the Wi-Fi from settings.", + "ar": "فشل الاتصال بشبكة 'HMG-MOHEMM' الرجاء اختيار نسيت الاتصال من اعدادت الشبكة" + }, "qr-text": { "en": "QR Code", "ar": "الشفرة QR" @@ -914,6 +930,14 @@ "nfc-cancel": { "en": "CANCEL", "ar": "إلغاء" + }, + "wifi-connect-message": { + "en": "Please wait", + "ar": "أرجو الإنتظار" + }, + "success-attendance": { + "en": "Your attendance is marked successfully.", + "ar": "تم تسجيل حضورك بنجاح" } }, "home": { diff --git a/Mohem/src/theme/styles.scss b/Mohem/src/theme/styles.scss index 31c8d1ee..35c54fcc 100644 --- a/Mohem/src/theme/styles.scss +++ b/Mohem/src/theme/styles.scss @@ -1382,6 +1382,12 @@ border:0px --border-radius: 0.4cm; } +.wifi-modal { + --height: 10cm !important; + --width: 90% !important; + --border-radius: 0.4cm; +} + .monthview-datetable { @media screen and (min-width: 300px) and (max-width:360px) { *{ diff --git a/WifiWizard2.java b/WifiWizard2.java new file mode 100644 index 00000000..03647d0a --- /dev/null +++ b/WifiWizard2.java @@ -0,0 +1,1891 @@ +// /* +// * Copyright 2018 Myles McNamara +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +// package wifiwizard2; + +// import org.apache.cordova.*; + +// import java.util.List; +// import java.lang.InterruptedException; + +// import org.json.JSONArray; +// import org.json.JSONException; +// import org.json.JSONObject; + +// import android.annotation.SuppressLint; +// import android.app.PendingIntent; +// import android.content.pm.PackageManager; +// import android.content.BroadcastReceiver; +// import android.content.Intent; +// import android.content.IntentFilter; + +// import android.net.Network; +// import android.net.NetworkCapabilities; +// import android.net.NetworkInfo; +// import android.net.NetworkRequest; +// import android.net.DhcpInfo; + +// import android.net.wifi.WifiManager; +// import android.net.wifi.WifiConfiguration; +// import android.net.wifi.ScanResult; +// import android.net.wifi.WifiInfo; +// import android.net.wifi.SupplicantState; +// import android.net.wifi.WifiNetworkSpecifier; +// import android.net.ConnectivityManager; + +// import android.content.Context; +// import android.os.AsyncTask; +// import android.util.Log; +// import android.os.Build.VERSION; +// import android.os.PatternMatcher; + +// import java.net.URL; +// import java.net.InetAddress; +// import java.net.Inet4Address; +// import java.net.InterfaceAddress; +// import java.net.NetworkInterface; +// import java.net.HttpURLConnection; + +// import java.net.UnknownHostException; + +// public class WifiWizard2 extends CordovaPlugin { +// private boolean hiddenSSID = false; + +// private static final String TAG = "WifiWizard2"; +// private static final int API_VERSION = VERSION.SDK_INT; + +// private static final String ADD_NETWORK = "add"; +// private static final String REMOVE_NETWORK = "remove"; +// private static final String CONNECT_NETWORK = "connect"; +// private static final String DISCONNECT_NETWORK = "disconnectNetwork"; +// private static final String DISCONNECT = "disconnect"; +// private static final String LIST_NETWORKS = "listNetworks"; +// private static final String START_SCAN = "startScan"; +// private static final String GET_SCAN_RESULTS = "getScanResults"; +// private static final String GET_CONNECTED_SSID = "getConnectedSSID"; +// private static final String GET_CONNECTED_BSSID = "getConnectedBSSID"; +// private static final String GET_CONNECTED_NETWORKID = "getConnectedNetworkID"; +// private static final String IS_WIFI_ENABLED = "isWifiEnabled"; +// private static final String SET_WIFI_ENABLED = "setWifiEnabled"; +// private static final String SCAN = "scan"; +// private static final String ENABLE_NETWORK = "enable"; +// private static final String DISABLE_NETWORK = "disable"; +// private static final String GET_SSID_NET_ID = "getSSIDNetworkID"; +// private static final String REASSOCIATE = "reassociate"; +// private static final String RECONNECT = "reconnect"; +// private static final String REQUEST_FINE_LOCATION = "requestFineLocation"; +// private static final String GET_WIFI_IP_ADDRESS = "getWifiIP"; +// private static final String GET_WIFI_ROUTER_IP_ADDRESS = "getWifiRouterIP"; +// private static final String CAN_PING_WIFI_ROUTER = "canPingWifiRouter"; +// private static final String CAN_CONNECT_TO_ROUTER = "canConnectToRouter"; +// private static final String CAN_CONNECT_TO_INTERNET = "canConnectToInternet"; +// private static final String IS_CONNECTED_TO_INTERNET = "isConnectedToInternet"; +// private static final String RESET_BIND_ALL = "resetBindAll"; +// private static final String SET_BIND_ALL = "setBindAll"; +// private static final String GET_WIFI_IP_INFO = "getWifiIPInfo"; + + + +// private static final int SCAN_RESULTS_CODE = 0; // Permissions request code for getScanResults() +// private static final int SCAN_CODE = 1; // Permissions request code for scan() +// private static final int LOCATION_REQUEST_CODE = 2; // Permissions request code +// private static final int WIFI_SERVICE_INFO_CODE = 3; +// private static final String ACCESS_FINE_LOCATION = android.Manifest.permission.ACCESS_FINE_LOCATION; + +// private static int LAST_NET_ID = -1; +// // This is for when SSID or BSSID is requested but permissions have not been granted for location +// // we store whether or not BSSID was requested, to recall the getWifiServiceInfo fn after permissions are granted +// private static boolean bssidRequested = false; + +// private WifiManager wifiManager; +// private CallbackContext callbackContext; +// private JSONArray passedData; + +// private ConnectivityManager connectivityManager; +// private ConnectivityManager.NetworkCallback networkCallback; + +// // Store AP, previous, and desired wifi info +// private AP previous, desired; + +// private PendingIntent pending_intent_net_req_received; +// private final BroadcastReceiver networkChangedReceiver = new NetworkChangedReceiver(); +// private static final IntentFilter NETWORK_STATE_CHANGED_FILTER = new IntentFilter(); + +// static { +// NETWORK_STATE_CHANGED_FILTER.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); +// } + +// /** +// * WEP has two kinds of password, a hex value that specifies the key or a character string used to +// * generate the real hex. This checks what kind of password has been supplied. The checks +// * correspond to WEP40, WEP104 & WEP232 +// */ +// private static boolean getHexKey(String s) { +// if (s == null) { +// return false; +// } + +// int len = s.length(); +// if (len != 10 && len != 26 && len != 58) { +// return false; +// } + +// for (int i = 0; i < len; ++i) { +// char c = s.charAt(i); +// if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) { +// return false; +// } +// } +// return true; +// } + +// @Override +// public void initialize(CordovaInterface cordova, CordovaWebView webView) { +// super.initialize(cordova, webView); +// this.wifiManager = (WifiManager) cordova.getActivity().getApplicationContext().getSystemService(Context.WIFI_SERVICE); +// this.connectivityManager = (ConnectivityManager) cordova.getActivity().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); +// } + +// @Override +// public boolean execute(String action, JSONArray data, CallbackContext callbackContext) +// throws JSONException { + +// this.callbackContext = callbackContext; +// this.passedData = data; + +// // Actions that do not require WiFi to be enabled +// if (action.equals(IS_WIFI_ENABLED)) { +// this.isWifiEnabled(callbackContext); +// return true; +// } else if (action.equals(SET_WIFI_ENABLED)) { +// this.setWifiEnabled(callbackContext, data); +// return true; +// } else if (action.equals(REQUEST_FINE_LOCATION)) { +// this.requestLocationPermission(LOCATION_REQUEST_CODE); +// return true; +// } else if (action.equals(GET_WIFI_ROUTER_IP_ADDRESS)) { + +// String ip = getWiFiRouterIP(); + +// if ( ip == null || ip.equals("0.0.0.0")) { +// callbackContext.error("NO_VALID_ROUTER_IP_FOUND"); +// return true; +// } else { +// callbackContext.success(ip); +// return true; +// } + +// } else if (action.equals(GET_WIFI_IP_ADDRESS) || action.equals(GET_WIFI_IP_INFO)) { +// String[] ipInfo = getWiFiIPAddress(); +// String ip = ipInfo[0]; +// String subnet = ipInfo[1]; +// if (ip == null || ip.equals("0.0.0.0")) { +// callbackContext.error("NO_VALID_IP_IDENTIFIED"); +// return true; +// } + +// // Return only IP address +// if( action.equals( GET_WIFI_IP_ADDRESS ) ){ +// callbackContext.success(ip); +// return true; +// } + +// // Return Wifi IP Info (subnet and IP as JSON object) +// JSONObject result = new JSONObject(); + +// result.put("ip", ip); +// result.put("subnet", subnet); + +// callbackContext.success(result); +// return true; +// } + +// boolean wifiIsEnabled = verifyWifiEnabled(); +// if (!wifiIsEnabled) { +// callbackContext.error("WIFI_NOT_ENABLED"); +// return true; // Even though enable wifi failed, we still return true and handle error in callback +// } + +// // Actions that DO require WiFi to be enabled +// if (action.equals(ADD_NETWORK)) { +// this.add(callbackContext, data); +// } else if (action.equals(IS_CONNECTED_TO_INTERNET)) { +// this.canConnectToInternet(callbackContext, true); +// } else if (action.equals(CAN_CONNECT_TO_INTERNET)) { +// this.canConnectToInternet(callbackContext, false); +// } else if (action.equals(CAN_PING_WIFI_ROUTER)) { +// this.canConnectToRouter(callbackContext, true); +// } else if (action.equals(CAN_CONNECT_TO_ROUTER)) { +// this.canConnectToRouter(callbackContext, false); +// } else if (action.equals(ENABLE_NETWORK)) { +// this.enable(callbackContext, data); +// } else if (action.equals(DISABLE_NETWORK)) { +// this.disable(callbackContext, data); +// } else if (action.equals(GET_SSID_NET_ID)) { +// this.getSSIDNetworkID(callbackContext, data); +// } else if (action.equals(REASSOCIATE)) { +// this.reassociate(callbackContext); +// } else if (action.equals(RECONNECT)) { +// this.reconnect(callbackContext); +// } else if (action.equals(SCAN)) { +// this.scan(callbackContext, data); +// } else if (action.equals(REMOVE_NETWORK)) { +// this.remove(callbackContext, data); +// } else if (action.equals(CONNECT_NETWORK)) { +// this.connect(callbackContext, data); +// } else if (action.equals(DISCONNECT_NETWORK)) { +// this.disconnectNetwork(callbackContext, data); +// } else if (action.equals(LIST_NETWORKS)) { +// this.listNetworks(callbackContext); +// } else if (action.equals(START_SCAN)) { +// this.startScan(callbackContext); +// } else if (action.equals(GET_SCAN_RESULTS)) { +// this.getScanResults(callbackContext, data); +// } else if (action.equals(DISCONNECT)) { +// this.disconnect(callbackContext); +// } else if (action.equals(GET_CONNECTED_SSID)) { +// this.getConnectedSSID(callbackContext); +// } else if (action.equals(GET_CONNECTED_BSSID)) { +// this.getConnectedBSSID(callbackContext); +// } else if (action.equals(GET_CONNECTED_NETWORKID)) { +// this.getConnectedNetworkID(callbackContext); +// } else if (action.equals(RESET_BIND_ALL)) { +// this.resetBindAll(callbackContext); +// } else if (action.equals(SET_BIND_ALL)) { +// this.setBindAll(callbackContext); +// } else { +// callbackContext.error("Incorrect action parameter: " + action); +// // The ONLY time to return FALSE is when action does not exist that was called +// // Returning false results in an INVALID_ACTION error, which translates to an error callback invoked on the JavaScript side +// // All other errors should be handled with the fail callback (callbackContext.error) +// // @see https://cordova.apache.org/docs/en/latest/guide/platforms/android/plugin.html +// return false; +// } + +// return true; +// } + +// /** +// * Scans networks and sends the list back on the success callback +// * +// * @param callbackContext A Cordova callback context +// * @param data JSONArray with [0] == JSONObject +// * @return true +// */ +// private boolean scan(final CallbackContext callbackContext, final JSONArray data) { +// Log.v(TAG, "Entering startScan"); +// final ScanSyncContext syncContext = new ScanSyncContext(); + +// final BroadcastReceiver receiver = new BroadcastReceiver() { +// public void onReceive(Context context, Intent intent) { +// Log.v(TAG, "Entering onReceive"); + +// synchronized (syncContext) { +// if (syncContext.finished) { +// Log.v(TAG, "In onReceive, already finished"); +// return; +// } +// syncContext.finished = true; +// context.unregisterReceiver(this); +// } + +// Log.v(TAG, "In onReceive, success"); +// getScanResults(callbackContext, data); +// } +// }; + +// final Context context = cordova.getActivity().getApplicationContext(); + +// Log.v(TAG, "Submitting timeout to threadpool"); + +// cordova.getThreadPool().submit(new Runnable() { + +// public void run() { + +// Log.v(TAG, "Entering timeout"); + +// final int TEN_SECONDS = 10000; + +// try { +// Thread.sleep(TEN_SECONDS); +// } catch (InterruptedException e) { +// Log.e(TAG, "Received InterruptedException e, " + e); +// // keep going into error +// } + +// Log.v(TAG, "Thread sleep done"); + +// synchronized (syncContext) { +// if (syncContext.finished) { +// Log.v(TAG, "In timeout, already finished"); +// return; +// } +// syncContext.finished = true; +// context.unregisterReceiver(receiver); +// } + +// Log.v(TAG, "In timeout, error"); +// callbackContext.error("TIMEOUT_WAITING_FOR_SCAN"); +// } + +// }); + +// Log.v(TAG, "Registering broadcastReceiver"); +// context.registerReceiver( +// receiver, +// new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) +// ); + +// if (!wifiManager.startScan()) { +// Log.v(TAG, "Scan failed"); +// callbackContext.error("SCAN_FAILED"); +// return false; +// } + +// Log.v(TAG, "Starting wifi scan"); +// return true; +// } + +// /** +// * This methods adds a network to the list of available WiFi networks. If the network already +// * exists, then it updates it. +// * +// * @return true if add successful, false if add fails +// * @params callbackContext A Cordova callback context. +// * @params data JSON Array with [0] == SSID, [1] == password +// */ +// private boolean add(CallbackContext callbackContext, JSONArray data) { + +// Log.d(TAG, "WifiWizard2: add entered."); + + +// try { +// // data's order for ANY object is +// // 0: SSID +// // 1: authentication algorithm, +// // 2: authentication information +// // 3: whether or not the SSID is hidden +// String newSSID = data.getString(0); +// String newPass = data.getString(2); +// String authType = data.getString(1); +// boolean isHiddenSSID = data.getBoolean(3); + +// if(API_VERSION >= 29){ +// // Remove Double Quotes +// newSSID = newSSID.replace("\"", ""); +// newPass = newPass.replace("\"", ""); + +// this.networkCallback = new ConnectivityManager.NetworkCallback() { +// @Override +// public void onAvailable(Network network) { +// connectivityManager.bindProcessToNetwork(network); +// Log.d(TAG, "onAvailable"); +// callbackContext.success("onAvailable"); +// } +// @Override +// public void onUnavailable() { +// super.onUnavailable(); +// Log.d(TAG, "onUnavailable"); +// callbackContext.error("onUnavailable"); +// } +// }; + +// // Connect Wifi using WifiNetworkSpecifier +// WifiNetworkSpecifier.Builder builder = new WifiNetworkSpecifier.Builder(); +// builder.setIsHiddenSsid(this.hiddenSSID); + +// if (newSSID.endsWith("#")) { +// newSSID = newSSID.replace("#", ""); +// builder.setSsidPattern(new PatternMatcher(newSSID, PatternMatcher.PATTERN_PREFIX)); +// }else { +// builder.setSsid(newSSID); +// } +// builder.setWpa2Passphrase(newPass); + +// WifiNetworkSpecifier wifiNetworkSpecifier = builder.build(); + +// NetworkRequest.Builder networkRequestBuilder1 = new NetworkRequest.Builder(); +// networkRequestBuilder1.addTransportType(NetworkCapabilities.TRANSPORT_WIFI); +// //removeCapability added for hotspots without internet +// networkRequestBuilder1.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); +// networkRequestBuilder1.setNetworkSpecifier(wifiNetworkSpecifier); + +// NetworkRequest nr = networkRequestBuilder1.build(); +// //timeout add because "No devices found" wasn't handled correct and doesn't throw Unavailable +// connectivityManager.requestNetwork(nr, this.networkCallback, 30000); + +// }else{ + +// // Initialize the WifiConfiguration object +// WifiConfiguration wifi = new WifiConfiguration(); +// wifi.hiddenSSID = this.hiddenSSID; +// wifi.SSID = newSSID; +// wifi.preSharedKey = newPass; +// wifi.status = WifiConfiguration.Status.ENABLED; +// wifi.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); +// wifi.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); +// wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); +// wifi.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); +// wifi.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); +// wifi.allowedProtocols.set(WifiConfiguration.Protocol.RSN); +// wifi.allowedProtocols.set(WifiConfiguration.Protocol.WPA); + +// wifi.networkId = ssidToNetworkId(newSSID); + +// // Set network to highest priority (deprecated in API >= 26) +// if(API_VERSION < 26) { +// wifi.priority = getMaxWifiPriority(wifiManager) + 1; +// } + +// // After processing authentication types, add or update network +// if(wifi.networkId == -1) { // -1 means SSID configuration does not exist yet + +// int newNetId = wifiManager.addNetwork(wifi); +// if( newNetId > -1 ){ +// callbackContext.success( newNetId ); +// } else { +// callbackContext.error( "ERROR_ADDING_NETWORK" ); +// } + +// } else { + +// int updatedNetID = wifiManager.updateNetwork(wifi); + +// if(updatedNetID == -1) +// updatedNetID = wifiManager.addNetwork(wifi); + +// if(updatedNetID > -1) { +// callbackContext.success( updatedNetID ); +// } else { +// callbackContext.error("ERROR_UPDATING_NETWORK"); +// } + +// } + +// // WifiManager configurations are presistent for API 26+ +// if(API_VERSION < 26) { +// wifiManager.saveConfiguration(); // Call saveConfiguration for older < 26 API +// } +// } + +// return true; + + +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; +// } +// } + +// /** +// * This method connects a network. +// * +// * @param callbackContext A Cordova callback context +// * @param data JSON Array, with [0] being SSID to connect +// */ +// private void enable(CallbackContext callbackContext, JSONArray data) { +// Log.d(TAG, "WifiWizard2: enable entered."); + +// if (!validateData(data)) { +// callbackContext.error("ENABLE_INVALID_DATA"); +// Log.d(TAG, "WifiWizard2: enable invalid data."); +// return; +// } + +// String ssidToEnable = ""; +// String bindAll = "false"; +// String waitForConnection = "false"; + +// try { +// ssidToEnable = data.getString(0); +// bindAll = data.getString(1); +// waitForConnection = data.getString(2); +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return; +// } + +// int networkIdToEnable = ssidToNetworkId(ssidToEnable); + +// try { + +// if(networkIdToEnable > -1) { + +// Log.d(TAG, "Valid networkIdToEnable: attempting connection"); + +// // Bind all requests to WiFi network (only necessary for Lollipop+ - API 21+) +// if(bindAll.equals("true")) { +// registerBindALL(networkIdToEnable); +// } + +// if(wifiManager.enableNetwork(networkIdToEnable, true)) { + +// if( waitForConnection.equals("true") ){ +// callbackContext.success("NETWORK_ENABLED"); +// return; +// } else { +// new ConnectAsync().execute(callbackContext, networkIdToEnable); +// return; +// } + +// } else { +// callbackContext.error("ERROR_ENABLING_NETWORK"); +// return; +// } + +// } else { +// callbackContext.error("UNABLE_TO_ENABLE"); +// return; +// } + +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return; +// } + +// } + +// /** +// * This method disables a network. +// * +// * @param callbackContext A Cordova callback context +// * @param data JSON Array, with [0] being SSID to connect +// * @return true if network disconnected, false if failed +// */ +// private boolean disable(CallbackContext callbackContext, JSONArray data) { +// Log.d(TAG, "WifiWizard2: disable entered."); + +// if (!validateData(data)) { +// callbackContext.error("DISABLE_INVALID_DATA"); +// Log.d(TAG, "WifiWizard2: disable invalid data"); +// return false; +// } + +// String ssidToDisable = ""; + +// try { +// ssidToDisable = data.getString(0); +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; +// } + +// int networkIdToDisconnect = ssidToNetworkId(ssidToDisable); + +// try { + +// if (networkIdToDisconnect > 0) { +// if(wifiManager.disableNetwork(networkIdToDisconnect)){ +// maybeResetBindALL(); +// callbackContext.success("Network " + ssidToDisable + " disabled!"); +// } else { +// callbackContext.error("UNABLE_TO_DISABLE"); +// } +// return true; +// } else { +// callbackContext.error("DISABLE_NETWORK_NOT_FOUND"); +// Log.d(TAG, "WifiWizard2: Network not found to disable."); +// return false; +// } + +// } catch (Exception e) { + +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; + +// } +// } + +// /** +// * This method removes a network from the list of configured networks. +// * +// * @param callbackContext A Cordova callback context +// * @param data JSON Array, with [0] being SSID to remove +// * @return true if network removed, false if failed +// */ +// private boolean remove(CallbackContext callbackContext, JSONArray data) { +// Log.d(TAG, "WifiWizard2: remove entered."); + +// if (!validateData(data)) { +// callbackContext.error("REMOVE_INVALID_DATA"); +// Log.d(TAG, "WifiWizard2: remove data invalid"); +// return false; +// } + +// // TODO: Verify the type of data! +// try { +// String ssidToDisconnect = data.getString(0); + +// if(API_VERSION >= 29){ +// if (networkCallback != null) { +// connectivityManager.unregisterNetworkCallback(networkCallback); +// networkCallback = null; +// } +// connectivityManager.releaseNetworkRequest(pending_intent_net_req_received); +// // WifiNetworkSuggestion wifiNetworkSuggestion = new WifiNetworkSuggestion.Builder() +// // .setSsid(ssidToDisconnect) +// // .build(); +// // List list = new ArrayList(); +// // list.add(wifiNetworkSuggestion); +// // wifiManager.removeNetworkSuggestions(list); +// callbackContext.success("NETWORK_REMOVED"); +// return true; +// } + + +// int networkIdToRemove = ssidToNetworkId(ssidToDisconnect); + +// if (networkIdToRemove > -1) { + +// if( wifiManager.removeNetwork(networkIdToRemove) ){ + +// // Configurations persist by default in API 26+ +// if (API_VERSION < 26) { +// wifiManager.saveConfiguration(); +// } + +// callbackContext.success("NETWORK_REMOVED"); + +// } else { + +// callbackContext.error( "UNABLE_TO_REMOVE" ); +// } + +// return true; +// } else { +// callbackContext.error("REMOVE_NETWORK_NOT_FOUND"); +// Log.d(TAG, "WifiWizard2: Network not found, can't remove."); +// return false; +// } +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; +// } +// } + +// /** +// * This method connects a network. +// * +// * @param callbackContext A Cordova callback context +// * @param data JSON Array, with [0] being SSID to connect +// */ +// private void connect(CallbackContext callbackContext, JSONArray data) { +// Log.d(TAG, "WifiWizard2: connect entered."); + +// if(API_VERSION >= 29){ +// // No need to connect, its already connected via WifiNetworkSpecifier at add(...) method +// callbackContext.success("NETWORK_CONNECTION_COMPLETED"); +// return; +// } + +// if (!validateData(data)) { +// callbackContext.error("CONNECT_INVALID_DATA"); +// Log.d(TAG, "WifiWizard2: connect invalid data."); +// return; +// } + +// String ssidToConnect = ""; +// String bindAll = "false"; + +// try { +// ssidToConnect = data.getString(0); +// bindAll = data.getString(1); +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return; +// } + +// int networkIdToConnect = ssidToNetworkId(ssidToConnect); + +// if (networkIdToConnect > -1) { +// // We disable the network before connecting, because if this was the last connection before +// // a disconnect(), this will not reconnect. + +// Log.d(TAG, "Valid networkIdToConnect: attempting connection"); + +// // Bind all requests to WiFi network (only necessary for Lollipop+ - API 21+) +// if( bindAll.equals("true") ){ +// registerBindALL(networkIdToConnect); +// } + +// if (API_VERSION >= 26) { +// // wifiManager.disconnect(); +// } else { +// wifiManager.disableNetwork(networkIdToConnect); +// } + +// wifiManager.enableNetwork(networkIdToConnect, true); + +// if (API_VERSION >= 26) { +// // wifiManager.reassociate(); +// } + +// new ConnectAsync().execute(callbackContext, networkIdToConnect); +// return; + +// } else { +// callbackContext.error("INVALID_NETWORK_ID_TO_CONNECT"); +// return; +// } +// } + +// /** +// * Wait for connection before returning error or success +// * +// * This method will wait up to 60 seconds for WiFi connection to specified network ID be in COMPLETED state, otherwise will return error. +// * +// * @param callbackContext +// * @param networkIdToConnect +// * @return +// */ +// private class ConnectAsync extends AsyncTask { +// CallbackContext callbackContext; +// @Override +// protected void onPostExecute(String[] results) { +// String error = results[0]; +// String success = results[1]; +// if (error != null) { +// this.callbackContext.error(error); +// } else { +// this.callbackContext.success(success); +// } +// } + +// @Override +// protected String[] doInBackground(Object... params) { +// this.callbackContext = (CallbackContext) params[0]; +// int networkIdToConnect = (Integer) params[1]; + +// final int TIMES_TO_RETRY = 15; +// for (int i = 0; i < TIMES_TO_RETRY; i++) { + +// WifiInfo info = wifiManager.getConnectionInfo(); +// NetworkInfo.DetailedState connectionState = info +// .getDetailedStateOf(info.getSupplicantState()); + +// boolean isConnected = +// // need to ensure we're on correct network because sometimes this code is +// // reached before the initial network has disconnected +// info.getNetworkId() == networkIdToConnect && ( +// connectionState == NetworkInfo.DetailedState.CONNECTED || +// // Android seems to sometimes get stuck in OBTAINING_IPADDR after it has received one +// (connectionState == NetworkInfo.DetailedState.OBTAINING_IPADDR +// && info.getIpAddress() != 0) +// ); + +// if (isConnected) { +// return new String[]{ null, "NETWORK_CONNECTION_COMPLETED" }; +// } + +// Log.d(TAG, "WifiWizard: Got " + connectionState.name() + " on " + (i + 1) + " out of " + TIMES_TO_RETRY); +// final int ONE_SECOND = 1000; + +// try { +// Thread.sleep(ONE_SECOND); +// } catch (InterruptedException e) { +// Log.e(TAG, e.getMessage()); +// return new String[]{ "INTERRUPT_EXCEPT_WHILE_CONNECTING", null }; +// } +// } +// Log.d(TAG, "WifiWizard: Network failed to finish connecting within the timeout"); +// return new String[]{ "CONNECT_FAILED_TIMEOUT", null }; +// } +// } + +// /** +// * This method disconnects a network. +// * +// * @param callbackContext A Cordova callback context +// * @param data JSON Array, with [0] being SSID to connect +// * @return true if network disconnected, false if failed +// */ +// private boolean disconnectNetwork(CallbackContext callbackContext, JSONArray data) { +// Log.d(TAG, "WifiWizard2: disconnectNetwork entered."); +// if (!validateData(data)) { +// callbackContext.error("DISCONNECT_NET_INVALID_DATA"); +// Log.d(TAG, "WifiWizard2: disconnectNetwork invalid data"); +// return false; +// } + +// String ssidToDisconnect = ""; + +// // TODO: Verify type of data here! +// try { +// ssidToDisconnect = data.getString(0); +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; +// } + +// if(API_VERSION < 29){ +// int networkIdToDisconnect = ssidToNetworkId(ssidToDisconnect); + +// if(networkIdToDisconnect > 0) { + +// if(wifiManager.disableNetwork(networkIdToDisconnect)) { + +// maybeResetBindALL(); + +// // We also remove the configuration from the device (use "disable" to keep config) +// if( wifiManager.removeNetwork(networkIdToDisconnect) ){ +// callbackContext.success("Network " + ssidToDisconnect + " disconnected and removed!"); +// } else { +// callbackContext.error("DISCONNECT_NET_REMOVE_ERROR"); +// Log.d(TAG, "WifiWizard2: Unable to remove network!"); +// return false; +// } + +// } else { +// callbackContext.error("DISCONNECT_NET_DISABLE_ERROR"); +// Log.d(TAG, "WifiWizard2: Unable to disable network!"); +// return false; +// } + +// return true; +// } else { +// callbackContext.error("DISCONNECT_NET_ID_NOT_FOUND"); +// Log.d(TAG, "WifiWizard2: Network not found to disconnect."); +// return false; +// } +// } else { +// try{ +// ConnectivityManager cm = (ConnectivityManager) cordova.getActivity().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); +// cm.unregisterNetworkCallback(this.networkCallback); +// connectivityManager.bindProcessToNetwork(null); +// return true; +// } +// catch(Exception e) { +// callbackContext.error(e.getMessage()); +// return false; +// } +// } +// } + +// /** +// * This method disconnects the currently connected network. +// * +// * @param callbackContext A Cordova callback context +// * @return true if network disconnected, false if failed +// */ +// private boolean disconnect(CallbackContext callbackContext) { +// Log.d(TAG, "WifiWizard2: disconnect entered."); + +// if (wifiManager.disconnect()) { +// maybeResetBindALL(); +// callbackContext.success("Disconnected from current network"); +// return true; +// } else { +// callbackContext.error("ERROR_DISCONNECT"); +// return false; +// } +// } + +// /** +// * Reconnect Network +// *

+// * Reconnect to the currently active access point, if we are currently disconnected. This may +// * result in the asynchronous delivery of state change events. +// */ +// private boolean reconnect(CallbackContext callbackContext) { +// Log.d(TAG, "WifiWizard2: reconnect entered."); + +// if (wifiManager.reconnect()) { +// callbackContext.success("Reconnected network"); +// return true; +// } else { +// callbackContext.error("ERROR_RECONNECT"); +// return false; +// } +// } + +// /** +// * Reassociate Network +// *

+// * Reconnect to the currently active access point, even if we are already connected. This may +// * result in the asynchronous delivery of state change events. +// */ +// private boolean reassociate(CallbackContext callbackContext) { +// Log.d(TAG, "WifiWizard2: reassociate entered."); + +// if (wifiManager.reassociate()) { +// callbackContext.success("Reassociated network"); +// return true; +// } else { +// callbackContext.error("ERROR_REASSOCIATE"); +// return false; +// } +// } + +// /** +// * This method uses the callbackContext.success method to send a JSONArray of the currently +// * configured networks. +// * +// * @param callbackContext A Cordova callback context +// * @return true if network disconnected, false if failed +// */ +// private boolean listNetworks(CallbackContext callbackContext) { +// Log.d(TAG, "WifiWizard2: listNetworks entered."); +// @SuppressLint("MissingPermission") List wifiList = wifiManager.getConfiguredNetworks(); + +// JSONArray returnList = new JSONArray(); + +// for (WifiConfiguration wifi : wifiList) { +// returnList.put(wifi.SSID); +// } + +// callbackContext.success(returnList); + +// return true; +// } + +// /** +// * This method uses the callbackContext.success method to send a JSONArray of the scanned +// * networks. +// * +// * @param callbackContext A Cordova callback context +// * @param data JSONArray with [0] == JSONObject +// * @return true +// */ +// private boolean getScanResults(CallbackContext callbackContext, JSONArray data) { + +// if (cordova.hasPermission(ACCESS_FINE_LOCATION)) { + +// List scanResults = wifiManager.getScanResults(); + +// JSONArray returnList = new JSONArray(); + +// Integer numLevels = null; + +// if (!validateData(data)) { +// callbackContext.error("GET_SCAN_RESULTS_INVALID_DATA"); +// Log.d(TAG, "WifiWizard2: getScanResults invalid data"); +// return false; +// } else if (!data.isNull(0)) { +// try { +// JSONObject options = data.getJSONObject(0); + +// if (options.has("numLevels")) { +// Integer levels = options.optInt("numLevels"); + +// if (levels > 0) { +// numLevels = levels; +// } else if (options.optBoolean("numLevels", false)) { +// // use previous default for {numLevels: true} +// numLevels = 5; +// } +// } +// } catch (JSONException e) { +// e.printStackTrace(); +// callbackContext.error(e.toString()); +// return false; +// } +// } + +// for (ScanResult scan : scanResults) { +// /* +// * @todo - breaking change, remove this notice when tidying new release and explain changes, e.g.: +// * 0.y.z includes a breaking change to WifiWizard2.getScanResults(). +// * Earlier versions set scans' level attributes to a number derived from wifiManager.calculateSignalLevel. +// * This update returns scans' raw RSSI value as the level, per Android spec / APIs. +// * If your application depends on the previous behaviour, we have added an options object that will modify behaviour: +// * - if `(n == true || n < 2)`, `*.getScanResults({numLevels: n})` will return data as before, split in 5 levels; +// * - if `(n > 1)`, `*.getScanResults({numLevels: n})` will calculate the signal level, split in n levels; +// * - if `(n == false)`, `*.getScanResults({numLevels: n})` will use the raw signal level; +// */ + +// int level; + +// if (numLevels == null) { +// level = scan.level; +// } else { +// level = wifiManager.calculateSignalLevel(scan.level, numLevels); +// } + +// JSONObject lvl = new JSONObject(); +// try { +// lvl.put("level", level); +// lvl.put("SSID", scan.SSID); +// lvl.put("BSSID", scan.BSSID); +// lvl.put("frequency", scan.frequency); +// lvl.put("capabilities", scan.capabilities); +// lvl.put("timestamp", scan.timestamp); + +// if (API_VERSION >= 23) { // Marshmallow +// lvl.put("channelWidth", scan.channelWidth); +// lvl.put("centerFreq0", scan.centerFreq0); +// lvl.put("centerFreq1", scan.centerFreq1); +// } else { +// lvl.put("channelWidth", JSONObject.NULL); +// lvl.put("centerFreq0", JSONObject.NULL); +// lvl.put("centerFreq1", JSONObject.NULL); +// } + +// returnList.put(lvl); +// } catch (JSONException e) { +// e.printStackTrace(); +// callbackContext.error(e.toString()); +// return false; +// } +// } + +// callbackContext.success(returnList); +// return true; + +// } else { + +// requestLocationPermission(SCAN_RESULTS_CODE); +// return true; +// } + +// } + +// /** +// * This method uses the callbackContext.success method. It starts a wifi scanning +// * +// * @param callbackContext A Cordova callback context +// * @return true if started was successful +// */ +// private boolean startScan(CallbackContext callbackContext) { + +// if (wifiManager.startScan()) { +// callbackContext.success(); +// return true; +// } else { +// callbackContext.error("STARTSCAN_FAILED"); +// return false; +// } +// } + +// /** +// * This method returns the connected WiFi network ID (if connected) +// * +// * @return -1 if no network connected, or network id if connected +// */ +// private int getConnectedNetId() { +// int networkId = -1; + +// WifiInfo info = wifiManager.getConnectionInfo(); + +// if (info == null) { +// Log.d(TAG, "Unable to read wifi info"); +// return networkId; +// } + +// networkId = info.getNetworkId(); + +// if (networkId == -1) { +// Log.d(TAG, "NO_CURRENT_NETWORK_FOUND"); +// } + +// return networkId; +// } + +// /** +// * Get Network ID from SSID +// * +// * @param callbackContext A Cordova callback context +// * @param data JSON Array, with [0] being SSID to connect +// * @return true if network connected, false if failed +// */ +// private boolean getSSIDNetworkID(CallbackContext callbackContext, JSONArray data) { +// Log.d(TAG, "WifiWizard2: getSSIDNetworkID entered."); + +// if (!validateData(data)) { +// callbackContext.error("GET_SSID_INVALID_DATA"); +// Log.d(TAG, "WifiWizard2: getSSIDNetworkID invalid data."); +// return false; +// } + +// String ssidToGetNetworkID = ""; + +// try { +// ssidToGetNetworkID = data.getString(0); +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; +// } + +// int networkIdToConnect = ssidToNetworkId(ssidToGetNetworkID); +// callbackContext.success(networkIdToConnect); + +// return true; +// } + +// /** +// * This method returns the connected WiFi network ID (if connected) +// * +// * @param callbackContext A Cordova callback context +// * @return -1 if no network connected, or network id if connected +// */ +// private boolean getConnectedNetworkID(CallbackContext callbackContext) { +// int networkId = getConnectedNetId(); + +// if (networkId == -1) { +// callbackContext.error("GET_CONNECTED_NET_ID_ERROR"); +// return false; +// } + +// callbackContext.success(networkId); +// return true; +// } + +// /** +// * This method retrieves the SSID for the currently connected network +// * +// * @param callbackContext A Cordova callback context +// * @return true if SSID found, false if not. +// */ +// private boolean getConnectedSSID(CallbackContext callbackContext) { +// return getWifiServiceInfo(callbackContext, false); +// } + +// /** +// * This method retrieves the BSSID for the currently connected network +// * +// * @param callbackContext A Cordova callback context +// * @return true if SSID found, false if not. +// */ +// private boolean getConnectedBSSID(CallbackContext callbackContext) { +// return getWifiServiceInfo(callbackContext, true); +// } + +// /** +// * This method retrieves the WifiInformation for the (SSID or BSSID) currently connected network. +// * +// * @param callbackContext A Cordova callback context +// * @param basicIdentifier A flag to get BSSID if true or SSID if false. +// * @return true if SSID found, false if not. +// */ +// private boolean getWifiServiceInfo(CallbackContext callbackContext, boolean basicIdentifier) { +// if (API_VERSION >= 23 && !cordova.hasPermission(ACCESS_FINE_LOCATION)) { //Android 9 (Pie) or newer +// requestLocationPermission(WIFI_SERVICE_INFO_CODE); +// bssidRequested = basicIdentifier; +// return true; +// } else { +// WifiInfo info = wifiManager.getConnectionInfo(); + +// if (info == null) { +// callbackContext.error("UNABLE_TO_READ_WIFI_INFO"); +// return false; +// } + +// // Only return SSID or BSSID when actually connected to a network +// SupplicantState state = info.getSupplicantState(); +// if (!state.equals(SupplicantState.COMPLETED)) { +// callbackContext.error("CONNECTION_NOT_COMPLETED"); +// return false; +// } + +// String serviceInfo; +// if (basicIdentifier) { +// serviceInfo = info.getBSSID(); +// } else { +// serviceInfo = info.getSSID(); +// } + +// if (serviceInfo == null || serviceInfo.isEmpty() || serviceInfo == "0x") { +// callbackContext.error("WIFI_INFORMATION_EMPTY"); +// return false; +// } + +// // http://developer.android.com/reference/android/net/wifi/WifiInfo.html#getSSID() +// if (serviceInfo.startsWith("\"") && serviceInfo.endsWith("\"")) { +// serviceInfo = serviceInfo.substring(1, serviceInfo.length() - 1); +// } + +// callbackContext.success(serviceInfo); +// return true; +// } +// } + +// /** +// * This method retrieves the current WiFi status +// * +// * @param callbackContext A Cordova callback context +// * @return true if WiFi is enabled, fail will be called if not. +// */ +// private boolean isWifiEnabled(CallbackContext callbackContext) { +// boolean isEnabled = wifiManager.isWifiEnabled(); +// callbackContext.success(isEnabled ? "1" : "0"); +// return isEnabled; +// } + +// /** +// * This method takes a given String, searches the current list of configured WiFi networks, and +// * returns the networkId for the network if the SSID matches. If not, it returns -1. +// */ +// private int ssidToNetworkId(String ssid) { + +// try { + +// int maybeNetId = Integer.parseInt(ssid); +// Log.d(TAG, "ssidToNetworkId passed SSID is integer, probably a Network ID: " + ssid); +// return maybeNetId; + +// } catch (NumberFormatException e) { + +// List currentNetworks = wifiManager.getConfiguredNetworks(); +// int networkId = -1; + +// // For each network in the list, compare the SSID with the given one +// for (WifiConfiguration test : currentNetworks) { +// if (test.SSID != null && test.SSID.equals(ssid)) { +// networkId = test.networkId; +// } +// } + +// return networkId; + +// } +// } + +// /** +// * This method enables or disables the wifi +// */ +// private boolean setWifiEnabled(CallbackContext callbackContext, JSONArray data) { +// if (!validateData(data)) { +// callbackContext.error("SETWIFIENABLED_INVALID_DATA"); +// Log.d(TAG, "WifiWizard2: setWifiEnabled invalid data"); +// return false; +// } + +// String status = ""; + +// try { +// status = data.getString(0); +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; +// } + +// if (wifiManager.setWifiEnabled(status.equals("true"))) { +// callbackContext.success(); +// return true; +// } else { +// callbackContext.error("ERROR_SETWIFIENABLED"); +// return false; +// } +// } + +// /** +// * This method will check if WiFi is enabled, and enable it if not, waiting up to 10 seconds for +// * it to enable +// * +// * @return True if wifi is enabled, false if unable to enable wifi +// */ +// private boolean verifyWifiEnabled() { + +// Log.d(TAG, "WifiWizard2: verifyWifiEnabled entered."); + +// if (!wifiManager.isWifiEnabled()) { + +// Log.i(TAG, "Enabling wi-fi..."); + +// if (wifiManager.setWifiEnabled(true)) { +// Log.i(TAG, "Wi-fi enabled"); +// } else { +// Log.e(TAG, "VERIFY_ERROR_ENABLE_WIFI"); +// return false; +// } + +// // This happens very quickly, but need to wait for it to enable. A little busy wait? +// int count = 0; + +// while (!wifiManager.isWifiEnabled()) { +// if (count >= 10) { +// Log.i(TAG, "Took too long to enable wi-fi, quitting"); +// return false; +// } + +// Log.i(TAG, "Still waiting for wi-fi to enable..."); + +// try { +// Thread.sleep(1000L); +// } catch (InterruptedException ie) { +// // continue +// } + +// count++; +// } + +// // If we make it this far, wifi should be enabled by now +// return true; + +// } else { + +// return true; + +// } + +// } + +// /** +// * Format and return WiFi IPv4 Address +// * @return +// */ +// private String[] getWiFiIPAddress() { +// WifiInfo wifiInfo = wifiManager.getConnectionInfo(); +// int ip = wifiInfo.getIpAddress(); + +// String ipString = formatIP(ip); +// String subnet = ""; + +// try { +// InetAddress inetAddress = InetAddress.getByName(ipString); +// subnet = getIPv4Subnet(inetAddress); +// } catch (Exception e) { +// } + +// return new String[]{ipString, subnet}; +// } + +// /** +// * Get WiFi Router IP from DHCP +// * @return +// */ +// private String getWiFiRouterIP() { +// DhcpInfo dhcp = wifiManager.getDhcpInfo(); +// int ip = dhcp.gateway; +// return formatIP(ip); +// } + +// /** +// * Format IPv4 Address +// * @param ip +// * @return +// */ +// private String formatIP(int ip) { +// return String.format( +// "%d.%d.%d.%d", +// (ip & 0xff), +// (ip >> 8 & 0xff), +// (ip >> 16 & 0xff), +// (ip >> 24 & 0xff) +// ); +// } + +// /** +// * Get IPv4 Subnet +// * @param inetAddress +// * @return +// */ +// public static String getIPv4Subnet(InetAddress inetAddress) { +// try { +// NetworkInterface ni = NetworkInterface.getByInetAddress(inetAddress); +// List intAddrs = ni.getInterfaceAddresses(); +// for (InterfaceAddress ia : intAddrs) { +// if (!ia.getAddress().isLoopbackAddress() && ia.getAddress() instanceof Inet4Address) { +// return getIPv4SubnetFromNetPrefixLength(ia.getNetworkPrefixLength()).getHostAddress() +// .toString(); +// } +// } +// } catch (Exception e) { +// } +// return ""; +// } + +// /** +// * Get Subnet from Prefix Length +// * @param netPrefixLength +// * @return +// */ +// public static InetAddress getIPv4SubnetFromNetPrefixLength(int netPrefixLength) { +// try { +// int shift = (1 << 31); +// for (int i = netPrefixLength - 1; i > 0; i--) { +// shift = (shift >> 1); +// } +// String subnet = +// Integer.toString((shift >> 24) & 255) + "." + Integer.toString((shift >> 16) & 255) + "." +// + Integer.toString((shift >> 8) & 255) + "." + Integer.toString(shift & 255); +// return InetAddress.getByName(subnet); +// } catch (Exception e) { +// } +// return null; +// } + +// /** +// * Validate JSON data +// */ +// private boolean validateData(JSONArray data) { +// try { +// if (data == null || data.get(0) == null) { +// callbackContext.error("DATA_IS_NULL"); +// return false; +// } +// return true; +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// } +// return false; +// } + +// /** +// * Request ACCESS_FINE_LOCATION Permission +// * @param requestCode +// */ +// protected void requestLocationPermission(int requestCode) { +// cordova.requestPermission(this, requestCode, ACCESS_FINE_LOCATION); +// } + +// /** +// * Handle Android Permission Requests +// */ +// public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults) +// throws JSONException { + +// for (int r : grantResults) { +// if (r == PackageManager.PERMISSION_DENIED) { +// callbackContext.error( "PERMISSION_DENIED" ); +// return; +// } +// } + +// switch (requestCode) { +// case SCAN_RESULTS_CODE: +// getScanResults(callbackContext, passedData); // Call method again after permissions approved +// break; +// case SCAN_CODE: +// scan(callbackContext, passedData); // Call method again after permissions approved +// break; +// case LOCATION_REQUEST_CODE: +// callbackContext.success("PERMISSION_GRANTED"); +// break; +// case WIFI_SERVICE_INFO_CODE: +// getWifiServiceInfo(callbackContext, bssidRequested); +// break; +// } +// } + +// /** +// * Figure out what the highest priority network in the network list is and return that priority +// */ +// private static int getMaxWifiPriority(final WifiManager wifiManager) { +// final List configurations = wifiManager.getConfiguredNetworks(); +// int maxPriority = 0; +// for (WifiConfiguration config : configurations) { +// if (config.priority > maxPriority) { +// maxPriority = config.priority; +// } +// } + +// Log.d(TAG, "WifiWizard: Found max WiFi priority of " +// + maxPriority); + +// return maxPriority; +// } + +// /** +// * Check if device is connected to Internet +// */ +// private boolean canConnectToInternet(CallbackContext callbackContext, boolean doPing) { + +// try { + +// if ( hasInternetConnection(doPing) ) { +// // Send success as 1 to return true from Promise (handled in JS) +// callbackContext.success("1"); +// return true; +// } else { +// callbackContext.success("0"); +// return false; +// } + +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; +// } +// } + +// /** +// * Check if we can conenct to router via HTTP connection +// * +// * @param callbackContext +// * @param doPing +// * @return boolean +// */ +// private boolean canConnectToRouter(CallbackContext callbackContext, boolean doPing) { + +// try { + +// if (hasConnectionToRouter(doPing)) { +// // Send success as 1 to return true from Promise (handled in JS) +// callbackContext.success("1"); +// return true; +// } else { +// callbackContext.success("0"); +// return false; +// } + +// } catch (Exception e) { +// callbackContext.error(e.getMessage()); +// Log.d(TAG, e.getMessage()); +// return false; +// } +// } + +// /** +// * Check if The Device Is Connected to Internet +// * +// * @return true if device connect to Internet or return false if not +// */ +// public boolean hasInternetConnection(boolean doPing) { +// if (connectivityManager != null) { +// NetworkInfo info = connectivityManager.getActiveNetworkInfo(); +// if (info != null) { +// if (info.isConnected()) { +// if( doPing ){ +// return pingCmd("8.8.8.8"); +// } else { +// return isHTTPreachable("http://www.google.com/"); +// } +// } +// } +// } +// return false; +// } + +// /** +// * Check for connection to router by pinging router IP +// * @return +// */ +// public boolean hasConnectionToRouter( boolean doPing ) { + +// String ip = getWiFiRouterIP(); + +// if ( ip == null || ip.equals("0.0.0.0") || connectivityManager == null) { + +// return false; + +// } else { + +// NetworkInfo info = connectivityManager.getActiveNetworkInfo(); + +// if (info != null && info.isConnected()) { + +// if( doPing ){ +// return pingCmd(ip); +// } else { +// return isHTTPreachable("http://" + ip + "/"); +// } +// } else { +// return false; +// } + +// } + +// } + +// /** +// * Check if HTTP connection to URL is reachable +// * +// * @param checkURL +// * @return boolean +// */ +// public static boolean isHTTPreachable(String checkURL) { +// try { +// // make a URL to a known source +// URL url = new URL(checkURL); + +// // open a connection to that source +// HttpURLConnection urlConnect = (HttpURLConnection) url.openConnection(); + +// // trying to retrieve data from the source. If there +// // is no connection, this line will fail +// Object objData = urlConnect.getContent(); + +// } catch (Exception e) { +// e.printStackTrace(); +// return false; +// } + +// return true; +// } + +// /** +// * Method to Ping IP Address +// * +// * @param addr IP address you want to ping it +// * @return true if the IP address is reachable +// */ +// public boolean pingCmd(String addr) { + +// try { + +// String ping = "ping -c 1 -W 3 " + addr; +// Runtime run = Runtime.getRuntime(); +// Process pro = run.exec(ping); + +// try { +// pro.waitFor(); +// } catch (InterruptedException e) { +// Log.e(TAG, "InterruptedException error.", e); +// } + +// int exit = pro.exitValue(); + +// Log.d(TAG, "pingCmd exitValue" + exit); + +// if (exit == 0) { +// return true; +// } else { +// // ip address is not reachable +// return false; +// } +// } catch (UnknownHostException e) { +// Log.d(TAG, "UnknownHostException: " + e.getMessage()); +// } catch (Exception e) { +// Log.d(TAG, e.getMessage()); +// } + +// return false; +// } + +// /** +// * Network Changed Broadcast Receiver +// */ +// private class NetworkChangedReceiver extends BroadcastReceiver { + +// @Override +// public void onReceive(final Context context, final Intent intent) { + +// if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) { + +// Log.d(TAG, "NETWORK_STATE_CHANGED_ACTION"); + +// NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); +// WifiInfo info = WifiWizard2.this.wifiManager.getConnectionInfo(); + +// // Checks that you're connected to the desired network +// if (networkInfo.isConnected() && info.getNetworkId() > -1) { + +// final String ssid = info.getSSID().replaceAll("\"", ""); +// final String bssid = info.getBSSID(); + +// Log.d(TAG, "Connected to '" + ssid + "' @ " + bssid); + +// // Verify the desired network ID is what we actually connected to +// if ( desired != null && info.getNetworkId() == desired.apId ) { +// onSuccessfulConnection(); +// } else { +// Log.e(TAG, "Could not connect to the desired ssid: " + ssid); +// } + +// } + +// } + +// } + +// } + +// /** +// * Register Receiver for Network Changed to handle BindALL +// * @param netID +// */ +// private void registerBindALL(int netID){ + +// // Bind all requests to WiFi network (only necessary for Lollipop+ - API 21+) +// if( API_VERSION > 21 ){ +// Log.d(TAG, "registerBindALL: registering net changed receiver"); +// desired = new AP(netID,null,null); +// cordova.getActivity().getApplicationContext().registerReceiver(networkChangedReceiver, NETWORK_STATE_CHANGED_FILTER); +// } else { +// Log.d(TAG, "registerBindALL: API older than 21, bindall ignored."); +// } +// } + +// /** +// * Maybe reset bind all after disconnect/disable +// * +// * This method unregisters the network changed receiver, as well as setting null for +// * bindProcessToNetwork or setProcessDefaultNetwork to prevent future sockets from application +// * being routed through Wifi. +// */ +// private void maybeResetBindALL(){ + +// Log.d(TAG, "maybeResetBindALL"); + +// // desired should have a value if receiver is registered +// if( desired != null ){ + +// if( API_VERSION > 21 ){ + +// try { +// // Unregister net changed receiver -- should only be registered in API versions > 21 +// cordova.getActivity().getApplicationContext().unregisterReceiver(networkChangedReceiver); +// } catch (Exception e) {} + +// } + +// // Lollipop OS or newer +// if ( API_VERSION >= 23 ) { +// connectivityManager.bindProcessToNetwork(null); +// } else if( API_VERSION >= 21 && API_VERSION < 23 ){ +// connectivityManager.setProcessDefaultNetwork(null); +// } + +// if ( API_VERSION > 21 && networkCallback != null) { + +// try { +// // Same behavior as releaseNetworkRequest +// connectivityManager.unregisterNetworkCallback(networkCallback); // Added in API 21 +// } catch (Exception e) {} +// } + +// networkCallback = null; +// previous = null; +// desired = null; + +// } + +// } + +// /** +// * Will un-bind to network (use Cellular network) +// * +// * @param callbackContext A Cordova callback context +// */ +// private void resetBindAll(CallbackContext callbackContext) { +// Log.d(TAG, "WifiWizard2: resetBindALL"); + +// try { +// maybeResetBindALL(); +// callbackContext.success("Successfully reset BindALL"); +// } catch (Exception e) { +// Log.e(TAG, "InterruptedException error.", e); +// callbackContext.error("ERROR_NO_BIND_ALL"); +// } +// } + +// /** +// * Will bind to network (use Wifi network) +// * +// * @param callbackContext A Cordova callback context +// */ +// private void setBindAll(CallbackContext callbackContext) { +// Log.d(TAG, "WifiWizard2: setBindALL"); + +// try { +// int networkId = getConnectedNetId(); +// registerBindALL(networkId); +// callbackContext.success("Successfully bindAll to network"); +// } catch (Exception e) { +// Log.e(TAG, "InterruptedException error.", e); +// callbackContext.error("ERROR_CANT_BIND_ALL"); +// } +// } + + +// /** +// * Called after successful connection to WiFi when using BindAll feature +// * +// * This method is called by the NetworkChangedReceiver after network changed action, and confirming that we are in fact connected to wifi, +// * and the wifi we're connected to, is the correct network set in enable, or connect. +// */ +// private void onSuccessfulConnection() { +// // On Lollipop+ the OS routes network requests through mobile data +// // when phone is attached to a wifi that doesn't have Internet connection +// // We use the ConnectivityManager to force bind all requests from our process +// // to the wifi without internet +// // see https://android-developers.googleblog.com/2016/07/connecting-your-app-to-wi-fi-device.html + +// // Marshmallow OS or newer +// if ( API_VERSION >= 23 ) { + +// Log.d(TAG, "BindALL onSuccessfulConnection API >= 23"); + +// // Marshmallow (API 23+) or newer uses bindProcessToNetwork +// final NetworkRequest request = new NetworkRequest.Builder() +// .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) +// .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) //removeCapability added for hotspots without internet +// .build(); + +// networkCallback = new ConnectivityManager.NetworkCallback() { +// @Override +// public void onAvailable(Network network) { +// if( connectivityManager.bindProcessToNetwork(network) ){ +// Log.d(TAG, "bindProcessToNetwork TRUE onSuccessfulConnection"); +// } else { +// Log.d(TAG, "bindProcessToNetwork FALSE onSuccessfulConnection"); +// } +// } +// }; + +// connectivityManager.requestNetwork(request, networkCallback); + +// // Only lollipop (API 21 && 22) use setProcessDefaultNetwork, API < 21 already does this by default +// } else if( API_VERSION >= 21 && API_VERSION < 23 ){ + +// Log.d(TAG, "BindALL onSuccessfulConnection API >= 21 && < 23"); + +// // Lollipop (API 21-22) use setProcessDefaultNetwork (deprecated in API 23 - Marshmallow) +// final NetworkRequest request = new NetworkRequest.Builder() +// .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) +// .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) //removeCapability addded for hotspots without internet +// .build(); + +// networkCallback = new ConnectivityManager.NetworkCallback() { +// @Override +// public void onAvailable(Network network) { +// connectivityManager.setProcessDefaultNetwork(network); +// } +// }; + +// connectivityManager.requestNetwork(request, networkCallback); + +// } else { +// // Technically we should never reach this with older API, but just in case +// Log.d(TAG, "BindALL onSuccessfulConnection API older than 21, no need to do any binding"); +// networkCallback = null; +// previous = null; +// desired = null; + +// } +// } + +// /** +// * Class to store finished boolean in +// */ +// private class ScanSyncContext { + +// public boolean finished = false; +// } + +// /** +// * Used for storing access point information +// */ +// private static class AP { +// final String ssid, bssid; +// final int apId; + +// AP(int apId, final String ssid, final String bssid) { +// this.apId = apId; +// this.ssid = ssid; +// this.bssid = bssid; +// } + +// } +// } \ No newline at end of file