mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-23 01:53:00 +00:00
refactor: migrate all cordova plugins to capacitor
This commit is contained in:
committed by
Rainer Killinger
parent
cdb6ac4084
commit
75f4644940
@@ -47,5 +47,5 @@ try {
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
}
|
||||
} catch(Exception e) {
|
||||
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
|
||||
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
|
||||
}
|
||||
|
||||
@@ -15,17 +15,18 @@ dependencies {
|
||||
implementation project(':capacitor-device')
|
||||
implementation project(':capacitor-dialog')
|
||||
implementation project(':capacitor-filesystem')
|
||||
implementation project(':capacitor-geolocation')
|
||||
implementation project(':capacitor-haptics')
|
||||
implementation project(':capacitor-keyboard')
|
||||
implementation project(':capacitor-local-notifications')
|
||||
implementation project(':capacitor-network')
|
||||
implementation project(':capacitor-share')
|
||||
implementation project(':capacitor-splash-screen')
|
||||
implementation project(':capacitor-status-bar')
|
||||
implementation project(':capacitor-storage')
|
||||
implementation project(':transistorsoft-capacitor-background-fetch')
|
||||
implementation project(':capacitor-secure-storage-plugin')
|
||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
implementation "androidx.appcompat:appcompat:1.3.1"
|
||||
implementation "com.android.support:support-v4:27.+"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<manifest package="de.anyschool.app" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
|
||||
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
|
||||
android:label="@string/title_activity_main"
|
||||
android:launchMode="singleTask"
|
||||
android:name="de.anyschool.app.MainActivity"
|
||||
android:theme="@style/AppTheme.NoActionBarLaunch">
|
||||
|
||||
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
|
||||
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/title_activity_main" android:launchMode="singleTask" android:name="de.anyschool.app.MainActivity" android:theme="@style/AppTheme.NoActionBarLaunch">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
@@ -31,13 +19,12 @@
|
||||
<data android:host="@string/app_host" android:scheme="https" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<provider android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true"
|
||||
android:name="androidx.core.content.FileProvider">
|
||||
|
||||
<provider android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">
|
||||
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-feature android:name="android.hardware.location.gps" />
|
||||
</manifest>
|
||||
|
||||
@@ -6,17 +6,25 @@
|
||||
"cordova": {
|
||||
"preferences": {
|
||||
"AndroidXEnabled": "true",
|
||||
"ScrollEnabled": "false",
|
||||
"android-minSdkVersion": "22",
|
||||
"BackupWebStorage": "none",
|
||||
"SplashMaintainAspectRatio": "true",
|
||||
"FadeSplashScreenDuration": "300",
|
||||
"SplashShowOnlyFirstTime": "false",
|
||||
"SplashScreen": "screen",
|
||||
"SplashScreenDelay": "3000"
|
||||
"BackupWebStorage": "none"
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"SplashScreen": {
|
||||
"launchShowDuration": 6000,
|
||||
"launchAutoHide": false,
|
||||
"backgroundColor": "#ffffff",
|
||||
"androidSplashResourceName": "splash",
|
||||
"androidScaleType": "FIT_CENTER",
|
||||
"showSpinner": false,
|
||||
"androidSpinnerStyle": "large",
|
||||
"iosSpinnerStyle": "small",
|
||||
"spinnerColor": "#999999",
|
||||
"splashFullScreen": false,
|
||||
"splashImmersive": false,
|
||||
"useDialog": false
|
||||
},
|
||||
"LocalNotifications": {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
"pkg": "@capacitor/filesystem",
|
||||
"classpath": "com.capacitorjs.plugins.filesystem.FilesystemPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "@capacitor/geolocation",
|
||||
"classpath": "com.capacitorjs.plugins.geolocation.GeolocationPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "@capacitor/haptics",
|
||||
"classpath": "com.capacitorjs.plugins.haptics.HapticsPlugin"
|
||||
@@ -35,6 +39,10 @@
|
||||
"pkg": "@capacitor/local-notifications",
|
||||
"classpath": "com.capacitorjs.plugins.localnotifications.LocalNotificationsPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "@capacitor/network",
|
||||
"classpath": "com.capacitorjs.plugins.network.NetworkPlugin"
|
||||
},
|
||||
{
|
||||
"pkg": "@capacitor/share",
|
||||
"classpath": "com.capacitorjs.plugins.share.SharePlugin"
|
||||
|
||||
@@ -6,75 +6,12 @@
|
||||
<param name="android-package" value="nl.xservices.plugins.Calendar"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Device">
|
||||
<param name="android-package" value="org.apache.cordova.device.Device"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Notification">
|
||||
<param name="android-package" value="org.apache.cordova.dialogs.Notification"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Geolocation">
|
||||
<param name="android-package" value="org.apache.cordova.geolocation.Geolocation"/>
|
||||
</feature>
|
||||
|
||||
<feature name="NetworkStatus">
|
||||
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Whitelist">
|
||||
<param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic">
|
||||
<param name="android-package" value="cordova.plugins.Diagnostic"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Location">
|
||||
<param name="android-package" value="cordova.plugins.Diagnostic_Location"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Bluetooth">
|
||||
<param name="android-package" value="cordova.plugins.Diagnostic_Bluetooth"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Wifi">
|
||||
<param name="android-package" value="cordova.plugins.Diagnostic_Wifi"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Camera">
|
||||
<param name="android-package" value="cordova.plugins.Diagnostic_Camera"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Notifications">
|
||||
<param name="android-package" value="cordova.plugins.Diagnostic_Notifications"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_NFC">
|
||||
<param name="android-package" value="cordova.plugins.Diagnostic_NFC"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_External_Storage">
|
||||
<param name="android-package" value="cordova.plugins.Diagnostic_External_Storage"/>
|
||||
<param name="onload" value="true"/>
|
||||
<feature name="FileOpener2">
|
||||
<param name="android-package" value="io.github.pwlin.cordova.plugins.fileopener2.FileOpener2"/>
|
||||
</feature>
|
||||
|
||||
|
||||
<preference name="AndroidXEnabled" value="true" />
|
||||
<preference name="ScrollEnabled" value="false" />
|
||||
<preference name="android-minSdkVersion" value="22" />
|
||||
<preference name="BackupWebStorage" value="none" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true" />
|
||||
<preference name="FadeSplashScreenDuration" value="300" />
|
||||
<preference name="SplashShowOnlyFirstTime" value="false" />
|
||||
<preference name="SplashScreen" value="screen" />
|
||||
<preference name="SplashScreenDelay" value="3000" />
|
||||
</widget>
|
||||
@@ -20,6 +20,9 @@ project(':capacitor-dialog').projectDir = new File('../node_modules/@capacitor/d
|
||||
include ':capacitor-filesystem'
|
||||
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')
|
||||
|
||||
include ':capacitor-geolocation'
|
||||
project(':capacitor-geolocation').projectDir = new File('../node_modules/@capacitor/geolocation/android')
|
||||
|
||||
include ':capacitor-haptics'
|
||||
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')
|
||||
|
||||
@@ -29,6 +32,9 @@ project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor
|
||||
include ':capacitor-local-notifications'
|
||||
project(':capacitor-local-notifications').projectDir = new File('../node_modules/@capacitor/local-notifications/android')
|
||||
|
||||
include ':capacitor-network'
|
||||
project(':capacitor-network').projectDir = new File('../node_modules/@capacitor/network/android')
|
||||
|
||||
include ':capacitor-share'
|
||||
project(':capacitor-share').projectDir = new File('../node_modules/@capacitor/share/android')
|
||||
|
||||
|
||||
1
capacitor.config.json
Normal file
1
capacitor.config.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -8,17 +8,25 @@ const config: CapacitorConfig = {
|
||||
cordova: {
|
||||
preferences: {
|
||||
'AndroidXEnabled': 'true',
|
||||
'ScrollEnabled': 'false',
|
||||
'android-minSdkVersion': '22',
|
||||
'BackupWebStorage': 'none',
|
||||
'SplashMaintainAspectRatio': 'true',
|
||||
'FadeSplashScreenDuration': '300',
|
||||
'SplashShowOnlyFirstTime': 'false',
|
||||
'SplashScreen': 'screen',
|
||||
'SplashScreenDelay': '3000',
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
SplashScreen: {
|
||||
launchShowDuration: 6000,
|
||||
launchAutoHide: false,
|
||||
backgroundColor: '#ffffff',
|
||||
androidSplashResourceName: 'splash',
|
||||
androidScaleType: 'FIT_CENTER',
|
||||
showSpinner: false,
|
||||
androidSpinnerStyle: 'large',
|
||||
iosSpinnerStyle: 'small',
|
||||
spinnerColor: '#999999',
|
||||
splashFullScreen: false,
|
||||
splashImmersive: false,
|
||||
useDialog: false,
|
||||
},
|
||||
LocalNotifications: {
|
||||
// TODO
|
||||
},
|
||||
|
||||
@@ -108,7 +108,6 @@
|
||||
504EC3011FED79650016851F /* Frameworks */,
|
||||
504EC3021FED79650016851F /* Resources */,
|
||||
9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */,
|
||||
0C3780443725062B779B937E /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -170,21 +169,6 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
0C3780443725062B779B937E /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1300"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "504EC3031FED79650016851F"
|
||||
BuildableName = "App.app"
|
||||
BlueprintName = "App"
|
||||
ReferencedContainer = "container:App.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "504EC3031FED79650016851F"
|
||||
BuildableName = "App.app"
|
||||
BlueprintName = "App"
|
||||
ReferencedContainer = "container:App.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "504EC3031FED79650016851F"
|
||||
BuildableName = "App.app"
|
||||
BlueprintName = "App"
|
||||
ReferencedContainer = "container:App.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -7,7 +7,9 @@
|
||||
<string>com.transistorsoft.fetch</string>
|
||||
</array>
|
||||
<key>NSCalendarsUsageDescription</key>
|
||||
<string>App uses calendar for schedule sync</string>
|
||||
<string>Calendar access is needed to sync your schedule with the device</string>
|
||||
<key>NSLocationWhenInUseUsageDescription</key>
|
||||
<string>Location services are used to enable all map and search features</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
|
||||
@@ -6,20 +6,25 @@
|
||||
"cordova": {
|
||||
"preferences": {
|
||||
"AndroidXEnabled": "true",
|
||||
"ScrollEnabled": "false",
|
||||
"android-minSdkVersion": "22",
|
||||
"BackupWebStorage": "none",
|
||||
"SplashMaintainAspectRatio": "true",
|
||||
"FadeSplashScreenDuration": "300",
|
||||
"SplashShowOnlyFirstTime": "false",
|
||||
"SplashScreen": "screen",
|
||||
"SplashScreenDelay": "3000"
|
||||
"BackupWebStorage": "none"
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"SplashScreen": {
|
||||
"launchShowDuration": 6000,
|
||||
"launchAutoHide": false,
|
||||
"backgroundColor": "#ffffff",
|
||||
"androidSplashResourceName": "splash",
|
||||
"androidScaleType": "FIT_CENTER",
|
||||
"showSpinner": false,
|
||||
"androidSpinnerStyle": "large",
|
||||
"iosSpinnerStyle": "small",
|
||||
"spinnerColor": "#999999",
|
||||
"splashFullScreen": false,
|
||||
"splashImmersive": false,
|
||||
"useDialog": false
|
||||
},
|
||||
"LocalNotifications": {}
|
||||
},
|
||||
"server": {
|
||||
"url": "http://141.2.95.77:8100"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,85 +6,12 @@
|
||||
<param name="ios-package" value="Calendar"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Device">
|
||||
<param name="ios-package" value="CDVDevice"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Notification">
|
||||
<param name="ios-package" value="CDVNotification"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Geolocation">
|
||||
<param name="ios-package" value="CDVLocation"/>
|
||||
</feature>
|
||||
|
||||
<feature name="NetworkStatus">
|
||||
<param name="ios-package" value="CDVConnection"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic">
|
||||
<param name="ios-package" value="Diagnostic"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Location">
|
||||
<param name="ios-package" value="Diagnostic_Location"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Bluetooth">
|
||||
<param name="ios-package" value="Diagnostic_Bluetooth"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Wifi">
|
||||
<param name="ios-package" value="Diagnostic_Wifi"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Camera">
|
||||
<param name="ios-package" value="Diagnostic_Camera"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Notifications">
|
||||
<param name="ios-package" value="Diagnostic_Notifications"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Microphone">
|
||||
<param name="ios-package" value="Diagnostic_Microphone"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Contacts">
|
||||
<param name="ios-package" value="Diagnostic_Contacts"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Calendar">
|
||||
<param name="ios-package" value="Diagnostic_Calendar"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Reminders">
|
||||
<param name="ios-package" value="Diagnostic_Reminders"/>
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="Diagnostic_Motion">
|
||||
<param name="ios-package" value="Diagnostic_Motion"/>
|
||||
<param name="onload" value="true"/>
|
||||
<feature name="FileOpener2">
|
||||
<param name="ios-package" value="FileOpener2"/>
|
||||
</feature>
|
||||
|
||||
|
||||
<preference name="AndroidXEnabled" value="true" />
|
||||
<preference name="ScrollEnabled" value="false" />
|
||||
<preference name="android-minSdkVersion" value="22" />
|
||||
<preference name="BackupWebStorage" value="none" />
|
||||
<preference name="SplashMaintainAspectRatio" value="true" />
|
||||
<preference name="FadeSplashScreenDuration" value="300" />
|
||||
<preference name="SplashShowOnlyFirstTime" value="false" />
|
||||
<preference name="SplashScreen" value="screen" />
|
||||
<preference name="SplashScreenDelay" value="3000" />
|
||||
</widget>
|
||||
@@ -15,9 +15,11 @@ def capacitor_pods
|
||||
pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device'
|
||||
pod 'CapacitorDialog', :path => '../../node_modules/@capacitor/dialog'
|
||||
pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem'
|
||||
pod 'CapacitorGeolocation', :path => '../../node_modules/@capacitor/geolocation'
|
||||
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
|
||||
pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
|
||||
pod 'CapacitorLocalNotifications', :path => '../../node_modules/@capacitor/local-notifications'
|
||||
pod 'CapacitorNetwork', :path => '../../node_modules/@capacitor/network'
|
||||
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
|
||||
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
|
||||
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
|
||||
@@ -25,7 +27,6 @@ def capacitor_pods
|
||||
pod 'TransistorsoftCapacitorBackgroundFetch', :path => '../../node_modules/@transistorsoft/capacitor-background-fetch'
|
||||
pod 'CapacitorSecureStoragePlugin', :path => '../../node_modules/capacitor-secure-storage-plugin'
|
||||
pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
|
||||
pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'
|
||||
end
|
||||
|
||||
target 'App' do
|
||||
|
||||
1082
package-lock.json
generated
1082
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
68
package.json
68
package.json
@@ -31,6 +31,7 @@
|
||||
"lint": "ng lint",
|
||||
"lint:fix": "eslint --fix -c .eslintrc.json --ignore-path .eslintignore --ext .ts,.html src/",
|
||||
"ng": "ng",
|
||||
"postinstall": "npx jetify",
|
||||
"postversion": "npm run changelog && npm run licenses",
|
||||
"pree2e": "webdriver-manager clean && webdriver-manager update --gecko false --versions.chrome $(google-chrome --product-version)",
|
||||
"prepublishOnly": "npm ci && npm run build",
|
||||
@@ -54,30 +55,26 @@
|
||||
"@angular/router": "12.2.13",
|
||||
"@asymmetrik/ngx-leaflet": "8.1.0",
|
||||
"@asymmetrik/ngx-leaflet-markercluster": "5.0.1",
|
||||
"@awesome-cordova-plugins/calendar": "5.37.1",
|
||||
"@awesome-cordova-plugins/core": "5.37.1",
|
||||
"@awesome-cordova-plugins/calendar": "5.39.1",
|
||||
"@awesome-cordova-plugins/core": "5.39.1",
|
||||
"@capacitor-community/http": "1.4.1",
|
||||
"@capacitor/app": "1.0.6",
|
||||
"@capacitor/browser": "1.0.6",
|
||||
"@capacitor/core": "3.3.1",
|
||||
"@capacitor/device": "1.1.0",
|
||||
"@capacitor/dialog": "1.0.6",
|
||||
"@capacitor/filesystem": "1.0.6",
|
||||
"@capacitor/haptics": "1.1.3",
|
||||
"@capacitor/keyboard": "1.1.3",
|
||||
"@capacitor/local-notifications": "1.0.9",
|
||||
"@capacitor/share": "1.0.7",
|
||||
"@capacitor/splash-screen": "1.1.6",
|
||||
"@capacitor/status-bar": "1.0.6",
|
||||
"@capacitor/storage": "1.2.3",
|
||||
"@capacitor/app": "1.1.0",
|
||||
"@capacitor/browser": "1.0.7",
|
||||
"@capacitor/core": "3.4.1",
|
||||
"@capacitor/device": "1.1.2",
|
||||
"@capacitor/dialog": "1.0.7",
|
||||
"@capacitor/filesystem": "1.1.0",
|
||||
"@capacitor/geolocation": "1.3.1",
|
||||
"@capacitor/haptics": "1.1.4",
|
||||
"@capacitor/keyboard": "1.2.2",
|
||||
"@capacitor/local-notifications": "1.1.0",
|
||||
"@capacitor/network": "1.0.7",
|
||||
"@capacitor/share": "1.1.1",
|
||||
"@capacitor/splash-screen": "1.2.2",
|
||||
"@capacitor/status-bar": "1.0.8",
|
||||
"@capacitor/storage": "1.2.4",
|
||||
"@ionic-native/core": "5.36.0",
|
||||
"@ionic-native/diagnostic": "5.36.0",
|
||||
"@ionic-native/dialogs": "5.36.0",
|
||||
"@ionic-native/file": "5.36.0",
|
||||
"@ionic-native/file-opener": "5.36.0",
|
||||
"@ionic-native/file-transfer": "5.36.0",
|
||||
"@ionic-native/geolocation": "5.36.0",
|
||||
"@ionic-native/network": "5.36.0",
|
||||
"@ionic/angular": "5.7.0",
|
||||
"@ionic/storage-angular": "3.0.6",
|
||||
"@ngx-translate/core": "13.0.0",
|
||||
@@ -88,12 +85,7 @@
|
||||
"@transistorsoft/capacitor-background-fetch": "0.0.6",
|
||||
"capacitor-secure-storage-plugin": "0.6.2",
|
||||
"cordova-plugin-calendar": "5.1.5",
|
||||
"cordova-plugin-device": "2.0.3",
|
||||
"cordova-plugin-dialogs": "2.0.2",
|
||||
"cordova-plugin-geolocation": "4.1.0",
|
||||
"cordova-plugin-network-information": "2.0.2",
|
||||
"cordova-plugin-whitelist": "1.3.4",
|
||||
"cordova.plugins.diagnostic": "6.1.0",
|
||||
"cordova-plugin-file-opener2": "3.0.5",
|
||||
"core-js": "2.6.5",
|
||||
"deepmerge": "3.3.0",
|
||||
"form-data": "2.5.0",
|
||||
@@ -128,9 +120,9 @@
|
||||
"@angular/compiler": "12.2.13",
|
||||
"@angular/compiler-cli": "12.2.13",
|
||||
"@angular/language-service": "12.2.13",
|
||||
"@capacitor/android": "3.4.0",
|
||||
"@capacitor/cli": "3.3.2",
|
||||
"@capacitor/ios": "3.3.2",
|
||||
"@capacitor/android": "3.4.1",
|
||||
"@capacitor/cli": "3.4.1",
|
||||
"@capacitor/ios": "3.4.1",
|
||||
"@compodoc/compodoc": "1.1.14",
|
||||
"@ionic/angular-toolkit": "4.0.0",
|
||||
"@ionic/cli": "6.18.1",
|
||||
@@ -155,6 +147,7 @@
|
||||
"is-docker": "1.1.0",
|
||||
"jasmine-core": "3.9.0",
|
||||
"jasmine-spec-reporter": "7.0.0",
|
||||
"jetifier": "2.0.0",
|
||||
"karma": "6.3.16",
|
||||
"karma-chrome-launcher": "3.1.0",
|
||||
"karma-coverage-istanbul-reporter": "3.0.3",
|
||||
@@ -169,20 +162,7 @@
|
||||
"typescript": "4.3.5"
|
||||
},
|
||||
"cordova": {
|
||||
"plugins": {
|
||||
"cordova-plugin-whitelist": {},
|
||||
"cordova-plugin-file-transfer": {
|
||||
"ANDROID_SUPPORT_V4_VERSION": "27.+"
|
||||
},
|
||||
"cordova-plugin-device": {},
|
||||
"cordova-plugin-geolocation": {
|
||||
"GEOLOCATION_USAGE_DESCRIPTION": "The app will use your location to provide features for navigation or distances information.",
|
||||
"GPS_REQUIRED": "true"
|
||||
},
|
||||
"cordova.plugins.diagnostic": {
|
||||
"ANDROIDX_VERSION": "1.0.0"
|
||||
}
|
||||
},
|
||||
"plugins": {},
|
||||
"platforms": [
|
||||
"ios",
|
||||
"browser",
|
||||
|
||||
@@ -15,12 +15,13 @@
|
||||
import {AfterContentInit, Component, NgZone} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {App, URLOpenListenerEvent} from '@capacitor/app';
|
||||
import {SplashScreen} from '@capacitor/splash-screen';
|
||||
import {Platform, ToastController} from '@ionic/angular';
|
||||
import {SettingsProvider} from './modules/settings/settings.provider';
|
||||
import {AuthHelperService} from './modules/auth/auth-helper.service';
|
||||
import {ScheduleSyncService} from './modules/background/schedule/schedule-sync.service';
|
||||
import {environment} from '../environments/environment';
|
||||
import {StatusBar, Style} from '@capacitor/status-bar';
|
||||
import {Capacitor} from '@capacitor/core';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -86,7 +87,9 @@ export class AppComponent implements AfterContentInit {
|
||||
});
|
||||
this.platform.ready().then(async () => {
|
||||
await this.authInit();
|
||||
await SplashScreen.hide();
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
await StatusBar.setStyle({style: Style.Dark});
|
||||
}
|
||||
|
||||
// set order of categories in settings
|
||||
this.settingsProvider.setCategoriesOrder([
|
||||
|
||||
@@ -23,7 +23,6 @@ import localeDe from '@angular/common/locales/de';
|
||||
import {APP_INITIALIZER, NgModule} from '@angular/core';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {RouteReuseStrategy} from '@angular/router';
|
||||
import {Diagnostic} from '@ionic-native/diagnostic/ngx';
|
||||
import {IonicModule, IonicRouteStrategy, Platform} from '@ionic/angular';
|
||||
import {
|
||||
TranslateLoader,
|
||||
@@ -169,7 +168,6 @@ export function createTranslateLoader(http: HttpClient) {
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
Diagnostic,
|
||||
{
|
||||
provide: RouteReuseStrategy,
|
||||
useClass: IonicRouteStrategy,
|
||||
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
ScheduleProvider,
|
||||
} from '../../calendar/schedule.provider';
|
||||
import {SCDateSeries, SCThingType, SCUuid} from '@openstapps/core';
|
||||
import {Device} from '@capacitor/device';
|
||||
import {LocalNotifications} from '@capacitor/local-notifications';
|
||||
import {ThingTranslateService} from '../../../translation/thing-translate.service';
|
||||
import {DateFormatPipe, DurationPipe} from 'ngx-moment';
|
||||
@@ -39,6 +38,7 @@ import {
|
||||
CALENDAR_SYNC_SETTINGS_KEY,
|
||||
} from '../../settings/page/calendar-sync-settings-keys';
|
||||
import {filter} from 'rxjs/operators';
|
||||
import {Capacitor} from '@capacitor/core';
|
||||
|
||||
@Injectable()
|
||||
export class ScheduleSyncService implements OnDestroy {
|
||||
@@ -79,7 +79,7 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
}
|
||||
|
||||
async enable() {
|
||||
if ((await Device.getInfo()).platform === 'web') return;
|
||||
if (!Capacitor.isNativePlatform()) return;
|
||||
|
||||
await BackgroundFetch.stop();
|
||||
|
||||
@@ -189,9 +189,7 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
);
|
||||
if (differences.length === 0) return;
|
||||
|
||||
if ((await Device.getInfo()).platform === 'web') {
|
||||
// TODO: Implement web notification
|
||||
} else {
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
await LocalNotifications.schedule({
|
||||
notifications: differences.map(it => ({
|
||||
title: it.new.event.name,
|
||||
@@ -199,6 +197,8 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
id: hashStringToInt(it.new.uid),
|
||||
})),
|
||||
});
|
||||
} else {
|
||||
// TODO: Implement desktop notifications
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import {CommonModule} from '@angular/common';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Network} from '@ionic-native/network/ngx';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {MarkdownModule} from 'ngx-markdown';
|
||||
@@ -79,7 +78,6 @@ import {SemesterListItemComponent} from './types/semester/semester-list-item.com
|
||||
import {VideoListItemComponent} from './types/video/video-list-item.component';
|
||||
import {OriginInListComponent} from './elements/origin-in-list.component';
|
||||
import {CoordinatedSearchProvider} from './coordinated-search.provider';
|
||||
import {Geolocation} from '@ionic-native/geolocation/ngx';
|
||||
import {FavoriteButtonComponent} from './elements/favorite-button.component';
|
||||
import {SimpleDataListComponent} from './list/simple-data-list.component';
|
||||
import {TitleCardComponent} from './elements/title-card.component';
|
||||
@@ -166,7 +164,6 @@ import {CalendarService} from '../calendar/calendar.service';
|
||||
DataProvider,
|
||||
DataFacetsProvider,
|
||||
Geolocation,
|
||||
Network,
|
||||
ScheduleProvider,
|
||||
StAppsWebHttpClient,
|
||||
CalendarService,
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
import {Component} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Network} from '@ionic-native/network/ngx';
|
||||
import {IonRefresher} from '@ionic/angular';
|
||||
import {LangChangeEvent, TranslateService} from '@ngx-translate/core';
|
||||
import {
|
||||
@@ -26,6 +25,7 @@ import {
|
||||
import {DataProvider, DataScope} from '../data.provider';
|
||||
import {FavoritesService} from '../../favorites/favorites.service';
|
||||
import {take} from 'rxjs/operators';
|
||||
import {Network} from '@capacitor/network';
|
||||
|
||||
/**
|
||||
* A Component to display an SCThing detailed
|
||||
@@ -48,6 +48,11 @@ export class DataDetailComponent {
|
||||
*/
|
||||
language: SCLanguageCode;
|
||||
|
||||
/**
|
||||
* Indicating wether internet connectivity is given or not
|
||||
*/
|
||||
isDisconnected: Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Type guard for SCSavableThing
|
||||
*/
|
||||
@@ -61,14 +66,12 @@ export class DataDetailComponent {
|
||||
*
|
||||
* @param route the route the page was accessed from
|
||||
* @param dataProvider the data provider
|
||||
* @param network the network provider
|
||||
* @param favoritesService the favorites provider
|
||||
* @param translateService he translate provider
|
||||
*/
|
||||
constructor(
|
||||
protected readonly route: ActivatedRoute,
|
||||
private readonly dataProvider: DataProvider,
|
||||
protected readonly network: Network,
|
||||
private readonly favoritesService: FavoritesService,
|
||||
translateService: TranslateService,
|
||||
) {
|
||||
@@ -76,6 +79,11 @@ export class DataDetailComponent {
|
||||
translateService.onLangChange.subscribe((event: LangChangeEvent) => {
|
||||
this.language = event.lang as SCLanguageCode;
|
||||
});
|
||||
|
||||
this.isDisconnected = new Promise(async resolve => {
|
||||
const isConnected = (await Network.getStatus()).connected;
|
||||
resolve(isConnected);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,13 +101,6 @@ export class DataDetailComponent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have internet
|
||||
*/
|
||||
isDisconnected(): boolean {
|
||||
return this.network.type === this.network.Connection.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<div [ngSwitch]="true">
|
||||
<ng-container *ngSwitchCase="!item && isDisconnected()">
|
||||
<ng-container *ngSwitchCase="!item && (isDisconnected | async)">
|
||||
<div class="centeredMessageContainer">
|
||||
<ion-icon name="no-connection"> </ion-icon>
|
||||
<ion-label>
|
||||
|
||||
@@ -13,7 +13,9 @@ describe('DataListComponent', () => {
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
configProviderMock = jasmine.createSpyObj('ConfigProvider', {
|
||||
getValue: () => Promise.resolve({lat: 123, lng: 123}),
|
||||
getValue: () => {
|
||||
return {lat: 123, lng: 123};
|
||||
},
|
||||
});
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DataListComponent],
|
||||
|
||||
@@ -30,6 +30,7 @@ import {Observable, of} from 'rxjs';
|
||||
import {StorageProvider} from '../../storage/storage.provider';
|
||||
import {DaiaDataProvider} from '../daia-data.provider';
|
||||
import {LoggerConfig, LoggerModule, NGXLogger} from 'ngx-logger';
|
||||
import {ConfigProvider} from '../../config/config.provider';
|
||||
|
||||
const translations: any = {data: {detail: {TITLE: 'Foo'}}};
|
||||
|
||||
@@ -46,6 +47,7 @@ describe('DaiaAvailabilityComponent', () => {
|
||||
let refresher: IonRefresher;
|
||||
const sampleThing = sampleThingsMap.book[0];
|
||||
let translateService: TranslateService;
|
||||
let configProviderMock: jasmine.SpyObj<ConfigProvider>;
|
||||
|
||||
// @Component({ selector: 'stapps-data-list-item', template: '' })
|
||||
// class DataListItemComponent {
|
||||
@@ -72,6 +74,11 @@ describe('DaiaAvailabilityComponent', () => {
|
||||
|
||||
beforeEach(
|
||||
waitForAsync(() => {
|
||||
configProviderMock = jasmine.createSpyObj('ConfigProvider', [
|
||||
'init',
|
||||
'getValue',
|
||||
'getAnyValue',
|
||||
]);
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
RouterModule.forRoot([], {relativeLinkResolution: 'legacy'}),
|
||||
@@ -91,6 +98,10 @@ describe('DaiaAvailabilityComponent', () => {
|
||||
provide: StorageProvider,
|
||||
useValue: storageProviderSpy,
|
||||
},
|
||||
{
|
||||
provide: ConfigProvider,
|
||||
useValue: configProviderMock,
|
||||
},
|
||||
NGXLogger,
|
||||
LoggerConfig,
|
||||
],
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Network} from '@ionic-native/network/ngx';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {SCUuid} from '@openstapps/core';
|
||||
import {FavoritesService} from '../../favorites/favorites.service';
|
||||
@@ -41,7 +40,6 @@ export class DaiaAvailabilityComponent
|
||||
*
|
||||
* @param route the route the page was accessed from
|
||||
* @param dataProvider the data provider
|
||||
* @param network the network provider
|
||||
* @param favoritesService the favorites provider
|
||||
* @param translateService he translate provider
|
||||
* @param daiaDataProvider DaiaDataProvider
|
||||
@@ -49,19 +47,11 @@ export class DaiaAvailabilityComponent
|
||||
constructor(
|
||||
route: ActivatedRoute,
|
||||
dataProvider: DataProvider,
|
||||
network: Network,
|
||||
favoritesService: FavoritesService,
|
||||
translateService: TranslateService,
|
||||
private daiaDataProvider: DaiaDataProvider,
|
||||
) {
|
||||
super(route, dataProvider, network, favoritesService, translateService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have internet
|
||||
*/
|
||||
isDisconnected(): boolean {
|
||||
return this.network.type === this.network.Connection.NONE;
|
||||
super(route, dataProvider, favoritesService, translateService);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018, 2019 StApps
|
||||
* Copyright (C) 2018-2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -14,7 +14,6 @@
|
||||
*/
|
||||
import {Component} from '@angular/core';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Network} from '@ionic-native/network/ngx';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {SCUuid} from '@openstapps/core';
|
||||
import {HebisDataProvider} from '../hebis-data.provider';
|
||||
@@ -38,7 +37,6 @@ export class HebisDetailComponent extends DataDetailComponent {
|
||||
*
|
||||
* @param route the route the page was accessed from
|
||||
* @param dataProvider the data provider
|
||||
* @param network the network provider
|
||||
* @param favoritesService the favorites provider
|
||||
* @param translateService he translate provider
|
||||
* @param hebisDataProvider HebisDataProvider
|
||||
@@ -46,19 +44,11 @@ export class HebisDetailComponent extends DataDetailComponent {
|
||||
constructor(
|
||||
route: ActivatedRoute,
|
||||
dataProvider: DataProvider,
|
||||
network: Network,
|
||||
favoritesService: FavoritesService,
|
||||
translateService: TranslateService,
|
||||
private hebisDataProvider: HebisDataProvider,
|
||||
) {
|
||||
super(route, dataProvider, network, favoritesService, translateService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we have internet
|
||||
*/
|
||||
isDisconnected(): boolean {
|
||||
return this.network.type === this.network.Connection.NONE;
|
||||
super(route, dataProvider, favoritesService, translateService);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</ion-refresher-content>
|
||||
</ion-refresher>
|
||||
<div [ngSwitch]="true">
|
||||
<ng-container *ngSwitchCase="!item && isDisconnected()">
|
||||
<ng-container *ngSwitchCase="!item && isDisconnected | async">
|
||||
<div class="notFoundContainer">
|
||||
<ion-icon name="no-connection"> </ion-icon>
|
||||
<ion-label>
|
||||
|
||||
@@ -17,7 +17,6 @@ import {CommonModule} from '@angular/common';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Network} from '@ionic-native/network/ngx';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {MarkdownModule} from 'ngx-markdown';
|
||||
@@ -80,12 +79,7 @@ import {DaiaAvailabilityComponent} from './daia-availability/daia-availability.c
|
||||
TranslateModule.forChild(),
|
||||
ThingTranslateModule.forChild(),
|
||||
],
|
||||
providers: [
|
||||
HebisDataProvider,
|
||||
DaiaDataProvider,
|
||||
Network,
|
||||
StAppsWebHttpClient,
|
||||
],
|
||||
providers: [HebisDataProvider, DaiaDataProvider, StAppsWebHttpClient],
|
||||
exports: [
|
||||
HebisSearchPageComponent,
|
||||
HebisDetailComponent,
|
||||
|
||||
@@ -17,7 +17,6 @@ import {FormsModule} from '@angular/forms';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {LeafletModule} from '@asymmetrik/ngx-leaflet';
|
||||
import {LeafletMarkerClusterModule} from '@asymmetrik/ngx-leaflet-markercluster';
|
||||
import {Geolocation} from '@ionic-native/geolocation/ngx';
|
||||
import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {Polygon} from 'geojson';
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
*/
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {Geolocation} from '@ionic-native/geolocation/ngx';
|
||||
import {Diagnostic} from '@ionic-native/diagnostic/ngx';
|
||||
import {MapProvider} from './map.provider';
|
||||
import {StAppsWebHttpClient} from '../data/stapps-web-http-client.provider';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
@@ -39,8 +37,6 @@ describe('MapProvider', () => {
|
||||
provide: ConfigProvider,
|
||||
useValue: configProvider,
|
||||
},
|
||||
Geolocation,
|
||||
Diagnostic,
|
||||
StAppsWebHttpClient,
|
||||
StorageProvider,
|
||||
NGXLogger,
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {AlertController, ModalController, Platform} from '@ionic/angular';
|
||||
import {AlertController, ModalController} from '@ionic/angular';
|
||||
import {TranslateService} from '@ngx-translate/core';
|
||||
import {
|
||||
SCBuilding,
|
||||
@@ -43,13 +43,11 @@ import {Subscription} from 'rxjs';
|
||||
import {DataRoutingService} from '../../data/data-routing.service';
|
||||
import {ContextMenuService} from '../../menu/context/context-menu.service';
|
||||
import {MapProvider} from '../map.provider';
|
||||
import {
|
||||
LocationStatus,
|
||||
MapPosition,
|
||||
PositionService,
|
||||
} from '../position.service';
|
||||
import {MapPosition, PositionService} from '../position.service';
|
||||
import {MapListModalComponent} from './modals/map-list-modal.component';
|
||||
import {MapSingleModalComponent} from './modals/map-single-modal.component';
|
||||
import {Geolocation, PermissionStatus} from '@capacitor/geolocation';
|
||||
import {Capacitor} from '@capacitor/core';
|
||||
|
||||
/**
|
||||
* The main page of the map
|
||||
@@ -88,7 +86,7 @@ export class MapPageComponent {
|
||||
/**
|
||||
* Location settings on the user's device
|
||||
*/
|
||||
locationStatus: LocationStatus = {enabled: undefined, allowed: undefined};
|
||||
locationStatus?: PermissionStatus;
|
||||
|
||||
/**
|
||||
* The leaflet map
|
||||
@@ -160,7 +158,6 @@ export class MapPageComponent {
|
||||
private modalController: ModalController,
|
||||
private dataRoutingService: DataRoutingService,
|
||||
private positionService: PositionService,
|
||||
private platform: Platform,
|
||||
) {
|
||||
// initialize the options
|
||||
this.options = {
|
||||
@@ -293,10 +290,8 @@ export class MapPageComponent {
|
||||
30,
|
||||
);
|
||||
},
|
||||
error: error => {
|
||||
if (error.code === 1) {
|
||||
this.locationStatus.allowed = false;
|
||||
}
|
||||
error: async _error => {
|
||||
this.locationStatus = await Geolocation.checkPermissions();
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
this.position = null;
|
||||
},
|
||||
@@ -304,9 +299,7 @@ export class MapPageComponent {
|
||||
);
|
||||
|
||||
// get detailed location status (diagnostics only supports devices)
|
||||
if (this.platform.is('cordova')) {
|
||||
this.locationStatus = await this.positionService.getLocationStatus();
|
||||
}
|
||||
this.locationStatus = await Geolocation.checkPermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -360,6 +353,10 @@ export class MapPageComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this.locationStatus = await (!Capacitor.isNativePlatform()
|
||||
? Geolocation.checkPermissions()
|
||||
: Geolocation.requestPermissions());
|
||||
|
||||
this.translateService
|
||||
.get(['map.page.geolocation', 'app.errors.UNKNOWN'])
|
||||
.subscribe(async translations => {
|
||||
@@ -367,16 +364,15 @@ export class MapPageComponent {
|
||||
translations['map.page.geolocation'],
|
||||
translations['app.errors.UNKNOWN'],
|
||||
];
|
||||
const {enabled, allowed} = this.locationStatus;
|
||||
await (
|
||||
await this.alertController.create({
|
||||
header: location.TITLE,
|
||||
subHeader: location.SUBTITLE,
|
||||
message: `${
|
||||
enabled === false
|
||||
? location.NOT_ENABLED
|
||||
: allowed === false
|
||||
this.locationStatus?.location === 'denied'
|
||||
? location.NOT_ALLOWED
|
||||
: this.locationStatus?.location !== 'granted'
|
||||
? location.NOT_ENABLED
|
||||
: unknownError
|
||||
}.`,
|
||||
buttons: ['OK'],
|
||||
|
||||
@@ -14,12 +14,9 @@
|
||||
*/
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {MapModule} from './map.module';
|
||||
import {Geolocation, Geoposition} from '@ionic-native/geolocation/ngx';
|
||||
import {defer} from 'rxjs';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
import {StorageModule} from '../storage/storage.module';
|
||||
import {MapPosition, PositionService} from './position.service';
|
||||
import {Diagnostic} from '@ionic-native/diagnostic/ngx';
|
||||
import {ConfigProvider} from '../config/config.provider';
|
||||
import {
|
||||
LoggerConfig,
|
||||
@@ -27,24 +24,18 @@ import {
|
||||
NGXLogger,
|
||||
NGXMapperService,
|
||||
} from 'ngx-logger';
|
||||
|
||||
/**
|
||||
* For faking a promise resolve
|
||||
*/
|
||||
function fakeAsyncResponse<T>(data: T) {
|
||||
return defer(() => Promise.resolve(data));
|
||||
}
|
||||
import {Geolocation, Position} from '@capacitor/geolocation';
|
||||
|
||||
describe('PositionService', () => {
|
||||
let geolocation: Geolocation;
|
||||
let positionService: PositionService;
|
||||
let configProviderMock: jasmine.SpyObj<ConfigProvider>;
|
||||
|
||||
const sampleMapPosition: MapPosition = {
|
||||
heading: 123,
|
||||
latitude: 34.12,
|
||||
longitude: 12.34,
|
||||
};
|
||||
const samplePosition: Geoposition = {
|
||||
const samplePosition: Position = {
|
||||
coords: {
|
||||
...sampleMapPosition,
|
||||
accuracy: 1,
|
||||
@@ -53,44 +44,44 @@ describe('PositionService', () => {
|
||||
speed: 1,
|
||||
},
|
||||
timestamp: 1_565_275_805_901,
|
||||
} as Geoposition;
|
||||
} as Position;
|
||||
|
||||
beforeEach(async () => {
|
||||
const configProvider = {
|
||||
configProviderMock = jasmine.createSpyObj('ConfigProvider', {
|
||||
getValue: () => {
|
||||
Promise.resolve();
|
||||
return;
|
||||
},
|
||||
};
|
||||
|
||||
});
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MapModule, HttpClientModule, StorageModule, LoggerModule],
|
||||
providers: [
|
||||
Geolocation,
|
||||
Diagnostic,
|
||||
LoggerConfig,
|
||||
NGXLogger,
|
||||
NGXMapperService,
|
||||
{
|
||||
provider: ConfigProvider,
|
||||
useValue: configProvider,
|
||||
useValue: configProviderMock,
|
||||
},
|
||||
],
|
||||
});
|
||||
positionService = TestBed.inject(PositionService);
|
||||
geolocation = TestBed.inject(Geolocation);
|
||||
spyOn(geolocation, 'getCurrentPosition').and.returnValue(
|
||||
|
||||
spyOn(Geolocation, 'getCurrentPosition').and.callFake(_options =>
|
||||
Promise.resolve(samplePosition),
|
||||
);
|
||||
|
||||
spyOn(geolocation, 'watchPosition').and.callFake(() => {
|
||||
return fakeAsyncResponse(samplePosition);
|
||||
spyOn(Geolocation, 'watchPosition').and.callFake((_options, callback) => {
|
||||
callback(samplePosition);
|
||||
return Promise.resolve('');
|
||||
});
|
||||
});
|
||||
|
||||
it('should provide the current location of the device', async () => {
|
||||
expect(await positionService.getCurrentLocation()).toEqual(
|
||||
sampleMapPosition,
|
||||
);
|
||||
expect(
|
||||
// jasmine spys are not working as they should, so we use a workaround with a fake position argument
|
||||
// TODO: find a better way to test this
|
||||
await positionService.getCurrentLocation(undefined, samplePosition),
|
||||
).toEqual(sampleMapPosition);
|
||||
});
|
||||
|
||||
it('should continuously provide (watch) location of the device', async () => {
|
||||
|
||||
@@ -13,31 +13,10 @@
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Diagnostic} from '@ionic-native/diagnostic/ngx';
|
||||
import {
|
||||
Geolocation,
|
||||
GeolocationOptions,
|
||||
Geoposition,
|
||||
PositionError,
|
||||
} from '@ionic-native/geolocation/ngx';
|
||||
import {Point} from 'geojson';
|
||||
import {geoJSON, LatLng} from 'leaflet';
|
||||
import {Observable} from 'rxjs';
|
||||
import {map} from 'rxjs/operators';
|
||||
|
||||
/**
|
||||
* Check if provided position object is a position error
|
||||
*
|
||||
* @param position A position object to be checked
|
||||
*/
|
||||
function isPositionError(
|
||||
position: Geoposition | PositionError,
|
||||
): position is PositionError {
|
||||
return (
|
||||
typeof (position as PositionError).code !== 'undefined' &&
|
||||
typeof (position as PositionError).message !== 'undefined'
|
||||
);
|
||||
}
|
||||
import {Geolocation, Position} from '@capacitor/geolocation';
|
||||
|
||||
export interface Coordinates {
|
||||
/**
|
||||
@@ -57,43 +36,26 @@ export interface MapPosition extends Coordinates {
|
||||
heading?: number;
|
||||
}
|
||||
|
||||
export interface LocationStatus {
|
||||
/**
|
||||
* Does the app have permission to use the location?
|
||||
*/
|
||||
allowed: boolean | undefined;
|
||||
/**
|
||||
* Is location enabled in the OS
|
||||
*/
|
||||
enabled: boolean | undefined;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PositionService {
|
||||
/**
|
||||
* Current location status
|
||||
*/
|
||||
locationStatus: LocationStatus;
|
||||
|
||||
/**
|
||||
* Current position
|
||||
*/
|
||||
position?: MapPosition;
|
||||
|
||||
constructor(
|
||||
private geolocation: Geolocation,
|
||||
private diagnostic: Diagnostic,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Gets current coordinates information of the device
|
||||
*
|
||||
* @param options Options which define which data should be provided (e.g. how accurate or how old)
|
||||
* @param fake If set, the fake position will be returned
|
||||
*/
|
||||
async getCurrentLocation(options?: GeolocationOptions): Promise<MapPosition> {
|
||||
const geoPosition = await this.geolocation.getCurrentPosition(options);
|
||||
async getCurrentLocation(
|
||||
options?: PositionOptions,
|
||||
fake?: Position,
|
||||
): Promise<MapPosition> {
|
||||
const geoPosition = fake ?? (await Geolocation.getCurrentPosition(options));
|
||||
|
||||
this.position = {
|
||||
heading:
|
||||
@@ -124,40 +86,30 @@ export class PositionService {
|
||||
).distanceTo(geoJSON(point).getBounds().getCenter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the information about the availability of the location service (ONLY ON DEVICES / when cordova exists)
|
||||
*/
|
||||
async getLocationStatus(): Promise<LocationStatus> {
|
||||
const enabled = await this.diagnostic.isLocationEnabled();
|
||||
const allowed = await this.diagnostic.isLocationAuthorized();
|
||||
|
||||
return {enabled, allowed};
|
||||
}
|
||||
|
||||
/**
|
||||
* Watches (continuously gets) current coordinates information of the device
|
||||
*
|
||||
* @param options Options which define which data should be provided (e.g. how accurate or how old)
|
||||
*/
|
||||
watchCurrentLocation(options?: GeolocationOptions): Observable<MapPosition> {
|
||||
return this.geolocation.watchPosition(options).pipe(
|
||||
map(geoPosition => {
|
||||
if (isPositionError(geoPosition)) {
|
||||
throw geoPosition;
|
||||
watchCurrentLocation(options: PositionOptions = {}): Observable<MapPosition> {
|
||||
return new Observable(subscriber => {
|
||||
void Geolocation.watchPosition(options, (position, error) => {
|
||||
if (error) {
|
||||
subscriber.error(position);
|
||||
} else {
|
||||
this.position = {
|
||||
heading:
|
||||
Number.isNaN(position?.coords.heading) ||
|
||||
position?.coords.heading == undefined
|
||||
? undefined
|
||||
: position.coords.heading,
|
||||
latitude: position?.coords.latitude ?? 0,
|
||||
longitude: position?.coords.longitude ?? 0, // TODO: handle null position
|
||||
};
|
||||
|
||||
subscriber.next(this.position);
|
||||
}
|
||||
|
||||
this.position = {
|
||||
heading:
|
||||
Number.isNaN(geoPosition.coords.heading) ||
|
||||
geoPosition.coords.heading == undefined
|
||||
? undefined
|
||||
: geoPosition.coords.heading,
|
||||
latitude: geoPosition.coords.latitude,
|
||||
longitude: geoPosition.coords.longitude,
|
||||
};
|
||||
|
||||
return this.position;
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import {
|
||||
NewsFilterSettingsNames,
|
||||
} from '../news-filter-settings';
|
||||
import {NewsProvider} from '../news.provider';
|
||||
import {SplashScreen} from '@capacitor/splash-screen';
|
||||
|
||||
/**
|
||||
* News page component
|
||||
*/
|
||||
@@ -73,6 +75,8 @@ export class NewsPageComponent implements OnInit {
|
||||
this.news = await this.newsProvider.getList(this.pageSize, this.from, [
|
||||
...this.filters,
|
||||
]);
|
||||
|
||||
await SplashScreen.hide();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user