|
@@ -1,6 +1,7 @@
|
|
|
import { Component } from '@angular/core';
|
|
|
import { NavController } from 'ionic-angular';
|
|
|
-import { LocalNotifications } from 'ionic-native';
|
|
|
+import { BackgroundMode, LocalNotifications } from 'ionic-native';
|
|
|
+import { PreferencesProvider } from '../../providers/preferences-provider';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'page-settings',
|
|
@@ -8,12 +9,13 @@ import { LocalNotifications } from 'ionic-native';
|
|
|
})
|
|
|
export class SettingsPage {
|
|
|
|
|
|
- initialPage: number;
|
|
|
+ startPage: number;
|
|
|
sync: boolean;
|
|
|
- syncFrecuency;
|
|
|
+ syncFrecuency: string;
|
|
|
|
|
|
constructor(
|
|
|
- public navCtrl: NavController
|
|
|
+ public navCtrl: NavController,
|
|
|
+ public preferencesProvider: PreferencesProvider
|
|
|
) {
|
|
|
this.initialize();
|
|
|
}
|
|
@@ -26,38 +28,48 @@ export class SettingsPage {
|
|
|
*
|
|
|
*/
|
|
|
initialize() {
|
|
|
- this.initialPage = +localStorage.getItem("initial_page");
|
|
|
- this.sync = (localStorage.getItem("sync") === "true");
|
|
|
- this.syncFrecuency = +(localStorage.getItem("sync_frecuency") ? localStorage.getItem("sync_frecuency") : "10");
|
|
|
+ this.startPage = this.preferencesProvider.getStartPage();
|
|
|
+ this.sync = this.preferencesProvider.getSync();
|
|
|
+ this.syncFrecuency = this.preferencesProvider.getSyncFrecuency();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
changeInitialPage(e: any) {
|
|
|
- localStorage.setItem("initial_page", e);
|
|
|
+ this.preferencesProvider.setStartPage(e);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
changeSync(e: any) {
|
|
|
- localStorage.setItem("sync", e);
|
|
|
-
|
|
|
- console.log(e);
|
|
|
+ this.sync = e;
|
|
|
+ this.preferencesProvider.setSync(e);
|
|
|
|
|
|
+ // if (e) {
|
|
|
+ // BackgroundMode.enable();
|
|
|
+
|
|
|
+ // LocalNotifications.schedule({
|
|
|
+ // id: 1,
|
|
|
+ // title: "Actualización de datos de Odoo Mobile",
|
|
|
+ // every: "minute"
|
|
|
+ // });
|
|
|
+
|
|
|
+ // LocalNotifications.on("trigger", () => {
|
|
|
+ // console.log("Realizar actualización");
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // BackgroundMode.disable();
|
|
|
|
|
|
- LocalNotifications.schedule({
|
|
|
- id: 1,
|
|
|
- text: "Test notification",
|
|
|
- every: "minute"
|
|
|
- });
|
|
|
+ // LocalNotifications.clearAll();
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
|
changeSyncFrecuency(e: any) {
|
|
|
- localStorage.setItem("sync_frecuency", e);
|
|
|
+ this.preferencesProvider.setSyncFrecuency(e);
|
|
|
}
|
|
|
}
|