From dbd08f2eb369b97844377bb3a17fccf8348824c1 Mon Sep 17 00:00:00 2001 From: vishnuraghavb Date: Tue, 25 May 2021 20:02:53 +0530 Subject: [PATCH] implementing foreground service --- app/ForegroundService.js | 51 + app/components/CookingTimer.vue | 97 +- app/components/EditRecipe.vue | 57 +- app/components/EnRecipes.vue | 28 +- app/components/GroceryList.vue | 5 +- app/components/MealPlanner.vue | 33 +- app/components/Settings.vue | 106 - app/components/Settings/CTSettings.vue | 139 - app/components/Settings/MPSettings.vue | 75 - app/components/Settings/Options.vue | 109 - app/components/ViewRecipe.vue | 28 +- .../ActionDialog.vue => modals/Action.vue} | 4 +- .../ActionWithSearch.vue} | 0 .../ConfirmDialog.vue => modals/Confirm.vue} | 0 .../{modal/Filters.vue => modals/Filter.vue} | 0 .../PromptDialog.vue => modals/Prompt.vue} | 0 .../TimePickerHM.vue} | 0 .../TimePickerHMS.vue} | 0 .../{Settings => settings}/About.vue | 11 +- app/components/settings/AppSettings.vue | 82 + app/components/settings/CTSettings.vue | 134 + .../{Settings => settings}/Database.vue | 70 +- .../{Settings => settings}/Interface.vue | 56 +- app/components/settings/MPSettings.vue | 45 + app/components/settings/Options.vue | 69 + .../{Settings => settings}/Reset.vue | 74 +- app/components/sub/OptionsList.vue | 62 + app/components/sub/SnackBar.vue | 23 + .../{SingleTimer.vue => sub/Timer.vue} | 6 +- app/components/sub/Toast.vue | 20 + app/i18n/en-GB.default.json | 3 +- app/main.ts | 24 +- .../Android/src/main/AndroidManifest.xml | 10 +- .../src/main/res/values-ar/strings.xml | 2 + .../src/main/res/values-ca/strings.xml | 4 +- .../src/main/res/values-da/strings.xml | 2 + .../src/main/res/values-de/strings.xml | 2 + .../src/main/res/values-en-rIN/strings.xml | 2 + .../src/main/res/values-en-rUS/strings.xml | 2 + .../src/main/res/values-es-rAR/strings.xml | 4 +- .../src/main/res/values-es/strings.xml | 2 + .../src/main/res/values-fi/strings.xml | 4 +- .../src/main/res/values-fr-rBE/strings.xml | 2 + .../src/main/res/values-fr-rCA/strings.xml | 2 + .../src/main/res/values-fr-rCH/strings.xml | 2 + .../src/main/res/values-fr/strings.xml | 2 + .../src/main/res/values-hi/strings.xml | 2 + .../src/main/res/values-id/strings.xml | 2 + .../src/main/res/values-it/strings.xml | 2 + .../src/main/res/values-ja/strings.xml | 4 +- .../src/main/res/values-kn/strings.xml | 4 +- .../src/main/res/values-ml/strings.xml | 4 +- .../src/main/res/values-nb-rNO/strings.xml | 4 +- .../src/main/res/values-nl/strings.xml | 2 + .../src/main/res/values-pt-rBR/strings.xml | 2 + .../src/main/res/values-pt/strings.xml | 2 + .../src/main/res/values-ru/strings.xml | 2 + .../src/main/res/values-ta/strings.xml | 4 +- .../src/main/res/values-te/strings.xml | 4 +- .../Android/src/main/res/values/strings.xml | 4 +- app/shared/{mixins.js => mixins.ts} | 2 + app/shared/{utils.js => utils.ts} | 107 +- app/store.ts | 7 +- package-lock.json | 2253 ++++------------- tsconfig.json | 2 +- webpack.config.js | 14 + 66 files changed, 1391 insertions(+), 2489 deletions(-) create mode 100644 app/ForegroundService.js delete mode 100644 app/components/Settings.vue delete mode 100644 app/components/Settings/CTSettings.vue delete mode 100644 app/components/Settings/MPSettings.vue delete mode 100644 app/components/Settings/Options.vue rename app/components/{modal/ActionDialog.vue => modals/Action.vue} (97%) rename app/components/{modal/ActionDialogWithSearch.vue => modals/ActionWithSearch.vue} (100%) rename app/components/{modal/ConfirmDialog.vue => modals/Confirm.vue} (100%) rename app/components/{modal/Filters.vue => modals/Filter.vue} (100%) rename app/components/{modal/PromptDialog.vue => modals/Prompt.vue} (100%) rename app/components/{modal/TimePicker.vue => modals/TimePickerHM.vue} (100%) rename app/components/{modal/CookingTimePicker.vue => modals/TimePickerHMS.vue} (100%) rename app/components/{Settings => settings}/About.vue (92%) create mode 100644 app/components/settings/AppSettings.vue create mode 100644 app/components/settings/CTSettings.vue rename app/components/{Settings => settings}/Database.vue (87%) rename app/components/{Settings => settings}/Interface.vue (71%) create mode 100644 app/components/settings/MPSettings.vue create mode 100644 app/components/settings/Options.vue rename app/components/{Settings => settings}/Reset.vue (54%) create mode 100644 app/components/sub/OptionsList.vue create mode 100644 app/components/sub/SnackBar.vue rename app/components/{SingleTimer.vue => sub/Timer.vue} (96%) create mode 100644 app/components/sub/Toast.vue rename app/shared/{mixins.js => mixins.ts} (96%) rename app/shared/{utils.js => utils.ts} (86%) diff --git a/app/ForegroundService.js b/app/ForegroundService.js new file mode 100644 index 00000000..dad1177b --- /dev/null +++ b/app/ForegroundService.js @@ -0,0 +1,51 @@ +var ForegroundService = /** @class */ (function(_super) { + __extends(ForegroundService, _super) + function ForegroundService() { + return (_super !== null && _super.apply(this, arguments)) || this + } + ForegroundService.prototype.onStartCommand = function( + intent, + flags, + startId + ) { + console.log('onStartCommand') + _super.prototype.onStartCommand.call(this, intent, flags, startId) + return android.app.Service.START_STICKY + } + ForegroundService.prototype.onCreate = function() { + console.log('onCreate') + _super.prototype.onCreate.call(this) + this.startForeground(1, this.getNotification()) + } + ForegroundService.prototype.onBind = function(intent) { + return _super.prototype.onBind.call(this, intent) + } + ForegroundService.prototype.onUnbind = function(intent) { + return _super.prototype.onUnbind.call(this, intent) + } + ForegroundService.prototype.onDestroy = function() { + console.log('onDestroy') + this.stopForeground(true) + } + ForegroundService.prototype.getNotification = function() { + var channel = new android.app.NotificationChannel( + 'channel_01', + 'ForegroundService Channel', + android.app.NotificationManager.IMPORTANCE_DEFAULT + ) + var notificationManager = this.getSystemService( + android.content.Context.NOTIFICATION_SERVICE + ) + notificationManager.createNotificationChannel(channel) + var builder = new android.app.Notification.Builder( + this.getApplicationContext(), + 'channel_01' + ) + return builder.build() + } + ForegroundService = __decorate( + [JavaProxy('com.tns.ForegroundService')], + ForegroundService + ) + return ForegroundService +})(android.app.Service) diff --git a/app/components/CookingTimer.vue b/app/components/CookingTimer.vue index af2d1054..c7367ff3 100644 --- a/app/components/CookingTimer.vue +++ b/app/components/CookingTimer.vue @@ -16,7 +16,7 @@ @tap="$navigateTo(CTSettings)" /> -