Skip to content
This repository has been archived by the owner on Feb 25, 2019. It is now read-only.

Commit

Permalink
remove unused cordova plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
imloama committed Dec 16, 2017
1 parent 783c2e6 commit 26c45c6
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ www/
platforms/
plugins/
hooks/
!src/libs/vue-cordova/plugins

npm-debug.log*
yarn-debug.log*
Expand Down
10 changes: 0 additions & 10 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<icon density="xhdpi" src="res/icon/firefly/logo.png" />
<icon density="xxhdpi" src="res/icon/firefly/logo.png" />
<splash src="res/screen/firefly/splash.png" />
<preference name="Fullscreen" value="false" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
Expand Down Expand Up @@ -55,21 +54,12 @@
<engine name="browser" spec="^5.0.1" />
<engine name="android" spec="^6.2.3" />
<engine name="ios" spec="^4.5.4" />
<plugin name="cordova-plugin-contacts" spec="^2.2.1">
<variable name="CONTACTS_USAGE_DESCRIPTION" value=" " />
</plugin>
<plugin name="cordova-plugin-device" spec="^1.1.7" />
<plugin name="cordova-plugin-geolocation" spec="^2.4.3">
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value=" " />
</plugin>
<plugin name="cordova-plugin-whitelist" spec="1" />
<plugin name="cordova-plugin-file" spec="^4.3.3" />
<plugin name="cordova-plugin-inappbrowser" spec="^1.7.2" />
<plugin name="cordova-plugin-qrscanner" spec="^2.5.0" />
<plugin name="cordova-plugin-splashscreen" spec="^4.1.0" />
<plugin name="cordova-plugin-statusbar" spec="^2.3.0" />
<plugin name="cordova-plugin-clipboard2" />
<plugin name="cordova-save-image-gallery" spec="^0.0.26 " />
<plugin name="cordova-plugin-camera" spec="^2.4.1" />
<plugin name="cordova-sqlite-storage" spec="^2.1.2" />
<plugin name="cordova-disable-http-cache" spec="^1.0.0" />
Expand Down
19 changes: 1 addition & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,12 @@
"cordova-ios": "^4.5.4",
"cordova-plugin-add-swift-support": "^1.7.0",
"cordova-plugin-camera": "^2.4.1",
"cordova-plugin-compat": "^1.2.0",
"cordova-plugin-contacts": "^2.2.1",
"cordova-plugin-device": "^1.1.7",
"cordova-plugin-file": "^4.3.3",
"cordova-plugin-geolocation": "^2.4.3",
"cordova-plugin-inappbrowser": "^1.7.2",
"cordova-plugin-whitelist": "1",
"cordova-plugin-qrscanner": "^2.5.0",
"cordova-plugin-splashscreen": "^4.1.0",
"cordova-plugin-statusbar": "^2.3.0",
"cordova-plugin-swift-support": "^3.1.1",
"cordova-plugin-whitelist": "1",
"cordova-save-image-gallery": "^0.0.26 ",
"cordova-sqlite-storage": "^2.1.2",
"ed25519": "0.0.4",
"hammerjs": "^2.0.8",
Expand All @@ -51,7 +45,6 @@
"uuid": "^3.1.0",
"vue": "^2.5.4",
"vue-awesome-swiper": "^2.6.7",
"vue-cordova": "0.1.2",
"vue-i18n": "^7.2.0",
"vue-methods-promise": "^0.2.2",
"vue-pull-refresh": "^0.2.6",
Expand All @@ -70,7 +63,6 @@
"babel-plugin-transform-runtime": "^6.22.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.3.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"babel-runtime": "^6.26.0",
Expand Down Expand Up @@ -125,21 +117,12 @@
],
"cordova": {
"plugins": {
"cordova-plugin-contacts": {
"CONTACTS_USAGE_DESCRIPTION": " "
},
"cordova-plugin-device": {},
"cordova-plugin-geolocation": {
"GEOLOCATION_USAGE_DESCRIPTION": " "
},
"cordova-plugin-whitelist": {},
"cordova-plugin-file": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-qrscanner": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-clipboard2": {},
"cordova-save-image-gallery": {},
"cordova-plugin-camera": {},
"cordova-sqlite-storage": {},
"cordova-disable-http-cache": {}
Expand Down
42 changes: 42 additions & 0 deletions src/libs/vue-cordova/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// list here all supported plugins
const pluginsList = [
'cordova-plugin-camera',
'cordova-plugin-device'
]

let VueCordova = {}

VueCordova.install = (Vue, options) => {

// declare global Vue.cordova object
Vue.cordova = Vue.cordova || {
deviceready: false,
plugins: []
}

// Cordova events wrapper
Vue.cordova.on = (eventName, cb) => {
document.addEventListener(eventName, cb, false)
}

// let Vue know that deviceready has been triggered
document.addEventListener('deviceready', () => {
Vue.cordova.deviceready = true
}, false)

// load supported plugins
pluginsList.forEach(pluginName => {
let plugin = require('./plugins/' + pluginName)
let install = plugin.install || plugin.default.install
install(Vue, options, pluginLoaded => {
if (pluginLoaded) {
Vue.cordova.plugins.push(pluginName)
}
if (Vue.config.debug) {
console.log('[VueCordova]', pluginName, '→', pluginLoaded ? 'loaded' : 'not loaded')
}
})
})
}

module.exports = VueCordova
16 changes: 16 additions & 0 deletions src/libs/vue-cordova/plugins/cordova-plugin-camera.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default {
install(Vue, options, cb) {
document.addEventListener('deviceready', () => {

if (typeof navigator.camera === 'undefined') {
return cb(false)
}

// pass through the camera object
Vue.cordova.camera = navigator.camera

return cb(true)

}, false)
}
}
32 changes: 32 additions & 0 deletions src/libs/vue-cordova/plugins/cordova-plugin-device.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

export default {
install(Vue, options, cb) {
document.addEventListener('deviceready', () => {

if (typeof device === 'undefined' || typeof device.cordova === 'undefined') {
return cb(false)
}

// default values
Vue.cordova.device = {
cordova: null,
model: null,
platform: null,
uuid: null,
version: null,
manufacturer: null,
isVirtual: null,
serial: null
}

Object.keys(Vue.cordova.device).forEach(key => {
if (typeof device[key] !== 'undefined') {
Vue.cordova.device[key] = device[key]
}
})

return cb(true)

}, false)
}
}
10 changes: 4 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,17 @@ Vue.use(vueMethodsPromise, {
}
})

var VueCordova = require('./libs/vue-cordova');
Vue.use(VueCordova);


import Toasted from 'vue-toasted';
Vue.use(Toasted,{
theme: "primary",
position: "bottom-center",
duration : 3000
})

//var VueTouch = require('vue-touch')
//Vue.use(VueTouch, {name: 'v-touch'})

import VueCordova from 'vue-cordova'
Vue.use(VueCordova)

// add cordova.js only if serving the app through file://
if (window.location.protocol === 'file:' || window.location.port === '3000') {
var cordovaScript = document.createElement('script')
Expand Down

0 comments on commit 26c45c6

Please sign in to comment.