From 87d2f3ea0edc8ebb724f5d2c6a07c125cfa59d23 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 27 May 2014 17:33:20 +0900 Subject: [PATCH] Refactor KeyboardAccessibilityDelegate class a bit Bug: 12491371 Change-Id: I2c2c6f3a6d0d7e7efbe0253127f5b9117cbc512d --- .../KeyboardAccessibilityDelegate.java | 14 ++++++++++++++ .../MainKeyboardAccessibilityDelegate.java | 8 ++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java index f0749a41b..0ebad9774 100644 --- a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java +++ b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java @@ -16,6 +16,7 @@ package com.android.inputmethod.accessibility; +import android.content.Context; import android.os.SystemClock; import android.support.v4.view.AccessibilityDelegateCompat; import android.support.v4.view.ViewCompat; @@ -69,6 +70,19 @@ public class KeyboardAccessibilityDelegate return mKeyboard; } + /** + * Sends a window state change event with the specified string resource id. + * + * @param resId The string resource id of the text to send with the event. + */ + protected void sendWindowStateChanged(final int resId) { + if (resId == 0) { + return; + } + final Context context = mKeyboardView.getContext(); + sendWindowStateChanged(context.getString(resId)); + } + /** * Sends a window state change event with the specified text. * diff --git a/java/src/com/android/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java index 443f793a1..ec6bb0156 100644 --- a/java/src/com/android/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java +++ b/java/src/com/android/inputmethod/accessibility/MainKeyboardAccessibilityDelegate.java @@ -163,17 +163,13 @@ public final class MainKeyboardAccessibilityDelegate default: return; } - final String text = mKeyboardView.getContext().getString(resId); - sendWindowStateChanged(text); + sendWindowStateChanged(resId); } /** * Announces that the keyboard has been hidden. */ private void announceKeyboardHidden() { - final Context context = mKeyboardView.getContext(); - final String text = context.getString(R.string.announce_keyboard_hidden); - - sendWindowStateChanged(text); + sendWindowStateChanged(R.string.announce_keyboard_hidden); } }