Merge "Clean up Dialog annotations, lint warnings, and declarations" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f04580852d
@@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
package android.app;
|
package android.app;
|
||||||
|
|
||||||
|
import com.android.internal.R;
|
||||||
|
import com.android.internal.app.WindowDecorActionBar;
|
||||||
|
import com.android.internal.policy.PhoneWindow;
|
||||||
|
|
||||||
import android.annotation.CallSuper;
|
import android.annotation.CallSuper;
|
||||||
import android.annotation.DrawableRes;
|
import android.annotation.DrawableRes;
|
||||||
import android.annotation.IdRes;
|
import android.annotation.IdRes;
|
||||||
@@ -56,12 +60,7 @@ import android.view.Window;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
|
||||||
import com.android.internal.R;
|
|
||||||
import com.android.internal.app.WindowDecorActionBar;
|
|
||||||
import com.android.internal.policy.PhoneWindow;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Dialogs.
|
* Base class for Dialogs.
|
||||||
@@ -94,10 +93,13 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
private static final String TAG = "Dialog";
|
private static final String TAG = "Dialog";
|
||||||
private Activity mOwnerActivity;
|
private Activity mOwnerActivity;
|
||||||
|
|
||||||
|
private final WindowManager mWindowManager;
|
||||||
|
|
||||||
final Context mContext;
|
final Context mContext;
|
||||||
final WindowManager mWindowManager;
|
final Window mWindow;
|
||||||
Window mWindow;
|
|
||||||
View mDecor;
|
View mDecor;
|
||||||
|
|
||||||
private ActionBar mActionBar;
|
private ActionBar mActionBar;
|
||||||
/**
|
/**
|
||||||
* This field should be made private, so it is hidden from the SDK.
|
* This field should be made private, so it is hidden from the SDK.
|
||||||
@@ -122,7 +124,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
private static final int CANCEL = 0x44;
|
private static final int CANCEL = 0x44;
|
||||||
private static final int SHOW = 0x45;
|
private static final int SHOW = 0x45;
|
||||||
|
|
||||||
private Handler mListenersHandler;
|
private final Handler mListenersHandler;
|
||||||
|
|
||||||
private SearchEvent mSearchEvent;
|
private SearchEvent mSearchEvent;
|
||||||
|
|
||||||
@@ -130,11 +132,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
|
|
||||||
private int mActionModeTypeStarting = ActionMode.TYPE_PRIMARY;
|
private int mActionModeTypeStarting = ActionMode.TYPE_PRIMARY;
|
||||||
|
|
||||||
private final Runnable mDismissAction = new Runnable() {
|
private final Runnable mDismissAction = this::dismissDialog;
|
||||||
public void run() {
|
|
||||||
dismissDialog();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a dialog window that uses the default dialog theme.
|
* Creates a dialog window that uses the default dialog theme.
|
||||||
@@ -197,14 +195,15 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected Dialog(@NonNull Context context, boolean cancelable, Message cancelCallback) {
|
protected Dialog(@NonNull Context context, boolean cancelable,
|
||||||
|
@Nullable Message cancelCallback) {
|
||||||
this(context);
|
this(context);
|
||||||
mCancelable = cancelable;
|
mCancelable = cancelable;
|
||||||
mCancelMessage = cancelCallback;
|
mCancelMessage = cancelCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Dialog(@NonNull Context context, boolean cancelable,
|
protected Dialog(@NonNull Context context, boolean cancelable,
|
||||||
OnCancelListener cancelListener) {
|
@Nullable OnCancelListener cancelListener) {
|
||||||
this(context);
|
this(context);
|
||||||
mCancelable = cancelable;
|
mCancelable = cancelable;
|
||||||
setOnCancelListener(cancelListener);
|
setOnCancelListener(cancelListener);
|
||||||
@@ -215,8 +214,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @return Context The Context used by the Dialog.
|
* @return Context The Context used by the Dialog.
|
||||||
*/
|
*/
|
||||||
@NonNull
|
public final @NonNull Context getContext() {
|
||||||
public final Context getContext() {
|
|
||||||
return mContext;
|
return mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +223,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @return The ActionBar attached to the dialog or null if no ActionBar is present.
|
* @return The ActionBar attached to the dialog or null if no ActionBar is present.
|
||||||
*/
|
*/
|
||||||
public ActionBar getActionBar() {
|
public @Nullable ActionBar getActionBar() {
|
||||||
return mActionBar;
|
return mActionBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +233,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @param activity The Activity that owns this dialog.
|
* @param activity The Activity that owns this dialog.
|
||||||
*/
|
*/
|
||||||
public final void setOwnerActivity(Activity activity) {
|
public final void setOwnerActivity(@NonNull Activity activity) {
|
||||||
mOwnerActivity = activity;
|
mOwnerActivity = activity;
|
||||||
|
|
||||||
getWindow().setVolumeControlStream(mOwnerActivity.getVolumeControlStream());
|
getWindow().setVolumeControlStream(mOwnerActivity.getVolumeControlStream());
|
||||||
@@ -249,7 +247,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @return The Activity that owns this Dialog.
|
* @return The Activity that owns this Dialog.
|
||||||
*/
|
*/
|
||||||
public final Activity getOwnerActivity() {
|
public final @Nullable Activity getOwnerActivity() {
|
||||||
return mOwnerActivity;
|
return mOwnerActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,13 +313,10 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
l = nl;
|
l = nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
mWindowManager.addView(mDecor, l);
|
||||||
mWindowManager.addView(mDecor, l);
|
mShowing = true;
|
||||||
mShowing = true;
|
|
||||||
|
|
||||||
sendShowMessage();
|
sendShowMessage();
|
||||||
} finally {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -387,7 +382,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal method to make sure mcreated is set properly without requiring
|
// internal method to make sure mCreated is set properly without requiring
|
||||||
// users to call through to super in onCreate
|
// users to call through to super in onCreate
|
||||||
void dispatchOnCreate(Bundle savedInstanceState) {
|
void dispatchOnCreate(Bundle savedInstanceState) {
|
||||||
if (!mCreated) {
|
if (!mCreated) {
|
||||||
@@ -399,7 +394,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* Similar to {@link Activity#onCreate}, you should initialize your dialog
|
* Similar to {@link Activity#onCreate}, you should initialize your dialog
|
||||||
* in this method, including calling {@link #setContentView}.
|
* in this method, including calling {@link #setContentView}.
|
||||||
* @param savedInstanceState If this dialog is being reinitalized after a
|
* @param savedInstanceState If this dialog is being reinitialized after a
|
||||||
* the hosting activity was previously shut down, holds the result from
|
* the hosting activity was previously shut down, holds the result from
|
||||||
* the most recent call to {@link #onSaveInstanceState}, or null if this
|
* the most recent call to {@link #onSaveInstanceState}, or null if this
|
||||||
* is the first time.
|
* is the first time.
|
||||||
@@ -432,7 +427,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* state.
|
* state.
|
||||||
* @return A bundle with the state of the dialog.
|
* @return A bundle with the state of the dialog.
|
||||||
*/
|
*/
|
||||||
public Bundle onSaveInstanceState() {
|
public @NonNull Bundle onSaveInstanceState() {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putBoolean(DIALOG_SHOWING_TAG, mShowing);
|
bundle.putBoolean(DIALOG_SHOWING_TAG, mShowing);
|
||||||
if (mCreated) {
|
if (mCreated) {
|
||||||
@@ -451,7 +446,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @param savedInstanceState The state of the dialog previously saved by
|
* @param savedInstanceState The state of the dialog previously saved by
|
||||||
* {@link #onSaveInstanceState()}.
|
* {@link #onSaveInstanceState()}.
|
||||||
*/
|
*/
|
||||||
public void onRestoreInstanceState(Bundle savedInstanceState) {
|
public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
|
||||||
final Bundle dialogHierarchyState = savedInstanceState.getBundle(DIALOG_HIERARCHY_TAG);
|
final Bundle dialogHierarchyState = savedInstanceState.getBundle(DIALOG_HIERARCHY_TAG);
|
||||||
if (dialogHierarchyState == null) {
|
if (dialogHierarchyState == null) {
|
||||||
// dialog has never been shown, or onCreated, nothing to restore.
|
// dialog has never been shown, or onCreated, nothing to restore.
|
||||||
@@ -472,7 +467,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @return Window The current window, or null if the activity is not
|
* @return Window The current window, or null if the activity is not
|
||||||
* visual.
|
* visual.
|
||||||
*/
|
*/
|
||||||
public Window getWindow() {
|
public @Nullable Window getWindow() {
|
||||||
return mWindow;
|
return mWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,7 +480,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @see #getWindow
|
* @see #getWindow
|
||||||
* @see android.view.Window#getCurrentFocus
|
* @see android.view.Window#getCurrentFocus
|
||||||
*/
|
*/
|
||||||
public View getCurrentFocus() {
|
public @Nullable View getCurrentFocus() {
|
||||||
return mWindow != null ? mWindow.getCurrentFocus() : null;
|
return mWindow != null ? mWindow.getCurrentFocus() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,8 +492,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @param id the identifier of the view to find
|
* @param id the identifier of the view to find
|
||||||
* @return The view with the given id or null.
|
* @return The view with the given id or null.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
public @Nullable View findViewById(@IdRes int id) {
|
||||||
public View findViewById(@IdRes int id) {
|
|
||||||
return mWindow.findViewById(id);
|
return mWindow.findViewById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,19 +513,19 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @param view The desired content to display.
|
* @param view The desired content to display.
|
||||||
*/
|
*/
|
||||||
public void setContentView(View view) {
|
public void setContentView(@NonNull View view) {
|
||||||
mWindow.setContentView(view);
|
mWindow.setContentView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the screen content to an explicit view. This view is placed
|
* Set the screen content to an explicit view. This view is placed
|
||||||
* directly into the screen's view hierarchy. It can itself be a complex
|
* directly into the screen's view hierarchy. It can itself be a complex
|
||||||
* view hierarhcy.
|
* view hierarchy.
|
||||||
*
|
*
|
||||||
* @param view The desired content to display.
|
* @param view The desired content to display.
|
||||||
* @param params Layout parameters for the view.
|
* @param params Layout parameters for the view.
|
||||||
*/
|
*/
|
||||||
public void setContentView(View view, ViewGroup.LayoutParams params) {
|
public void setContentView(@NonNull View view, @Nullable ViewGroup.LayoutParams params) {
|
||||||
mWindow.setContentView(view, params);
|
mWindow.setContentView(view, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,7 +536,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @param view The desired content to display.
|
* @param view The desired content to display.
|
||||||
* @param params Layout parameters for the view.
|
* @param params Layout parameters for the view.
|
||||||
*/
|
*/
|
||||||
public void addContentView(View view, ViewGroup.LayoutParams params) {
|
public void addContentView(@NonNull View view, @Nullable ViewGroup.LayoutParams params) {
|
||||||
mWindow.addContentView(view, params);
|
mWindow.addContentView(view, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,7 +545,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @param title The new text to display in the title.
|
* @param title The new text to display in the title.
|
||||||
*/
|
*/
|
||||||
public void setTitle(CharSequence title) {
|
public void setTitle(@Nullable CharSequence title) {
|
||||||
mWindow.setTitle(title);
|
mWindow.setTitle(title);
|
||||||
mWindow.getAttributes().setTitle(title);
|
mWindow.getAttributes().setTitle(title);
|
||||||
}
|
}
|
||||||
@@ -577,7 +571,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @see #onKeyUp
|
* @see #onKeyUp
|
||||||
* @see android.view.KeyEvent
|
* @see android.view.KeyEvent
|
||||||
*/
|
*/
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
event.startTracking();
|
event.startTracking();
|
||||||
return true;
|
return true;
|
||||||
@@ -591,7 +586,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* KeyEvent.Callback.onKeyLongPress()}: always returns false (doesn't handle
|
* KeyEvent.Callback.onKeyLongPress()}: always returns false (doesn't handle
|
||||||
* the event).
|
* the event).
|
||||||
*/
|
*/
|
||||||
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
@Override
|
||||||
|
public boolean onKeyLongPress(int keyCode, @NonNull KeyEvent event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,7 +600,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @see #onKeyDown
|
* @see #onKeyDown
|
||||||
* @see KeyEvent
|
* @see KeyEvent
|
||||||
*/
|
*/
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
@Override
|
||||||
|
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
|
||||||
&& !event.isCanceled()) {
|
&& !event.isCanceled()) {
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
@@ -618,7 +615,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* KeyEvent.Callback.onKeyMultiple()}: always returns false (doesn't handle
|
* KeyEvent.Callback.onKeyMultiple()}: always returns false (doesn't handle
|
||||||
* the event).
|
* the event).
|
||||||
*/
|
*/
|
||||||
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
|
@Override
|
||||||
|
public boolean onKeyMultiple(int keyCode, int repeatCount, @NonNull KeyEvent event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -643,7 +641,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @param event Description of the key event.
|
* @param event Description of the key event.
|
||||||
* @return True if the key shortcut was handled.
|
* @return True if the key shortcut was handled.
|
||||||
*/
|
*/
|
||||||
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
|
public boolean onKeyShortcut(int keyCode, @NonNull KeyEvent event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,7 +655,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* The default implementation will cancel the dialog when a touch
|
* The default implementation will cancel the dialog when a touch
|
||||||
* happens outside of the window bounds.
|
* happens outside of the window bounds.
|
||||||
*/
|
*/
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(@NonNull MotionEvent event) {
|
||||||
if (mCancelable && mShowing && mWindow.shouldCloseOnTouch(mContext, event)) {
|
if (mCancelable && mShowing && mWindow.shouldCloseOnTouch(mContext, event)) {
|
||||||
cancel();
|
cancel();
|
||||||
return true;
|
return true;
|
||||||
@@ -680,7 +678,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @return Return true if you have consumed the event, false if you haven't.
|
* @return Return true if you have consumed the event, false if you haven't.
|
||||||
* The default implementation always returns false.
|
* The default implementation always returns false.
|
||||||
*/
|
*/
|
||||||
public boolean onTrackballEvent(MotionEvent event) {
|
public boolean onTrackballEvent(@NonNull MotionEvent event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,25 +707,30 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @return Return true if you have consumed the event, false if you haven't.
|
* @return Return true if you have consumed the event, false if you haven't.
|
||||||
* The default implementation always returns false.
|
* The default implementation always returns false.
|
||||||
*/
|
*/
|
||||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
public boolean onGenericMotionEvent(@NonNull MotionEvent event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
|
public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
|
||||||
if (mDecor != null) {
|
if (mDecor != null) {
|
||||||
mWindowManager.updateViewLayout(mDecor, params);
|
mWindowManager.updateViewLayout(mDecor, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onContentChanged() {
|
public void onContentChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onWindowFocusChanged(boolean hasFocus) {
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onAttachedToWindow() {
|
public void onAttachedToWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onDetachedFromWindow() {
|
public void onDetachedFromWindow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,7 +749,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @return boolean Return true if this event was consumed.
|
* @return boolean Return true if this event was consumed.
|
||||||
*/
|
*/
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
@Override
|
||||||
|
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
|
||||||
if ((mOnKeyListener != null) && (mOnKeyListener.onKey(this, event.getKeyCode(), event))) {
|
if ((mOnKeyListener != null) && (mOnKeyListener.onKey(this, event.getKeyCode(), event))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -766,7 +770,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @param event The key shortcut event.
|
* @param event The key shortcut event.
|
||||||
* @return True if this event was consumed.
|
* @return True if this event was consumed.
|
||||||
*/
|
*/
|
||||||
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
|
@Override
|
||||||
|
public boolean dispatchKeyShortcutEvent(@NonNull KeyEvent event) {
|
||||||
if (mWindow.superDispatchKeyShortcutEvent(event)) {
|
if (mWindow.superDispatchKeyShortcutEvent(event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -783,7 +788,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @return boolean Return true if this event was consumed.
|
* @return boolean Return true if this event was consumed.
|
||||||
*/
|
*/
|
||||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
@Override
|
||||||
|
public boolean dispatchTouchEvent(@NonNull MotionEvent ev) {
|
||||||
if (mWindow.superDispatchTouchEvent(ev)) {
|
if (mWindow.superDispatchTouchEvent(ev)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -800,7 +806,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @return boolean Return true if this event was consumed.
|
* @return boolean Return true if this event was consumed.
|
||||||
*/
|
*/
|
||||||
public boolean dispatchTrackballEvent(MotionEvent ev) {
|
@Override
|
||||||
|
public boolean dispatchTrackballEvent(@NonNull MotionEvent ev) {
|
||||||
if (mWindow.superDispatchTrackballEvent(ev)) {
|
if (mWindow.superDispatchTrackballEvent(ev)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -817,14 +824,16 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @return boolean Return true if this event was consumed.
|
* @return boolean Return true if this event was consumed.
|
||||||
*/
|
*/
|
||||||
public boolean dispatchGenericMotionEvent(MotionEvent ev) {
|
@Override
|
||||||
|
public boolean dispatchGenericMotionEvent(@NonNull MotionEvent ev) {
|
||||||
if (mWindow.superDispatchGenericMotionEvent(ev)) {
|
if (mWindow.superDispatchGenericMotionEvent(ev)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return onGenericMotionEvent(ev);
|
return onGenericMotionEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
@Override
|
||||||
|
public boolean dispatchPopulateAccessibilityEvent(@NonNull AccessibilityEvent event) {
|
||||||
event.setClassName(getClass().getName());
|
event.setClassName(getClass().getName());
|
||||||
event.setPackageName(mContext.getPackageName());
|
event.setPackageName(mContext.getPackageName());
|
||||||
|
|
||||||
@@ -839,6 +848,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* @see Activity#onCreatePanelView(int)
|
* @see Activity#onCreatePanelView(int)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public View onCreatePanelView(int featureId) {
|
public View onCreatePanelView(int featureId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -846,7 +856,8 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* @see Activity#onCreatePanelMenu(int, Menu)
|
* @see Activity#onCreatePanelMenu(int, Menu)
|
||||||
*/
|
*/
|
||||||
public boolean onCreatePanelMenu(int featureId, Menu menu) {
|
@Override
|
||||||
|
public boolean onCreatePanelMenu(int featureId, @NonNull Menu menu) {
|
||||||
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
|
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
|
||||||
return onCreateOptionsMenu(menu);
|
return onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
@@ -857,10 +868,10 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* @see Activity#onPreparePanel(int, View, Menu)
|
* @see Activity#onPreparePanel(int, View, Menu)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onPreparePanel(int featureId, View view, Menu menu) {
|
public boolean onPreparePanel(int featureId, View view, Menu menu) {
|
||||||
if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) {
|
if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) {
|
||||||
boolean goforit = onPrepareOptionsMenu(menu);
|
return onPrepareOptionsMenu(menu) && menu.hasVisibleItems();
|
||||||
return goforit && menu.hasVisibleItems();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -868,6 +879,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* @see Activity#onMenuOpened(int, Menu)
|
* @see Activity#onMenuOpened(int, Menu)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onMenuOpened(int featureId, Menu menu) {
|
public boolean onMenuOpened(int featureId, Menu menu) {
|
||||||
if (featureId == Window.FEATURE_ACTION_BAR) {
|
if (featureId == Window.FEATURE_ACTION_BAR) {
|
||||||
mActionBar.dispatchMenuVisibilityChanged(true);
|
mActionBar.dispatchMenuVisibilityChanged(true);
|
||||||
@@ -878,6 +890,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* @see Activity#onMenuItemSelected(int, MenuItem)
|
* @see Activity#onMenuItemSelected(int, MenuItem)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -885,6 +898,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* @see Activity#onPanelClosed(int, Menu)
|
* @see Activity#onPanelClosed(int, Menu)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onPanelClosed(int featureId, Menu menu) {
|
public void onPanelClosed(int featureId, Menu menu) {
|
||||||
if (featureId == Window.FEATURE_ACTION_BAR) {
|
if (featureId == Window.FEATURE_ACTION_BAR) {
|
||||||
mActionBar.dispatchMenuVisibilityChanged(false);
|
mActionBar.dispatchMenuVisibilityChanged(false);
|
||||||
@@ -899,7 +913,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @see Activity#onCreateOptionsMenu(Menu)
|
* @see Activity#onCreateOptionsMenu(Menu)
|
||||||
* @see #getOwnerActivity()
|
* @see #getOwnerActivity()
|
||||||
*/
|
*/
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,21 +925,21 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @see Activity#onPrepareOptionsMenu(Menu)
|
* @see Activity#onPrepareOptionsMenu(Menu)
|
||||||
* @see #getOwnerActivity()
|
* @see #getOwnerActivity()
|
||||||
*/
|
*/
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
public boolean onPrepareOptionsMenu(@NonNull Menu menu) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Activity#onOptionsItemSelected(MenuItem)
|
* @see Activity#onOptionsItemSelected(MenuItem)
|
||||||
*/
|
*/
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Activity#onOptionsMenuClosed(Menu)
|
* @see Activity#onOptionsMenuClosed(Menu)
|
||||||
*/
|
*/
|
||||||
public void onOptionsMenuClosed(Menu menu) {
|
public void onOptionsMenuClosed(@NonNull Menu menu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -958,47 +972,49 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* @see Activity#onCreateContextMenu(ContextMenu, View, ContextMenuInfo)
|
* @see Activity#onCreateContextMenu(ContextMenu, View, ContextMenuInfo)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Activity#registerForContextMenu(View)
|
* @see Activity#registerForContextMenu(View)
|
||||||
*/
|
*/
|
||||||
public void registerForContextMenu(View view) {
|
public void registerForContextMenu(@NonNull View view) {
|
||||||
view.setOnCreateContextMenuListener(this);
|
view.setOnCreateContextMenuListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Activity#unregisterForContextMenu(View)
|
* @see Activity#unregisterForContextMenu(View)
|
||||||
*/
|
*/
|
||||||
public void unregisterForContextMenu(View view) {
|
public void unregisterForContextMenu(@NonNull View view) {
|
||||||
view.setOnCreateContextMenuListener(null);
|
view.setOnCreateContextMenuListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Activity#openContextMenu(View)
|
* @see Activity#openContextMenu(View)
|
||||||
*/
|
*/
|
||||||
public void openContextMenu(View view) {
|
public void openContextMenu(@NonNull View view) {
|
||||||
view.showContextMenu();
|
view.showContextMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Activity#onContextItemSelected(MenuItem)
|
* @see Activity#onContextItemSelected(MenuItem)
|
||||||
*/
|
*/
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(@NonNull MenuItem item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Activity#onContextMenuClosed(Menu)
|
* @see Activity#onContextMenuClosed(Menu)
|
||||||
*/
|
*/
|
||||||
public void onContextMenuClosed(Menu menu) {
|
public void onContextMenuClosed(@NonNull Menu menu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This hook is called when the user signals the desire to start a search.
|
* This hook is called when the user signals the desire to start a search.
|
||||||
*/
|
*/
|
||||||
public boolean onSearchRequested(SearchEvent searchEvent) {
|
@Override
|
||||||
|
public boolean onSearchRequested(@NonNull SearchEvent searchEvent) {
|
||||||
mSearchEvent = searchEvent;
|
mSearchEvent = searchEvent;
|
||||||
return onSearchRequested();
|
return onSearchRequested();
|
||||||
}
|
}
|
||||||
@@ -1006,6 +1022,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* This hook is called when the user signals the desire to start a search.
|
* This hook is called when the user signals the desire to start a search.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onSearchRequested() {
|
public boolean onSearchRequested() {
|
||||||
final SearchManager searchManager = (SearchManager) mContext
|
final SearchManager searchManager = (SearchManager) mContext
|
||||||
.getSystemService(Context.SEARCH_SERVICE);
|
.getSystemService(Context.SEARCH_SERVICE);
|
||||||
@@ -1028,13 +1045,10 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @return SearchEvent The SearchEvent that triggered the {@link
|
* @return SearchEvent The SearchEvent that triggered the {@link
|
||||||
* #onSearchRequested} callback.
|
* #onSearchRequested} callback.
|
||||||
*/
|
*/
|
||||||
public final SearchEvent getSearchEvent() {
|
public final @Nullable SearchEvent getSearchEvent() {
|
||||||
return mSearchEvent;
|
return mSearchEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
|
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback) {
|
||||||
if (mActionBar != null && mActionModeTypeStarting == ActionMode.TYPE_PRIMARY) {
|
if (mActionBar != null && mActionModeTypeStarting == ActionMode.TYPE_PRIMARY) {
|
||||||
@@ -1043,9 +1057,6 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
|
public ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type) {
|
||||||
try {
|
try {
|
||||||
@@ -1062,6 +1073,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* Note that if you override this method you should always call through
|
* Note that if you override this method you should always call through
|
||||||
* to the superclass implementation by calling super.onActionModeStarted(mode).
|
* to the superclass implementation by calling super.onActionModeStarted(mode).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void onActionModeStarted(ActionMode mode) {
|
public void onActionModeStarted(ActionMode mode) {
|
||||||
mActionMode = mode;
|
mActionMode = mode;
|
||||||
@@ -1073,6 +1085,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* Note that if you override this method you should always call through
|
* Note that if you override this method you should always call through
|
||||||
* to the superclass implementation by calling super.onActionModeFinished(mode).
|
* to the superclass implementation by calling super.onActionModeFinished(mode).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void onActionModeFinished(ActionMode mode) {
|
public void onActionModeFinished(ActionMode mode) {
|
||||||
if (mode == mActionMode) {
|
if (mode == mActionMode) {
|
||||||
@@ -1138,7 +1151,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* Convenience for calling
|
* Convenience for calling
|
||||||
* {@link android.view.Window#setFeatureDrawableUri}.
|
* {@link android.view.Window#setFeatureDrawableUri}.
|
||||||
*/
|
*/
|
||||||
public final void setFeatureDrawableUri(int featureId, Uri uri) {
|
public final void setFeatureDrawableUri(int featureId, @Nullable Uri uri) {
|
||||||
getWindow().setFeatureDrawableUri(featureId, uri);
|
getWindow().setFeatureDrawableUri(featureId, uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1146,7 +1159,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* Convenience for calling
|
* Convenience for calling
|
||||||
* {@link android.view.Window#setFeatureDrawable(int, Drawable)}.
|
* {@link android.view.Window#setFeatureDrawable(int, Drawable)}.
|
||||||
*/
|
*/
|
||||||
public final void setFeatureDrawable(int featureId, Drawable drawable) {
|
public final void setFeatureDrawable(int featureId, @Nullable Drawable drawable) {
|
||||||
getWindow().setFeatureDrawable(featureId, drawable);
|
getWindow().setFeatureDrawable(featureId, drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1158,7 +1171,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
getWindow().setFeatureDrawableAlpha(featureId, alpha);
|
getWindow().setFeatureDrawableAlpha(featureId, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LayoutInflater getLayoutInflater() {
|
public @NonNull LayoutInflater getLayoutInflater() {
|
||||||
return getWindow().getLayoutInflater();
|
return getWindow().getLayoutInflater();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1190,6 +1203,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* Cancel the dialog. This is essentially the same as calling {@link #dismiss()}, but it will
|
* Cancel the dialog. This is essentially the same as calling {@link #dismiss()}, but it will
|
||||||
* also call your {@link DialogInterface.OnCancelListener} (if registered).
|
* also call your {@link DialogInterface.OnCancelListener} (if registered).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
if (!mCanceled && mCancelMessage != null) {
|
if (!mCanceled && mCancelMessage != null) {
|
||||||
mCanceled = true;
|
mCanceled = true;
|
||||||
@@ -1210,7 +1224,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
*
|
*
|
||||||
* @param listener The {@link DialogInterface.OnCancelListener} to use.
|
* @param listener The {@link DialogInterface.OnCancelListener} to use.
|
||||||
*/
|
*/
|
||||||
public void setOnCancelListener(final OnCancelListener listener) {
|
public void setOnCancelListener(@Nullable OnCancelListener listener) {
|
||||||
if (mCancelAndDismissTaken != null) {
|
if (mCancelAndDismissTaken != null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"OnCancelListener is already taken by "
|
"OnCancelListener is already taken by "
|
||||||
@@ -1228,7 +1242,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* @param msg The msg to send when the dialog is canceled.
|
* @param msg The msg to send when the dialog is canceled.
|
||||||
* @see #setOnCancelListener(android.content.DialogInterface.OnCancelListener)
|
* @see #setOnCancelListener(android.content.DialogInterface.OnCancelListener)
|
||||||
*/
|
*/
|
||||||
public void setCancelMessage(final Message msg) {
|
public void setCancelMessage(@Nullable Message msg) {
|
||||||
mCancelMessage = msg;
|
mCancelMessage = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1236,7 +1250,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* Set a listener to be invoked when the dialog is dismissed.
|
* Set a listener to be invoked when the dialog is dismissed.
|
||||||
* @param listener The {@link DialogInterface.OnDismissListener} to use.
|
* @param listener The {@link DialogInterface.OnDismissListener} to use.
|
||||||
*/
|
*/
|
||||||
public void setOnDismissListener(final OnDismissListener listener) {
|
public void setOnDismissListener(@Nullable OnDismissListener listener) {
|
||||||
if (mCancelAndDismissTaken != null) {
|
if (mCancelAndDismissTaken != null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"OnDismissListener is already taken by "
|
"OnDismissListener is already taken by "
|
||||||
@@ -1253,7 +1267,7 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* Sets a listener to be invoked when the dialog is shown.
|
* Sets a listener to be invoked when the dialog is shown.
|
||||||
* @param listener The {@link DialogInterface.OnShowListener} to use.
|
* @param listener The {@link DialogInterface.OnShowListener} to use.
|
||||||
*/
|
*/
|
||||||
public void setOnShowListener(OnShowListener listener) {
|
public void setOnShowListener(@Nullable OnShowListener listener) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
mShowMessage = mListenersHandler.obtainMessage(SHOW, listener);
|
mShowMessage = mListenersHandler.obtainMessage(SHOW, listener);
|
||||||
} else {
|
} else {
|
||||||
@@ -1265,13 +1279,13 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
* Set a message to be sent when the dialog is dismissed.
|
* Set a message to be sent when the dialog is dismissed.
|
||||||
* @param msg The msg to send when the dialog is dismissed.
|
* @param msg The msg to send when the dialog is dismissed.
|
||||||
*/
|
*/
|
||||||
public void setDismissMessage(final Message msg) {
|
public void setDismissMessage(@Nullable Message msg) {
|
||||||
mDismissMessage = msg;
|
mDismissMessage = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public boolean takeCancelAndDismissListeners(String msg, final OnCancelListener cancel,
|
public boolean takeCancelAndDismissListeners(@Nullable String msg,
|
||||||
final OnDismissListener dismiss) {
|
@Nullable OnCancelListener cancel, @Nullable OnDismissListener dismiss) {
|
||||||
if (mCancelAndDismissTaken != null) {
|
if (mCancelAndDismissTaken != null) {
|
||||||
mCancelAndDismissTaken = null;
|
mCancelAndDismissTaken = null;
|
||||||
} else if (mCancelMessage != null || mDismissMessage != null) {
|
} else if (mCancelMessage != null || mDismissMessage != null) {
|
||||||
@@ -1305,15 +1319,15 @@ public class Dialog implements DialogInterface, Window.Callback,
|
|||||||
/**
|
/**
|
||||||
* Sets the callback that will be called if a key is dispatched to the dialog.
|
* Sets the callback that will be called if a key is dispatched to the dialog.
|
||||||
*/
|
*/
|
||||||
public void setOnKeyListener(final OnKeyListener onKeyListener) {
|
public void setOnKeyListener(@Nullable OnKeyListener onKeyListener) {
|
||||||
mOnKeyListener = onKeyListener;
|
mOnKeyListener = onKeyListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class ListenersHandler extends Handler {
|
private static final class ListenersHandler extends Handler {
|
||||||
private WeakReference<DialogInterface> mDialog;
|
private final WeakReference<DialogInterface> mDialog;
|
||||||
|
|
||||||
public ListenersHandler(Dialog dialog) {
|
public ListenersHandler(Dialog dialog) {
|
||||||
mDialog = new WeakReference<DialogInterface>(dialog);
|
mDialog = new WeakReference<>(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user