am a7ce1551: Merge "Add API to turn on HW drawing in IMEs." into jb-mr1-dev

* commit 'a7ce1551a6c05d4f983e283b413cadb1ddc1026d':
  Add API to turn on HW drawing in IMEs.
This commit is contained in:
Dianne Hackborn
2012-08-01 19:15:23 -07:00
committed by Android Git Automerger
2 changed files with 27 additions and 0 deletions

View File

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

View File

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