Skip to content

Commit a15d1a6

Browse files
authored
Merge pull request #1256 from complexdatacollective/december-23-cordova-fixes
Implement experimental workaround for Android Server pairing
2 parents 19c835e + 0864ae1 commit a15d1a6

File tree

7 files changed

+63
-52
lines changed

7 files changed

+63
-52
lines changed

config.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<widget android-versionCode="6374" id="org.codaco.NetworkCanvasInterviewer6" ios-CFBundleIdentifier="org.codaco.networkCanvasInterviewerBusiness" ios-CFBundleVersion="6374" version="6.5.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2+
<widget android-versionCode="6415" id="org.codaco.NetworkCanvasInterviewer6" ios-CFBundleIdentifier="org.codaco.networkCanvasInterviewerBusiness" ios-CFBundleVersion="6415" version="6.5.2"
3+
xmlns="http://www.w3.org/ns/widgets"
4+
xmlns:android="http://schemas.android.com/apk/res/android"
5+
xmlns:cdv="http://cordova.apache.org/ns/1.0">
36
<name>Network Canvas Interviewer</name>
47
<description>
58
A tool for conducting Network Canvas Interviews.
@@ -16,6 +19,7 @@
1619
<hook src="scripts/cordova/after-run.js" type="after_run"/>
1720
<hook src="scripts/cordova/before-prepare.js" type="before_prepare"/>
1821
<platform name="android">
22+
<preference name="scheme" value="http"/>
1923
<allow-intent href="market:*"/>
2024
<allow-navigation href="https://*/*"/>
2125
<uses-permission android:name="android.permission.INTERNET"/>
@@ -81,4 +85,4 @@
8185
<plugin name="cordova-plugin-network-information" spec="~2.0.2"/>
8286
<plugin name="cordova-plugin-chooser" spec="~1.3.1"/>
8387
<plugin name="cordova-sqlite-storage" spec="6.0.0"/>
84-
</widget>
88+
</widget>

package-lock.json

Lines changed: 28 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "network-canvas-interviewer",
3-
"version": "6.5.1",
3+
"version": "6.5.2",
44
"productName": "Network Canvas Interviewer",
55
"description": "A tool for conducting Network Canvas Interviews.",
66
"author": "Complex Data Collective",
@@ -78,8 +78,8 @@
7878
"connected-react-router": "^6.8.0",
7979
"cordova-android": "~12.0.0",
8080
"cordova-ios": "~7.0.0",
81-
"cordova-plugin-file": "github:apache/cordova-plugin-file",
82-
"cordova-plugin-file-transfer": "github:apache/cordova-plugin-file-transfer",
81+
"cordova-plugin-file": "github:apache/cordova-plugin-file#265a932",
82+
"cordova-plugin-file-transfer": "github:apache/cordova-plugin-file-transfer#f12b73e",
8383
"cordova-plugin-fullscreen": "github:mesmotronic/cordova-plugin-fullscreen",
8484
"cordova-plugin-ionic-keyboard": "github:ionic-team/cordova-plugin-ionic-keyboard",
8585
"cordova-plugin-network-canvas-client": "github:complexdatacollective/cordova-plugin-network-canvas-client",
@@ -176,11 +176,11 @@
176176
"whatwg-fetch": "2.0.3",
177177
"worker-loader": "^2.0.0",
178178
"xml2js": "~0.4.23",
179-
"xmldom": "~0.1.27",
180179
"xss": "^0.3.4"
181180
},
182181
"dependencies": {
183182
"@babel/runtime": "7.10.1",
183+
"@xmldom/xmldom": "~0.8.10",
184184
"archiver": "^4.0.1",
185185
"d3-force": "~3.0.0",
186186
"dmg-builder": "~23.6.0",

public/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "network-canvas-interviewer",
3-
"version": "6.5.1",
3+
"version": "6.5.2",
44
"productName": "Network Canvas Interviewer",
55
"description": "A tool for conducting Network Canvas Interviews.",
66
"author": "Complex Data Collective",

src/containers/SessionManagementScreen/SessionManagementScreen.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ const fatalExportErrorAction = withErrorDialog((error) => ({
2323
error,
2424
}));
2525

26+
const getInitialFilename = () => `networkCanvasExport-${Date.now()}`;
27+
2628
const DataExportScreen = ({ show, onClose }) => {
2729
const [step, setStep] = useState(3);
2830
const [selectedSessions, setSelectedSessions] = useState([]);
2931

3032
// Set the default filename to 'networkCanvasExport-<timestamp>'
31-
const [filename, setFilename] = useState(`networkCanvasExport-${Date.now()}`);
33+
const [filename, setFilename] = useState(getInitialFilename());
3234
const [abortHandlers, setAbortHandlers] = useState(null);
3335

3436
const pairedServer = useSelector((state) => state.pairedServer);
@@ -40,6 +42,7 @@ const DataExportScreen = ({ show, onClose }) => {
4042
const openDialog = (dialog) => dispatch(dialogActions.openDialog(dialog));
4143

4244
const reset = () => {
45+
setFilename(getInitialFilename());
4346
setSelectedSessions([]);
4447
setStep(1);
4548
};

src/utils/protocol/downloadProtocol.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* global FileTransfer */
33
import uuid from 'uuid/v4';
44
import environments from '../environments';
5-
import inEnvironment from '../Environment';
5+
import inEnvironment, { isIOS } from '../Environment';
66
import { writeFile, tempDataPath } from '../filesystem';
77
import friendlyErrorMessage from '../../utils/friendlyErrorMessage';
88
import ApiClient from '../../utils/ApiClient';
@@ -36,8 +36,8 @@ const downloadProtocol = inEnvironment((environment) => {
3636
if (environment === environments.ELECTRON) {
3737
const request = require('request-promise-native');
3838
const destination = path.join(tempDataPath(), getProtocolName());
39-
4039
return (uri, pairedServer = false) => {
40+
4141
let promisedResponse;
4242
if (pairedServer) {
4343
promisedResponse = new ApiClient(pairedServer).downloadProtocol(uri);
@@ -56,29 +56,41 @@ const downloadProtocol = inEnvironment((environment) => {
5656
}
5757

5858
if (environment === environments.CORDOVA) {
59-
const destination = `${tempDataPath()}${getProtocolName()}`
6059
return (uri, pairedServer) => {
6160
let promisedResponse;
61+
6262
if (pairedServer) {
63+
// on iOS, the cordova-plugin-network-canvas-client wants the destination
64+
// to be a folder, not a file. It assigns a temp filename itself.
65+
//
66+
// however, on android it needs to be a file.
67+
const destination = isIOS() ? tempDataPath() : `${tempDataPath()}${getProtocolName()}`;
68+
6369
promisedResponse = new ApiClient(pairedServer)
6470
// .addTrustedCert() is not required, assuming we've just fetched the protocol list
6571
.downloadProtocol(uri, destination)
66-
.then(() => destination);
72+
.then((result) => {
73+
// Result is a FileEntry object
74+
return result.nativeURL;
75+
})
6776
} else {
6877
promisedResponse = getURL(uri)
6978
.then(url => url.href)
7079
.catch(urlError)
7180
.then(href => new Promise((resolve, reject) => {
81+
// The filetransfer plugin requires a folder to write to
82+
const destinationWithFolder = `${tempDataPath()}${getProtocolName()}`;
83+
7284
const fileTransfer = new FileTransfer();
73-
console.log('fileTransfer', destination);
7485
fileTransfer.download(
7586
href,
76-
destination,
77-
() => resolve(destination),
87+
destinationWithFolder,
88+
() => resolve(destinationWithFolder),
7889
error => reject(error),
7990
);
8091
}));
8192
}
93+
8294
return promisedResponse
8395
.catch((error) => {
8496
const getErrorMessage = ({ code }) => {

0 commit comments

Comments
 (0)