--- a/AndroidManifest.xml Mon Mar 21 00:14:20 2011 +0100
+++ b/AndroidManifest.xml Wed Mar 30 23:29:12 2011 +0200
@@ -1,70 +1,117 @@
<?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"
+<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"
+ <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"
+ <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" />
+ <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"
+ <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 Connection">
+ <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>
<action
- android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+ android:name="com.beem.project.beem.MAIN" />
+ <category
+ android:name="android.intent.category.DEFAULT" />
</intent-filter>
- </activity>
- <activity android:name=".ui.Chat" android:label="@string/chat_name"
- android:launchMode="singleTop">
- <intent-filter android:label="Beem Connection">
+ <intent-filter
+ android:label="Beem Connection">
<action
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
</intent-filter>
</activity>
- <activity android:name=".ui.ChangeStatus" android:label="@string/ChangeStatusActTitle"
- android:launchMode="singleTask" android:windowSoftInputMode="stateHidden">
- <intent-filter android:label="Beem Connection">
+ <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>
</activity>
- <activity android:name=".ui.AddContact" android:label="@string/AddCActTitle">
- <intent-filter android:label="Beem Connection">
+ <activity
+ android:name=".ui.ChangeStatus"
+ android:label="@string/ChangeStatusActTitle"
+ android:launchMode="singleTask"
+ android:windowSoftInputMode="stateHidden">
+ <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">
+ <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"
+ <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">
+ <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">
+ <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">
+ <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>
@@ -76,51 +123,80 @@
android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </receiver>
-->
- <provider android:name=".providers.AvatarProvider"
+ <provider
+ android:name=".providers.AvatarProvider"
android:authorities="com.beem.project.beem.providers.avatarprovider"
android:exported="false" />
- <meta-data android:name="android.provider.CONTACTS_STRUCTURE"
- android:resource="@xml/contacts" />
- <service android:name=".account.AuthenticatorService"
- android:exported="true" android:process=":auth">
+ <service
+ android:name=".account.AuthenticatorService"
+ android:exported="true"
+ android:process=":auth">
<intent-filter>
- <action android:name="android.accounts.AccountAuthenticator" />
+ <action
+ android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
- <meta-data android:name="android.accounts.AccountAuthenticator"
+ <meta-data
+ android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
- <service android:name=".account.SyncAdapterService"
- android:exported="true" android:process=":contacts">
+ <service
+ android:name=".account.SyncAdapterService"
+ android:exported="true"
+ android:process=":contacts">
<intent-filter>
- <action android:name="android.content.SyncAdapter" />
+ <action
+ android:name="android.content.SyncAdapter" />
</intent-filter>
- <meta-data android:name="android.content.SyncAdapter"
+ <meta-data
+ android:name="android.content.SyncAdapter"
android:resource="@xml/sync_contacts" />
</service>
- <service android:name="BeemService" android:enabled="true"
- android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_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>
+ <action
+ android:name="com.beem.project.beem.BeemService"></action>
</intent-filter>
</service>
</application>
- <permission android:permissionGroup="android.permission-group.NETWORK"
- android:label="BeemService" android:description="@string/BeemServiceDescription"
+ <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.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="8" android:targetSdkVersion="8" />
- <supports-screens android:largeScreens="true"
- android:normalScreens="true" android:smallScreens="true"
+ <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="8"
+ android:targetSdkVersion="8" />
+ <supports-screens
+ android:largeScreens="true"
+ android:normalScreens="true"
+ android:smallScreens="true"
android:anyDensity="true" />
</manifest>
\ No newline at end of file
--- a/res/xml/authenticator.xml Mon Mar 21 00:14:20 2011 +0100
+++ b/res/xml/authenticator.xml Wed Mar 30 23:29:12 2011 +0200
@@ -4,6 +4,6 @@
android:accountType="com.beem.project.com"
android:icon="@drawable/beem_launcher_icon_silver"
android:smallIcon="@drawable/beem_status_icon"
- android:label="@string/app_name" />
-<!-- android:accountPreferences="@xml/preferences" -->
+ android:label="@string/app_name"
+ android:accountPreferences="@xml/preferences" />
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemConnection.java Mon Mar 21 00:14:20 2011 +0100
+++ b/src/com/beem/project/beem/BeemConnection.java Wed Mar 30 23:29:12 2011 +0200
@@ -95,6 +95,10 @@
mSettings.unregisterOnSharedPreferenceChangeListener(mPreferenceListener);
}
+ public void setNoPresence() {
+ mConnectionConfiguration.setSendPresence(false);
+ }
+
/**
* @return the login
*/
--- a/src/com/beem/project/beem/account/Authenticator.java Mon Mar 21 00:14:20 2011 +0100
+++ b/src/com/beem/project/beem/account/Authenticator.java Wed Mar 30 23:29:12 2011 +0200
@@ -1,7 +1,5 @@
package com.beem.project.beem.account;
-import com.beem.project.beem.ui.wizard.AccountConfigure;
-
import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
@@ -10,6 +8,9 @@
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.util.Log;
+
+import com.beem.project.beem.ui.wizard.AccountConfigure;
public class Authenticator extends AbstractAccountAuthenticator {
@@ -23,6 +24,8 @@
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
String[] requiredFeatures, Bundle options) throws NetworkErrorException {
+ Log.v("AUTHENTICATOR", "Add account request type " + accountType + " token " + authTokenType + " features " + requiredFeatures + " option " + options);
+
Intent intent = new Intent(mContext, AccountConfigure.class);
intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
Bundle reply = new Bundle();
--- a/src/com/beem/project/beem/account/SyncAdapterService.java Mon Mar 21 00:14:20 2011 +0100
+++ b/src/com/beem/project/beem/account/SyncAdapterService.java Wed Mar 30 23:29:12 2011 +0200
@@ -64,30 +64,32 @@
return mSyncAdapter;
}
- public static void performSync(Context context, Account account, Bundle extras, String authority,
+ public static void performSync(Context context, final Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) throws OperationCanceledException {
mContentResolver = context.getContentResolver();
Log.i(TAG, "performSync: " + account.toString());
BeemConnection beemco = new BeemConnection(mContext.getSharedPreferences(account.name, MODE_PRIVATE), null);
- String host = StringUtils.parseServer(account.name);
- String user = StringUtils.parseName(account.name);
- XMPPConnection con = new XMPPConnection(host);
+ beemco.setNoPresence();
+ XMPPConnection con = new XMPPConnection(beemco.getConnectionConfiguration());
try {
con.connect();
- con.login(user, beemco.getPassword());
- } catch (XMPPException e) {
- Log.d(TAG, "Error during sync connection", e);
- }
- Roster roster = con.getRoster();
- if (roster != null) {
- for (RosterEntry entry : roster.getEntries()) {
- if (entry != null) {
- addEntry(account, entry);
+ con.login(beemco.getLogin(), beemco.getPassword(), "BEEM_SYNC_ADAPTER");
+
+ Roster roster = con.getRoster();
+ if (roster != null) {
+ for (RosterEntry entry : roster.getEntries()) {
+ if (entry != null) {
+ addEntry(account, entry);
+ }
}
}
+ } catch (XMPPException e) {
+ Log.e(TAG, "Error while connecting with syncAdapter", e);
}
+ con.disconnect();
+
}
private static void addEntry(Account account, RosterEntry entry) {
@@ -106,8 +108,7 @@
builder.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
builder.withValue(StructuredName.DISPLAY_NAME, entry.getUser());
ops.add(builder.build());
-
- //Add row contact information
+
builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
builder.withValueBackReference(Data.RAW_CONTACT_ID, 0);
builder.withValue(Data.MIMETYPE, Im.CONTENT_ITEM_TYPE);
@@ -121,7 +122,6 @@
} catch (Exception e) {
Log.d(TAG, "Error during add of contact", e);
}
-
}
}
--- a/src/com/beem/project/beem/ui/Chat.java Mon Mar 21 00:14:20 2011 +0100
+++ b/src/com/beem/project/beem/ui/Chat.java Wed Mar 30 23:29:12 2011 +0200
@@ -40,33 +40,35 @@
Flavien Astraud, November 26, 2009
Head of the EIP Laboratory.
-*/
+ */
package com.beem.project.beem.ui;
+import java.io.IOException;
+import java.io.InputStream;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.io.InputStream;
-import java.io.IOException;
import org.jivesoftware.smack.packet.Presence.Mode;
import org.jivesoftware.smack.util.StringUtils;
import android.app.Activity;
import android.app.Dialog;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -91,7 +93,6 @@
import android.widget.ListView;
import android.widget.TextView;
-
import com.beem.project.beem.R;
import com.beem.project.beem.providers.AvatarProvider;
import com.beem.project.beem.service.Contact;
@@ -510,8 +511,8 @@
@Override
public void run() {
if (msg.getType() == Message.MSG_TYPE_ERROR) {
- mListMessages.add(new MessageText(fromBareJid, mContact.getName(),
- msg.getBody(), true, msg.getTimestamp()));
+ mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(), true, msg
+ .getTimestamp()));
mMessagesListAdapter.notifyDataSetChanged();
} else if (msg.getBody() != null) {
MessageText lastMessage = null;
@@ -523,8 +524,8 @@
lastMessage.setTimestamp(msg.getTimestamp());
mListMessages.set(mListMessages.size() - 1, lastMessage);
} else if (msg.getBody() != null)
- mListMessages.add(new MessageText(fromBareJid, mContact.getName(),
- msg.getBody(), false, msg.getTimestamp()));
+ mListMessages.add(new MessageText(fromBareJid, mContact.getName(), msg.getBody(),
+ false, msg.getTimestamp()));
mMessagesListAdapter.notifyDataSetChanged();
}
}
@@ -581,15 +582,13 @@
} else {
Mode m = Status.getPresenceModeFromStatus(mContact.getStatus());
if (m == null)
- setTitle(getString(R.string.chat_name) + " " + name
- + " (" + getString(R.string.contact_status_msg_offline) + ")");
+ setTitle(getString(R.string.chat_name) + " " + name + " ("
+ + getString(R.string.contact_status_msg_offline) + ")");
else
setTitle(getString(R.string.chat_name) + " " + name + " (" + m.name() + ")");
}
}
-
-
/**
* Update the contact status icon.
*/
@@ -610,7 +609,6 @@
/**
* Get a Drawable containing the avatar icon.
- *
* @param avatarId the avatar id to retrieve or null to get default
* @return a Drawable
*/
@@ -622,7 +620,7 @@
try {
try {
in = getContentResolver().openInputStream(uri);
- avatarDrawable = Drawable.createFromStream(in, avatarId);
+ avatarDrawable = Drawable.createFromStream(in, avatarId);
} finally {
if (in != null)
in.close();
@@ -705,7 +703,7 @@
View sv;
if (convertView == null) {
LayoutInflater inflater = Chat.this.getLayoutInflater();
- sv = inflater.inflate(R.layout.chat_msg_row, null);
+ sv = inflater.inflate(R.layout.chat_msg_row, null);
} else {
sv = convertView;
}
@@ -762,8 +760,7 @@
* @param message A String containing the message.
* @param isError if the message is an error message.
*/
- public MessageText(final String bareJid, final String name, final String message,
- final boolean isError) {
+ public MessageText(final String bareJid, final String name, final String message, final boolean isError) {
mBareJid = bareJid;
mName = name;
mMessage = message;
@@ -778,8 +775,8 @@
* @param isError if the message is an error message.
* @param date the time of the message.
*/
- public MessageText(final String bareJid, final String name, final String message,
- final boolean isError, Date date) {
+ public MessageText(final String bareJid, final String name, final String message, final boolean isError,
+ Date date) {
mBareJid = bareJid;
mName = name;
mMessage = message;
@@ -949,4 +946,18 @@
}
}
}
+
+ public class MyReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Context c = getApplicationContext();
+ Intent sendIntent = new Intent();
+ if ( intent.getAction().equals(Intent.ACTION_SENDTO) ) {
+ sendIntent.setClass(c, Chat.class);
+ context.startActivity(sendIntent);
+ }
+ }
+ }
+
}