Merge change 24688 into eclair
* changes:
Adjustments for the look of the tab page.
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 7e0db56..7e0f93d 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -960,6 +960,14 @@
}
mCredsDlg = null;
+ // FIXME: This removes the active tabs page and resets the menu to
+ // MAIN_MENU. A better solution might be to do this work in onNewIntent
+ // but then we would need to save it in onSaveInstanceState and restore
+ // it in onCreate/onRestoreInstanceState
+ if (mActiveTabsPage != null) {
+ removeActiveTabPage(true);
+ }
+
cancelStopToast();
// unregister network state listener
diff --git a/src/com/android/browser/BrowserHomepagePreference.java b/src/com/android/browser/BrowserHomepagePreference.java
index 7324f24..be96db3 100644
--- a/src/com/android/browser/BrowserHomepagePreference.java
+++ b/src/com/android/browser/BrowserHomepagePreference.java
@@ -18,47 +18,46 @@
import android.app.AlertDialog;
import android.content.Context;
-import android.content.DialogInterface;
import android.preference.EditTextPreference;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.text.util.Regex;
import android.util.AttributeSet;
-public class BrowserHomepagePreference extends EditTextPreference implements
- TextWatcher {
+public class BrowserHomepagePreference extends EditTextPreference {
public BrowserHomepagePreference(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
- getEditText().addTextChangedListener(this);
}
public BrowserHomepagePreference(Context context, AttributeSet attrs) {
super(context, attrs);
- getEditText().addTextChangedListener(this);
}
public BrowserHomepagePreference(Context context) {
super(context);
- getEditText().addTextChangedListener(this);
}
- public void afterTextChanged(Editable s) {
- AlertDialog dialog = (AlertDialog) getDialog();
- // This callback is called before the dialog has been fully constructed
- if (dialog != null) {
- String url = s.toString();
- dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(
- url.length() == 0 ||
- BrowserActivity.ACCEPTED_URI_SCHEMA.matcher(url).matches());
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ if (positiveResult) {
+ String url = getEditText().getText().toString();
+ if (url.length() > 0
+ && !BrowserActivity.ACCEPTED_URI_SCHEMA.matcher(url)
+ .matches()) {
+ int colon = url.indexOf(':');
+ int space = url.indexOf(' ');
+ if (colon == -1 && space == -1) {
+ // if no colon, no space, add "http://" to make it a url
+ getEditText().setText("http://" + url);
+ } else {
+ // show an error dialog and change the positiveResult to
+ // false so that the bad url will not override the old url
+ new AlertDialog.Builder(this.getContext()).setMessage(
+ R.string.bookmark_url_not_valid).setPositiveButton(
+ R.string.ok, null).show();
+ positiveResult = false;
+ }
+ }
}
- }
-
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
- }
-
- public void onTextChanged(CharSequence s, int start, int before, int count) {
+ super.onDialogClosed(positiveResult);
}
}