am d3642a2a: Merge "Refactor KeyboardAccessibilityDelegate class a bit"

* commit 'd3642a2a58a21c29b09c70b4454a133a8309770e':
  Refactor KeyboardAccessibilityDelegate class a bit
main
Tadashi G. Takaoka 2014-05-27 09:57:12 +00:00 committed by Android Git Automerger
commit 69146aa107
2 changed files with 16 additions and 6 deletions

View File

@ -16,6 +16,7 @@
package com.android.inputmethod.accessibility; package com.android.inputmethod.accessibility;
import android.content.Context;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.v4.view.AccessibilityDelegateCompat; import android.support.v4.view.AccessibilityDelegateCompat;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
@ -69,6 +70,19 @@ public class KeyboardAccessibilityDelegate<KV extends KeyboardView>
return mKeyboard; 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. * Sends a window state change event with the specified text.
* *

View File

@ -163,17 +163,13 @@ public final class MainKeyboardAccessibilityDelegate
default: default:
return; return;
} }
final String text = mKeyboardView.getContext().getString(resId); sendWindowStateChanged(resId);
sendWindowStateChanged(text);
} }
/** /**
* Announces that the keyboard has been hidden. * Announces that the keyboard has been hidden.
*/ */
private void announceKeyboardHidden() { private void announceKeyboardHidden() {
final Context context = mKeyboardView.getContext(); sendWindowStateChanged(R.string.announce_keyboard_hidden);
final String text = context.getString(R.string.announce_keyboard_hidden);
sendWindowStateChanged(text);
} }
} }