Support more suggestions accessibility mode
Bug: 12491371 Change-Id: Ib01452b6a2a53faa591b05e62014f356e0511308main
parent
86e1e1f97c
commit
aea429200e
|
@ -144,4 +144,9 @@
|
||||||
<string name="spoken_open_more_keys_keyboard">Alternative characters are available</string>
|
<string name="spoken_open_more_keys_keyboard">Alternative characters are available</string>
|
||||||
<!-- Spoken descriptions when closing a more keys keyboard that has alternative characters. -->
|
<!-- Spoken descriptions when closing a more keys keyboard that has alternative characters. -->
|
||||||
<string name="spoken_close_more_keys_keyboard">Alternative characters are dismissed</string>
|
<string name="spoken_close_more_keys_keyboard">Alternative characters are dismissed</string>
|
||||||
|
|
||||||
|
<!-- Spoken descriptions when opening a more suggestions panel that has alternative suggested words. -->
|
||||||
|
<string name="spoken_open_more_suggestions">Alternative suggestions are available</string>
|
||||||
|
<!-- Spoken descriptions when closing a more suggestions panel that has alternative suggested words. -->
|
||||||
|
<string name="spoken_close_more_suggestions">Alternative suggestions are dismissed</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 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.android.inputmethod.accessibility;
|
||||||
|
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
import com.android.inputmethod.keyboard.KeyDetector;
|
||||||
|
import com.android.inputmethod.keyboard.MoreKeysKeyboardView;
|
||||||
|
|
||||||
|
public final class MoreSuggestionsAccessibilityDelegate
|
||||||
|
extends MoreKeysKeyboardAccessibilityDelegate {
|
||||||
|
public MoreSuggestionsAccessibilityDelegate(final MoreKeysKeyboardView moreKeysKeyboardView,
|
||||||
|
final KeyDetector keyDetector) {
|
||||||
|
super(moreKeysKeyboardView, keyDetector);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void simulateTouchEvent(final int touchAction, final MotionEvent hoverEvent) {
|
||||||
|
final MotionEvent touchEvent = synthesizeTouchEvent(touchAction, hoverEvent);
|
||||||
|
mKeyboardView.onTouchEvent(touchEvent);
|
||||||
|
touchEvent.recycle();
|
||||||
|
}
|
||||||
|
}
|
|
@ -44,7 +44,7 @@ public class MoreKeysKeyboardView extends KeyboardView implements MoreKeysPanel
|
||||||
|
|
||||||
private int mActivePointerId;
|
private int mActivePointerId;
|
||||||
|
|
||||||
private MoreKeysKeyboardAccessibilityDelegate mAccessibilityDelegate;
|
protected MoreKeysKeyboardAccessibilityDelegate mAccessibilityDelegate;
|
||||||
|
|
||||||
public MoreKeysKeyboardView(final Context context, final AttributeSet attrs) {
|
public MoreKeysKeyboardView(final Context context, final AttributeSet attrs) {
|
||||||
this(context, attrs, R.attr.moreKeysKeyboardViewStyle);
|
this(context, attrs, R.attr.moreKeysKeyboardViewStyle);
|
||||||
|
|
|
@ -20,6 +20,8 @@ import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.android.inputmethod.accessibility.AccessibilityUtils;
|
||||||
|
import com.android.inputmethod.accessibility.MoreSuggestionsAccessibilityDelegate;
|
||||||
import com.android.inputmethod.keyboard.Key;
|
import com.android.inputmethod.keyboard.Key;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
import com.android.inputmethod.keyboard.Keyboard;
|
||||||
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
import com.android.inputmethod.keyboard.KeyboardActionListener;
|
||||||
|
@ -49,6 +51,18 @@ public final class MoreSuggestionsView extends MoreKeysKeyboardView {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setKeyboard(final Keyboard keyboard) {
|
||||||
|
super.setKeyboard(keyboard);
|
||||||
|
// With accessibility mode off, {@link #mAccessibilityDelegate} is set to null at the
|
||||||
|
// above {@link MoreKeysKeyboardView#setKeyboard(Keyboard)} call.
|
||||||
|
if (AccessibilityUtils.getInstance().isAccessibilityEnabled()) {
|
||||||
|
mAccessibilityDelegate = new MoreSuggestionsAccessibilityDelegate(this, mKeyDetector);
|
||||||
|
mAccessibilityDelegate.setOpenAnnounce(R.string.spoken_open_more_suggestions);
|
||||||
|
mAccessibilityDelegate.setCloseAnnounce(R.string.spoken_close_more_suggestions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getDefaultCoordX() {
|
protected int getDefaultCoordX() {
|
||||||
final MoreSuggestions pane = (MoreSuggestions)getKeyboard();
|
final MoreSuggestions pane = (MoreSuggestions)getKeyboard();
|
||||||
|
|
Loading…
Reference in New Issue