+ Accessibility/Accessibility Service
+ ClockBack
+
+ 1. Enable TalkBack (Settings -> Accessibility -> TalkBack).
+ \n\n2. Enable Explore-byTouch (Settings -> Accessibility -> Explore by Touch).
+ \n\n3. Touch explore the Clock application and the home screen.
+ \n\n4. Go to the Clock application and change the time of an alarm.
+ \n\n5. Enable ClockBack (Settings -> Accessibility -> ClockBack).
+ \n\n6. Go to the Clock application and change an alarm.
+ \n\n7. Set the ringer to vibration mode and change an alarm.
+ \n\n8. Set the ringer to muted mode and change an alarm.
+
- Accessibility/Accessibility Node Querying
- Task App Accessibility Service
- TaskBack
+ Ringer audible
+ Ringer vibrate
+ Ringer silent
+ Screen on. Volume %1$s percent.
+ Screen off. Volume %1$s percent.
+
+ Accessibility/Accessibility Node Querying
+ QueryBack
+ Task App Accessibility Service
+
+ 1. Enable QueryBack (Settings -> Accessibility -> QueryBack).
+ \n\n2. Enable Explore-byTouch (Settings -> Accessibility -> Explore by Touch).
+ \n\n3. Touch explore the list.
+
Task
Task %1$s %2$s
is complete
is not complete
+
diff --git a/samples/ApiDemos/res/xml/taskbackconfig.xml b/samples/ApiDemos/res/xml/taskbackconfig.xml
index 02ff11c70..5dc0cf5c7 100644
--- a/samples/ApiDemos/res/xml/taskbackconfig.xml
+++ b/samples/ApiDemos/res/xml/taskbackconfig.xml
@@ -15,11 +15,10 @@
limitations under the License.
-->
-
+
diff --git a/samples/ApiDemos/src/com/example/android/apis/accessibility/ClockBackActivity.java b/samples/ApiDemos/src/com/example/android/apis/accessibility/ClockBackActivity.java
new file mode 100644
index 000000000..75fb1ff3d
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/accessibility/ClockBackActivity.java
@@ -0,0 +1,55 @@
+/*
+ * 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.example.android.apis.accessibility;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.view.View;
+import android.widget.ImageButton;
+
+import com.example.android.apis.R;
+
+/**
+ * This is the entry activity for a sample that demonstrates how to implement an
+ * {@link android.accessibilityservice.AccessibilityService}.
+ */
+public class ClockBackActivity extends Activity {
+
+ /** An intent for launching the system settings. */
+ private static final Intent sSettingsIntent =
+ new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.accessibility_service);
+
+ // Add a shortcut to the accessibility settings.
+ ImageButton button = (ImageButton) findViewById(R.id.button);
+ button.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startActivity(sSettingsIntent);
+ }
+ });
+ }
+}
diff --git a/samples/AccessibilityService/src/com/example/android/clockback/ClockBackService.java b/samples/ApiDemos/src/com/example/android/apis/accessibility/ClockBackService.java
similarity index 75%
rename from samples/AccessibilityService/src/com/example/android/clockback/ClockBackService.java
rename to samples/ApiDemos/src/com/example/android/apis/accessibility/ClockBackService.java
index 5746716e1..d5cd2a3cb 100644
--- a/samples/AccessibilityService/src/com/example/android/clockback/ClockBackService.java
+++ b/samples/ApiDemos/src/com/example/android/apis/accessibility/ClockBackService.java
@@ -14,7 +14,9 @@
* limitations under the License.
*/
-package com.example.android.clockback;
+package com.example.android.apis.accessibility;
+
+import com.example.android.apis.R;
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
@@ -54,19 +56,7 @@ import java.util.List;
* Providing dynamic, context-dependent feedback — feedback type changes
* depending on the ringer state.
*
- *
- * Application specific UI enhancement - application domain knowledge is
- * utilized to enhance the provided feedback.
- *
*
- *
- *
- * Note: This code sample will work only on devices shipped with the default Clock
- * application. If you are running Android 1.6 of Android 2.0 you should enable first
- * ClockBack and then TalkBack since in these releases accessibility services are
- * notified in the order of registration.
- *
- *
*/
public class ClockBackService extends AccessibilityService {
@@ -147,56 +137,6 @@ public class ClockBackService extends AccessibilityService {
/** The space string constant. */
private static final String SPACE = " ";
- /**
- * The class name of the number picker buttons with no text we want to
- * announce in the Clock application.
- */
- private static final String CLASS_NAME_NUMBER_PICKER_BUTTON_CLOCK = "android.widget.NumberPickerButton";
-
- /**
- * The class name of the number picker buttons with no text we want to
- * announce in the AlarmClock application.
- */
- private static final String CLASS_NAME_NUMBER_PICKER_BUTTON_ALARM_CLOCK = "com.android.internal.widget.NumberPickerButton";
-
- /**
- * The class name of the edit text box for hours and minutes we want to
- * better announce.
- */
- private static final String CLASS_NAME_EDIT_TEXT = "android.widget.EditText";
-
- /**
- * Mapping from integer to string resource id where the keys are generated
- * from the {@link AccessibilityEvent#getText()},
- * {@link AccessibilityEvent#getItemCount()} and
- * {@link AccessibilityEvent#getCurrentItemIndex()} properties.
- *
- * Note: In general, computing these mappings includes the widget position on
- * the screen. This is fragile and should be used as a last resort since
- * changing the layout could potentially change the widget position. This is
- * a workaround since the widgets of interest are image buttons that do not
- * have contentDescription attribute set (plus/minus buttons) or no other
- * information in the accessibility event is available to distinguish them
- * aside of their positions on the screen (hour/minute inputs).
- * If you are owner of the target application (Clock in this case) you
- * should add contentDescription attribute to all image buttons such that a
- * screen reader knows how to speak them. For input fields (while not
- * applicable for the hour and minute inputs since they are not empty) a
- * hint text should be set to enable better announcement.
- *
- */
- private static final SparseArray sEventDataMappedStringResourceIds = new SparseArray();
- static {
- sEventDataMappedStringResourceIds.put(110, R.string.value_increase_hours);
- sEventDataMappedStringResourceIds.put(1140, R.string.value_increase_minutes);
- sEventDataMappedStringResourceIds.put(1120, R.string.value_decrease_hours);
- sEventDataMappedStringResourceIds.put(1160, R.string.value_decrease_minutes);
- sEventDataMappedStringResourceIds.put(1111, R.string.value_hour);
- sEventDataMappedStringResourceIds.put(1110, R.string.value_hours);
- sEventDataMappedStringResourceIds.put(1151, R.string.value_minute);
- sEventDataMappedStringResourceIds.put(1150, R.string.value_minutes);
- }
-
/** Mapping from integers to vibration patterns for haptic feedback. */
private static final SparseArray sVibrationPatterns = new SparseArray();
static {
@@ -215,6 +155,9 @@ public class ClockBackService extends AccessibilityService {
sVibrationPatterns.put(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, new long[] {
0L, 25L, 50L, 25L, 50L, 25L
});
+ sVibrationPatterns.put(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER, new long[] {
+ 0L, 15L, 10L, 15L, 15L, 10L
+ });
sVibrationPatterns.put(INDEX_SCREEN_ON, new long[] {
0L, 10L, 10L, 20L, 20L, 30L
});
@@ -226,11 +169,18 @@ public class ClockBackService extends AccessibilityService {
/** Mapping from integers to raw sound resource ids. */
private static SparseArray sSoundsResourceIds = new SparseArray();
static {
- sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_CLICKED, R.raw.sound_view_clicked);
- sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED, R.raw.sound_view_clicked);
- sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_SELECTED, R.raw.sound_view_focused_or_selected);
- sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_FOCUSED, R.raw.sound_view_focused_or_selected);
- sSoundsResourceIds.put(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, R.raw.sound_window_state_changed);
+ sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_CLICKED,
+ R.raw.sound_view_clicked);
+ sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED,
+ R.raw.sound_view_clicked);
+ sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_SELECTED,
+ R.raw.sound_view_focused_or_selected);
+ sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_FOCUSED,
+ R.raw.sound_view_focused_or_selected);
+ sSoundsResourceIds.put(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED,
+ R.raw.sound_window_state_changed);
+ sSoundsResourceIds.put(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER,
+ R.raw.sound_view_hover_enter);
sSoundsResourceIds.put(INDEX_SCREEN_ON, R.raw.sound_screen_on);
sSoundsResourceIds.put(INDEX_SCREEN_OFF, R.raw.sound_screen_off);
sSoundsResourceIds.put(INDEX_RINGER_SILENT, R.raw.sound_ringer_silent);
@@ -304,7 +254,9 @@ public class ClockBackService extends AccessibilityService {
case MESSAGE_VIBRATE:
int key = message.arg1;
long[] pattern = sVibrationPatterns.get(key);
- mVibrator.vibrate(pattern, -1);
+ if (pattern != null) {
+ mVibrator.vibrate(pattern, -1);
+ }
return;
case MESSAGE_STOP_VIBRATE:
mVibrator.cancel();
@@ -473,12 +425,6 @@ public class ClockBackService extends AccessibilityService {
* Let some other services provide audible feedback (SounBack) and haptic
* feedback (KickBack).
*