Merge "Refactor KeyboardAccessibilityDelegate class a bit"

main
Tadashi G. Takaoka 2014-05-27 09:54:55 +00:00 committed by Android (Google) Code Review
commit d3642a2a58
2 changed files with 16 additions and 6 deletions

View File

@ -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<KV extends KeyboardView>
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.
*

View File

@ -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);
}
}