summaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-01-09 17:51:25 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-01-09 17:51:25 -0800
commitf0d90e9e5a360a627f8ca5652fb6052e0d1c123a (patch)
tree283fec12026e2ed39618fa0668792759332d3779 /src/com
parenteef1589d1f658de1b50a5617c4f5edae0daa0769 (diff)
downloadImProvider-f0d90e9e5a360a627f8ca5652fb6052e0d1c123a.tar.gz
auto import from //branches/cupcake/...@125939
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/providers/im/ImProvider.java33
-rw-r--r--src/com/android/providers/im/LandingPage.java23
-rw-r--r--src/com/android/providers/im/ProviderListItem.java2
3 files changed, 42 insertions, 16 deletions
diff --git a/src/com/android/providers/im/ImProvider.java b/src/com/android/providers/im/ImProvider.java
index 636ecc1..9a40865 100644
--- a/src/com/android/providers/im/ImProvider.java
+++ b/src/com/android/providers/im/ImProvider.java
@@ -1446,11 +1446,6 @@ public class ImProvider extends ContentProvider {
mQueryContactPresenceSelectionArgs[0] = String.valueOf(account);
- if (DBG) {
- log("seedInitialPresence: contacts_with_no_presence_selection => " +
- CONTACTS_WITH_NO_PRESENCE_SELECTION);
- }
-
final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
db.beginTransaction();
@@ -1461,14 +1456,30 @@ public class ImProvider extends ContentProvider {
presenceValues.put(Im.Presence.PRESENCE_STATUS, Im.Presence.OFFLINE);
presenceValues.put(Im.Presence.PRESENCE_CUSTOM_STATUS, "");
- // First: update all the presence so they are offline
- //
- // TODO: this doesn't take into the accountId. It's ok for GTalk account for now
- // as we only support one account. However, for multiple account this will be a problem.
- int count = db.update(TABLE_PRESENCE, presenceValues, null, null);
+ // First: update all the presence for the account so they are offline
+ StringBuilder buf = new StringBuilder();
+ buf.append(Im.Presence.CONTACT_ID);
+ buf.append(" in (select ");
+ buf.append(Im.Contacts._ID);
+ buf.append(" from ");
+ buf.append(TABLE_CONTACTS);
+ buf.append(" where ");
+ buf.append(Im.Contacts.ACCOUNT);
+ buf.append("=?) ");
+
+ String selection = buf.toString();
+ if (DBG) log("seedInitialPresence: reset presence selection=" + selection);
+
+ int count = db.update(TABLE_PRESENCE, presenceValues, selection,
+ mQueryContactPresenceSelectionArgs);
if (DBG) log("seedInitialPresence: reset " + count + " presence rows to OFFLINE");
// second: add a presence row for each contact that doesn't have a presence
+ if (DBG) {
+ log("seedInitialPresence: contacts_with_no_presence_selection => " +
+ CONTACTS_WITH_NO_PRESENCE_SELECTION);
+ }
+
c = qb.query(db,
CONTACT_ID_PROJECTION,
CONTACTS_WITH_NO_PRESENCE_SELECTION,
@@ -1926,7 +1937,7 @@ public class ImProvider extends ContentProvider {
// Find all the chats without a quick switch slot, and order
Cursor c = query(Im.Chats.CONTENT_URI,
BACKFILL_PROJECTION,
- Im.Chats.SHORTCUT + "=-1", null, Im.Chats.LAST_MESSAGE_DATE + "DESC");
+ Im.Chats.SHORTCUT + "=-1", null, Im.Chats.LAST_MESSAGE_DATE + " DESC");
try {
if (c.getCount() < 1) {
diff --git a/src/com/android/providers/im/LandingPage.java b/src/com/android/providers/im/LandingPage.java
index 47cddc3..364a899 100644
--- a/src/com/android/providers/im/LandingPage.java
+++ b/src/com/android/providers/im/LandingPage.java
@@ -137,7 +137,7 @@ public class LandingPage extends ListActivity implements View.OnCreateContextMen
setTitle(R.string.landing_page_title);
if (!loadPlugins()) {
- Log.e(TAG, "load plugin failed, no plugin found!");
+ Log.e(TAG, "[onCreate] load plugin failed, no plugin found!");
finish();
return;
}
@@ -166,7 +166,16 @@ public class LandingPage extends ListActivity implements View.OnCreateContextMen
super.onRestart();
// refresh the accountToPlugin map after mProviderCursor is requeried
- rebuildAccountToPluginMap();
+ if (!rebuildAccountToPluginMap()) {
+ Log.w(TAG, "[onRestart] rebuiltAccountToPluginMap failed, reload plugins...");
+
+ if (!loadPlugins()) {
+ Log.e(TAG, "[onRestart] load plugin failed, no plugin found!");
+ finish();
+ return;
+ }
+ rebuildAccountToPluginMap();
+ }
startPlugins();
}
@@ -340,7 +349,7 @@ public class LandingPage extends ListActivity implements View.OnCreateContextMen
return res == null ? mDefaultBrandingResources : res;
}
- private void rebuildAccountToPluginMap() {
+ private boolean rebuildAccountToPluginMap() {
if (Log.isLoggable(TAG, Log.DEBUG)) {
log("rebuildAccountToPluginMap");
}
@@ -352,6 +361,9 @@ public class LandingPage extends ListActivity implements View.OnCreateContextMen
mAccountToPluginMap = new HashMap<Long, PluginInfo>();
mProviderCursor.moveToFirst();
+
+ boolean retVal = true;
+
do {
long accountId = mProviderCursor.getLong(ACTIVE_ACCOUNT_ID_COLUMN);
@@ -368,8 +380,11 @@ public class LandingPage extends ListActivity implements View.OnCreateContextMen
mAccountToPluginMap.put(accountId, pluginInfo);
} else {
Log.w(TAG, "[LandingPage] no plugin found for " + name);
+ retVal = false;
}
} while (mProviderCursor.moveToNext()) ;
+
+ return retVal;
}
private void signIn(long accountId) {
@@ -497,7 +512,7 @@ public class LandingPage extends ListActivity implements View.OnCreateContextMen
boolean isLoggedIn = isSignedIn(providerCursor);
if (!isLoggedIn) {
- menu.add(0, ID_SIGN_IN, 0, R.string.sign_in).setIcon(R.drawable.ic_menu_login);
+ menu.add(0, ID_SIGN_IN, 0, R.string.sign_in).setIcon(android.R.drawable.ic_menu_login);
} else {
BrandingResources brandingRes = getBrandingResource(providerId);
menu.add(0, ID_VIEW_CONTACT_LIST, 0,
diff --git a/src/com/android/providers/im/ProviderListItem.java b/src/com/android/providers/im/ProviderListItem.java
index 4e5c78a..19d456c 100644
--- a/src/com/android/providers/im/ProviderListItem.java
+++ b/src/com/android/providers/im/ProviderListItem.java
@@ -87,7 +87,7 @@ public class ProviderListItem extends LinearLayout {
if (!cursor.isNull(mActiveAccountIdColumn)) {
line1.setVisibility(View.VISIBLE);
- line1.setText(r.getString(R.string.account_title, providerDisplayName));
+ line1.setText(providerDisplayName);
line2.setText(cursor.getString(mActiveAccountUserNameColumn));
long accountId = cursor.getLong(mActiveAccountIdColumn);