mirror of
https://github.com/tomfong/simple-qr.git
synced 2025-06-28 12:09:58 +00:00
feat: allow user to hide exit app alert
This commit is contained in:
parent
c1c8a2171e
commit
04949d2bf9
5 changed files with 65 additions and 40 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { Preferences } from '@capacitor/preferences';
|
||||||
import { AlertController, IonRouterOutlet, Platform } from '@ionic/angular';
|
import { AlertController, IonRouterOutlet, Platform } from '@ionic/angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { EnvService } from 'src/app/services/env.service';
|
import { EnvService } from 'src/app/services/env.service';
|
||||||
|
@ -50,26 +51,45 @@ export class LandingPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
async confirmExitApp(): Promise<void> {
|
async confirmExitApp(): Promise<void> {
|
||||||
const alert = await this.alertController.create({
|
if (this.env.showExitAppAlert == "on") {
|
||||||
header: this.translate.instant('EXIT_APP'),
|
const alert = await this.alertController.create({
|
||||||
message: this.translate.instant('MSG.EXIT_APP'),
|
header: this.translate.instant('EXIT_APP'),
|
||||||
cssClass: ['alert-bg'],
|
message: this.translate.instant('MSG.EXIT_APP'),
|
||||||
buttons: [
|
inputs: [
|
||||||
{
|
{
|
||||||
text: this.translate.instant('EXIT'),
|
type: "checkbox",
|
||||||
handler: () => {
|
label: this.translate.instant("MSG.TUTORIAL_NOT_SHOW_AGAIN"),
|
||||||
navigator['app'].exitApp();
|
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
{
|
cssClass: ['alert-bg', 'alert-input-no-border'],
|
||||||
text: this.translate.instant('RATE_THE_APP'),
|
buttons: [
|
||||||
handler: () => {
|
{
|
||||||
this.openGooglePlay();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item *ngIf="isAndroid" class="ion-no-padding ripple-parent" detail="false" lines="none"
|
<ion-item *ngIf="isAndroid" class="ion-no-padding ripple-parent" detail="false" lines="none"
|
||||||
(click)="confirmExitApp()">
|
(click)="exitApp()">
|
||||||
<ion-icon class="ion-margin-start ion-padding-horizontal" color="danger" name="exit"></ion-icon>
|
<ion-icon class="ion-margin-start ion-padding-horizontal" color="danger" name="exit"></ion-icon>
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<p class="ion-padding pre-line">
|
<p class="ion-padding pre-line">
|
||||||
|
|
|
@ -127,27 +127,8 @@ export class SettingPage {
|
||||||
alert.present();
|
alert.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
async confirmExitApp(): Promise<void> {
|
exitApp() {
|
||||||
const alert = await this.alertController.create({
|
navigator['app'].exitApp();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openGooglePlay(): void {
|
openGooglePlay(): void {
|
||||||
|
|
|
@ -75,6 +75,7 @@ export class EnvService {
|
||||||
public showSendMessageButton: OnOffType = 'on';
|
public showSendMessageButton: OnOffType = 'on';
|
||||||
public showSendEmailButton: OnOffType = 'on';
|
public showSendEmailButton: OnOffType = 'on';
|
||||||
public showOpenFoodFactsButton: OnOffType = 'on';
|
public showOpenFoodFactsButton: OnOffType = 'on';
|
||||||
|
public showExitAppAlert: OnOffType = "on";
|
||||||
public debugMode: OnOffType = 'off';
|
public debugMode: OnOffType = 'off';
|
||||||
public autoExitAppMin: 1 | 3 | 5 | -1 = -1;
|
public autoExitAppMin: 1 | 3 | 5 | -1 = -1;
|
||||||
|
|
||||||
|
@ -86,6 +87,7 @@ export class EnvService {
|
||||||
public readonly KEY_LANGUAGE = "language";
|
public readonly KEY_LANGUAGE = "language";
|
||||||
public readonly KEY_COLOR = "color";
|
public readonly KEY_COLOR = "color";
|
||||||
public readonly KEY_DEBUG_MODE = "debug-mode-on";
|
public readonly KEY_DEBUG_MODE = "debug-mode-on";
|
||||||
|
public readonly KEY_SHOW_EXIT_APP_ALERT = "showExitAppAlert";
|
||||||
public readonly KEY_ORIENTATION = "orientation";
|
public readonly KEY_ORIENTATION = "orientation";
|
||||||
public readonly KEY_SCAN_RECORD_LOGGING = "scan-record-logging";
|
public readonly KEY_SCAN_RECORD_LOGGING = "scan-record-logging";
|
||||||
public readonly KEY_RECORDS_LIMIT = "recordsLimit";
|
public readonly KEY_RECORDS_LIMIT = "recordsLimit";
|
||||||
|
@ -852,6 +854,15 @@ export class EnvService {
|
||||||
await this.toggleColorTheme();
|
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(
|
await Preferences.get({ key: this.KEY_DEBUG_MODE }).then(
|
||||||
async result => {
|
async result => {
|
||||||
if (result.value != null) {
|
if (result.value != null) {
|
||||||
|
@ -1216,6 +1227,7 @@ export class EnvService {
|
||||||
this.showOpenFoodFactsButton = 'on';
|
this.showOpenFoodFactsButton = 'on';
|
||||||
this.scanRecords = [];
|
this.scanRecords = [];
|
||||||
this.bookmarks = [];
|
this.bookmarks = [];
|
||||||
|
this.showExitAppAlert = 'on';
|
||||||
this.debugMode = 'off';
|
this.debugMode = 'off';
|
||||||
this.autoExitAppMin = -1;
|
this.autoExitAppMin = -1;
|
||||||
}
|
}
|
||||||
|
@ -1349,6 +1361,9 @@ export class EnvService {
|
||||||
this.showOpenFoodFactsButton = 'on';
|
this.showOpenFoodFactsButton = 'on';
|
||||||
await Preferences.set({ key: this.KEY_SHOW_OPEN_FOOD_FACTS_BUTTON, value: this.showOpenFoodFactsButton });
|
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';
|
this.debugMode = 'off';
|
||||||
await Preferences.set({ key: this.KEY_DEBUG_MODE, value: this.debugMode });
|
await Preferences.set({ key: this.KEY_DEBUG_MODE, value: this.debugMode });
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,15 @@ ion-tab-button:not(.tab-selected)::part(native):hover {
|
||||||
opacity: 0.5;
|
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 {
|
.alert-can-copy {
|
||||||
user-select: text !important;
|
user-select: text !important;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue