diff --git a/src/app/pages/landing/landing.page.ts b/src/app/pages/landing/landing.page.ts index 9785c56..8742333 100644 --- a/src/app/pages/landing/landing.page.ts +++ b/src/app/pages/landing/landing.page.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import { Router } from '@angular/router'; +import { Preferences } from '@capacitor/preferences'; import { AlertController, IonRouterOutlet, Platform } from '@ionic/angular'; import { TranslateService } from '@ngx-translate/core'; import { EnvService } from 'src/app/services/env.service'; @@ -50,26 +51,45 @@ export class LandingPage { } async confirmExitApp(): Promise { - const alert = await this.alertController.create({ - header: this.translate.instant('EXIT_APP'), - message: this.translate.instant('MSG.EXIT_APP'), - cssClass: ['alert-bg'], - buttons: [ - { - text: this.translate.instant('EXIT'), - handler: () => { - navigator['app'].exitApp(); + if (this.env.showExitAppAlert == "on") { + const alert = await this.alertController.create({ + header: this.translate.instant('EXIT_APP'), + message: this.translate.instant('MSG.EXIT_APP'), + inputs: [ + { + type: "checkbox", + label: this.translate.instant("MSG.TUTORIAL_NOT_SHOW_AGAIN"), + checked: false, + handler: async (result) => { + if (result.checked) { + this.env.showExitAppAlert = "off"; + } else { + this.env.showExitAppAlert = "on"; + } + await Preferences.set({ key: this.env.KEY_SHOW_EXIT_APP_ALERT, value: this.env.showExitAppAlert }); + } } - }, - { - text: this.translate.instant('RATE_THE_APP'), - handler: () => { - this.openGooglePlay(); + ], + cssClass: ['alert-bg', 'alert-input-no-border'], + buttons: [ + { + text: this.translate.instant('EXIT'), + handler: () => { + navigator['app'].exitApp(); + } + }, + { + text: this.translate.instant('RATE_THE_APP'), + handler: () => { + this.openGooglePlay(); + } } - } - ] - }); - await alert.present(); + ] + }); + await alert.present(); + } else { + navigator['app'].exitApp(); + } } } diff --git a/src/app/pages/setting/setting.page.html b/src/app/pages/setting/setting.page.html index 7768845..033978e 100644 --- a/src/app/pages/setting/setting.page.html +++ b/src/app/pages/setting/setting.page.html @@ -134,7 +134,7 @@ + (click)="exitApp()">

diff --git a/src/app/pages/setting/setting.page.ts b/src/app/pages/setting/setting.page.ts index 408364c..15752d4 100644 --- a/src/app/pages/setting/setting.page.ts +++ b/src/app/pages/setting/setting.page.ts @@ -127,27 +127,8 @@ export class SettingPage { alert.present(); } - async confirmExitApp(): Promise { - const alert = await this.alertController.create({ - header: this.translate.instant('EXIT_APP'), - message: this.translate.instant('MSG.EXIT_APP'), - cssClass: ['alert-bg'], - buttons: [ - { - text: this.translate.instant('EXIT'), - handler: () => { - navigator['app'].exitApp(); - } - }, - { - text: this.translate.instant('RATE_THE_APP'), - handler: () => { - this.openGooglePlay(); - } - } - ] - }); - await alert.present(); + exitApp() { + navigator['app'].exitApp(); } openGooglePlay(): void { diff --git a/src/app/services/env.service.ts b/src/app/services/env.service.ts index 3299e32..b077dea 100644 --- a/src/app/services/env.service.ts +++ b/src/app/services/env.service.ts @@ -75,6 +75,7 @@ export class EnvService { public showSendMessageButton: OnOffType = 'on'; public showSendEmailButton: OnOffType = 'on'; public showOpenFoodFactsButton: OnOffType = 'on'; + public showExitAppAlert: OnOffType = "on"; public debugMode: OnOffType = 'off'; public autoExitAppMin: 1 | 3 | 5 | -1 = -1; @@ -86,6 +87,7 @@ export class EnvService { public readonly KEY_LANGUAGE = "language"; public readonly KEY_COLOR = "color"; public readonly KEY_DEBUG_MODE = "debug-mode-on"; + public readonly KEY_SHOW_EXIT_APP_ALERT = "showExitAppAlert"; public readonly KEY_ORIENTATION = "orientation"; public readonly KEY_SCAN_RECORD_LOGGING = "scan-record-logging"; public readonly KEY_RECORDS_LIMIT = "recordsLimit"; @@ -852,6 +854,15 @@ export class EnvService { await this.toggleColorTheme(); } ); + await Preferences.get({ key: this.KEY_SHOW_EXIT_APP_ALERT }).then( + async result => { + if (result.value != null) { + this.showExitAppAlert = result.value as OnOffType; + } else { + this.showExitAppAlert = 'on'; + } + } + ); await Preferences.get({ key: this.KEY_DEBUG_MODE }).then( async result => { if (result.value != null) { @@ -1216,6 +1227,7 @@ export class EnvService { this.showOpenFoodFactsButton = 'on'; this.scanRecords = []; this.bookmarks = []; + this.showExitAppAlert = 'on'; this.debugMode = 'off'; this.autoExitAppMin = -1; } @@ -1349,6 +1361,9 @@ export class EnvService { this.showOpenFoodFactsButton = 'on'; await Preferences.set({ key: this.KEY_SHOW_OPEN_FOOD_FACTS_BUTTON, value: this.showOpenFoodFactsButton }); + this.showExitAppAlert = 'on'; + await Preferences.set({ key: this.KEY_SHOW_EXIT_APP_ALERT, value: this.showExitAppAlert }); + this.debugMode = 'off'; await Preferences.set({ key: this.KEY_DEBUG_MODE, value: this.debugMode }); diff --git a/src/global.scss b/src/global.scss index e755143..d1e7602 100644 --- a/src/global.scss +++ b/src/global.scss @@ -109,6 +109,15 @@ ion-tab-button:not(.tab-selected)::part(native):hover { opacity: 0.5; } +.alert-input-no-border .alert-checkbox-group { + border: 0px !important; +} + +.alert-input-no-border .alert-checkbox-label { + overflow: auto !important; + white-space: pre-line !important; +} + .alert-can-copy { user-select: text !important; }