Skip to content

Commit 9f93186

Browse files
committed
Adding a sample accessibility service
Change-Id: I5bd42157e263aac6d7a85db090319db168dea2fd
1 parent f0f2aba commit 9f93186

14 files changed

+924
-0
lines changed

build/sdk.atree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ sdk/files/android.el tools/lib/android.el
8686
# (see web_docs_sample_code_flags in frameworks/base/Android.mk)
8787
development/samples/source.properties samples/${PLATFORM_NAME}/source.properties
8888
development/apps/GestureBuilder samples/${PLATFORM_NAME}/GestureBuilder
89+
development/samples/AccessibilityService samples/${PLATFORM_NAME}/AccessibilityService
8990
development/samples/BluetoothChat samples/${PLATFORM_NAME}/BluetoothChat
9091
development/samples/Home samples/${PLATFORM_NAME}/Home
9192
development/samples/LunarLander samples/${PLATFORM_NAME}/LunarLander
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
LOCAL_PATH:= $(call my-dir)
2+
include $(CLEAR_VARS)
3+
4+
LOCAL_MODULE_TAGS := samples
5+
6+
LOCAL_SRC_FILES := $(call all-subdir-java-files)
7+
8+
LOCAL_PACKAGE_NAME := AccessibilityService
9+
10+
LOCAL_SDK_VERSION := current
11+
12+
include $(BUILD_PACKAGE)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<!-- Copyright (C) 2010 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19+
package="com.example.android.clockback"
20+
android:versionCode="1"
21+
android:versionName="1.0">
22+
23+
<uses-permission android:name="android.permission.VIBRATE" />
24+
25+
<application android:label="@string/clockback_setup_title">
26+
27+
<!-- We declare our service here -->
28+
<service android:name=".ClockBackService">
29+
<!-- This intent filter is a clue for the system that this is an accessibility service -->
30+
<intent-filter>
31+
<action android:name="android.accessibilityservice.AccessibilityService" />
32+
</intent-filter>
33+
</service>
34+
35+
</application>
36+
37+
<!-- Accessibility API appeared in SDK version 4 (Android 1.6) -->
38+
<uses-sdk android:minSdkVersion="4" />
39+
40+
</manifest>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<p>
2+
This is an example of an accessibility service that provides custom feedback for the Clock application which comes by default with Android devices. It demonstrates the following key features of the Android accessibility APIs:
3+
</p>
4+
<ol>
5+
<li>
6+
Simple demonstration of how to use the accessibility APIs.
7+
</li>
8+
<li>
9+
Hands-on example of various ways to utilize the accessibility API for providing alternative and complementary feedback.
10+
</li>
11+
<li>
12+
Providing application specific feedback &mdash; the service handles only accessibility events from the Clock application.
13+
</li>
14+
<li>
15+
Providing dynamic, context-dependent feedback &mdash; feedback type changes depending on the ringer mode.
16+
</li>
17+
<li>
18+
Application specific UI enhancement &mdash; application domain knowledge is utilized to enhance the provided feedback.
19+
</li>
20+
</ol>
21+
<p>
22+
<strong>
23+
Note: This code sample will work only on devices shipped with the default Clock application. If you are
24+
running Android 1.6 of Android 2.0 you should enable first ClockBack and then TalkBack since in these
25+
releases accessibility services are notified in the order of registration.
26+
</strong>
27+
</p>
28+
<p>
29+
Steps to exercise the ClockBack example:
30+
</p>
31+
<ol>
32+
<li>
33+
<ul>
34+
<li>
35+
<strong>Action:</strong> Enable accessibility and all default accessibility services:<br/>
36+
Settings &rarr; Accessibility &rarr; select the Accessibility, TalkBack, KickBack, and SoundBack checkboxes
37+
</li>
38+
<li>
39+
<strong>Result:</strong> The system provides spoken, audible, and haptic feedback.
40+
</li>
41+
</ul>
42+
</li>
43+
<li>
44+
<ul>
45+
<li>
46+
<strong>Action:</strong> Explore the feedback provided by the system:<br/>
47+
Poke around with the trackball.
48+
</li>
49+
<li>
50+
<strong>Result:</strong> You are somehow familiar with the type of the provided feedback.
51+
</li>
52+
</ul>
53+
</li>
54+
<li>
55+
<ul>
56+
<li>
57+
<strong>Action:</strong> Go to the Clock application and try to change the time of an alarm:<br/>
58+
All applications &rarr; Clock &rarr; Alarms (left corner) &rarr; Select an alarm &rarr; Time &mdash; explore the plus, minus buttons, hour and minute edit boxes.
59+
</li>
60+
<li>
61+
<strong>Result:</strong> The hour and minute edit boxes are announced without any clue which is the hour and which is the minute one (you can guess from the arrangement).
62+
</li>
63+
</ul>
64+
</li>
65+
<li>
66+
<ul>
67+
<li>
68+
<strong>Action:</strong> Enable ClockBack:<br>
69+
Settings &rarr; Accessibility &rarr; ClockBack &mdash; select the checkbox (assuming you have installed the APK).
70+
</li>
71+
<li>
72+
<strong>Result:</strong> We have active accessibility service for providing application specific feedback for the Clock application.
73+
</li>
74+
</ul>
75+
</li>
76+
<li>
77+
<ul>
78+
<li>
79+
<strong>Action:</strong> Go to the Clock application and try to change the time of an alarm:<br/>
80+
All applications &rarr; Clock &rarr; Alarms (left corner) &rarr; Select an alarm &rarr; Time &mdash; explore the hour and minute edit boxes.
81+
</li>
82+
<li>
83+
<strong>Result:</strong> The hour and minute edit boxes are now spoken. This is an example of application specific feedback that utilizes domain information to enhance the user experience.
84+
</li>
85+
</ul>
86+
</li>
87+
<li>
88+
<ul>
89+
<li>
90+
<strong>Action:</strong> Set the ringer to vibration mode and explore the provided feedback:<br/>
91+
Use the device button for reducing the ringer volume until it is in vibration mode. Move around the Clock application and outside of that application.
92+
</li>
93+
<li>
94+
<strong>Result:</strong> The Clock application provides custom audible and default haptic feedback. The rest of the system provides the default feedback.
95+
</li>
96+
</ul>
97+
</li>
98+
<li>
99+
<ul>
100+
<li>
101+
<strong>Action:</strong> Set the ringer to muted mode and explore the provided feedback:<br/>
102+
Use the device button for reducing the ringer volume until it is in muted mode. Move around the Clock application and outside of that application.
103+
</li>
104+
<li>
105+
<strong>Result:</strong> The Clock application provides only custom haptic feedback. The rest of the system provides the default feedback. Now we are providing custom context dependent feedback based on the device state (ringer mode).
106+
</li>
107+
</ul>
108+
</li>
109+
<li>
110+
<ul>
111+
<li>
112+
<strong>Action:</strong> Write an accessibility service:<br/>
113+
The <a href="http://code.google.com/p/eyes-free/">Eyes-Free open source project</a> has more accessibility-related resources. To contribute, visit the project page or post to the <a href="http://groups.google.com/group/eyes-free">mailing list</a>.
114+
</li>
115+
<li>
116+
<strong>Result:</strong> One more cool application has been written.
117+
</li>
118+
</ul>
119+
</li>
120+
</ol>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<!-- VALUES -->
5+
6+
<!-- Setting up the user interface vibration feedback service -->
7+
<string name="clockback_setup_title">ClockBack</string>
8+
9+
<!-- String value for announcing the increase hours buttons -->
10+
<string name="value_increase_hours">Increase hours</string>
11+
12+
<!-- String value for announcing the increase minutes buttons -->
13+
<string name="value_increase_minutes">Increase minutes</string>
14+
15+
<!-- String value for announcing the decrease hours buttons -->
16+
<string name="value_decrease_hours">Decrease hours</string>
17+
18+
<!-- String value for announcing the decrease minutes buttons -->
19+
<string name="value_decrease_minutes">Decrease minutes</string>
20+
21+
<!-- String value for announcing one hour input -->
22+
<string name="value_hour">hour</string>
23+
24+
<!-- String value for announcing the hours input -->
25+
<string name="value_hours">hours</string>
26+
27+
<!-- String value for announcing one minute input -->
28+
<string name="value_minute">minute</string>
29+
30+
<!-- String value for announcing the minutes input -->
31+
<string name="value_minutes">minutes</string>
32+
33+
<!-- String value for announcing audible ringer mode -->
34+
<string name="value_ringer_audible">Ringer audible</string>
35+
36+
<!-- String value for announcing vibrating ringer mode -->
37+
<string name="value_ringer_vibrate">Ringer vibrate</string>
38+
39+
<!-- String value for announcing silent ringer mode-->
40+
<string name="value_ringer_silent">Ringer silent</string>
41+
42+
<!-- TEMPLATES -->
43+
44+
<!-- String template for announcing the screen on -->
45+
<string name="template_screen_on">Screen on. Volume %1$s percent.</string>
46+
47+
<!-- String template for announcing the screen off -->
48+
<string name="template_screen_off">Screen off. Volume %1$s percent.</string>
49+
50+
</resources>

0 commit comments

Comments
 (0)