auto import from //branches/cupcake/...@125939
diff --git a/src/com/android/browser/GearsBaseDialog.java b/src/com/android/browser/GearsBaseDialog.java
index c930dc8..afd0dd2 100644
--- a/src/com/android/browser/GearsBaseDialog.java
+++ b/src/com/android/browser/GearsBaseDialog.java
@@ -22,6 +22,9 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.style.UnderlineSpan;
import android.util.Log;
import android.view.InflateException;
import android.view.LayoutInflater;
@@ -145,11 +148,14 @@
*/
void setupButton(int buttonRscID,
int rscString,
- View.OnClickListener listener) {
+ View.OnClickListener listener,
+ boolean isLink,
+ boolean requestFocus) {
View view = findViewById(buttonRscID);
if (view == null) {
return;
}
+
Button button = (Button) view;
if (rscString == 0) {
@@ -158,10 +164,25 @@
CharSequence text = getString(rscString);
button.setText(text);
button.setOnClickListener(listener);
+ if (isLink) {
+ displayAsLink(button);
+ }
+ if (requestFocus) {
+ button.requestFocus();
+ }
}
}
/**
+ * Button setup: as the above method, except that 'isLink' and
+ * 'requestFocus' default to false.
+ */
+ void setupButton(int buttonRsc, int rsc,
+ View.OnClickListener listener) {
+ setupButton(buttonRsc, rsc, listener, false, false);
+ }
+
+ /**
* Utility method to setup the three dialog buttons.
*/
void setupButtons(int alwaysDenyRsc, int allowRsc, int denyRsc) {
@@ -170,14 +191,14 @@
public void onClick(View v) {
mHandler.sendEmptyMessage(ALWAYS_DENY);
}
- });
+ }, true, false);
setupButton(R.id.button_allow, allowRsc,
new Button.OnClickListener() {
public void onClick(View v) {
mHandler.sendEmptyMessage(ALLOW);
}
- });
+ }, false, true);
setupButton(R.id.button_deny, denyRsc,
new Button.OnClickListener() {
@@ -188,6 +209,26 @@
}
/**
+ * Display a button as an HTML link. Remove the background, set the
+ * text color to R.color.dialog_link and draw an underline
+ */
+ void displayAsLink(Button button) {
+ if (button == null) {
+ return;
+ }
+
+ CharSequence text = button.getText();
+ button.setBackgroundDrawable(null);
+ int color = getResources().getColor(R.color.dialog_link);
+ button.setTextColor(color);
+ SpannableString str = new SpannableString(text);
+ str.setSpan(new UnderlineSpan(), 0, str.length(),
+ Spannable.SPAN_INCLUSIVE_INCLUSIVE);
+ button.setText(str);
+ button.setFocusable(false);
+ }
+
+ /**
* Utility method to set elements' text indicated in
* the dialogs' arguments.
*/
@@ -332,5 +373,4 @@
setupDialog();
}
-
}