Skip to content

Commit ffde002

Browse files
authored
Merge pull request #1 from shankari/master
Initial version of the base app
2 parents f24acf8 + ce44b48 commit ffde002

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+3619
-1
lines changed

.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "www/lib"
3+
}

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Specifies intentionally untracked files to ignore when using Git
2+
# http://git-scm.com/docs/gitignore
3+
4+
node_modules/
5+
platforms/
6+
plugins/
7+
www/lib/
8+
package-hooks/
9+
.DS_Store
10+
app-settings.json
11+
.idea/
12+
.io-config.json

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# e-mission-base
2-
Base app that invites the user to customize the UI by scanning a QR code
2+
Base app that invites the user to customize the UI by scanning a QR code.
3+
4+
Installation instructions are the same as for the full-featured e-mission phone app.
5+
https://github.com/e-mission/e-mission-phone
6+
7+

bower.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "emission",
3+
"private": "true",
4+
"devDependencies": {
5+
"ionic": "driftyco/ionic-bower#1.3.1",
6+
"moment": "^2.11.2",
7+
"moment-timezone": "^0.5.0"
8+
},
9+
"resolutions": {
10+
"angular": "1.5.3",
11+
"angular-animate": "1.5.3",
12+
"angular-sanitize": "1.5.3"
13+
},
14+
"dependencies": {
15+
"angularLocalStorage": "^0.3.2"
16+
}
17+
}

config.xml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<widget android-versionCode="1" id="edu.berkeley.eecs.embase" ios-CFBundleVersion="1" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
3+
<name>e²mission</name>
4+
<description>
5+
Base version of the e-mission app, intended for customization by studies.
6+
</description>
7+
<author email="shankari@eecs.berkeley.edu" href="https://e-mission.eecs.berkeley.edu">
8+
E-Mission Team
9+
</author>
10+
<content src="index.html" />
11+
<access origin="*" />
12+
<hook src="package-hooks/ios9_allow_http.sh" type="after_prepare" />
13+
<preference name="webviewbounce" value="false" />
14+
<preference name="UIWebViewBounce" value="false" />
15+
<preference name="DisallowOverscroll" value="true" />
16+
<preference name="android-minSdkVersion" value="18" />
17+
<preference name="BackupWebStorage" value="none" />
18+
<preference name="SplashScreen" value="screen" />
19+
<preference name="SplashScreenDelay" value="100" />
20+
<preference name="xwalkVersion" value="19+" />
21+
<preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect" />
22+
<preference name="xwalkMode" value="embedded" />
23+
<preference name="xwalkMultipleApk" value="true" />
24+
<feature name="StatusBar">
25+
<param name="ios-package" onload="true" value="CDVStatusBar" />
26+
</feature>
27+
<platform name="ios">
28+
</platform>
29+
<platform name="android">
30+
<preference name="android-minSdkVersion" value="18" />
31+
<preference name="android-targetSdkVersion" value="21" />
32+
</platform>
33+
<icon src="resources/icon.png" />
34+
<plugin name="phonegap-plugin-push" spec="~1.9.2">
35+
<variable name="SENDER_ID" value="1096592179912" />
36+
</plugin>
37+
<plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
38+
<plugin name="cordova-plugin-app-version" spec="~0.1.9" />
39+
<plugin name="cordova-plugin-file" spec="~6.0.1" />
40+
<plugin name="cordova-plugin-device" spec="~2.0.1" />
41+
<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
42+
<plugin name="cordova-plugin-customurlscheme" spec="~4.3.0">
43+
<variable name="URL_SCHEME" value="emission" />
44+
</plugin>
45+
<plugin name="cordova-plugin-email-composer" spec="~0.8.12" />
46+
<plugin name="cordova-plugin-x-socialsharing" spec="~5.2.1" />
47+
<plugin name="cordova-plugin-inappbrowser" spec="https://github.com/shankari/cordova-plugin-inappbrowser.git" />
48+
<plugin name="de.appplant.cordova.plugin.local-notification-ios9-fix" spec="https://github.com/shankari/cordova-plugin-local-notifications.git" />
49+
<plugin name="edu.berkeley.eecs.emission.cordova.settings" spec="https://github.com/e-mission/cordova-connection-settings.git" />
50+
<plugin name="edu.berkeley.eecs.emission.cordova.unifiedlogger" spec="https://github.com/e-mission/cordova-unified-logger.git" />
51+
<plugin name="edu.berkeley.eecs.emission.cordova.comm" spec="https://github.com/e-mission/cordova-server-communication.git" />
52+
<plugin name="edu.berkeley.eecs.emission.cordova.usercache" spec="https://github.com/e-mission/cordova-usercache.git" />
53+
<plugin name="edu.berkeley.eecs.emission.cordova.datacollection" spec="https://github.com/e-mission/e-mission-data-collection.git" />
54+
<plugin name="edu.berkeley.eecs.emission.cordova.serversync" spec="https://github.com/e-mission/cordova-server-sync.git" />
55+
<plugin name="edu.berkeley.eecs.emission.cordova.transitionnotify" spec="https://github.com/e-mission/e-mission-transition-notify.git" />
56+
<plugin name="cordova-plugin-ionic" spec="~3.0.0">
57+
<variable name="APP_ID" value="6ab82e2d" />
58+
<variable name="CHANNEL_NAME" value="Production" />
59+
<variable name="UPDATE_METHOD" value="none" />
60+
</plugin>
61+
<plugin name="edu.berkeley.eecs.emission.cordova.auth" spec="https://github.com/e-mission/cordova-jwt-auth.git" />
62+
<preference name="SplashShowOnlyFirstTime" value="false" />
63+
<plugin name="phonegap-plugin-barcodescanner" spec="^7.1.0">
64+
<variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
65+
<edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
66+
<string>To scan the barcode for the study</string>
67+
</edit-config>
68+
</plugin>
69+
<engine name="ios" spec="^4.5.4" />
70+
<engine name="android" spec="^6.4.0" />
71+
</widget>

hooks/README.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!--
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
-->
21+
# Cordova Hooks
22+
23+
This directory may contain scripts used to customize cordova commands. This
24+
directory used to exist at `.cordova/hooks`, but has now been moved to the
25+
project root. Any scripts you add to these directories will be executed before
26+
and after the commands corresponding to the directory name. Useful for
27+
integrating your own build systems or integrating with version control systems.
28+
29+
__Remember__: Make your scripts executable.
30+
31+
## Hook Directories
32+
The following subdirectories will be used for hooks:
33+
34+
after_build/
35+
after_compile/
36+
after_docs/
37+
after_emulate/
38+
after_platform_add/
39+
after_platform_rm/
40+
after_platform_ls/
41+
after_plugin_add/
42+
after_plugin_ls/
43+
after_plugin_rm/
44+
after_plugin_search/
45+
after_prepare/
46+
after_run/
47+
after_serve/
48+
before_build/
49+
before_compile/
50+
before_docs/
51+
before_emulate/
52+
before_platform_add/
53+
before_platform_rm/
54+
before_platform_ls/
55+
before_plugin_add/
56+
before_plugin_ls/
57+
before_plugin_rm/
58+
before_plugin_search/
59+
before_prepare/
60+
before_run/
61+
before_serve/
62+
pre_package/ <-- Windows 8 and Windows Phone only.
63+
64+
## Script Interface
65+
66+
All scripts are run from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables:
67+
68+
* CORDOVA_VERSION - The version of the Cordova-CLI.
69+
* CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios).
70+
* CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer)
71+
* CORDOVA_HOOK - Path to the hook that is being executed.
72+
* CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate)
73+
74+
If a script returns a non-zero exit code, then the parent cordova command will be aborted.
75+
76+
77+
## Writing hooks
78+
79+
We highly recommend writting your hooks using Node.js so that they are
80+
cross-platform. Some good examples are shown here:
81+
82+
[http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/)
83+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/usr/bin/env node
2+
3+
// Add Platform Class
4+
// v1.0
5+
// Automatically adds the platform class to the body tag
6+
// after the `prepare` command. By placing the platform CSS classes
7+
// directly in the HTML built for the platform, it speeds up
8+
// rendering the correct layout/style for the specific platform
9+
// instead of waiting for the JS to figure out the correct classes.
10+
11+
var fs = require('fs');
12+
var path = require('path');
13+
14+
var rootdir = process.argv[2];
15+
16+
function addPlatformBodyTag(indexPath, platform) {
17+
// add the platform class to the body tag
18+
try {
19+
var platformClass = 'platform-' + platform;
20+
var cordovaClass = 'platform-cordova platform-webview';
21+
22+
var html = fs.readFileSync(indexPath, 'utf8');
23+
24+
var bodyTag = findBodyTag(html);
25+
if(!bodyTag) return; // no opening body tag, something's wrong
26+
27+
if(bodyTag.indexOf(platformClass) > -1) return; // already added
28+
29+
var newBodyTag = bodyTag;
30+
31+
var classAttr = findClassAttr(bodyTag);
32+
if(classAttr) {
33+
// body tag has existing class attribute, add the classname
34+
var endingQuote = classAttr.substring(classAttr.length-1);
35+
var newClassAttr = classAttr.substring(0, classAttr.length-1);
36+
newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote;
37+
newBodyTag = bodyTag.replace(classAttr, newClassAttr);
38+
39+
} else {
40+
// add class attribute to the body tag
41+
newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">');
42+
}
43+
44+
html = html.replace(bodyTag, newBodyTag);
45+
46+
fs.writeFileSync(indexPath, html, 'utf8');
47+
48+
process.stdout.write('add to body class: ' + platformClass + '\n');
49+
} catch(e) {
50+
process.stdout.write(e);
51+
}
52+
}
53+
54+
function findBodyTag(html) {
55+
// get the body tag
56+
try{
57+
return html.match(/<body(?=[\s>])(.*?)>/gi)[0];
58+
}catch(e){}
59+
}
60+
61+
function findClassAttr(bodyTag) {
62+
// get the body tag's class attribute
63+
try{
64+
return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0];
65+
}catch(e){}
66+
}
67+
68+
if (rootdir) {
69+
70+
// go through each of the platform directories that have been prepared
71+
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
72+
73+
for(var x=0; x<platforms.length; x++) {
74+
// open up the index.html file at the www root
75+
try {
76+
var platform = platforms[x].trim().toLowerCase();
77+
var indexPath;
78+
79+
if(platform == 'android') {
80+
indexPath = path.join('platforms', platform, 'assets', 'www', 'index.html');
81+
} else {
82+
indexPath = path.join('platforms', platform, 'www', 'index.html');
83+
}
84+
85+
if(fs.existsSync(indexPath)) {
86+
addPlatformBodyTag(indexPath, platform);
87+
}
88+
89+
} catch(e) {
90+
process.stdout.write(e);
91+
}
92+
}
93+
94+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env node
2+
3+
var fs = require('fs-extra');
4+
var path = require('path');
5+
var klawSync = require('klaw-sync')
6+
7+
var androidPlatformsDir = path.resolve(__dirname, '../../platforms/android/res');
8+
9+
var copyAllIcons = function(iconDir) {
10+
var densityDirs = klawSync(iconDir, {nofile: true})
11+
// console.log("densityDirs = "+JSON.stringify(densityDirs));
12+
densityDirs.forEach(function(dDir) {
13+
var files = klawSync(dDir.path, {nodir: true});
14+
files.forEach(function(file) {
15+
var dirName = path.basename(dDir.path);
16+
var fileName = path.basename(file.path);
17+
if (dirName.startsWith("mipmap")) {
18+
var drawableName = dirName.replace("mipmap", "drawable");
19+
var srcName = path.join(iconDir, dirName, fileName);
20+
var dstName = path.join(iconDir, drawableName, fileName);
21+
console.log("About to copy file "+srcName+" -> "+dstName);
22+
fs.copySync(srcName, dstName);
23+
}
24+
});
25+
});
26+
};
27+
28+
var copyIconsFromAllDirs = function() {
29+
// Ensure that the res directory exists
30+
fs.mkdirsSync(androidPlatformsDir);
31+
copyAllIcons(androidPlatformsDir);
32+
}
33+
34+
var platformList = process.env.CORDOVA_PLATFORMS;
35+
36+
if (platformList == undefined) {
37+
console.log("Testing by running standalone script, invoke anyway");
38+
copyIconsFromAllDirs();
39+
} else {
40+
var platforms = platformList.split(",");
41+
if (platforms.indexOf('android') < 0) {
42+
console.log("Android platform not specified, skipping...");
43+
} else {
44+
copyIconsFromAllDirs();
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env node
2+
3+
var fs = require('fs-extra');
4+
var path = require('path');
5+
var klawSync = require('klaw-sync')
6+
7+
var androidPlatformsDir = path.resolve(__dirname, '../../platforms/android/res');
8+
var notificationIconsList = [
9+
path.resolve(__dirname, '../../resources/android/ic_mood_question'),
10+
path.resolve(__dirname, '../../resources/android/ic_question_answer')];
11+
12+
var copyAllIcons = function(iconDir) {
13+
var densityDirs = klawSync(iconDir, {nofile: true})
14+
// console.log("densityDirs = "+JSON.stringify(densityDirs));
15+
densityDirs.forEach(function(dDir) {
16+
var files = klawSync(dDir.path, {nodir: true});
17+
files.forEach(function(file) {
18+
var dirName = path.basename(dDir.path);
19+
var fileName = path.basename(file.path);
20+
var srcName = path.join(iconDir, dirName, fileName);
21+
var dstName = path.join(androidPlatformsDir, dirName, fileName);
22+
console.log("About to copy file "+srcName+" -> "+dstName);
23+
fs.copySync(srcName, dstName);
24+
});
25+
});
26+
};
27+
28+
var copyIconsFromAllDirs = function() {
29+
notificationIconsList.forEach(function(iconDir) {
30+
console.log("About to copy icons from "+iconDir);
31+
copyAllIcons(iconDir);
32+
});
33+
}
34+
35+
var platformList = process.env.CORDOVA_PLATFORMS;
36+
37+
if (platformList == undefined) {
38+
console.log("Testing by running standalone script, invoke anyway");
39+
copyIconsFromAllDirs();
40+
} else {
41+
var platforms = platformList.split(",");
42+
if (platforms.indexOf('android') < 0) {
43+
console.log("Android platform not specified, skipping...");
44+
} else {
45+
copyIconsFromAllDirs();
46+
}
47+
}

0 commit comments

Comments
 (0)