Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java

Issue 1653533002: bluetooth: Change the status of the chooser once discovery has ended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Improve test and add new test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 d0320bc7028c3077f6084972e5ed57b6230a8ef5..0c0bf406909c0da92ec7da61be5f70e61ac6c6f1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ItemChooserDialog.java
@@ -74,21 +74,26 @@ public class ItemChooserDialog {
public static class ItemChooserLabels {
// The title at the top of the dialog.
public final SpannableString mTitle;
- // The message to show while results are trickling in.
+ // The message to show while there are no results.
Finnur 2016/02/01 12:16:43 This comment that you are changing was carefully w
ortuno 2016/02/01 17:00:31 Interesting, that's not how it's implemented right
Finnur 2016/02/02 17:02:52 OK, the implementation probably changed so the com
public final String mSearching;
// The message to show when no results were produced.
public final SpannableString mNoneFound;
- // A status message to show above the button row.
- public final SpannableString mStatus;
+ // A status message to show above the button row after an item has
+ // been added and discovery is still ongoing.
+ public final SpannableString mStatusActive;
+ // A status message to show above the button row after an item has
+ // been added and discovery has stopped.
+ public final SpannableString mStatusIdle;
// The label for the positive button (e.g. Select/Pair).
public final String mPositiveButton;
public ItemChooserLabels(SpannableString title, String searching, SpannableString noneFound,
- SpannableString status, String positiveButton) {
+ SpannableString statusActive, SpannableString statusIdle, String positiveButton) {
mTitle = title;
mSearching = searching;
mNoneFound = noneFound;
- mStatus = status;
+ mStatusActive = statusActive;
+ mStatusIdle = statusIdle;
mPositiveButton = positiveButton;
}
}
@@ -96,10 +101,7 @@ public class ItemChooserDialog {
/**
* The various states the dialog can represent.
*/
- private enum State {
- STARTING,
- PROGRESS_UPDATE_AVAILABLE,
- }
+ private enum State { STARTING, PROGRESS_UPDATE_AVAILABLE, DISCOVERY_IDLE }
/**
* An adapter for keeping track of which items to show in the dialog.
@@ -346,12 +348,11 @@ public class ItemChooserDialog {
/**
* Add items to show in the dialog.
*
- * @param list The list of items to show. This function can be called
- * multiple times to add more items and new items will be appended to
- * the end of the list. An empty list should be used if there are no
- * items to show.
+ * @param list The list of items to add to the chooser. This function can be
+ * called multiple times to add more items and new items will be appended to
+ * the end of the list.
*/
- public void showList(List<ItemChooserRow> list) {
+ public void addItemsToList(List<ItemChooserRow> list) {
mProgressBar.setVisibility(View.GONE);
if (!list.isEmpty()) {
@@ -361,6 +362,14 @@ public class ItemChooserDialog {
}
/**
+ * Indicates the chooser that no more items will be added.
+ */
+ public void discoveryIdle() {
+ mProgressBar.setVisibility(View.GONE);
+ setState(State.DISCOVERY_IDLE);
+ }
+
+ /**
* Sets whether the item is enabled.
* @param id The id of the item to affect.
* @param enabled Whether the item should be enabled or not.
@@ -397,13 +406,15 @@ public class ItemChooserDialog {
mEmptyMessage.setVisibility(View.GONE);
break;
case PROGRESS_UPDATE_AVAILABLE:
- mStatus.setText(mLabels.mStatus);
+ mStatus.setText(mLabels.mStatusActive);
mProgressBar.setVisibility(View.GONE);
mListView.setVisibility(View.VISIBLE);
-
+ break;
+ case DISCOVERY_IDLE:
boolean showEmptyMessage = mItemAdapter.isEmpty();
mEmptyMessage.setText(mLabels.mNoneFound);
mEmptyMessage.setVisibility(showEmptyMessage ? View.VISIBLE : View.GONE);
+ mStatus.setText(mLabels.mStatusIdle);
break;
}
}

Powered by Google App Engine
This is Rietveld 408576698