Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java |
| index b71813ac54578667f7a1eb69654fe357ffb28b7a..c3eddf8a7cbb92f22662aff2c253af62c3f5c422 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java |
| @@ -10,7 +10,6 @@ import android.content.Context; |
| import android.content.DialogInterface; |
| import android.graphics.Color; |
| import android.graphics.drawable.ColorDrawable; |
| -import android.text.SpannableString; |
| import android.text.TextUtils; |
| import android.text.method.LinkMovementMethod; |
| import android.view.Gravity; |
| @@ -367,6 +366,9 @@ public class ItemChooserDialog { |
| // The maximum height of the listview in the dialog (in dp). |
| private static final int MAX_HEIGHT_DP = (int) (LIST_ROW_HEIGHT_DP * 8.5); |
| + // Whether the window should be closed when it loses focus. |
| + private boolean mCloseWindowWhenLoseFocus; |
| + |
| /** |
| * Creates the ItemChooserPopup and displays it (and starts waiting for data). |
| * |
| @@ -426,9 +428,15 @@ public class ItemChooserDialog { |
| getListHeight(mActivity.getWindow().getDecorView().getHeight(), |
| mActivity.getResources().getDisplayMetrics().density))); |
| + mCloseWindowWhenLoseFocus = true; |
| + |
| showDialogForView(dialogContainer); |
| } |
| + public void setCloseWindowWhenLoseFocus(boolean closeWindowWhenLoseFocus) { |
|
Ted C
2017/01/13 16:24:03
javadoc for public apis.
While I agree this inter
|
| + mCloseWindowWhenLoseFocus = closeWindowWhenLoseFocus; |
| + } |
| + |
| // Computes the height of the device list, bound to half-multiples of the |
| // row height so that it's obvious if there are more elements to scroll to. |
| @VisibleForTesting |
| @@ -445,7 +453,8 @@ public class ItemChooserDialog { |
| @Override |
| public void onWindowFocusChanged(boolean hasFocus) { |
| super.onWindowFocusChanged(hasFocus); |
| - if (!hasFocus) super.dismiss(); |
| + if (mCloseWindowWhenLoseFocus && !hasFocus) super.dismiss(); |
| + setCloseWindowWhenLoseFocus(true); |
| } |
| }; |
| mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); |
| @@ -528,7 +537,7 @@ public class ItemChooserDialog { |
| /** |
| * Shows an error message in the dialog. |
| */ |
| - public void setErrorState(SpannableString errorMessage, SpannableString errorStatus) { |
| + public void setErrorState(CharSequence errorMessage, CharSequence errorStatus) { |
| mListView.setVisibility(View.GONE); |
| mProgressBar.setVisibility(View.GONE); |
| mEmptyMessage.setText(errorMessage); |