summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt1
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java26
2 files changed, 27 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 66b76bb..4abf386 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -10157,6 +10157,7 @@ package android.inputmethodservice {
public class InputMethodService extends android.inputmethodservice.AbstractInputMethodService {
ctor public InputMethodService();
+ method public boolean enableHardwareAcceleration();
method public int getBackDisposition();
method public int getCandidatesHiddenVisibility();
method public android.view.inputmethod.InputBinding getCurrentInputBinding();
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index c2cb1ff..a9de289 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -19,6 +19,7 @@ package android.inputmethodservice;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import android.app.ActivityManager;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Configuration;
@@ -38,6 +39,7 @@ import android.text.method.MovementMethod;
import android.util.Log;
import android.util.PrintWriterPrinter;
import android.util.Printer;
+import android.view.Display;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -250,6 +252,7 @@ public class InputMethodService extends AbstractInputMethodService {
InputMethodManager mImm;
int mTheme = 0;
+ boolean mHardwareAccelerated = false;
LayoutInflater mInflater;
TypedArray mThemeAttrs;
@@ -614,6 +617,26 @@ public class InputMethodService extends AbstractInputMethodService {
mTheme = theme;
}
+ /**
+ * You can call this to try to enable hardware accelerated drawing for
+ * your IME. This must be set before {@link #onCreate}, so you
+ * will typically call it in your constructor. It is not always possible
+ * to use hardware acclerated drawing in an IME (for example on low-end
+ * devices that do not have the resources to support this), so the call
+ * returns true if it succeeds otherwise false if you will need to draw
+ * in software. You must be able to handle either case.
+ */
+ public boolean enableHardwareAcceleration() {
+ if (mWindow != null) {
+ throw new IllegalStateException("Must be called before onCreate()");
+ }
+ if (ActivityManager.isHighEndGfx(new Display(Display.DEFAULT_DISPLAY, null))) {
+ mHardwareAccelerated = true;
+ return true;
+ }
+ return false;
+ }
+
@Override public void onCreate() {
mTheme = Resources.selectSystemTheme(mTheme,
getApplicationInfo().targetSdkVersion,
@@ -626,6 +649,9 @@ public class InputMethodService extends AbstractInputMethodService {
mInflater = (LayoutInflater)getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
mWindow = new SoftInputWindow(this, mTheme, mDispatcherState);
+ if (mHardwareAccelerated) {
+ mWindow.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
+ }
initViews();
mWindow.getWindow().setLayout(MATCH_PARENT, WRAP_CONTENT);
}