diff options
author | Rob Tsuk <robtsuk@google.com> | 2011-05-05 16:39:13 -0700 |
---|---|---|
committer | Erik Gilling <konkers@android.com> | 2011-05-05 16:40:03 -0700 |
commit | b63ed7adbf146a2b7c7c4422c01a5e0ef6bb10ca (patch) | |
tree | 57af569e8351f5b1ea42ebd6b5fde2e0f7e03a0f | |
parent | c3daa854525e8c192b9cc360a0c443f5a9d64949 (diff) | |
download | demokit-b63ed7adbf146a2b7c7c4422c01a5e0ef6bb10ca.tar.gz |
Demokit UI Refresh
Change-Id: I0531d311b4a8812fafc94da363614114f728a0d6
Signed-off-by: Erik Gilling <konkers@android.com>
111 files changed, 1961 insertions, 989 deletions
diff --git a/demokit/app/AndroidManifest.xml b/demokit/app/AndroidManifest.xml index b51b29b..6eac59c 100644 --- a/demokit/app/AndroidManifest.xml +++ b/demokit/app/AndroidManifest.xml @@ -1,50 +1,37 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 The Android Open Source Project - - Licensed 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. ---> - <manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="com.google.android.DemoKit" - android:versionCode="1" - android:versionName="1.0"> - - <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="11" /> - - <application android:label="DemoKit" - android:icon="@drawable/icon" - android:hardwareAccelerated="true"> - <uses-library android:name="com.android.future.usb.accessory" /> - - <activity android:name="DemoKitActivity" - android:label="DemoKit"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.LAUNCHER" /> - </intent-filter> - </activity> - - <!-- This activity receives USB_ACCESSORY_ATTACHED Intents and springboards to main Gallery activity. --> - <activity android:name="UsbAccessoryActivity" android:label="DemoKit" - android:taskAffinity="" - android:launchMode="singleInstance"> - <intent-filter> - <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /> - </intent-filter> - - <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" - android:resource="@xml/accessory_filter" /> - </activity> - - </application> -</manifest> + package="com.google.android.DemoKit" android:versionCode="1" + android:versionName="1.0"> + + <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="11" /> + + <application android:icon="@drawable/ic_launcher_demokit" + android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> + <uses-library android:name="com.android.future.usb.accessory" /> + <activity android:name=".DemoKitLaunch" android:label="@string/app_name"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity android:name=".DemoKitActivity" android:label="@string/app_name" + android:screenOrientation="portrait"> + </activity> + <activity android:name=".DemoKitPhone" android:label="@string/app_name" + android:screenOrientation="portrait"> + </activity> + <activity android:name=".DemoKitTablet" android:label="@string/app_name" + android:screenOrientation="landscape" android:theme="@android:style/Theme.Holo"> + </activity> + <activity android:name="UsbAccessoryActivity" android:label="DemoKit" + android:taskAffinity="" android:launchMode="singleInstance"> + <intent-filter> + <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /> + </intent-filter> + + <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" + android:resource="@xml/accessory_filter" /> + </activity> + + </application> +</manifest>
\ No newline at end of file diff --git a/demokit/app/res/drawable-hdpi/droid_off.png b/demokit/app/res/drawable-hdpi/droid_off.png Binary files differdeleted file mode 100644 index c908bf8..0000000 --- a/demokit/app/res/drawable-hdpi/droid_off.png +++ /dev/null diff --git a/demokit/app/res/drawable-hdpi/droid_on.png b/demokit/app/res/drawable-hdpi/droid_on.png Binary files differdeleted file mode 100644 index 0bd2390..0000000 --- a/demokit/app/res/drawable-hdpi/droid_on.png +++ /dev/null diff --git a/demokit/app/res/drawable-hdpi/greenball.png b/demokit/app/res/drawable-hdpi/greenball.png Binary files differdeleted file mode 100644 index 7851232..0000000 --- a/demokit/app/res/drawable-hdpi/greenball.png +++ /dev/null diff --git a/demokit/app/res/drawable-hdpi/ic_launcher_demokit.png b/demokit/app/res/drawable-hdpi/ic_launcher_demokit.png Binary files differnew file mode 100644 index 0000000..0de0a95 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/ic_launcher_demokit.png diff --git a/demokit/app/res/drawable-hdpi/icon.png b/demokit/app/res/drawable-hdpi/icon.png Binary files differdeleted file mode 100644 index 0496e35..0000000 --- a/demokit/app/res/drawable-hdpi/icon.png +++ /dev/null diff --git a/demokit/app/res/drawable-hdpi/indicator_button1_off_noglow.png b/demokit/app/res/drawable-hdpi/indicator_button1_off_noglow.png Binary files differnew file mode 100644 index 0000000..9cd43ce --- /dev/null +++ b/demokit/app/res/drawable-hdpi/indicator_button1_off_noglow.png diff --git a/demokit/app/res/drawable-hdpi/indicator_button1_on_noglow.png b/demokit/app/res/drawable-hdpi/indicator_button1_on_noglow.png Binary files differnew file mode 100644 index 0000000..d24866f --- /dev/null +++ b/demokit/app/res/drawable-hdpi/indicator_button1_on_noglow.png diff --git a/demokit/app/res/drawable-hdpi/indicator_button2_off_noglow.png b/demokit/app/res/drawable-hdpi/indicator_button2_off_noglow.png Binary files differnew file mode 100644 index 0000000..92f962f --- /dev/null +++ b/demokit/app/res/drawable-hdpi/indicator_button2_off_noglow.png diff --git a/demokit/app/res/drawable-hdpi/indicator_button2_on_noglow.png b/demokit/app/res/drawable-hdpi/indicator_button2_on_noglow.png Binary files differnew file mode 100644 index 0000000..2e24282 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/indicator_button2_on_noglow.png diff --git a/demokit/app/res/drawable-hdpi/indicator_button3_off_noglow.png b/demokit/app/res/drawable-hdpi/indicator_button3_off_noglow.png Binary files differnew file mode 100644 index 0000000..4f9e951 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/indicator_button3_off_noglow.png diff --git a/demokit/app/res/drawable-hdpi/indicator_button3_on_noglow.png b/demokit/app/res/drawable-hdpi/indicator_button3_on_noglow.png Binary files differnew file mode 100644 index 0000000..8cfefe6 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/indicator_button3_on_noglow.png diff --git a/demokit/app/res/drawable-hdpi/indicator_button_capacitive_off_noglow.png b/demokit/app/res/drawable-hdpi/indicator_button_capacitive_off_noglow.png Binary files differnew file mode 100644 index 0000000..ae46086 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/indicator_button_capacitive_off_noglow.png diff --git a/demokit/app/res/drawable-hdpi/indicator_button_capacitive_on_noglow.png b/demokit/app/res/drawable-hdpi/indicator_button_capacitive_on_noglow.png Binary files differnew file mode 100644 index 0000000..7afc536 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/indicator_button_capacitive_on_noglow.png diff --git a/demokit/app/res/drawable-hdpi/joystick_background.png b/demokit/app/res/drawable-hdpi/joystick_background.png Binary files differnew file mode 100644 index 0000000..7349fb7 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/joystick_background.png diff --git a/demokit/app/res/drawable-hdpi/joystick_normal_holo_dark.png b/demokit/app/res/drawable-hdpi/joystick_normal_holo_dark.png Binary files differnew file mode 100644 index 0000000..33796ac --- /dev/null +++ b/demokit/app/res/drawable-hdpi/joystick_normal_holo_dark.png diff --git a/demokit/app/res/drawable-hdpi/joystick_pressed_holo_dark.png b/demokit/app/res/drawable-hdpi/joystick_pressed_holo_dark.png Binary files differnew file mode 100644 index 0000000..4eba4b4 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/joystick_pressed_holo_dark.png diff --git a/demokit/app/res/drawable-hdpi/redball.png b/demokit/app/res/drawable-hdpi/redball.png Binary files differdeleted file mode 100644 index fba2f5d..0000000 --- a/demokit/app/res/drawable-hdpi/redball.png +++ /dev/null diff --git a/demokit/app/res/drawable-hdpi/scrubber_control_holo_dark.png b/demokit/app/res/drawable-hdpi/scrubber_control_holo_dark.png Binary files differnew file mode 100644 index 0000000..5947ee1 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/scrubber_control_holo_dark.png diff --git a/demokit/app/res/drawable-hdpi/scrubber_horizontal_blue_holo_dark.9.png b/demokit/app/res/drawable-hdpi/scrubber_horizontal_blue_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..1dcd3b0 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/scrubber_horizontal_blue_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/scrubber_horizontal_green_holo_dark.9.png b/demokit/app/res/drawable-hdpi/scrubber_horizontal_green_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..6221a0f --- /dev/null +++ b/demokit/app/res/drawable-hdpi/scrubber_horizontal_green_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/scrubber_horizontal_holo_dark.9.png b/demokit/app/res/drawable-hdpi/scrubber_horizontal_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..6a162ed --- /dev/null +++ b/demokit/app/res/drawable-hdpi/scrubber_horizontal_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/scrubber_horizontal_red_holo_dark.9.png b/demokit/app/res/drawable-hdpi/scrubber_horizontal_red_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..b785ebd --- /dev/null +++ b/demokit/app/res/drawable-hdpi/scrubber_horizontal_red_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/scrubber_vertical_blue_holo_dark.9.png b/demokit/app/res/drawable-hdpi/scrubber_vertical_blue_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..5a22af5 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/scrubber_vertical_blue_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/scrubber_vertical_green_holo_dark.9.png b/demokit/app/res/drawable-hdpi/scrubber_vertical_green_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..1ebd9f6 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/scrubber_vertical_green_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/scrubber_vertical_red_holo_dark.9.png b/demokit/app/res/drawable-hdpi/scrubber_vertical_red_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..74800a4 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/scrubber_vertical_red_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/tab_focused_holo_dark.9.png b/demokit/app/res/drawable-hdpi/tab_focused_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..39d0fc1 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/tab_focused_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/tab_normal_holo_dark.9.png b/demokit/app/res/drawable-hdpi/tab_normal_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..bf001cf --- /dev/null +++ b/demokit/app/res/drawable-hdpi/tab_normal_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/tab_touched_holo_dark.9.png b/demokit/app/res/drawable-hdpi/tab_touched_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..4c31e32 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/tab_touched_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/toggle_button_off_holo_dark.9.png b/demokit/app/res/drawable-hdpi/toggle_button_off_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..52f172c --- /dev/null +++ b/demokit/app/res/drawable-hdpi/toggle_button_off_holo_dark.9.png diff --git a/demokit/app/res/drawable-hdpi/toggle_button_on_holo_dark.9.png b/demokit/app/res/drawable-hdpi/toggle_button_on_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..404f888 --- /dev/null +++ b/demokit/app/res/drawable-hdpi/toggle_button_on_holo_dark.9.png diff --git a/demokit/app/res/drawable-ldpi/droid_off.png b/demokit/app/res/drawable-ldpi/droid_off.png Binary files differdeleted file mode 100644 index 75a1bf6..0000000 --- a/demokit/app/res/drawable-ldpi/droid_off.png +++ /dev/null diff --git a/demokit/app/res/drawable-ldpi/droid_on.png b/demokit/app/res/drawable-ldpi/droid_on.png Binary files differdeleted file mode 100644 index 41dd449..0000000 --- a/demokit/app/res/drawable-ldpi/droid_on.png +++ /dev/null diff --git a/demokit/app/res/drawable-ldpi/greenball.png b/demokit/app/res/drawable-ldpi/greenball.png Binary files differdeleted file mode 100644 index 3a814fc..0000000 --- a/demokit/app/res/drawable-ldpi/greenball.png +++ /dev/null diff --git a/demokit/app/res/drawable-ldpi/icon.png b/demokit/app/res/drawable-ldpi/icon.png Binary files differdeleted file mode 100644 index ee36e96..0000000 --- a/demokit/app/res/drawable-ldpi/icon.png +++ /dev/null diff --git a/demokit/app/res/drawable-ldpi/redball.png b/demokit/app/res/drawable-ldpi/redball.png Binary files differdeleted file mode 100644 index 6e0add3..0000000 --- a/demokit/app/res/drawable-ldpi/redball.png +++ /dev/null diff --git a/demokit/app/res/drawable-mdpi/droid_off.png b/demokit/app/res/drawable-mdpi/droid_off.png Binary files differdeleted file mode 100644 index e7fcabf..0000000 --- a/demokit/app/res/drawable-mdpi/droid_off.png +++ /dev/null diff --git a/demokit/app/res/drawable-mdpi/droid_on.png b/demokit/app/res/drawable-mdpi/droid_on.png Binary files differdeleted file mode 100644 index 121f517..0000000 --- a/demokit/app/res/drawable-mdpi/droid_on.png +++ /dev/null diff --git a/demokit/app/res/drawable-mdpi/greenball.png b/demokit/app/res/drawable-mdpi/greenball.png Binary files differdeleted file mode 100644 index 7851232..0000000 --- a/demokit/app/res/drawable-mdpi/greenball.png +++ /dev/null diff --git a/demokit/app/res/drawable-mdpi/ic_launcher_demokit.png b/demokit/app/res/drawable-mdpi/ic_launcher_demokit.png Binary files differnew file mode 100644 index 0000000..2111755 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/ic_launcher_demokit.png diff --git a/demokit/app/res/drawable-mdpi/icon.png b/demokit/app/res/drawable-mdpi/icon.png Binary files differdeleted file mode 100644 index b01345c..0000000 --- a/demokit/app/res/drawable-mdpi/icon.png +++ /dev/null diff --git a/demokit/app/res/drawable-mdpi/indicator_button1_off_holo_dark.png b/demokit/app/res/drawable-mdpi/indicator_button1_off_holo_dark.png Binary files differnew file mode 100644 index 0000000..00461f4 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/indicator_button1_off_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/indicator_button1_on_holo_dark.png b/demokit/app/res/drawable-mdpi/indicator_button1_on_holo_dark.png Binary files differnew file mode 100644 index 0000000..387fe91 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/indicator_button1_on_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/indicator_button2_off_holo_dark.png b/demokit/app/res/drawable-mdpi/indicator_button2_off_holo_dark.png Binary files differnew file mode 100644 index 0000000..186627b --- /dev/null +++ b/demokit/app/res/drawable-mdpi/indicator_button2_off_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/indicator_button2_on_holo_dark.png b/demokit/app/res/drawable-mdpi/indicator_button2_on_holo_dark.png Binary files differnew file mode 100644 index 0000000..8ad4d8c --- /dev/null +++ b/demokit/app/res/drawable-mdpi/indicator_button2_on_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/indicator_button3_off_holo_dark.png b/demokit/app/res/drawable-mdpi/indicator_button3_off_holo_dark.png Binary files differnew file mode 100644 index 0000000..e078642 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/indicator_button3_off_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/indicator_button3_on_holo_dark.png b/demokit/app/res/drawable-mdpi/indicator_button3_on_holo_dark.png Binary files differnew file mode 100644 index 0000000..3314451 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/indicator_button3_on_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/indicator_button_capacitive_off_holo_dark.png b/demokit/app/res/drawable-mdpi/indicator_button_capacitive_off_holo_dark.png Binary files differnew file mode 100644 index 0000000..6cde802 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/indicator_button_capacitive_off_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/indicator_button_capacitive_on_holo_dark.png b/demokit/app/res/drawable-mdpi/indicator_button_capacitive_on_holo_dark.png Binary files differnew file mode 100644 index 0000000..e3fea37 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/indicator_button_capacitive_on_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/joystick_background.png b/demokit/app/res/drawable-mdpi/joystick_background.png Binary files differnew file mode 100644 index 0000000..6afdd44 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/joystick_background.png diff --git a/demokit/app/res/drawable-mdpi/joystick_normal_holo_dark.png b/demokit/app/res/drawable-mdpi/joystick_normal_holo_dark.png Binary files differnew file mode 100644 index 0000000..ab72d36 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/joystick_normal_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/joystick_pressed_holo_dark.png b/demokit/app/res/drawable-mdpi/joystick_pressed_holo_dark.png Binary files differnew file mode 100644 index 0000000..c0afa77 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/joystick_pressed_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/redball.png b/demokit/app/res/drawable-mdpi/redball.png Binary files differdeleted file mode 100644 index fba2f5d..0000000 --- a/demokit/app/res/drawable-mdpi/redball.png +++ /dev/null diff --git a/demokit/app/res/drawable-mdpi/scrubber_control_holo_dark.png b/demokit/app/res/drawable-mdpi/scrubber_control_holo_dark.png Binary files differnew file mode 100644 index 0000000..90ece2a --- /dev/null +++ b/demokit/app/res/drawable-mdpi/scrubber_control_holo_dark.png diff --git a/demokit/app/res/drawable-mdpi/scrubber_horizontal_blue_holo_dark.9.png b/demokit/app/res/drawable-mdpi/scrubber_horizontal_blue_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..3a7665b --- /dev/null +++ b/demokit/app/res/drawable-mdpi/scrubber_horizontal_blue_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/scrubber_horizontal_green_holo_dark.9.png b/demokit/app/res/drawable-mdpi/scrubber_horizontal_green_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..dac988a --- /dev/null +++ b/demokit/app/res/drawable-mdpi/scrubber_horizontal_green_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/scrubber_horizontal_holo_dark.9.png b/demokit/app/res/drawable-mdpi/scrubber_horizontal_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..ce62fbe --- /dev/null +++ b/demokit/app/res/drawable-mdpi/scrubber_horizontal_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/scrubber_horizontal_red_holo_dark.9.png b/demokit/app/res/drawable-mdpi/scrubber_horizontal_red_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..bd349fd --- /dev/null +++ b/demokit/app/res/drawable-mdpi/scrubber_horizontal_red_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/scrubber_vertical_blue_holo_dark.9.png b/demokit/app/res/drawable-mdpi/scrubber_vertical_blue_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..fd9ca52 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/scrubber_vertical_blue_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/scrubber_vertical_green_holo_dark.9.png b/demokit/app/res/drawable-mdpi/scrubber_vertical_green_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..f5cc83e --- /dev/null +++ b/demokit/app/res/drawable-mdpi/scrubber_vertical_green_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/scrubber_vertical_red_holo_dark.9.png b/demokit/app/res/drawable-mdpi/scrubber_vertical_red_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..26eaa3d --- /dev/null +++ b/demokit/app/res/drawable-mdpi/scrubber_vertical_red_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/tab_focused_holo_dark.9.png b/demokit/app/res/drawable-mdpi/tab_focused_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..155d0e4 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/tab_focused_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/tab_normal_holo_dark.9.png b/demokit/app/res/drawable-mdpi/tab_normal_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..380ffbb --- /dev/null +++ b/demokit/app/res/drawable-mdpi/tab_normal_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/toggle_button_off_holo_dark.9.png b/demokit/app/res/drawable-mdpi/toggle_button_off_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..8cde52c --- /dev/null +++ b/demokit/app/res/drawable-mdpi/toggle_button_off_holo_dark.9.png diff --git a/demokit/app/res/drawable-mdpi/toggle_button_on_holo_dark.9.png b/demokit/app/res/drawable-mdpi/toggle_button_on_holo_dark.9.png Binary files differnew file mode 100644 index 0000000..8ed6cf7 --- /dev/null +++ b/demokit/app/res/drawable-mdpi/toggle_button_on_holo_dark.9.png diff --git a/demokit/app/res/drawable-nodpi/background_holo_dark.jpg b/demokit/app/res/drawable-nodpi/background_holo_dark.jpg Binary files differnew file mode 100644 index 0000000..97eed62 --- /dev/null +++ b/demokit/app/res/drawable-nodpi/background_holo_dark.jpg diff --git a/demokit/app/res/drawable-nodpi/demokit_splash.png b/demokit/app/res/drawable-nodpi/demokit_splash.png Binary files differnew file mode 100644 index 0000000..1dbd8e3 --- /dev/null +++ b/demokit/app/res/drawable-nodpi/demokit_splash.png diff --git a/demokit/app/res/drawable-xlarge-nodpi/background_holo_dark.png b/demokit/app/res/drawable-xlarge-nodpi/background_holo_dark.png Binary files differnew file mode 100644 index 0000000..5d41f1f --- /dev/null +++ b/demokit/app/res/drawable-xlarge-nodpi/background_holo_dark.png diff --git a/demokit/app/res/layout-xlarge-land/main.xml b/demokit/app/res/layout-xlarge-land/main.xml new file mode 100644 index 0000000..4ba5569 --- /dev/null +++ b/demokit/app/res/layout-xlarge-land/main.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" android:layout_width="match_parent" + android:layout_height="match_parent" android:paddingLeft="20dip" + android:paddingBottom="80dip" android:layout_weight="1" android:background="@drawable/background_holo_dark"> + <include layout="@layout/inputcontainer" android:id="@+id/inputContainer" + android:layout_width="400dip" android:layout_height="match_parent" + android:layout_weight="0" android:layout_marginRight = "50dip"/> + <include layout="@layout/output_tablet" android:id="@+id/outputContainer" + android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_weight="1" /> +</LinearLayout> diff --git a/demokit/app/res/layout-xlarge/main.xml b/demokit/app/res/layout-xlarge/main.xml deleted file mode 100644 index 8fdf685..0000000 --- a/demokit/app/res/layout-xlarge/main.xml +++ /dev/null @@ -1,94 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> - <TableLayout android:id="@+id/tableLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:addStatesFromChildren="true"> - <TableRow android:id="@+id/tableRow1" android:layout_width="match_parent" android:layout_gravity="center_vertical" android:orientation="vertical" android:showDividers="beginning|middle|end" android:layout_weight="1" android:layout_height="wrap_content" android:baselineAligned="false" android:gravity="center_vertical" android:layout_marginBottom="8dip"> - <TextView android:id="@+id/textView17" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/buttons" android:layout_marginRight="8dip"></TextView> - <LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:verticalScrollbarPosition="right" android:layout_width="match_parent" android:layout_gravity="fill_horizontal"> - <TextView android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="@string/button1" android:layout_gravity="center_vertical" android:layout_marginRight="8dip"></TextView> - <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/droid_off" android:id="@+id/button1Image"></ImageView> - </LinearLayout> - <LinearLayout android:id="@+id/linearLayout5" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:layout_width="wrap_content" android:id="@+id/textView2" android:layout_height="wrap_content" android:text="@string/button2" android:layout_gravity="center_vertical" android:layout_marginRight="8dip"></TextView> - <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/droid_off" android:id="@+id/button2Image"></ImageView> - </LinearLayout> - <LinearLayout android:id="@+id/linearLayout6" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:layout_width="wrap_content" android:id="@+id/textView3" android:layout_height="wrap_content" android:text="@string/button3" android:layout_gravity="center_vertical" android:layout_marginRight="8dip"></TextView> - <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/droid_off" android:id="@+id/button3Image"></ImageView> - </LinearLayout> - </TableRow> - <TableRow android:id="@+id/tableRow14" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:id="@+id/textView19" android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView> - <TextView android:id="@+id/textView20" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:text="@string/led1"></TextView> - <TextView android:layout_gravity="center_horizontal" android:id="@+id/textView21" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/led2"></TextView> - <TextView android:layout_gravity="center_horizontal" android:id="@+id/textView22" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/led3"></TextView> - </TableRow> - <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow4" android:layout_width="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:layout_marginBottom="8dip"> - <TextView android:id="@+id/textView5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dip" android:text="@string/red"></TextView> - <SeekBar android:layout_height="wrap_content" android:max="255" android:id="@+id/led1Red" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - <SeekBar android:id="@+id/led2Red" android:layout_height="wrap_content" android:max="255" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - <SeekBar android:id="@+id/led3Red" android:layout_height="wrap_content" android:max="255" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - </TableRow> - <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow5" android:layout_width="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:layout_marginBottom="8dip"> - <TextView android:id="@+id/textView6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dip" android:text="@string/green"></TextView> - <SeekBar android:layout_height="wrap_content" android:max="255" android:id="@+id/led1Green" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - <SeekBar android:id="@+id/led2Green" android:layout_height="wrap_content" android:max="255" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - <SeekBar android:id="@+id/led3Green" android:layout_height="wrap_content" android:max="255" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - </TableRow> - <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow6" android:layout_width="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:layout_marginBottom="8dip"> - <TextView android:id="@+id/textView7" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dip" android:text="@string/blue"></TextView> - <SeekBar android:layout_height="wrap_content" android:max="255" android:id="@+id/led1Blue" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - <SeekBar android:id="@+id/led2Blue" android:layout_height="wrap_content" android:max="255" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - <SeekBar android:id="@+id/led3Blue" android:layout_height="wrap_content" android:max="255" android:layout_marginRight="16dip" android:layout_width="250dip"></SeekBar> - </TableRow> - <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow2" android:layout_width="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:layout_marginBottom="8dip"> - <TextView android:id="@+id/textView18" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/relays" android:layout_marginRight="8dip"></TextView> - <LinearLayout android:id="@+id/linearLayout2" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:text="@string/relay1" android:id="@+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dip"></TextView> - <ToggleButton android:text="ToggleButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/relay1Button"></ToggleButton> - </LinearLayout> - <LinearLayout android:id="@+id/linearLayout7" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:layout_width="wrap_content" android:id="@+id/textView14" android:layout_height="wrap_content" android:text="@string/relay2" android:layout_marginRight="8dip"></TextView> - <ToggleButton android:layout_width="wrap_content" android:text="ToggleButton" android:layout_height="wrap_content" android:id="@+id/relay2Button"></ToggleButton> - </LinearLayout> - </TableRow> - <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow3" android:layout_width="match_parent" android:layout_weight="1" android:layout_marginBottom="8dip"> - <TextView android:text="@string/temperature" android:id="@+id/textView15" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dip"></TextView> - <TextView android:id="@+id/temperature" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> - </TableRow> - <TableRow android:layout_height="wrap_content" android:id="@+id/tableRow13" android:layout_width="match_parent" android:layout_weight="1" android:layout_marginBottom="8dip"> - <TextView android:text="@string/light" android:id="@+id/textView16" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="8dip"></TextView> - <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/light"></TextView> - </TableRow> - <TableRow android:id="@+id/tableRow7" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:layout_marginRight="8dip" android:id="@+id/textView8" android:layout_width="wrap_content" android:text="@string/servos" android:layout_height="wrap_content"></TextView> - <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="8dip" android:id="@+id/servo1" android:max="255" android:progress="127"></SeekBar> - <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="8dip" android:id="@+id/servo2" android:max="255" android:progress="127"></SeekBar> - <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="8dip" android:id="@+id/servo3" android:max="255" android:progress="127"></SeekBar> - </TableRow> - <TableRow android:layout_width="match_parent" android:id="@+id/tableRow8" android:layout_height="wrap_content"> - <TextView android:id="@+id/textView9" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/joystick"></TextView> - <LinearLayout android:id="@+id/linearLayout3" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:layout_width="wrap_content" android:id="@+id/textView10" android:layout_height="wrap_content" android:text="@string/x" android:layout_marginRight="8dip"></TextView> - <TextView android:layout_width="wrap_content" android:id="@+id/joyX" android:layout_height="wrap_content"></TextView> - </LinearLayout> - <LinearLayout android:id="@+id/linearLayout4" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:layout_width="wrap_content" android:id="@+id/textView12" android:layout_height="wrap_content" android:text="@string/y" android:layout_marginRight="8dip"></TextView> - <TextView android:layout_width="wrap_content" android:id="@+id/joyY" android:layout_height="wrap_content"></TextView> - </LinearLayout> - <LinearLayout android:id="@+id/linearLayout5" android:layout_width="wrap_content" android:layout_height="wrap_content"> - <TextView android:layout_width="wrap_content" android:id="@+id/textViewJoyButton" android:layout_height="wrap_content" android:text="@string/button" android:layout_marginRight="8dip"></TextView> - <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/droid_off" android:id="@+id/joyButtonImage"></ImageView> - </LinearLayout> - - - </TableRow> - <TableRow android:layout_width="match_parent" android:id="@+id/tableRow9" android:layout_height="wrap_content"> - <TextView android:id="@+id/textView11" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:text="@string/cap"></TextView> - <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="left" android:src="@drawable/droid_off" android:id="@+id/cap"></ImageView> - </TableRow> - </TableLayout> - -</LinearLayout> diff --git a/demokit/app/res/layout/buttoncontainer.xml b/demokit/app/res/layout/buttoncontainer.xml new file mode 100644 index 0000000..117ee2b --- /dev/null +++ b/demokit/app/res/layout/buttoncontainer.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ButtonContainer" + android:paddingLeft="5dip" android:layout_width="fill_parent" + android:orientation="vertical" android:layout_height="wrap_content" > + <TextView android:text="Buttons" android:id="@+id/lightPercentValue" + style="@style/DemoKitControlLabel" android:layout_weight="1" + android:layout_height="wrap_content" android:layout_width="wrap_content" + android:gravity="center|top"></TextView> + <LinearLayout android:id="@+id/ButtonContainer" + android:layout_width="fill_parent" android:orientation="horizontal" + android:layout_weight="1" android:layout_marginTop="5dip" + android:layout_height="wrap_content" android:layout_gravity="center_vertical"> + <ImageButton android:background="@null" android:id="@+id/Button1" + style="@style/DemoKitButtonDisplay" android:src="@drawable/indicator_button1_off_noglow"></ImageButton> + <ImageButton android:background="@null" android:id="@+id/Button2" + style="@style/DemoKitButtonDisplay" android:src="@drawable/indicator_button2_off_noglow"></ImageButton> + <ImageButton android:background="@null" android:id="@+id/Button3" + style="@style/DemoKitButtonDisplay" android:src="@drawable/indicator_button3_off_noglow"></ImageButton> + <ImageButton android:background="@null" android:id="@+id/Button4" + style="@style/DemoKitButtonDisplay" android:src="@drawable/indicator_button_capacitive_off_noglow"></ImageButton> + </LinearLayout> +</LinearLayout> + diff --git a/demokit/app/res/layout/color_sliders.xml b/demokit/app/res/layout/color_sliders.xml new file mode 100644 index 0000000..0eb670c --- /dev/null +++ b/demokit/app/res/layout/color_sliders.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:orientation="vertical" android:padding="0dip" + android:layout_margin="0dip"> + <include layout="@layout/led_slider" android:layout_width="match_parent" android:layout_height="wrap_content"/> + <include layout="@layout/led_slider" android:layout_width="match_parent" android:layout_height="wrap_content"/> + <include layout="@layout/led_slider" android:layout_width="match_parent" android:layout_height="wrap_content"/> +</LinearLayout>
\ No newline at end of file diff --git a/demokit/app/res/layout/inputcontainer.xml b/demokit/app/res/layout/inputcontainer.xml new file mode 100644 index 0000000..2c2f18f --- /dev/null +++ b/demokit/app/res/layout/inputcontainer.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:layout_height="match_parent" + android:orientation="vertical" android:weightSum="2"> + <include layout="@layout/templightcontainer" android:id="@+id/TempLightContainer_ref" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="1" /> + <include layout="@layout/buttoncontainer" android:id="@+id/ButtonContainer_ref" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="1" /> + <include layout="@layout/joycontainer" android:id="@+id/JoyContainer_ref" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="0" /> +</LinearLayout> + diff --git a/demokit/app/res/layout/joycontainer.xml b/demokit/app/res/layout/joycontainer.xml new file mode 100644 index 0000000..ff35579 --- /dev/null +++ b/demokit/app/res/layout/joycontainer.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/JoyContainer" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_height="wrap_content" android:paddingLeft="5dip"> + <TextView android:text="Joystick" android:id="@+id/joystickLabel" + android:layout_width="wrap_content" android:layout_height="fill_parent" + style="@style/DemoKitControlLabel" android:gravity="center" + android:layout_marginTop="10dp" android:layout_marginBottom="-40dp"></TextView> + <com.google.android.DemoKit.JoystickView + android:id="@+id/joystickView" android:layout_height="wrap_content" + android:src="@drawable/joystick_background" android:layout_width="match_parent" + android:layout_gravity="center_horizontal|bottom"></com.google.android.DemoKit.JoystickView> +</LinearLayout> + diff --git a/demokit/app/res/layout/led_slider.xml b/demokit/app/res/layout/led_slider.xml new file mode 100644 index 0000000..77eed2b --- /dev/null +++ b/demokit/app/res/layout/led_slider.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:orientation="horizontal" android:layout_weight="1"> + <TextView android:text="@string/ledLabel" style="@style/DemoKitLEDText" + android:layout_gravity="left|center_vertical" android:layout_width="40dip" android:clickable="true"/> + <com.google.android.DemoKit.Slider + android:layout_height="wrap_content" android:layout_width="wrap_content" + android:layout_weight="1"></com.google.android.DemoKit.Slider> + <TextView android:text="155" style="@style/DemoKitLEDText" android:layout_width="40dip" + android:layout_gravity="center_vertical|right" android:gravity="right" android:clickable="true"/> +</LinearLayout> + diff --git a/demokit/app/res/layout/leds_tablet.xml b/demokit/app/res/layout/leds_tablet.xml new file mode 100644 index 0000000..f9f6cfb --- /dev/null +++ b/demokit/app/res/layout/leds_tablet.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" + android:orientation="horizontal" android:layout_height="match_parent" android:layout_weight="1"> + <include layout="@layout/vertical_color_sliders" android:id="@+id/leds1" android:layout_weight="1" + android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <include layout="@layout/vertical_color_sliders" android:id="@+id/leds2" android:layout_weight="1" + android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <include layout="@layout/vertical_color_sliders" android:id="@+id/leds3" android:layout_weight="1" + android:layout_width="wrap_content" android:layout_height="wrap_content" /> +</LinearLayout> + diff --git a/demokit/app/res/layout/main.xml b/demokit/app/res/layout/main.xml index 6dbf840..1c52750 100644 --- a/demokit/app/res/layout/main.xml +++ b/demokit/app/res/layout/main.xml @@ -1,297 +1,28 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="match_parent"> - <ScrollView - android:layout_width="match_parent" - android:layout_height="match_parent"> - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="wrap_content"> - <!-- Buttons --> - <TextView - android:id="@+id/textView17" android:layout_alignParentLeft="true" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/buttons" android:layout_marginRight="8dip"/> - <TextView - android:id="@+id/textView1" android:layout_below="@id/textView17" - android:layout_height="wrap_content" android:layout_width="wrap_content" - android:text="@string/button1" android:layout_gravity="center_vertical" - android:layout_marginRight="12dip" android:layout_marginLeft="8dp" - android:paddingTop="30dp" android:layout_marginBottom="5dp"/> - <ImageView - android:id="@+id/button1Image" android:layout_toRightOf="@id/textView1" - android:layout_alignBottom="@id/textView1" - android:layout_marginTop="8dp" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:src="@drawable/droid_off"/> - <TextView - android:id="@+id/textView2" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_toRightOf="@id/button1Image" - android:layout_marginLeft="24dp" android:text="@string/button2" - android:layout_gravity="center_vertical" android:layout_marginRight="12dip" - android:layout_alignBottom="@id/textView1"/> - <ImageView - android:id="@+id/button2Image" android:layout_toRightOf="@id/textView2" - android:layout_alignBottom="@id/textView2" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_marginTop="8dp" - android:src="@drawable/droid_off"/> - <TextView - android:id="@+id/textView3" android:layout_toRightOf="@id/button2Image" - android:layout_marginLeft="24dp" android:layout_alignBottom="@id/textView1" - android:layout_marginRight="12dp" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:text="@string/button3" - android:layout_gravity="center_vertical"/> - <ImageView - android:id="@+id/button3Image" android:layout_toRightOf="@id/textView3" - android:layout_alignBottom="@id/textView3" android:layout_marginTop="8dp" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/droid_off"/> - - <!-- LED 1 --> - <TextView - android:id="@+id/textView20" android:layout_height="wrap_content" - android:layout_width="match_parent" android:layout_gravity="center_horizontal" - android:text="@string/led1" android:layout_below="@id/textView1" - android:paddingTop="30dp"/> - <TextView - android:id="@+id/textView5" android:layout_below="@id/textView20" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="8dip" android:text="@string/red" - android:paddingTop="20dp"/> - <SeekBar - android:id="@+id/led1Red" - android:layout_alignParentRight="true" - android:layout_height="wrap_content" android:layout_alignBottom="@id/textView5" - android:max="255" android:layout_width="250dp" android:layout_marginRight="16dip"/> - <TextView - android:id="@+id/textView6" android:layout_below="@id/textView5" - android:paddingTop="20dp" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="8dip" android:text="@string/green"/> - <SeekBar - android:id="@+id/led1Green" - android:layout_alignParentRight="true" - android:layout_alignBottom="@id/textView6" android:layout_height="wrap_content" - android:max="255" android:layout_marginRight="16dip" - android:layout_width="250dip"/> - <TextView - android:id="@+id/textView7" android:layout_below="@id/textView6" - android:paddingTop="20dp" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="8dip" android:text="@string/blue"/> - <SeekBar - android:id="@+id/led1Blue" android:layout_alignParentRight="true" - android:layout_height="wrap_content" android:max="255" - android:layout_marginRight="16dip" android:layout_width="250dip" - android:layout_alignBottom="@id/textView7"/> - - <!-- LED 2 --> - <TextView - android:id="@+id/textView21" android:layout_height="wrap_content" - android:layout_width="match_parent" android:layout_gravity="center_horizontal" - android:text="@string/led2" android:layout_below="@id/led1Blue" - android:paddingTop="30dp"/> - <TextView - android:id="@+id/textView5_2" android:layout_below="@id/textView21" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="8dip" android:text="@string/red" - android:paddingTop="20dp"/> - <SeekBar - android:id="@+id/led2Red" android:layout_alignParentRight="true" - android:layout_height="wrap_content" android:layout_alignBottom="@id/textView5_2" - android:max="255" android:layout_width="250dp" android:layout_marginRight="16dip"/> - <TextView - android:id="@+id/textView6_2" android:layout_below="@id/textView5_2" - android:paddingTop="20dp" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_marginRight="8dip" - android:text="@string/green"/> - <SeekBar - android:id="@+id/led2Green" android:layout_alignParentRight="true" - android:layout_alignBottom="@id/textView6_2" android:layout_height="wrap_content" - android:max="255" android:layout_marginRight="16dip" - android:layout_width="250dip"/> - <TextView - android:id="@+id/textView7_2" android:layout_below="@id/textView6_2" - android:paddingTop="20dp" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_marginRight="8dip" - android:text="@string/blue"/> - <SeekBar - android:id="@+id/led2Blue" android:layout_alignParentRight="true" - android:layout_height="wrap_content" android:max="255" - android:layout_marginRight="16dip" android:layout_width="250dip" - android:layout_alignBottom="@id/textView7_2"/> - - <!-- LED 3 --> - <TextView - android:id="@+id/textView22" android:layout_height="wrap_content" - android:layout_width="match_parent" android:layout_gravity="center_horizontal" - android:text="@string/led3" android:layout_below="@id/led2Blue" - android:paddingTop="30dp"/> - <TextView - android:id="@+id/textView5_3" android:layout_below="@id/textView22" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="8dip" android:text="@string/red" - android:paddingTop="20dp"/> - <SeekBar - android:id="@+id/led3Red" android:layout_alignParentRight="true" - android:layout_height="wrap_content" android:layout_alignBottom="@id/textView5_3" - android:max="255" android:layout_width="250dp" android:layout_marginRight="16dip"/> - <TextView - android:id="@+id/textView6_3" android:layout_below="@id/textView5_3" - android:paddingTop="20dp" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_marginRight="8dip" - android:text="@string/green"/> - <SeekBar - android:id="@+id/led3Green" android:layout_alignParentRight="true" - android:layout_alignBottom="@id/textView6_3" android:layout_height="wrap_content" - android:max="255" android:layout_marginRight="16dip" - android:layout_width="250dip"/> - <TextView - android:id="@+id/textView7_3" android:layout_below="@id/textView6_3" - android:paddingTop="20dp" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_marginRight="8dip" - android:text="@string/blue"/> - <SeekBar - android:id="@+id/led3Blue" android:layout_alignParentRight="true" - android:layout_height="wrap_content" android:max="255" - android:layout_marginRight="16dip" android:layout_width="250dip" - android:layout_alignBottom="@id/textView7_3"/> - - <!-- Relays --> - <TextView - android:id="@+id/textView18" android:layout_below="@id/led3Blue" - android:paddingTop="60dp" android:layout_alignParentLeft="true" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/relays" android:layout_marginRight="8dip"/> - <ToggleButton - android:id="@+id/relay1Button" android:text="ToggleButton" - android:layout_toRightOf="@id/textView18" - android:layout_alignBottom="@id/textView18" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_marginLeft="12dp"/> - <TextView - android:id="@+id/textView4" android:layout_below="@id/relay1Button" - android:layout_alignLeft="@id/relay1Button" - android:layout_alignRight="@id/relay1Button" android:text="@string/relay1" - android:layout_width="wrap_content" android:gravity="center_horizontal" - android:layout_marginTop="4dp" android:layout_height="wrap_content"/> - <ToggleButton - android:id="@+id/relay2Button" android:text="ToggleButton" - android:layout_alignBottom="@id/textView18" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="12dp" android:layout_alignParentRight="true"/> - <TextView - android:id="@+id/textView4" android:layout_below="@id/relay2Button" - android:layout_alignLeft="@id/relay2Button" - android:layout_alignRight="@id/relay2Button" android:text="@string/relay2" - android:layout_width="wrap_content" android:gravity="center_horizontal" - android:layout_marginTop="4dp" android:layout_height="wrap_content"/> - - <!-- Temperature --> - <TextView - android:id="@+id/textView15" android:text="@string/temperature" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="8dip" android:layout_below="@id/textView18" - android:paddingTop="50dp" android:layout_alignParentLeft="true"/> - <TextView - android:id="@+id/temperature" android:layout_toRightOf="@id/textView15" - android:layout_alignBottom="@id/textView15" android:layout_width="wrap_content" - android:layout_height="wrap_content"/> - - <!-- Light --> - <TextView - android:id="@+id/light" android:layout_alignParentRight="true" - android:layout_alignBottom="@id/textView15" android:layout_width="50dp" - android:layout_height="wrap_content"/> - <TextView - android:id="@+id/textView16" android:text="@string/light" - android:layout_alignBottom="@id/light" android:layout_toLeftOf="@id/light" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="8dip"/> - - <!-- Servos --> - <TextView - android:id="@+id/textView8" android:layout_height="wrap_content" - android:layout_width="match_parent" android:layout_gravity="center_horizontal" - android:text="@string/servos" android:layout_below="@id/textView15" - android:paddingTop="30dp"/> - <TextView - android:id="@+id/servo1Text" android:layout_below="@id/textView8" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginRight="8dip" android:text="@string/servo1" - android:paddingTop="20dp"/> - <SeekBar - android:id="@+id/servo1" android:layout_alignParentRight="true" - android:progress="127" android:layout_height="wrap_content" - android:layout_alignBottom="@id/servo1Text" android:max="255" - android:layout_width="250dp" android:layout_marginRight="16dip"/> - <TextView - android:id="@+id/servo2Text" android:layout_below="@id/servo1Text" - android:paddingTop="20dp" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_marginRight="8dip" - android:text="@string/servo2"/> - <SeekBar - android:id="@+id/servo2" android:layout_alignParentRight="true" - android:progress="127" android:layout_alignBottom="@id/servo2Text" - android:layout_height="wrap_content" android:max="255" - android:layout_marginRight="16dip" android:layout_width="250dip"/> - <TextView - android:id="@+id/servo3Text" android:layout_below="@id/servo2Text" - android:paddingTop="20dp" android:layout_width="wrap_content" - android:layout_height="wrap_content" android:layout_marginRight="8dip" - android:text="@string/servo3"/> - <SeekBar - android:id="@+id/servo3" android:layout_alignParentRight="true" - android:layout_height="wrap_content" android:max="255" - android:layout_marginRight="16dip" android:layout_width="250dip" - android:layout_alignBottom="@id/servo3Text" android:progress="127"/> - - <!-- Joystick --> - <TextView - android:id="@+id/textView9" android:layout_below="@id/servo3Text" - android:padding="30dp" android:text="@string/joystick" - android:layout_width="wrap_content" android:layout_height="wrap_content"/> - <TextView - android:layout_width="wrap_content" android:id="@+id/textView10" - android:layout_height="wrap_content" android:text="@string/x" - android:layout_marginRight="8dip" android:paddingTop="20dp" - android:layout_below="@id/textView9" android:layout_alignParentLeft="true"/> - <TextView - android:layout_width="wrap_content" android:id="@+id/joyX" - android:layout_height="wrap_content" android:layout_toRightOf="@id/textView10" - android:layout_alignBottom="@id/textView10"/> - <TextView - android:layout_width="wrap_content" android:id="@+id/textView12" - android:layout_height="wrap_content" android:text="@string/y" - android:layout_marginRight="8dip" android:paddingTop="20dp" - android:layout_below="@id/textView10" android:layout_alignParentLeft="true"/> - <TextView - android:layout_width="wrap_content" android:id="@+id/joyY" - android:layout_height="wrap_content" android:layout_toRightOf="@id/textView12" - android:layout_alignBottom="@id/textView12"/> - <TextView - android:layout_width="wrap_content" android:id="@+id/textViewJoyButton" - android:layout_height="wrap_content" android:text="@string/button" - android:layout_marginRight="8dip" android:paddingTop="20dp" - android:layout_below="@id/textView12" android:layout_alignParentLeft="true"/> - <ImageView - android:src="@drawable/droid_off" android:id="@+id/joyButtonImage" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toRightOf="@id/textViewJoyButton" - android:layout_alignBottom="@id/textViewJoyButton"/> - - <!-- Touch panel --> - <TextView - android:id="@+id/textView11" android:layout_below="@id/textViewJoyButton" - android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center_vertical" android:text="@string/cap" - android:paddingTop="30dp"/> - <ImageView - android:id="@+id/cap" android:layout_marginLeft="8dp" - android:layout_height="wrap_content" android:layout_width="wrap_content" - android:layout_gravity="left" android:src="@drawable/droid_off" - android:layout_toRightOf="@id/textView11" - android:layout_alignBottom="@id/textView11"/> - </RelativeLayout> - </ScrollView> + android:layout_width="match_parent" android:layout_height="match_parent" + android:orientation="vertical" android:background="@drawable/background_holo_dark"> + <LinearLayout android:id="@+id/InOutTabContainer" + android:layout_width="fill_parent" android:orientation="horizontal" + android:layout_height="48dip"> + <TextView android:layout_width="wrap_content" android:id="@+id/inputLabel" + android:text="@string/input" style="@style/DemoKitTextBase" + android:gravity="center" android:layout_weight="1" + android:background="@drawable/tab_focused_holo_dark" + android:clickable="true" android:layout_gravity="center" + android:layout_height="match_parent"></TextView> + <TextView android:text="@string/output" android:id="@+id/outputLabel" + android:layout_width="wrap_content" android:layout_height="match_parent" + style="@style/DemoKitTextBase" android:gravity="center" + android:layout_weight="1" android:layout_gravity="center" + android:clickable="true"></TextView> + </LinearLayout> + <FrameLayout android:layout_width="match_parent" + android:layout_height="wrap_content" android:orientation="vertical" + android:paddingLeft="10dip" android:paddingRight="10dip"> + <include layout="@layout/inputcontainer" android:id="@+id/inputContainer" + android:layout_width="match_parent" android:layout_height="wrap_content" /> + <include layout="@layout/outputcontainer" android:id="@+id/outputContainer" + android:layout_width="match_parent" android:layout_height="wrap_content" /> + </FrameLayout> </LinearLayout> diff --git a/demokit/app/res/layout/no_device.xml b/demokit/app/res/layout/no_device.xml new file mode 100644 index 0000000..b8492d4 --- /dev/null +++ b/demokit/app/res/layout/no_device.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:layout_weight="1" + android:layout_height="fill_parent" android:orientation="vertical" + android:background="@drawable/background_holo_dark" + android:layout_gravity="fill_horizontal"> + <TextView android:layout_width="match_parent" + android:layout_height="wrap_content" android:id="@+id/textView1" + android:layout_weight="1" android:text="@string/no_device" style="@style/DemoKitNoDevice" + android:gravity="center"></TextView> + <ImageView android:id="@+id/imageView1" android:layout_width="match_parent" + android:layout_height="wrap_content" android:layout_gravity="fill_vertical" + android:src="@drawable/demokit_splash" android:layout_weight="1"></ImageView> +</LinearLayout> diff --git a/demokit/app/res/layout/output_tablet.xml b/demokit/app/res/layout/output_tablet.xml new file mode 100644 index 0000000..bca2a7b --- /dev/null +++ b/demokit/app/res/layout/output_tablet.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:orientation="vertical" android:layout_weight="1"> + <include layout="@layout/servo_tablet" android:id="@+id/servo_tablet" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="0" android:layout_gravity="center_vertical" /> + <include layout="@layout/relay_tablet" android:layout_width="fill_parent" android:layout_weight="0" + android:layout_height="wrap_content" /> + <include layout="@layout/leds_tablet" android:layout_width="match_parent" android:layout_weight="1" + android:layout_height="wrap_content" /> +</LinearLayout> + diff --git a/demokit/app/res/layout/outputcontainer.xml b/demokit/app/res/layout/outputcontainer.xml new file mode 100644 index 0000000..95b8b77 --- /dev/null +++ b/demokit/app/res/layout/outputcontainer.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:orientation="vertical" > + <include layout="@layout/servorelay" android:id="@+id/servoRelay_ref" + android:layout_height="wrap_content" /> + <include layout="@layout/color_sliders" android:id="@+id/leds1" + android:layout_width="match_parent" android:layout_height="wrap_content" /> + <include layout="@layout/color_sliders" android:id="@+id/leds2" + android:layout_width="match_parent" android:layout_height="wrap_content" /> + <include layout="@layout/color_sliders" android:id="@+id/leds3" + android:layout_width="match_parent" android:layout_height="wrap_content" /> +</LinearLayout> + diff --git a/demokit/app/res/layout/relay_tablet.xml b/demokit/app/res/layout/relay_tablet.xml new file mode 100644 index 0000000..18f229b --- /dev/null +++ b/demokit/app/res/layout/relay_tablet.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" + android:orientation="horizontal" android:layout_height="wrap_content"> + <include android:id="@+id/relay1" layout="@layout/relaybutton" + android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <include android:id="@+id/relay2" layout="@layout/relaybutton" + android:layout_width="wrap_content" android:layout_height="wrap_content" /> +</LinearLayout> + diff --git a/demokit/app/res/layout/relaybutton.xml b/demokit/app/res/layout/relaybutton.xml new file mode 100644 index 0000000..f6b8584 --- /dev/null +++ b/demokit/app/res/layout/relaybutton.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_height="wrap_content" android:orientation="vertical" + android:layout_width="wrap_content" android:layout_marginTop="-10dip"> + <TextView android:text="@string/relay1Label" style="@style/DemoKitControlLabel" + android:layout_width="match_parent" android:gravity="left" + android:layout_height="wrap_content"></TextView> + <ToggleButton style="@style/DemoKitRelayButton" + android:textOff="@string/off" android:textOn="@string/on" + android:layout_height="wrap_content" android:layout_width="match_parent"></ToggleButton> +</LinearLayout> + diff --git a/demokit/app/res/layout/servo.xml b/demokit/app/res/layout/servo.xml new file mode 100644 index 0000000..6444773 --- /dev/null +++ b/demokit/app/res/layout/servo.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:orientation="vertical" + android:layout_height="wrap_content"> + <TextView android:layout_height="wrap_content" style="@style/DemoKitControlLabel" + android:layout_width="wrap_content" android:text="@string/servo1Label"></TextView> + <com.google.android.DemoKit.Slider + android:layout_height="wrap_content" android:layout_width="match_parent" + android:layout_marginTop="-7dip"></com.google.android.DemoKit.Slider> +</LinearLayout> + diff --git a/demokit/app/res/layout/servo_tablet.xml b/demokit/app/res/layout/servo_tablet.xml new file mode 100644 index 0000000..23c6ee8 --- /dev/null +++ b/demokit/app/res/layout/servo_tablet.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" android:orientation="horizontal" + android:layout_height="wrap_content" + android:padding="20dip"> + <include layout="@layout/servo" android:id="@+id/servo1" + android:layout_width="fill_parent" android:layout_height="wrap_content" + android:layout_weight="1" /> + <include layout="@layout/servo" android:id="@+id/servo2" + android:layout_weight="1" android:layout_width="fill_parent" + android:layout_height="wrap_content" /> + <include layout="@layout/servo" android:id="@+id/servo3" + android:layout_weight="1" android:layout_width="fill_parent" + android:layout_height="wrap_content" /> +</LinearLayout> + diff --git a/demokit/app/res/layout/servorelay.xml b/demokit/app/res/layout/servorelay.xml new file mode 100644 index 0000000..6225731 --- /dev/null +++ b/demokit/app/res/layout/servorelay.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/servoRelay" android:layout_width="match_parent" + android:orientation="horizontal" android:layout_height="wrap_content"> + <LinearLayout android:layout_width="0dip" + android:layout_height="wrap_content" android:id="@+id/servos" + android:orientation="vertical" android:layout_weight="2"> + <include layout="@layout/servo" android:id="@+id/servo1" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_weight="0.7" /> + <include layout="@layout/servo" android:id="@+id/servo2" + android:layout_width="match_parent" android:layout_height="wrap_content" /> + <include layout="@layout/servo" android:id="@+id/servo3" + android:layout_width="match_parent" android:layout_height="wrap_content" /> + </LinearLayout> + <LinearLayout android:layout_height="wrap_content" + android:id="@+id/relays" android:orientation="vertical" + android:layout_width="0dip" android:layout_weight="1" android:padding="-10dip"> + <include android:id="@+id/relay1" layout="@layout/relaybutton" + android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <include android:id="@+id/relay2" layout="@layout/relaybutton" + android:layout_width="wrap_content" android:layout_height="wrap_content" /> + </LinearLayout> +</LinearLayout> + diff --git a/demokit/app/res/layout/templightcontainer.xml b/demokit/app/res/layout/templightcontainer.xml new file mode 100644 index 0000000..d3a2ba1 --- /dev/null +++ b/demokit/app/res/layout/templightcontainer.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/TempLightContainer" android:layout_width="fill_parent" + android:orientation="horizontal" android:layout_height="wrap_content" + android:paddingLeft="5dip"> + <LinearLayout android:id="@+id/TempContainer" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_weight="1" android:layout_height="wrap_content"> + <TextView android:id="@+id/tempLabel" android:text="Temp" + style="@style/DemoKitControlLabel" android:gravity="center" + android:layout_weight="1"></TextView> + <TextView android:text="45º" android:id="@+id/tempValue" + style="@style/DemoKitMeasurement" android:layout_weight="1"></TextView> + <TextView android:text=" " android:id="@+id/hiddenPercentValue" + style="@style/DemoKitControlLabel" android:gravity="center" + android:layout_weight="1"></TextView> + </LinearLayout> + <LinearLayout android:id="@+id/LightContainer" + android:layout_width="fill_parent" android:orientation="vertical" + android:layout_weight="1" android:layout_height="wrap_content"> + <TextView android:id="@+id/lightPercentLabel" android:text="Light" + style="@style/DemoKitControlLabel" android:gravity="center" + android:layout_weight="1"></TextView> + <LinearLayout android:id="@+id/lightPercentValueContainer" + android:layout_width="fill_parent" android:orientation="horizontal" + android:layout_height="wrap_content"> + <TextView android:text="23" android:id="@+id/lightPercentValue" + style="@style/DemoKitMeasurement"></TextView> + <TextView android:id="@+id/lightPercentSuffix" style="@style/DemoKitMeasurementSuffix" + android:gravity="top" android:text="%"></TextView> + </LinearLayout> + <LinearLayout android:id="@+id/lightRawValueContainer" + android:layout_width="wrap_content" android:orientation="horizontal" + android:layout_height="wrap_content"> + <TextView android:text="200" android:id="@+id/lightRawValue" + style="@style/DemoKitControlLightLowerLabel"></TextView> + <TextView android:text="/1024" + style="@style/DemoKitControlLightLowerLabelConst"></TextView> + </LinearLayout> + </LinearLayout> +</LinearLayout> + diff --git a/demokit/app/res/layout/vertical_color_sliders.xml b/demokit/app/res/layout/vertical_color_sliders.xml new file mode 100644 index 0000000..db65e1e --- /dev/null +++ b/demokit/app/res/layout/vertical_color_sliders.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" android:layout_height="wrap_content" + android:orientation="horizontal" > + <include layout="@layout/vertical_led_slider" + android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginRight="20dip"/> + <include layout="@layout/vertical_led_slider" + android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginRight="20dip"/> + <include layout="@layout/vertical_led_slider" + android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginRight="20dip"/> +</LinearLayout>
\ No newline at end of file diff --git a/demokit/app/res/layout/vertical_led_slider.xml b/demokit/app/res/layout/vertical_led_slider.xml new file mode 100644 index 0000000..a649648 --- /dev/null +++ b/demokit/app/res/layout/vertical_led_slider.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="wrap_content" android:layout_height="match_parent" + android:orientation="vertical" android:layout_weight="1" android:layout_marginRight="30dip" android:paddingRight="20dip"> + <TextView android:text="@string/ledLabel" style="@style/DemoKitLEDText" + android:layout_gravity="center" android:layout_height="20dip" + android:clickable="true" /> + <com.google.android.DemoKit.VerticalSlider + android:layout_height="wrap_content" android:layout_width="wrap_content" + android:layout_weight="1" android:layout_gravity="center"> + </com.google.android.DemoKit.VerticalSlider> + <TextView android:text="155" style="@style/DemoKitLEDText" + android:layout_height="20dip" android:layout_gravity="center" + android:gravity="center" android:clickable="true" /> +</LinearLayout> + diff --git a/demokit/app/res/values/attrs.xml b/demokit/app/res/values/attrs.xml new file mode 100644 index 0000000..eeb5e0a --- /dev/null +++ b/demokit/app/res/values/attrs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <declare-styleable name="com.google.android.DemoKit.Slider"> + <attr name="vertical" format="boolean" /> + </declare-styleable> +</resources> diff --git a/demokit/app/res/values/colors.xml b/demokit/app/res/values/colors.xml new file mode 100644 index 0000000..c6d917f --- /dev/null +++ b/demokit/app/res/values/colors.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <color name="DemoKitTextWhite">#FFF</color> + <color name="DemoKitLabelGray">#666</color> +</resources> diff --git a/demokit/app/res/values/strings.xml b/demokit/app/res/values/strings.xml index 8a5d45d..740b91e 100644 --- a/demokit/app/res/values/strings.xml +++ b/demokit/app/res/values/strings.xml @@ -1,38 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="hello">Hello World, DemoKitActivity!</string> - <string name="app_name">DemoKit</string> - <string name="button">button</string> - <string name="button1">1</string> - <string name="button2">2</string> - <string name="button3">3</string> - <string name="led1Red">Led 1 Red</string> - <string name="led1Green">Led 1 Green</string> - <string name="led1Blue">Led 1 Blue</string> - <string name="led2Red">Led 2 Red</string> - <string name="led2Green">Led 2 Green</string> - <string name="led2Blue">Led 2 Blue</string> - <string name="led3Red">Led 3 Red</string> - <string name="led3Green">Led 3 Green</string> - <string name="led3Blue">Led 3 Blue</string> - <string name="relay1">1</string> - <string name="relay2">2</string> - <string name="temperature">Temperature</string> - <string name="light">Light</string> - <string name="buttons">Buttons</string> - <string name="relays">Relays</string> - <string name="led1">Led 1</string> - <string name="led2">Led 2</string> - <string name="led3">Led 3</string> - <string name="red">Red</string> - <string name="green">Green</string> - <string name="blue">Blue</string> - <string name="servos">Servos</string> - <string name="x">X</string> - <string name="y">Y</string> - <string name="joystick">Joystick</string> - <string name="cap">Cap Button</string> - <string name="servo1">1</string> - <string name="servo2">2</string> - <string name="servo3">3</string> + <string name="app_name">DemoKit</string> + <string name="input">In</string> + <string name="output">Out</string> + <string name="no_device">Please connect a DemoKit board.</string> + <string name="servo1Label">Servo<sub>1</sub></string> + <string name="ledLabel">LED<sub>1</sub></string> + <string name="relay1Label">Relay<sub>1</sub></string> + <string name="relay2Label">Relay<sub>2</sub></string> + <string name="off">Off</string> + <string name="on">On</string> </resources> diff --git a/demokit/app/res/values/styles.xml b/demokit/app/res/values/styles.xml new file mode 100644 index 0000000..d2f68c7 --- /dev/null +++ b/demokit/app/res/values/styles.xml @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <style name="DemoKitTextBase" parent="@android:style/TextAppearance.Medium"> + <item name="android:layout_height">wrap_content</item> + <item name="android:layout_width">wrap_content</item> + <item name="android:typeface">sans</item> + <item name="android:textSize">24dip</item> + <item name="android:textColor">@color/DemoKitTextWhite</item> + <item name="android:background">@null</item> + <item name="android:includeFontPadding">false</item> + </style> + <style name="DemoKitControlLabel" parent="@style/DemoKitTextBase"> + <item name="android:textSize">15dip</item> + <item name="android:textColor">@color/DemoKitLabelGray</item> + <item name="android:includeFontPadding">true</item> + <item name="android:layout_height">25dip</item> + <item name="android:lineSpacingExtra">2dip</item> + </style> + <style name="DemoKitControlLightLowerLabel" parent="@style/DemoKitTextBase"> + <item name="android:layout_marginTop">-2dip</item> + <item name="android:textSize">15dip</item> + <item name="android:textColor">@color/DemoKitTextWhite</item> + </style> + <style name="DemoKitControlLightLowerLabelConst" parent="@style/DemoKitControlLightLowerLabel"> + <item name="android:textColor">@color/DemoKitLabelGray</item> + </style> + <style name="DemoKitMeasurement" parent="@style/DemoKitTextBase"> + <item name="android:textSize">40dip</item> + <item name="android:layout_marginTop">-8dip</item> + <item name="android:layout_marginBottom">0dip</item> + <item name="android:layout_gravity">top</item> + </style> + <style name="DemoKitLEDText" parent="@style/DemoKitControlLabel"> + <item name="android:layout_width">wrap_content</item> + <item name="android:layout_height">wrap_content</item> + </style> + <style name="DemoKitNoDevice" parent="@style/DemoKitTextBase"> + <item name="android:textSize">30dip</item> + </style> + <style name="DemoKitMeasurementSuffix" parent="@style/DemoKitMeasurement"> + <item name="android:textSize">20dip</item> + </style> + <style name="DemoKitButtonDisplay"> + <item name="android:layout_height">wrap_content</item> + <item name="android:layout_width">wrap_content</item> + <item name="android:layout_weight">1</item> + <item name="android:gravity">center_horizontal|bottom</item> + <item name="android:layout_gravity">center</item> + <item name="android:layout_margin">2dip</item> + <item name="android:padding">2dip</item> + </style> + <style name="DemoKitRelayButton" parent="@style/DemoKitTextBase"> + <item name="android:textSize">15dip</item> + <item name="android:layout_marginTop">-10dip</item> + <item name="android:layout_height">70dip</item> + <item name="android:layout_width">fill_parent</item> + <item name="android:textColor">@color/DemoKitTextWhite</item> + <item name="android:gravity">center</item> + <item name="android:background">@drawable/toggle_button_off_holo_dark</item> + </style> +</resources> diff --git a/demokit/app/src/com/google/android/DemoKit/AccessoryController.java b/demokit/app/src/com/google/android/DemoKit/AccessoryController.java new file mode 100644 index 0000000..5f94faa --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/AccessoryController.java @@ -0,0 +1,28 @@ +package com.google.android.DemoKit; + +import android.content.res.Resources; +import android.view.View; + +public abstract class AccessoryController { + + protected DemoKitActivity mHostActivity; + + public AccessoryController(DemoKitActivity activity) { + mHostActivity = activity; + } + + protected View findViewById(int id) { + return mHostActivity.findViewById(id); + } + + protected Resources getResources() { + return mHostActivity.getResources(); + } + + void accessoryAttached() { + onAccesssoryAttached(); + } + + abstract protected void onAccesssoryAttached(); + +}
\ No newline at end of file diff --git a/demokit/app/src/com/google/android/DemoKit/BaseActivity.java b/demokit/app/src/com/google/android/DemoKit/BaseActivity.java new file mode 100644 index 0000000..249ad52 --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/BaseActivity.java @@ -0,0 +1,93 @@ +package com.google.android.DemoKit; + +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; + +public class BaseActivity extends DemoKitActivity { + + private InputController mInputController; + + public BaseActivity() { + super(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (mAccessory != null) { + showControls(); + } else { + hideControls(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + menu.add("Simulate"); + menu.add("Quit"); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getTitle() == "Simulate") { + showControls(); + } else if (item.getTitle() == "Quit") { + finish(); + System.exit(0); + } + return true; + } + + protected void enableControls(boolean enable) { + if (enable) { + showControls(); + } else { + hideControls(); + } + } + + protected void hideControls() { + setContentView(R.layout.no_device); + mInputController = null; + } + + protected void showControls() { + setContentView(R.layout.main); + + mInputController = new InputController(this); + mInputController.accessoryAttached(); + } + + protected void handleJoyMessage(JoyMsg j) { + if (mInputController != null) { + mInputController.joystickMoved(j.getX(), j.getY()); + } + } + + protected void handleLightMessage(LightMsg l) { + if (mInputController != null) { + mInputController.setLightValue(l.getLight()); + } + } + + protected void handleTemperatureMessage(TemperatureMsg t) { + if (mInputController != null) { + mInputController.setTemperature(t.getTemperature()); + } + } + + protected void handleSwitchMessage(SwitchMsg o) { + if (mInputController != null) { + byte sw = o.getSw(); + if (sw >= 0 && sw < 4) { + mInputController.switchStateChanged(sw, o.getState() != 0); + } else if (sw == 4) { + mInputController + .joystickButtonSwitchStateChanged(o.getState() != 0); + } + } + } + +}
\ No newline at end of file diff --git a/demokit/app/src/com/google/android/DemoKit/ColorLEDController.java b/demokit/app/src/com/google/android/DemoKit/ColorLEDController.java new file mode 100644 index 0000000..3bc6e24 --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/ColorLEDController.java @@ -0,0 +1,114 @@ +package com.google.android.DemoKit; + +import com.google.android.DemoKit.Slider.SliderPositionListener; + +import android.content.res.Resources; +import android.graphics.drawable.Drawable; +import android.text.SpannableStringBuilder; +import android.text.style.RelativeSizeSpan; +import android.text.style.SubscriptSpan; +import android.view.View; +import android.view.View.OnClickListener; +import android.view.ViewGroup; +import android.widget.TextView; + +public class ColorLEDController { + private int mLEDNumber; + + private Drawable mGreen; + private Drawable mRed; + private Drawable mBlue; + private DemoKitActivity mActivity; + + class LedValueUpdater implements Slider.SliderPositionListener { + private TextView mTarget; + private final byte mCommandTarget; + + LedValueUpdater(TextView target, int colorIndex) { + mTarget = target; + mCommandTarget = (byte) ((mLEDNumber - 1) * 3 + colorIndex); + } + + public void onPositionChange(double value) { + int v = (int) (255 * value); + mTarget.setText(String.valueOf(v)); + if (mActivity != null) { + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND, + mCommandTarget, (byte) v); + } + } + } + + class LabelClickListener implements OnClickListener { + final private double mValue; + private final Slider mSlider; + + public LabelClickListener(Slider slider, double value) { + mSlider = slider; + mValue = value; + } + + public void onClick(View v) { + mSlider.setPosition(mValue); + } + + } + + public ColorLEDController(DemoKitActivity activity, int number, + Resources res, boolean vertical) { + mActivity = activity; + mLEDNumber = number; + if (vertical) { + mRed = res.getDrawable(R.drawable.scrubber_vertical_red_holo_dark); + mGreen = res + .getDrawable(R.drawable.scrubber_vertical_green_holo_dark); + mBlue = res + .getDrawable(R.drawable.scrubber_vertical_blue_holo_dark); + } else { + mRed = res + .getDrawable(R.drawable.scrubber_horizontal_red_holo_dark); + mGreen = res + .getDrawable(R.drawable.scrubber_horizontal_green_holo_dark); + mBlue = res + .getDrawable(R.drawable.scrubber_horizontal_blue_holo_dark); + } + } + + public void attachToView(ViewGroup targetView) { + for (int i = 0; i < 3; ++i) { + ViewGroup g = (ViewGroup) targetView.getChildAt(i); + TextView label = (TextView) g.getChildAt(0); + Slider slider = (Slider) g.getChildAt(1); + TextView valueText = (TextView) g.getChildAt(2); + SliderPositionListener positionListener = new LedValueUpdater( + valueText, i); + slider.setPositionListener(positionListener); + LabelClickListener leftLabelListener = new LabelClickListener( + slider, 0); + label.setOnClickListener(leftLabelListener); + LabelClickListener rightLabelListener = new LabelClickListener( + slider, 1); + valueText.setOnClickListener(rightLabelListener); + valueText.setText("0"); + if (i == 0) { + String labelText = "Led"; + SpannableStringBuilder ssb = new SpannableStringBuilder( + labelText); + ssb.append(String.valueOf(mLEDNumber)); + int spanStart = labelText.length(); + int spanEnd = spanStart + 1; + ssb.setSpan(new SubscriptSpan(), spanStart, spanEnd, 0); + ssb.setSpan(new RelativeSizeSpan(0.7f), spanStart, spanEnd, 0); + label.setText(ssb); + slider.setSliderBackground(mRed); + } else { + label.setText(""); + if (i == 1) { + slider.setSliderBackground(mGreen); + } else { + slider.setSliderBackground(mBlue); + } + } + } + } +} diff --git a/demokit/app/src/com/google/android/DemoKit/ColorWheel.java b/demokit/app/src/com/google/android/DemoKit/ColorWheel.java new file mode 100644 index 0000000..a1292cc --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/ColorWheel.java @@ -0,0 +1,229 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed 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. + */ + +package com.google.android.DemoKit; + +import android.content.Context; +import android.graphics.*; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; + + +/* This class was masterfully pilfered, Carmen-Sandiego style, from our awesome sample app + * ApiDemos. To see how it looks as a dialog, check out: + * http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/ColorPickerDialog.html + * + */ + + public class ColorWheel extends View { + public interface OnColorChangedListener { + void colorChanged(int color); + } + + /* + */ + + private OnColorChangedListener mListener; + + private int mInitialColor; + + private Paint mPaint; + private Paint mCenterPaint; + private final int[] mColors; + + public void setOnColorChangedListener(OnColorChangedListener l) { + mListener = l; + } + + + public ColorWheel(Context c, AttributeSet attributes) { + + super(c, attributes); + + mColors = new int[] { + 0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00, + 0xFFFFFF00, 0xFFFF0000 + }; + Shader s = new SweepGradient(0, 0, mColors, null); + + mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mPaint.setShader(s); + mPaint.setStyle(Paint.Style.STROKE); + mPaint.setStrokeWidth(32); + + mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mCenterPaint.setColor(0); + mCenterPaint.setStrokeWidth(5); + } + + + + private boolean mTrackingCenter; + private boolean mHighlightCenter; + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + float r = CENTER_X - mPaint.getStrokeWidth()*0.5f; + + canvas.translate(CENTER_X, CENTER_X); + + canvas.drawOval(new RectF(-r, -r, r, r), mPaint); + canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint); + + if (mTrackingCenter) { + int c = mCenterPaint.getColor(); + mCenterPaint.setStyle(Paint.Style.STROKE); + + if (mHighlightCenter) { + mCenterPaint.setAlpha(0xFF); + } else { + mCenterPaint.setAlpha(0x80); + } + canvas.drawCircle(0, 0, + CENTER_RADIUS + mCenterPaint.getStrokeWidth(), + mCenterPaint); + + mCenterPaint.setStyle(Paint.Style.FILL); + mCenterPaint.setColor(c); + } + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + + setMeasuredDimension(CENTER_X*2, CENTER_Y*2); + } + + private static final int CENTER_X = 200; + private static final int CENTER_Y = 200; + private static final int CENTER_RADIUS = 64; + + private int floatToByte(float x) { + int n = java.lang.Math.round(x); + return n; + } + private int pinToByte(int n) { + if (n < 0) { + n = 0; + } else if (n > 255) { + n = 255; + } + return n; + } + + private int ave(int s, int d, float p) { + return s + java.lang.Math.round(p * (d - s)); + } + + private int interpColor(int colors[], float unit) { + if (unit <= 0) { + return colors[0]; + } + if (unit >= 1) { + return colors[colors.length - 1]; + } + + float p = unit * (colors.length - 1); + int i = (int)p; + p -= i; + + // now p is just the fractional part [0...1) and i is the index + int c0 = colors[i]; + int c1 = colors[i+1]; + int a = ave(Color.alpha(c0), Color.alpha(c1), p); + int r = ave(Color.red(c0), Color.red(c1), p); + int g = ave(Color.green(c0), Color.green(c1), p); + int b = ave(Color.blue(c0), Color.blue(c1), p); + + return Color.argb(a, r, g, b); + } + + private int rotateColor(int color, float rad) { + float deg = rad * 180 / 3.1415927f; + int r = Color.red(color); + int g = Color.green(color); + int b = Color.blue(color); + + ColorMatrix cm = new ColorMatrix(); + ColorMatrix tmp = new ColorMatrix(); + + cm.setRGB2YUV(); + tmp.setRotate(0, deg); + cm.postConcat(tmp); + tmp.setYUV2RGB(); + cm.postConcat(tmp); + + final float[] a = cm.getArray(); + + int ir = floatToByte(a[0] * r + a[1] * g + a[2] * b); + int ig = floatToByte(a[5] * r + a[6] * g + a[7] * b); + int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b); + + return Color.argb(Color.alpha(color), pinToByte(ir), + pinToByte(ig), pinToByte(ib)); + } + + private static final float PI = 3.1415926f; + + @Override + public boolean onTouchEvent(MotionEvent event) { + float x = event.getX() - CENTER_X; + float y = event.getY() - CENTER_Y; + boolean inCenter = java.lang.Math.sqrt(x*x + y*y) <= CENTER_RADIUS; + + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + mTrackingCenter = inCenter; + if (inCenter) { + mHighlightCenter = true; + invalidate(); + break; + } + case MotionEvent.ACTION_MOVE: + if (mTrackingCenter) { + if (mHighlightCenter != inCenter) { + mHighlightCenter = inCenter; + invalidate(); + } + } else { + float angle = (float)java.lang.Math.atan2(y, x); + // need to turn angle [-PI ... PI] into unit [0....1] + float unit = angle/(2*PI); + if (unit < 0) { + unit += 1; + } + mCenterPaint.setColor(interpColor(mColors, unit)); + invalidate(); + mListener.colorChanged(mCenterPaint.getColor()); + } + break; + case MotionEvent.ACTION_UP: + if (mTrackingCenter) { + if (inCenter) { + mListener.colorChanged(mCenterPaint.getColor()); + } + mListener.colorChanged(0); + // mListener.colorChanged(mCenterPaint.getColor()); + mTrackingCenter = false; // so we draw w/o halo + invalidate(); + } + break; + } + return true; + } + } diff --git a/demokit/app/src/com/google/android/DemoKit/ColorWheelLEDController.java b/demokit/app/src/com/google/android/DemoKit/ColorWheelLEDController.java new file mode 100644 index 0000000..82b59b1 --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/ColorWheelLEDController.java @@ -0,0 +1,34 @@ +package com.google.android.DemoKit; + +import android.graphics.Color; +import android.text.SpannableStringBuilder; +import android.text.style.RelativeSizeSpan; +import android.text.style.SubscriptSpan; +import android.view.ViewGroup; +import android.widget.TextView; + +public class ColorWheelLEDController implements ColorWheel.OnColorChangedListener { + private DemoKitActivity mActivity; + + public ColorWheelLEDController(DemoKitActivity activity) { + mActivity = activity; + } + + public void colorChanged(int color) { + int red = Color.red(color) / 8; + int green = Color.green(color) / 8; + int blue = Color.blue(color) / 8; + + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)0,(byte)red); + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)1,(byte)green); + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)2,(byte)blue); + + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)3,(byte)red); + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)4,(byte)green); + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)5,(byte)blue); + + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)6,(byte)red); + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)7,(byte)green); + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND,(byte)8,(byte)blue); + } +} diff --git a/demokit/app/src/com/google/android/DemoKit/DemoKitActivity.java b/demokit/app/src/com/google/android/DemoKit/DemoKitActivity.java index d066f8b..3544481 100644 --- a/demokit/app/src/com/google/android/DemoKit/DemoKitActivity.java +++ b/demokit/app/src/com/google/android/DemoKit/DemoKitActivity.java @@ -16,6 +16,11 @@ package com.google.android.DemoKit; +import java.io.FileDescriptor; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + import android.app.Activity; import android.app.PendingIntent; import android.content.BroadcastReceiver; @@ -27,231 +32,141 @@ import android.os.Handler; import android.os.Message; import android.os.ParcelFileDescriptor; import android.util.Log; - -import android.widget.ImageView; -import android.widget.TextView; import android.widget.SeekBar; -import android.widget.ToggleButton; -import android.widget.CompoundButton; -import android.graphics.drawable.Drawable; import com.android.future.usb.UsbAccessory; import com.android.future.usb.UsbManager; -import java.io.FileDescriptor; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; +public class DemoKitActivity extends Activity implements Runnable { + private static final String TAG = "DemoKit"; + + private static final String ACTION_USB_PERMISSION = "com.google.android.DemoKit.action.USB_PERMISSION"; + private UsbManager mUsbManager; + private PendingIntent mPermissionIntent; + private boolean mPermissionRequestPending; -public class DemoKitActivity extends Activity implements Runnable, SeekBar.OnSeekBarChangeListener, CompoundButton.OnCheckedChangeListener { - private static final String TAG = "DemoKit"; + UsbAccessory mAccessory; + ParcelFileDescriptor mFileDescriptor; + FileInputStream mInputStream; + FileOutputStream mOutputStream; - private static final String ACTION_USB_PERMISSION = - "com.google.android.DemoKit.action.USB_PERMISSION"; + private static final int MESSAGE_SWITCH = 1; + private static final int MESSAGE_TEMPERATURE = 2; + private static final int MESSAGE_LIGHT = 3; + private static final int MESSAGE_JOY = 4; - private UsbManager mUsbManager; - private PendingIntent mPermissionIntent; - private boolean mPermissionRequestPending; + public static final byte LED_SERVO_COMMAND = 2; + public static final byte RELAY_COMMAND = 3; - UsbAccessory mAccessory; - ParcelFileDescriptor mFileDescriptor; - FileInputStream mInputStream; - FileOutputStream mOutputStream; + protected class SwitchMsg { + private byte sw; + private byte state; - ImageView mButton1Image; - ImageView mButton2Image; - ImageView mButton3Image; + public SwitchMsg(byte sw, byte state) { + this.sw = sw; + this.state = state; + } + + public byte getSw() { + return sw; + } + + public byte getState() { + return state; + } + } + + protected class TemperatureMsg { + private int temperature; + + public TemperatureMsg(int temperature) { + this.temperature = temperature; + } + + public int getTemperature() { + return temperature; + } + } + + protected class LightMsg { + private int light; + + public LightMsg(int light) { + this.light = light; + } + + public int getLight() { + return light; + } + } + + protected class JoyMsg { + private int x; + private int y; + + public JoyMsg(int x, int y) { + this.x = x; + this.y = y; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + } + + private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (ACTION_USB_PERMISSION.equals(action)) { + synchronized (this) { + UsbAccessory accessory = UsbManager.getAccessory(intent); + if (intent.getBooleanExtra( + UsbManager.EXTRA_PERMISSION_GRANTED, false)) { + openAccessory(accessory); + } else { + Log.d(TAG, "permission denied for accessory " + + accessory); + } + mPermissionRequestPending = false; + } + } else if (UsbManager.ACTION_USB_ACCESSORY_DETACHED.equals(action)) { + UsbAccessory accessory = UsbManager.getAccessory(intent); + if (accessory != null && accessory.equals(mAccessory)) { + closeAccessory(); + } + } + } + }; + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mUsbManager = UsbManager.getInstance(this); + mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent( + ACTION_USB_PERMISSION), 0); + IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); + filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); + registerReceiver(mUsbReceiver, filter); + + if (getLastNonConfigurationInstance() != null) { + mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); + openAccessory(mAccessory); + } + + setContentView(R.layout.main); + + enableControls(false); + } - SeekBar mLed1Red; - SeekBar mLed1Green; - SeekBar mLed1Blue; - SeekBar mLed2Red; - SeekBar mLed2Green; - SeekBar mLed2Blue; - SeekBar mLed3Red; - SeekBar mLed3Green; - SeekBar mLed3Blue; - - ToggleButton mRelay1Button; - ToggleButton mRelay2Button; - - TextView mTemperature; - TextView mLight; - - SeekBar mServo1; - SeekBar mServo2; - SeekBar mServo3; - - TextView mJoyX; - TextView mJoyY; - ImageView mJoyButtonImage; - - - ImageView mCap; - - - Drawable mSwitchOff; - Drawable mSwitchOn; - - private static final int MESSAGE_SWITCH = 1; - private static final int MESSAGE_TEMPERATURE = 2; - private static final int MESSAGE_LIGHT = 3; - private static final int MESSAGE_JOY = 4; - - private class SwitchMsg { - private byte sw; - private byte state; - public SwitchMsg(byte sw, byte state) { - this.sw = sw; - this.state = state; - } - - public byte getSw() { - return sw; - } - - public byte getState() { - return state; - } - } - - private class TemperatureMsg { - private int temperature; - - public TemperatureMsg(int temperature) { - this.temperature = temperature; - } - - public int getTemperature() { - return temperature; - } - } - - private class LightMsg { - private int light; - - public LightMsg(int light) { - this.light = light; - } - - public int getLight() { - return light; - } - } - - private class JoyMsg { - private int x; - private int y; - - public JoyMsg(int x, int y) { - this.x = x; - this.y = y; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - } - - private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (ACTION_USB_PERMISSION.equals(action)) { - synchronized (this) { - UsbAccessory accessory = UsbManager.getAccessory(intent); - if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) { - openAccessory(accessory); - } else { - Log.d(TAG, "permission denied for accessory " + accessory); - } - mPermissionRequestPending = false; - } - } else if (UsbManager.ACTION_USB_ACCESSORY_DETACHED.equals(action)) { - UsbAccessory accessory = UsbManager.getAccessory(intent); - if (accessory != null && accessory.equals(mAccessory)) { - closeAccessory(); - } - } - } - }; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mUsbManager = UsbManager.getInstance(this); - mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); - IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); - filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); - registerReceiver(mUsbReceiver, filter); - - if (getLastNonConfigurationInstance() != null) { - mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); - openAccessory(mAccessory); - } - - setContentView(R.layout.main); - - mButton1Image = (ImageView)findViewById(R.id.button1Image); - mButton2Image = (ImageView)findViewById(R.id.button2Image); - mButton3Image = (ImageView)findViewById(R.id.button3Image); - - mLed1Red = (SeekBar)findViewById(R.id.led1Red); - mLed1Red.setOnSeekBarChangeListener(this); - mLed1Green = (SeekBar)findViewById(R.id.led1Green); - mLed1Green.setOnSeekBarChangeListener(this); - mLed1Blue = (SeekBar)findViewById(R.id.led1Blue); - mLed1Blue.setOnSeekBarChangeListener(this); - - mLed2Red = (SeekBar)findViewById(R.id.led2Red); - mLed2Red.setOnSeekBarChangeListener(this); - mLed2Green = (SeekBar)findViewById(R.id.led2Green); - mLed2Green.setOnSeekBarChangeListener(this); - mLed2Blue = (SeekBar)findViewById(R.id.led2Blue); - mLed2Blue.setOnSeekBarChangeListener(this); - - mLed3Red = (SeekBar)findViewById(R.id.led3Red); - mLed3Red.setOnSeekBarChangeListener(this); - mLed3Green = (SeekBar)findViewById(R.id.led3Green); - mLed3Green.setOnSeekBarChangeListener(this); - mLed3Blue = (SeekBar)findViewById(R.id.led3Blue); - mLed3Blue.setOnSeekBarChangeListener(this); - - mRelay1Button = (ToggleButton)findViewById(R.id.relay1Button); - mRelay1Button.setOnCheckedChangeListener(this); - mRelay2Button = (ToggleButton)findViewById(R.id.relay2Button); - mRelay2Button.setOnCheckedChangeListener(this); - - mTemperature = (TextView)findViewById(R.id.temperature); - mLight = (TextView)findViewById(R.id.light); - - mServo1 = (SeekBar)findViewById(R.id.servo1); - mServo1.setOnSeekBarChangeListener(this); - mServo2 = (SeekBar)findViewById(R.id.servo2); - mServo2.setOnSeekBarChangeListener(this); - mServo3 = (SeekBar)findViewById(R.id.servo3); - mServo3.setOnSeekBarChangeListener(this); - - mJoyX = (TextView)findViewById(R.id.joyX); - mJoyY = (TextView)findViewById(R.id.joyY); - mJoyButtonImage = (ImageView)findViewById(R.id.joyButtonImage); - - mCap = (ImageView)findViewById(R.id.cap); - - mSwitchOff = getResources().getDrawable(R.drawable.droid_off); - mSwitchOn = getResources().getDrawable(R.drawable.droid_on); - - enableControls(false); - } - - @Override + @Override public Object onRetainNonConfigurationInstance() { if (mAccessory != null) { return mAccessory; @@ -261,295 +176,215 @@ public class DemoKitActivity extends Activity implements Runnable, SeekBar.OnSee } @Override - public void onResume() { - super.onResume(); - - Intent intent = getIntent(); - Log.d(TAG, "intent: " + intent); - if (mInputStream != null && mOutputStream != null) { - return; - } - - UsbAccessory[] accessories = mUsbManager.getAccessoryList(); - UsbAccessory accessory = (accessories == null ? null : accessories[0]); - if (accessory != null) { - if (mUsbManager.hasPermission(accessory)) { - openAccessory(accessory); - } else { - synchronized (mUsbReceiver) { - if (!mPermissionRequestPending) { - mUsbManager.requestPermission(accessory, mPermissionIntent); - mPermissionRequestPending = true; - } - } - } - } else { - Log.d(TAG, "mAccessory is null"); - } - } - - @Override - public void onPause() { - super.onPause(); - closeAccessory(); - } - - @Override - public void onDestroy() { - unregisterReceiver(mUsbReceiver); - super.onDestroy(); - } - - private void openAccessory(UsbAccessory accessory) { - Log.d(TAG, "openAccessory: " + accessory); - mFileDescriptor = mUsbManager.openAccessory(accessory); - if (mFileDescriptor != null) { - mAccessory = accessory; - FileDescriptor fd = mFileDescriptor.getFileDescriptor(); - mInputStream = new FileInputStream(fd); - mOutputStream = new FileOutputStream(fd); - Thread thread = new Thread(null, this, "AccessoryChat"); - thread.start(); - Log.d(TAG, "openAccessory succeeded"); - enableControls(true); - } else { - Log.d(TAG, "openAccessory fail"); - } - } - - private void closeAccessory() { - enableControls(false); - - mButton1Image.setImageDrawable(mSwitchOff); - mButton2Image.setImageDrawable(mSwitchOff); - mButton3Image.setImageDrawable(mSwitchOff); - mJoyButtonImage.setImageDrawable(mSwitchOff); - mCap.setImageDrawable(mSwitchOff); - mLed1Red.setProgress(0); - mLed1Green.setProgress(0); - mLed1Blue.setProgress(0); - mLed2Red.setProgress(0); - mLed2Green.setProgress(0); - mLed2Blue.setProgress(0); - mLed3Red.setProgress(0); - mLed3Green.setProgress(0); - mLed3Blue.setProgress(0); - mServo1.setProgress(0); - mServo2.setProgress(0); - mServo3.setProgress(0); - mTemperature.setText(""); - mLight.setText(""); - mJoyX.setText(""); - mJoyY.setText(""); - mRelay1Button.setChecked(false); - mRelay2Button.setChecked(false); - - try { - if (mFileDescriptor != null) { - mFileDescriptor.close(); - } - } catch (IOException e) { - } finally { - mFileDescriptor = null; - mAccessory = null; - } - } - - private void enableControls(boolean enable) { - mLed1Red.setEnabled(enable); - mLed1Green.setEnabled(enable); - mLed1Blue.setEnabled(enable); - mLed2Red.setEnabled(enable); - mLed2Green.setEnabled(enable); - mLed2Blue.setEnabled(enable); - mLed3Red.setEnabled(enable); - mLed3Green.setEnabled(enable); - mLed3Blue.setEnabled(enable); - mServo1.setEnabled(enable); - mServo2.setEnabled(enable); - mServo3.setEnabled(enable); - mRelay1Button.setEnabled(enable); - mRelay2Button.setEnabled(enable); - } - - private int composeInt(byte hi, byte lo) { - int val = (int)hi & 0xff; - val *= 256; - val += (int)lo & 0xff; - return val; - } - - public void run() { - int ret = 0; - byte[] buffer = new byte[16384]; - int i; - - while (ret >= 0) { - try { - ret = mInputStream.read(buffer); - } catch (IOException e) { - break; - } - - Log.d(TAG, "got bytes " + ret); - i = 0; - while (i < ret) { - int len = ret - i; - - switch (buffer[i]) { - case 0x1: - if (len >= 3) { - Message m = Message.obtain(mHandler, MESSAGE_SWITCH); - m.obj = new SwitchMsg(buffer[i+1], buffer[i+2]); - mHandler.sendMessage(m); - } - i += 3; - break; - - case 0x4: - if (len >= 3) { - Message m = Message.obtain(mHandler, MESSAGE_TEMPERATURE); - m.obj = new TemperatureMsg(composeInt(buffer[i+1], buffer[i+2])); - mHandler.sendMessage(m); - } - i += 3; - break; - - case 0x5: - if (len >= 3) { - Message m = Message.obtain(mHandler, MESSAGE_LIGHT); - m.obj = new LightMsg(composeInt(buffer[i+1], buffer[i+2])); - mHandler.sendMessage(m); - } - i += 3; - break; - - case 0x6: - if (len >= 3) { - Message m = Message.obtain(mHandler, MESSAGE_JOY); - m.obj = new JoyMsg(buffer[i+1], buffer[i+2]); - mHandler.sendMessage(m); - } - i += 3; - break; - - default: - Log.d(TAG, "unknown msg: " + buffer[i]); - i = len; - break; - } - } - - } - Log.d(TAG, "thread out"); - } - - Handler mHandler = new Handler() { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case MESSAGE_SWITCH: - SwitchMsg o = (SwitchMsg)msg.obj; - if (o.getSw() == 0) - mButton1Image.setImageDrawable(o.getState() != 0 ? mSwitchOn : mSwitchOff); - else if (o.getSw() == 1) - mButton2Image.setImageDrawable(o.getState() != 0 ? mSwitchOn : mSwitchOff); - else if (o.getSw() == 2) - mButton3Image.setImageDrawable(o.getState() != 0 ? mSwitchOn : mSwitchOff); - else if (o.getSw() == 3) - mCap.setImageDrawable(o.getState() != 0 ? mSwitchOn : mSwitchOff); - else if (o.getSw() == 4) - mJoyButtonImage.setImageDrawable(o.getState() != 0 ? mSwitchOn : mSwitchOff); - break; - - case MESSAGE_TEMPERATURE: - TemperatureMsg t = (TemperatureMsg)msg.obj; - mTemperature.setText(String.format("%04x", t.getTemperature())); - break; - - case MESSAGE_LIGHT: - LightMsg l = (LightMsg)msg.obj; - mLight.setText(String.format("%04x", l.getLight())); - break; - - case MESSAGE_JOY: - JoyMsg j = (JoyMsg)msg.obj; - mJoyX.setText(String.format("%d", j.getX())); - mJoyY.setText(String.format("%d", j.getY())); - break; - - } - } - }; - - public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - byte[] buffer = new byte[3]; - if (progress > 255) - progress = 255; - - buffer[0] = 0x2; - buffer[1] = -1; - buffer[2] = (byte) progress; - - if (seekBar == mLed1Red) - buffer[1] = 0x0; - else if (seekBar == mLed1Green) - buffer[1] = 0x1; - else if (seekBar == mLed1Blue) - buffer[1] = 0x2; - else if (seekBar == mLed2Red) - buffer[1] = 0x3; - else if (seekBar == mLed2Green) - buffer[1] = 0x4; - else if (seekBar == mLed2Blue) - buffer[1] = 0x5; - else if (seekBar == mLed3Red) - buffer[1] = 0x6; - else if (seekBar == mLed3Green) - buffer[1] = 0x7; - else if (seekBar == mLed3Blue) - buffer[1] = 0x8; - else if (seekBar == mServo1) - buffer[1] = 0x10; - else if (seekBar == mServo2) - buffer[1] = 0x11; - else if (seekBar == mServo3) - buffer[1] = 0x12; - - if (mOutputStream != null && buffer[1] != -1) { - try { - mOutputStream.write(buffer); - } catch (IOException e) { - Log.e(TAG, "write failed", e); - } - } - - } - - public void onStartTrackingTouch(SeekBar seekBar) { - } - - public void onStopTrackingTouch(SeekBar seekBar) { - } - - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - byte[] buffer = new byte[3]; - buffer[0] = 0x3; - buffer[1] = -1; - buffer[2] = isChecked ? (byte)0x1 : (byte)0x0; - - if (buttonView == mRelay1Button) - buffer[1] = 0; - else if (buttonView == mRelay2Button) - buffer[1] = 1; - - if (buffer[1] != -1) { - try { - mOutputStream.write(buffer); - } catch (IOException e) { - Log.e(TAG, "write failed", e); - } - } - } -} + public void onResume() { + super.onResume(); + + Intent intent = getIntent(); + Log.d(TAG, "intent: " + intent); + if (mInputStream != null && mOutputStream != null) { + return; + } + + UsbAccessory[] accessories = mUsbManager.getAccessoryList(); + UsbAccessory accessory = (accessories == null ? null : accessories[0]); + if (accessory != null) { + if (mUsbManager.hasPermission(accessory)) { + openAccessory(accessory); + } else { + synchronized (mUsbReceiver) { + if (!mPermissionRequestPending) { + mUsbManager.requestPermission(accessory, + mPermissionIntent); + mPermissionRequestPending = true; + } + } + } + } else { + Log.d(TAG, "mAccessory is null"); + } + } + + @Override + public void onPause() { + super.onPause(); + closeAccessory(); + } + + @Override + public void onDestroy() { + unregisterReceiver(mUsbReceiver); + super.onDestroy(); + } + + private void openAccessory(UsbAccessory accessory) { + Log.d(TAG, "openAccessory: " + accessory); + mFileDescriptor = mUsbManager.openAccessory(accessory); + if (mFileDescriptor != null) { + mAccessory = accessory; + FileDescriptor fd = mFileDescriptor.getFileDescriptor(); + mInputStream = new FileInputStream(fd); + mOutputStream = new FileOutputStream(fd); + Thread thread = new Thread(null, this, "AccessoryChat"); + thread.start(); + Log.d(TAG, "openAccessory succeeded"); + enableControls(true); + } else { + Log.d(TAG, "openAccessory fail"); + } + } + + private void closeAccessory() { + enableControls(false); + + try { + if (mFileDescriptor != null) { + mFileDescriptor.close(); + } + } catch (IOException e) { + } finally { + mFileDescriptor = null; + mAccessory = null; + } + } + + protected void enableControls(boolean enable) { + } + private int composeInt(byte hi, byte lo) { + int val = (int) hi & 0xff; + val *= 256; + val += (int) lo & 0xff; + return val; + } + + public void run() { + int ret = 0; + byte[] buffer = new byte[16384]; + int i; + + while (ret >= 0) { + try { + ret = mInputStream.read(buffer); + } catch (IOException e) { + break; + } + + Log.d(TAG, "got bytes " + ret); + i = 0; + while (i < ret) { + int len = ret - i; + + switch (buffer[i]) { + case 0x1: + if (len >= 3) { + Message m = Message.obtain(mHandler, MESSAGE_SWITCH); + m.obj = new SwitchMsg(buffer[i + 1], buffer[i + 2]); + mHandler.sendMessage(m); + } + i += 3; + break; + + case 0x4: + if (len >= 3) { + Message m = Message.obtain(mHandler, + MESSAGE_TEMPERATURE); + m.obj = new TemperatureMsg(composeInt(buffer[i + 1], + buffer[i + 2])); + mHandler.sendMessage(m); + } + i += 3; + break; + + case 0x5: + if (len >= 3) { + Message m = Message.obtain(mHandler, MESSAGE_LIGHT); + m.obj = new LightMsg(composeInt(buffer[i + 1], + buffer[i + 2])); + mHandler.sendMessage(m); + } + i += 3; + break; + + case 0x6: + if (len >= 3) { + Message m = Message.obtain(mHandler, MESSAGE_JOY); + m.obj = new JoyMsg(buffer[i + 1], buffer[i + 2]); + mHandler.sendMessage(m); + } + i += 3; + break; + + default: + Log.d(TAG, "unknown msg: " + buffer[i]); + i = len; + break; + } + } + + } + Log.d(TAG, "thread out"); + } + + Handler mHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MESSAGE_SWITCH: + SwitchMsg o = (SwitchMsg) msg.obj; + handleSwitchMessage(o); + break; + + case MESSAGE_TEMPERATURE: + TemperatureMsg t = (TemperatureMsg) msg.obj; + handleTemperatureMessage(t); + break; + + case MESSAGE_LIGHT: + LightMsg l = (LightMsg) msg.obj; + handleLightMessage(l); + break; + + case MESSAGE_JOY: + JoyMsg j = (JoyMsg) msg.obj; + handleJoyMessage(j); + break; + + } + } + }; + + public void sendCommand(byte command, byte target, int value) { + byte[] buffer = new byte[3]; + if (value > 255) + value = 255; + + buffer[0] = command; + buffer[1] = target; + buffer[2] = (byte) value; + if (mOutputStream != null && buffer[1] != -1) { + try { + mOutputStream.write(buffer); + } catch (IOException e) { + Log.e(TAG, "write failed", e); + } + } + } + + protected void handleJoyMessage(JoyMsg j) { + } + + protected void handleLightMessage(LightMsg l) { + } + + protected void handleTemperatureMessage(TemperatureMsg t) { + } + + protected void handleSwitchMessage(SwitchMsg o) { + } + + public void onStartTrackingTouch(SeekBar seekBar) { + } + + public void onStopTrackingTouch(SeekBar seekBar) { + } +} diff --git a/demokit/app/src/com/google/android/DemoKit/DemoKitLaunch.java b/demokit/app/src/com/google/android/DemoKit/DemoKitLaunch.java new file mode 100644 index 0000000..a2e2e42 --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/DemoKitLaunch.java @@ -0,0 +1,43 @@ +package com.google.android.DemoKit; + +import android.app.Activity; +import android.content.ActivityNotFoundException; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.Display; + +public class DemoKitLaunch extends Activity { + static final String TAG = "DemoKitLaunch"; + + static Intent createIntent(Activity activity) { + Display display = activity.getWindowManager().getDefaultDisplay(); + int maxExtent = Math.max(display.getWidth(), display.getHeight()); + + Intent intent; + if (maxExtent > 1200) { + Log.i(TAG, "starting tablet ui"); + intent = new Intent(activity, DemoKitTablet.class); + } else { + Log.i(TAG, "starting phone ui"); + intent = new Intent(activity, DemoKitPhone.class); + } + return intent; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = createIntent(this); + + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_CLEAR_TOP); + try { + startActivity(intent); + } catch (ActivityNotFoundException e) { + Log.e(TAG, "unable to start DemoKit activity", e); + } + finish(); + } +} diff --git a/demokit/app/src/com/google/android/DemoKit/DemoKitPhone.java b/demokit/app/src/com/google/android/DemoKit/DemoKitPhone.java new file mode 100644 index 0000000..b429bb3 --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/DemoKitPhone.java @@ -0,0 +1,77 @@ +package com.google.android.DemoKit; + +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.LinearLayout; +import android.widget.TextView; + +public class DemoKitPhone extends BaseActivity implements OnClickListener { + static final String TAG = "DemoKitPhone"; + /** Called when the activity is first created. */ + TextView mInputLabel; + TextView mOutputLabel; + LinearLayout mInputContainer; + LinearLayout mOutputContainer; + Drawable mFocusedTabImage; + Drawable mNormalTabImage; + OutputController mOutputController; + + @Override + protected void hideControls() { + super.hideControls(); + mOutputController = null; + } + + public void onCreate(Bundle savedInstanceState) { + mFocusedTabImage = getResources().getDrawable( + R.drawable.tab_focused_holo_dark); + mNormalTabImage = getResources().getDrawable( + R.drawable.tab_normal_holo_dark); + super.onCreate(savedInstanceState); + } + + protected void showControls() { + super.showControls(); + + mOutputController = new OutputController(this, false); + mOutputController.accessoryAttached(); + mInputLabel = (TextView) findViewById(R.id.inputLabel); + mOutputLabel = (TextView) findViewById(R.id.outputLabel); + mInputContainer = (LinearLayout) findViewById(R.id.inputContainer); + mOutputContainer = (LinearLayout) findViewById(R.id.outputContainer); + mInputLabel.setOnClickListener(this); + mOutputLabel.setOnClickListener(this); + + showTabContents(true); + } + + void showTabContents(Boolean showInput) { + if (showInput) { + mInputContainer.setVisibility(View.VISIBLE); + mInputLabel.setBackgroundDrawable(mFocusedTabImage); + mOutputContainer.setVisibility(View.GONE); + mOutputLabel.setBackgroundDrawable(mNormalTabImage); + } else { + mInputContainer.setVisibility(View.GONE); + mInputLabel.setBackgroundDrawable(mNormalTabImage); + mOutputContainer.setVisibility(View.VISIBLE); + mOutputLabel.setBackgroundDrawable(mFocusedTabImage); + } + } + + public void onClick(View v) { + int vId = v.getId(); + switch (vId) { + case R.id.inputLabel: + showTabContents(true); + break; + + case R.id.outputLabel: + showTabContents(false); + break; + } + } + +}
\ No newline at end of file diff --git a/demokit/app/src/com/google/android/DemoKit/DemoKitTablet.java b/demokit/app/src/com/google/android/DemoKit/DemoKitTablet.java new file mode 100644 index 0000000..8abe51a --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/DemoKitTablet.java @@ -0,0 +1,16 @@ +package com.google.android.DemoKit; + +public class DemoKitTablet extends BaseActivity { + private OutputController mOutputController; + + protected void hideControls() { + super.hideControls(); + mOutputController = null; + } + + protected void showControls() { + super.showControls(); + mOutputController = new OutputController(this, true); + mOutputController.accessoryAttached(); + } +} diff --git a/demokit/app/src/com/google/android/DemoKit/InputController.java b/demokit/app/src/com/google/android/DemoKit/InputController.java new file mode 100644 index 0000000..04624ea --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/InputController.java @@ -0,0 +1,146 @@ +package com.google.android.DemoKit; + +import java.text.DecimalFormat; +import java.util.ArrayList; + +import android.graphics.drawable.Drawable; +import android.widget.ImageView; +import android.widget.TextView; + +public class InputController extends AccessoryController { + private TextView mTemperature; + private TextView mLightView; + private TextView mLightRawView; + private JoystickView mJoystickView; + ArrayList<SwitchDisplayer> mSwitchDisplayers; + private final DecimalFormat mLightValueFormatter = new DecimalFormat("##.#"); + private final DecimalFormat mTemperatureFormatter = new DecimalFormat( + "###¼"); + + InputController(DemoKitActivity hostActivity) { + super(hostActivity); + mTemperature = (TextView) findViewById(R.id.tempValue); + mLightView = (TextView) findViewById(R.id.lightPercentValue); + mLightRawView = (TextView) findViewById(R.id.lightRawValue); + mJoystickView = (JoystickView) findViewById(R.id.joystickView); + } + + protected void onAccesssoryAttached() { + mSwitchDisplayers = new ArrayList<SwitchDisplayer>(); + for (int i = 0; i < 4; ++i) { + SwitchDisplayer sd = new SwitchDisplayer(i); + mSwitchDisplayers.add(sd); + } + } + + public void setTemperature(int temperatureFromArduino) { + /* + * Arduino board contains a 6 channel (8 channels on the Mini and Nano, + * 16 on the Mega), 10-bit analog to digital converter. This means that + * it will map input voltages between 0 and 5 volts into integer values + * between 0 and 1023. This yields a resolution between readings of: 5 + * volts / 1024 units or, .0049 volts (4.9 mV) per unit. + */ + double voltagemv = temperatureFromArduino * 4.9; + /* + * The change in voltage is scaled to a temperature coefficient of 10.0 + * mV/¡C (typical) for the MCP9700/9700A and 19.5 mV/¡C (typical) for + * the MCP9701/9701A. The out- put voltage at 0¡C is also scaled to 500 + * mV (typical) and 400 mV (typical) for the MCP9700/9700A and + * MCP9701/9701A, respectively. VOUT = TC¥TA+V0¡C + */ + double kVoltageAtZeroCmv = 400; + double kTemperatureCoefficientmvperC = 19.5; + double ambientTemperatureC = ((double) voltagemv - kVoltageAtZeroCmv) + / kTemperatureCoefficientmvperC; + double temperatureF = (9.0 / 5.0) * ambientTemperatureC + 32.0; + mTemperature.setText(mTemperatureFormatter.format(temperatureF)); + } + + public void setLightValue(int lightValueFromArduino) { + mLightRawView.setText(String.valueOf(lightValueFromArduino)); + mLightView.setText(mLightValueFormatter + .format((100.0 * (double) lightValueFromArduino / 1024.0))); + } + + public void switchStateChanged(int switchIndex, boolean switchState) { + if (switchIndex >= 0 && switchIndex < mSwitchDisplayers.size()) { + SwitchDisplayer sd = mSwitchDisplayers.get(switchIndex); + sd.onSwitchStateChange(switchState); + } + } + + public void joystickButtonSwitchStateChanged(boolean buttonState) { + mJoystickView.setPressed(buttonState); + } + + public void joystickMoved(int x, int y) { + mJoystickView.setPosition(x, y); + } + + public void onTemperature(int temperature) { + setTemperature(temperature); + } + + public void onLightChange(int lightValue) { + setLightValue(lightValue); + } + + public void onSwitchStateChange(int switchIndex, Boolean switchState) { + switchStateChanged(switchIndex, switchState); + } + + public void onButton(Boolean buttonState) { + joystickButtonSwitchStateChanged(buttonState); + } + + public void onStickMoved(int x, int y) { + joystickMoved(x, y); + } + + class SwitchDisplayer { + private final ImageView mTargetView; + private final Drawable mOnImage; + private final Drawable mOffImage; + + SwitchDisplayer(int switchIndex) { + int viewId, onImageId, offImageId; + switch (switchIndex) { + default: + viewId = R.id.Button1; + onImageId = R.drawable.indicator_button1_on_noglow; + offImageId = R.drawable.indicator_button1_off_noglow; + break; + case 1: + viewId = R.id.Button2; + onImageId = R.drawable.indicator_button2_on_noglow; + offImageId = R.drawable.indicator_button2_off_noglow; + break; + case 2: + viewId = R.id.Button3; + onImageId = R.drawable.indicator_button3_on_noglow; + offImageId = R.drawable.indicator_button3_off_noglow; + break; + case 3: + viewId = R.id.Button4; + onImageId = R.drawable.indicator_button_capacitive_on_noglow; + offImageId = R.drawable.indicator_button_capacitive_off_noglow; + break; + } + mTargetView = (ImageView) findViewById(viewId); + mOffImage = mHostActivity.getResources().getDrawable(offImageId); + mOnImage = mHostActivity.getResources().getDrawable(onImageId); + } + + public void onSwitchStateChange(Boolean switchState) { + Drawable currentImage; + if (!switchState) { + currentImage = mOffImage; + } else { + currentImage = mOnImage; + } + mTargetView.setImageDrawable(currentImage); + } + + } +} diff --git a/demokit/app/src/com/google/android/DemoKit/JoystickView.java b/demokit/app/src/com/google/android/DemoKit/JoystickView.java new file mode 100644 index 0000000..020e276 --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/JoystickView.java @@ -0,0 +1,85 @@ +package com.google.android.DemoKit; + +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.View; + +public class JoystickView extends View { + + private Drawable mJoystickBackground; + private Drawable mJoystickPressed; + private Drawable mJoystickNormal; + + private int fX; + private int fY; + Boolean fPressed; + private Paint mLabelPaint; + private String mLabelText; + + public JoystickView(Context context) { + super(context); + initJoystickView(context); + } + + public JoystickView(Context context, AttributeSet attrs) { + super(context, attrs); + initJoystickView(context); + } + + public void setPosition(int x, int y) { + fX = x; + fY = y; + mLabelText = String.format("%d,%d", fX, fY); + invalidate(); + } + + public void setPressed(boolean pressed) { + fPressed = pressed; + invalidate(); + } + + private void initJoystickView(Context context) { + fX = fY = 0; + fPressed = false; + Resources r = context.getResources(); + mJoystickBackground = r.getDrawable(R.drawable.joystick_background); + int w = mJoystickBackground.getIntrinsicWidth(); + int h = mJoystickBackground.getIntrinsicHeight(); + mJoystickBackground.setBounds(0, 0, w, h); + mJoystickPressed = r.getDrawable(R.drawable.joystick_pressed_holo_dark); + mJoystickNormal = r.getDrawable(R.drawable.joystick_normal_holo_dark); + Utilities.centerAround(w / 2 - 4, h / 2 + 4, mJoystickNormal); + Utilities.centerAround(w / 2 - 4, h / 2 + 4, mJoystickPressed); + mLabelPaint = new Paint(); + mLabelPaint.setColor(Color.WHITE); + mLabelPaint.setTextSize(24); + mLabelPaint.setAntiAlias(true); + mLabelPaint.setShadowLayer(1, 2, 2, Color.BLACK); + setPosition(0, 0); + } + + @Override + protected void onDraw(Canvas canvas) { + mJoystickBackground.draw(canvas); + Drawable indicator = fPressed ? mJoystickPressed : mJoystickNormal; + int w = mJoystickBackground.getIntrinsicWidth(); + int h = mJoystickBackground.getIntrinsicHeight(); + int x = w / 2 - 4 + fX; + int y = h / 2 + 4 + fY; + Utilities.centerAround(x, y, indicator); + indicator.draw(canvas); + canvas.drawText(mLabelText, x + 12, y + 8, mLabelPaint); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + setMeasuredDimension(mJoystickBackground.getIntrinsicWidth(), + mJoystickBackground.getIntrinsicHeight()); + } + +} diff --git a/demokit/app/src/com/google/android/DemoKit/OutputController.java b/demokit/app/src/com/google/android/DemoKit/OutputController.java new file mode 100644 index 0000000..a9842b9 --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/OutputController.java @@ -0,0 +1,44 @@ +package com.google.android.DemoKit; + +import android.view.ViewGroup; + +public class OutputController extends AccessoryController { + + private boolean mVertical; + + OutputController(DemoKitActivity hostActivity, boolean vertical) { + super(hostActivity); + mVertical = vertical; + } + + protected void onAccesssoryAttached() { + setupServoController(1, R.id.servo1); + setupServoController(2, R.id.servo2); + setupServoController(3, R.id.servo3); + + setupLedController(1, R.id.leds1); + setupLedController(2, R.id.leds2); + setupLedController(3, R.id.leds3); + + setupRelayController(1, R.id.relay1); + setupRelayController(2, R.id.relay2); + } + + private void setupServoController(int servoIndex, int viewId) { + ServoController sc = new ServoController(mHostActivity, servoIndex); + sc.attachToView((ViewGroup) findViewById(viewId)); + } + + private void setupLedController(int index, int viewId) { + ColorLEDController ledC = new ColorLEDController(mHostActivity, index, + getResources(), mVertical); + ledC.attachToView((ViewGroup) findViewById(viewId)); + } + + private void setupRelayController(int index, int viewId) { + RelayController r = new RelayController(mHostActivity, index, + getResources()); + r.attachToView((ViewGroup) findViewById(viewId)); + } + +} diff --git a/demokit/app/src/com/google/android/DemoKit/RelayController.java b/demokit/app/src/com/google/android/DemoKit/RelayController.java new file mode 100644 index 0000000..d08516f --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/RelayController.java @@ -0,0 +1,56 @@ +package com.google.android.DemoKit; + +import android.content.res.Resources; +import android.graphics.drawable.Drawable; +import android.text.SpannableStringBuilder; +import android.text.style.RelativeSizeSpan; +import android.text.style.SubscriptSpan; +import android.view.ViewGroup; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; +import android.widget.TextView; +import android.widget.ToggleButton; + +public class RelayController implements OnCheckedChangeListener { + private final int mRelayNumber; + private final byte mCommandTarget; + private DemoKitActivity mActivity; + private TextView mLabel; + private ToggleButton mButton; + private Drawable mOffBackground; + private Drawable mOnBackground; + + public RelayController(DemoKitActivity activity, int relayNumber, + Resources res) { + mActivity = activity; + mRelayNumber = relayNumber; + mCommandTarget = (byte) (relayNumber - 1); + mOffBackground = res + .getDrawable(R.drawable.toggle_button_off_holo_dark); + mOnBackground = res.getDrawable(R.drawable.toggle_button_on_holo_dark); + } + + public void attachToView(ViewGroup targetView) { + mLabel = (TextView) targetView.getChildAt(0); + SpannableStringBuilder ssb = new SpannableStringBuilder("Relay"); + ssb.append(String.valueOf(mRelayNumber)); + ssb.setSpan(new SubscriptSpan(), 5, 6, 0); + ssb.setSpan(new RelativeSizeSpan(0.7f), 5, 6, 0); + mLabel.setText(ssb); + mButton = (ToggleButton) targetView.getChildAt(1); + mButton.setOnCheckedChangeListener(this); + } + + public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { + if (isChecked) { + mButton.setBackgroundDrawable(mOnBackground); + } else { + mButton.setBackgroundDrawable(mOffBackground); + } + if (mActivity != null) { + mActivity.sendCommand(DemoKitActivity.RELAY_COMMAND, + mCommandTarget, isChecked ? 1 : 0); + } + } + +} diff --git a/demokit/app/src/com/google/android/DemoKit/ServoController.java b/demokit/app/src/com/google/android/DemoKit/ServoController.java new file mode 100644 index 0000000..4584a9f --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/ServoController.java @@ -0,0 +1,39 @@ +package com.google.android.DemoKit; + +import android.text.SpannableStringBuilder; +import android.text.style.RelativeSizeSpan; +import android.text.style.SubscriptSpan; +import android.view.ViewGroup; +import android.widget.TextView; + +public class ServoController implements Slider.SliderPositionListener { + private final int mServoNumber; + private final byte mCommandTarget; + private TextView mLabel; + private Slider mSlider; + private DemoKitActivity mActivity; + + public ServoController(DemoKitActivity activity, int servoNumber) { + mActivity = activity; + mServoNumber = servoNumber; + mCommandTarget = (byte) (servoNumber - 1 + 0x10); + } + + public void attachToView(ViewGroup targetView) { + mLabel = (TextView) targetView.getChildAt(0); + SpannableStringBuilder ssb = new SpannableStringBuilder("Servo"); + ssb.append(String.valueOf(mServoNumber)); + ssb.setSpan(new SubscriptSpan(), 5, 6, 0); + ssb.setSpan(new RelativeSizeSpan(0.7f), 5, 6, 0); + mLabel.setText(ssb); + mSlider = (Slider) targetView.getChildAt(1); + mSlider.setPositionListener(this); + } + + public void onPositionChange(double value) { + byte v = (byte) (value * 255); + mActivity.sendCommand(DemoKitActivity.LED_SERVO_COMMAND, + mCommandTarget, v); + } + +} diff --git a/demokit/app/src/com/google/android/DemoKit/Slider.java b/demokit/app/src/com/google/android/DemoKit/Slider.java new file mode 100644 index 0000000..3517bff --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/Slider.java @@ -0,0 +1,133 @@ +package com.google.android.DemoKit; + +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.util.AttributeSet; +import android.view.MotionEvent; +import android.view.View; + +public class Slider extends View { + + interface SliderPositionListener { + void onPositionChange(double value); + } + + private Drawable mIndicator; + private Drawable mBackground; + private double mPosition; + private SliderPositionListener mListener; + private boolean mVertical; + + public Slider(Context context) { + super(context); + initSliderView(context, false); + } + + public Slider(Context context, AttributeSet attrs) { + super(context, attrs); + initSliderView(context, false); + } + + public void setSliderBackground(Drawable background) { + mBackground = background; + invalidate(); + } + + public void setPositionListener(SliderPositionListener listener) { + mListener = listener; + } + + public void setPosition(double position) { + if (mPosition != position) { + invalidate(); + mPosition = position; + if (mListener != null) { + mListener.onPositionChange(mPosition); + } + } + } + + private OnTouchListener mClickListener = new OnTouchListener() { + public boolean onTouch(View v, MotionEvent m) { + Rect r = new Rect(); + getDrawingRect(r); + + double position; + if (mVertical) { + double y = m.getY(); + position = Math.max(0, (r.bottom - y) / r.height()); + } else { + double x = m.getX(); + position = Math.max(0, (x - r.left) / r.width()); + } + position = Math.min(1, position); + setPosition(position); + return true; + } + }; + + protected void initSliderView(Context context, boolean vertical) { + mPosition = 0; + mVertical = vertical; + Resources res = context.getResources(); + if (mVertical) { + mBackground = res + .getDrawable(R.drawable.scrubber_vertical_blue_holo_dark); + } else { + mBackground = res + .getDrawable(R.drawable.scrubber_horizontal_holo_dark); + } + mIndicator = res.getDrawable(R.drawable.scrubber_control_holo_dark); + this.setOnTouchListener(mClickListener); + } + + protected void onDraw(Canvas canvas) { + Rect r = new Rect(); + getDrawingRect(r); + if (mVertical) { + int lineX = r.centerX(); + int bgW = mBackground.getIntrinsicWidth() / 2; + if (bgW == 0) { + bgW = 5; + } + mBackground.setBounds(lineX - bgW, r.top + 10, lineX + bgW, + r.bottom - 10); + mBackground.draw(canvas); + final int kMargin = 48; + int indicatorY = (int) (r.bottom - (r.height() - kMargin) + * mPosition) + - kMargin / 2; + Utilities.centerAround(lineX, indicatorY, mIndicator); + mIndicator.draw(canvas); + } else { + int lineY = r.centerY(); + int bgH = mBackground.getIntrinsicHeight() / 2; + if (bgH == 0) { + bgH = 5; + } + mBackground.setBounds(r.left + 10, lineY - bgH, r.right - 10, lineY + + bgH); + mBackground.draw(canvas); + final int kMargin = 48; + int indicatorX = (int) ((r.width() - kMargin) * mPosition) + r.left + + kMargin / 2; + Utilities.centerAround(indicatorX, lineY, mIndicator); + mIndicator.draw(canvas); + } + } + + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + if (mVertical) { + setMeasuredDimension(mIndicator.getIntrinsicWidth(), + getMeasuredHeight()); + } else { + setMeasuredDimension(getMeasuredWidth(), + mIndicator.getIntrinsicHeight()); + } + } + +} diff --git a/demokit/app/src/com/google/android/DemoKit/UsbAccessoryActivity.java b/demokit/app/src/com/google/android/DemoKit/UsbAccessoryActivity.java index f6a6ae5..9bf4079 100644 --- a/demokit/app/src/com/google/android/DemoKit/UsbAccessoryActivity.java +++ b/demokit/app/src/com/google/android/DemoKit/UsbAccessoryActivity.java @@ -16,7 +16,6 @@ package com.google.android.DemoKit; - import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; @@ -28,19 +27,20 @@ import android.util.Log; */ public final class UsbAccessoryActivity extends Activity { - static final String TAG = "UsbAccessoryActivity"; + static final String TAG = "UsbAccessoryActivity"; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); - Intent intent = new Intent(this, DemoKitActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); - try { - startActivity(intent); - } catch (ActivityNotFoundException e) { - Log.e(TAG, "unable to start DemoKit activity", e); - } - finish(); - } + Intent intent = DemoKitLaunch.createIntent(this); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_CLEAR_TOP); + try { + startActivity(intent); + } catch (ActivityNotFoundException e) { + Log.e(TAG, "unable to start DemoKit activity", e); + } + finish(); + } } diff --git a/demokit/app/src/com/google/android/DemoKit/Utilities.java b/demokit/app/src/com/google/android/DemoKit/Utilities.java new file mode 100644 index 0000000..0e9679c --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/Utilities.java @@ -0,0 +1,16 @@ +package com.google.android.DemoKit; + +import android.graphics.drawable.Drawable; + +public class Utilities { + static void centerAround(int x, int y, Drawable d) { + int w = d.getIntrinsicWidth(); + int h = d.getIntrinsicHeight(); + int left = x - w / 2; + int top = y - h / 2; + int right = left + w; + int bottom = top + h; + d.setBounds(left, top, right, bottom); + } + +} diff --git a/demokit/app/src/com/google/android/DemoKit/VerticalSlider.java b/demokit/app/src/com/google/android/DemoKit/VerticalSlider.java new file mode 100644 index 0000000..4cbb768 --- /dev/null +++ b/demokit/app/src/com/google/android/DemoKit/VerticalSlider.java @@ -0,0 +1,17 @@ +package com.google.android.DemoKit; + +import android.content.Context; +import android.util.AttributeSet; + +public class VerticalSlider extends Slider { + public VerticalSlider(Context context) { + super(context); + initSliderView(context, true); + } + + public VerticalSlider(Context context, AttributeSet attrs) { + super(context, attrs); + initSliderView(context, true); + } + +} diff --git a/demokit/demokit.pde b/demokit/demokit.pde index 6f70e4c..888aabc 100644 --- a/demokit/demokit.pde +++ b/demokit/demokit.pde @@ -267,6 +267,22 @@ void loop() break; } + } else { + analogWrite(LED1_RED, 255); + analogWrite(LED1_GREEN, 255); + analogWrite(LED1_BLUE, 255); + analogWrite(LED2_RED, 255); + analogWrite(LED2_GREEN, 255); + analogWrite(LED2_BLUE, 255); + analogWrite(LED3_RED, 255); + analogWrite(LED3_GREEN, 255); + analogWrite(LED3_BLUE, 255); + servos[0].write(90); + servos[0].write(90); + servos[0].write(90); + digitalWrite(RELAY1, LOW); + digitalWrite(RELAY2, LOW); + } delay(10); |