Merge "Updates to the add bookmark dialog."
diff --git a/res/drawable-hdpi/ic_launcher_browser.png b/res/drawable-hdpi/ic_launcher_browser.png
index cdce53e..2ca92c8 100644
--- a/res/drawable-hdpi/ic_launcher_browser.png
+++ b/res/drawable-hdpi/ic_launcher_browser.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_partial_secure.png b/res/drawable-hdpi/ic_partial_secure.png
new file mode 100644
index 0000000..76ba96a
--- /dev/null
+++ b/res/drawable-hdpi/ic_partial_secure.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_secure.png b/res/drawable-hdpi/ic_secure.png
new file mode 100644
index 0000000..4f15fc4
--- /dev/null
+++ b/res/drawable-hdpi/ic_secure.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_partial_secure.png b/res/drawable-mdpi/ic_partial_secure.png
new file mode 100644
index 0000000..b3ca0cc
--- /dev/null
+++ b/res/drawable-mdpi/ic_partial_secure.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_secure.png b/res/drawable-mdpi/ic_secure.png
new file mode 100644
index 0000000..70d7edd
--- /dev/null
+++ b/res/drawable-mdpi/ic_secure.png
Binary files differ
diff --git a/res/layout/suggestion_item.xml b/res/layout/suggestion_item.xml
index fec5ae3..37e1f2a 100644
--- a/res/layout/suggestion_item.xml
+++ b/res/layout/suggestion_item.xml
@@ -55,6 +55,13 @@
android:layout_below="@android:id/text1"
android:layout_alignLeft="@android:id/text1" />
</RelativeLayout>
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/divider"
+ android:scaleType="center"
+ android:src="@drawable/divider_vert"
+ />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/url_bar.xml b/res/layout/url_bar.xml
index e85ad83..8b4a3c0 100644
--- a/res/layout/url_bar.xml
+++ b/res/layout/url_bar.xml
@@ -60,7 +60,7 @@
<ImageView
android:id="@+id/lock"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
style="@style/HoloIcon"
android:visibility="gone" />
<EditText
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 590235c..9683b31 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -199,10 +199,8 @@
return;
}
- mSecLockIcon = Resources.getSystem().getDrawable(
- android.R.drawable.ic_secure);
- mMixLockIcon = Resources.getSystem().getDrawable(
- android.R.drawable.ic_partial_secure);
+ mSecLockIcon = getResources().getDrawable(R.drawable.ic_secure);
+ mMixLockIcon = getResources().getDrawable(R.drawable.ic_partial_secure);
// Create the tab control and our initial tab
mTabControl = new TabControl(this);
@@ -1007,18 +1005,7 @@
mSSLCertificateOnErrorError);
}
if (mHttpAuthenticationDialog != null) {
- String title = ((TextView) mHttpAuthenticationDialog
- .findViewById(com.android.internal.R.id.alertTitle)).getText()
- .toString();
- String name = ((TextView) mHttpAuthenticationDialog
- .findViewById(R.id.username_edit)).getText().toString();
- String password = ((TextView) mHttpAuthenticationDialog
- .findViewById(R.id.password_edit)).getText().toString();
- int focusId = mHttpAuthenticationDialog.getCurrentFocus()
- .getId();
- mHttpAuthenticationDialog.dismiss();
- showHttpAuthentication(mHttpAuthHandler, null, null, title,
- name, password, focusId);
+ mHttpAuthenticationDialog.reshow();
}
}
@@ -1627,6 +1614,9 @@
if (v instanceof TitleBarBase) {
return;
}
+ if (!(v instanceof WebView)) {
+ return;
+ }
WebView webview = (WebView) v;
WebView.HitTestResult result = webview.getHitTestResult();
if (result == null) {
@@ -3629,73 +3619,23 @@
/**
* Displays an http-authentication dialog.
*/
- void showHttpAuthentication(final HttpAuthHandler handler,
- final String host, final String realm, final String title,
- final String name, final String password, int focusId) {
- LayoutInflater factory = LayoutInflater.from(this);
- final View v = factory
- .inflate(R.layout.http_authentication, null);
- if (name != null) {
- ((EditText) v.findViewById(R.id.username_edit)).setText(name);
- }
- if (password != null) {
- ((EditText) v.findViewById(R.id.password_edit)).setText(password);
- }
-
- String titleText = title;
- if (titleText == null) {
- titleText = getText(R.string.sign_in_to).toString().replace(
- "%s1", host).replace("%s2", realm);
- }
-
- mHttpAuthHandler = handler;
- AlertDialog dialog = new AlertDialog.Builder(this)
- .setTitle(titleText)
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setView(v)
- .setPositiveButton(R.string.action,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- String nm = ((EditText) v
- .findViewById(R.id.username_edit))
- .getText().toString();
- String pw = ((EditText) v
- .findViewById(R.id.password_edit))
- .getText().toString();
- BrowserActivity.this.setHttpAuthUsernamePassword
- (host, realm, nm, pw);
- handler.proceed(nm, pw);
- mHttpAuthenticationDialog = null;
- mHttpAuthHandler = null;
- }})
- .setNegativeButton(R.string.cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- handler.cancel();
- BrowserActivity.this.resetTitleAndRevertLockIcon();
- mHttpAuthenticationDialog = null;
- mHttpAuthHandler = null;
- }})
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- handler.cancel();
- BrowserActivity.this.resetTitleAndRevertLockIcon();
- mHttpAuthenticationDialog = null;
- mHttpAuthHandler = null;
- }})
- .create();
- // Make the IME appear when the dialog is displayed if applicable.
- dialog.getWindow().setSoftInputMode(
- WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
- dialog.show();
- if (focusId != 0) {
- dialog.findViewById(focusId).requestFocus();
- } else {
- v.findViewById(R.id.username_edit).requestFocus();
- }
- mHttpAuthenticationDialog = dialog;
+ void showHttpAuthentication(final HttpAuthHandler handler, String host, String realm) {
+ mHttpAuthenticationDialog = new HttpAuthenticationDialog(this, host, realm);
+ mHttpAuthenticationDialog.setOkListener(new HttpAuthenticationDialog.OkListener() {
+ public void onOk(String host, String realm, String username, String password) {
+ BrowserActivity.this.setHttpAuthUsernamePassword(host, realm, username, password);
+ handler.proceed(username, password);
+ mHttpAuthenticationDialog = null;
+ }
+ });
+ mHttpAuthenticationDialog.setCancelListener(new HttpAuthenticationDialog.CancelListener() {
+ public void onCancel() {
+ handler.cancel();
+ BrowserActivity.this.resetTitleAndRevertLockIcon();
+ mHttpAuthenticationDialog = null;
+ }
+ });
+ mHttpAuthenticationDialog.show();
}
public int getProgress() {
@@ -4251,8 +4191,7 @@
// as HttpAuthentication has different style for landscape / portrait, we
// have to re-open it when configuration changed
- private AlertDialog mHttpAuthenticationDialog;
- private HttpAuthHandler mHttpAuthHandler;
+ private HttpAuthenticationDialog mHttpAuthenticationDialog;
/*package*/ static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS =
new FrameLayout.LayoutParams(
diff --git a/src/com/android/browser/BrowserHistoryPage.java b/src/com/android/browser/BrowserHistoryPage.java
index ab622b1..e565696 100644
--- a/src/com/android/browser/BrowserHistoryPage.java
+++ b/src/com/android/browser/BrowserHistoryPage.java
@@ -167,6 +167,7 @@
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.history, container, false);
mList = (ExpandableListView) root.findViewById(android.R.id.list);
+ mList.setCacheColorHint(0);
mList.setOnCreateContextMenuListener(this);
mList.setOnChildClickListener(this);
mAdapter = new HistoryAdapter(getActivity());
@@ -316,8 +317,8 @@
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
- if (v instanceof BookmarkItem) {
- mCallbacks.onUrlSelected(((BookmarkItem) v).getUrl(), false);
+ if (v instanceof HistoryItem) {
+ mCallbacks.onUrlSelected(((HistoryItem) v).getUrl(), false);
return true;
}
return false;
@@ -331,9 +332,9 @@
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
- BookmarkItem item;
- if (null == convertView || !(convertView instanceof BookmarkItem)) {
- item = new BookmarkItem(getContext());
+ HistoryItem item;
+ if (null == convertView || !(convertView instanceof HistoryItem)) {
+ item = new HistoryItem(getContext());
// Add padding on the left so it will be indented from the
// arrows on the group views.
item.setPadding(item.getPaddingLeft() + 10,
@@ -341,7 +342,7 @@
item.getPaddingRight(),
item.getPaddingBottom());
} else {
- item = (BookmarkItem) convertView;
+ item = (HistoryItem) convertView;
}
// Bail early if the Cursor is closed.
diff --git a/src/com/android/browser/HttpAuthenticationDialog.java b/src/com/android/browser/HttpAuthenticationDialog.java
new file mode 100644
index 0000000..a9ba332
--- /dev/null
+++ b/src/com/android/browser/HttpAuthenticationDialog.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.browser;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.TextView;
+
+/**
+ * HTTP authentication dialog.
+ */
+public class HttpAuthenticationDialog {
+
+ private final Context mContext;
+
+ private final String mHost;
+ private final String mRealm;
+
+ private AlertDialog mDialog;
+ private TextView mUsernameView;
+ private TextView mPasswordView;
+
+ private OkListener mOkListener;
+ private CancelListener mCancelListener;
+
+ /**
+ * Creates an HTTP authentication dialog.
+ */
+ public HttpAuthenticationDialog(Context context, String host, String realm) {
+ mContext = context;
+ mHost = host;
+ mRealm = realm;
+ createDialog();
+ }
+
+ private String getUsername() {
+ return mUsernameView.getText().toString();
+ }
+
+ private String getPassword() {
+ return mPasswordView.getText().toString();
+ }
+
+ /**
+ * Sets the listener that will be notified when the user submits the credentials.
+ */
+ public void setOkListener(OkListener okListener) {
+ mOkListener = okListener;
+ }
+
+ /**
+ * Sets the listener that will be notified when the user cancels the authentication
+ * dialog.
+ */
+ public void setCancelListener(CancelListener cancelListener) {
+ mCancelListener = cancelListener;
+ }
+
+ /**
+ * Shows the dialog.
+ */
+ public void show() {
+ mDialog.show();
+ mUsernameView.requestFocus();
+ }
+
+ /**
+ * Hides, recreates, and shows the dialog. This can be used to handle configuration changes.
+ */
+ public void reshow() {
+ String username = getUsername();
+ String password = getPassword();
+ int focusId = mDialog.getCurrentFocus().getId();
+ mDialog.dismiss();
+ createDialog();
+ mDialog.show();
+ if (username != null) {
+ mUsernameView.setText(username);
+ }
+ if (password != null) {
+ mPasswordView.setText(password);
+ }
+ if (focusId != 0) {
+ mDialog.findViewById(focusId).requestFocus();
+ } else {
+ mUsernameView.requestFocus();
+ }
+ }
+
+ private void createDialog() {
+ LayoutInflater factory = LayoutInflater.from(mContext);
+ View v = factory.inflate(R.layout.http_authentication, null);
+ mUsernameView = (TextView) v.findViewById(R.id.username_edit);
+ mPasswordView = (TextView) v.findViewById(R.id.password_edit);
+
+ String title = mContext.getText(R.string.sign_in_to).toString().replace(
+ "%s1", mHost).replace("%s2", mRealm);
+
+ mDialog = new AlertDialog.Builder(mContext)
+ .setTitle(title)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setView(v)
+ .setPositiveButton(R.string.action, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ if (mOkListener != null) {
+ mOkListener.onOk(mHost, mRealm, getUsername(), getPassword());
+ }
+ }})
+ .setNegativeButton(R.string.cancel,new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int whichButton) {
+ if (mCancelListener != null) mCancelListener.onCancel();
+ }})
+ .setOnCancelListener(new DialogInterface.OnCancelListener() {
+ public void onCancel(DialogInterface dialog) {
+ if (mCancelListener != null) mCancelListener.onCancel();
+ }})
+ .create();
+
+ // Make the IME appear when the dialog is displayed if applicable.
+ mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
+ }
+
+ /**
+ * Interface for listeners that are notified when the user submits the credentials.
+ */
+ public interface OkListener {
+ void onOk(String host, String realm, String username, String password);
+ }
+
+ /**
+ * Interface for listeners that are notified when the user cancels the dialog.
+ */
+ public interface CancelListener {
+ void onCancel();
+ }
+}
diff --git a/src/com/android/browser/SuggestionsAdapter.java b/src/com/android/browser/SuggestionsAdapter.java
index 7cfd78e..903768c 100644
--- a/src/com/android/browser/SuggestionsAdapter.java
+++ b/src/com/android/browser/SuggestionsAdapter.java
@@ -79,6 +79,8 @@
public void onSelect(String txt);
+ public void onFilterComplete(int count);
+
}
public SuggestionsAdapter(Context ctx, CompletionListener listener) {
@@ -179,7 +181,7 @@
if (item != null) {
bindView(iv, item);
} else {
- iv.setVisibility((mResults.getLeftCount() == 0) ? View.GONE :
+ iv.setVisibility((mResults.getLeftCount() == 0) ? View.GONE :
View.INVISIBLE);
}
item = getItem(position + mResults.getLineCount());
@@ -190,7 +192,7 @@
if (item != null) {
bindView(iv, item);
} else {
- iv.setVisibility((mResults.getRightCount() == 0) ? View.GONE :
+ iv.setVisibility((mResults.getRightCount() == 0) ? View.GONE :
View.INVISIBLE);
}
return view;
@@ -209,6 +211,7 @@
ImageView ic1 = (ImageView) view.findViewById(R.id.icon1);
View spacer = view.findViewById(R.id.spacer);
View ic2 = view.findViewById(R.id.icon2);
+ View div = view.findViewById(R.id.divider);
tv1.setText(item.title);
tv2.setText(item.url);
int id = -1;
@@ -234,6 +237,7 @@
}
ic2.setVisibility(((TYPE_SUGGEST == item.type) || (TYPE_SEARCH == item.type))
? View.VISIBLE : View.GONE);
+ div.setVisibility(ic2.getVisibility());
spacer.setVisibility(((TYPE_SUGGEST == item.type) || (TYPE_SEARCH == item.type))
? View.GONE : View.INVISIBLE);
view.setOnClickListener(this);
@@ -242,7 +246,6 @@
class SuggestFilter extends Filter {
- int count;
SuggestionResults results;
@Override
@@ -267,14 +270,13 @@
return res;
}
results = new SuggestionResults();
- count = 0;
if (constraint != null) {
for (CursorSource sc : mSources) {
sc.runQuery(constraint);
}
mixResults();
}
- res.count = count;
+ res.count = results.getLineCount();
res.values = results;
return res;
}
@@ -282,9 +284,9 @@
void mixResults() {
for (int i = 0; i < mSources.size(); i++) {
CursorSource s = mSources.get(i);
- int n = Math.min(s.getCount(), (mLandscapeMode ? mLinesLandscape
+ int n = Math.min(s.getCount(), (mLandscapeMode ? mLinesLandscape
: mLinesPortrait));
- boolean more = true;
+ boolean more = false;
for (int j = 0; j < n; j++) {
results.addResult(s.getItem());
more = s.moveToNext();
@@ -303,12 +305,12 @@
}
}
}
-
}
@Override
protected void publishResults(CharSequence constraint, FilterResults fresults) {
mResults = (SuggestionResults) fresults.values;
+ mListener.onFilterComplete(fresults.count);
notifyDataSetChanged();
}
@@ -452,10 +454,10 @@
selection = COMBINED_SELECTION;
}
Uri.Builder ub = BrowserContract.Combined.CONTENT_URI.buildUpon();
- ub.appendQueryParameter(BrowserContract.PARAM_LIMIT,
+ ub.appendQueryParameter(BrowserContract.PARAM_LIMIT,
Integer.toString(mLinesPortrait));
mCursor =
- mContext.getContentResolver().query(ub.build(), COMBINED_PROJECTION,
+ mContext.getContentResolver().query(ub.build(), COMBINED_PROJECTION,
selection,
(constraint != null) ? args : null,
BrowserContract.Combined.VISITS + " DESC, " +
@@ -536,10 +538,10 @@
String[] args = new String[] {constraint.toString()};
String selection = BrowserContract.Searches.SEARCH + " LIKE ?";
Uri.Builder ub = BrowserContract.Searches.CONTENT_URI.buildUpon();
- ub.appendQueryParameter(BrowserContract.PARAM_LIMIT,
+ ub.appendQueryParameter(BrowserContract.PARAM_LIMIT,
Integer.toString(mLinesPortrait));
mCursor =
- mContext.getContentResolver().query(ub.build(), SEARCHES_PROJECTION,
+ mContext.getContentResolver().query(ub.build(), SEARCHES_PROJECTION,
selection,
args, BrowserContract.Searches.DATE + " DESC");
if (mCursor != null) {
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index cb70e01..36566c1 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -818,8 +818,7 @@
handler.proceed(username, password);
} else {
if (mInForeground) {
- mActivity.showHttpAuthentication(handler, host, realm,
- null, null, null, 0);
+ mActivity.showHttpAuthentication(handler, host, realm);
} else {
handler.cancel();
}
diff --git a/src/com/android/browser/TabScrollView.java b/src/com/android/browser/TabScrollView.java
index 0d85920..7268ddc 100644
--- a/src/com/android/browser/TabScrollView.java
+++ b/src/com/android/browser/TabScrollView.java
@@ -18,6 +18,7 @@
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.content.Context;
@@ -171,44 +172,28 @@
}
private void animateIn(View tab) {
- ObjectAnimator animator = new ObjectAnimator<PropertyValuesHolder>(
- mAnimationDuration, tab,
- new PropertyValuesHolder<Integer>("TranslationX", 500, 0));
+ ObjectAnimator animator = ObjectAnimator.ofInt(tab, "TranslationX", 500, 0);
+ animator.setDuration(mAnimationDuration);
animator.start();
}
private void animateOut(final View tab) {
- ObjectAnimator animator = new ObjectAnimator<PropertyValuesHolder>(
- mAnimationDuration, tab,
- new PropertyValuesHolder<Integer>("TranslationX", 0,
- getScrollX() - tab.getRight()));
- animator.addListener(new AnimatorListener() {
-
- @Override
- public void onAnimationCancel(Animator animation) {
- }
-
+ ObjectAnimator animator = ObjectAnimator.ofInt(
+ tab, "TranslationX", 0, getScrollX() - tab.getRight());
+ animator.setDuration(mAnimationDuration);
+ animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mContentView.removeView(tab);
}
-
- @Override
- public void onAnimationRepeat(Animator animation) {
- }
-
- @Override
- public void onAnimationStart(Animator animation) {
- }
});
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
}
private void animateScroll(int newscroll) {
- ObjectAnimator animator = new ObjectAnimator<PropertyValuesHolder>(
- mAnimationDuration, this,
- new PropertyValuesHolder<Integer>("scroll", getScrollX(), newscroll));
+ ObjectAnimator animator = ObjectAnimator.ofInt(this, "scroll", getScrollX(), newscroll);
+ animator.setDuration(mAnimationDuration);
animator.start();
}
diff --git a/src/com/android/browser/TitleBarXLarge.java b/src/com/android/browser/TitleBarXLarge.java
index 57098a9..7310f75 100644
--- a/src/com/android/browser/TitleBarXLarge.java
+++ b/src/com/android/browser/TitleBarXLarge.java
@@ -105,6 +105,7 @@
mUrlFocused.setUrlInputListener(this);
mUrlUnfocused.setOnFocusChangeListener(this);
mUrlFocused.setContainer(mFocusContainer);
+ mUnfocusContainer.setOnClickListener(this);
}
public void onFocusChange(View v, boolean hasFocus) {
@@ -119,7 +120,9 @@
@Override
public void onClick(View v) {
- if (mBackButton == v) {
+ if (mUnfocusContainer == v) {
+ mUrlUnfocused.requestFocus();
+ } else if (mBackButton == v) {
mBrowserActivity.getTopWindow().goBack();
} else if (mForwardButton == v) {
mBrowserActivity.getTopWindow().goForward();
@@ -171,7 +174,7 @@
@Override
public void onEdit(String text) {
- setDisplayTitle(text);
+ setDisplayTitle(text, true);
if (text != null) {
mUrlFocused.setSelection(text.length());
}
@@ -240,4 +243,9 @@
mUrlUnfocused.setText(title);
}
+ void setDisplayTitle(String title, boolean filter) {
+ mUrlFocused.setText(title, filter);
+ mUrlUnfocused.setText(title);
+ }
+
}