diff options
Diffstat (limited to 'StoneIsland/plugins')
10 files changed, 245 insertions, 0 deletions
diff --git a/StoneIsland/plugins/android.json b/StoneIsland/plugins/android.json index 67cc3c41..6ad5cf91 100755 --- a/StoneIsland/plugins/android.json +++ b/StoneIsland/plugins/android.json @@ -53,6 +53,10 @@ }, "cordova-plugin-firebase": { "PACKAGE_NAME": "us.okfoc.stoneisland" + }, + "cordova-plugin-app-name": { + "APP_NAME": "Stone Island", + "PACKAGE_NAME": "us.okfoc.stoneisland" } }, "dependent_plugins": { diff --git a/StoneIsland/plugins/cordova-plugin-app-name/LICENSE b/StoneIsland/plugins/cordova-plugin-app-name/LICENSE new file mode 100644 index 00000000..3b7b70c7 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-app-name/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 blakgeek + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/StoneIsland/plugins/cordova-plugin-app-name/README.md b/StoneIsland/plugins/cordova-plugin-app-name/README.md new file mode 100644 index 00000000..a8680f30 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-app-name/README.md @@ -0,0 +1,26 @@ +# cordova-plugin-app-name +I created this plugin to address the issue of spaces in the names of my Cordova apps. + +## How does it work? +It adds an after_prepare hook that changes the value of app_name in strings.xml for Android and updates the "Project Name" and +"Project Display Name" in the plist for iOS. + +## How do I install it? + +If you're like me and using [Cordova CLI](http://cordova.apache.org/): +``` +cordova plugin add cordova-plugin-app-name --variable APP_NAME="Look <Ma> I Got Spaces and Stuff!" +``` + +or + +``` +phonegap local plugin add cordova-plugin-app-name --variable APP_NAME="Look <Ma> I Got Spaces and Stuff!" +``` + +## How do I use it? +Um ... See above :) + + + + diff --git a/StoneIsland/plugins/cordova-plugin-app-name/package.json b/StoneIsland/plugins/cordova-plugin-app-name/package.json new file mode 100644 index 00000000..5db6bb73 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-app-name/package.json @@ -0,0 +1,66 @@ +{ + "_from": "cordova-plugin-app-name", + "_id": "cordova-plugin-app-name@1.0.4", + "_inBundle": false, + "_integrity": "sha1-FruwzRrwdAumNH66QPIgM0HU+z0=", + "_location": "/cordova-plugin-app-name", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "cordova-plugin-app-name", + "name": "cordova-plugin-app-name", + "escapedName": "cordova-plugin-app-name", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/cordova-plugin-app-name/-/cordova-plugin-app-name-1.0.4.tgz", + "_shasum": "16bbb0cd1af0740ba6347eba40f2203341d4fb3d", + "_spec": "cordova-plugin-app-name", + "_where": "/Users/user/Sites/stone-island/StoneIsland/node_modules", + "bugs": { + "url": "https://github.com/blakgeek/cordova-plugin-app-name/issues" + }, + "bundleDependencies": false, + "cordova": { + "id": "cordova-plugin-app-name", + "platforms": [ + "ios", + "android" + ] + }, + "dependencies": { + "xml2js": "^0.4.16" + }, + "deprecated": false, + "description": "A Cordova/PhoneGap plugin that allows you to give you app a name with spaces and special characters and stuff.", + "devDependencies": { + "libxmljs": "^0.18.4" + }, + "homepage": "https://github.com/blakgeek/cordova-plugin-app-name", + "keywords": [ + "ecosystem:cordova", + "cordova-android", + "cordova-ios", + "cordova:plugin", + "spaces", + "app", + "name", + "rename" + ], + "license": "MIT", + "name": "cordova-plugin-app-name", + "repository": { + "type": "git", + "url": "git+https://github.com/blakgeek/cordova-plugin-app-name.git" + }, + "scripts": { + "postversion": "node scripts/sync-plugin-version.js; git add plugin.xml; git commit plugin.xml -m \"v${npm_package_version}\"" + }, + "version": "1.0.4" +} diff --git a/StoneIsland/plugins/cordova-plugin-app-name/plugin.xml b/StoneIsland/plugins/cordova-plugin-app-name/plugin.xml new file mode 100644 index 00000000..6e7c5480 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-app-name/plugin.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="cordova-plugin-app-name" version="1.0.4"> + <name>App Namer</name> + <author>Carlos "blakgeek" Lawton</author> + <description> + Cordova/Phonegap plugin that allows you to put spaces in the display name of your app. + </description> + <keywords>cordova, ios, app, name, spaces</keywords> + <license>MIT</license> + <engines> + <engine name="cordova" version=">=3.0.0"/> + </engines> + + <preference name="APP_NAME"/> + <hook type="after_prepare" src="src/rename-app.js"/> + + <platform name="android"> + <config-file target="config.xml" parent="/*"> + <preference name="AppName" value="$APP_NAME"/> + </config-file> + </platform> + + <platform name="ios"> + <config-file target="*-Info.plist" parent="CFBundleName"> + <string>$APP_NAME</string> + </config-file> + <config-file target="*-Info.plist" parent="CFBundleDisplayName"> + <string>$APP_NAME</string> + </config-file> + </platform> +</plugin> diff --git a/StoneIsland/plugins/cordova-plugin-app-name/scripts/npm-install.js b/StoneIsland/plugins/cordova-plugin-app-name/scripts/npm-install.js new file mode 100644 index 00000000..710905cf --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-app-name/scripts/npm-install.js @@ -0,0 +1,8 @@ +var exec = require('child_process').execSync; + +module.exports = function(context) { + + exec('npm install', { + cwd: context.opts.plugin.pluginInfo.dir + }); +};
\ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-app-name/scripts/sync-plugin-version.js b/StoneIsland/plugins/cordova-plugin-app-name/scripts/sync-plugin-version.js new file mode 100644 index 00000000..e3295cc9 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-app-name/scripts/sync-plugin-version.js @@ -0,0 +1,12 @@ +var fs = require('fs'); +var libxml = require('libxmljs'); +var version = process.env.npm_package_version; +var content = fs.readFileSync('plugin.xml'); +var xml = libxml.parseXmlString(content); +xml.get('/p:plugin', { + 'p': 'http://apache.org/cordova/ns/plugins/1.0' +}).attr({ + 'version': version +}); + +fs.writeFileSync('plugin.xml', xml.toString()); diff --git a/StoneIsland/plugins/cordova-plugin-app-name/src/rename-app.js b/StoneIsland/plugins/cordova-plugin-app-name/src/rename-app.js new file mode 100755 index 00000000..3eb4d211 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-app-name/src/rename-app.js @@ -0,0 +1,63 @@ +#!/usr/bin/env node + +var fs = require('fs'); +var path = require("path"); +var xml2js = require('xml2js'); +var parser = new xml2js.Parser(); +var builder = new xml2js.Builder({ + xmldec: { + version: '1.0', + encoding: 'UTF-8' + } +}); + +module.exports = function (context) { + + if(context.opts.platforms.indexOf('android') === -1) return; + + console.log('Attempting to set app name'); + + var projectRoot = context.opts.projectRoot; + var configPath = path.join(projectRoot, 'platforms', 'android', 'res', 'xml', 'config.xml'); + var stringsPath = path.join(projectRoot, 'platforms', 'android', 'res', 'values', 'strings.xml'); + var stringsXml, name; + + // make sure the android config file exists + try { + fs.accessSync(configPath, fs.F_OK); + } catch(e) { + return; + } + + name = getConfigParser(context, configPath).getPreference('AppName'); + + if (name) { + stringsXml = fs.readFileSync(stringsPath, 'UTF-8'); + parser.parseString(stringsXml, function (err, data) { + + data.resources.string.forEach(function (string) { + + if (string.$.name === 'app_name') { + + console.log('Setting App Name: ', name); + string._ = name; + } + }); + + fs.writeFileSync(stringsPath, builder.buildObject(data)); + + }); + } +}; + +function getConfigParser(context, config) { + var semver = context.requireCordovaModule('semver'); + + if (semver.lt(context.opts.cordova.version, '5.4.0')) { + ConfigParser = context.requireCordovaModule('cordova-lib/src/ConfigParser/ConfigParser'); + } else { + ConfigParser = context.requireCordovaModule('cordova-common/src/ConfigParser/ConfigParser'); + } + + return new ConfigParser(config); +} diff --git a/StoneIsland/plugins/fetch.json b/StoneIsland/plugins/fetch.json index e1f47bbb..4d0eafbb 100755 --- a/StoneIsland/plugins/fetch.json +++ b/StoneIsland/plugins/fetch.json @@ -122,5 +122,15 @@ }, "is_top_level": true, "variables": {} + }, + "cordova-plugin-app-name": { + "source": { + "type": "registry", + "id": "cordova-plugin-app-name" + }, + "is_top_level": true, + "variables": { + "APP_NAME": "Stone Island" + } } }
\ No newline at end of file diff --git a/StoneIsland/plugins/ios.json b/StoneIsland/plugins/ios.json index ad839f95..7ac7caec 100644 --- a/StoneIsland/plugins/ios.json +++ b/StoneIsland/plugins/ios.json @@ -50,6 +50,10 @@ }, "cordova-plugin-firebase": { "PACKAGE_NAME": "us.okfoc.stoneisland" + }, + "cordova-plugin-app-name": { + "APP_NAME": "Stone Island", + "PACKAGE_NAME": "us.okfoc.stoneisland" } }, "dependent_plugins": { |
