# HG changeset patch # User dasilvj # Date 1255008382 -7200 # Node ID eb1ce472a1a5788fef304cb76868082d10526fc6 # Parent 63cffd88721d1fc5f8b3f86823cadef95a6b17e5# Parent aa654c8efd1b4ba70bb6ea2d2407408dd238342d Merge diff -r aa654c8efd1b -r eb1ce472a1a5 .classpath --- a/.classpath Thu Oct 08 15:00:12 2009 +0200 +++ b/.classpath Thu Oct 08 15:26:22 2009 +0200 @@ -1,34 +1,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r aa654c8efd1b -r eb1ce472a1a5 AndroidManifest.xml --- a/AndroidManifest.xml Thu Oct 08 15:00:12 2009 +0200 +++ b/AndroidManifest.xml Thu Oct 08 15:26:22 2009 +0200 @@ -87,6 +87,6 @@ - + diff -r aa654c8efd1b -r eb1ce472a1a5 Beem-ecipse-formatter.xml --- a/Beem-ecipse-formatter.xml Thu Oct 08 15:00:12 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r aa654c8efd1b -r eb1ce472a1a5 eclipse_formatter.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse_formatter.xml Thu Oct 08 15:26:22 2009 +0200 @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r aa654c8efd1b -r eb1ce472a1a5 res/values --- a/res/values Thu Oct 08 15:00:12 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -values-en \ No newline at end of file diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/jingle/JingleService.java --- a/src/com/beem/project/beem/jingle/JingleService.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/jingle/JingleService.java Thu Oct 08 15:26:22 2009 +0200 @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; + import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smackx.jingle.JingleManager; @@ -26,7 +27,7 @@ public class JingleService { private static final String TAG = "JingleService"; private JingleManager mJingleManager; - private List mMediaManagers; + private final List mMediaManagers; private JingleSession mIn; private JingleSession mOut; @@ -36,7 +37,7 @@ */ public JingleService(final XMPPConnection xmppConnection) { BasicTransportManager bt = new BasicTransportManager(); - //JingleTransportManager tm = new ICETransportManager(); + // JingleTransportManager tm = new ICETransportManager(); mMediaManagers = new ArrayList(); mMediaManagers.add(new MicrophoneRTPManager(bt)); @@ -89,13 +90,15 @@ @Override public void sessionClosed(String reason, JingleSession jingleSession) { - //System.out.println("Session " + jingleSession.getResponder() + "closedd because " + reason); + // System.out.println("Session " + jingleSession.getResponder() + + // "closedd because " + reason); } @Override public void sessionClosedOnError(XMPPException e, JingleSession jingleSession) { // TODO Auto-generated method stub - // System.out.println("Session " + jingleSession.getResponder() + " closed"); + // System.out.println("Session " + jingleSession.getResponder() + + // " closed"); } @@ -107,16 +110,18 @@ @Override public void sessionEstablished(PayloadType pt, TransportCandidate remoteCandidate, TransportCandidate localCandidate, JingleSession jingleSession) { - //System.out.println("Session established"); - //System.out.println("Je recois sur " + remoteCandidate.getIp() + ":" + remoteCandidate.getPort()); + // System.out.println("Session established"); + // System.out.println("Je recois sur " + remoteCandidate.getIp() + + // ":" + remoteCandidate.getPort()); // TODO choose the right RTPReceiver depending on the payload type - //RTPReceiver rtpReceiver = new RTPReceiver(remoteCandidate.getPort()); + // RTPReceiver rtpReceiver = new + // RTPReceiver(remoteCandidate.getPort()); Log.d(TAG, "Session " + jingleSession.getResponder() + "established"); } @Override public void sessionMediaReceived(JingleSession jingleSession, String participant) { - //System.out.println("Session Media received from " + participant); + // System.out.println("Session Media received from " + participant); } @Override @@ -130,6 +135,8 @@ */ private class BeemJingleCallerSessionListener implements JingleSessionListener { + private static final int SLP_DURATION = 20000; + /** * constructor. */ @@ -140,18 +147,21 @@ @Override public void sessionClosed(final String reason, final JingleSession jingleSession) { - // System.out.println("Session " + jingleSession.getResponder() + "closed because " + reason); + // System.out.println("Session " + jingleSession.getResponder() + + // "closed because " + reason); } @Override public void sessionClosedOnError(final XMPPException e, final JingleSession jingleSession) { - // System.out.println("Session " + jingleSession.getResponder() + " closed on error"); + // System.out.println("Session " + jingleSession.getResponder() + + // " closed on error"); } @Override public void sessionDeclined(final String reason, final JingleSession jingleSession) { - // System.out.println("Session " + jingleSession.getResponder() + "declined because " + reason); + // System.out.println("Session " + jingleSession.getResponder() + + // "declined because " + reason); Log.d(TAG, "Session " + jingleSession.getResponder() + "declined because " + reason); } @@ -162,19 +172,20 @@ // String name = localCandidate.getName(); String ip = localCandidate.getIp(); int port = localCandidate.getPort(); - // System.out.println("Session established waiting connection on " + ip + ":" + port); + // System.out.println("Session established waiting connection on " + + // ip + ":" + port); RTPTransmitter transm = new PCMTransmitter(ip, port); transm.run(); try { - Thread.sleep(20000); + Thread.sleep(SLP_DURATION); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } transm.stop(); - // System.out.println("End of transfer"); + // System.out.println("End of transfer"); } diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/jingle/MicrophoneRTPSession.java --- a/src/com/beem/project/beem/jingle/MicrophoneRTPSession.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/jingle/MicrophoneRTPSession.java Thu Oct 08 15:26:22 2009 +0200 @@ -23,12 +23,13 @@ * @param jingleSession the current jingle session */ public MicrophoneRTPSession(final PayloadType payloadType, final TransportCandidate remote, - final TransportCandidate local, final String mediaLocator, final JingleSession jingleSession) { + final TransportCandidate local, final String mediaLocator, final JingleSession jingleSession) { super(payloadType, remote, local, mediaLocator, jingleSession); - // TODO le transmitter ne devrait peut etre pas etre init ici, c'est peut etre encore un peu tot, a voir. + // TODO le transmitter ne devrait peut etre pas etre init ici, c'est + // peut etre encore un peu tot, a voir. mTransmitter = new PCMTransmitter(remote.getIp(), getRemote().getPort()); - //mReceiver = new MicroRTPReceiver(getLocal().getPort()); + // mReceiver = new MicroRTPReceiver(getLocal().getPort()); } @Override diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/jingle/PCMTransmitter.java --- a/src/com/beem/project/beem/jingle/PCMTransmitter.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/jingle/PCMTransmitter.java Thu Oct 08 15:26:22 2009 +0200 @@ -10,6 +10,10 @@ */ public class PCMTransmitter extends RTPTransmitter { + private static final int BUFF_SIZE = 1024; + private static final int RATE_IN_HZ = 8000; + private static final int SLP_DURATION = 200; + /** * Constructor. * @param remoteIP receiver IP. @@ -21,18 +25,18 @@ @Override void start() { - AudioRecord audRec = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, 8000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT, AudioRecord.getMinBufferSize(8000, - AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT)); - byte[] audioData = new byte[1024]; + AudioRecord audRec = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, RATE_IN_HZ, + AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT, AudioRecord.getMinBufferSize( + RATE_IN_HZ, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT)); + byte[] audioData = new byte[BUFF_SIZE]; int byteReaded = 0; while (!isKillme()) { - byteReaded = audRec.read(audioData, byteReaded, 1024); + byteReaded = audRec.read(audioData, byteReaded, BUFF_SIZE); System.out.println("readed " + byteReaded); getRtpSession().sendData(audioData); } try { - Thread.sleep(200); + Thread.sleep(SLP_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/jingle/RTPReceiver.java --- a/src/com/beem/project/beem/jingle/RTPReceiver.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/jingle/RTPReceiver.java Thu Oct 08 15:26:22 2009 +0200 @@ -10,7 +10,6 @@ /** * abstract RTP receiver class. * @author nikita - * */ public abstract class RTPReceiver implements Runnable, RTPAppIntf { diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/jingle/demo/JingleCallActivity.java --- a/src/com/beem/project/beem/jingle/demo/JingleCallActivity.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/jingle/demo/JingleCallActivity.java Thu Oct 08 15:26:22 2009 +0200 @@ -23,6 +23,9 @@ */ public class JingleCallActivity extends Activity { + private static final int SLP_DURATION = 3000; + private static final int DEFAULT_XMPP_PORT = 5222; + private XMPPConnection mConnection; private ConnectionConfiguration mConf; private JingleService mJingle; @@ -45,7 +48,7 @@ super.onCreate(savedInstanceState); setContentView(R.layout.jingle_call_activity); // localhost mConf = new ConnectionConfiguration("10.0.2.2", 5222); - mConf = new ConnectionConfiguration("elyzion.net", 5222); + mConf = new ConnectionConfiguration("elyzion.net", DEFAULT_XMPP_PORT); mConf.setSecurityMode(SecurityMode.required); mEdJID = (EditText) findViewById(R.id.jingledemocalljid); mEdPassword = (EditText) findViewById(R.id.jingledemocallpassword); @@ -61,16 +64,16 @@ String password = mEdPassword.getText().toString(); try { mConnection.connect(); - Thread.sleep(3000); - mConnection.login(login, password); - mJingle = new JingleService(mConnection); - mJingle.initWhenConntected(mConnection); - mBtcall.setEnabled(true); - Toast.makeText(JingleCallActivity.this, "Connected", Toast.LENGTH_SHORT); - } catch (XMPPException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InterruptedException e) { + Thread.sleep(SLP_DURATION); + mConnection.login(login, password); + mJingle = new JingleService(mConnection); + mJingle.initWhenConntected(mConnection); + mBtcall.setEnabled(true); + Toast.makeText(JingleCallActivity.this, "Connected", Toast.LENGTH_SHORT); + } catch (XMPPException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } @@ -87,7 +90,7 @@ Toast.makeText(JingleCallActivity.this, "Appel en cours", Toast.LENGTH_SHORT); } else Toast.makeText(JingleCallActivity.this, "Remplir le champ (JID complet en toto@tutu.com/truc)", - Toast.LENGTH_SHORT); + Toast.LENGTH_SHORT); } }); diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/jingle/demo/package-info.java --- a/src/com/beem/project/beem/jingle/demo/package-info.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/jingle/demo/package-info.java Thu Oct 08 15:26:22 2009 +0200 @@ -2,3 +2,4 @@ * Package for testing the Jingle classes. */ package com.beem.project.beem.jingle.demo; + diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/jingle/package-info.java --- a/src/com/beem/project/beem/jingle/package-info.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/jingle/package-info.java Thu Oct 08 15:26:22 2009 +0200 @@ -2,3 +2,4 @@ * This package contains the class used by the Beem Jingle process. */ package com.beem.project.beem.jingle; + diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/package-info.java --- a/src/com/beem/project/beem/package-info.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/package-info.java Thu Oct 08 15:26:22 2009 +0200 @@ -2,3 +2,4 @@ * This package contains the main class for the Beem application. */ package com.beem.project.beem; + diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/provider/Beem.java --- a/src/com/beem/project/beem/provider/Beem.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/provider/Beem.java Thu Oct 08 15:26:22 2009 +0200 @@ -4,165 +4,186 @@ import android.provider.BaseColumns; /** - * Convenience definitions for BEEM's providers + * Convenience definitions for BEEM's providers. */ public final class Beem { /** - * Contacts table + * Contacts table. */ public static final class Contacts implements BaseColumns { /** - * The query used to create the table + * The query used to create the table. */ - public final static String QUERY_CREATE = "CREATE TABLE " + Beem.CONTACTS_TABLE_NAME + " (" - + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," - + Contacts.UID + " INTEGER, " + Contacts.JID - + " INTEGER," + Contacts.NICKNAME + " TEXT," - + Contacts.ALIAS + " TEXT," + Contacts.DATE_CREATED - + " INTEGER," + Contacts.DATE_MODIFIED + " INTEGER" - + ");"; + public static final String QUERY_CREATE = "CREATE TABLE " + Beem.CONTACTS_TABLE_NAME + " (" + BaseColumns._ID + + " INTEGER PRIMARY KEY AUTOINCREMENT," + Contacts.UID + " INTEGER, " + Contacts.JID + " INTEGER," + + Contacts.NICKNAME + " TEXT," + Contacts.ALIAS + " TEXT," + Contacts.DATE_CREATED + " INTEGER," + + Contacts.DATE_MODIFIED + " INTEGER" + ");"; /** - * The content:// style URL for Contacts table + * The content:// style URL for Contacts table. */ - public final static Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/contacts"); + public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/contacts"); /** * The MIME type of {@link #CONTENT_URI} providing a directory of contacts. */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.beem.project.contact"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.beem.project.contact"; /** * The MIME type of a {@link #CONTENT_URI} sub-directory of a single contact. */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.beem.project.contact"; + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.beem.project.contact"; /** - * The default sort order for this table + * The default sort order for this table. */ - public final static String DEFAULT_SORT_ORDER = "nickname ASC"; + public static final String DEFAULT_SORT_ORDER = "nickname ASC"; /** * The user id having the contact *

* Type: INTEGER *

+ * . */ - public final static String UID = "uid"; + public static final String UID = "uid"; /** * The JabberID of the contact *

* Type: INTEGER *

+ * . */ - public final static String JID = "jid"; + public static final String JID = "jid"; /** * The nickname of the contact *

* Type: TEXT *

+ * . */ - public final static String NICKNAME = "nickname"; + public static final String NICKNAME = "nickname"; /** * The alias of the contact *

* Type: TEXT *

+ * . */ - public final static String ALIAS = "alias"; + public static final String ALIAS = "alias"; /** * The timestamp for when the contact was created *

* Type: INTEGER (long from System.curentTimeMillis()) *

+ * . */ - public final static String DATE_CREATED = "created"; + public static final String DATE_CREATED = "created"; /** * The timestamp for when the contact was last modified *

* Type: INTEGER (long from System.curentTimeMillis()) *

+ * . */ - public final static String DATE_MODIFIED = "modified"; + public static final String DATE_MODIFIED = "modified"; } /** - * Users table + * Users table. */ public static final class Users implements BaseColumns { /** - * The query used to create the table + * The query used to create the table. */ - public final static String QUERY_CREATE = "CREATE TABLE " + Beem.USERS_TABLE_NAME + " (" - + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," - + Users.JUSERNAME + " TEXT," + Users.DATE_CREATED - + " INTEGER," + Users.DATE_MODIFIED + " INTEGER" + ");"; + public static final String QUERY_CREATE = "CREATE TABLE " + Beem.USERS_TABLE_NAME + " (" + BaseColumns._ID + + " INTEGER PRIMARY KEY AUTOINCREMENT," + Users.JUSERNAME + " TEXT," + Users.DATE_CREATED + " INTEGER," + + Users.DATE_MODIFIED + " INTEGER" + ");"; /** - * The content:// style URL for Contacts table + * The content:// style URL for Contacts table. */ - public final static Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/users"); + public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/users"); /** * The MIME type of {@link #CONTENT_URI} providing a directory of users. */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.beem.project.user"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.beem.project.user"; /** * The MIME type of a {@link #CONTENT_URI} sub-directory of a single user. */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.beem.project.user"; + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.beem.project.user"; /** - * The default sort order for this table + * The default sort order for this table. */ - public final static String DEFAULT_SORT_ORDER = "_id ASC"; + public static final String DEFAULT_SORT_ORDER = "_id ASC"; /** * The Jabber username of the user *

* Type: TEXT *

+ * . */ - public final static String JUSERNAME = "username"; + public static final String JUSERNAME = "username"; /** * The timestamp for when the user was created *

* Type: INTEGER (long from System.curentTimeMillis()) *

+ * . */ - public final static String DATE_CREATED = "created"; + public static final String DATE_CREATED = "created"; /** * The timestamp for when the user was last modified *

* Type: INTEGER (long from System.curentTimeMillis()) *

+ * . */ - public final static String DATE_MODIFIED = "modified"; + public static final String DATE_MODIFIED = "modified"; } - public final static String AUTHORITY = "com.beem.project.provider"; + /** + * AUTHORITY. + */ + public static final String AUTHORITY = "com.beem.project.provider"; - public final static String DB_NAME = "beem.db"; - public final static int DB_VERSION = 2; - - public final static String USERS_TABLE_NAME = "users"; - - public final static String CONTACTS_TABLE_NAME = "contacts"; + /** + * DB Name. + */ + public static final String DB_NAME = "beem.db"; /** - * Constructor + * DB Version. + */ + public static final int DB_VERSION = 2; + + /** + * Name of the users table. + */ + public static final String USERS_TABLE_NAME = "users"; + + /** + * Name of the contacts table. + */ + public static final String CONTACTS_TABLE_NAME = "contacts"; + + /** + * Constructor. */ private Beem() { } diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/provider/BeemDatabaseHelper.java --- a/src/com/beem/project/beem/provider/BeemDatabaseHelper.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/provider/BeemDatabaseHelper.java Thu Oct 08 15:26:22 2009 +0200 @@ -5,13 +5,25 @@ import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; +/** + * BeemDatabaseHelper class. + * @author Jamu + */ public class BeemDatabaseHelper extends SQLiteOpenHelper { - private String mTag; - private String mTableName; - private String mCreationQuery; + private final String mTag; + private final String mTableName; + private final String mCreationQuery; - public BeemDatabaseHelper(Context context, String tag, String tableName, String creationQuery) { + /** + * BeemDatabaseHelper class. + * @param context the context. + * @param tag the tag. + * @param tableName the tableName. + * @param creationQuery the creation query. + */ + public BeemDatabaseHelper(final Context context, final String tag, final String tableName, + final String creationQuery) { super(context, Beem.DB_NAME, null, Beem.DB_VERSION); this.mTag = tag; diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/provider/ContactProvider.java --- a/src/com/beem/project/beem/provider/ContactProvider.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/provider/ContactProvider.java Thu Oct 08 15:26:22 2009 +0200 @@ -1,6 +1,3 @@ -/** - * - */ package com.beem.project.beem.provider; import java.util.HashMap; @@ -18,22 +15,23 @@ import android.text.TextUtils; /** + * ContactProvider class. * @author dasilvj */ public class ContactProvider extends ContentProvider { - private final static String TAG = "ContactProvider"; + private static final String TAG = "ContactProvider"; private static HashMap sContactsProjectionMap; - private static final int CONTACTS = 1; - private static final int CONTACT_ID = 2; + private static final int CONTACTS = 1; + private static final int CONTACT_ID = 2; - private static final UriMatcher sUriMatcher; + private static final UriMatcher S_URI_MATCHER; static { - sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); - sUriMatcher.addURI(Beem.AUTHORITY, "contacts", CONTACTS); - sUriMatcher.addURI(Beem.AUTHORITY, "contacts/#", CONTACT_ID); + S_URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); + S_URI_MATCHER.addURI(Beem.AUTHORITY, "contacts", CONTACTS); + S_URI_MATCHER.addURI(Beem.AUTHORITY, "contacts/#", CONTACT_ID); sContactsProjectionMap = new HashMap(); sContactsProjectionMap.put(BaseColumns._ID, BaseColumns._ID); @@ -45,14 +43,14 @@ sContactsProjectionMap.put(Beem.Contacts.DATE_MODIFIED, Beem.Contacts.DATE_MODIFIED); } - private BeemDatabaseHelper mOpenHelper; + private BeemDatabaseHelper mOpenHelper; @Override public int delete(Uri uri, String selection, String[] selectionArgs) { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count; - switch (sUriMatcher.match(uri)) { + switch (S_URI_MATCHER.match(uri)) { case CONTACTS: count = db.delete(Beem.CONTACTS_TABLE_NAME, selection, selectionArgs); break; @@ -73,7 +71,7 @@ @Override public String getType(Uri uri) { - switch (sUriMatcher.match(uri)) { + switch (S_URI_MATCHER.match(uri)) { case CONTACTS: return Beem.Contacts.CONTENT_TYPE; @@ -88,7 +86,7 @@ @Override public Uri insert(Uri uri, ContentValues initialValues) { // Validate the requested uri - if (sUriMatcher.match(uri) != CONTACTS) { + if (S_URI_MATCHER.match(uri) != CONTACTS) { throw new IllegalArgumentException("Unknown URI " + uri); } @@ -102,28 +100,28 @@ Long now = Long.valueOf(System.currentTimeMillis()); // Make sure that the fields are all set - if (values.containsKey(Beem.Contacts.UID) == false) { + if (!values.containsKey(Beem.Contacts.UID)) { // TODO :: Must check that the UID exists using UserProvider throw new SQLException("No UID specified. Failed to insert row into " + uri); } - if (values.containsKey(Beem.Contacts.JID) == false) { + if (!values.containsKey(Beem.Contacts.JID)) { values.put(Beem.Contacts.JID, ""); } - if (values.containsKey(Beem.Contacts.NICKNAME) == false) { + if (!values.containsKey(Beem.Contacts.NICKNAME)) { values.put(Beem.Contacts.JID, ""); } - if (values.containsKey(Beem.Contacts.ALIAS) == false) { + if (!values.containsKey(Beem.Contacts.ALIAS)) { values.put(Beem.Contacts.JID, ""); } - if (values.containsKey(Beem.Contacts.DATE_CREATED) == false) { + if (!values.containsKey(Beem.Contacts.DATE_CREATED)) { values.put(Beem.Contacts.DATE_CREATED, now); } - if (values.containsKey(Beem.Contacts.DATE_MODIFIED) == false) { + if (!values.containsKey(Beem.Contacts.DATE_MODIFIED)) { values.put(Beem.Contacts.DATE_MODIFIED, now); } @@ -148,7 +146,7 @@ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - switch (sUriMatcher.match(uri)) { + switch (S_URI_MATCHER.match(uri)) { case CONTACTS: qb.setTables(Beem.CONTACTS_TABLE_NAME); qb.setProjectionMap(sContactsProjectionMap); @@ -176,7 +174,8 @@ SQLiteDatabase db = mOpenHelper.getReadableDatabase(); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy); - // Tell the cursor what uri to watch, so it knows when its source data changes + // Tell the cursor what uri to watch, so it knows when its source data + // changes c.setNotificationUri(getContext().getContentResolver(), uri); return c; } @@ -186,7 +185,7 @@ SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count; - switch (sUriMatcher.match(uri)) { + switch (S_URI_MATCHER.match(uri)) { case CONTACTS: count = db.update(Beem.CONTACTS_TABLE_NAME, values, selection, selectionArgs); break; diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/provider/UserProvider.java --- a/src/com/beem/project/beem/provider/UserProvider.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/provider/UserProvider.java Thu Oct 08 15:26:22 2009 +0200 @@ -14,20 +14,24 @@ import android.provider.BaseColumns; import android.text.TextUtils; +/** + * UserProvider class. + * @author Jamu + */ public class UserProvider extends ContentProvider { - private final static String TAG = "UserProvider"; + private static final String TAG = "UserProvider"; private static HashMap sUsersProjectionMap; - private static final int USERS = 1; - private static final int USER_ID = 2; + private static final int USERS = 1; + private static final int USER_ID = 2; - private static final UriMatcher sUriMatcher; + private static final UriMatcher S_URI_MATCHER; static { - sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); - sUriMatcher.addURI(Beem.AUTHORITY, "users", USERS); - sUriMatcher.addURI(Beem.AUTHORITY, "users/#", USER_ID); + S_URI_MATCHER = new UriMatcher(UriMatcher.NO_MATCH); + S_URI_MATCHER.addURI(Beem.AUTHORITY, "users", USERS); + S_URI_MATCHER.addURI(Beem.AUTHORITY, "users/#", USER_ID); sUsersProjectionMap = new HashMap(); sUsersProjectionMap.put(BaseColumns._ID, BaseColumns._ID); @@ -36,14 +40,14 @@ sUsersProjectionMap.put(Beem.Users.DATE_MODIFIED, Beem.Users.DATE_MODIFIED); } - private BeemDatabaseHelper mOpenHelper; + private BeemDatabaseHelper mOpenHelper; @Override public int delete(Uri uri, String selection, String[] selectionArgs) { SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count; - switch (sUriMatcher.match(uri)) { + switch (S_URI_MATCHER.match(uri)) { case USERS: count = db.delete(Beem.USERS_TABLE_NAME, selection, selectionArgs); break; @@ -64,7 +68,7 @@ @Override public String getType(Uri uri) { - switch (sUriMatcher.match(uri)) { + switch (S_URI_MATCHER.match(uri)) { case USERS: return Beem.Users.CONTENT_TYPE; @@ -79,7 +83,7 @@ @Override public Uri insert(Uri uri, ContentValues initialValues) { // Validate the requested uri - if (sUriMatcher.match(uri) != USERS) { + if (S_URI_MATCHER.match(uri) != USERS) { throw new IllegalArgumentException("Unknown URI " + uri); } @@ -93,15 +97,15 @@ Long now = Long.valueOf(System.currentTimeMillis()); // Make sure that the fields are all set - if (values.containsKey(Beem.Users.JUSERNAME) == false) { + if (!values.containsKey(Beem.Users.JUSERNAME)) { throw new SQLException("No JUSERNAME specified. Failed to insert row into " + uri); } - if (values.containsKey(Beem.Users.DATE_CREATED) == false) { + if (!values.containsKey(Beem.Users.DATE_CREATED)) { values.put(Beem.Users.DATE_CREATED, now); } - if (values.containsKey(Beem.Users.DATE_MODIFIED) == false) { + if (!values.containsKey(Beem.Users.DATE_MODIFIED)) { values.put(Beem.Users.DATE_MODIFIED, now); } @@ -126,7 +130,7 @@ public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - switch (sUriMatcher.match(uri)) { + switch (S_URI_MATCHER.match(uri)) { case USERS: qb.setTables(Beem.USERS_TABLE_NAME); qb.setProjectionMap(sUsersProjectionMap); @@ -154,7 +158,8 @@ SQLiteDatabase db = mOpenHelper.getReadableDatabase(); Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy); - // Tell the cursor what uri to watch, so it knows when its source data changes + // Tell the cursor what uri to watch, so it knows when its source data + // changes c.setNotificationUri(getContext().getContentResolver(), uri); return c; } @@ -164,7 +169,7 @@ SQLiteDatabase db = mOpenHelper.getWritableDatabase(); int count; - switch (sUriMatcher.match(uri)) { + switch (S_URI_MATCHER.match(uri)) { case USERS: count = db.update(Beem.USERS_TABLE_NAME, values, selection, selectionArgs); break; diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/provider/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/provider/package-info.java Thu Oct 08 15:26:22 2009 +0200 @@ -0,0 +1,5 @@ +/** + * This package contains the class concerning the providers of Beem. + */ +package com.beem.project.beem.provider; + diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/BeemChatManager.java --- a/src/com/beem/project/beem/service/BeemChatManager.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/BeemChatManager.java Thu Oct 08 15:26:22 2009 +0200 @@ -29,14 +29,12 @@ /** * An adapter for smack's ChatManager. This class provides functionnality to handle chats. - * * @author darisk */ public class BeemChatManager extends IChatManager.Stub { /** * A listener for all the chat creation event that happens on the connection. - * * @author darisk */ private class ChatListener implements ChatStateListener, ChatManagerListener, MessageListener { @@ -71,22 +69,20 @@ /** * Set a notification of a new chat in android. - * - * @param chat - * The chat to access by the notification + * @param chat The chat to access by the notification */ private void notifyNewChat(IChat chat) { try { String text = chat.getParticipant().getJID(); Notification notif = new Notification(com.beem.project.beem.R.drawable.notify_message, text, System - .currentTimeMillis()); + .currentTimeMillis()); notif.defaults = Notification.DEFAULT_ALL; notif.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, SendIM.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.setData(chat.getParticipant().toUri()); notif.setLatestEventInfo(mService, text, mService.getString(R.string.BeemChatManagerNewMessage), - PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); + PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)); int id = chat.hashCode(); mService.sendNotification(id, notif); } catch (RemoteException e) { @@ -151,20 +147,15 @@ private final ChatManager mAdaptee; private final Map mChats = new HashMap(); private final ChatListener mChatListener = new ChatListener(); - private final RemoteCallbackList mRemoteChatCreationListeners - = new RemoteCallbackList(); - private final RemoteCallbackList mRemoteMessageListeners - = new RemoteCallbackList(); + private final RemoteCallbackList mRemoteChatCreationListeners = new RemoteCallbackList(); + private final RemoteCallbackList mRemoteMessageListeners = new RemoteCallbackList(); private final BeemService mService; /** * Constructor. - * - * @param chatManager - * the smack ChatManager to adapt - * @param service - * the service which runs the chat manager + * @param chatManager the smack ChatManager to adapt + * @param service the service which runs the chat manager */ public BeemChatManager(final ChatManager chatManager, final BeemService service) { mService = service; @@ -182,11 +173,8 @@ /** * Create a chat session. - * - * @param contact - * the contact you want to chat with - * @param listener - * listener to use for chat events on this chat session + * @param contact the contact you want to chat with + * @param listener listener to use for chat events on this chat session * @return the chat session */ public IChat createChat(Contact contact, IMessageListener listener) { @@ -196,11 +184,8 @@ /** * Create a chat session. - * - * @param jid - * the jid of the contact you want to chat with - * @param listener - * listener to use for chat events on this chat session + * @param jid the jid of the contact you want to chat with + * @param listener listener to use for chat events on this chat session * @return the chat session */ public IChat createChat(String jid, IMessageListener listener) { @@ -233,9 +218,7 @@ /** * Get an existing ChatAdapter or create it if necessary. - * - * @param chat - * The real instance of smack chat + * @param chat The real instance of smack chat * @return a chat adapter register in the manager */ private ChatAdapter getChat(Chat chat) { diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/ChatAdapter.java --- a/src/com/beem/project/beem/service/ChatAdapter.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/ChatAdapter.java Thu Oct 08 15:26:22 2009 +0200 @@ -16,11 +16,13 @@ * @author darisk */ public class ChatAdapter extends IChat.Stub { - private Chat mAdaptee; - private Contact mParticipant; + private final Chat mAdaptee; + private final Contact mParticipant; private String mState; private boolean mIsOpen; - private List mMessages; + private final List mMessages; + + private static final int HISTORY_MAX_SIZE = 50; /** * Constructor. @@ -115,7 +117,7 @@ * @param msg the message to add */ void addMessage(Message msg) { - if (mMessages.size() == 50) + if (mMessages.size() == HISTORY_MAX_SIZE) mMessages.remove(0); mMessages.add(msg); } diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/Contact.java --- a/src/com/beem/project/beem/service/Contact.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/Contact.java Thu Oct 08 15:26:22 2009 +0200 @@ -52,8 +52,7 @@ /** * Construct a contact from a parcel. - * @param in - * parcel to use for construction + * @param in parcel to use for construction */ private Contact(final Parcel in) { mID = in.readInt(); @@ -69,8 +68,7 @@ /** * Constructor. - * @param jid - * JID of the contact + * @param jid JID of the contact */ public Contact(final String jid) { mJID = StringUtils.parseBareAddress(jid); @@ -85,10 +83,8 @@ /** * Create a contact from a Uri. - * @param uri - * an uri for the contact - * @throws IllegalArgumentException - * if it is not a xmpp uri + * @param uri an uri for the contact + * @throws IllegalArgumentException if it is not a xmpp uri */ public Contact(final Uri uri) { if (!"xmpp".equals(uri.getScheme())) @@ -104,8 +100,7 @@ /** * Add a group for the contact. - * @param group - * the group + * @param group the group */ public void addGroup(String group) { if (!mGroups.contains(group)) @@ -122,8 +117,7 @@ /** * Add a resource for this contact. - * @param res - * the resource to add + * @param res the resource to add */ public void addRes(String res) { if (!mRes.contains(res)) @@ -132,8 +126,7 @@ /** * Delete a resource for this contact. - * @param res - * the resource de delete + * @param res the resource de delete */ public void delRes(String res) { mRes.remove(res); @@ -206,8 +199,7 @@ /** * Set the groups the contact is in. - * @param groups - * list of groups + * @param groups list of groups */ public void setGroups(Collection groups) { this.mGroups.clear(); @@ -218,8 +210,7 @@ /** * Set the groups the contact is in. - * @param groups - * the mGroups to set + * @param groups the mGroups to set */ public void setGroups(List groups) { this.mGroups = groups; @@ -227,8 +218,7 @@ /** * set the id of te contact on the phone contact list. - * @param mid - * the mID to set + * @param mid the mID to set */ public void setID(int mid) { mID = mid; @@ -236,8 +226,7 @@ /** * Set the Jabber ID of the contact. - * @param jid - * the jabber ID to set + * @param jid the jabber ID to set */ public void setJID(String jid) { mJID = jid; @@ -245,8 +234,7 @@ /** * Set a list of resource for the contact. - * @param mRes - * the mRes to set + * @param mRes the mRes to set */ public void setMRes(List mRes) { this.mRes = mRes; @@ -254,8 +242,7 @@ /** * Set the message status of the contact. - * @param msgState - * the message status of the contact to set + * @param msgState the message status of the contact to set */ public void setMsgState(String msgState) { mMsgState = msgState; @@ -263,8 +250,7 @@ /** * Set the name of the contact. - * @param name - * the mName to set + * @param name the mName to set */ public void setName(String name) { if (name != null) @@ -273,8 +259,7 @@ /** * Set the status of the contact. - * @param status - * the mStatus to set + * @param status the mStatus to set */ public void setStatus(int status) { mStatus = status; @@ -282,8 +267,7 @@ /** * Set the status of the contact using a presence packet. - * @param presence - * the presence containing status + * @param presence the presence containing status */ public void setStatus(Presence presence) { mStatus = Status.getStatusFromPresence(presence); @@ -292,8 +276,7 @@ /** * Set status for the contact. - * @param presence - * The presence packet which contains the status + * @param presence The presence packet which contains the status */ public void setStatus(PresenceAdapter presence) { mStatus = presence.getStatus(); diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/Message.java --- a/src/com/beem/project/beem/service/Message.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/Message.java Thu Oct 08 15:26:22 2009 +0200 @@ -53,9 +53,9 @@ private String mTo; private String mFrom; private String mThread; + // TODO ajouter l'erreur - /** * Constructor. * @param to the destinataire of the message @@ -95,7 +95,8 @@ mType = MSG_TYPE_NORMAL; break; // TODO gerer les message de type error - // this a little work around waiting for a better handling of error messages + // this a little work around waiting for a better handling of error + // messages case error: mType = MSG_TYPE_ERROR; break; diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/PresenceAdapter.java --- a/src/com/beem/project/beem/service/PresenceAdapter.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/PresenceAdapter.java Thu Oct 08 15:26:22 2009 +0200 @@ -20,8 +20,7 @@ public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override - public PresenceAdapter createFromParcel( - Parcel source) { + public PresenceAdapter createFromParcel(Parcel source) { return new PresenceAdapter(source); } @@ -31,12 +30,11 @@ } }; - private int mType; - private int mStatus; - private String mTo; - private String mFrom; - private String mStatusText; - + private int mType; + private int mStatus; + private String mTo; + private String mFrom; + private String mStatusText; /** * constructor from Parcel. diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Thu Oct 08 15:26:22 2009 +0200 @@ -162,7 +162,7 @@ public PresenceAdapter getPresence(String jid) throws RemoteException { return new PresenceAdapter(mAdaptee.getPresence(jid)); } - + @Override public void addContactToGroup(String groupName, String jid) throws RemoteException { createGroup(groupName); @@ -171,9 +171,9 @@ group.addEntry(mAdaptee.getEntry(jid)); } catch (XMPPException e) { e.printStackTrace(); - } + } } - + @Override public void removeContactFromGroup(String groupName, String jid) throws RemoteException { RosterGroup group = mAdaptee.getGroup(groupName); @@ -196,7 +196,7 @@ c.setGroups(entry.getGroups()); c.setName(entry.getName()); return c; - } + } /** * Listener for the roster events. It will call the remote listeners registered. @@ -235,7 +235,8 @@ */ @Override public void entriesAdded(Collection addresses) { - // Log.i(TAG, "Ajout de l'entry " + addresses.size() + " " + addresses.toArray()[0]); + // Log.i(TAG, "Ajout de l'entry " + addresses.size() + " " + + // addresses.toArray()[0]); final int n = mRemoteRosListeners.beginBroadcast(); List tab = new ArrayList(); @@ -277,7 +278,8 @@ */ @Override public void entriesUpdated(Collection addresses) { - // Log.i(TAG, "Update de l'entry " + addresses.size() + " " + addresses.toArray()[0]); + // Log.i(TAG, "Update de l'entry " + addresses.size() + " " + + // addresses.toArray()[0]); final int n = mRemoteRosListeners.beginBroadcast(); List tab = new ArrayList(); @@ -314,5 +316,5 @@ } mRemoteRosListeners.finishBroadcast(); } - } + } } diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Oct 08 15:26:22 2009 +0200 @@ -41,17 +41,18 @@ */ private static final String TAG = "XMPPConnectionAdapter"; - private XMPPConnection mAdaptee; + private static final int PRESENCE_PRIORITY = 128; + + private final XMPPConnection mAdaptee; private IChatManager mChatManager; - private String mLogin; - private String mPassword; + private final String mLogin; + private final String mPassword; private RosterAdapter mRoster; private PrivacyListManagerAdapter mPrivacyList; - private BeemService mService; - private RemoteCallbackList mRemoteConnListeners = - new RemoteCallbackList(); + private final BeemService mService; + private final RemoteCallbackList mRemoteConnListeners = new RemoteCallbackList(); - private ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter(); + private final ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter(); /** * Constructor. @@ -134,13 +135,14 @@ mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService); mPrivacyList = new PrivacyListManagerAdapter(mAdaptee); - this.initFeatures(); // pour declarer les features xmpp qu'on supporte + this.initFeatures(); // pour declarer les features xmpp qu'on + // supporte ChatStateManager.getInstance(mAdaptee); triggerAsynchronousConnectEvent(); - //Priority between -128 and 128 - Presence p = new Presence(Presence.Type.available, "Beem : http://www.beem-project.com", - 128, Presence.Mode.available); + // Priority between -128 and 128 + Presence p = new Presence(Presence.Type.available, "Beem : http://www.beem-project.com", PRESENCE_PRIORITY, + Presence.Mode.available); mAdaptee.sendPacket(p); return true; } catch (XMPPException e) { @@ -338,14 +340,14 @@ @Override public void processPacket(Packet packet) { String from = packet.getFrom(); - Notification notif = new Notification(com.beem.project.beem.R.drawable.signal, - mService.getString(R.string.AcceptContactRequest), System.currentTimeMillis()); + Notification notif = new Notification(com.beem.project.beem.R.drawable.signal, mService + .getString(R.string.AcceptContactRequest), System.currentTimeMillis()); notif.defaults = Notification.DEFAULT_ALL; notif.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); intent.putExtra("from", from); - notif.setLatestEventInfo(mService, from, mService.getString(R.string.AcceptContactRequestFrom) + from, - PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); + notif.setLatestEventInfo(mService, from, mService.getString(R.string.AcceptContactRequestFrom) + + from, PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); int id = packet.hashCode(); mService.sendNotification(id, notif); } @@ -438,21 +440,19 @@ @Override public void processPacket(Packet packet) { String from = packet.getFrom(); - Notification notif = new Notification(com.beem.project.beem.R.drawable.signal, - mService.getString(R.string.AcceptContactRequest), System.currentTimeMillis()); + Notification notif = new Notification(com.beem.project.beem.R.drawable.signal, mService + .getString(R.string.AcceptContactRequest), System.currentTimeMillis()); notif.defaults = Notification.DEFAULT_ALL; notif.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); intent.putExtra("from", from); - notif.setLatestEventInfo(mService, from, - mService.getString(R.string.AcceptContactRequestFrom) + from, - PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); + notif.setLatestEventInfo(mService, from, mService.getString(R.string.AcceptContactRequestFrom) + + from, PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); int id = packet.hashCode(); mService.sendNotification(id, notif); } }, filter); - final int n = mRemoteConnListeners.beginBroadcast(); for (int i = 0; i < n; i++) { diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/XmppFacade.java --- a/src/com/beem/project/beem/service/XmppFacade.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/XmppFacade.java Thu Oct 08 15:26:22 2009 +0200 @@ -25,9 +25,9 @@ */ public class XmppFacade extends IXmppFacade.Stub { - private XmppConnectionAdapter mConnexion; - private BeemService mBeemService; - private JingleService mJingle; + private XmppConnectionAdapter mConnexion; + private BeemService mBeemService; + private JingleService mJingle; /** * Constructor for XMPPFacade. @@ -138,7 +138,7 @@ VCard vcard = new VCard(); try { - vcard.load(mConnexion.getAdaptee(),jid); + vcard.load(mConnexion.getAdaptee(), jid); return vcard.getAvatar(); } catch (XMPPException e) { e.printStackTrace(); diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/service/package-info.java --- a/src/com/beem/project/beem/service/package-info.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/service/package-info.java Thu Oct 08 15:26:22 2009 +0200 @@ -1,5 +1,5 @@ /** - * This package contains the class used by the Beem service - * process. + * This package contains the class used by the Beem service process. */ package com.beem.project.beem.service; + diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/AddContact.java --- a/src/com/beem/project/beem/ui/AddContact.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/AddContact.java Thu Oct 08 15:26:22 2009 +0200 @@ -115,7 +115,6 @@ private final OnClickListener mOkListener = new OnClickListener() { - @Override public void onClick(View v) { String login; login = getWidgetText(R.id.addc_login); diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/ContactDialog.java --- a/src/com/beem/project/beem/ui/ContactDialog.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactDialog.java Thu Oct 08 15:26:22 2009 +0200 @@ -74,7 +74,8 @@ @Override public void onClick(View v) { try { - //TODO permettre a l'user de choisir a quel ressource il veut faire le call. + // TODO permettre a l'user de choisir a quel ressource il veut + // faire le call. mXmppFacade.call(mContact.getJID() + "/BEEM"); } catch (RemoteException e) { e.printStackTrace(); diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Thu Oct 08 15:26:22 2009 +0200 @@ -58,8 +58,8 @@ private BeemBanner mAdapterBanner; private IRoster mRoster; private List mListContact = new ArrayList(); - private List mListGroup = new ArrayList(); - private Map> mContactOnGroup = new HashMap>(); + private final List mListGroup = new ArrayList(); + private final Map> mContactOnGroup = new HashMap>(); private String mCurGroup; private Handler mHandler; private IXmppFacade mXmppFacade; @@ -144,7 +144,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE) { - if (resultCode == 69) { + if (resultCode == RESULT_OK) { stopService(SERVICE_INTENT); finish(); startActivity(new Intent(this, Login.class)); @@ -444,11 +444,11 @@ } curContact.setStatus(mRoster.getPresence(StringUtils.parseBareAddress(presence.getFrom()))); int status = presence.getStatus(); - if (!resfound - && (status != Status.CONTACT_STATUS_DISCONNECT && status != Status.CONTACT_STATUS_UNAVAILABLE)) + if (!resfound && status != Status.CONTACT_STATUS_DISCONNECT + && status != Status.CONTACT_STATUS_UNAVAILABLE) curContact.addRes(pres); - else if (resfound - && (status == Status.CONTACT_STATUS_DISCONNECT && status == Status.CONTACT_STATUS_UNAVAILABLE)) + else if (resfound && status == Status.CONTACT_STATUS_DISCONNECT + && status == Status.CONTACT_STATUS_UNAVAILABLE) curContact.delRes(pres); mHandler.post(new RunnableChange()); return; @@ -461,7 +461,7 @@ * Adapter contact list. */ private class BeemContactList extends BaseAdapter { - private LayoutInflater mInflater; + private final LayoutInflater mInflater; /** * Constructor. @@ -595,7 +595,7 @@ * Adapter banner list. */ public class BeemBanner extends BaseAdapter { - private Context mContext; + private final Context mContext; /** * Constructor. @@ -645,7 +645,7 @@ * The service connection used to connect to the Beem service. */ private class BeemServiceConnection implements ServiceConnection { - private BeemRosterListener mBeemRosterListener = new BeemRosterListener(); + private final BeemRosterListener mBeemRosterListener = new BeemRosterListener(); /** * Constructor. diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/CreateAccount.java --- a/src/com/beem/project/beem/ui/CreateAccount.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/CreateAccount.java Thu Oct 08 15:26:22 2009 +0200 @@ -32,6 +32,7 @@ private static final boolean DEFAULT_BOOLEAN_VALUE = false; private static final String DEFAULT_STRING_VALUE = ""; private static final int DEFAULT_INT_VALUE = 0; + private static final int DEFAULT_XMPP_PORT = 5222; private static final int NOTIFICATION_DURATION = Toast.LENGTH_SHORT; @@ -41,7 +42,8 @@ /** * Constructor. */ - public CreateAccount() { } + public CreateAccount() { + } /** * {@inheritDoc} @@ -65,9 +67,10 @@ ConnectionConfiguration connectionConfiguration = null; if (getRegisteredProxy() != null) { - connectionConfiguration = new ConnectionConfiguration(getXMPPServer(), 5222, getRegisteredProxy()); + connectionConfiguration = new ConnectionConfiguration(getXMPPServer(), DEFAULT_XMPP_PORT, + getRegisteredProxy()); } else { - connectionConfiguration = new ConnectionConfiguration(getXMPPServer(), 5222); + connectionConfiguration = new ConnectionConfiguration(getXMPPServer(), DEFAULT_XMPP_PORT); } if (getRegisteredXMPPTLSUse()) connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required); diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/GroupList.java --- a/src/com/beem/project/beem/ui/GroupList.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/GroupList.java Thu Oct 08 15:26:22 2009 +0200 @@ -10,7 +10,6 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; -import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnKeyListener; @@ -44,7 +43,7 @@ private ArrayAdapter mGroups; private Contact mContact; private TextView mText; - private ArrayList mStrings = new ArrayList(); + private final ArrayList mStrings = new ArrayList(); static { SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); @@ -96,18 +95,7 @@ } /** - * On group click listener. - * @param l The ListView where the click happened - * @param v The view that was clicked within the ListView - * @param position The position of the view in the list - * @param id The row id of the item that was clicked - */ - protected void onListItemClick(ListView l, View v, int position, long id) { - - } - - /** - * init activity lsit adapter. + * init activity list adapter. */ private void setAdapter() { try { diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/Login.java Thu Oct 08 15:26:22 2009 +0200 @@ -111,7 +111,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE) { - if (resultCode == 69) { + if (resultCode == RESULT_OK) { stopService(SERVICE_INTENT); } } diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/SendIM.java --- a/src/com/beem/project/beem/ui/SendIM.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/SendIM.java Thu Oct 08 15:26:22 2009 +0200 @@ -50,6 +50,7 @@ public class SendIM extends Activity implements OnClickListener, OnKeyListener { + private static final int STATUS_TXT_SIZE = 12; private static final String TAG = "SEND_IM"; private static final Intent SERVICE_INTENT = new Intent(); static { @@ -78,7 +79,6 @@ private TextView mStatusText; private BeemBroadcastReceiver mReceiver; - /** * Constructor. */ @@ -100,7 +100,7 @@ @Override protected void onCreate(Bundle saveBundle) { super.onCreate(saveBundle); - //setTheme(R.style.OldTheme); + // setTheme(R.style.OldTheme); setContentView(R.layout.sendim); mHandler = new Handler(); mChatManagerListener = new OnChatListener(); @@ -134,7 +134,7 @@ Drawable avatar = getResources().getDrawable(R.drawable.avatar); ImageView imgV = (ImageView) findViewById(R.id.sendimavatar); imgV.setImageDrawable(avatar); - mStatusText.setTextSize(12); + mStatusText.setTextSize(STATUS_TXT_SIZE); mContactName = mContact.getName(); if (mContactName == null || "".equals(mContactName)) { mContactName = mContact.getJID(); @@ -282,12 +282,13 @@ * The service connection used to connect with the BeemService. */ private final class BeemServiceConnection implements ServiceConnection { - private BeemRosterListener mBeemRosterListener = new BeemRosterListener(); + private final BeemRosterListener mBeemRosterListener = new BeemRosterListener(); /** * Constructor. */ - public BeemServiceConnection() { } + public BeemServiceConnection() { + } @Override public void onServiceConnected(ComponentName name, IBinder service) { @@ -399,7 +400,8 @@ /** * Constructor. */ - public OnChatListener() { } + public OnChatListener() { + } /** * {@inheritDoc} @@ -419,7 +421,8 @@ /** * Constructor. */ - public BeemRosterListener() { } + public BeemRosterListener() { + } @Override public void onEntriesAdded(List addresses) throws RemoteException { @@ -461,7 +464,8 @@ /** * Constructor. */ - public RunnableChange() { } + public RunnableChange() { + } @Override public void run() { @@ -470,8 +474,6 @@ } } - - } /** @@ -483,7 +485,8 @@ /** * Constructor. */ - public OnMessageListener() { } + public OnMessageListener() { + } /** * {@inheritDoc} diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/SendIMDialogSmiley.java --- a/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Thu Oct 08 15:26:22 2009 +0200 @@ -11,7 +11,7 @@ public class SendIMDialogSmiley extends Dialog { @SuppressWarnings("unused") - private SendIM mSendIM; + private SendIM mSendIM; @SuppressWarnings("unused") private SharedPreferences mSet; diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/Settings.java --- a/src/com/beem/project/beem/ui/Settings.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/Settings.java Thu Oct 08 15:26:22 2009 +0200 @@ -66,9 +66,10 @@ public void onStop() { super.onStop(); SharedPreferences settings = getPreferenceManager().getSharedPreferences(); - settings.edit().putBoolean("PreferenceIsConfigured", + settings.edit().putBoolean( + "PreferenceIsConfigured", !"".equals(settings.getString("settings_key_account_username", "")) - || !"".equals(settings.getString("settings_key_account_password", ""))).commit(); + || !"".equals(settings.getString("settings_key_account_password", ""))).commit(); } /** @@ -81,8 +82,6 @@ return true; } - - /** * {@inheritDoc} */ @@ -95,11 +94,12 @@ startActivity(i); return true; case R.id.settings_menu_login: - setResult(69); + setResult(RESULT_OK); SharedPreferences settings = getPreferenceManager().getSharedPreferences(); - settings.edit().putBoolean("PreferenceIsConfigured", + settings.edit().putBoolean( + "PreferenceIsConfigured", !"".equals(settings.getString("settings_key_account_username", "")) - || !"".equals(settings.getString("settings_key_account_password", ""))).commit(); + || !"".equals(settings.getString("settings_key_account_password", ""))).commit(); this.stopService(SERVICE_INTENT); finish(); return true; @@ -120,7 +120,7 @@ @Override public void onReceive(Context context, Intent intent) { - Settings.this.setResult(69); + Settings.this.setResult(RESULT_CANCELED); } } } diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/Subscription.java --- a/src/com/beem/project/beem/ui/Subscription.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/Subscription.java Thu Oct 08 15:26:22 2009 +0200 @@ -94,23 +94,21 @@ PresenceAdapter preAdapt = new PresenceAdapter(presence); try { mService.sendPresencePacket(preAdapt); - Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), - Toast.LENGTH_SHORT).show(); + Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), Toast.LENGTH_SHORT) + .show(); finish(); } catch (RemoteException e) { - Toast.makeText(Subscription.this, getString(R.string.SubscriptError), - Toast.LENGTH_SHORT).show(); + Toast.makeText(Subscription.this, getString(R.string.SubscriptError), Toast.LENGTH_SHORT) + .show(); e.printStackTrace(); } break; case R.id.SubscriptionRefuse: - Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused), - Toast.LENGTH_SHORT).show(); + Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused), Toast.LENGTH_SHORT).show(); break; default: - Toast.makeText(Subscription.this, getString(R.string.SubscriptError), - Toast.LENGTH_SHORT).show(); + Toast.makeText(Subscription.this, getString(R.string.SubscriptError), Toast.LENGTH_SHORT).show(); } } }; diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/UserInfo.java diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/ui/package-info.java --- a/src/com/beem/project/beem/ui/package-info.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/ui/package-info.java Thu Oct 08 15:26:22 2009 +0200 @@ -1,5 +1,5 @@ /** - * This package contains the class concerning the user interface - * (activities) of Beem. + * This package contains the class concerning the user interface (activities) of Beem. */ package com.beem.project.beem.ui; + diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/utils/FreePort.java --- a/src/com/beem/project/beem/utils/FreePort.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/utils/FreePort.java Thu Oct 08 15:26:22 2009 +0200 @@ -9,6 +9,9 @@ */ public final class FreePort { + private static final int MAGIC_10 = 10; + private static final int MAGIC_10000 = 10000; + /** * Private default constructor. */ @@ -23,8 +26,8 @@ ServerSocket ss; int freePort = 0; - for (int i = 0; i < 10; i++) { - freePort = (int) (10000 + Math.round(Math.random() * 10000)); + for (int i = 0; i < MAGIC_10; i++) { + freePort = (int) (MAGIC_10000 + Math.round(Math.random() * MAGIC_10000)); try { ss = new ServerSocket(freePort); freePort = ss.getLocalPort(); diff -r aa654c8efd1b -r eb1ce472a1a5 src/com/beem/project/beem/utils/package-info.java --- a/src/com/beem/project/beem/utils/package-info.java Thu Oct 08 15:00:12 2009 +0200 +++ b/src/com/beem/project/beem/utils/package-info.java Thu Oct 08 15:26:22 2009 +0200 @@ -2,3 +2,4 @@ * This package contains utility class used by the Beem project. */ package com.beem.project.beem.utils; +