Skip to content

Commit

Permalink
Improved permonace on android < 4.4 with gradle script.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnill committed Jul 22, 2016
1 parent 67f6be6 commit 9602948
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="com.likesmagia.cordova.updater"
version="0.1.0">
version="0.9.1">

<engines>
<engine name="cordova" version=">=2.4.0" />
Expand All @@ -25,6 +25,10 @@
<asset src="www/updater.html" target="updater.html" />
<asset src="www/config.json" target="config.json" />

<platform name="android">
<framework src="updater.gradle" custom="true" type="gradleReference" />
</platform>

<js-module src="www/updater.js" name="AppUpdater">
<clobbers target="AppUpdater"/>
</js-module>
Expand Down
57 changes: 57 additions & 0 deletions updater.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
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.
*/
ext.postBuildExtras = {
def inAssetsDir = file("assets")
def outAssetsDir = inAssetsDir
def outFile = new File(outAssetsDir, "cdvasset.manifest")

def newTask = task("cdvCreateAssetManifest") << {
def contents = new HashMap()
def sizes = new HashMap()
contents[""] = inAssetsDir.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return !name.equals(".DS_Store");
}
})
def tree = fileTree(dir: inAssetsDir)
tree.visit { fileDetails ->
if (fileDetails.isDirectory()) {
contents[fileDetails.relativePath.toString()] = fileDetails.file.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return !name.equals(".DS_Store");
}
})
} else if (fileDetails.name) {
sizes[fileDetails.relativePath.toString()] = fileDetails.file.length()
}
}

outAssetsDir.mkdirs()
outFile.withObjectOutputStream { oos ->
oos.writeObject(contents)
oos.writeObject(sizes)
}
}
newTask.inputs.dir inAssetsDir
newTask.outputs.file outFile
def preBuildTask = tasks["preBuild"]
preBuildTask.dependsOn(newTask)
}

0 comments on commit 9602948

Please sign in to comment.