Skip to content

Commit a58f8ab

Browse files
committed
Initial Commit
0 parents  commit a58f8ab

27 files changed

+2462
-0
lines changed

Stubber.jar

11.5 KB
Binary file not shown.

build.xml

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--build_version=1.4-->
3+
4+
5+
<project name="Connectivity" default="default" basedir=".">
6+
<description>Builds, tests, and runs the project Connectivity.</description>
7+
<import file="nbproject/build-impl.xml"/>
8+
<property file="codenameone_settings.properties"/>
9+
10+
<target depends="init,compile,jar" name="compile-test">
11+
</target>
12+
13+
<target depends="compile-test" name="-do-test-run">
14+
</target>
15+
16+
<target depends="-do-test-run" description="Run unit tests." name="test">
17+
<echo>Currently testing a library project isn't supported</echo>
18+
</target>
19+
20+
<target name="-pre-compile">
21+
<echo>Compile is forcing compliance to the supported API's/features for maximum device compatibility. This allows smaller
22+
code size and wider device support</echo>
23+
<mkdir dir="build/tmp"/>
24+
<javac destdir="build/tmp"
25+
source="1.5"
26+
target="1.5"
27+
bootclasspath="lib/CLDC11.jar"
28+
classpath="${javac.classpath}:${build.classes.dir}">
29+
<src path="${src.dir}"/>
30+
</javac>
31+
</target>
32+
33+
34+
<target name="-pre-init">
35+
<property name="javac.source" value="1.5" />
36+
<property name="javac.target" value="1.5" />
37+
</target>
38+
39+
<target name="run">
40+
<echo>You can't run a library project</echo>
41+
</target>
42+
43+
<target name="debug">
44+
<echo>You can't run a library project</echo>
45+
</target>
46+
47+
<target name="Stubs">
48+
<delete dir="build/stubs"/>
49+
<javadoc sourcepath="src"
50+
classpath="lib/CodenameOne.jar:lib/CLDC11.jar"
51+
docletpath="Stubber.jar"
52+
doclet="com.codename1.build.client.StubGenerator">
53+
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
54+
<filename name="**/*.java"/>
55+
</fileset>
56+
</javadoc>
57+
</target>
58+
59+
<target name="jar" depends="compile,Stubs">
60+
<mkdir dir="build/lib" />
61+
<zip basedir="${build.classes.dir}" compress="false" destfile="build/lib/main.zip" />
62+
<zip basedir="build/stubs" compress="false" destfile="build/lib/stubs.zip" />
63+
<copy file="manifest.properties" todir="build/lib" />
64+
<copy file="codenameone_library_appended.properties" todir="build/lib" />
65+
<copy file="codenameone_library_required.properties" todir="build/lib" />
66+
<antcall target="buildNativeIOS" />
67+
<antcall target="buildNativeRIM" />
68+
<antcall target="buildNativeAND" />
69+
<antcall target="buildNativeSE" />
70+
<antcall target="buildNativeWIN" />
71+
<antcall target="buildNativeME" />
72+
<antcall target="buildNativeJS" />
73+
<mkdir dir="dist" />
74+
<zip basedir="build/lib" compress="true" destfile="dist/${application.title}.cn1lib" />
75+
</target>
76+
77+
<target name="buildNativeRIM">
78+
<path id="rimNativeDir">
79+
<fileset dir="native/rim"/>
80+
</path>
81+
<property name="test.rimDir.property" refid="rimNativeDir"/>
82+
<condition property="doesntHaveRimFiles">
83+
<equals arg1="" arg2="${test.rimDir.property}"/>
84+
</condition>
85+
86+
<antcall target="createRimZip" />
87+
</target>
88+
89+
<target name="createRimZip"
90+
unless="doesntHaveRimFiles">
91+
<echo>Zipping rim native code</echo>
92+
<zip basedir="native/rim" compress="false" destfile="build/lib/nativerim.zip" />
93+
</target>
94+
95+
<target name="buildNativeAND">
96+
<path id="andNativeDir">
97+
<fileset dir="native/android"/>
98+
</path>
99+
<property name="test.andDir.property" refid="andNativeDir"/>
100+
<condition property="doesntHaveAndFiles">
101+
<equals arg1="" arg2="${test.andDir.property}"/>
102+
</condition>
103+
104+
<antcall target="createAndZip" />
105+
</target>
106+
107+
<target name="buildNativeSE">
108+
<mkdir dir="native/javase" />
109+
<path id="seNativeDir">
110+
<fileset dir="native/javase"/>
111+
</path>
112+
<property name="test.seDir.property" refid="seNativeDir"/>
113+
<condition property="doesntHaveSeFiles">
114+
<equals arg1="" arg2="${test.seDir.property}"/>
115+
</condition>
116+
117+
<antcall target="createSeZip" />
118+
</target>
119+
120+
<target name="createSeZip"
121+
unless="doesntHaveSeFiles">
122+
<echo>Zipping JavaSE native code</echo>
123+
<zip basedir="native/javase" compress="false" destfile="build/lib/nativese.zip" />
124+
125+
</target>
126+
127+
<target name="createAndZip"
128+
unless="doesntHaveAndFiles">
129+
<echo>Zipping Android native code</echo>
130+
<zip basedir="native/android" compress="false" destfile="build/lib/nativeand.zip" />
131+
</target>
132+
133+
<target name="buildNativeWIN">
134+
<path id="winNativeDir">
135+
<fileset dir="native/win"/>
136+
</path>
137+
<property name="test.winDir.property" refid="winNativeDir"/>
138+
<condition property="doesntHaveWinFiles">
139+
<equals arg1="" arg2="${test.winDir.property}"/>
140+
</condition>
141+
142+
<antcall target="createWinZip" />
143+
</target>
144+
145+
<target name="createWinZip"
146+
unless="doesntHaveWinFiles">
147+
<echo>Zipping win native code</echo>
148+
<zip basedir="native/win" compress="false" destfile="build/lib/nativewin.zip" />
149+
</target>
150+
151+
<target name="buildNativeIOS">
152+
<path id="iosNativeDir">
153+
<fileset dir="native/ios"/>
154+
</path>
155+
<property name="test.iosDir.property" refid="iosNativeDir"/>
156+
<condition property="doesntHaveIosFiles">
157+
<equals arg1="" arg2="${test.iosDir.property}"/>
158+
</condition>
159+
160+
<antcall target="createIosZip" />
161+
</target>
162+
163+
<target name="createIosZip"
164+
unless="doesntHaveIosFiles">
165+
<echo>Zipping ios native code</echo>
166+
<zip basedir="native/ios" compress="false" destfile="build/lib/nativeios.zip" />
167+
</target>
168+
169+
<target name="buildNativeME">
170+
<path id="meNativeDir">
171+
<fileset dir="native/j2me"/>
172+
</path>
173+
<property name="test.meDir.property" refid="meNativeDir"/>
174+
<condition property="doesntHaveMeFiles">
175+
<equals arg1="" arg2="${test.meDir.property}"/>
176+
</condition>
177+
178+
<antcall target="createMeZip" />
179+
</target>
180+
181+
<target name="createMeZip"
182+
unless="doesntHaveMeFiles">
183+
<echo>Zipping me native code</echo>
184+
<zip basedir="native/j2me" compress="false" destfile="build/lib/nativeme.zip" />
185+
</target>
186+
187+
188+
<target name="buildNativeJS">
189+
<path id="jsNativeDir">
190+
<fileset dir="native/javascript"/>
191+
</path>
192+
<property name="test.jsDir.property" refid="jsNativeDir"/>
193+
<condition property="doesntHaveJsFiles">
194+
<equals arg1="" arg2="${test.jsDir.property}"/>
195+
</condition>
196+
197+
<antcall target="createJsZip" />
198+
</target>
199+
200+
<target name="createJsZip"
201+
unless="doesntHaveJsFiles">
202+
<echo>Zipping javascript native code</echo>
203+
<zip basedir="native/javascript" compress="false" destfile="build/lib/nativejavascript.zip" />
204+
</target>
205+
206+
</project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
codename1.arg.android.xpermissions=<uses-permission android\:name\="android.permission.ACCESS_NETWORK_STATE"/>
2+
codename1.arg.ios.add_libs=SystemConfiguration.framework
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Place here properties that are required to build this Library and if they have
2+
#a conflict with the main project or with other cn1lib the refresh cn1lib action
3+
#will fail.
4+
#For example codename1.arg.android.includeGPlayServices is a required property type, if the cn1lib
5+
#needs the google play services but the main project marked this property to false
6+
#The refresh cn1lib action will fail.
7+
#
8+
#Wed Jan 09 17:59:31 IST 2013

lib/CLDC11.jar

2 MB
Binary file not shown.

lib/CodenameOne.jar

3.64 MB
Binary file not shown.

lib/CodenameOne_SRC.zip

6.79 MB
Binary file not shown.

manifest.mf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
X-COMMENT: Main-Class will be added automatically by build
3+

manifest.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Codename One libray manifest
2+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
The MIT License (MIT)
3+
Copyright (c) 2014 LittleMonkey Ltd.
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18+
THE SOFTWARE.
19+
*/
20+
package org.littlemonkey.connectivity;
21+
22+
import com.codename1.impl.android.AndroidNativeUtil;
23+
import android.app.Activity;
24+
import android.net.ConnectivityManager;
25+
import android.net.NetworkInfo;
26+
27+
public class NativeConnectivityImpl {
28+
29+
public int getConnectionStatus() {
30+
Activity activity = AndroidNativeUtil.getActivity();
31+
ConnectivityManager connManager = (ConnectivityManager) activity.getSystemService(activity.CONNECTIVITY_SERVICE);
32+
NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
33+
NetworkInfo mMobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
34+
35+
if (mWifi.isConnected()) {
36+
return 2;
37+
}
38+
39+
if (mMobile.isConnected()) {
40+
return 1;
41+
}
42+
43+
return 0;
44+
}
45+
46+
public boolean isSupported() {
47+
return true;
48+
}
49+
50+
}

0 commit comments

Comments
 (0)