Skip to content

Commit

Permalink
Merge pull request #1 from shankari/master
Browse files Browse the repository at this point in the history
Initial version of the base app
  • Loading branch information
shankari authored Mar 26, 2018
2 parents f24acf8 + ce44b48 commit ffde002
Show file tree
Hide file tree
Showing 52 changed files with 3,619 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "www/lib"
}
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Specifies intentionally untracked files to ignore when using Git
# http://git-scm.com/docs/gitignore

node_modules/
platforms/
plugins/
www/lib/
package-hooks/
.DS_Store
app-settings.json
.idea/
.io-config.json
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# e-mission-base
Base app that invites the user to customize the UI by scanning a QR code
Base app that invites the user to customize the UI by scanning a QR code.

Installation instructions are the same as for the full-featured e-mission phone app.
https://github.com/e-mission/e-mission-phone


17 changes: 17 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "emission",
"private": "true",
"devDependencies": {
"ionic": "driftyco/ionic-bower#1.3.1",
"moment": "^2.11.2",
"moment-timezone": "^0.5.0"
},
"resolutions": {
"angular": "1.5.3",
"angular-animate": "1.5.3",
"angular-sanitize": "1.5.3"
},
"dependencies": {
"angularLocalStorage": "^0.3.2"
}
}
71 changes: 71 additions & 0 deletions config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version='1.0' encoding='utf-8'?>
<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">
<name>e²mission</name>
<description>
Base version of the e-mission app, intended for customization by studies.
</description>
<author email="[email protected]" href="https://e-mission.eecs.berkeley.edu">
E-Mission Team
</author>
<content src="index.html" />
<access origin="*" />
<hook src="package-hooks/ios9_allow_http.sh" type="after_prepare" />
<preference name="webviewbounce" value="false" />
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="18" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="100" />
<preference name="xwalkVersion" value="19+" />
<preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect" />
<preference name="xwalkMode" value="embedded" />
<preference name="xwalkMultipleApk" value="true" />
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<platform name="ios">
</platform>
<platform name="android">
<preference name="android-minSdkVersion" value="18" />
<preference name="android-targetSdkVersion" value="21" />
</platform>
<icon src="resources/icon.png" />
<plugin name="phonegap-plugin-push" spec="~1.9.2">
<variable name="SENDER_ID" value="1096592179912" />
</plugin>
<plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
<plugin name="cordova-plugin-app-version" spec="~0.1.9" />
<plugin name="cordova-plugin-file" spec="~6.0.1" />
<plugin name="cordova-plugin-device" spec="~2.0.1" />
<plugin name="cordova-plugin-whitelist" spec="~1.3.3" />
<plugin name="cordova-plugin-customurlscheme" spec="~4.3.0">
<variable name="URL_SCHEME" value="emission" />
</plugin>
<plugin name="cordova-plugin-email-composer" spec="~0.8.12" />
<plugin name="cordova-plugin-x-socialsharing" spec="~5.2.1" />
<plugin name="cordova-plugin-inappbrowser" spec="https://github.com/shankari/cordova-plugin-inappbrowser.git" />
<plugin name="de.appplant.cordova.plugin.local-notification-ios9-fix" spec="https://github.com/shankari/cordova-plugin-local-notifications.git" />
<plugin name="edu.berkeley.eecs.emission.cordova.settings" spec="https://github.com/e-mission/cordova-connection-settings.git" />
<plugin name="edu.berkeley.eecs.emission.cordova.unifiedlogger" spec="https://github.com/e-mission/cordova-unified-logger.git" />
<plugin name="edu.berkeley.eecs.emission.cordova.comm" spec="https://github.com/e-mission/cordova-server-communication.git" />
<plugin name="edu.berkeley.eecs.emission.cordova.usercache" spec="https://github.com/e-mission/cordova-usercache.git" />
<plugin name="edu.berkeley.eecs.emission.cordova.datacollection" spec="https://github.com/e-mission/e-mission-data-collection.git" />
<plugin name="edu.berkeley.eecs.emission.cordova.serversync" spec="https://github.com/e-mission/cordova-server-sync.git" />
<plugin name="edu.berkeley.eecs.emission.cordova.transitionnotify" spec="https://github.com/e-mission/e-mission-transition-notify.git" />
<plugin name="cordova-plugin-ionic" spec="~3.0.0">
<variable name="APP_ID" value="6ab82e2d" />
<variable name="CHANNEL_NAME" value="Production" />
<variable name="UPDATE_METHOD" value="none" />
</plugin>
<plugin name="edu.berkeley.eecs.emission.cordova.auth" spec="https://github.com/e-mission/cordova-jwt-auth.git" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<plugin name="phonegap-plugin-barcodescanner" spec="^7.1.0">
<variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
<edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
<string>To scan the barcode for the study</string>
</edit-config>
</plugin>
<engine name="ios" spec="^4.5.4" />
<engine name="android" spec="^6.4.0" />
</widget>
83 changes: 83 additions & 0 deletions hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
# Cordova Hooks

This directory may contain scripts used to customize cordova commands. This
directory used to exist at `.cordova/hooks`, but has now been moved to the
project root. Any scripts you add to these directories will be executed before
and after the commands corresponding to the directory name. Useful for
integrating your own build systems or integrating with version control systems.

__Remember__: Make your scripts executable.

## Hook Directories
The following subdirectories will be used for hooks:

after_build/
after_compile/
after_docs/
after_emulate/
after_platform_add/
after_platform_rm/
after_platform_ls/
after_plugin_add/
after_plugin_ls/
after_plugin_rm/
after_plugin_search/
after_prepare/
after_run/
after_serve/
before_build/
before_compile/
before_docs/
before_emulate/
before_platform_add/
before_platform_rm/
before_platform_ls/
before_plugin_add/
before_plugin_ls/
before_plugin_rm/
before_plugin_search/
before_prepare/
before_run/
before_serve/
pre_package/ <-- Windows 8 and Windows Phone only.

## Script Interface

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:

* CORDOVA_VERSION - The version of the Cordova-CLI.
* CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios).
* CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer)
* CORDOVA_HOOK - Path to the hook that is being executed.
* CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate)

If a script returns a non-zero exit code, then the parent cordova command will be aborted.


## Writing hooks

We highly recommend writting your hooks using Node.js so that they are
cross-platform. Some good examples are shown here:

[http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/)

94 changes: 94 additions & 0 deletions hooks/after_prepare/010_add_platform_class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env node

// Add Platform Class
// v1.0
// Automatically adds the platform class to the body tag
// after the `prepare` command. By placing the platform CSS classes
// directly in the HTML built for the platform, it speeds up
// rendering the correct layout/style for the specific platform
// instead of waiting for the JS to figure out the correct classes.

var fs = require('fs');
var path = require('path');

var rootdir = process.argv[2];

function addPlatformBodyTag(indexPath, platform) {
// add the platform class to the body tag
try {
var platformClass = 'platform-' + platform;
var cordovaClass = 'platform-cordova platform-webview';

var html = fs.readFileSync(indexPath, 'utf8');

var bodyTag = findBodyTag(html);
if(!bodyTag) return; // no opening body tag, something's wrong

if(bodyTag.indexOf(platformClass) > -1) return; // already added

var newBodyTag = bodyTag;

var classAttr = findClassAttr(bodyTag);
if(classAttr) {
// body tag has existing class attribute, add the classname
var endingQuote = classAttr.substring(classAttr.length-1);
var newClassAttr = classAttr.substring(0, classAttr.length-1);
newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote;
newBodyTag = bodyTag.replace(classAttr, newClassAttr);

} else {
// add class attribute to the body tag
newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">');
}

html = html.replace(bodyTag, newBodyTag);

fs.writeFileSync(indexPath, html, 'utf8');

process.stdout.write('add to body class: ' + platformClass + '\n');
} catch(e) {
process.stdout.write(e);
}
}

function findBodyTag(html) {
// get the body tag
try{
return html.match(/<body(?=[\s>])(.*?)>/gi)[0];
}catch(e){}
}

function findClassAttr(bodyTag) {
// get the body tag's class attribute
try{
return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0];
}catch(e){}
}

if (rootdir) {

// go through each of the platform directories that have been prepared
var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);

for(var x=0; x<platforms.length; x++) {
// open up the index.html file at the www root
try {
var platform = platforms[x].trim().toLowerCase();
var indexPath;

if(platform == 'android') {
indexPath = path.join('platforms', platform, 'assets', 'www', 'index.html');
} else {
indexPath = path.join('platforms', platform, 'www', 'index.html');
}

if(fs.existsSync(indexPath)) {
addPlatformBodyTag(indexPath, platform);
}

} catch(e) {
process.stdout.write(e);
}
}

}
46 changes: 46 additions & 0 deletions hooks/after_prepare/015_copy_icon_to_drawable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env node

var fs = require('fs-extra');
var path = require('path');
var klawSync = require('klaw-sync')

var androidPlatformsDir = path.resolve(__dirname, '../../platforms/android/res');

var copyAllIcons = function(iconDir) {
var densityDirs = klawSync(iconDir, {nofile: true})
// console.log("densityDirs = "+JSON.stringify(densityDirs));
densityDirs.forEach(function(dDir) {
var files = klawSync(dDir.path, {nodir: true});
files.forEach(function(file) {
var dirName = path.basename(dDir.path);
var fileName = path.basename(file.path);
if (dirName.startsWith("mipmap")) {
var drawableName = dirName.replace("mipmap", "drawable");
var srcName = path.join(iconDir, dirName, fileName);
var dstName = path.join(iconDir, drawableName, fileName);
console.log("About to copy file "+srcName+" -> "+dstName);
fs.copySync(srcName, dstName);
}
});
});
};

var copyIconsFromAllDirs = function() {
// Ensure that the res directory exists
fs.mkdirsSync(androidPlatformsDir);
copyAllIcons(androidPlatformsDir);
}

var platformList = process.env.CORDOVA_PLATFORMS;

if (platformList == undefined) {
console.log("Testing by running standalone script, invoke anyway");
copyIconsFromAllDirs();
} else {
var platforms = platformList.split(",");
if (platforms.indexOf('android') < 0) {
console.log("Android platform not specified, skipping...");
} else {
copyIconsFromAllDirs();
}
}
47 changes: 47 additions & 0 deletions hooks/after_prepare/020_copy_notification_icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env node

var fs = require('fs-extra');
var path = require('path');
var klawSync = require('klaw-sync')

var androidPlatformsDir = path.resolve(__dirname, '../../platforms/android/res');
var notificationIconsList = [
path.resolve(__dirname, '../../resources/android/ic_mood_question'),
path.resolve(__dirname, '../../resources/android/ic_question_answer')];

var copyAllIcons = function(iconDir) {
var densityDirs = klawSync(iconDir, {nofile: true})
// console.log("densityDirs = "+JSON.stringify(densityDirs));
densityDirs.forEach(function(dDir) {
var files = klawSync(dDir.path, {nodir: true});
files.forEach(function(file) {
var dirName = path.basename(dDir.path);
var fileName = path.basename(file.path);
var srcName = path.join(iconDir, dirName, fileName);
var dstName = path.join(androidPlatformsDir, dirName, fileName);
console.log("About to copy file "+srcName+" -> "+dstName);
fs.copySync(srcName, dstName);
});
});
};

var copyIconsFromAllDirs = function() {
notificationIconsList.forEach(function(iconDir) {
console.log("About to copy icons from "+iconDir);
copyAllIcons(iconDir);
});
}

var platformList = process.env.CORDOVA_PLATFORMS;

if (platformList == undefined) {
console.log("Testing by running standalone script, invoke anyway");
copyIconsFromAllDirs();
} else {
var platforms = platformList.split(",");
if (platforms.indexOf('android') < 0) {
console.log("Android platform not specified, skipping...");
} else {
copyIconsFromAllDirs();
}
}
Loading

0 comments on commit ffde002

Please sign in to comment.