Update request in contactlist.ui
authorNikita Kozlov <nikita@elyzion.net>
Sun, 06 Nov 2011 21:22:00 +0100
changeset 918 80d2be82fa84
parent 917 f7cfc4a68225
child 919 b1815efd3cf6
Update request in contactlist.ui add filter in manifest to add contact
AndroidManifest.xml
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/ui/ContactList.java
--- a/AndroidManifest.xml	Sun Nov 06 04:27:09 2011 +0100
+++ b/AndroidManifest.xml	Sun Nov 06 21:22:00 2011 +0100
@@ -1,253 +1,225 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<manifest
-	xmlns:android="http://schemas.android.com/apk/res/android"
-	package="com.beem.project.beem"
-	android:versionCode="7"
-	android:versionName="0.1.5">
-	<application
-		android:label="@string/app_name"
-		android:icon="@drawable/beem_launcher_icon_silver"
-		android:theme="@style/Theme.BEEM.Default"
-		android:name=".BeemApplication">
-		<activity
-			android:name=".ui.Login"
-			android:label="@string/app_name"
-			android:launchMode="standard">
-			<intent-filter>
-				<action
-					android:name="android.intent.action.MAIN" />
-				<category
-					android:name="android.intent.category.LAUNCHER" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name=".ui.wizard.Account"
-			android:label="Account wizard" />
-		<activity
-			android:name=".ui.wizard.AccountConfigure"
-			android:label="Account wizard" />
-		<activity
-			android:name=".ui.LoginAnim"
-			android:label="@string/login_login_progress"
-			android:launchMode="singleTop"
-			android:screenOrientation="portrait" />
-		<activity
-			android:name=".ui.Settings"
-			android:label="@string/edit_settings_name">
-			<intent-filter
-				android:label="Beem Android Account">
-				<action
-					android:name="com.beem.project.beem.SETTINGS" />
-				<category
-					android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-			<intent-filter
-				android:label="Beem Connection">
-				<action
-					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name=".ui.Chat"
-			android:label="@string/chat_name"
-			android:launchMode="singleTop">
-			<intent-filter
-				android:label="Beem Connection">
-				<action
-					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
-			</intent-filter>
-			<intent-filter>
-				<action
-					android:name="android.intent.action.SENDTO" />
-				<category
-					android:name="android.intent.category.DEFAULT" />
-				<category
-					android:name="com.android.im.category.JABBER" />
-				<data
-					android:scheme="im" />
-			</intent-filter>
-			<intent-filter>
-				<action
-					android:name="android.intent.action.SENDTO" />
-				<category
-					android:name="android.intent.category.DEFAULT" />
-				<data
-					android:scheme="imto"
-					android:host="jabber" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name=".ui.ChangeStatus"
-			android:label="@string/ChangeStatusActTitle"
-			android:launchMode="singleTask"
-			android:windowSoftInputMode="stateHidden">
-			<intent-filter
-				android:label="Beem Android Account">
-				<action
-					android:name="com.beem.project.beem.CHANGESTATUS" />
-				<category
-					android:name="android.intent.category.DEFAULT" />
-			</intent-filter>
-			<intent-filter
-				android:label="Beem Connection">
-				<action
-					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name=".ui.AddContact"
-			android:label="@string/AddCActTitle">
-			<intent-filter
-				android:label="Beem Connection">
-				<action
-					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name=".ui.Subscription"
-			android:label="@string/app_name">
-			<intent-filter
-				android:label="Beem Connection">
-				<action
-					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name=".ui.CreateAccount"
-			android:label="@string/create_account_name" />
-		<activity
-			android:name=".ui.ContactList"
-			android:label="@string/contact_list_name"
-			android:launchMode="singleTask">
-			<intent-filter
-				android:label="Beem Connection">
-				<action
-					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name=".ui.GroupList"
-			android:label="GroupList">
-			<intent-filter
-				android:label="Beem Connection">
-				<action
-					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name=".ui.PrivacyList"
-			android:label="@string/privacy_list_name">
-			<intent-filter
-				android:label="Beem Connection">
-				<action
-					android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
-			</intent-filter>
-		</activity>
-		<activity
-			android:name="com.beem.project.beem.account.ManageAccountsSettings"
-			android:label="Sync Settings">
-		</activity>
-		<!--
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.beem.project.beem"
+    android:versionCode="7"
+    android:versionName="0.1.5" >
+
+    <application
+        android:icon="@drawable/beem_launcher_icon_silver"
+        android:label="@string/app_name"
+        android:name=".BeemApplication"
+        android:theme="@style/Theme.BEEM.Default" >
+        <activity
+            android:label="@string/app_name"
+            android:launchMode="standard"
+            android:name=".ui.Login" >
+            <intent-filter >
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="Account wizard"
+            android:name=".ui.wizard.Account" />
+        <activity
+            android:label="Account wizard"
+            android:name=".ui.wizard.AccountConfigure" />
+        <activity
+            android:label="@string/login_login_progress"
+            android:launchMode="singleTop"
+            android:name=".ui.LoginAnim"
+            android:screenOrientation="portrait" />
+        <activity
+            android:label="@string/edit_settings_name"
+            android:name=".ui.Settings" >
+            <intent-filter android:label="Beem Android Account" >
+                <action android:name="com.beem.project.beem.SETTINGS" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter android:label="Beem Connection" >
+                <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="@string/chat_name"
+            android:launchMode="singleTop"
+            android:name=".ui.Chat" >
+            <intent-filter android:label="Beem Connection" >
+                <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+            </intent-filter>
+            <intent-filter >
+                <action android:name="android.intent.action.SENDTO" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="com.android.im.category.JABBER" />
+
+                <data android:scheme="im" />
+            </intent-filter>
+            <intent-filter >
+                <action android:name="android.intent.action.SENDTO" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+
+                <data
+                    android:host="jabber"
+                    android:scheme="imto" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="@string/ChangeStatusActTitle"
+            android:launchMode="singleTask"
+            android:name=".ui.ChangeStatus"
+            android:windowSoftInputMode="stateHidden" >
+            <intent-filter android:label="Beem Android Account" >
+                <action android:name="com.beem.project.beem.CHANGESTATUS" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+            <intent-filter android:label="Beem Connection" >
+                <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="@string/AddCActTitle"
+            android:name=".ui.AddContact" >
+            <intent-filter android:label="Create Contact" >
+                <action android:name="android.intent.action.INSERT" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+
+                <data android:mimeType="vnd.android.cursor.dir/person" />
+                <data android:mimeType="vnd.android.cursor.dir/contact" />
+                <data android:mimeType="vnd.android.cursor.dir/raw_contact" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="@string/app_name"
+            android:name=".ui.Subscription" >
+            <intent-filter android:label="Beem Connection" >
+                <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="@string/create_account_name"
+            android:name=".ui.CreateAccount" />
+        <activity
+            android:label="@string/contact_list_name"
+            android:launchMode="singleTask"
+            android:name=".ui.ContactList" >
+            <intent-filter android:label="Beem Connection" >
+                <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="GroupList"
+            android:name=".ui.GroupList" >
+            <intent-filter android:label="Beem Connection" >
+                <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="@string/privacy_list_name"
+            android:name=".ui.PrivacyList" >
+            <intent-filter android:label="Beem Connection" >
+                <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:label="Sync Settings"
+            android:name="com.beem.project.beem.account.ManageAccountsSettings" >
+        </activity>
+        <!--
 			Could be interesting if we would launch beem at startup <receiver
 			android:name=".tool.BeemBroadcastReceiver" android:enabled="true">
 			<intent-filter> <action
 			android:name="android.intent.action.BOOT_COMPLETED" />
 			</intent-filter> </receiver>
-		-->
-		<provider
-			android:name=".providers.AvatarProvider"
-			android:label="Avatar Provider"
-			android:authorities="com.beem.project.beem.providers.avatarprovider"
-			android:exported="false" />
-		<provider
-			android:name=".providers.MessageProvider"
-			android:label="Message Provider"
-			android:authorities="com.beem.project.beem.providers.messageprovider" />
-		<service
-			android:name=".account.AuthenticatorService"
-			android:exported="true"
-			android:process=":auth">
-			<intent-filter>
-				<action
-					android:name="android.accounts.AccountAuthenticator" />
-			</intent-filter>
-			<meta-data
-				android:name="android.accounts.AccountAuthenticator"
-				android:resource="@xml/authenticator" />
-		</service>
-		<service
-			android:name=".account.SyncAdapterService"
-			android:exported="true"
-			android:process=":contacts">
-			<intent-filter>
-				<action
-					android:name="android.content.SyncAdapter" />
-			</intent-filter>
-			<meta-data
-				android:name="android.content.SyncAdapter"
-				android:resource="@xml/sync_contacts" />
-			<meta-data
-				android:name="android.provider.CONTACTS_STRUCTURE"
-				android:resource="@xml/contacts" />
-		</service>
-		<service
-			android:name="BeemService"
-			android:enabled="true"
-			android:label="Beem Service"
-			android:permission="com.beem.project.beem.BEEM_SERVICE">
-			<intent-filter>
-				<action
-					android:name="com.beem.project.beem.BeemService"></action>
-			</intent-filter>
-			<intent-filter>
-				<action
-					android:name="com.beem.project.beem.BeemService" />
-				<action
-					android:name="com.beem.project.beem.intent.action.SYNC" />
-				<action
-					android:name="com.beem.project.beem.intent.action.CONNECT" />
-				<action
-					android:name="com.beem.project.beem.intent.action.DISCONNECT" />
-				<action
-					android:name="com.beem.project.beem.intent.action.SEND_MESSAGE" />
-			</intent-filter>
-		</service>
-	</application>
-	<permission
-		android:permissionGroup="android.permission-group.NETWORK"
-		android:label="BeemService"
-		android:description="@string/BeemServiceDescription"
-		android:name="com.beem.project.beem.BEEM_SERVICE" />
-	<uses-permission
-		android:name="android.permission.INTERNET" />
-	<uses-permission
-		android:name="android.permission.VIBRATE" />
-	<uses-permission
-		android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-	<uses-permission
-		android:name="android.permission.ACCESS_NETWORK_STATE" />
-	<uses-permission
-		android:name="com.beem.project.beem.BEEM_SERVICE" />
-	<uses-permission
-		android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
-	<uses-permission
-		android:name="android.permission.GET_ACCOUNTS" />
-	<uses-permission
-		android:name="android.permission.READ_CONTACTS" />
-	<uses-permission
-		android:name="android.permission.WRITE_CONTACTS" />
-	<uses-permission
-		android:name="android.permission.MANAGE_ACCOUNTS" />
-	<uses-permission
-		android:name="android.permission.READ_SYNC_SETTINGS" />
-	<uses-permission
-		android:name="android.permission.WRITE_SYNC_SETTINGS" />
-	<uses-sdk
-		android:minSdkVersion="7"
-		android:targetSdkVersion="8" />
-	<supports-screens
-		android:largeScreens="true"
-		android:normalScreens="true"
-		android:smallScreens="true"
-		android:anyDensity="true" />
+        -->
+        <provider
+            android:authorities="com.beem.project.beem.providers.avatarprovider"
+            android:exported="false"
+            android:label="Avatar Provider"
+            android:name=".providers.AvatarProvider" />
+        <provider
+            android:authorities="com.beem.project.beem.providers.messageprovider"
+            android:label="Message Provider"
+            android:name=".providers.MessageProvider" />
+
+        <service
+            android:exported="true"
+            android:name=".account.AuthenticatorService"
+            android:process=":auth" >
+            <intent-filter >
+                <action android:name="android.accounts.AccountAuthenticator" />
+            </intent-filter>
+
+            <meta-data
+                android:name="android.accounts.AccountAuthenticator"
+                android:resource="@xml/authenticator" />
+        </service>
+        <service
+            android:exported="true"
+            android:name=".account.SyncAdapterService"
+            android:process=":contacts" >
+            <intent-filter >
+                <action android:name="android.content.SyncAdapter" />
+            </intent-filter>
+
+            <meta-data
+                android:name="android.content.SyncAdapter"
+                android:resource="@xml/sync_contacts" />
+            <meta-data
+                android:name="android.provider.CONTACTS_STRUCTURE"
+                android:resource="@xml/contacts" />
+        </service>
+        <service
+            android:enabled="true"
+            android:label="Beem Service"
+            android:name="BeemService"
+            android:permission="com.beem.project.beem.BEEM_SERVICE" >
+            <intent-filter >
+                <action android:name="com.beem.project.beem.BeemService" >
+                </action>
+            </intent-filter>
+            <intent-filter >
+                <action android:name="com.beem.project.beem.BeemService" />
+                <action android:name="com.beem.project.beem.intent.action.SYNC" />
+                <action android:name="com.beem.project.beem.intent.action.CONNECT" />
+                <action android:name="com.beem.project.beem.intent.action.DISCONNECT" />
+                <action android:name="com.beem.project.beem.intent.action.SEND_MESSAGE" />
+            </intent-filter>
+        </service>
+    </application>
+
+    <permission
+        android:description="@string/BeemServiceDescription"
+        android:label="BeemService"
+        android:name="com.beem.project.beem.BEEM_SERVICE"
+        android:permissionGroup="android.permission-group.NETWORK" />
+
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="com.beem.project.beem.BEEM_SERVICE" />
+    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
+    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
+    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+
+    <uses-sdk
+        android:minSdkVersion="7"
+        android:targetSdkVersion="8" />
+
+    <supports-screens
+        android:anyDensity="true"
+        android:largeScreens="true"
+        android:normalScreens="true"
+        android:smallScreens="true" />
+
 </manifest>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemService.java	Sun Nov 06 04:27:09 2011 +0100
+++ b/src/com/beem/project/beem/BeemService.java	Sun Nov 06 21:22:00 2011 +0100
@@ -62,11 +62,14 @@
 import android.app.Notification;
 import android.app.Service;
 import android.content.BroadcastReceiver;
+import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.Editor;
+import android.database.ContentObserver;
+import android.database.Cursor;
 import android.net.ConnectivityManager;
 import android.os.Bundle;
 import android.os.Handler;
@@ -75,6 +78,8 @@
 import android.os.Looper;
 import android.os.Message;
 import android.os.RemoteException;
+import android.provider.ContactsContract;
+import android.provider.ContactsContract.RawContacts;
 import android.util.Log;
 
 import com.beem.project.beem.service.XmppConnectionAdapter;
@@ -163,7 +168,6 @@
 	configure(ProviderManager.getInstance());
 	BeemNotification.BindNotification(this);
 	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
-
     }
 
     /**
--- a/src/com/beem/project/beem/ui/ContactList.java	Sun Nov 06 04:27:09 2011 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java	Sun Nov 06 21:22:00 2011 +0100
@@ -111,13 +111,16 @@
 	cursorGroup.registerContentObserver(new BeemGroupObserver(new Handler()));
 	// Get Contacts list
 	// TODO: Get contact list by account  -> Create Sqlite View or join
-	final Cursor cursorContact = getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI,
-	    new String[] { ContactsContract.RawContacts._ID, ContactsContract.RawContacts.SOURCE_ID },
-	    ContactsContract.RawContacts.ACCOUNT_NAME + "=?", new String[] { mAccountName }, null);
+	final Cursor cursorContact = getContentResolver().query(
+	    ContactsContract.RawContacts.CONTENT_URI,
+	    new String[] { ContactsContract.RawContacts._ID, ContactsContract.Contacts.DISPLAY_NAME,
+		ContactsContract.RawContacts.SOURCE_ID }, ContactsContract.RawContacts.ACCOUNT_NAME + "=?",
+	    new String[] { mAccountName }, null);
 	// TODO: GetAvatar + Presence
 	mAdapterContactList = new BeemContactList(this, R.layout.contactlistcontact, cursorContact, new String[] {
-	    ContactsContract.RawContacts._ID, ContactsContract.RawContacts.SOURCE_ID }, new int[] { R.id.avatar,
-	    R.id.contactlistpseudo, R.id.contactlistmsgperso });
+	    ContactsContract.RawContacts._ID, ContactsContract.Contacts.DISPLAY_NAME,
+	    ContactsContract.RawContacts.SOURCE_ID }, new int[] { R.id.avatar, R.id.contactlistpseudo,
+	    R.id.contactlistmsgperso });
 
 	ListView listView = (ListView) findViewById(R.id.contactlist);
 	listView.setOnItemClickListener(mOnContactClick);
@@ -306,7 +309,7 @@
 
 	@Override
 	public void bindView(View view, Context context, Cursor cursor) {
-	    String name = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.SOURCE_ID));
+	    String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
 	    String jid = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.SOURCE_ID));
 	    TextView nameText = (TextView) view.findViewById(R.id.contactlistpseudo);
 	    if (nameText != null) {