@saltcorn/mobile-app 1.1.3-beta.9 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,8 +2,19 @@ const { parseStringPromise, Builder } = require("xml2js");
2
2
  const { join } = require("path");
3
3
  const { readFileSync, writeFileSync } = require("fs");
4
4
 
5
+ const readMobileConfig = () => {
6
+ console.log("Reading mobile config");
7
+ const content = readFileSync(
8
+ "/saltcorn-mobile-app/saltcorn-mobile-cfg.json",
9
+ "utf8"
10
+ );
11
+ console.log(content);
12
+ return JSON.parse(content);
13
+ };
14
+
5
15
  (async () => {
6
16
  try {
17
+ const { permissions, features } = readMobileConfig();
7
18
  const androidManifest = join(
8
19
  "android",
9
20
  "app",
@@ -14,17 +25,12 @@ const { readFileSync, writeFileSync } = require("fs");
14
25
  const content = readFileSync(androidManifest);
15
26
  const parsed = await parseStringPromise(content);
16
27
 
17
- parsed.manifest["uses-permission"] = [
18
- { $: { "android:name": "android.permission.READ_EXTERNAL_STORAGE" } },
19
- { $: { "android:name": "android.permission.WRITE_EXTERNAL_STORAGE" } },
20
- { $: { "android:name": "android.permission.INTERNET" } },
21
- { $: { "android:name": "android.permission.CAMERA" } },
22
- { $: { "android:name": "android.permission.ACCESS_COARSE_LOCATION" } },
23
- { $: { "android:name": "android.permission.ACCESS_FINE_LOCATION" } },
24
- ];
25
- parsed.manifest["uses-feature"] = [
26
- { $: { "android:name": "android.hardware.location.gps" } },
27
- ];
28
+ parsed.manifest["uses-permission"] = permissions.map((p) => ({
29
+ $: { "android:name": p },
30
+ }));
31
+ parsed.manifest["uses-feature"] = features.map((f) => ({
32
+ $: { "android:name": f },
33
+ }));
28
34
 
29
35
  parsed.manifest.application[0].$ = {
30
36
  ...parsed.manifest.application[0].$,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@saltcorn/mobile-app",
3
3
  "displayName": "Saltcorn mobile app",
4
- "version": "1.1.3-beta.9",
4
+ "version": "1.1.3",
5
5
  "description": "Saltcorn mobile app for Android and iOS",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { apiCall } from "./api";
4
4
  import { Camera, CameraResultType } from "@capacitor/camera";
5
- import { Geolocation } from "@capacitor/geolocation";
6
5
  import { ScreenOrientation } from "@capacitor/screen-orientation";
7
6
  import { SendIntent } from "send-intent";
8
7
 
@@ -167,17 +166,6 @@ export async function takePhoto() {
167
166
  }
168
167
  }
169
168
 
170
- export async function getGeolocation(successCb, errorCb) {
171
- try {
172
- const coordinates = await Geolocation.getCurrentPosition();
173
- if (successCb) successCb(coordinates);
174
- return coordinates;
175
- } catch (error) {
176
- if (errorCb) errorCb(error);
177
- return null;
178
- }
179
- }
180
-
181
169
  export function registerScreenOrientationListener(name, listener) {
182
170
  if (!orientationChangeListeners.has(name)) {
183
171
  orientationChangeListeners.add(name, listener);
package/src/index.js CHANGED
@@ -8,6 +8,13 @@ import * as offlineMode from "./helpers/offline_mode";
8
8
  import * as dbSchema from "./helpers/db_schema";
9
9
  import { router } from "./routing/index";
10
10
 
11
+ const plugins = {};
12
+ const context = require.context("./plugins-code", true, /index\.js$/);
13
+ context.keys().forEach((key) => {
14
+ const pluginName = key.split("/")[1];
15
+ plugins[pluginName] = context(key);
16
+ });
17
+
11
18
  export const mobileApp = {
12
19
  init,
13
20
  api,
@@ -17,4 +24,5 @@ export const mobileApp = {
17
24
  navigation: { ...navigation, router },
18
25
  offlineMode,
19
26
  dbSchema,
27
+ plugins,
20
28
  };