Skip to content

Commit e99e22b

Browse files
author
Igor Khomenko
committed
added sample chat-cordova
1 parent e843046 commit e99e22b

File tree

458 files changed

+55248
-496
lines changed

Some content is hidden

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

458 files changed

+55248
-496
lines changed
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Non-project-specific build files:
2+
build.xml
3+
local.properties
4+
/gradlew
5+
/gradlew.bat
6+
/gradle
7+
# Ant builds
8+
ant-build
9+
ant-gen
10+
# Eclipse builds
11+
gen
12+
out
13+
# Gradle builds
14+
/build
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.cordova.hellocordova" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
6+
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
7+
<intent-filter android:label="@string/launcher_name">
8+
<action android:name="android.intent.action.MAIN" />
9+
<category android:name="android.intent.category.LAUNCHER" />
10+
</intent-filter>
11+
</activity>
12+
</application>
13+
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
14+
</manifest>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
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+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
21+
package="org.apache.cordova" android:versionName="1.0" android:versionCode="1">
22+
<uses-sdk android:minSdkVersion="14" />
23+
</manifest>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* Licensed to the Apache Software Foundation (ASF) under one
2+
or more contributor license agreements. See the NOTICE file
3+
distributed with this work for additional information
4+
regarding copyright ownership. The ASF licenses this file
5+
to you under the Apache License, Version 2.0 (the
6+
"License"); you may not use this file except in compliance
7+
with the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing,
12+
software distributed under the License is distributed on an
13+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
KIND, either express or implied. See the License for the
15+
specific language governing permissions and limitations
16+
under the License.
17+
*/
18+
19+
20+
21+
buildscript {
22+
repositories {
23+
mavenCentral()
24+
}
25+
26+
dependencies {
27+
classpath 'com.android.tools.build:gradle:1.5.0'
28+
}
29+
30+
}
31+
32+
apply plugin: 'android-library'
33+
34+
ext {
35+
apply from: 'cordova.gradle'
36+
cdvCompileSdkVersion = privateHelpers.getProjectTarget()
37+
cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
38+
}
39+
40+
android {
41+
compileSdkVersion cdvCompileSdkVersion
42+
buildToolsVersion cdvBuildToolsVersion
43+
publishNonDefault true
44+
45+
compileOptions {
46+
sourceCompatibility JavaVersion.VERSION_1_6
47+
targetCompatibility JavaVersion.VERSION_1_6
48+
}
49+
50+
sourceSets {
51+
main {
52+
manifest.srcFile 'AndroidManifest.xml'
53+
java.srcDirs = ['src']
54+
resources.srcDirs = ['src']
55+
aidl.srcDirs = ['src']
56+
renderscript.srcDirs = ['src']
57+
res.srcDirs = ['res']
58+
assets.srcDirs = ['assets']
59+
}
60+
}
61+
}
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
import java.util.regex.Pattern
21+
import groovy.swing.SwingBuilder
22+
23+
String doEnsureValueExists(filePath, props, key) {
24+
if (props.get(key) == null) {
25+
throw new GradleException(filePath + ': Missing key required "' + key + '"')
26+
}
27+
return props.get(key)
28+
}
29+
30+
String doGetProjectTarget() {
31+
def props = new Properties()
32+
file('project.properties').withReader { reader ->
33+
props.load(reader)
34+
}
35+
return doEnsureValueExists('project.properties', props, 'target')
36+
}
37+
38+
String[] getAvailableBuildTools() {
39+
def buildToolsDir = new File(getAndroidSdkDir(), "build-tools")
40+
buildToolsDir.list()
41+
.findAll { it ==~ /[0-9.]+/ }
42+
.sort { a, b -> compareVersions(b, a) }
43+
}
44+
45+
String doFindLatestInstalledBuildTools(String minBuildToolsVersion) {
46+
def availableBuildToolsVersions
47+
try {
48+
availableBuildToolsVersions = getAvailableBuildTools()
49+
} catch (e) {
50+
println "An exception occurred while trying to find the Android build tools."
51+
throw e
52+
}
53+
if (availableBuildToolsVersions.length > 0) {
54+
def highestBuildToolsVersion = availableBuildToolsVersions[0]
55+
if (compareVersions(highestBuildToolsVersion, minBuildToolsVersion) < 0) {
56+
throw new RuntimeException(
57+
"No usable Android build tools found. Highest installed version is " +
58+
highestBuildToolsVersion + "; minimum version required is " +
59+
minBuildToolsVersion + ".")
60+
}
61+
highestBuildToolsVersion
62+
} else {
63+
throw new RuntimeException(
64+
"No installed build tools found. Please install the Android build tools version " +
65+
minBuildToolsVersion + " or higher.")
66+
}
67+
}
68+
69+
// Return the first non-zero result of subtracting version list elements
70+
// pairwise. If they are all identical, return the difference in length of
71+
// the two lists.
72+
int compareVersionList(Collection aParts, Collection bParts) {
73+
def pairs = ([aParts, bParts]).transpose()
74+
pairs.findResult(aParts.size()-bParts.size()) {it[0] - it[1] != 0 ? it[0] - it[1] : null}
75+
}
76+
77+
// Compare two version strings, such as "19.0.0" and "18.1.1.0". If all matched
78+
// elements are identical, the longer version is the largest by this method.
79+
// Examples:
80+
// "19.0.0" > "19"
81+
// "19.0.1" > "19.0.0"
82+
// "19.1.0" > "19.0.1"
83+
// "19" > "18.999.999"
84+
int compareVersions(String a, String b) {
85+
def aParts = a.tokenize('.').collect {it.toInteger()}
86+
def bParts = b.tokenize('.').collect {it.toInteger()}
87+
compareVersionList(aParts, bParts)
88+
}
89+
90+
String getAndroidSdkDir() {
91+
def rootDir = project.rootDir
92+
def androidSdkDir = null
93+
String envVar = System.getenv("ANDROID_HOME")
94+
def localProperties = new File(rootDir, 'local.properties')
95+
String systemProperty = System.getProperty("android.home")
96+
if (envVar != null) {
97+
androidSdkDir = envVar
98+
} else if (localProperties.exists()) {
99+
Properties properties = new Properties()
100+
localProperties.withInputStream { instr ->
101+
properties.load(instr)
102+
}
103+
def sdkDirProp = properties.getProperty('sdk.dir')
104+
if (sdkDirProp != null) {
105+
androidSdkDir = sdkDirProp
106+
} else {
107+
sdkDirProp = properties.getProperty('android.dir')
108+
if (sdkDirProp != null) {
109+
androidSdkDir = (new File(rootDir, sdkDirProp)).getAbsolutePath()
110+
}
111+
}
112+
}
113+
if (androidSdkDir == null && systemProperty != null) {
114+
androidSdkDir = systemProperty
115+
}
116+
if (androidSdkDir == null) {
117+
throw new RuntimeException(
118+
"Unable to determine Android SDK directory.")
119+
}
120+
androidSdkDir
121+
}
122+
123+
def doExtractIntFromManifest(name) {
124+
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
125+
def pattern = Pattern.compile(name + "=\"(\\d+)\"")
126+
def matcher = pattern.matcher(manifestFile.getText())
127+
matcher.find()
128+
return Integer.parseInt(matcher.group(1))
129+
}
130+
131+
def doExtractStringFromManifest(name) {
132+
def manifestFile = file(android.sourceSets.main.manifest.srcFile)
133+
def pattern = Pattern.compile(name + "=\"(\\S+)\"")
134+
def matcher = pattern.matcher(manifestFile.getText())
135+
matcher.find()
136+
return matcher.group(1)
137+
}
138+
139+
def doPromptForPassword(msg) {
140+
if (System.console() == null) {
141+
def ret = null
142+
new SwingBuilder().edt {
143+
dialog(modal: true, title: 'Enter password', alwaysOnTop: true, resizable: false, locationRelativeTo: null, pack: true, show: true) {
144+
vbox {
145+
label(text: msg)
146+
def input = passwordField()
147+
button(defaultButton: true, text: 'OK', actionPerformed: {
148+
ret = input.password;
149+
dispose();
150+
})
151+
}
152+
}
153+
}
154+
if (!ret) {
155+
throw new GradleException('User canceled build')
156+
}
157+
return new String(ret)
158+
} else {
159+
return System.console().readPassword('\n' + msg);
160+
}
161+
}
162+
163+
def doGetConfigXml() {
164+
def xml = file("res/xml/config.xml").getText()
165+
// Disable namespace awareness since Cordova doesn't use them properly
166+
return new XmlParser(false, false).parseText(xml)
167+
}
168+
169+
def doGetConfigPreference(name, defaultValue) {
170+
name = name.toLowerCase()
171+
def root = doGetConfigXml()
172+
173+
def ret = defaultValue
174+
root.preference.each { it ->
175+
def attrName = it.attribute("name")
176+
if (attrName && attrName.toLowerCase() == name) {
177+
ret = it.attribute("value")
178+
}
179+
}
180+
return ret
181+
}
182+
183+
// Properties exported here are visible to all plugins.
184+
ext {
185+
// These helpers are shared, but are not guaranteed to be stable / unchanged.
186+
privateHelpers = {}
187+
privateHelpers.getProjectTarget = { doGetProjectTarget() }
188+
privateHelpers.findLatestInstalledBuildTools = { doFindLatestInstalledBuildTools('19.1.0') }
189+
privateHelpers.extractIntFromManifest = { name -> doExtractIntFromManifest(name) }
190+
privateHelpers.extractStringFromManifest = { name -> doExtractStringFromManifest(name) }
191+
privateHelpers.promptForPassword = { msg -> doPromptForPassword(msg) }
192+
privateHelpers.ensureValueExists = { filePath, props, key -> doEnsureValueExists(filePath, props, key) }
193+
194+
// These helpers can be used by plugins / projects and will not change.
195+
cdvHelpers = {}
196+
// Returns a XmlParser for the config.xml. Added in 4.1.0.
197+
cdvHelpers.getConfigXml = { doGetConfigXml() }
198+
// Returns the value for the desired <preference>. Added in 4.1.0.
199+
cdvHelpers.getConfigPreference = { name, defaultValue -> doGetConfigPreference(name, defaultValue) }
200+
}
201+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system use,
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
10+
# Indicates whether an apk should be generated for each density.
11+
split.density=false
12+
# Project target.
13+
target=android-23
14+
apk-configurations=
15+
renderscript.opt.level=O0
16+
android.library=true

0 commit comments

Comments
 (0)