1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.text.method; 18 19 import android.text.Spannable; 20 import android.view.KeyEvent; 21 import android.view.MotionEvent; 22 import android.widget.TextView; 23 24 /** 25 * Provides cursor positioning, scrolling and text selection functionality in a {@link TextView}. 26 * <p> 27 * The {@link TextView} delegates handling of key events, trackball motions and touches to 28 * the movement method for purposes of content navigation. The framework automatically 29 * selects an appropriate movement method based on the content of the {@link TextView}. 30 * </p><p> 31 * This interface is intended for use by the framework; it should not be implemented 32 * directly by applications. 33 * </p> 34 */ 35 @android.ravenwood.annotation.RavenwoodKeepWholeClass 36 public interface MovementMethod { initialize(TextView widget, Spannable text)37 public void initialize(TextView widget, Spannable text); onKeyDown(TextView widget, Spannable text, int keyCode, KeyEvent event)38 public boolean onKeyDown(TextView widget, Spannable text, int keyCode, KeyEvent event); onKeyUp(TextView widget, Spannable text, int keyCode, KeyEvent event)39 public boolean onKeyUp(TextView widget, Spannable text, int keyCode, KeyEvent event); 40 41 /** 42 * If the key listener wants to other kinds of key events, return true, 43 * otherwise return false and the caller (i.e. the widget host) 44 * will handle the key. 45 */ onKeyOther(TextView view, Spannable text, KeyEvent event)46 public boolean onKeyOther(TextView view, Spannable text, KeyEvent event); 47 onTakeFocus(TextView widget, Spannable text, int direction)48 public void onTakeFocus(TextView widget, Spannable text, int direction); onTrackballEvent(TextView widget, Spannable text, MotionEvent event)49 public boolean onTrackballEvent(TextView widget, Spannable text, MotionEvent event); onTouchEvent(TextView widget, Spannable text, MotionEvent event)50 public boolean onTouchEvent(TextView widget, Spannable text, MotionEvent event); onGenericMotionEvent(TextView widget, Spannable text, MotionEvent event)51 public boolean onGenericMotionEvent(TextView widget, Spannable text, MotionEvent event); 52 53 /** 54 * Returns true if this movement method allows arbitrary selection 55 * of any text; false if it has no selection (like a movement method 56 * that only scrolls) or a constrained selection (for example 57 * limited to links. The "Select All" menu item is disabled 58 * if arbitrary selection is not allowed. 59 */ canSelectArbitrarily()60 public boolean canSelectArbitrarily(); 61 } 62