Refactor KeyboardAccessibilityDelegate class a bit

Bug: 12491371
Change-Id: I2c2c6f3a6d0d7e7efbe0253127f5b9117cbc512d
main
Tadashi G. Takaoka 2014-05-27 17:33:20 +09:00
parent 01748cde4e
commit 87d2f3ea0e
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);
} }
} }