chore: change to use @capacitor/preferences as storage

This commit is contained in:
Tom Fong 2022-10-16 14:05:25 +08:00
parent 438768d7b7
commit 63ea056c2a
35 changed files with 1073 additions and 434 deletions

View file

@ -19,6 +19,7 @@ dependencies {
implementation project(':capacitor-filesystem')
implementation project(':capacitor-haptics')
implementation project(':capacitor-keyboard')
implementation project(':capacitor-preferences')
implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar')
implementation project(':capacitor-toast')

View file

@ -39,6 +39,10 @@
"pkg": "@capacitor/keyboard",
"classpath": "com.capacitorjs.plugins.keyboard.KeyboardPlugin"
},
{
"pkg": "@capacitor/preferences",
"classpath": "com.capacitorjs.plugins.preferences.PreferencesPlugin"
},
{
"pkg": "@capacitor/splash-screen",
"classpath": "com.capacitorjs.plugins.splashscreen.SplashScreenPlugin"

View file

@ -32,6 +32,9 @@ project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/
include ':capacitor-keyboard'
project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor/keyboard/android')
include ':capacitor-preferences'
project(':capacitor-preferences').projectDir = new File('../node_modules/@capacitor/preferences/android')
include ':capacitor-splash-screen'
project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capacitor/splash-screen/android')

View file

@ -21,6 +21,7 @@ def capacitor_pods
pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
pod 'CapacitorPreferences', :path => '../../node_modules/@capacitor/preferences'
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
pod 'CapacitorToast', :path => '../../node_modules/@capacitor/toast'

15
package-lock.json generated
View file

@ -39,6 +39,7 @@
"@capacitor/haptics": "^4.0.1",
"@capacitor/ios": "^4.3.0",
"@capacitor/keyboard": "^4.0.1",
"@capacitor/preferences": "^4.0.1",
"@capacitor/splash-screen": "^4.1.0",
"@capacitor/status-bar": "^4.0.1",
"@capacitor/toast": "^4.0.1",
@ -2490,6 +2491,14 @@
"@capacitor/core": "^4.0.0"
}
},
"node_modules/@capacitor/preferences": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@capacitor/preferences/-/preferences-4.0.1.tgz",
"integrity": "sha512-FffJjKS4XcodUj/rtFtWizQ9q/oYDSn5opZ+JYwj/EkjiMWMhY/Pk9lN3vwQfp+VJrTt3hjr+bwKXjhTbYBqKw==",
"peerDependencies": {
"@capacitor/core": "^4.0.0"
}
},
"node_modules/@capacitor/splash-screen": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@capacitor/splash-screen/-/splash-screen-4.1.0.tgz",
@ -16346,6 +16355,12 @@
"integrity": "sha512-JZVci2v9jAKH0sIoNNZzmw/cWGXWf+KneLt0yDr/6YSs/2/tfuH10yOrUOhgrKFkR+fFj/rddTClQXUQ8Rqcrg==",
"requires": {}
},
"@capacitor/preferences": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@capacitor/preferences/-/preferences-4.0.1.tgz",
"integrity": "sha512-FffJjKS4XcodUj/rtFtWizQ9q/oYDSn5opZ+JYwj/EkjiMWMhY/Pk9lN3vwQfp+VJrTt3hjr+bwKXjhTbYBqKw==",
"requires": {}
},
"@capacitor/splash-screen": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/@capacitor/splash-screen/-/splash-screen-4.1.0.tgz",

View file

@ -48,6 +48,7 @@
"@capacitor/haptics": "^4.0.1",
"@capacitor/ios": "^4.3.0",
"@capacitor/keyboard": "^4.0.1",
"@capacitor/preferences": "^4.0.1",
"@capacitor/splash-screen": "^4.1.0",
"@capacitor/status-bar": "^4.0.1",
"@capacitor/toast": "^4.0.1",

View file

@ -10,6 +10,7 @@ import { NgxQrcodeElementTypes, NgxQrcodeErrorCorrectionLevels, QrcodeComponent
import { EnvService } from 'src/app/services/env.service';
import { ScreenBrightness } from '@capacitor-community/screen-brightness';
import { rgbToHex } from 'src/app/utils/helpers';
import { Preferences } from '@capacitor/preferences';
@Component({
selector: 'app-qr-code',
@ -149,7 +150,7 @@ export class QrCodePage {
async onErrorCorrectionLevelChange() {
this.setErrorCorrectionLevel();
await this.env.storageSet("error-correction-level", this.env.errorCorrectionLevel);
await Preferences.set({ key: this.env.KEY_ERROR_CORRECTION_LEVEL, value: this.env.errorCorrectionLevel });
if (this.qrcodeElement != null) {
this.qrcodeElement.errorCorrectionLevel = this.errorCorrectionLevel;
} else {

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { Toast } from '@capacitor/toast';
import { AlertController, Platform } from '@ionic/angular';
import { TranslateService } from '@ngx-translate/core';
@ -89,7 +90,7 @@ export class AboutPage {
if (this.env.debugMode != 'on') {
if (this.tapAppVersionTimes >= 5) {
this.env.debugMode = 'on';
await this.env.storageSet("debug-mode-on", 'on');
await Preferences.set({ key: this.env.KEY_DEBUG_MODE, value: 'on' });
await Toast.show({
text: this.translate.instant("MSG.DEBUG_MODE_ON"),
duration: "short",

View file

@ -295,8 +295,8 @@ export class GeneratePage {
}
async processQrCode(loading: HTMLIonLoadingElement): Promise<void> {
this.env.result = this.qrCodeContent;
this.env.resultFormat = "";
this.env.resultContent = this.qrCodeContent;
this.env.resultContentFormat = "";
this.qrCodeContent = '';
this.env.recordSource = "create";
this.env.detailedRecordSource = "create";

View file

@ -198,7 +198,7 @@ export class HistoryPage {
case "RSS_EXPANDED":
return this.translate.instant("BARCODE_TYPE.RSS").trim();
default:
return this.env.resultFormat;
return this.env.resultContentFormat;
}
}
@ -210,8 +210,8 @@ export class HistoryPage {
this.changeDetectorRef.detectChanges();
this.changeDetectorRef.reattach();
const loading = await this.presentLoading(this.translate.instant('PLEASE_WAIT'));
this.env.result = data;
this.env.resultFormat = "";
this.env.resultContent = data;
this.env.resultContentFormat = "";
this.env.recordSource = "view";
this.env.detailedRecordSource = source;
this.env.viewResultFrom = "/tabs/history";

View file

@ -101,8 +101,8 @@ export class ImportImagePage {
}
async processQrCode(scannedData: string, loading: HTMLIonLoadingElement): Promise<void> {
this.env.result = scannedData;
this.env.resultFormat = "QR_CODE";
this.env.resultContent = scannedData;
this.env.resultContentFormat = "QR_CODE";
this.env.recordSource = "scan";
this.env.detailedRecordSource = "scan-image";
this.env.viewResultFrom = "/tabs/import-image";

View file

@ -28,7 +28,7 @@
</ion-row>
<ng-container *ngIf="qrCodeContent && qrCodeContent.trim().length > 0" [ngTemplateOutlet]="contentBlock"
[ngTemplateOutletContext]="{ label: barcodeFormat + ('CONTENT' | translate), content: qrCodeContent, hint: env.resultFormat }">
[ngTemplateOutletContext]="{ label: barcodeFormat + ('CONTENT' | translate), content: qrCodeContent, hint: env.resultContentFormat }">
</ng-container>
<ng-container *ngIf="base64Encoded && qrCodeContent && qrCodeContent.trim().length > 0"

View file

@ -1,4 +1,4 @@
import { Component, OnInit, QueryList, ViewChildren } from '@angular/core';
import { Component, QueryList, ViewChildren } from '@angular/core';
import { Clipboard } from '@capacitor/clipboard';
import { Contacts, ContactType, EmailAddress, NewContact, PhoneNumber } from '@capacitor-community/contacts'
import { SMS } from '@awesome-cordova-plugins/sms/ngx';
@ -81,7 +81,7 @@ export class ResultPage {
this.showQrFirst = true;
}
}
this.qrCodeContent = this.env.result;
this.qrCodeContent = this.env.resultContent;
this.setContentType();
}
@ -616,7 +616,6 @@ export class ResultPage {
lines.forEach(
line => {
const tLine = line.trim();
console.log(tLine);
if (tLine.toUpperCase().substr(0, fullNameId1.length) === fullNameId1) {
this.vCardContact.fullName = tLine.substr(fullNameId1.length);
} else if (tLine.toUpperCase().substr(0, fullNameId2.length) === fullNameId2) {
@ -860,7 +859,7 @@ export class ResultPage {
}
get barcodeFormat(): string {
switch (this.env.resultFormat) {
switch (this.env.resultContentFormat) {
case "UPC_A":
return this.translate.instant("BARCODE_TYPE.UPC");
case "UPC_E":
@ -900,7 +899,7 @@ export class ResultPage {
case "RSS_EXPANDED":
return this.translate.instant("BARCODE_TYPE.RSS");
default:
return this.env.resultFormat;
return this.env.resultContentFormat;
}
}

View file

@ -137,8 +137,8 @@ export class ScanPage {
}
async processQrCode(scannedData: string, format: string, loading: HTMLIonLoadingElement): Promise<void> {
this.env.result = scannedData;
this.env.resultFormat = format;
this.env.resultContent = scannedData;
this.env.resultContentFormat = format;
this.env.recordSource = "scan";
this.env.detailedRecordSource = "scan-camera";
this.env.viewResultFrom = "/tabs/scan";

View file

@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { Preferences } from '@capacitor/preferences';
import { Toast } from '@capacitor/toast';
import { EnvService } from 'src/app/services/env.service';
@ -15,12 +16,12 @@ export class SettingAutoBrightnessPage {
) { }
async saveAutoMaxBrightness() {
await this.env.storageSet("auto-max-brightness", this.env.autoMaxBrightness);
await Preferences.set({ key: this.env.KEY_AUTO_MAX_BRIGHTNESS, value: this.env.autoMaxBrightness });
}
async onAutoMaxBrightnessChange(ev: any) {
this.env.autoMaxBrightness = ev ? 'on' : 'off';
await this.env.storageSet("auto-max-brightness", this.env.autoMaxBrightness);
await Preferences.set({ key: this.env.KEY_AUTO_MAX_BRIGHTNESS, value: this.env.autoMaxBrightness });
await this.tapHaptic();
}

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { EnvService } from 'src/app/services/env.service';
@Component({
@ -13,6 +14,6 @@ export class SettingAutoExitPage{
) { }
async saveAutoExitAppMin() {
await this.env.storageSet("autoExitAppMin", this.env.autoExitAppMin);
await Preferences.set({ key: this.env.KEY_AUTO_EXIT_MIN, value: JSON.stringify(this.env.autoExitAppMin) });
}
}

View file

@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { Preferences } from '@capacitor/preferences';
import { Toast } from '@capacitor/toast';
import { EnvService } from 'src/app/services/env.service';
@ -16,31 +17,31 @@ export class SettingAutoQrPage {
async onShowQrAfterCameraScanChange(ev: any) {
this.env.showQrAfterCameraScan = ev ? 'on' : 'off';
await this.env.storageSet("show-qr-after-camera-scan", this.env.showQrAfterCameraScan);
await Preferences.set({ key: this.env.KEY_SHOW_QR_AFTER_CAMERA_SCAN, value: this.env.showQrAfterCameraScan });
await this.tapHaptic();
}
async onShowQrAfterImageScanChange(ev: any) {
this.env.showQrAfterImageScan = ev ? 'on' : 'off';
await this.env.storageSet("show-qr-after-image-scan", this.env.showQrAfterImageScan);
await Preferences.set({ key: this.env.KEY_SHOW_QR_AFTER_IMAGE_SCAN, value: this.env.showQrAfterImageScan });
await this.tapHaptic();
}
async onShowQrAfterCreateChange(ev: any) {
this.env.showQrAfterCreate = ev ? 'on' : 'off';
await this.env.storageSet("show-qr-after-create", this.env.showQrAfterCreate);
await Preferences.set({ key: this.env.KEY_SHOW_QR_AFTER_CREATE, value: this.env.showQrAfterCreate });
await this.tapHaptic();
}
async onShowQrAfterLogViewChange(ev: any) {
this.env.showQrAfterLogView = ev ? 'on' : 'off';
await this.env.storageSet("show-qr-after-log-view", this.env.showQrAfterLogView);
await Preferences.set({ key: this.env.KEY_SHOW_QR_AFTER_LOG_VIEW, value: this.env.showQrAfterLogView });
await this.tapHaptic();
}
async onShowQrAfterBookmarkViewChange(ev: any) {
this.env.showQrAfterBookmarkView = ev ? 'on' : 'off';
await this.env.storageSet("show-qr-after-bookmark-view", this.env.showQrAfterBookmarkView);
await Preferences.set({ key: this.env.KEY_SHOW_QR_AFTER_BOOKMARK_VIEW, value: this.env.showQrAfterBookmarkView });
await this.tapHaptic();
}

View file

@ -1,5 +1,6 @@
import { OverlayContainer } from '@angular/cdk/overlay';
import { Component } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { TranslateService } from '@ngx-translate/core';
import { EnvService } from 'src/app/services/env.service';
@ -18,7 +19,7 @@ export class SettingColorPage {
async saveColorTheme() {
await this.env.toggleColorTheme();
await this.env.storageSet("color", this.env.selectedColorTheme);
await Preferences.set({ key: this.env.KEY_COLOR, value: this.env.selectedColorTheme });
}
}

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { TranslateService } from '@ngx-translate/core';
import { EnvService } from 'src/app/services/env.service';
@ -15,7 +16,7 @@ export class SettingDebugPage {
) { }
async saveDebugMode() {
await this.env.storageSet("debug-mode-on", this.env.debugMode);
await Preferences.set({ key: this.env.KEY_DEBUG_MODE, value: this.env.debugMode });
}
}

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { TranslateService } from '@ngx-translate/core';
import { EnvService } from 'src/app/services/env.service';
@ -16,6 +17,6 @@ export class SettingLanguagePage {
async saveLanguage() {
this.env.toggleLanguageChange();
await this.env.storageSet("language", this.env.selectedLanguage);
await Preferences.set({ key: this.env.KEY_LANGUAGE, value: this.env.selectedLanguage });
}
}

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { EnvService } from 'src/app/services/env.service';
@Component({
@ -14,6 +15,6 @@ export class SettingOrientationPage {
async saveOrientation() {
await this.env.toggleOrientationChange();
await this.env.storageSet("orientation", this.env.orientation);
await Preferences.set({ key: this.env.KEY_ORIENTATION, value: this.env.orientation });
}
}

View file

@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { Preferences } from '@capacitor/preferences';
import { Toast } from '@capacitor/toast';
import { AlertController, Platform } from '@ionic/angular';
import { TranslateService } from '@ngx-translate/core';
@ -68,35 +69,35 @@ export class SettingQrPage {
async saveErrorCorrectionLevel() {
this.setErrorCorrectionLevel();
await this.env.storageSet("error-correction-level", this.env.errorCorrectionLevel);
await Preferences.set({ key: this.env.KEY_ERROR_CORRECTION_LEVEL, value: this.env.errorCorrectionLevel });
}
async saveQrCodeDarkR() {
await this.env.storageSet("qrCodeDarkR", this.env.qrCodeDarkR);
await Preferences.set({ key: this.env.KEY_QR_CODE_DARK_R, value: JSON.stringify(this.env.qrCodeDarkR) });
}
async saveQrCodeDarkG() {
await this.env.storageSet("qrCodeDarkG", this.env.qrCodeDarkG);
await Preferences.set({ key: this.env.KEY_QR_CODE_DARK_G, value: JSON.stringify(this.env.qrCodeDarkG) });
}
async saveQrCodeDarkB() {
await this.env.storageSet("qrCodeDarkB", this.env.qrCodeDarkB);
await Preferences.set({ key: this.env.KEY_QR_CODE_DARK_B, value: JSON.stringify(this.env.qrCodeDarkB) });
}
async saveQrCodeLightR() {
await this.env.storageSet("qrCodeLightR", this.env.qrCodeLightR);
await Preferences.set({ key: this.env.KEY_QR_CODE_LIGHT_R, value: JSON.stringify(this.env.qrCodeLightR) });
}
async saveQrCodeLightG() {
await this.env.storageSet("qrCodeLightG", this.env.qrCodeLightG);
await Preferences.set({ key: this.env.KEY_QR_CODE_LIGHT_G, value: JSON.stringify(this.env.qrCodeLightG) });
}
async saveQrCodeLightB() {
await this.env.storageSet("qrCodeLightB", this.env.qrCodeLightB);
await Preferences.set({ key: this.env.KEY_QR_CODE_LIGHT_B, value: JSON.stringify(this.env.qrCodeLightB) });
}
async saveQrCodeMargin() {
await this.env.storageSet("qrCodeMargin", this.env.qrCodeMargin);
await Preferences.set({ key: this.env.KEY_QR_CODE_MARGIN, value: JSON.stringify(this.env.qrCodeMargin) });
}
async resetDefault() {

View file

@ -12,6 +12,7 @@ import { ScanRecord } from 'src/app/models/scan-record';
import { Bookmark } from 'src/app/models/bookmark';
import { SocialSharing } from '@awesome-cordova-plugins/social-sharing/ngx';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { Preferences } from '@capacitor/preferences';
@Component({
selector: 'app-setting-record',
@ -43,17 +44,17 @@ export class SettingRecordPage {
}
async saveHistoryPageStartSegment() {
await this.env.storageSet("history-page-start-segment", this.env.historyPageStartSegment);
await Preferences.set({ key: this.env.KEY_HISTORY_PAGE_START_SEGMENT, value: this.env.historyPageStartSegment });
}
async onScanRecordLoggingChange(ev: any) {
this.env.scanRecordLogging = ev ? 'on' : 'off';
await this.env.storageSet("scan-record-logging", this.env.scanRecordLogging);
await Preferences.set({ key: this.env.KEY_SCAN_RECORD_LOGGING, value: this.env.scanRecordLogging });
await this.tapHaptic();
}
async saveRecordsLimit() {
await this.env.storageSet("recordsLimit", this.env.recordsLimit);
await Preferences.set({ key: this.env.KEY_RECORDS_LIMIT, value: JSON.stringify(this.env.recordsLimit) });
if (this.env.recordsLimit != -1 && !this.preventRecordsLimitToast) {
this.presentToast(this.translate.instant("MSG.DELETE_OVERFLOWED_RECORDS"), "short", "bottom");
}
@ -61,7 +62,7 @@ export class SettingRecordPage {
async onShowNumberOfRecordsChange(ev: any) {
this.env.showNumberOfRecords = ev ? 'on' : 'off';
await this.env.storageSet("showNumberOfRecords", this.env.showNumberOfRecords);
await Preferences.set({ key: this.env.KEY_SHOW_NUMBER_OF_RECORDS, value: this.env.showNumberOfRecords });
await this.tapHaptic();
}

View file

@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { Preferences } from '@capacitor/preferences';
import { Toast } from '@capacitor/toast';
import { EnvService } from 'src/app/services/env.service';
@ -15,72 +16,72 @@ export class SettingResultButtonsPage {
) { }
async saveResultPageButtons() {
await this.env.storageSet("result-page-buttons", this.env.resultPageButtons);
await Preferences.set({ key: this.env.KEY_RESULT_PAGE_BUTTONS, value: this.env.resultPageButtons });
}
async onSearchButtonChange(ev: any) {
this.env.showSearchButton = ev ? 'on' : 'off';
await this.env.storageSet("showSearchButton", this.env.showSearchButton);
await Preferences.set({ key: this.env.KEY_SHOW_SEARCH_BUTTON, value: this.env.showSearchButton });
await this.tapHaptic();
}
async onCopyButtonChange(ev: any) {
this.env.showCopyButton = ev ? 'on' : 'off';
await this.env.storageSet("showCopyButton", this.env.showCopyButton);
await Preferences.set({ key: this.env.KEY_SHOW_COPY_BUTTON, value: this.env.showCopyButton });
await this.tapHaptic();
}
async onBase64ButtonChange(ev: any) {
this.env.showBase64Button = ev ? 'on' : 'off';
await this.env.storageSet("showBase64Button", this.env.showBase64Button);
await Preferences.set({ key: this.env.KEY_SHOW_BASE64_BUTTON, value: this.env.showBase64Button });
await this.tapHaptic();
}
async onEnlargeButtonChange(ev: any) {
this.env.showEnlargeButton = ev ? 'on' : 'off';
await this.env.storageSet("showEnlargeButton", this.env.showEnlargeButton);
await Preferences.set({ key: this.env.KEY_SHOW_ENLARGE_BUTTON, value: this.env.showEnlargeButton });
await this.tapHaptic();
}
async onBookmarkButtonChange(ev: any) {
this.env.showBookmarkButton = ev ? 'on' : 'off';
await this.env.storageSet("showBookmarkButton", this.env.showBookmarkButton);
await Preferences.set({ key: this.env.KEY_SHOW_BOOKMARK_BUTTON, value: this.env.showBookmarkButton });
await this.tapHaptic();
}
async onOpenUrlButtonChange(ev: any) {
this.env.showOpenUrlButton = ev ? 'on' : 'off';
await this.env.storageSet("showOpenUrlButton", this.env.showOpenUrlButton);
await Preferences.set({ key: this.env.KEY_SHOW_OPEN_URL_BUTTON, value: this.env.showOpenUrlButton });
await this.tapHaptic();
}
async onBrowseButtonChange(ev: any) {
this.env.showBrowseButton = ev ? 'on' : 'off';
await this.env.storageSet("showBrowseButton", this.env.showBrowseButton);
await Preferences.set({ key: this.env.KEY_SHOW_BROWSE_BUTTON, value: this.env.showBrowseButton });
await this.tapHaptic();
}
async onAddContactButtonChange(ev: any) {
this.env.showAddContactButton = ev ? 'on' : 'off';
await this.env.storageSet("showAddContactButton", this.env.showAddContactButton);
await Preferences.set({ key: this.env.KEY_SHOW_ADD_CONTACT_BUTTON, value: this.env.showAddContactButton });
await this.tapHaptic();
}
async onCallButtonChange(ev: any) {
this.env.showCallButton = ev ? 'on' : 'off';
await this.env.storageSet("showCallButton", this.env.showCallButton);
await Preferences.set({ key: this.env.KEY_SHOW_CALL_BUTTON, value: this.env.showCallButton });
await this.tapHaptic();
}
async onSendMessageButtonChange(ev: any) {
this.env.showSendMessageButton = ev ? 'on' : 'off';
await this.env.storageSet("showSendMessageButton", this.env.showSendMessageButton);
await Preferences.set({ key: this.env.KEY_SHOW_SEND_MESSAGE_BUTTON, value: this.env.showSendMessageButton });
await this.tapHaptic();
}
async onSendEmailButtonChange(ev: any) {
this.env.showSendEmailButton = ev ? 'on' : 'off';
await this.env.storageSet("showSendEmailButton", this.env.showSendEmailButton);
await Preferences.set({ key: this.env.KEY_SHOW_SEND_EMAIL_BUTTON, value: this.env.showSendEmailButton });
await this.tapHaptic();
}

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { TranslateService } from '@ngx-translate/core';
import { EnvService } from 'src/app/services/env.service';
@ -15,7 +16,7 @@ export class SettingSearchEnginePage {
) { }
async saveSearchEngine() {
await this.env.storageSet("search-engine", this.env.searchEngine);
await Preferences.set({ key: this.env.KEY_SEARCH_ENGINE, value: this.env.searchEngine });
}

View file

@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { Preferences } from '@capacitor/preferences';
import { Toast } from '@capacitor/toast';
import { EnvService } from 'src/app/services/env.service';
import { fadeIn } from 'src/app/utils/animations';
@ -17,12 +18,12 @@ export class SettingStartPagePage {
) { }
async saveStartPage() {
await this.env.storageSet("start-page", this.env.startPage);
await Preferences.set({ key: this.env.KEY_START_PAGE, value: this.env.startPage });
}
async onStartPageHeaderChange(ev: any) {
this.env.startPageHeader = ev ? 'on' : 'off';
await this.env.storageSet("start-page-header", this.env.startPageHeader);
await Preferences.set({ key: this.env.KEY_START_PAGE_HEADER, value: this.env.startPageHeader });
await this.tapHaptic();
}

View file

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Preferences } from '@capacitor/preferences';
import { EnvService } from 'src/app/services/env.service';
@Component({
@ -13,6 +14,6 @@ export class SettingVibrationPage {
) { }
async saveVibration() {
await this.env.storageSet("vibration", this.env.vibration);
await Preferences.set({ key: this.env.KEY_VIBRATION, value: this.env.vibration });
}
}

View file

@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { Preferences } from '@capacitor/preferences';
import { SplashScreen } from '@capacitor/splash-screen';
import { Toast } from '@capacitor/toast';
import { AlertController, Platform } from '@ionic/angular';
@ -62,29 +63,35 @@ export class TabsPage {
async ionViewDidEnter() {
if (this.env.firstAppLoad) {
this.env.firstAppLoad = false;
await this.router.navigate([this.env.startPage], { replaceUrl: true });
await this.loadPatchNote();
this.env.initObservable.subscribe(async value => {
console.log(`tabs.page.ts - ionViewDidEnter() - initObservable value: ${value}`)
if (value) {
console.log(`tabs.page.ts - ionViewDidEnter() - env.startPage: ${this.env.startPage}`)
await this.router.navigate([this.env.startPage], { replaceUrl: true });
await this.loadPatchNote();
}
});
}
}
async loadPatchNote() {
const storageKey = this.platform.is('ios') ? this.env.IOS_PATCH_NOTE_STORAGE_KEY : this.env.AN_PATCH_NOTE_STORAGE_KEY;
await this.env.storageGet(storageKey).then(
async value => {
if (value != null) {
this.env.notShowUpdateNotes = (value === 'yes' ? true : false);
const storageKey = this.platform.is('ios') ? this.env.KEY_IOS_NOT_SHOW_UPDATE_NOTES : this.env.KEY_ANDROID_NOT_SHOW_UPDATE_NOTES;
await Preferences.get({ key: storageKey }).then(
async result => {
if (result.value != null) {
this.env.notShowUpdateNotes = result.value == 'yes';
} else {
this.env.notShowUpdateNotes = false;
}
await this.env.storageSet(storageKey, 'yes');
if (this.env.notShowUpdateNotes === false) {
await Preferences.set({ key: storageKey, value: 'yes' });
if (!this.env.notShowUpdateNotes) {
this.env.notShowUpdateNotes = true;
await this.showUpdateNotes();
const versionWording = this.translate.instant("VERSION_VERSION") as string;
await this.presentToast(versionWording.replace("{version}", this.env.appVersionNumber), "short", 'bottom');
}
}
);
)
}
async showUpdateNotes() {

File diff suppressed because it is too large Load diff

View file

@ -130,6 +130,7 @@
"OPEN": "Öffnen",
"OPEN_URL": "Öffne URL",
"OPEN_WITH_...": "Öffnen mit...",
"OPTIMIZING_DATA": "Optimierung der Daten",
"ORGANIZATION": "Organization",
"ORIGINAL": "Original",
"OTHERS": "Andere",

View file

@ -130,6 +130,7 @@
"OPEN": "Open",
"OPEN_URL": "Open URL",
"OPEN_WITH_...": "Open with...",
"OPTIMIZING_DATA": "Optimizing data",
"ORGANIZATION": "Organization",
"ORIGINAL": "Original",
"OTHERS": "Others",

View file

@ -130,6 +130,7 @@
"OPEN": "Ouvrir",
"OPEN_URL": "Ouvrir l'URL",
"OPEN_WITH_...": "Ouvrir avec...",
"OPTIMIZING_DATA": "Optimiser les données",
"ORGANIZATION": "Organisme",
"ORIGINAL": "Original",
"OTHERS": "Autres",

View file

@ -130,6 +130,7 @@
"OPEN": "Aprire",
"OPEN_URL": "Aprire l'URL",
"OPEN_WITH_...": "Apri con...",
"OPTIMIZING_DATA": "Ottimizzazione dei dati",
"ORGANIZATION": "Organizzazione",
"ORIGINAL": "Orginale",
"OTHERS": "Altri",

View file

@ -130,6 +130,7 @@
"OPEN": "打开",
"OPEN_URL": "打开网址",
"OPEN_WITH_...": "以下方式打开",
"OPTIMIZING_DATA": "优化数据",
"ORGANIZATION": "组织",
"ORIGINAL": "原始",
"OTHERS": "其他",

View file

@ -130,6 +130,7 @@
"OPEN": "打開",
"OPEN_URL": "打開網址",
"OPEN_WITH_...": "用以下方式打開",
"OPTIMIZING_DATA": "最佳化數據",
"ORGANIZATION": "組織",
"ORIGINAL": "原始",
"OTHERS": "其他",