Skip to content

Commit

Permalink
Added autosave feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Darius Musiolik authored and Darius Musiolik committed Jul 6, 2017
1 parent ad54921 commit a976976
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 7 deletions.
Binary file modified platforms/android/.gradle/3.3/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified platforms/android/.gradle/3.3/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified platforms/android/.gradle/3.3/taskArtifacts/taskArtifacts.bin
Binary file not shown.
Binary file modified platforms/android/.gradle/3.3/taskArtifacts/taskArtifacts.lock
Binary file not shown.
30 changes: 28 additions & 2 deletions platforms/android/assets/www/build/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56966,6 +56966,11 @@ var ModalContentPage = (function () {
_this.bgcolor = val;
console.log("[INFO] DB loaded bgcolor");
});
//Read DB and get autosave
storage.get("autosave").then(function (val) {
_this.autosave = val;
console.log("[INFO] DB loaded autosave");
});
//Loading Lang
this.langInit();
this.item = this.params.get("filename");
Expand All @@ -56983,6 +56988,11 @@ var ModalContentPage = (function () {
}
ModalContentPage.prototype.showConfirm = function () {
var _this = this;
if (this.autosave == true) {
console.log("[INFO] Autosave = true!");
this.bbe = false;
this.dismiss();
}
if (this.value == null || this.value == "") {
console.log("[WARN] Nothing to write");
this.viewCtrl.dismiss();
Expand Down Expand Up @@ -57014,11 +57024,18 @@ var ModalContentPage = (function () {
}
};
ModalContentPage.prototype.dismiss = function () {
var _this = this;
console.log("[INFO] Writing Stuff to >" + this.item + "<");
this.inputValue = this.value + "";
console.log("[INFO] Content to save: >" + this.inputValue + "<");
this.file.writeExistingFile(this.file.dataDirectory, this.item, this.inputValue);
this.presentToast();
//Catch BackBTN Event
this.plt.ready().then(function () {
_this.plt.registerBackButtonAction(function () {
_this.freeBBE(); //This is pretty useless. See it as kinda reset
});
});
this.viewCtrl.dismiss();
};
ModalContentPage.prototype.freeBBE = function () {
Expand Down Expand Up @@ -57150,11 +57167,16 @@ var AboutPage = (function () {
_this.save_hint = val;
console.log("[INFO] DB loaded savehint");
});
//Read DB and get fontsize
//Read DB and get welcomemsg_toogler
storage.get("welcomemsg_toogler").then(function (val) {
_this.welcomemsg_toogler = val;
console.log("[INFO] DB loaded welcomemsg_toogler");
});
//Read DB and get autosave
storage.get("autosave").then(function (val) {
_this.autosave = val;
console.log("[INFO] DB loaded autosave");
});
//Waiting for Promise
if (this.save_hint == "0") {
setTimeout(function () {
Expand All @@ -57170,6 +57192,7 @@ var AboutPage = (function () {
this.storage.set("welcomemsg_toogler", this.welcomemsg_toogler);
this.storage.set("fontcolor", this.font_color);
this.storage.set("bgcolor", this.bg_color);
this.storage.set("autosave", this.autosave);
console.log("[INFO] Wrote new data to DB");
this.toastSTRG(this.wrotedata, "top");
//Refresh - Help me navCtrl, you're my only hope
Expand Down Expand Up @@ -57208,6 +57231,7 @@ var AboutPage = (function () {
_this.white = "White";
_this.green = "Green";
_this.tardis = "Tardis Blue";
_this.autosave_text = "Enable autosave on BackBtnEvent";
break;
case "de":
console.log("[INFO] Settings loading lang: >de<");
Expand All @@ -57227,6 +57251,7 @@ var AboutPage = (function () {
_this.white = "Weiß";
_this.green = "Grün";
_this.tardis = "Tardis Blau";
_this.autosave_text = "Automatisch speichern bei Zurücktastendruck";
break;
default:
console.log("[FAIL] Micro$oft be like: Something happend.. (Maybe the Promise was not send, slow device ?)");
Expand All @@ -57238,7 +57263,7 @@ var AboutPage = (function () {
}());
AboutPage = __decorate([
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["_6" /* Component */])({
selector: 'page-about',template:/*ion-inline-start:"/home/dmusiolik/Desktop/Ionic Framework/klebezettel/src/pages/about/about.html"*/'<ion-header>\n <ion-navbar color="dark">\n <ion-title>{{ header }}</ion-title>\n <ion-buttons end>\n <button ion-button icon-only color="royal" (click)="saveSettings()">\n <ion-icon name="md-checkmark"></ion-icon>\n </button>\n </ion-buttons>\n </ion-navbar>\n</ion-header>\n<ion-content padding>\n<ion-item>\n <ion-label>{{ lang_text }}</ion-label>\n <ion-select [(ngModel)]="lang">\n <ion-option value="en">English</ion-option>\n <ion-option value="de">Deutsch</ion-option>\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label>{{ fontsite_text }}</ion-label>\n <ion-select [(ngModel)]="fontsize">\n <ion-option value="40">40 pt</ion-option>\n <ion-option value="35">35 pt</ion-option>\n <ion-option value="30">30 pt</ion-option>\n <ion-option value="25">25 pt</ion-option>\n <ion-option value="20">20 pt</ion-option>\n <ion-option value="15">15 pt</ion-option>\n <ion-option value="10">10 pt</ion-option>\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label>{{ welcomemsg_toogle }}</ion-label>\n <ion-toggle [(ngModel)]="welcomemsg_toogler" checked="{{ welcomemsg_toogler }}"></ion-toggle>\n </ion-item>\n <ion-item>\n <ion-label>{{ font_color_text }}</ion-label>\n <ion-select [(ngModel)]="font_color">\n <ion-option value="black">{{ black }}</ion-option>\n <ion-option value="white">{{ white }}</ion-option>\n <ion-option value="red">{{ red }}</ion-option>\n <ion-option value="blue">{{ blue }}</ion-option>\n <ion-option value="yellow">{{ yellow }}</ion-option>\n <ion-option value="orange">{{ orange }}</ion-option>\n <ion-option value="green">{{ green }}</ion-option>\n <ion-option value="#003B6F">{{ tardis }}</ion-option>\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label>{{ bg_color_text }}</ion-label>\n <ion-select [(ngModel)]="bg_color">\n <ion-option value="black">{{ black }}</ion-option>\n <ion-option value="white">{{ white }}</ion-option>\n <ion-option value="red">{{ red }}</ion-option>\n <ion-option value="blue">{{ blue }}</ion-option>\n <ion-option value="yellow">{{ yellow }}</ion-option>\n <ion-option value="orange">{{ orange }}</ion-option>\n <ion-option value="green">{{ green }}</ion-option>\n <ion-option value="#003B6F">{{ tardis }}</ion-option>\n </ion-select>\n </ion-item>\n</ion-content>\n'/*ion-inline-end:"/home/dmusiolik/Desktop/Ionic Framework/klebezettel/src/pages/about/about.html"*/
selector: 'page-about',template:/*ion-inline-start:"/home/dmusiolik/Desktop/Ionic Framework/klebezettel/src/pages/about/about.html"*/'<ion-header>\n <ion-navbar color="dark">\n <ion-title>{{ header }}</ion-title>\n <ion-buttons end>\n <button ion-button icon-only color="royal" (click)="saveSettings()">\n <ion-icon name="md-checkmark"></ion-icon>\n </button>\n </ion-buttons>\n </ion-navbar>\n</ion-header>\n<ion-content padding>\n<ion-item>\n <ion-label>{{ lang_text }}</ion-label>\n <ion-select [(ngModel)]="lang">\n <ion-option value="en">English</ion-option>\n <ion-option value="de">Deutsch</ion-option>\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label>{{ fontsite_text }}</ion-label>\n <ion-select [(ngModel)]="fontsize">\n <ion-option value="40">40 pt</ion-option>\n <ion-option value="35">35 pt</ion-option>\n <ion-option value="30">30 pt</ion-option>\n <ion-option value="25">25 pt</ion-option>\n <ion-option value="20">20 pt</ion-option>\n <ion-option value="15">15 pt</ion-option>\n <ion-option value="10">10 pt</ion-option>\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label>{{ welcomemsg_toogle }}</ion-label>\n <ion-toggle [(ngModel)]="welcomemsg_toogler" checked="{{ welcomemsg_toogler }}"></ion-toggle>\n </ion-item>\n <ion-item>\n <ion-label>{{ font_color_text }}</ion-label>\n <ion-select [(ngModel)]="font_color">\n <ion-option value="black">{{ black }}</ion-option>\n <ion-option value="white">{{ white }}</ion-option>\n <ion-option value="red">{{ red }}</ion-option>\n <ion-option value="blue">{{ blue }}</ion-option>\n <ion-option value="yellow">{{ yellow }}</ion-option>\n <ion-option value="orange">{{ orange }}</ion-option>\n <ion-option value="green">{{ green }}</ion-option>\n <ion-option value="#003B6F">{{ tardis }}</ion-option>\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label>{{ bg_color_text }}</ion-label>\n <ion-select [(ngModel)]="bg_color">\n <ion-option value="black">{{ black }}</ion-option>\n <ion-option value="white">{{ white }}</ion-option>\n <ion-option value="red">{{ red }}</ion-option>\n <ion-option value="blue">{{ blue }}</ion-option>\n <ion-option value="yellow">{{ yellow }}</ion-option>\n <ion-option value="orange">{{ orange }}</ion-option>\n <ion-option value="green">{{ green }}</ion-option>\n <ion-option value="#003B6F">{{ tardis }}</ion-option>\n </ion-select>\n </ion-item>\n <ion-item>\n <ion-label>{{ autosave_text }}</ion-label>\n <ion-toggle [(ngModel)]="autosave" checked="{{ autosave }}"></ion-toggle>\n </ion-item>\n</ion-content>\n'/*ion-inline-end:"/home/dmusiolik/Desktop/Ionic Framework/klebezettel/src/pages/about/about.html"*/
}),
__metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_1_ionic_angular__["f" /* NavController */], __WEBPACK_IMPORTED_MODULE_2__ionic_storage__["b" /* Storage */], __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["i" /* ToastController */], __WEBPACK_IMPORTED_MODULE_1_ionic_angular__["n" /* Events */]])
], AboutPage);
Expand Down Expand Up @@ -57379,6 +57404,7 @@ var HomePage = (function () {
storage.set("fontsize", "20");
storage.set("fontcolor", "black");
storage.set("bgcolor", "white");
storage.set("autosave", "false");
storage.set("welcomemsg_toogler", "true");
storage.set("save_hint", "0");
}
Expand Down
2 changes: 1 addition & 1 deletion platforms/android/assets/www/build/main.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/pages/about/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@
<ion-option value="#003B6F">{{ tardis }}</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>{{ autosave_text }}</ion-label>
<ion-toggle [(ngModel)]="autosave" checked="{{ autosave }}"></ion-toggle>
</ion-item>
</ion-content>
13 changes: 12 additions & 1 deletion src/pages/about/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ welcomemsg_toogler:string;
save_hint:string;
font_color:string;
bg_color:string;
autosave:string;
//Lang Varz
reminder:string;
wrotedata:string;
Expand All @@ -38,6 +39,7 @@ orange:string;
white:string;
green:string;
tardis:string;
autosave_text:string;

constructor(public navCtrl: NavController, private storage: Storage, public toastCtrl: ToastController, public events: Events) {

Expand Down Expand Up @@ -75,12 +77,18 @@ tardis:string;
console.log("[INFO] DB loaded savehint");
});

//Read DB and get fontsize
//Read DB and get welcomemsg_toogler
storage.get("welcomemsg_toogler").then((val) => {
this.welcomemsg_toogler = val;
console.log("[INFO] DB loaded welcomemsg_toogler");
});

//Read DB and get autosave
storage.get("autosave").then((val) => {
this.autosave = val;
console.log("[INFO] DB loaded autosave");
});

//Waiting for Promise
if(this.save_hint == "0") {
setTimeout(() => {
Expand All @@ -97,6 +105,7 @@ tardis:string;
this.storage.set("welcomemsg_toogler", this.welcomemsg_toogler);
this.storage.set("fontcolor", this.font_color);
this.storage.set("bgcolor", this.bg_color);
this.storage.set("autosave", this.autosave);
console.log("[INFO] Wrote new data to DB");
this.toastSTRG(this.wrotedata, "top");
//Refresh - Help me navCtrl, you're my only hope
Expand Down Expand Up @@ -136,6 +145,7 @@ tardis:string;
this.white = "White";
this.green = "Green";
this.tardis = "Tardis Blue";
this.autosave_text = "Enable autosave on BackBtnEvent";
break;
case "de":
console.log("[INFO] Settings loading lang: >de<");
Expand All @@ -155,6 +165,7 @@ tardis:string;
this.white = "Weiß";
this.green = "Grün";
this.tardis = "Tardis Blau";
this.autosave_text = "Automatisch speichern bei Zurücktastendruck";
break;
default:
console.log("[FAIL] Micro$oft be like: Something happend.. (Maybe the Promise was not send, slow device ?)");
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class HomePage {
storage.set("fontsize", "20");
storage.set("fontcolor", "black");
storage.set("bgcolor", "white");
storage.set("autosave", "false");
storage.set("welcomemsg_toogler", "true");
storage.set("save_hint", "0");
}
Expand Down
18 changes: 18 additions & 0 deletions src/pages/modal-content/modal-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class ModalContentPage {
fontcolor:string = "";
bgcolor:string = "";
bbe:boolean = true;
autosave:boolean;
//Lang Varz
savedmsg:string;
placeholder:string;
Expand Down Expand Up @@ -78,6 +79,12 @@ export class ModalContentPage {
console.log("[INFO] DB loaded bgcolor");
});

//Read DB and get autosave
storage.get("autosave").then((val) => {
this.autosave = val;
console.log("[INFO] DB loaded autosave");
});

//Loading Lang
this.langInit();

Expand All @@ -98,6 +105,11 @@ export class ModalContentPage {
}

showConfirm() {
if(this.autosave == true) {
console.log("[INFO] Autosave = true!");
this.bbe = false;
this.dismiss();
}
if(this.value == null || this.value == "") {
console.log("[WARN] Nothing to write");
this.viewCtrl.dismiss();
Expand Down Expand Up @@ -135,6 +147,12 @@ export class ModalContentPage {
console.log("[INFO] Content to save: >" + this.inputValue + "<");
this.file.writeExistingFile(this.file.dataDirectory, this.item, this.inputValue);
this.presentToast();
//Catch BackBTN Event
this.plt.ready().then( ()=> {
this.plt.registerBackButtonAction( ()=> {
this.freeBBE(); //This is pretty useless. See it as kinda reset
})
});
this.viewCtrl.dismiss();
}

Expand Down
Loading

0 comments on commit a976976

Please sign in to comment.