summaryrefslogtreecommitdiff
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
parenteef1589d1f658de1b50a5617c4f5edae0daa0769 (diff)
downloadImProvider-f0d90e9e5a360a627f8ca5652fb6052e0d1c123a.tar.gz
auto import from //branches/cupcake/...@125939
-rw-r--r--res/drawable/ic_menu_login.pngbin2466 -> 0 bytes
-rw-r--r--res/layout/account_view.xml46
-rw-r--r--res/values/strings.xml2
-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
6 files changed, 63 insertions, 43 deletions
diff --git a/res/drawable/ic_menu_login.png b/res/drawable/ic_menu_login.png
deleted file mode 100644
index 2b856bc..0000000
--- a/res/drawable/ic_menu_login.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/account_view.xml b/res/layout/account_view.xml
index 4955e6c..faa938e 100644
--- a/res/layout/account_view.xml
+++ b/res/layout/account_view.xml
@@ -23,26 +23,11 @@
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight">
- <RelativeLayout
- android:layout_width="48dip"
- android:layout_height="38dip"
- android:paddingLeft="6dip"
- android:layout_gravity="center_vertical">
- <ImageView
- android:id="@+id/providerIcon"
- android:scaleType="centerCrop"
- android:layout_width="32dip"
- android:layout_height="32dip"
- android:layout_alignParentLeft="true"
- android:layout_alignParentBottom="true" />
- <ImageView
- android:id="@+id/statusIcon"
- android:scaleType="fitXY"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_alignParentTop="true" />
- </RelativeLayout>
+ <ImageView
+ android:id="@+id/providerIcon"
+ android:scaleType="centerCrop"
+ android:layout_width="32dip"
+ android:layout_height="32dip"/>
<LinearLayout android:orientation="vertical"
android:paddingLeft="4dip"
@@ -58,11 +43,22 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
- <TextView android:id="@+id/line2"
- android:textSize="16sp"
- android:maxLines="1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
+ <LinearLayout android:orientation="horizontal"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+ <ImageView
+ android:id="@+id/statusIcon"
+ android:scaleType="fitXY"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingRight="6dip"
+ />
+ <TextView android:id="@+id/line2"
+ android:textSize="16sp"
+ android:maxLines="1"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"/>
+ </LinearLayout>
</LinearLayout>
<LinearLayout
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 65c0441..c2b75a1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -53,8 +53,6 @@
<!-- These strings displayed on the landing page. -->
<!-- The title of the landing page.-->
<string name="choose_account_title">Chat - Select an account</string>
- <!-- The account label on the landing page e.g. "AIM account:", if there is an account.-->
- <string name="account_title"><xliff:g id="account">%1$s</xliff:g> account:</string>
<!-- Displays if there is only one ongoing chat on the landing page.-->
<string name="one_conversation">1 chat</string>
<!-- Displays the number of ongoing chats on the landing page.-->
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);