Commit 76dea9de220898110f20a03e2468d17d7b54916f
1 parent
5775e070
--no commit message
Showing
30 changed files
with
0 additions
and
1444 deletions
Blinker/.classpath deleted
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<classpath> | ||
3 | - <classpathentry kind="src" path="src"/> | ||
4 | - <classpathentry kind="src" path="gen"/> | ||
5 | - <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
6 | - <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||
7 | - <classpathentry kind="lib" path="libs/EmmocoFramework.jar"/> | ||
8 | - <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> | ||
9 | - <classpathentry kind="output" path="bin/classes"/> | ||
10 | -</classpath> |
Blinker/.project deleted
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<projectDescription> | ||
3 | - <name>Blinker</name> | ||
4 | - <comment></comment> | ||
5 | - <projects> | ||
6 | - </projects> | ||
7 | - <buildSpec> | ||
8 | - <buildCommand> | ||
9 | - <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||
10 | - <arguments> | ||
11 | - </arguments> | ||
12 | - </buildCommand> | ||
13 | - <buildCommand> | ||
14 | - <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||
15 | - <arguments> | ||
16 | - </arguments> | ||
17 | - </buildCommand> | ||
18 | - <buildCommand> | ||
19 | - <name>org.eclipse.jdt.core.javabuilder</name> | ||
20 | - <arguments> | ||
21 | - </arguments> | ||
22 | - </buildCommand> | ||
23 | - <buildCommand> | ||
24 | - <name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||
25 | - <arguments> | ||
26 | - </arguments> | ||
27 | - </buildCommand> | ||
28 | - </buildSpec> | ||
29 | - <natures> | ||
30 | - <nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||
31 | - <nature>org.eclipse.jdt.core.javanature</nature> | ||
32 | - </natures> | ||
33 | -</projectDescription> |
Blinker/.settings/org.eclipse.jdt.core.prefs deleted
Blinker/AndroidManifest.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | - package="com.emmoco.example.blinker" | ||
4 | - android:versionCode="1" | ||
5 | - android:versionName="0.8"> | ||
6 | - <uses-sdk android:minSdkVersion="8" | ||
7 | - android:targetSdkVersion="8" | ||
8 | - android:maxSdkVersion="8" /> | ||
9 | - | ||
10 | - <supports-screens android:largeScreens="false" android:xlargeScreens="false" /> | ||
11 | - | ||
12 | - | ||
13 | - <!-- Application --> | ||
14 | - <application | ||
15 | - android:label="@string/app_name" | ||
16 | - android:debuggable="false" | ||
17 | - android:icon="@drawable/icon" | ||
18 | - android:theme="@style/AppTheme"> | ||
19 | - | ||
20 | - <activity android:name="com.emmoco.example.blinker.MainActivity" | ||
21 | - android:screenOrientation="portrait" | ||
22 | - android:alwaysRetainTaskState="true" | ||
23 | - android:launchMode="singleTop" | ||
24 | - android:clearTaskOnLaunch="false" | ||
25 | - android:label="@string/app_name" | ||
26 | - android:configChanges="keyboardHidden|orientation"> | ||
27 | - <intent-filter> | ||
28 | - <action android:name="android.intent.action.MAIN" /> | ||
29 | - <category android:name="android.intent.category.LAUNCHER" /> | ||
30 | - </intent-filter> | ||
31 | - </activity> | ||
32 | - <activity android:name="com.emmoco.example.blinker.SetDeviceActivity" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation"> </activity> | ||
33 | - </application> | ||
34 | - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
35 | - <uses-permission android:name="android.permission.BLUETOOTH" /> | ||
36 | - <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> | ||
37 | - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
38 | - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
39 | - <uses-permission android:name="android.permission.INTERNET" /> | ||
40 | -</manifest> |
Blinker/ant.properties deleted
1 | -# This file is used to override default values used by the Ant build system. | ||
2 | -# | ||
3 | -# This file must be checked in Version Control Systems, as it is | ||
4 | -# integral to the build system of your project. | ||
5 | - | ||
6 | -# This file is only used by the Ant script. | ||
7 | - | ||
8 | -# You can use this to override default values such as | ||
9 | -# 'source.dir' for the location of your java source folder and | ||
10 | -# 'out.dir' for the location of your output folder. | ||
11 | - | ||
12 | -# You can also use it define how the release builds are signed by declaring | ||
13 | -# the following properties: | ||
14 | -# 'key.store' for the location of your keystore and | ||
15 | -# 'key.alias' for the name of the key to use. | ||
16 | -# The password will be asked during the build when you use the 'release' target. | ||
17 | - |
Blinker/bin/AndroidManifest.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | -<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | - package="com.emmoco.example.blinker" | ||
4 | - android:versionCode="1" | ||
5 | - android:versionName="0.8"> | ||
6 | - <uses-sdk android:minSdkVersion="8" | ||
7 | - android:targetSdkVersion="8" | ||
8 | - android:maxSdkVersion="8" /> | ||
9 | - | ||
10 | - <supports-screens android:largeScreens="false" android:xlargeScreens="false" /> | ||
11 | - | ||
12 | - | ||
13 | - <!-- Application --> | ||
14 | - <application | ||
15 | - android:label="@string/app_name" | ||
16 | - android:debuggable="false" | ||
17 | - android:icon="@drawable/icon" | ||
18 | - android:theme="@style/AppTheme"> | ||
19 | - | ||
20 | - <activity android:name="com.emmoco.example.blinker.MainActivity" | ||
21 | - android:screenOrientation="portrait" | ||
22 | - android:alwaysRetainTaskState="true" | ||
23 | - android:launchMode="singleTop" | ||
24 | - android:clearTaskOnLaunch="false" | ||
25 | - android:label="@string/app_name" | ||
26 | - android:configChanges="keyboardHidden|orientation"> | ||
27 | - <intent-filter> | ||
28 | - <action android:name="android.intent.action.MAIN" /> | ||
29 | - <category android:name="android.intent.category.LAUNCHER" /> | ||
30 | - </intent-filter> | ||
31 | - </activity> | ||
32 | - <activity android:name="com.emmoco.example.blinker.SetDeviceActivity" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation"> </activity> | ||
33 | - </application> | ||
34 | - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
35 | - <uses-permission android:name="android.permission.BLUETOOTH" /> | ||
36 | - <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> | ||
37 | - <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
38 | - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
39 | - <uses-permission android:name="android.permission.INTERNET" /> | ||
40 | -</manifest> |
Blinker/build.xml deleted
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<project name="Blinker" default="help"> | ||
3 | - | ||
4 | - <!-- The local.properties file is created and updated by the 'android' tool. | ||
5 | - It contains the path to the SDK. It should *NOT* be checked into | ||
6 | - Version Control Systems. --> | ||
7 | - <loadproperties srcFile="local.properties" /> | ||
8 | - | ||
9 | - <!-- The ant.properties file can be created by you. It is only edited by the | ||
10 | - 'android' tool to add properties to it. | ||
11 | - This is the place to change some Ant specific build properties. | ||
12 | - Here are some properties you may want to change/update: | ||
13 | - | ||
14 | - source.dir | ||
15 | - The name of the source directory. Default is 'src'. | ||
16 | - out.dir | ||
17 | - The name of the output directory. Default is 'bin'. | ||
18 | - | ||
19 | - For other overridable properties, look at the beginning of the rules | ||
20 | - files in the SDK, at tools/ant/build.xml | ||
21 | - | ||
22 | - Properties related to the SDK location or the project target should | ||
23 | - be updated using the 'android' tool with the 'update' action. | ||
24 | - | ||
25 | - This file is an integral part of the build system for your | ||
26 | - application and should be checked into Version Control Systems. | ||
27 | - | ||
28 | - --> | ||
29 | - <property file="ant.properties" /> | ||
30 | - | ||
31 | - <!-- The project.properties file is created and updated by the 'android' | ||
32 | - tool, as well as ADT. | ||
33 | - | ||
34 | - This contains project specific properties such as project target, and library | ||
35 | - dependencies. Lower level build properties are stored in ant.properties | ||
36 | - (or in .classpath for Eclipse projects). | ||
37 | - | ||
38 | - This file is an integral part of the build system for your | ||
39 | - application and should be checked into Version Control Systems. --> | ||
40 | - <loadproperties srcFile="project.properties" /> | ||
41 | - | ||
42 | - <!-- quick check on sdk.dir --> | ||
43 | - <fail | ||
44 | - message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'" | ||
45 | - unless="sdk.dir" | ||
46 | - /> | ||
47 | - | ||
48 | - | ||
49 | -<!-- extension targets. Uncomment the ones where you want to do custom work | ||
50 | - in between standard targets --> | ||
51 | -<!-- | ||
52 | - <target name="-pre-build"> | ||
53 | - </target> | ||
54 | - <target name="-pre-compile"> | ||
55 | - </target> | ||
56 | - | ||
57 | - /* This is typically used for code obfuscation. | ||
58 | - Compiled code location: ${out.classes.absolute.dir} | ||
59 | - If this is not done in place, override ${out.dex.input.absolute.dir} */ | ||
60 | - <target name="-post-compile"> | ||
61 | - </target> | ||
62 | ---> | ||
63 | - | ||
64 | - <!-- Import the actual build file. | ||
65 | - | ||
66 | - To customize existing targets, there are two options: | ||
67 | - - Customize only one target: | ||
68 | - - copy/paste the target into this file, *before* the | ||
69 | - <import> task. | ||
70 | - - customize it to your needs. | ||
71 | - - Customize the whole content of build.xml | ||
72 | - - copy/paste the content of the rules files (minus the top node) | ||
73 | - into this file, replacing the <import> task. | ||
74 | - - customize to your needs. | ||
75 | - | ||
76 | - *********************** | ||
77 | - ****** IMPORTANT ****** | ||
78 | - *********************** | ||
79 | - In all cases you must update the value of version-tag below to read 'custom' instead of an integer, | ||
80 | - in order to avoid having your file be overridden by tools such as "android update project" | ||
81 | - --> | ||
82 | - <!-- version-tag: custom --> | ||
83 | - <import file="../../../tools/Android/version.xml" optional="true"/> | ||
84 | - <import file="${sdk.dir}/tools/ant/build.xml" /> | ||
85 | - | ||
86 | -</project> |
Blinker/default.properties deleted
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 | -# "build.properties", and override values to adapt the script to your | ||
8 | -# project structure. | ||
9 | - | ||
10 | -# Project target. | ||
11 | -target=android-8 |
Blinker/proguard.cfg deleted
1 | --optimizationpasses 5 | ||
2 | --dontusemixedcaseclassnames | ||
3 | --dontskipnonpubliclibraryclasses | ||
4 | --dontpreverify | ||
5 | --verbose | ||
6 | --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* | ||
7 | - | ||
8 | --keep public class * extends android.app.Activity | ||
9 | --keep public class * extends android.app.Application | ||
10 | --keep public class * extends android.app.Service | ||
11 | --keep public class * extends android.content.BroadcastReceiver | ||
12 | --keep public class * extends android.content.ContentProvider | ||
13 | --keep public class * extends android.app.backup.BackupAgentHelper | ||
14 | --keep public class * extends android.preference.Preference | ||
15 | --keep public class com.android.vending.licensing.ILicensingService | ||
16 | - | ||
17 | --keepclasseswithmembernames class * { | ||
18 | - native <methods>; | ||
19 | -} | ||
20 | - | ||
21 | --keepclasseswithmembers class * { | ||
22 | - public <init>(android.content.Context, android.util.AttributeSet); | ||
23 | -} | ||
24 | - | ||
25 | --keepclasseswithmembers class * { | ||
26 | - public <init>(android.content.Context, android.util.AttributeSet, int); | ||
27 | -} | ||
28 | - | ||
29 | --keepclassmembers class * extends android.app.Activity { | ||
30 | - public void *(android.view.View); | ||
31 | -} | ||
32 | - | ||
33 | --keepclassmembers enum * { | ||
34 | - public static **[] values(); | ||
35 | - public static ** valueOf(java.lang.String); | ||
36 | -} | ||
37 | - | ||
38 | --keep class * implements android.os.Parcelable { | ||
39 | - public static final android.os.Parcelable$Creator *; | ||
40 | -} |
Blinker/project.properties deleted
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 | -# Project target. | ||
11 | -target=android-10 |
Blinker/res/drawable-hdpi/blinker_connection_connected.png deleted
1.14 KB
Blinker/res/drawable-hdpi/blinker_connection_disconnected.png deleted
1.15 KB
Blinker/res/drawable-hdpi/blinker_light_off.png deleted
14.8 KB
Blinker/res/drawable-hdpi/blinker_light_on.png deleted
13.6 KB
Blinker/res/drawable-hdpi/icon.png deleted
2.06 KB
Blinker/res/drawable-ldpi/icon.png deleted
1.68 KB
Blinker/res/drawable-mdpi/icon.png deleted
2.06 KB
Blinker/res/drawable/connected_indicator.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | -<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
3 | - | ||
4 | - <item android:state_enabled="false" android:drawable="@drawable/blinker_connection_disconnected"/> | ||
5 | - | ||
6 | - <item android:drawable="@drawable/blinker_connection_connected"/> | ||
7 | - | ||
8 | -</selector> | ||
9 | \ No newline at end of file | 0 | \ No newline at end of file |
Blinker/res/drawable/gradient.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | - | ||
3 | -<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | - android:shape="rectangle"> | ||
5 | - <gradient | ||
6 | - android:startColor="#66000000" | ||
7 | - android:endColor="#DD000000" | ||
8 | - android:angle="270"/> | ||
9 | -</shape> | ||
10 | \ No newline at end of file | 0 | \ No newline at end of file |
Blinker/res/drawable/led.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | - | ||
3 | -<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
4 | - <item | ||
5 | - android:state_selected="true" | ||
6 | - android:drawable="@drawable/blinker_light_on" /> | ||
7 | - <item | ||
8 | - android:state_selected="false" | ||
9 | - android:drawable="@drawable/blinker_light_off" /> | ||
10 | -</selector> | ||
11 | - | ||
12 | - |
Blinker/res/layout/list_item.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | - | ||
3 | -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | - android:layout_width="fill_parent" | ||
5 | - android:layout_height="wrap_content"> | ||
6 | - <TextView | ||
7 | - android:id="@+id/item_label" | ||
8 | - android:layout_alignParentLeft="true" | ||
9 | - android:layout_gravity="left" | ||
10 | - android:layout_width="wrap_content" | ||
11 | - android:layout_height="fill_parent" | ||
12 | - android:layout_centerVertical="true" | ||
13 | - android:textSize="20px" | ||
14 | - android:text="test" | ||
15 | - android:paddingBottom="10dp" | ||
16 | - android:paddingTop="10dp" | ||
17 | - android:layout_marginLeft="10dp" | ||
18 | - android:textColor="@color/labels" | ||
19 | - /> | ||
20 | - <ImageView | ||
21 | - android:id="@+id/checkmark" | ||
22 | - android:src="@android:drawable/checkbox_on_background" | ||
23 | - android:layout_alignParentRight="true" | ||
24 | - android:layout_centerVertical="true" | ||
25 | - android:layout_width="wrap_content" | ||
26 | - android:layout_height="wrap_content" | ||
27 | - android:layout_marginRight="10dp" | ||
28 | - /> | ||
29 | - | ||
30 | -</RelativeLayout> | ||
31 | \ No newline at end of file | 0 | \ No newline at end of file |
Blinker/res/layout/main_activity.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | - android:layout_width="fill_parent" | ||
4 | - android:layout_height="fill_parent" | ||
5 | - android:background="@color/background"> | ||
6 | - | ||
7 | - | ||
8 | - <!--Connected and disconnected graphic in upper right corner--> | ||
9 | - <ImageView | ||
10 | - android:contentDescription="connected indicator" | ||
11 | - android:id="@+id/connected_indicator" | ||
12 | - android:layout_alignParentRight="true" | ||
13 | - android:layout_alignParentTop="true" | ||
14 | - android:layout_height="wrap_content" | ||
15 | - android:layout_width="wrap_content" | ||
16 | - android:layout_marginRight="5dp" | ||
17 | - android:layout_marginTop="5dp" | ||
18 | - android:src="@drawable/connected_indicator" | ||
19 | - /> | ||
20 | - | ||
21 | - /> | ||
22 | - | ||
23 | - <!--The LED image--> | ||
24 | - <ImageView | ||
25 | - android:contentDescription="led image" | ||
26 | - android:id="@+id/led_image" | ||
27 | - android:layout_marginTop="10dp" | ||
28 | - android:layout_marginBottom="45dp" | ||
29 | - android:layout_below="@id/connected_indicator" | ||
30 | - android:layout_height="wrap_content" | ||
31 | - android:layout_width="wrap_content" | ||
32 | - android:layout_centerHorizontal="true" | ||
33 | - android:src="@drawable/led" /> | ||
34 | - | ||
35 | - | ||
36 | - | ||
37 | - | ||
38 | - <!--The on/off control line--> | ||
39 | - <RelativeLayout | ||
40 | - android:id="@+id/blink_control" | ||
41 | - android:layout_below="@id/led_image" | ||
42 | - android:layout_width="fill_parent" | ||
43 | - android:layout_height="wrap_content" | ||
44 | - android:layout_marginBottom="@dimen/control_bottom"> | ||
45 | - | ||
46 | - <TextView android:layout_height="wrap_content" | ||
47 | - android:layout_width="wrap_content" | ||
48 | - android:text="@string/label_blink" | ||
49 | - android:textColor="@color/labels" | ||
50 | - android:textStyle="bold" | ||
51 | - android:layout_marginLeft="@dimen/label_left_margin" | ||
52 | - android:layout_alignParentLeft="true" | ||
53 | - android:layout_centerVertical="true" | ||
54 | - /> | ||
55 | - | ||
56 | - <ToggleButton | ||
57 | - android:id="@+id/on_off_button" | ||
58 | - android:layout_height="wrap_content" | ||
59 | - android:layout_width="wrap_content" | ||
60 | - android:layout_centerHorizontal="true" | ||
61 | - android:layout_centerVertical="true" | ||
62 | - android:textOff="@string/toggle_text_off" | ||
63 | - android:textOn="@string/toggle_text_on" | ||
64 | - android:gravity="center_horizontal" | ||
65 | - android:onClick="onToggleOnOff" | ||
66 | - /> | ||
67 | - | ||
68 | - <TextView | ||
69 | - android:id="@+id/indicator_count" | ||
70 | - android:layout_height="wrap_content" | ||
71 | - android:layout_width="wrap_content" | ||
72 | - android:layout_marginRight="@dimen/label_right_margin" | ||
73 | - android:layout_alignParentRight="true" | ||
74 | - android:layout_centerVertical="true" | ||
75 | - android:text="0" | ||
76 | - android:textStyle="bold" | ||
77 | - android:textColor="@color/numbers" | ||
78 | - /> | ||
79 | - | ||
80 | - </RelativeLayout> | ||
81 | - | ||
82 | - | ||
83 | - | ||
84 | - <!--The Delay Slider Control and Display Line--> | ||
85 | - <RelativeLayout | ||
86 | - android:id="@+id/delay_control" | ||
87 | - android:layout_below="@id/blink_control" | ||
88 | - android:layout_width="fill_parent" | ||
89 | - android:layout_height="wrap_content" | ||
90 | - android:layout_marginBottom="@dimen/control_bottom"> | ||
91 | - | ||
92 | - | ||
93 | - <TextView android:layout_height="wrap_content" | ||
94 | - android:layout_width="wrap_content" | ||
95 | - android:text="@string/label_delay" | ||
96 | - android:textColor="@color/labels" | ||
97 | - android:textStyle="bold" | ||
98 | - android:layout_marginLeft="@dimen/label_left_margin" | ||
99 | - android:layout_alignParentLeft="true" | ||
100 | - android:layout_centerVertical="true" | ||
101 | - /> | ||
102 | - <SeekBar | ||
103 | - android:id="@+id/slider" | ||
104 | - android:layout_width="150dp" | ||
105 | - android:layout_height="wrap_content" | ||
106 | - android:layout_centerVertical="true" | ||
107 | - android:layout_centerHorizontal="true" | ||
108 | - /> | ||
109 | - | ||
110 | - <TextView | ||
111 | - android:id="@+id/delay" | ||
112 | - android:layout_height="wrap_content" | ||
113 | - android:layout_width="wrap_content" | ||
114 | - android:layout_marginRight="@dimen/label_right_margin" | ||
115 | - android:layout_alignParentRight="true" | ||
116 | - android:layout_centerVertical="true" | ||
117 | - android:text="0" | ||
118 | - android:textStyle="bold" | ||
119 | - android:textColor="@color/numbers" | ||
120 | - /> | ||
121 | - | ||
122 | - </RelativeLayout> | ||
123 | - | ||
124 | - | ||
125 | - <!--The Repeat Control and Display Line--> | ||
126 | - <RelativeLayout | ||
127 | - android:id="@+id/repeat_control" | ||
128 | - android:layout_below="@id/delay_control" | ||
129 | - android:layout_width="fill_parent" | ||
130 | - android:layout_height="wrap_content" | ||
131 | - android:layout_marginBottom="@dimen/control_bottom"> | ||
132 | - | ||
133 | - | ||
134 | - <TextView android:layout_height="wrap_content" | ||
135 | - android:layout_width="wrap_content" | ||
136 | - android:text="@string/label_repeat" | ||
137 | - android:textColor="@color/labels" | ||
138 | - android:textStyle="bold" | ||
139 | - android:layout_marginLeft="@dimen/label_left_margin" | ||
140 | - android:layout_alignParentLeft="true" | ||
141 | - android:layout_centerVertical="true" | ||
142 | - /> | ||
143 | - | ||
144 | - <LinearLayout | ||
145 | - android:layout_width="wrap_content" | ||
146 | - android:layout_height="wrap_content" | ||
147 | - android:orientation="horizontal" | ||
148 | - android:layout_centerVertical="true" | ||
149 | - android:layout_centerHorizontal="true" | ||
150 | - > | ||
151 | - <Button | ||
152 | - android:id="@+id/minus_button" | ||
153 | - android:layout_height="wrap_content" | ||
154 | - android:layout_width="wrap_content" | ||
155 | - android:text="-" | ||
156 | - android:textSize="30dp" | ||
157 | - android:typeface="monospace" | ||
158 | - android:paddingLeft="22dp" | ||
159 | - android:paddingRight="22dp" | ||
160 | - | ||
161 | - android:gravity="center" | ||
162 | - android:layout_marginRight="0dp" | ||
163 | - android:onClick="onMinusButtonClick" | ||
164 | - /> | ||
165 | - | ||
166 | - <Button | ||
167 | - android:id="@+id/plus_button" | ||
168 | - android:layout_height="wrap_content" | ||
169 | - android:layout_width="wrap_content" | ||
170 | - android:text="+" | ||
171 | - android:textSize="30dp" | ||
172 | - android:typeface="monospace" | ||
173 | - android:paddingLeft="22dp" | ||
174 | - android:paddingRight="22dp" | ||
175 | - | ||
176 | - android:gravity="center" | ||
177 | - android:layout_marginLeft="0dp" | ||
178 | - android:onClick="onPlusButtonClick" | ||
179 | - /> | ||
180 | - | ||
181 | - </LinearLayout> | ||
182 | - | ||
183 | - | ||
184 | - <TextView | ||
185 | - android:id="@+id/repeat_count" | ||
186 | - android:layout_height="wrap_content" | ||
187 | - android:layout_width="wrap_content" | ||
188 | - android:layout_marginRight="@dimen/label_right_margin" | ||
189 | - android:layout_alignParentRight="true" | ||
190 | - android:layout_centerVertical="true" | ||
191 | - android:text="0" | ||
192 | - android:textStyle="bold" | ||
193 | - android:textColor="@color/numbers" | ||
194 | - /> | ||
195 | - | ||
196 | - </RelativeLayout> | ||
197 | - | ||
198 | - | ||
199 | - <!--Container for Footer buttons, SetDevice and Connect/Disconnect --> | ||
200 | - <RelativeLayout | ||
201 | - android:layout_width="fill_parent" | ||
202 | - android:layout_height="wrap_content" | ||
203 | - android:layout_alignParentBottom="true" | ||
204 | - android:paddingBottom="8dp" | ||
205 | - android:paddingTop="8dp" | ||
206 | - android:background="@drawable/gradient" | ||
207 | - > | ||
208 | - | ||
209 | - <Button | ||
210 | - android:id="@+id/connect_button" | ||
211 | - android:text="@string/label_connect" | ||
212 | - android:gravity="center" | ||
213 | - android:layout_centerVertical="true" | ||
214 | - android:layout_alignParentRight="true" | ||
215 | - android:layout_height="wrap_content" | ||
216 | - android:layout_width="wrap_content" | ||
217 | - android:onClick="onConnectToggleClick" | ||
218 | - | ||
219 | - /> | ||
220 | - <Button | ||
221 | - android:id="@+id/setdevice_button" | ||
222 | - android:text="@string/label_set_device" | ||
223 | - android:gravity="center" | ||
224 | - android:layout_centerVertical="true" | ||
225 | - android:layout_alignParentLeft="true" | ||
226 | - android:layout_height="wrap_content" | ||
227 | - android:layout_width="wrap_content" | ||
228 | - android:onClick="onSetDeviceClick" | ||
229 | - /> | ||
230 | - | ||
231 | - | ||
232 | - | ||
233 | - </RelativeLayout> | ||
234 | - | ||
235 | -</RelativeLayout> | ||
236 | - |
Blinker/res/layout/set_device_activity.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | - | ||
3 | -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
4 | - android:layout_width="fill_parent" | ||
5 | - android:layout_height="fill_parent" | ||
6 | - android:orientation="vertical" | ||
7 | - android:background="@color/background" | ||
8 | - > | ||
9 | - | ||
10 | - <!--Simple header for our list--> | ||
11 | - <RelativeLayout | ||
12 | - android:layout_width="fill_parent" | ||
13 | - android:layout_height="wrap_content" | ||
14 | - android:background="@color/background_header" | ||
15 | - > | ||
16 | - <TextView | ||
17 | - android:layout_width="fill_parent" | ||
18 | - android:layout_height="wrap_content" | ||
19 | - android:paddingBottom="10dp" | ||
20 | - android:layout_centerInParent="true" | ||
21 | - android:gravity="center" | ||
22 | - android:text="@string/heading_set_device" | ||
23 | - android:textStyle="bold" | ||
24 | - /> | ||
25 | - <Button | ||
26 | - android:layout_alignParentRight="true" | ||
27 | - android:layout_width="wrap_content" | ||
28 | - android:layout_height="wrap_content" | ||
29 | - android:text="@string/label_scan" | ||
30 | - android:onClick="onScanDeviceClick"/> | ||
31 | - | ||
32 | - </RelativeLayout> | ||
33 | - | ||
34 | - <!--The actual device list--> | ||
35 | - <ListView | ||
36 | - android:id="@+id/device_list_view" | ||
37 | - android:layout_width="fill_parent" | ||
38 | - android:layout_height="fill_parent" | ||
39 | - /> | ||
40 | - | ||
41 | - | ||
42 | -</LinearLayout> | ||
43 | \ No newline at end of file | 0 | \ No newline at end of file |
Blinker/res/raw/blinker.json deleted
1 | -{"resources":{"$schemaHash":{"id":-6,"align":1,"attributes":{"readonly":true},"type":"A16:u1","access":"r","size":16},"$eapProtocolLevel":{"id":-3,"align":2,"attributes":{"readonly":true},"type":"u2","access":"r","size":2},"cmd":{"id":1,"align":1,"attributes":{"writeonly":true},"type":"E:demos@emmoco.com.Blinker/Cmd","access":"w","size":1},"$mcmProtocolLevel":{"id":-2,"align":2,"attributes":{"readonly":true},"type":"u2","access":"r","size":2},"count":{"id":2,"align":2,"attributes":{"readwrite":true},"type":"i2","access":"rw","size":2},"$schemaUuid":{"id":-1,"align":1,"attributes":{"readonly":true},"type":"A16:u1","access":"r","size":16},"delay":{"id":3,"align":2,"attributes":{"readwrite":true},"type":"N:0.500000,2.000000,0.100000,3/u2","access":"rw","size":2},"$eapBuildDate":{"id":-4,"align":1,"attributes":{"readonly":true},"type":"A8:u1","access":"r","size":8},"$resourceCount":{"id":-7,"align":1,"attributes":{"readonly":true},"type":"S:system@emmoco.com.System/ResourceCount","access":"r","size":2},"ledState":{"id":4,"align":1,"attributes":{"indicator":true,"readonly":true},"type":"E:demos@emmoco.com.Blinker/LedState","access":"ir","size":1},"$fileIndexReset":{"id":-5,"align":2,"attributes":{"writeonly":true},"type":"i2","access":"w","size":2}},"resourceNamesSys":["$eapBuildDate","$eapProtocolLevel","$fileIndexReset","$mcmProtocolLevel","$resourceCount","$schemaHash","$schemaUuid"],"manifest":{"protocolLevel":7,"hash":[193,64,14,198,222,65,254,73,231,195,236,98,124,34,224,251],"name":"Blinker","uuid":[243,78,78,150,58,146,163,180,255,66,64,107,112,96,163,80],"build":[228,142,35,113,54,1,0,0],"date":"2012-04-01T22:40:17","maxAlign":2,"maxSize":16,"version":"1.0.0"},"resourceNames":["cmd","count","delay","ledState","$schemaUuid","$mcmProtocolLevel","$eapProtocolLevel","$eapBuildDate","$fileIndexReset","$schemaHash","$resourceCount"],"attributes":{"description":"Blinker, the hello world program for mobile control","owner":"demos@emmoco.com","uuid":"50a36070-6b40-42ff-b4a3-923a964e4ef3","version":"1.0.0"},"types":{"system@emmoco.com.System/ResourceCount":{"align":1,"type":"S:system@emmoco.com.System/ResourceCount","size":2,"fields":[{"align":1,"name":"app","type":"u1","size":1},{"align":1,"name":"sys","type":"u1","size":1}]},"std:i2":{"align":2,"size":2},"demos@emmoco.com.Blinker/LedState":{"values":["LED_OFF","LED_ON"],"align":1,"type":"E:demos@emmoco.com.Blinker/LedState","size":1},"std:u1":{"align":1,"size":1},"std:u2":{"align":2,"size":2},"demos@emmoco.com.Blinker/Cmd":{"values":["START_CMD","STOP_CMD"],"align":1,"type":"E:demos@emmoco.com.Blinker/Cmd","size":1}},"resourceNamesApp":["cmd","count","delay","ledState"],"imports":{"demos@emmoco.com.Blinker":true}} | ||
2 | \ No newline at end of file | 0 | \ No newline at end of file |
Blinker/res/values/colors.xml deleted
Blinker/res/values/dimensions.xml deleted
Blinker/res/values/strings.xml deleted
1 | -<?xml version="1.0" encoding="utf-8"?> | ||
2 | -<resources> | ||
3 | - <string name="app_name">Blinker Demo</string> | ||
4 | - | ||
5 | - | ||
6 | - <!--Label and heading strings--> | ||
7 | - <string name="label_set_device">Device</string> | ||
8 | - <string name="label_delay">Delay</string> | ||
9 | - <string name="label_repeat">Repeat</string> | ||
10 | - <string name="label_blink">Blink</string> | ||
11 | - <string name="heading_set_device">Choose Target Device"</string> | ||
12 | - <string name="label_connect">Connect</string> | ||
13 | - <string name="label_disconnect">Disconnect</string> | ||
14 | - <string name="label_cancel">Cancel</string> | ||
15 | - <string name="label_scan">Scan</string> | ||
16 | - | ||
17 | - <string name="toggle_text_on">ON</string> | ||
18 | - <string name="toggle_text_off">OFF</string> | ||
19 | - | ||
20 | - | ||
21 | - | ||
22 | - <!--Toast messages--> | ||
23 | - <string name="notice_connected">Emmoco Target Device Connected</string> | ||
24 | - <string name="notice_disconnected">Emmoco Target Device Disconnected</string> | ||
25 | - <string name="notice_timeout">Emmoco Target Device Connection Timeout</string> | ||
26 | - <string name="notice_cancelled">Emmoco Target Device Connection Cancelled</string> | ||
27 | - <string name="notice_failure">Emmoco Target Device Connection Failure</string> | ||
28 | - <string name="notice_uuid_mismatch">Connection Failure. The Target Device Is Not Using The Blinker Schema</string> | ||
29 | - <string name="notice_connecting">Connecting</string> | ||
30 | - <string name="notice_cancelling">Cancelling connection...</string> | ||
31 | - | ||
32 | - | ||
33 | - <!--Dialog text when the schema does not match--> | ||
34 | - <string name="mismatch_title">Incompatible Schema</string> | ||
35 | - <string name="mismatch_uuid">The schema that is on the device you\'re connecting to isn\'t the same | ||
36 | - as the one you\'re viewing currently. Attempting to read or write resources will probably fail.</string> | ||
37 | - | ||
38 | - | ||
39 | - | ||
40 | -</resources> |
Blinker/res/values/styles.xml deleted
Blinker/src/com/emmoco/example/blinker/MainActivity.java deleted
1 | -package com.emmoco.example.blinker; | ||
2 | - | ||
3 | -import android.app.Activity; | ||
4 | -import android.app.ProgressDialog; | ||
5 | -import android.content.Context; | ||
6 | -import android.content.DialogInterface; | ||
7 | -import android.content.Intent; | ||
8 | -import android.content.SharedPreferences; | ||
9 | -import android.os.Bundle; | ||
10 | -import android.preference.PreferenceManager; | ||
11 | -import android.text.InputType; | ||
12 | -import android.view.View; | ||
13 | -import android.widget.*; | ||
14 | -import com.emmoco.android.*; | ||
15 | - | ||
16 | - | ||
17 | -/** | ||
18 | - * This example application uses the Emmoco Framework to connect to a target running the Blinker schema | ||
19 | - * It allows the users to control the target by setting the blink counter, the blink delay and start the LED blinker | ||
20 | - * application running on the target. | ||
21 | - * | ||
22 | - * This application will receive indicators from the target when the LED changes state (on or off) and the app will | ||
23 | - * update an on-screen LED to match the state of the target's LED | ||
24 | - * | ||
25 | - * | ||
26 | - */ | ||
27 | -public class MainActivity extends Activity { | ||
28 | - | ||
29 | - // The connection states track the app's connection to the target device | ||
30 | - public enum ConnectionState { | ||
31 | - CONNECTED, DISCONNECTED | ||
32 | - }; | ||
33 | - | ||
34 | - private final static String TAG = "Blinker"; | ||
35 | - | ||
36 | - private String mCurrentDevice; | ||
37 | - private ResourceSchema mServiceSchema; | ||
38 | - private TargetConnection mTargetConnection; | ||
39 | - | ||
40 | - private ResourceValue mCmdResourceValue; | ||
41 | - private ResourceValue mLedStateResourceValue; | ||
42 | - private ResourceValue mCountResourceValue; | ||
43 | - private ResourceValue mDelayResourceValue; | ||
44 | - | ||
45 | - private ImageView mLedImage; | ||
46 | - private ImageView mIndicator; | ||
47 | - private TextView mCountTextView; | ||
48 | - private TextView mDelayTextView; | ||
49 | - private TextView mIndTextView; | ||
50 | - private Button mConnectButton; | ||
51 | - private ToggleButton mOnOffButton; | ||
52 | - private Button mPlusButton; | ||
53 | - private Button mMinusButton; | ||
54 | - private Button mSetDevice; | ||
55 | - | ||
56 | - private ConnectionState mConnectionState = ConnectionState.DISCONNECTED; | ||
57 | - private long mScaledStep; | ||
58 | - private String mDelayFormat; | ||
59 | - private SeekBar mSlider; | ||
60 | - private StickyProgressDialog mProgress; | ||
61 | - private int mLocalCount; | ||
62 | - | ||
63 | - | ||
64 | - /** | ||
65 | - * Standard Android onCreate method. This will setup all the layout and save references to the UI elements | ||
66 | - * that will be modified during the course of the program | ||
67 | - * | ||
68 | - * @param savedInstanceState | ||
69 | - */ | ||
70 | - @Override | ||
71 | - public void onCreate(Bundle savedInstanceState) { | ||
72 | - | ||
73 | - super.onCreate(savedInstanceState); | ||
74 | - | ||
75 | - // Setup and retrieve view references | ||
76 | - setContentView(R.layout.main_activity); | ||
77 | - mLedImage = (ImageView) findViewById(R.id.led_image); | ||
78 | - mIndicator = (ImageView) findViewById(R.id.connected_indicator); | ||
79 | - mCountTextView = (TextView) findViewById(R.id.repeat_count); | ||
80 | - mIndTextView = (TextView) findViewById(R.id.indicator_count); | ||
81 | - mConnectButton = (Button) findViewById(R.id.connect_button); | ||
82 | - mOnOffButton = (ToggleButton) findViewById(R.id.on_off_button); | ||
83 | - mPlusButton = (Button) findViewById(R.id.plus_button); | ||
84 | - mMinusButton = (Button) findViewById(R.id.minus_button); | ||
85 | - mSetDevice = (Button) findViewById(R.id.setdevice_button); | ||
86 | - | ||
87 | - // Create a ProgressDialog spinner to use during connection | ||
88 | - mProgress = new StickyProgressDialog(this); | ||
89 | - mProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER); | ||
90 | - mProgress.setButton(getResources().getString(R.string.label_cancel), new DialogInterface.OnClickListener() { | ||
91 | - public void onClick(DialogInterface dialog, int which) { | ||
92 | - // Cancel the connect attempt by closing it | ||
93 | - mTargetConnection.closeSync(); | ||
94 | - mProgress.setMessage(getResources().getString(R.string.notice_cancelling)); | ||
95 | - mProgress.show(); | ||
96 | - return; | ||
97 | - } | ||
98 | - }); | ||
99 | - | ||
100 | - // Setup Emmoco specific items | ||
101 | - initializeEmmoco(); | ||
102 | - | ||
103 | - // set the slider for entering the delay value | ||
104 | - setup_slider(); | ||
105 | - | ||
106 | - // Update the UI elements to show that the we are not connected to the target | ||
107 | - updateUiState(false); | ||
108 | - | ||
109 | - | ||
110 | - } | ||
111 | - | ||
112 | - | ||
113 | - | ||
114 | - /** | ||
115 | - * Standard Android onDestroy. Here we will make sure that we are disconnected from the target on Activity | ||
116 | - * destruction. | ||
117 | - */ | ||
118 | - @Override | ||
119 | - protected void onDestroy() { | ||
120 | - super.onDestroy(); | ||
121 | - if (mTargetConnection != null) | ||
122 | - mTargetConnection.closeSync(); | ||
123 | - } | ||
124 | - | ||
125 | - | ||
126 | - /** | ||
127 | - * Do all the work loading the schema and setting up the references to the Emmoco Target's Resources | ||
128 | - */ | ||
129 | - private void initializeEmmoco() { | ||
130 | - | ||
131 | - // load the schema that was downloaded from em-hub. We include the schema as part of the app resources | ||
132 | - mServiceSchema = Framework.current().createSchemaFromRaw(this, R.raw.blinker); | ||
133 | - | ||
134 | - // get the device to connect to from the users preferences | ||
135 | - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); | ||
136 | - mCurrentDevice = prefs.getString(SetDeviceActivity.PREF_DEVICE_NAME, TargetConnection.MOCK_BLINKER_PRE); | ||
137 | - | ||
138 | - // initialize the Emmoco the resources | ||
139 | - mCmdResourceValue = mServiceSchema.newValue("cmd"); | ||
140 | - mLedStateResourceValue = mServiceSchema.newValue("ledState"); | ||
141 | - mCountResourceValue = mServiceSchema.newValue("count"); | ||
142 | - mDelayResourceValue = mServiceSchema.newValue("delay"); | ||
143 | - | ||
144 | - | ||
145 | - } | ||
146 | - | ||
147 | - /** | ||
148 | - * Update the UI elements based on whether we are connected or disconnected from the target | ||
149 | - * | ||
150 | - * If we are connected, we enable all the UI controls. | ||
151 | - * If we are disconnected, we disable all the UI controls that require talking to the target to operate | ||
152 | - * | ||
153 | - * @param connected | ||
154 | - */ | ||
155 | - private void updateUiState(boolean connected){ | ||
156 | - | ||
157 | - // indicator light | ||
158 | - mIndicator.setEnabled(connected); | ||
159 | - | ||
160 | - // delay slider | ||
161 | - mSlider.setEnabled(connected); | ||
162 | - | ||
163 | - // on/off toggle | ||
164 | - mOnOffButton.setEnabled(connected); | ||
165 | - | ||
166 | - if (mConnectionState == ConnectionState.DISCONNECTED){ | ||
167 | - // Change text on connect button | ||
168 | - mConnectButton.setText(R.string.label_connect); | ||
169 | - }else{ | ||
170 | - mConnectButton.setText(R.string.label_disconnect); | ||
171 | - } | ||
172 | - | ||
173 | - // Repeat section buttons | ||
174 | - mMinusButton.setEnabled(connected); | ||
175 | - mPlusButton.setEnabled(connected); | ||
176 | - mCountTextView.setEnabled(connected); | ||
177 | - | ||
178 | - // The device button is only active when not connected | ||
179 | - mSetDevice.setEnabled(!connected); | ||
180 | - | ||
181 | - // When connect or disconnect happens, the toggle button is not checked | ||
182 | - mOnOffButton.setChecked(false); | ||
183 | - | ||
184 | - // Clear the local counter | ||
185 | - mIndTextView.setText(""); | ||
186 | - | ||
187 | - | ||
188 | - } | ||
189 | - | ||
190 | - | ||
191 | - /** | ||
192 | - * Emmoco Reactor used to handle the connection requests to the target | ||
193 | - * | ||
194 | - * Reactors are listeners that are called when the target device state changes, read/writes complete, or the target | ||
195 | - * sends an indicator. | ||
196 | - * | ||
197 | - * Reactors are called from the context of the UI thread. | ||
198 | - * | ||
199 | - * This reactor will be called back during the connection and disconnection phases of the example. | ||
200 | - * | ||
201 | - * This will set the UI elements to certain values based on connection and disconnection states | ||
202 | - * | ||
203 | - */ | ||
204 | - enum Connection { CONNECT_DONE, DISCONNECT_DONE }; | ||
205 | - private Reactor<Connection> mConnectionReactor = new Reactor<Connection>() { | ||
206 | - public void exec(Connection action, int status, Bundle data) { | ||
207 | - Toast msg; | ||
208 | - int notice; | ||
209 | - | ||
210 | - switch (action) { | ||
211 | - case CONNECT_DONE: | ||
212 | - | ||
213 | - if (status == TargetConnection.STATUS_OK) { | ||
214 | - // | ||
215 | - // Connection completed successfully | ||
216 | - // | ||
217 | - mConnectionState = ConnectionState.CONNECTED; | ||
218 | - notice = R.string.notice_connected; | ||
219 | - | ||
220 | - // bind to catch if the far end disconnects | ||
221 | - mTargetConnection.bindHangupEvent(mConnectionReactor.event(Connection.DISCONNECT_DONE)); | ||
222 | - | ||
223 | - // read and display the current value of count | ||
224 | - mTargetConnection.read(mCountResourceValue, mCountReactor.event(CountAction.READ_COMPLETE)); | ||
225 | - | ||
226 | - // read and display the current value of delay | ||
227 | - mTargetConnection.read(mDelayResourceValue, mDelayReactor.event(DelayAction.READ_COMPLETE)); | ||
228 | - | ||
229 | - // Now update all the UI elements | ||
230 | - updateUiState(true); | ||
231 | - } else if (status == TargetConnection.STATUS_UUID_MISMATCH) { | ||
232 | - mConnectionState = ConnectionState.DISCONNECTED; | ||
233 | - notice = R.string.notice_uuid_mismatch; | ||
234 | - } else if (status == TargetConnection.STATUS_CONNECTION_TIMEOUT) { | ||
235 | - mConnectionState = ConnectionState.DISCONNECTED; | ||
236 | - notice = R.string.notice_timeout; | ||
237 | - } else if (status == TargetConnection.STATUS_CONNECTION_CANCELLED) { | ||
238 | - mConnectionState = ConnectionState.DISCONNECTED; | ||
239 | - notice = R.string.notice_cancelled; | ||
240 | - } else { | ||
241 | - // Connection attempt failed. Display a message | ||
242 | - notice = R.string.notice_failure; | ||
243 | - mConnectionState = ConnectionState.DISCONNECTED; | ||
244 | - } | ||
245 | - | ||
246 | - // Show a quick toast with the status of the connection | ||
247 | - msg = Toast.makeText(getApplicationContext(), notice, Toast.LENGTH_LONG); | ||
248 | - msg.show(); | ||
249 | - | ||
250 | - // Dismiss the dialog only when connect result comes back | ||
251 | - mProgress.dismissManually(); | ||
252 | - | ||
253 | - break; | ||
254 | - | ||
255 | - case DISCONNECT_DONE: | ||
256 | - // no need to check the status, disconnect always completes by leaving us | ||
257 | - // in the disconnected state | ||
258 | - mConnectionState = ConnectionState.DISCONNECTED; | ||
259 | - msg = Toast.makeText(getApplicationContext(), R.string.notice_disconnected, Toast.LENGTH_SHORT); | ||
260 | - msg.show(); | ||
261 | - | ||
262 | - updateUiState(false); | ||
263 | - | ||
264 | - break; | ||
265 | - } | ||
266 | - } | ||
267 | - }; | ||
268 | - | ||
269 | - | ||
270 | - /** | ||
271 | - * Reactor used to handle the writes and indicators for the blinker schema. This reactor will be called back | ||
272 | - * after each write (where we do not need to do anything at all) and the firing of the indicator. When the | ||
273 | - * indicator is fired, it signals when the LED changes, so we can use that indicator to trigger our UI LED and | ||
274 | - * countdown value to change | ||
275 | - */ | ||
276 | - enum Action { WRITE_CMD_COMPLETE, INDICATOR }; | ||
277 | - private Reactor<Action> mLedReactor = new Reactor<Action>() { | ||
278 | - public void exec(Action action, int status, Bundle data) { | ||
279 | - switch (action) { | ||
280 | - case WRITE_CMD_COMPLETE: | ||
281 | - // nothing to do | ||
282 | - break; | ||
283 | - case INDICATOR: | ||
284 | - // update the virtual led display based on the value that gets updated when the indicator is fired. | ||
285 | - // We registered this value after connection occurred with bindIndicatorValue() | ||
286 | - if (mLedStateResourceValue.toString().equals("LED_OFF")) { | ||
287 | - mLedImage.setSelected(false); | ||
288 | - if (mLocalCount == 0){ | ||
289 | - // Reached the end, we disable some UI elements | ||
290 | - mIndTextView.setText(""); | ||
291 | - mOnOffButton.setChecked(false); | ||
292 | - } | ||
293 | - } else { | ||
294 | - mLedImage.setSelected(true); | ||
295 | - mLocalCount--; | ||
296 | - mIndTextView.setText(String.valueOf(mLocalCount)); | ||
297 | - } | ||
298 | - break; | ||
299 | - } | ||
300 | - } | ||
301 | - }; | ||
302 | - | ||
303 | - | ||
304 | - /** | ||
305 | - * Reactor used for count value. When the count value is read back from the target, the UI value is updated with | ||
306 | - * the new value that is read back | ||
307 | - */ | ||
308 | - enum CountAction { READ_COMPLETE, WRITE_COMPLETE }; | ||
309 | - private Reactor<CountAction> mCountReactor = new Reactor<CountAction>() { | ||
310 | - public void exec(CountAction action, int status, Bundle data) { | ||
311 | - Long count; | ||
312 | - switch (action) { | ||
313 | - case READ_COMPLETE: | ||
314 | - count = new Long(mCountResourceValue.toLong()); | ||
315 | - mCountTextView.setText(count.toString()); | ||
316 | - break; | ||
317 | - case WRITE_COMPLETE: | ||
318 | - mTargetConnection.read(mCountResourceValue,mCountReactor.event(CountAction.READ_COMPLETE)); | ||
319 | - break; | ||
320 | - } | ||
321 | - } | ||
322 | - }; | ||
323 | - | ||
324 | - | ||
325 | - /** | ||
326 | - * Reactor used for delay resource. When the delay resource is read or written, the seek bar value is moved (on | ||
327 | - * read) and the display value is updated | ||
328 | - */ | ||
329 | - enum DelayAction { READ_COMPLETE, WRITE_COMPLETE }; | ||
330 | - private Reactor<DelayAction> mDelayReactor = new Reactor<DelayAction>() { | ||
331 | - public void exec(DelayAction action, int status, Bundle data) { | ||
332 | - double delay; | ||
333 | - long delayOrd; | ||
334 | - switch (action) { | ||
335 | - case READ_COMPLETE: | ||
336 | - delay = mDelayResourceValue.toDouble(); | ||
337 | - delayOrd = mDelayResourceValue.toLong(); | ||
338 | - mDelayTextView.setText(String.format(mDelayFormat, delay)); | ||
339 | - | ||
340 | - // set the progress bar position based on the ordinal value. We use the ordinal value | ||
341 | - // to determine where to position the seek on the 0 to 100 scale of the seekbar. | ||
342 | - int progress; | ||
343 | - if (delayOrd == mDelayResourceValue.numMaxOrdinal()) { | ||
344 | - progress = 100; | ||
345 | - } else { | ||
346 | - progress = (int) (delayOrd * mScaledStep); | ||
347 | - } | ||
348 | - mSlider.setProgress(progress); | ||
349 | - break; | ||
350 | - case WRITE_COMPLETE: | ||
351 | - // Nothing to do | ||
352 | - break; | ||
353 | - } | ||
354 | - } | ||
355 | - }; | ||
356 | - | ||
357 | - | ||
358 | - | ||
359 | - | ||
360 | - | ||
361 | - | ||
362 | - /** | ||
363 | - * The set-device button has been pressed, start the sub-activity which will change the device preference | ||
364 | - */ | ||
365 | - final private int DEVICE_SELECT = 1; | ||
366 | - public void onSetDeviceClick(View v) { | ||
367 | - Intent i = new Intent(this, SetDeviceActivity.class); | ||
368 | - startActivityForResult(i, DEVICE_SELECT); | ||
369 | - } | ||
370 | - | ||
371 | - /** | ||
372 | - * Process the result from the set-device sub activity | ||
373 | - * | ||
374 | - * @param requestCode | ||
375 | - * @param resultCode | ||
376 | - * @param data | ||
377 | - */ | ||
378 | - @Override | ||
379 | - protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
380 | - switch (requestCode){ | ||
381 | - case DEVICE_SELECT: | ||
382 | - // If the device value string has changed, update our local copy | ||
383 | - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); | ||
384 | - String device = prefs.getString(SetDeviceActivity.PREF_DEVICE_NAME, TargetConnection.MOCK_BLINKER_PRE); | ||
385 | - | ||
386 | - // If device has changed we need to disconnect if connected, then the user can reconnect | ||
387 | - // manually to the new device | ||
388 | - if (!mCurrentDevice.contentEquals(device)){ | ||
389 | - mCurrentDevice = device; | ||
390 | - | ||
391 | - if ((mTargetConnection != null) &&(mTargetConnection.isConnected())){ | ||
392 | - onConnectToggleClick(null); | ||
393 | - } | ||
394 | - } | ||
395 | - break; | ||
396 | - } | ||
397 | - } | ||
398 | - | ||
399 | - /** | ||
400 | - * Handler function for when the on/off button is press. In this handler, depending on the current state, | ||
401 | - * the command is sent to start or stop the blinker on the target | ||
402 | - * | ||
403 | - * @param v unused | ||
404 | - */ | ||
405 | - public void onToggleOnOff(View v) { | ||
406 | - | ||
407 | - String command; | ||
408 | - | ||
409 | - ToggleButton b = (ToggleButton)v; | ||
410 | - | ||
411 | - // Determine which command to send | ||
412 | - if (b.isChecked()){ | ||
413 | - // We have been turned on | ||
414 | - command = "START_CMD"; | ||
415 | - | ||
416 | - // Set up the local count value so we can count down | ||
417 | - mLocalCount = mCountResourceValue.toInt(); | ||
418 | - ((TextView)findViewById(R.id.indicator_count)).setText(String.valueOf(mLocalCount)); | ||
419 | - | ||
420 | - }else{ | ||
421 | - // We have been turned off | ||
422 | - command = "STOP_CMD"; | ||
423 | - } | ||
424 | - | ||
425 | - // Send command | ||
426 | - mCmdResourceValue.assignEnum(command); | ||
427 | - mTargetConnection.write(mCmdResourceValue, mLedReactor.event(Action.WRITE_CMD_COMPLETE)); | ||
428 | - | ||
429 | - } | ||
430 | - | ||
431 | - | ||
432 | - /** | ||
433 | - * Handler for the connect toggle button | ||
434 | - * | ||
435 | - * Normally in an app the user doesn't worry about connecting or disconnecting, we | ||
436 | - * simply connect when the main activity becomes visible and disconnect | ||
437 | - * when another activity comes to the front, but this handler is used to | ||
438 | - * give the user the ability to toggle the connect state by touching the | ||
439 | - * connect/disconnect button | ||
440 | - * | ||
441 | - * @param v unused | ||
442 | - */ | ||
443 | - public void onConnectToggleClick(View v) { | ||
444 | - | ||
445 | - // toggle connect or disconnect | ||
446 | - switch (mConnectionState) { | ||
447 | - case DISCONNECTED: | ||
448 | - | ||
449 | - // Show Connection spinner | ||
450 | - mProgress.setMessage(getResources().getString(R.string.notice_connecting)); | ||
451 | - mProgress.setCancelable(false); | ||
452 | - mProgress.show(); | ||
453 | - | ||
454 | - // configure the generic mock device if it is being used with some default values | ||
455 | - if (mCurrentDevice.equals(TargetConnection.MOCK_PRE)) { | ||
456 | - MockTargetDevice.reset(); | ||
457 | - MockTargetDevice.current().setTickRate(500); | ||
458 | - MockTargetDevice.current().setAccessDelay(2); | ||
459 | - } | ||
460 | - | ||
461 | - // connect to the device using the schema | ||
462 | - mTargetConnection = new TargetConnection(mCurrentDevice, getApplicationContext()); | ||
463 | - mTargetConnection.bindSchema(mServiceSchema); | ||
464 | - mTargetConnection.bindIndicatorValue("ledState", mLedReactor.event(Action.INDICATOR),mLedStateResourceValue); | ||
465 | - | ||
466 | - mTargetConnection.open(mConnectionReactor.event(Connection.CONNECT_DONE)); | ||
467 | - | ||
468 | - break; | ||
469 | - case CONNECTED: | ||
470 | - mTargetConnection.close(mConnectionReactor.event(Connection.DISCONNECT_DONE)); | ||
471 | - break; | ||
472 | - } | ||
473 | - } | ||
474 | - | ||
475 | - /** | ||
476 | - * handler for the minus Button | ||
477 | - * the minus button decrements the count resource and writes it to blinker | ||
478 | - * | ||
479 | - * @param v | ||
480 | - */ | ||
481 | - public void onMinusButtonClick(View v) { | ||
482 | - long count = Long.parseLong(mCountTextView.getText().toString()); | ||
483 | - if (count > 0) { | ||
484 | - count--; | ||
485 | - } | ||
486 | - mCountResourceValue.assignInt(count); | ||
487 | - mTargetConnection.write(mCountResourceValue, mCountReactor.event(CountAction.WRITE_COMPLETE)); | ||
488 | - } | ||
489 | - | ||
490 | - /** | ||
491 | - * Handler for the plus Button | ||
492 | - * The plus button increments the count resource and writes it to blinker | ||
493 | - * | ||
494 | - * @param v | ||
495 | - */ | ||
496 | - public void onPlusButtonClick(View v) { | ||
497 | - long count = Long.parseLong(mCountTextView.getText().toString()); | ||
498 | - if (count < mCountResourceValue.intMax()){ | ||
499 | - count++; | ||
500 | - } | ||
501 | - mCountResourceValue.assignInt(count); | ||
502 | - mTargetConnection.write(mCountResourceValue, mCountReactor.event(CountAction.WRITE_COMPLETE)); | ||
503 | - } | ||
504 | - | ||
505 | - | ||
506 | - | ||
507 | - | ||
508 | - | ||
509 | - /** | ||
510 | - * Sets up the seekbar to be used as the input for changing the target's delay values. This must be called | ||
511 | - * after the schema and resource values are set up, We need to do some math here to split the 0 to 100 range of the | ||
512 | - * seekbar into the number of distinct values we can set the delay resource, and map those parts of the seekbar | ||
513 | - * into values that are set. | ||
514 | - * | ||
515 | - */ | ||
516 | - private void setup_slider() { | ||
517 | - // calculate scaled step | ||
518 | - mScaledStep = 100 / mDelayResourceValue.numMaxOrdinal(); | ||
519 | - mDelayFormat = "%.1f"; | ||
520 | - | ||
521 | - mDelayTextView = (TextView) findViewById(R.id.delay); | ||
522 | - mDelayTextView.setRawInputType(InputType.TYPE_CLASS_NUMBER); | ||
523 | - mSlider = (SeekBar) findViewById(R.id.slider); | ||
524 | - | ||
525 | - // initializeEmmoco slider listener | ||
526 | - mSlider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | ||
527 | - | ||
528 | - public void onStopTrackingTouch(SeekBar seekBar) { | ||
529 | - // they took their finger off the bar, so write to the device | ||
530 | - Double delay = Double.parseDouble(mDelayTextView.getText().toString()); | ||
531 | - mDelayResourceValue.assignNum(delay); | ||
532 | - mTargetConnection.write(mDelayResourceValue, mDelayReactor.event(DelayAction.WRITE_COMPLETE)); | ||
533 | - } | ||
534 | - | ||
535 | - public void onStartTrackingTouch(SeekBar seekBar) { | ||
536 | - } | ||
537 | - | ||
538 | - public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | ||
539 | - long ord = progress / mScaledStep; | ||
540 | - mDelayResourceValue.assignNum(ord); | ||
541 | - mDelayTextView.setText(String.format(mDelayFormat, mDelayResourceValue.toDouble())); | ||
542 | - } | ||
543 | - }); | ||
544 | - } | ||
545 | - | ||
546 | - | ||
547 | - /** | ||
548 | - * Android UI tweak. | ||
549 | - * Normally a progress dialog disappears when you hit a button (like cancel), but we want our dialog to stick around | ||
550 | - * until our background task has completed the cancellation phase. The easiest way is to override the dismiss() so | ||
551 | - * the dialog does not automatically close | ||
552 | - */ | ||
553 | - private class StickyProgressDialog extends ProgressDialog { | ||
554 | - private StickyProgressDialog(Context context) { | ||
555 | - super(context); | ||
556 | - } | ||
557 | - | ||
558 | - @Override | ||
559 | - public void dismiss() { | ||
560 | - // do nothing | ||
561 | - } | ||
562 | - public void dismissManually() { | ||
563 | - super.dismiss(); | ||
564 | - } | ||
565 | - } | ||
566 | -} | ||
567 | - |
Blinker/src/com/emmoco/example/blinker/SetDeviceActivity.java deleted
1 | -package com.emmoco.example.blinker; | ||
2 | - | ||
3 | -import android.app.Activity; | ||
4 | -import android.content.Intent; | ||
5 | -import android.content.SharedPreferences; | ||
6 | -import android.os.Bundle; | ||
7 | -import android.preference.PreferenceManager; | ||
8 | -import android.view.LayoutInflater; | ||
9 | -import android.view.View; | ||
10 | -import android.view.ViewGroup; | ||
11 | -import android.widget.AdapterView; | ||
12 | -import android.widget.BaseAdapter; | ||
13 | -import android.widget.ListView; | ||
14 | -import android.widget.TextView; | ||
15 | -import com.emmoco.android.TargetConnection; | ||
16 | - | ||
17 | -import java.util.ArrayList; | ||
18 | - | ||
19 | -/** | ||
20 | - * This activity manages a screen where the user can choose from a list of target devices. These devices include | ||
21 | - * the Bluetooth paired devices and the Emmoco mock devices used for testing. | ||
22 | - * | ||
23 | - * This activity maintains a simple listview. There is an option to jump to the Settings->Bluetooth-Scan activity | ||
24 | - * When this activity returns, it refreshes the paired bluetooth device list in case it has changed | ||
25 | - * | ||
26 | - * This uses a custom Listview Adapter to show a checkmark next to the currently saved device | ||
27 | - * | ||
28 | - * The devices is stored using standard Android SharedPreferences | ||
29 | - * | ||
30 | - */ | ||
31 | -public class SetDeviceActivity extends Activity{ | ||
32 | - final static private String TAG="SetDeviceActivity"; | ||
33 | - | ||
34 | - private String mCurrentDevice; | ||
35 | - private ListView mDeviceList; | ||
36 | - private DeviceArrayAdapter mAdapter; | ||
37 | - | ||
38 | - final public static String PREF_DEVICE_NAME = "DEVICE"; | ||
39 | - final public static String MOCK_DEVICE_LABEL = "Mock Blinker Device"; | ||
40 | - | ||
41 | - | ||
42 | - /** | ||
43 | - * Internal class that adapts our array of device strings to a listview. Current choice is highlighted with | ||
44 | - * a checkmark | ||
45 | - */ | ||
46 | - private class DeviceArrayAdapter extends BaseAdapter { | ||
47 | - | ||
48 | - ArrayList<String> mList; | ||
49 | - Activity mContext; | ||
50 | - | ||
51 | - DeviceArrayAdapter(Activity context, ArrayList<String> arrayList) { | ||
52 | - mList = arrayList; | ||
53 | - mContext = context; | ||
54 | - } | ||
55 | - | ||
56 | - public int getCount() { | ||
57 | - return mList.size(); | ||
58 | - } | ||
59 | - | ||
60 | - public Object getItem(int i) { | ||
61 | - return mList.get(i); | ||
62 | - } | ||
63 | - | ||
64 | - public long getItemId(int i) { | ||
65 | - return i; | ||
66 | - } | ||
67 | - | ||
68 | - /** | ||
69 | - * Returns a new view constructed from a simple layout. The layout has a textview for the name of the device | ||
70 | - * and a checkmark graphic that is visible or not. | ||
71 | - * | ||
72 | - * @param i | ||
73 | - * @param view | ||
74 | - * @param viewGroup | ||
75 | - * @return | ||
76 | - */ | ||
77 | - public View getView(int i, View view, ViewGroup viewGroup) { | ||
78 | - LayoutInflater inflator = mContext.getLayoutInflater(); | ||
79 | - view = inflator.inflate(R.layout.list_item, null); | ||
80 | - | ||
81 | - String name = (String)getItem(i); | ||
82 | - String label = name; | ||
83 | - | ||
84 | - // Translate the URI for the device into a pretty label for display in the listview | ||
85 | - | ||
86 | - // If Mock device, use mock label | ||
87 | - if (name.contentEquals(TargetConnection.MOCK_BLINKER_PRE)){ | ||
88 | - label = MOCK_DEVICE_LABEL; | ||
89 | - } | ||
90 | - if (name.startsWith(TargetConnection.BT_PRE)) { | ||
91 | - // If Bluetooth, remove prefix | ||
92 | - label = name.substring(TargetConnection.BT_PRE.length()); | ||
93 | - } | ||
94 | - | ||
95 | - | ||
96 | - // Set the label in the view | ||
97 | - ((TextView)view.findViewById(R.id.item_label)).setText(label); | ||
98 | - | ||
99 | - // If the current one, show the checkbox | ||
100 | - if (mList.get(i).contentEquals(mCurrentDevice)){ | ||
101 | - view.findViewById(R.id.checkmark).setVisibility(View.VISIBLE); | ||
102 | - }else{ | ||
103 | - view.findViewById(R.id.checkmark).setVisibility(View.INVISIBLE); | ||
104 | - } | ||
105 | - return view; | ||
106 | - } | ||
107 | - | ||
108 | - // Replace the list with a new one and trigger a redraw on the screen | ||
109 | - public void updateList(ArrayList<String> list){ | ||
110 | - mList = list; | ||
111 | - notifyDataSetInvalidated(); | ||
112 | - } | ||
113 | - } | ||
114 | - | ||
115 | - /** | ||
116 | - * Standard Android method called at start of activity. | ||
117 | - * | ||
118 | - * Save the | ||
119 | - * @param savedInstanceState | ||
120 | - */ | ||
121 | - @Override | ||
122 | - protected void onCreate(Bundle savedInstanceState) { | ||
123 | - | ||
124 | - super.onCreate(savedInstanceState); | ||
125 | - setContentView(R.layout.set_device_activity); | ||
126 | - | ||
127 | - | ||
128 | - mDeviceList = (ListView)findViewById(R.id.device_list_view); | ||
129 | - | ||
130 | - mAdapter = new DeviceArrayAdapter(this,TargetConnection.deviceList(true,false)); | ||
131 | - mDeviceList.setAdapter(mAdapter); | ||
132 | - | ||
133 | - // get the device to connect to from the users preferences | ||
134 | - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); | ||
135 | - mCurrentDevice = prefs.getString(PREF_DEVICE_NAME, TargetConnection.MOCK_BLINKER_PRE); | ||
136 | - | ||
137 | - | ||
138 | - // Register a handler when one of the list items is clicked. This handler will set the | ||
139 | - // preference to use the new device, and finish this activity so we go back to the main activity | ||
140 | - mDeviceList.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||
141 | - public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { | ||
142 | - | ||
143 | - String newDeviceName = (String)mAdapter.getItem(i); | ||
144 | - | ||
145 | - // Save changed name to preferences | ||
146 | - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(SetDeviceActivity.this); | ||
147 | - SharedPreferences.Editor edit = prefs.edit(); | ||
148 | - edit.putString(PREF_DEVICE_NAME, newDeviceName); | ||
149 | - edit.commit(); | ||
150 | - | ||
151 | - // Set the result so the calling activity know we have changed the device | ||
152 | - setResult(RESULT_OK); | ||
153 | - finish(); | ||
154 | - } | ||
155 | - } ); | ||
156 | - | ||
157 | - } | ||
158 | - | ||
159 | - @Override | ||
160 | - protected void onResume() { | ||
161 | - // If we are resuming after going to Settings-->Bluetooth, the device list may have changed so update | ||
162 | - mAdapter.updateList(TargetConnection.deviceList(true,false)); | ||
163 | - | ||
164 | - super.onResume(); | ||
165 | - } | ||
166 | - | ||
167 | - | ||
168 | - | ||
169 | - /** | ||
170 | - * Use an intent to call the Android bluetooth settings for scanning bluetooth devices | ||
171 | - * @param v | ||
172 | - */ | ||
173 | - public void onScanDeviceClick(View v) { | ||
174 | - Intent i = new Intent(); | ||
175 | - i.setAction(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS); | ||
176 | - startActivity(i); | ||
177 | - } | ||
178 | - | ||
179 | -} |