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

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

Issue 2247633002: Keep "Add" button in "Add to Homescreen" dialog disabled till launcher icon is fetched (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into webapk_dialog_detector0 Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java
index 7d46b67c73e07a7bc5ad52479b9b09f14535cbdf..49b3aa251dc25e8470226600f7b72b0c764239e6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/AddToHomescreenDialog.java
@@ -95,7 +95,7 @@ public class AddToHomescreenDialog {
progressBarView.setVisibility(View.GONE);
iconView.setVisibility(View.VISIBLE);
iconView.setImageBitmap(icon);
- dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(true);
+ updateAddButtonEnabledState(dialog, dialogHelper, input);
}
});
@@ -110,11 +110,7 @@ public class AddToHomescreenDialog {
@Override
public void afterTextChanged(Editable editableText) {
- if (TextUtils.isEmpty(editableText)) {
- dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
- } else {
- dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(true);
- }
+ updateAddButtonEnabledState(dialog, dialogHelper, input);
}
});
@@ -133,8 +129,7 @@ public class AddToHomescreenDialog {
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface d) {
- dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(
- dialogHelper.isInitialized());
+ updateAddButtonEnabledState(dialog, dialogHelper, input);
}
});
@@ -150,4 +145,16 @@ public class AddToHomescreenDialog {
dialog.show();
}
+
+ /**
+ * Updates whether the dialog's OK button is enabled.
+ * @param dialog The dialog whose "OK" button to enable or disable.
+ * @param helper
+ * @param input The dialog's text field.
+ */
+ public static void updateAddButtonEnabledState(
+ AlertDialog dialog, AddToHomescreenDialogHelper helper, EditText input) {
+ boolean enable = helper.isInitialized() && !TextUtils.isEmpty(input.getText());
+ dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(enable);
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698