Merge "Fix null token error"

main
Ken Wakasa 2011-03-01 14:27:12 -08:00 committed by Android (Google) Code Review
commit 7ec48741e4
1 changed files with 4 additions and 1 deletions

View File

@ -39,6 +39,7 @@ import android.media.AudioManager;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.os.Debug; import android.os.Debug;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder;
import android.os.Message; import android.os.Message;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.Vibrator; import android.os.Vibrator;
@ -2263,6 +2264,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void showOptionsMenuInternal(CharSequence title, CharSequence[] items, private void showOptionsMenuInternal(CharSequence title, CharSequence[] items,
DialogInterface.OnClickListener listener) { DialogInterface.OnClickListener listener) {
final IBinder windowToken = mKeyboardSwitcher.getInputView().getWindowToken();
if (windowToken == null) return;
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(true); builder.setCancelable(true);
builder.setIcon(R.drawable.ic_dialog_keyboard); builder.setIcon(R.drawable.ic_dialog_keyboard);
@ -2273,7 +2276,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mOptionsDialog.setCanceledOnTouchOutside(true); mOptionsDialog.setCanceledOnTouchOutside(true);
Window window = mOptionsDialog.getWindow(); Window window = mOptionsDialog.getWindow();
WindowManager.LayoutParams lp = window.getAttributes(); WindowManager.LayoutParams lp = window.getAttributes();
lp.token = mKeyboardSwitcher.getInputView().getWindowToken(); lp.token = windowToken;
lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
window.setAttributes(lp); window.setAttributes(lp);
window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);