Skip to content

Commit

Permalink
#805 - Removing insomnia plugin and using from capacitor now.
Browse files Browse the repository at this point in the history
  • Loading branch information
graphefruit committed Oct 5, 2024
1 parent 3233a16 commit 9589365
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 56 deletions.
1 change: 1 addition & 0 deletions android/app/capacitor.build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ android {

apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-community-keep-awake')
implementation project(':capacitor-app')
implementation project(':capacitor-barcode-scanner')
implementation project(':capacitor-camera')
Expand Down
3 changes: 3 additions & 0 deletions android/capacitor.settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')

include ':capacitor-community-keep-awake'
project(':capacitor-community-keep-awake').projectDir = new File('../node_modules/@capacitor-community/keep-awake/android')

include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')

Expand Down
1 change: 1 addition & 0 deletions ios/App/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ install! 'cocoapods', :disable_input_output_paths => true
def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCommunityKeepAwake', :path => '../../node_modules/@capacitor-community/keep-awake'
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
pod 'CapacitorBarcodeScanner', :path => '../../node_modules/@capacitor/barcode-scanner'
pod 'CapacitorCamera', :path => '../../node_modules/@capacitor/camera'
Expand Down
8 changes: 7 additions & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ PODS:
- Capacitor
- CapacitorClipboard (6.0.1):
- Capacitor
- CapacitorCommunityKeepAwake (5.0.1):
- Capacitor
- CapacitorCordova (6.1.2)
- CapacitorDevice (6.0.1):
- Capacitor
Expand Down Expand Up @@ -40,6 +42,7 @@ DEPENDENCIES:
- "CapacitorBarcodeScanner (from `../../node_modules/@capacitor/barcode-scanner`)"
- "CapacitorCamera (from `../../node_modules/@capacitor/camera`)"
- "CapacitorClipboard (from `../../node_modules/@capacitor/clipboard`)"
- "CapacitorCommunityKeepAwake (from `../../node_modules/@capacitor-community/keep-awake`)"
- "CapacitorCordova (from `../../node_modules/@capacitor/ios`)"
- "CapacitorDevice (from `../../node_modules/@capacitor/device`)"
- "CapacitorFilesystem (from `../../node_modules/@capacitor/filesystem`)"
Expand Down Expand Up @@ -68,6 +71,8 @@ EXTERNAL SOURCES:
:path: "../../node_modules/@capacitor/camera"
CapacitorClipboard:
:path: "../../node_modules/@capacitor/clipboard"
CapacitorCommunityKeepAwake:
:path: "../../node_modules/@capacitor-community/keep-awake"
CapacitorCordova:
:path: "../../node_modules/@capacitor/ios"
CapacitorDevice:
Expand Down Expand Up @@ -97,6 +102,7 @@ SPEC CHECKSUMS:
CapacitorBarcodeScanner: 3057910347ab6c3db06e1a38bdf688a6a469227a
CapacitorCamera: ed022171dbf3853e68eec877b4d78995378af6b7
CapacitorClipboard: 756cd7e83e8d5d19b0c74f40b57517c287bd5fe2
CapacitorCommunityKeepAwake: e2ddd50812e3407f8dc3a2c28e97d66e9b59b2f5
CapacitorCordova: f48c89f96c319101cd2f0ce8a2b7449b5fb8b3dd
CapacitorDevice: 7097a1deb4224b77fd13a6e60a355d0062a5d772
CapacitorFilesystem: 37fb3aa5c945b4539ab11c74a5c57925a302bf24
Expand All @@ -111,6 +117,6 @@ SPEC CHECKSUMS:
OSBarcodeLib: 4bb4cc0b9850451fe71ba4953c1c934368e767df
OSInAppBrowserLib: c3d0b21a0c8b6d81e69117ad08bb6b8a4849c4e1

PODFILE CHECKSUM: 30fb69e4e19accf809b98b75f801bdc0e4181b2a
PODFILE CHECKSUM: ad0e379d6401d3e70e089ff32db2ec36e5499426

COCOAPODS: 1.15.2
36 changes: 10 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@awesome-cordova-plugins/deeplinks": "^6.4.0",
"@awesome-cordova-plugins/file-chooser": "^6.4.0",
"@awesome-cordova-plugins/image-picker": "^6.4.0",
"@awesome-cordova-plugins/insomnia": "^6.4.0",
"@awesome-cordova-plugins/three-dee-touch": "^6.4.0",
"@capacitor-community/keep-awake": "^5.0.1",
"@capacitor/android": "6.1.2",
"@capacitor/app": "6.0.1",
"@capacitor/barcode-scanner": "^1.0.1",
Expand Down Expand Up @@ -96,7 +96,6 @@
"cordova-plugin-android-permissions": "^1.1.5",
"cordova-plugin-ble-central": "^1.7.4",
"cordova-plugin-health": "^2.1.0",
"cordova-plugin-insomnia": "^4.3.0",
"cordova-sqlite-storage": "^5.1.0",
"elliptic": ">=6.5.4",
"husky": "^8.0.1",
Expand Down
2 changes: 0 additions & 2 deletions src/app/brew/brew-add/brew-add.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { UIBrewStorage } from '../../../services/uiBrewStorage';
import { UISettingsStorage } from '../../../services/uiSettingsStorage';
import { UIMillStorage } from '../../../services/uiMillStorage';
import { UIBrewHelper } from '../../../services/uiBrewHelper';
import { Insomnia } from '@awesome-cordova-plugins/insomnia/ngx';
import { BrewTrackingService } from '../../../services/brewTracking/brew-tracking.service';
import { UIAnalytics } from '../../../services/uiAnalytics';
import { VisualizerService } from '../../../services/visualizerService/visualizer-service.service';
Expand Down Expand Up @@ -85,7 +84,6 @@ describe('BrewAddComponent', () => {
{ provide: UIAnalytics, useValue: {} },
{ provide: BrewTrackingService, useValue: {} },
{ provide: VisualizerService, useValue: {} },
Insomnia,
{ provide: Router },
{ provide: UIHelper, useClass: UIHelperMock },
],
Expand Down
16 changes: 5 additions & 11 deletions src/app/brew/brew-add/brew-add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { UILog } from '../../../services/uiLog';
import { UIBrewHelper } from '../../../services/uiBrewHelper';
import { Settings } from '../../../classes/settings/settings';
import { UIHealthKit } from '../../../services/uiHealthKit';
import { Insomnia } from '@awesome-cordova-plugins/insomnia/ngx';
import { BrewBrewingComponent } from '../../../components/brews/brew-brewing/brew-brewing.component';
import { UIAlert } from '../../../services/uiAlert';
import { BrewTrackingService } from '../../../services/brewTracking/brew-tracking.service';
Expand All @@ -47,6 +46,7 @@ import { XeniaDevice } from '../../../classes/preparationDevice/xenia/xeniaDevic
import { BrewFlow } from '../../../classes/brew/brewFlow';
import { REFERENCE_GRAPH_TYPE } from '../../../enums/brews/referenceGraphType';
import { ReferenceGraph } from '../../../classes/brew/referenceGraph';
import { UIHelper } from '../../../services/uiHelper';

declare var Plotly;

Expand Down Expand Up @@ -88,14 +88,14 @@ export class BrewAddComponent implements OnInit, OnDestroy {
private readonly uiLog: UILog,
private readonly uiBrewHelper: UIBrewHelper,
private readonly uiHealthKit: UIHealthKit,
private readonly insomnia: Insomnia,
private readonly uiAlert: UIAlert,
private readonly brewTracking: BrewTrackingService,
private readonly uiAnalytics: UIAnalytics,
private readonly bleManager: CoffeeBluetoothDevicesService,
private readonly visualizerService: VisualizerService,
private readonly changeDetectorRef: ChangeDetectorRef,
private readonly hapticService: HapticService
private readonly hapticService: HapticService,
private readonly uiHelper: UIHelper
) {
// Initialize to standard in drop down

Expand Down Expand Up @@ -135,10 +135,7 @@ export class BrewAddComponent implements OnInit, OnDestroy {
public ionViewDidEnter(): void {
this.uiAnalytics.trackEvent(BREW_TRACKING.TITLE, BREW_TRACKING.ACTIONS.ADD);
if (this.settings.wake_lock) {
this.insomnia.keepAwake().then(
() => {},
() => {}
);
this.uiHelper.deviceKeepAwake();
}

// TODO Capacitor migration: There is a race condition here, as this function
Expand Down Expand Up @@ -192,10 +189,7 @@ export class BrewAddComponent implements OnInit, OnDestroy {

public ionViewWillLeave() {
if (this.settings.wake_lock) {
this.insomnia.allowSleepAgain().then(
() => {},
() => {}
);
this.uiHelper.deviceAllowSleepAgain();
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/app/brew/brew-edit/brew-edit.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { ImagePicker } from '@awesome-cordova-plugins/image-picker/ngx';
import { Router } from '@angular/router';
import { AsyncImageComponent } from '../../../components/async-image/async-image.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { Insomnia } from '@awesome-cordova-plugins/insomnia/ngx';
import { PipesModule } from 'src/pipes/pipes.module';

describe('BrewEditComponent', () => {
Expand All @@ -36,7 +35,6 @@ describe('BrewEditComponent', () => {
{ provide: Storage },
{ provide: ImagePicker },
{ provide: Router },
{ provide: Insomnia },
],
}).compileComponents();
}));
Expand Down
12 changes: 2 additions & 10 deletions src/app/brew/brew-edit/brew-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { BrewTrackingService } from '../../../services/brewTracking/brew-trackin
import BREW_TRACKING from '../../../data/tracking/brewTracking';
import { UIAnalytics } from '../../../services/uiAnalytics';
import { UISettingsStorage } from '../../../services/uiSettingsStorage';
import { Insomnia } from '@awesome-cordova-plugins/insomnia/ngx';
import { Settings } from '../../../classes/settings/settings';
import { SettingsPopoverBluetoothActionsComponent } from '../../settings/settings-popover-bluetooth-actions/settings-popover-bluetooth-actions.component';
import {
Expand Down Expand Up @@ -53,7 +52,6 @@ export class BrewEditComponent implements OnInit {
private readonly brewTracking: BrewTrackingService,
private readonly uiAnalytics: UIAnalytics,
private readonly uiSettingsStorage: UISettingsStorage,
private readonly insomnia: Insomnia,
private readonly bleManager: CoffeeBluetoothDevicesService,
private readonly uiAlert: UIAlert,
private readonly visualizerService: VisualizerService,
Expand All @@ -80,19 +78,13 @@ export class BrewEditComponent implements OnInit {
}
public ionViewDidEnter(): void {
if (this.settings.wake_lock) {
this.insomnia.keepAwake().then(
() => {},
() => {}
);
this.uiHelper.deviceKeepAwake();
}
this.initialBeanData = JSON.stringify(this.data);
}
public ionViewWillLeave() {
if (this.settings.wake_lock) {
this.insomnia.allowSleepAgain().then(
() => {},
() => {}
);
this.uiHelper.deviceAllowSleepAgain();
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ import { GreenBeanEditComponent } from '../roasting-section/green-beans/green-be
import { GreenBeanDetailComponent } from '../roasting-section/green-beans/green-bean-detail/green-bean-detail.component';
import { GreenBeanPopoverActionsComponent } from '../roasting-section/green-beans/green-bean-popover-actions/green-bean-popover-actions.component';
import { GreenBeanInformationComponent } from '../../components/green-bean-information/green-bean-information.component';
import { Insomnia } from '@awesome-cordova-plugins/insomnia/ngx';
import { PhotoPopoverComponent } from '../../popover/photo-popover/photo-popover.component';
import { PhotoAddComponent } from '../../components/photo-add/photo-add.component';
import { BeanRoastInformationComponent } from '../../components/beans/bean-roast-information/bean-roast-information.component';
Expand Down Expand Up @@ -379,7 +378,6 @@ import { BluetoothDeviceChooserPopoverComponent } from '../../popover/bluetooth-
ThreeDeeTouch,
ImagePicker,
AndroidPermissions,
Insomnia,
],
exports: [
SettingsPage,
Expand Down
12 changes: 12 additions & 0 deletions src/services/uiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { cloneDeep } from 'lodash';
import { UIToast } from './uiToast';
import { UISettingsStorage } from './uiSettingsStorage';
import { InAppBrowser } from '@capacitor/inappbrowser';
import { KeepAwake } from '@capacitor-community/keep-awake';
/**
* Handles every helping functionalities
*/
Expand Down Expand Up @@ -245,6 +246,17 @@ export class UIHelper {
return promise;
}

public deviceKeepAwake() {
try {
KeepAwake.keepAwake();
} catch (ex) {}
}
public deviceAllowSleepAgain() {
try {
KeepAwake.allowSleep();
} catch (ex) {}
}

public convertToNumber(event: any): number {
let eventInput: any = event;
if (eventInput === '') {
Expand Down

0 comments on commit 9589365

Please sign in to comment.