# HG changeset patch # User dasilvj # Date 1255005489 -7200 # Node ID 63cffd88721d1fc5f8b3f86823cadef95a6b17e5 # Parent fe0ba62ee3ffba62ca7f65cb3bdc7254eef41055 Normalisation de certaines parties du code. Renommage de l'export de l'Eclipse formatter. Mise a jour de la version minimum du SDK dans l'AndroidManifest (provoquait un warning). Ajout du fichier d'information "package-info" pour le package com.beem.project.beem.provider. diff -r fe0ba62ee3ff -r 63cffd88721d AndroidManifest.xml --- a/AndroidManifest.xml Thu Oct 08 13:59:04 2009 +0200 +++ b/AndroidManifest.xml Thu Oct 08 14:38:09 2009 +0200 @@ -87,6 +87,6 @@ - + diff -r fe0ba62ee3ff -r 63cffd88721d Beem-ecipse-formatter.xml --- a/Beem-ecipse-formatter.xml Thu Oct 08 13:59:04 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r fe0ba62ee3ff -r 63cffd88721d eclipse_formatter.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eclipse_formatter.xml Thu Oct 08 14:38:09 2009 +0200 @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/jingle/JingleService.java --- a/src/com/beem/project/beem/jingle/JingleService.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/jingle/JingleService.java Thu Oct 08 14:38:09 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; @@ -134,6 +135,8 @@ */ private class BeemJingleCallerSessionListener implements JingleSessionListener { + private static final int SLP_DURATION = 20000; + /** * constructor. */ @@ -176,7 +179,7 @@ transm.run(); try { - Thread.sleep(20000); + Thread.sleep(SLP_DURATION); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); diff -r fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/jingle/PCMTransmitter.java --- a/src/com/beem/project/beem/jingle/PCMTransmitter.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/jingle/PCMTransmitter.java Thu Oct 08 14:38:09 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 fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/jingle/demo/JingleCallActivity.java --- a/src/com/beem/project/beem/jingle/demo/JingleCallActivity.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/jingle/demo/JingleCallActivity.java Thu Oct 08 14:38:09 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,7 +64,7 @@ String password = mEdPassword.getText().toString(); try { mConnection.connect(); - Thread.sleep(3000); + Thread.sleep(SLP_DURATION); mConnection.login(login, password); mJingle = new JingleService(mConnection); mJingle.initWhenConntected(mConnection); diff -r fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/provider/ContactProvider.java --- a/src/com/beem/project/beem/provider/ContactProvider.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/provider/ContactProvider.java Thu Oct 08 14:38:09 2009 +0200 @@ -1,6 +1,3 @@ -/** - * - */ package com.beem.project.beem.provider; import java.util.HashMap; @@ -30,11 +27,11 @@ 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); @@ -53,7 +50,7 @@ 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; @@ -74,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; @@ -89,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); } @@ -149,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); @@ -188,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 fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/provider/UserProvider.java --- a/src/com/beem/project/beem/provider/UserProvider.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/provider/UserProvider.java Thu Oct 08 14:38:09 2009 +0200 @@ -27,11 +27,11 @@ 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); @@ -47,7 +47,7 @@ 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; @@ -68,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; @@ -83,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); } @@ -130,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); @@ -169,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 fe0ba62ee3ff -r 63cffd88721d 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 14:38:09 2009 +0200 @@ -0,0 +1,5 @@ +/** + * This package contains the class concerning the providers of Beem. + */ +package com.beem.project.beem.provider; + diff -r fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/service/ChatAdapter.java --- a/src/com/beem/project/beem/service/ChatAdapter.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/service/ChatAdapter.java Thu Oct 08 14:38:09 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 fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Oct 08 14:38:09 2009 +0200 @@ -41,16 +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. @@ -139,7 +141,7 @@ triggerAsynchronousConnectEvent(); // Priority between -128 and 128 - Presence p = new Presence(Presence.Type.available, "Beem : http://www.beem-project.com", 128, + Presence p = new Presence(Presence.Type.available, "Beem : http://www.beem-project.com", PRESENCE_PRIORITY, Presence.Mode.available); mAdaptee.sendPacket(p); return true; diff -r fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Thu Oct 08 14:38:09 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 fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/ui/CreateAccount.java --- a/src/com/beem/project/beem/ui/CreateAccount.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/ui/CreateAccount.java Thu Oct 08 14:38:09 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; @@ -66,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 fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/ui/Login.java Thu Oct 08 14:38:09 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 fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/ui/SendIM.java --- a/src/com/beem/project/beem/ui/SendIM.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/ui/SendIM.java Thu Oct 08 14:38:09 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 { @@ -133,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(); @@ -281,7 +282,7 @@ * 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. diff -r fe0ba62ee3ff -r 63cffd88721d src/com/beem/project/beem/ui/Settings.java --- a/src/com/beem/project/beem/ui/Settings.java Thu Oct 08 13:59:04 2009 +0200 +++ b/src/com/beem/project/beem/ui/Settings.java Thu Oct 08 14:38:09 2009 +0200 @@ -94,7 +94,7 @@ startActivity(i); return true; case R.id.settings_menu_login: - setResult(69); + setResult(RESULT_OK); SharedPreferences settings = getPreferenceManager().getSharedPreferences(); settings.edit().putBoolean( "PreferenceIsConfigured", @@ -120,7 +120,7 @@ @Override public void onReceive(Context context, Intent intent) { - Settings.this.setResult(69); + Settings.this.setResult(RESULT_CANCELED); } } }