Merge "Import revised translations.  DO NOT MERGE" into ics-mr0
diff --git a/res/drawable-hdpi/row_activated_bookmark_widget_holo.9.png b/res/drawable-hdpi/row_activated_bookmark_widget_holo.9.png
deleted file mode 100644
index 54e5825..0000000
--- a/res/drawable-hdpi/row_activated_bookmark_widget_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/row_activated_bookmark_widget_holo.9.png b/res/drawable-mdpi/row_activated_bookmark_widget_holo.9.png
deleted file mode 100644
index 69b6d40..0000000
--- a/res/drawable-mdpi/row_activated_bookmark_widget_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/row_activated_bookmark_widget_holo.9.png b/res/drawable-xhdpi/row_activated_bookmark_widget_holo.9.png
deleted file mode 100644
index 8df6517..0000000
--- a/res/drawable-xhdpi/row_activated_bookmark_widget_holo.9.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable/suggest_item_selector.xml b/res/drawable/suggest_item_selector.xml
deleted file mode 100644
index 301584f..0000000
--- a/res/drawable/suggest_item_selector.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:exitFadeDuration="@android:integer/config_mediumAnimTime">
-    <item android:state_pressed="true"
-        android:drawable="@drawable/row_activated_bookmark_widget_holo" />
-    <item android:state_pressed="false" android:drawable="@drawable/clear" />
-</selector>
diff --git a/res/layout/suggestion_item.xml b/res/layout/suggestion_item.xml
index 2def735..0adea1b 100644
--- a/res/layout/suggestion_item.xml
+++ b/res/layout/suggestion_item.xml
@@ -32,7 +32,7 @@
         android:layout_height="match_parent"
         android:layout_weight="1"
         android:orientation="horizontal"
-        android:background="@drawable/suggest_item_selector"
+        android:background="?android:attr/selectableItemBackground"
         android:padding="0dp">
         <ImageView
             android:layout_width="wrap_content"
@@ -74,7 +74,7 @@
         android:id="@+id/icon2"
         android:scaleType="center"
         android:src="@drawable/ic_querybuilder"
-        android:background="@drawable/suggest_item_selector"
+        android:background="?android:attr/selectableItemBackground"
         android:paddingRight="@dimen/suggest_item_padding"
         android:paddingLeft="@dimen/suggest_item_padding"
          />
diff --git a/src/com/android/browser/AddBookmarkPage.java b/src/com/android/browser/AddBookmarkPage.java
index 71af567..ae5ae69 100644
--- a/src/com/android/browser/AddBookmarkPage.java
+++ b/src/com/android/browser/AddBookmarkPage.java
@@ -999,7 +999,7 @@
         }
     }
 
-    public static class AccountsLoader extends CursorLoader {
+    static class AccountsLoader extends CursorLoader {
 
         static final String[] PROJECTION = new String[] {
             Accounts.ACCOUNT_NAME,
diff --git a/src/com/android/browser/provider/BrowserProvider2.java b/src/com/android/browser/provider/BrowserProvider2.java
index 9aa2502..06c8e16 100644
--- a/src/com/android/browser/provider/BrowserProvider2.java
+++ b/src/com/android/browser/provider/BrowserProvider2.java
@@ -379,6 +379,7 @@
     // This is so provider tests can intercept widget updating
     ContentObserver mWidgetObserver = null;
     boolean mUpdateWidgets = false;
+    boolean mSyncToNetwork = true;
 
     final class DatabaseHelper extends SQLiteOpenHelper {
         static final String DATABASE_NAME = "browser2.db";
@@ -804,6 +805,7 @@
             }
             mUpdateWidgets = false;
         }
+        mSyncToNetwork = true;
     }
 
     @Override
@@ -1319,7 +1321,9 @@
         }
         if (deleted > 0) {
             postNotifyUri(uri);
-            postNotifyUri(LEGACY_AUTHORITY_URI);
+            if (shouldNotifyLegacy(uri)) {
+                postNotifyUri(LEGACY_AUTHORITY_URI);
+            }
         }
         return deleted;
     }
@@ -1466,7 +1470,9 @@
 
         if (id >= 0) {
             postNotifyUri(uri);
-            postNotifyUri(LEGACY_AUTHORITY_URI);
+            if (shouldNotifyLegacy(uri)) {
+                postNotifyUri(LEGACY_AUTHORITY_URI);
+            }
             return ContentUris.withAppendedId(uri, id);
         } else {
             return null;
@@ -1678,15 +1684,26 @@
                     db.insertOrThrow(TABLE_IMAGES, Images.FAVICON, values);
                     count = 1;
                 }
+                // Only favicon is exposed in the public API. If we updated
+                // the thumbnail or touch icon don't bother notifying the
+                // legacy authority since it can't read it anyway.
+                boolean updatedLegacy = false;
                 if (getUrlCount(db, TABLE_BOOKMARKS, url) > 0) {
                     postNotifyUri(Bookmarks.CONTENT_URI);
+                    updatedLegacy = values.containsKey(Images.FAVICON);
                     refreshWidgets();
                 }
                 if (getUrlCount(db, TABLE_HISTORY, url) > 0) {
                     postNotifyUri(History.CONTENT_URI);
+                    updatedLegacy = values.containsKey(Images.FAVICON);
                 }
-                postNotifyUri(LEGACY_AUTHORITY_URI);
-                pruneImages();
+                if (pruneImages() > 0 || updatedLegacy) {
+                    postNotifyUri(LEGACY_AUTHORITY_URI);
+                }
+                // Even though we may be calling notifyUri on Bookmarks, don't
+                // sync to network as images aren't synced. Otherwise this
+                // unnecessarily triggers a bookmark sync.
+                mSyncToNetwork = false;
                 return count;
             }
 
@@ -1714,7 +1731,9 @@
         pruneImages();
         if (modified > 0) {
             postNotifyUri(uri);
-            postNotifyUri(LEGACY_AUTHORITY_URI);
+            if (shouldNotifyLegacy(uri)) {
+                postNotifyUri(LEGACY_AUTHORITY_URI);
+            }
         }
         return modified;
     }
@@ -2028,9 +2047,31 @@
         return imageValues;
     }
 
-    void pruneImages() {
+    int pruneImages() {
         final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        db.delete(TABLE_IMAGES, IMAGE_PRUNE, null);
+        return db.delete(TABLE_IMAGES, IMAGE_PRUNE, null);
+    }
+
+    boolean shouldNotifyLegacy(Uri uri) {
+        if (uri.getPathSegments().contains("history")
+                || uri.getPathSegments().contains("bookmarks")
+                || uri.getPathSegments().contains("searches")) {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    protected boolean syncToNetwork(Uri uri) {
+        if (BrowserContract.AUTHORITY.equals(uri.getAuthority())
+                && uri.getPathSegments().contains("bookmarks")) {
+            return mSyncToNetwork;
+        }
+        if (LEGACY_AUTHORITY.equals(uri.getAuthority())) {
+            // Allow for 3rd party sync adapters
+            return true;
+        }
+        return false;
     }
 
     static class SuggestionsCursor extends AbstractCursor {
diff --git a/src/com/android/browser/provider/SQLiteContentProvider.java b/src/com/android/browser/provider/SQLiteContentProvider.java
index 13acd3d..75e298e 100644
--- a/src/com/android/browser/provider/SQLiteContentProvider.java
+++ b/src/com/android/browser/provider/SQLiteContentProvider.java
@@ -239,7 +239,12 @@
         }
         ContentResolver resolver = getContext().getContentResolver();
         for (Uri uri : changed) {
-            resolver.notifyChange(uri, null, !callerIsSyncAdapter);
+            boolean syncToNetwork = !callerIsSyncAdapter && syncToNetwork(uri);
+            resolver.notifyChange(uri, null, syncToNetwork);
         }
     }
+
+    protected boolean syncToNetwork(Uri uri) {
+        return false;
+    }
 }
diff --git a/src/com/android/browser/widget/BookmarkWidgetConfigure.java b/src/com/android/browser/widget/BookmarkWidgetConfigure.java
index 4231f37..a74bed9 100644
--- a/src/com/android/browser/widget/BookmarkWidgetConfigure.java
+++ b/src/com/android/browser/widget/BookmarkWidgetConfigure.java
@@ -19,16 +19,18 @@
 import android.app.ListActivity;
 import android.app.LoaderManager.LoaderCallbacks;
 import android.appwidget.AppWidgetManager;
+import android.content.Context;
+import android.content.CursorLoader;
 import android.content.Intent;
 import android.content.Loader;
 import android.database.Cursor;
 import android.os.Bundle;
+import android.provider.BrowserContract.Accounts;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
 
-import com.android.browser.AddBookmarkPage.AccountsLoader;
 import com.android.browser.AddBookmarkPage.BookmarkAccount;
 import com.android.browser.R;
 import com.android.browser.provider.BrowserProvider2;
@@ -91,10 +93,12 @@
 
     @Override
     public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
-        if (cursor == null || cursor.getCount() <= 1) {
-            // We always have the local account, so if count == 1 it must
-            // be the local account
+        if (cursor == null || cursor.getCount() < 1) {
+            // We always have the local account, so fall back to that
             pickAccount(BrowserProvider2.FIXED_ID_ROOT);
+        } else if (cursor.getCount() == 1) {
+            cursor.moveToFirst();
+            pickAccount(cursor.getLong(AccountsLoader.COLUMN_INDEX_ROOT_ID));
         } else {
             mAccountAdapter.clear();
             while (cursor.moveToNext()) {
@@ -110,4 +114,25 @@
         // Don't care
     }
 
+    static class AccountsLoader extends CursorLoader {
+
+        static final String[] PROJECTION = new String[] {
+            Accounts.ACCOUNT_NAME,
+            Accounts.ACCOUNT_TYPE,
+            Accounts.ROOT_ID,
+        };
+
+        static final int COLUMN_INDEX_ACCOUNT_NAME = 0;
+        static final int COLUMN_INDEX_ACCOUNT_TYPE = 1;
+        static final int COLUMN_INDEX_ROOT_ID = 2;
+
+        public AccountsLoader(Context context) {
+            super(context, Accounts.CONTENT_URI
+                    .buildUpon()
+                    .appendQueryParameter(BrowserProvider2.PARAM_ALLOW_EMPTY_ACCOUNTS, "false")
+                    .build(), PROJECTION, null, null, null);
+        }
+
+    }
+
 }