summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-15 16:12:10 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-15 16:12:10 -0800
commit9266c558bf1d21ff647525ff99f7dadbca417309 (patch)
tree1630b1ba80f4793caf39d865528e662bdb1037fe /core/java/android/view
parentb798689749c64baba81f02e10cf2157c747d6b46 (diff)
downloadframeworks_base-9266c558bf1d21ff647525ff99f7dadbca417309.zip
frameworks_base-9266c558bf1d21ff647525ff99f7dadbca417309.tar.gz
frameworks_base-9266c558bf1d21ff647525ff99f7dadbca417309.tar.bz2
auto import from //branches/cupcake/...@126645
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/IWindowManager.aidl1
-rw-r--r--core/java/android/view/RawInputEvent.java5
-rw-r--r--core/java/android/view/View.java30
-rw-r--r--core/java/android/view/ViewRoot.java33
-rw-r--r--core/java/android/view/WindowManager.java53
-rw-r--r--core/java/android/view/animation/Animation.java46
-rw-r--r--core/java/android/view/inputmethod/DefaultInputMethod.java4
-rw-r--r--core/java/android/view/inputmethod/InputMethod.java13
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java40
9 files changed, 184 insertions, 41 deletions
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index d89c7b4..40251db 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -67,6 +67,7 @@ interface IWindowManager
int getAppOrientation(IApplicationToken token);
void setFocusedApp(IBinder token, boolean moveFocusNow);
void prepareAppTransition(int transit);
+ int getPendingAppTransition();
void executeAppTransition();
void setAppStartingWindow(IBinder token, String pkg, int theme,
CharSequence nonLocalizedLabel, int labelRes,
diff --git a/core/java/android/view/RawInputEvent.java b/core/java/android/view/RawInputEvent.java
index 580a80d..30da83e 100644
--- a/core/java/android/view/RawInputEvent.java
+++ b/core/java/android/view/RawInputEvent.java
@@ -10,8 +10,9 @@ package android.view;
public class RawInputEvent {
// Event class as defined by EventHub.
public static final int CLASS_KEYBOARD = 0x00000001;
- public static final int CLASS_TOUCHSCREEN = 0x00000002;
- public static final int CLASS_TRACKBALL = 0x00000004;
+ public static final int CLASS_ALPHAKEY = 0x00000002;
+ public static final int CLASS_TOUCHSCREEN = 0x00000004;
+ public static final int CLASS_TRACKBALL = 0x00000008;
// More special classes for QueuedEvent below.
public static final int CLASS_CONFIGURATION_CHANGED = 0x10000000;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 1cc7b60..85f482c 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -1670,6 +1670,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
int viewFlagValues = 0;
int viewFlagMasks = 0;
+ boolean setScrollContainer = false;
+
int x = 0;
int y = 0;
@@ -1796,6 +1798,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
viewFlagMasks |= SCROLLBARS_STYLE_MASK;
}
break;
+ case R.styleable.View_isScrollContainer:
+ setScrollContainer = true;
+ if (a.getBoolean(attr, false)) {
+ setScrollContainer(true);
+ }
+ break;
case com.android.internal.R.styleable.View_keepScreenOn:
if (a.getBoolean(attr, false)) {
viewFlagValues |= KEEP_SCREEN_ON;
@@ -1856,6 +1864,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
scrollTo(x, y);
}
+ if (!setScrollContainer && (viewFlagValues&SCROLLBARS_VERTICAL) != 0) {
+ setScrollContainer(true);
+ }
+
a.recycle();
}
@@ -3555,10 +3567,28 @@ public class View implements Drawable.Callback, KeyEvent.Callback {
}
/**
+ * Check whether the called view is a text editor, in which case it
+ * would make sense to automatically display a soft input window for
+ * it. Subclasses should override this if they implement
+ * {@link #onCreateInputConnection(EditorInfo)} to return true if
+ * a call on that method would return a non-null InputConnection. The
+ * default implementation always returns false.
+ *
+ * @return Returns true if this view is a text editor, else false.
+ */
+ public boolean onCheckIsTextEditor() {
+ return false;
+ }
+
+ /**
* Create a new InputConnection for an InputMethod to interact
* with the view. The default implementation returns null, since it doesn't
* support input methods. You can override this to implement such support.
* This is only needed for views that take focus and text input.
+ *
+ * <p>When implementing this, you probably also want to implement
+ * {@link #onCheckIsTextEditor()} to indicate you will return a
+ * non-null InputConnection.
*
* @param outAttrs Fill in with attribute information about the connection.
*/
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index a254edb..9d7a124 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1579,9 +1579,16 @@ public final class ViewRoot extends Handler implements ViewParent,
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) {
imm.onWindowFocus(mView.findFocus(),
- mWindowAttributes.softInputMode, !mHasHadWindowFocus,
- mWindowAttributes.flags);
+ mWindowAttributes.softInputMode,
+ !mHasHadWindowFocus, mWindowAttributes.flags);
}
+ // Clear the forward bit. We can just do this directly, since
+ // the window manager doesn't care about it.
+ mWindowAttributes.softInputMode &=
+ ~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
+ ((WindowManager.LayoutParams)mView.getLayoutParams())
+ .softInputMode &=
+ ~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION;
mHasHadWindowFocus = true;
}
}
@@ -2030,14 +2037,20 @@ public final class ViewRoot extends Handler implements ViewParent,
}
return;
}
- InputMethodManager imm = InputMethodManager.peekInstance();
- if (imm != null && mView != null && imm.isActive()) {
- int seq = enqueuePendingEvent(event, sendDone);
- if (DEBUG_IMF) Log.v(TAG, "Sending key event to IME: seq="
- + seq + " event=" + event);
- imm.dispatchKeyEvent(mView.getContext(), seq, event,
- mInputMethodCallback);
- return;
+ // If it is possible for this window to interact with the input
+ // method window, then we want to first dispatch our key events
+ // to the input method.
+ if (WindowManager.LayoutParams.mayUseInputMethod(
+ mWindowAttributes.flags)) {
+ InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm != null && mView != null && imm.isActive()) {
+ int seq = enqueuePendingEvent(event, sendDone);
+ if (DEBUG_IMF) Log.v(TAG, "Sending key event to IME: seq="
+ + seq + " event=" + event);
+ imm.dispatchKeyEvent(mView.getContext(), seq, event,
+ mInputMethodCallback);
+ return;
+ }
}
deliverKeyEventToViewHierarchy(event, sendDone);
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 7d202aa..7e47ad1 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -466,12 +466,6 @@ public interface WindowManager extends ViewManager {
*/
public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
- /** Window flag: set when this window was created from the restored
- * state of a previous window, indicating this is not the first time
- * the user has navigated to it.
- */
- public static final int FLAG_RESTORED_STATE = 0x00080000;
-
/** Window flag: a special option intended for system dialogs. When
* this flag is set, the window will demand focus unconditionally when
* it is created.
@@ -479,6 +473,29 @@ public interface WindowManager extends ViewManager {
public static final int FLAG_SYSTEM_ERROR = 0x40000000;
/**
+ * Given a particular set of window manager flags, determine whether
+ * such a window may be a target for an input method when it has
+ * focus. In particular, this checks the
+ * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
+ * flags and returns true if the combination of the two corresponds
+ * to a window that needs to be behind the input method so that the
+ * user can type into it.
+ *
+ * @param flags The current window manager flags.
+ *
+ * @return Returns true if such a window should be behind/interact
+ * with an input method, false if not.
+ */
+ public static boolean mayUseInputMethod(int flags) {
+ switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
+ case 0:
+ case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
+ return true;
+ }
+ return false;
+ }
+
+ /**
* Mask for {@link #softInputMode} of the bits that determine the
* desired visibility state of the soft input area for this window.
*/
@@ -502,16 +519,17 @@ public interface WindowManager extends ViewManager {
public static final int SOFT_INPUT_STATE_HIDDEN = 2;
/**
- * Visibility state for {@link #softInputMode}: please show the soft input area
- * the first time the window is shown.
+ * Visibility state for {@link #softInputMode}: please show the soft
+ * input area when normally appropriate (when the user is navigating
+ * forward to your window).
*/
- public static final int SOFT_INPUT_STATE_FIRST_VISIBLE = 3;
+ public static final int SOFT_INPUT_STATE_VISIBLE = 3;
/**
- * Visibility state for {@link #softInputMode}: please always show the soft
- * input area.
+ * Visibility state for {@link #softInputMode}: please always make the
+ * soft input area visible when this window receives input focus.
*/
- public static final int SOFT_INPUT_STATE_VISIBLE = 4;
+ public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 4;
/**
* Mask for {@link #softInputMode} of the bits that determine the
@@ -547,13 +565,22 @@ public interface WindowManager extends ViewManager {
public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
/**
+ * Bit for {@link #softInputMode}: set when the user has navigated
+ * forward to the window. This is normally set automatically for
+ * you by the system, though you may want to set it in certain cases
+ * when you are displaying a window yourself. This flag will always
+ * be cleared automatically after the window is displayed.
+ */
+ public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
+
+ /**
* Desired operating mode for any soft input area. May any combination
* of:
*
* <ul>
* <li> One of the visibility states
* {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
- * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_FIRST_VISIBLE}, or
+ * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
* {@link #SOFT_INPUT_STATE_VISIBLE}.
* <li> One of the adjustment options
* {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
diff --git a/core/java/android/view/animation/Animation.java b/core/java/android/view/animation/Animation.java
index d1d549c..9264398 100644
--- a/core/java/android/view/animation/Animation.java
+++ b/core/java/android/view/animation/Animation.java
@@ -118,7 +118,12 @@ public abstract class Animation {
* Indicates whether the animation transformation should be applied after the
* animation ends.
*/
- boolean mFillAfter = true;
+ boolean mFillAfter = false;
+
+ /**
+ * Indicates whether fillAfter should be taken into account.
+ */
+ boolean mFillEnabled = false;
/**
* The time in milliseconds at which the animation must start;
@@ -193,6 +198,7 @@ public abstract class Animation {
setDuration((long) a.getInt(com.android.internal.R.styleable.Animation_duration, 0));
setStartOffset((long) a.getInt(com.android.internal.R.styleable.Animation_startOffset, 0));
+ setFillEnabled(a.getBoolean(com.android.internal.R.styleable.Animation_fillEnabled, mFillEnabled));
setFillBefore(a.getBoolean(com.android.internal.R.styleable.Animation_fillBefore, mFillBefore));
setFillAfter(a.getBoolean(com.android.internal.R.styleable.Animation_fillAfter, mFillAfter));
@@ -406,6 +412,31 @@ public abstract class Animation {
}
/**
+ * If fillEnabled is true, this animation will apply fillBefore and fillAfter.
+ *
+ * @return true if the animation will take fillBefore and fillAfter into account
+ * @attr ref android.R.styleable#Animation_fillEnabled
+ */
+ public boolean isFillEnabled() {
+ return mFillEnabled;
+ }
+
+ /**
+ * If fillEnabled is true, the animation will apply the value of fillBefore and
+ * fillAfter. Otherwise, fillBefore and fillAfter are ignored and the animation
+ * transformation is always applied.
+ *
+ * @param fillEnabled true if the animation should take fillBefore and fillAfter into account
+ * @attr ref android.R.styleable#Animation_fillEnabled
+ *
+ * @see #setFillBefore(boolean)
+ * @see #setFillAfter(boolean)
+ */
+ public void setFillEnabled(boolean fillEnabled) {
+ mFillEnabled = fillEnabled;
+ }
+
+ /**
* If fillBefore is true, this animation will apply its transformation
* before the start time of the animation. Defaults to true if not set.
* Note that this applies when using an {@link
@@ -415,6 +446,8 @@ public abstract class Animation {
*
* @param fillBefore true if the animation should apply its transformation before it starts
* @attr ref android.R.styleable#Animation_fillBefore
+ *
+ * @see #setFillEnabled(boolean)
*/
public void setFillBefore(boolean fillBefore) {
mFillBefore = fillBefore;
@@ -422,7 +455,7 @@ public abstract class Animation {
/**
* If fillAfter is true, the transformation that this animation performed
- * will persist when it is finished. Defaults to true if not set.
+ * will persist when it is finished. Defaults to false if not set.
* Note that this applies when using an {@link
* android.view.animation.AnimationSet AnimationSet} to chain
* animations. The transformation is not applied before the AnimationSet
@@ -430,6 +463,8 @@ public abstract class Animation {
*
* @param fillAfter true if the animation should apply its transformation after it ends
* @attr ref android.R.styleable#Animation_fillAfter
+ *
+ * @see #setFillEnabled(boolean)
*/
public void setFillAfter(boolean fillAfter) {
mFillAfter = fillAfter;
@@ -623,9 +658,11 @@ public abstract class Animation {
normalizedTime = currentTime < mStartTime ? 0.0f : 1.0f;
}
- boolean expired = normalizedTime >= 1.0f;
+ final boolean expired = normalizedTime >= 1.0f;
mMore = !expired;
+ if (!mFillEnabled) normalizedTime = Math.max(Math.min(normalizedTime, 1.0f), 0.0f);
+
if ((normalizedTime >= 0.0f || mFillBefore) && (normalizedTime <= 1.0f || mFillAfter)) {
if (!mStarted) {
if (mListener != null) {
@@ -634,8 +671,7 @@ public abstract class Animation {
mStarted = true;
}
- // Pin time to 0.0 to 1.0 range
- normalizedTime = Math.max(Math.min(normalizedTime, 1.0f), 0.0f);
+ if (mFillEnabled) normalizedTime = Math.max(Math.min(normalizedTime, 1.0f), 0.0f);
if (mCycleFlip) {
normalizedTime = 1.0f - normalizedTime;
diff --git a/core/java/android/view/inputmethod/DefaultInputMethod.java b/core/java/android/view/inputmethod/DefaultInputMethod.java
index e92cbad..073b01c 100644
--- a/core/java/android/view/inputmethod/DefaultInputMethod.java
+++ b/core/java/android/view/inputmethod/DefaultInputMethod.java
@@ -98,7 +98,7 @@ public class DefaultInputMethod implements InputMethod, InputMethodSession {
public void hideSoftInput() {
}
- public void showSoftInput() {
+ public void showSoftInput(int flags) {
}
}
@@ -231,7 +231,7 @@ class SimpleInputMethod extends IInputMethod.Stub {
}
}
- public void showSoftInput() {
+ public void showSoftInput(boolean blah) {
}
public void hideSoftInput() {
diff --git a/core/java/android/view/inputmethod/InputMethod.java b/core/java/android/view/inputmethod/InputMethod.java
index ad61f94..c0e6590 100644
--- a/core/java/android/view/inputmethod/InputMethod.java
+++ b/core/java/android/view/inputmethod/InputMethod.java
@@ -165,9 +165,20 @@ public interface InputMethod {
public void revokeSession(InputMethodSession session);
/**
+ * Flag for {@link #showSoftInput(int)}: this show has been explicitly
+ * requested by the user. If not set, the system has decided it may be
+ * a good idea to show the input method based on a navigation operation
+ * in the UI.
+ */
+ public static final int SHOW_EXPLICIT = 0x00001;
+
+ /**
* Request that any soft input part of the input method be shown to the user.
+ *
+ * @param flags Provide additional information about the show request.
+ * Currently may be 0 or have the bit {@link #SHOW_EXPLICIT} set.
*/
- public void showSoftInput();
+ public void showSoftInput(int flags);
/**
* Request that any soft input part of the input method be hidden from the user.
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index a9c46c3..a676234 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -645,6 +645,13 @@ public final class InputMethodManager {
}
/**
+ * Flag for {@link #showSoftInput} to indicate that the this is an implicit
+ * request to show the input window, not as the result of a direct request
+ * by the user. The window may not be shown in this case.
+ */
+ public static final int SHOW_IMPLICIT = 0x0001;
+
+ /**
* Explicitly request that the current input method's soft input area be
* shown to the user, if needed. Call this if the user interacts with
* your view in such a way that they have expressed they would like to
@@ -652,21 +659,30 @@ public final class InputMethodManager {
*
* @param view The currently focused view, which would like to receive
* soft keyboard input.
+ * @param flags Provides additional operating flags. Currently may be
+ * 0 or have the {@link #SHOW_IMPLICIT} bit set.
*/
- public void showSoftInput(View view) {
+ public void showSoftInput(View view, int flags) {
synchronized (mH) {
if (mServedView != view) {
return;
}
try {
- mService.showSoftInput(mClient);
+ mService.showSoftInput(mClient, flags);
} catch (RemoteException e) {
}
}
}
/**
+ * Flag for {@link #hideSoftInputFromWindow} to indicate that the soft
+ * input window should only be hidden if it was not explicitly shown
+ * by the user.
+ */
+ public static final int HIDE_IMPLICIT_ONLY = 0x0001;
+
+ /**
* Request to hide the soft input window from the context of the window
* that is currently accepting input. This should be called as a result
* of the user doing some actually than fairly explicitly requests to
@@ -674,15 +690,17 @@ public final class InputMethodManager {
*
* @param windowToken The token of the window that is making the request,
* as returned by {@link View#getWindowToken() View.getWindowToken()}.
+ * @param flags Provides additional operating flags. Currently may be
+ * 0 or have the {@link #HIDE_IMPLICIT_ONLY} bit set.
*/
- public void hideSoftInputFromWindow(IBinder windowToken) {
+ public void hideSoftInputFromWindow(IBinder windowToken, int flags) {
synchronized (mH) {
if (mServedView == null || mServedView.getWindowToken() != windowToken) {
return;
}
try {
- mService.hideSoftInput(mClient);
+ mService.hideSoftInput(mClient, flags);
} catch (RemoteException e) {
}
}
@@ -880,13 +898,14 @@ public final class InputMethodManager {
void closeCurrentInput() {
try {
- mService.hideSoftInput(mClient);
+ mService.hideSoftInput(mClient, 0);
} catch (RemoteException e) {
}
}
/**
* Called by ViewRoot the first time it gets window focus.
+ * @hide
*/
public void onWindowFocus(View focusedView, int softInputMode,
boolean first, int windowFlags) {
@@ -896,8 +915,10 @@ public final class InputMethodManager {
+ " first=" + first + " flags=#"
+ Integer.toHexString(windowFlags));
try {
+ final boolean isTextEditor = focusedView != null &&
+ focusedView.onCheckIsTextEditor();
mService.windowGainedFocus(mClient, focusedView != null,
- softInputMode, first, windowFlags);
+ isTextEditor, softInputMode, first, windowFlags);
} catch (RemoteException e) {
}
}
@@ -987,13 +1008,16 @@ public final class InputMethodManager {
* Close/hide the input method's soft input area, so the user no longer
* sees it or can interact with it. This can only be called
* from the currently active input method, as validated by the given token.
+ *
* @param token Supplies the identifying token given to an input method
* when it was started, which allows it to perform this operation on
* itself.
+ * @param flags Provides additional operating flags. Currently may be
+ * 0 or have the {@link #HIDE_IMPLICIT_ONLY} bit set.
*/
- public void hideSoftInputFromInputMethod(IBinder token) {
+ public void hideSoftInputFromInputMethod(IBinder token, int flags) {
try {
- mService.hideMySoftInput(token);
+ mService.hideMySoftInput(token, flags);
} catch (RemoteException e) {
throw new RuntimeException(e);
}