use of android.view.KeyEvent in project platform_frameworks_base by android.
the class TextView method onKeyMultiple.
@Override
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
KeyEvent down = KeyEvent.changeAction(event, KeyEvent.ACTION_DOWN);
final int which = doKeyDown(keyCode, down, event);
if (which == KEY_EVENT_NOT_HANDLED) {
// Go through default dispatching.
return super.onKeyMultiple(keyCode, repeatCount, event);
}
if (which == KEY_EVENT_HANDLED) {
// Consumed the whole thing.
return true;
}
repeatCount--;
// We are going to dispatch the remaining events to either the input
// or movement method. To do this, we will just send a repeated stream
// of down and up events until we have done the complete repeatCount.
// It would be nice if those interfaces had an onKeyMultiple() method,
// but adding that is a more complicated change.
KeyEvent up = KeyEvent.changeAction(event, KeyEvent.ACTION_UP);
if (which == KEY_DOWN_HANDLED_BY_KEY_LISTENER) {
// mEditor and mEditor.mInput are not null from doKeyDown
mEditor.mKeyListener.onKeyUp(this, (Editable) mText, keyCode, up);
while (--repeatCount > 0) {
mEditor.mKeyListener.onKeyDown(this, (Editable) mText, keyCode, down);
mEditor.mKeyListener.onKeyUp(this, (Editable) mText, keyCode, up);
}
hideErrorIfUnchanged();
} else if (which == KEY_DOWN_HANDLED_BY_MOVEMENT_METHOD) {
// mMovement is not null from doKeyDown
mMovement.onKeyUp(this, (Spannable) mText, keyCode, up);
while (--repeatCount > 0) {
mMovement.onKeyDown(this, (Spannable) mText, keyCode, down);
mMovement.onKeyUp(this, (Spannable) mText, keyCode, up);
}
}
return true;
}
use of android.view.KeyEvent in project platform_frameworks_base by android.
the class PasswordEntryKeyboardHelper method sendDownUpKeyEvents.
public void sendDownUpKeyEvents(int keyEventCode) {
long eventTime = SystemClock.uptimeMillis();
ViewRootImpl viewRootImpl = mTargetView.getViewRootImpl();
viewRootImpl.dispatchKeyFromIme(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, keyEventCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
viewRootImpl.dispatchKeyFromIme(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, keyEventCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
}
use of android.view.KeyEvent in project weiciyuan by qii.
the class BrowserWebFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.browserwebfragment_layout, container, false);
if (mWebView != null) {
mWebView.destroy();
}
mWebView = (WebView) view.findViewById(R.id.webView);
mProgressBar = (ProgressBar) view.findViewById(R.id.progressbar);
mWebView.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
mWebView.goBack();
return true;
}
return false;
}
});
mWebView.setWebViewClient(new InnerWebViewClient());
mWebView.setWebChromeClient(new InnerWebChromeClient());
mIsWebViewAvailable = true;
WebSettings settings = mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
return view;
}
use of android.view.KeyEvent in project weiciyuan by qii.
the class UserAvatarDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
String path = getArguments().getString("path");
final Rect ori = getArguments().getParcelable("rect");
Bitmap bitmap = BitmapFactory.decodeFile(path);
final View content = getActivity().getLayoutInflater().inflate(R.layout.useravatardialog_layout, null);
final ImageView avatar = ((ImageView) content.findViewById(R.id.imageview));
avatar.setImageBitmap(bitmap);
avatar.setClickable(true);
content.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
animateClose(avatar, ori);
}
});
Dialog dialog = new Dialog(getActivity(), R.style.UserAvatarDialog) {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
animateClose(avatar, ori);
return true;
}
return super.onKeyDown(keyCode, event);
}
};
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(content);
content.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
content.getViewTreeObserver().removeOnGlobalLayoutListener(this);
if (ori == null) {
return;
}
int[] avatarLocation = new int[2];
avatar.getLocationOnScreen(avatarLocation);
final int transX = ori.left - avatarLocation[0];
final int transY = ori.top - avatarLocation[1];
final float scaleX = (float) ori.width() / (float) avatar.getWidth();
final float scaleY = (float) ori.height() / (float) avatar.getHeight();
avatar.setTranslationX(transX);
avatar.setTranslationY(transY);
avatar.setPivotX(0);
avatar.setPivotY(0);
avatar.setScaleX(scaleX);
avatar.setScaleY(scaleY);
avatar.animate().translationX(0).translationY(0).scaleY(1).scaleX(1).alpha(1.0f).setDuration(300).withEndAction(new Runnable() {
@Override
public void run() {
}
});
}
});
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
return dialog;
}
use of android.view.KeyEvent in project roboguice by roboguice.
the class AstroboyMasterConsole method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
// @Inject, @InjectResource, and @InjectExtra injection happens during super.onCreate()
super.onCreate(savedInstanceState);
sayText.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
// Have the remoteControl tell Astroboy to say something
remoteControl.say(textView.getText().toString());
textView.setText(null);
return true;
}
});
brushTeethButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
remoteControl.brushTeeth();
}
});
selfDestructButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
// Self destruct the remoteControl
vibrator.vibrate(2000);
remoteControl.selfDestruct();
}
});
// Fighting the forces of evil deserves its own activity
fightEvilButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
startActivity(new Intent(AstroboyMasterConsole.this, FightForcesOfEvilActivity.class));
}
});
}
Aggregations