Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
authorJean-Manuel Da Silva <dasilvj@gmail.com>
Sat, 14 Nov 2009 23:53:18 +0100
changeset 514 c5d0b38dd35f
parent 513 1bd07ab7a1ad
child 515 5e4b8b7908f6
Mise a jour de la JavaDoc et corrections des erreurs de CheckStyle.
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/service/BeemChatManager.java
src/com/beem/project/beem/service/PrivacyListManagerAdapter.java
src/com/beem/project/beem/service/RosterAdapter.java
src/com/beem/project/beem/ui/Chat.java
src/com/beem/project/beem/ui/CreateAccount.java
src/com/beem/project/beem/ui/Login.java
--- a/src/com/beem/project/beem/BeemService.java	Sat Nov 14 00:45:45 2009 +0100
+++ b/src/com/beem/project/beem/BeemService.java	Sat Nov 14 23:53:18 2009 +0100
@@ -36,6 +36,8 @@
      * The id to use for status notification.
      */
     public static final int NOTIFICATION_STATUS_ID = 100;
+
+    private static final String TAG = "BeemService";
     private static final int DEFAULT_XMPP_PORT = 5222;
 
     private NotificationManager mNotificationManager;
@@ -95,7 +97,7 @@
      */
     @Override
     public IBinder onBind(Intent intent) {
-	Log.d("BEEMSERVICE", "ONBIND()");
+	Log.d(TAG, "ONBIND()");
 	return mBind;
     }
 
@@ -140,7 +142,7 @@
 	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
 	mJingle = new JingleService(mConnection.getAdaptee());
 	mBind = new XmppFacade(mConnection, this, mJingle);
-	Log.d("BEEEMSERVICE", "ONCREATE");
+	Log.d(TAG, "ONCREATE");
     }
 
     /**
@@ -152,7 +154,7 @@
 	mNotificationManager.cancel(NOTIFICATION_STATUS_ID);
 	if (mConnection.isAuthentificated())
 	    mConnection.disconnect();
-	Log.d("BEEEMSERVICE", "ONDESTROY");
+	Log.d(TAG, "ONDESTROY");
     }
 
     /**
@@ -161,7 +163,7 @@
     @Override
     public void onStart(Intent intent, int startId) {
 	super.onStart(intent, startId);
-	Log.d("BEEMSERVICE", "onStart");
+	Log.d(TAG, "onStart");
 	try {
 	    mConnection.connectAsync();
 	} catch (RemoteException e) {
@@ -196,13 +198,17 @@
     }
 
     /**
-     * init jingle from XmppConnectionAdapter.
-     * @param adaptee XmppConntection used for jingle.
+     * Initialize Jingle from an XmppConnectionAdapter.
+     * @param adaptee XmppConnection used for jingle.
      */
     public void initJingle(XMPPConnection adaptee) {
 	mJingle.initWhenConntected(adaptee);
     }
-    
+
+    /**
+     * Return a bind to an XmppFacade instance.
+     * @return IXmppFacade a bind to an XmppFacade instance
+     */
     public IXmppFacade getBind() {
 	return mBind;
     }
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Sat Nov 14 00:45:45 2009 +0100
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Sat Nov 14 23:53:18 2009 +0100
@@ -71,8 +71,8 @@
 
 	/**
 	 * Create the PendingIntent to launch our activity if the user select this chat notification.
-	 * @param chat
-	 * @return
+	 * @param chat A ChatAdapter instance
+	 * @return A Chat activity PendingIntent
 	 */
 	private PendingIntent makeChatIntent(IChat chat) {
 	    Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class);
@@ -84,7 +84,7 @@
 	    }
 	    PendingIntent contentIntent = PendingIntent.getActivity(mService, 0, chatIntent,
 		PendingIntent.FLAG_UPDATE_CURRENT);
-	    return (contentIntent);
+	    return contentIntent;
 	}
 
 	/**
@@ -93,7 +93,8 @@
 	 */
 	private void notifyNewChat(IChat chat) {
 	    try {
-		CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID()).getName();
+		CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID())
+		    .getName();
 		Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System
 		    .currentTimeMillis());
 		notification.defaults = Notification.DEFAULT_ALL;
@@ -243,15 +244,20 @@
 	return res;
     }
 
+    /**
+     * This methods permits to retrieve the list of contacts who have an opened chat session with us.
+     * @return An List containing Contact instances.
+     * @throws RemoteException If a Binder remote-invocation error occurred.
+     */
     public List<Contact> getOpenedChatList() throws RemoteException {
 	List<Contact> openedChats = new ArrayList<Contact>();
 	IRoster mRoster = mService.getBind().getRoster();
-	
+
 	for (ChatAdapter chat : mChats.values()) {
 	    if (!chat.isOpen())
 		openedChats.add(mRoster.getContact(chat.getParticipant().getJID()));
 	}
-	return (openedChats);
+	return openedChats;
     }
 
     /**
--- a/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java	Sat Nov 14 00:45:45 2009 +0100
+++ b/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java	Sat Nov 14 23:53:18 2009 +0100
@@ -33,8 +33,8 @@
 
     private PrivacyListManager mAdaptee;
     private List<String> mBlockedUsers = new ArrayList<String>();
-    private XMPPConnection mConnection;
-    private MyPrivacyListListener mPrivacyPacketListener = new MyPrivacyListListener();
+    private final XMPPConnection mConnection;
+    private final MyPrivacyListListener mPrivacyPacketListener = new MyPrivacyListListener();
 
     /**
      * Privacy list constructor.
@@ -57,7 +57,7 @@
 
     /**
      * Add a user to the blocked user list.
-     * @param jid blocked user jid TODO: Ne bloque pas uniquement un utilisateur, fonction a découper/revoir
+     * @param jid blocked user jid TODO: Ne bloque pas uniquement un utilisateur, fonction a d�couper/revoir
      */
     public synchronized void addBlockedUser(final String jid) {
 	Log.d(TAG, "BEGIN addBlockedUser.");
@@ -100,6 +100,9 @@
 
     /**
      * Return a list of users blocked for a specified list.
+     * @param listName The list name that will be checked for blocked users.
+     * @return A list of String which contains a user JID who is blocked by the user.
+     * @throws RemoteException If a Binder remote-invocation error occurred.
      */
     @Override
     public List<String> getBlockedUsersByList(String listName) throws RemoteException {
@@ -126,9 +129,8 @@
     }
 
     /**
-     * A class which allows listening on a PrivacyList
-     * 
-     * TODO: Besoin d'en discuter. Va t-on gérer plusieurs listes ? Une seule ?
+     * A class which allows listening on a PrivacyList TODO: Besoin d'en discuter. Va t-on g�rer plusieurs listes ? Une
+     * seule ?
      */
     class MyPrivacyListListener implements PrivacyListListener {
 	/**
--- a/src/com/beem/project/beem/service/RosterAdapter.java	Sat Nov 14 00:45:45 2009 +0100
+++ b/src/com/beem/project/beem/service/RosterAdapter.java	Sat Nov 14 23:53:18 2009 +0100
@@ -24,19 +24,19 @@
 
 /**
  * This class implement a Roster adapter for BEEM.
- * @author darisk
  */
 public class RosterAdapter extends com.beem.project.beem.service.aidl.IRoster.Stub {
 
     private static final String TAG = "RosterAdapter";
-    private Roster mAdaptee;
-    private RemoteCallbackList<IBeemRosterListener> mRemoteRosListeners = new RemoteCallbackList<IBeemRosterListener>();
-    private Map<Integer, String> mDefaultStatusMessages;
-    private RosterListenerAdapter mRosterListener = new RosterListenerAdapter();
+    private final Roster mAdaptee;
+    private final RemoteCallbackList<IBeemRosterListener> mRemoteRosListeners = new RemoteCallbackList<IBeemRosterListener>();
+    private final Map<Integer, String> mDefaultStatusMessages;
+    private final RosterListenerAdapter mRosterListener = new RosterListenerAdapter();
 
     /**
      * Constructor.
-     * @param roster the roster to adapt
+     * @param roster The roster to adapt.
+     * @param context The context of the RosterAdapter.
      */
     public RosterAdapter(final Roster roster, Context context) {
 	mAdaptee = roster;
@@ -196,7 +196,7 @@
 	Contact c = new Contact(user);
 	Presence p = mAdaptee.getPresence(user);
 
-	if (p.getStatus() == null || p.getStatus().equals(""))
+	if (p.getStatus() == null || "".equals(p.getStatus()))
 	    p.setStatus(mDefaultStatusMessages.get(Status.getStatusFromPresence(p)));
 	c.setStatus(p);
 	try {
@@ -210,7 +210,8 @@
 
     /**
      * Create a map which contains default status messages.
-     * @return
+     * @param context The context of the roster adapter.
+     * @return A Map<Integer, String> which assigns a status to a message.
      */
     private Map<Integer, String> createDefaultStatusMessagesMap(Context context) {
 	Map<Integer, String> defaultStatusMessages = new HashMap<Integer, String>();
@@ -222,7 +223,8 @@
 	defaultStatusMessages.put(Status.CONTACT_STATUS_BUSY, context.getString(R.string.contact_status_msg_dnd));
 	defaultStatusMessages.put(Status.CONTACT_STATUS_DISCONNECT, context
 	    .getString(R.string.contact_status_msg_offline));
-	defaultStatusMessages.put(Status.CONTACT_STATUS_UNAVAILABLE, context.getString(R.string.contact_status_msg_xa));
+	defaultStatusMessages
+	    .put(Status.CONTACT_STATUS_UNAVAILABLE, context.getString(R.string.contact_status_msg_xa));
 
 	return (defaultStatusMessages);
     }
@@ -338,7 +340,7 @@
 		IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
 		try {
 		    Log.d(TAG, ">>> Presence changed.");
-		    if (presence.getStatus() == null || presence.getStatus().equals("")) {
+		    if (presence.getStatus() == null || "".equals(presence.getStatus())) {
 			presence.setStatus(mDefaultStatusMessages.get(Status.getStatusFromPresence(presence)));
 			Log.d(TAG, ">>> Default status added.");
 		    }
--- a/src/com/beem/project/beem/ui/Chat.java	Sat Nov 14 00:45:45 2009 +0100
+++ b/src/com/beem/project/beem/ui/Chat.java	Sat Nov 14 23:53:18 2009 +0100
@@ -54,6 +54,10 @@
 import com.beem.project.beem.utils.BeemBroadcastReceiver;
 import com.beem.project.beem.utils.Status;
 
+/**
+ * This class represents an activity which allows the user to chat with his/her contacts.
+ * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
+ */
 public class Chat extends Activity implements OnKeyListener {
 
     private static final String TAG = "Chat";
@@ -71,9 +75,9 @@
     private ImageView mContactStatusIcon;
     private ListView mMessagesListView;
     private EditText mInputField;
-    private Map<Integer, Bitmap> mStatusIconsMap = new HashMap<Integer, Bitmap>();
+    private final Map<Integer, Bitmap> mStatusIconsMap = new HashMap<Integer, Bitmap>();
 
-    private List<MessageText> mListMessages = new ArrayList<MessageText>();
+    private final List<MessageText> mListMessages = new ArrayList<MessageText>();
 
     private IChat mChat;
     private IChatManager mChatManager;
@@ -94,6 +98,7 @@
     /**
      * {@inheritDoc}.
      */
+    @Override
     protected void onCreate(Bundle savedBundle) {
 	super.onCreate(savedBundle);
 
@@ -127,6 +132,7 @@
     /**
      * {@inheritDoc}.
      */
+    @Override
     protected void onDestroy() {
 	super.onDestroy();
 
@@ -145,6 +151,7 @@
     /**
      * {@inheritDoc}.
      */
+    @Override
     protected void onStart() {
 	super.onStart();
 
@@ -156,6 +163,7 @@
     /**
      * {@inheritDoc}.
      */
+    @Override
     protected void onStop() {
 	super.onStop();
 
@@ -176,6 +184,7 @@
     /**
      * {@inheritDoc}.
      */
+    @Override
     protected void onResume() {
 	super.onResume();
     }
@@ -183,6 +192,7 @@
     /**
      * {@inheritDoc}.
      */
+    @Override
     protected void onPause() {
 	super.onPause();
     }
@@ -190,12 +200,14 @@
     /**
      * {@inheritDoc}.
      */
+    @Override
     protected void onNewIntent(Intent intent) {
 	super.onNewIntent(intent);
 
 	Log.v(TAG, "BEGIN onNewIntent.");
 	try {
-	    changeCurrentChat((mContact = new Contact(intent.getData())));
+	    mContact = new Contact(intent.getData());
+	    changeCurrentChat(mContact);
 	} catch (RemoteException e) {
 	    Log.e(TAG, e.getMessage());
 	}
@@ -246,7 +258,7 @@
 	    case R.id.chat_menu_change_chat:
 		try {
 		    final List<Contact> openedChats = mChatManager.getOpenedChatList();
-		    
+
 		    if (openedChats.size() > 0)
 			createChatSwitcherDialog(openedChats);
 		    else
@@ -296,7 +308,10 @@
 	AlertDialog chatSwitcherDialog = builder.create();
 	chatSwitcherDialog.show();
     }
-    
+
+    /**
+     * Create a dialog which notify the user that there're not another one active chat.
+     */
     private void createNoActiveChatsDialog() {
 	AlertDialog.Builder builder = new AlertDialog.Builder(this);
 	builder.setMessage(getString(R.string.chat_no_more_chats));
@@ -306,8 +321,8 @@
 
     /**
      * Change the displayed chat.
-     * @param contact
-     * @throws RemoteException
+     * @param contact the targeted contact of the new chat
+     * @throws RemoteException If a Binder remote-invocation error occurred.
      */
     private void changeCurrentChat(Contact contact) throws RemoteException {
 	Log.v(TAG, "BEGIN changeCurrentChat.");
@@ -328,7 +343,7 @@
 
     /**
      * Get all messages from the current chat and refresh the activity with them.
-     * @throws RemoteException
+     * @throws RemoteException If a Binder remote-invocation error occurred.
      */
     private void playRegisteredTranscript() throws RemoteException {
 	String fromBareJid = null;
@@ -366,7 +381,7 @@
     }
 
     /**
-     * @author Jamu
+     * {@inheritDoc}.
      */
     private final class BeemServiceConnection implements ServiceConnection {
 
@@ -385,7 +400,8 @@
 		mChatManager = mXmppFacade.getChatManager();
 		mRoster = mXmppFacade.getRoster();
 		mRoster.addRosterListener(mBeemRosterListener);
-		changeCurrentChat((mContact = new Contact(getIntent().getData())));
+		mContact = new Contact(getIntent().getData());
+		changeCurrentChat(mContact);
 	    } catch (RemoteException e) {
 		Log.e(TAG, e.getMessage());
 	    }
@@ -410,7 +426,7 @@
     }
 
     /**
-     * @author Jamu
+     * {@inheritDoc}.
      */
     private class BeemRosterListener extends IBeemRosterListener.Stub {
 
@@ -473,7 +489,7 @@
     }
 
     /**
-     * @author Jamu
+     * {@inheritDoc}.
      */
     private class OnMessageListener extends IMessageListener.Stub {
 
@@ -531,7 +547,8 @@
     }
 
     /**
-     * @author Jamu
+     * This class serve to listen on ChatManager events.
+     * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
      */
     private class OnChatManagerListener extends IChatManagerListener.Stub {
 	/**
@@ -595,26 +612,54 @@
 	    R.drawable.status_requested));
     }
 
+    /**
+     * {@inheritDoc}.
+     */
     private class MessagesListAdapter extends BaseAdapter {
 
-	private Context mContext;
+	private final Context mContext;
 
-	public MessagesListAdapter(Context context) {
+	/**
+	 * Constructor.
+	 * @param context The MessagesListAdapter context.
+	 */
+	public MessagesListAdapter(final Context context) {
 	    mContext = context;
 	}
 
+	/**
+	 * Returns the number of messages contained in the messages list.
+	 * @return The number of messages contained in the messages list.
+	 */
 	public int getCount() {
 	    return mListMessages.size();
 	}
 
+	/**
+	 * Return an item from the messages list that is positioned at the position passed by parameter.
+	 * @param position The position of the requested item.
+	 * @return The item from the messages list at the requested position.
+	 */
 	public Object getItem(int position) {
 	    return position;
 	}
 
+	/**
+	 * Return the id of an item from the messages list that is positioned at the position passed by parameter.
+	 * @param position The position of the requested item.
+	 * @return The id of an item from the messages list at the requested position.
+	 */
 	public long getItemId(int position) {
 	    return position;
 	}
 
+	/**
+	 * Return the view of an item from the messages list.
+	 * @param position The position of the requested item.
+	 * @param convertView The old view to reuse if possible.
+	 * @param parent The parent that this view will eventually be attached to.
+	 * @return A View corresponding to the data at the specified position.
+	 */
 	public View getView(int position, View convertView, ViewGroup parent) {
 	    MessageView sv;
 	    if (convertView == null) {
@@ -640,39 +685,73 @@
 	}
     }
 
+    /**
+     * Class which simplify an Xmpp text message.
+     * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
+     */
     private class MessageText {
 	private String mBareJid;
 	private String mName;
 	private String mMessage;
 
-	public MessageText(String bareJid, String name, String message) {
+	/**
+	 * Construtor.
+	 * @param bareJid A String containing the bare JID of the message's author.
+	 * @param name A String containing the name of the message's author.
+	 * @param message A String containing the message.
+	 */
+	public MessageText(final String bareJid, final String name, final String message) {
 	    mBareJid = bareJid;
 	    mName = name;
 	    mMessage = message;
 	}
 
+	/**
+	 * JID attribute accessor.
+	 * @return A String containing the bare JID of the message's author.
+	 */
 	public String getBareJid() {
 	    return mBareJid;
 	}
 
+	/**
+	 * Name attribute accessor.
+	 * @return A String containing the name of the message's author.
+	 */
 	public String getName() {
 	    return mName;
 	}
 
+	/**
+	 * Message attribute accessor.
+	 * @return A String containing the message.
+	 */
 	public String getMessage() {
 	    return mMessage;
 	}
 
+	/**
+	 * JID attribute mutator.
+	 * @param bareJid A String containing the author's bare JID of the message.
+	 */
 	@SuppressWarnings("unused")
 	public void setBareJid(String bareJid) {
 	    mBareJid = bareJid;
 	}
 
+	/**
+	 * Name attribute mutator.
+	 * @param name A String containing the author's name of the message.
+	 */
 	@SuppressWarnings("unused")
 	public void setName(String name) {
 	    mName = name;
 	}
 
+	/**
+	 * Message attribute mutator.
+	 * @param message A String containing a message.
+	 */
 	public void setMessage(String message) {
 	    mMessage = message;
 	}
@@ -682,16 +761,16 @@
      * We will use a MessageView to display each message.
      */
     private class MessageView extends LinearLayout {
-	private TextView mName;
-	private TextView mMessage;
+	private final TextView mName;
+	private final TextView mMessage;
 
 	/**
 	 * Constructor.
-	 * @param context
-	 * @param name
-	 * @param message
+	 * @param context The context of the MessageView
+	 * @param name A String containing the message's author.
+	 * @param message A String containing the message.
 	 */
-	public MessageView(Context context, String name, String message) {
+	public MessageView(final Context context, final String name, final String message) {
 	    super(context);
 
 	    this.setOrientation(VERTICAL);
@@ -706,14 +785,16 @@
 	}
 
 	/**
-	 * Convenience method to set the title of a MessageView
+	 * Convenience method to set the title of a MessageView.
+	 * @param name A String containing the message's author.
 	 */
 	public void setName(String name) {
 	    mName.setText(name);
 	}
 
 	/**
-	 * Convenience method to set the dialogue of a MessageView
+	 * Convenience method to set the dialogue of a MessageView.
+	 * @param message A String containing the message.
 	 */
 	public void setMessage(String message) {
 	    mMessage.setText(message);
@@ -739,13 +820,13 @@
     }
 
     /**
-     * Send an xmpp message.
+     * Send an XMPP message.
      */
     private void sendMessage() {
 	final String inputContent = mInputField.getText().toString();
 
 	Log.v(TAG, "BEGIN sendMessage.");
-	if (!inputContent.equals("")) {
+	if (!"".equals(inputContent)) {
 	    Message msgToSend = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT);
 	    msgToSend.setBody(inputContent);
 
--- a/src/com/beem/project/beem/ui/CreateAccount.java	Sat Nov 14 00:45:45 2009 +0100
+++ b/src/com/beem/project/beem/ui/CreateAccount.java	Sat Nov 14 23:53:18 2009 +0100
@@ -26,7 +26,7 @@
 
 /**
  * This class represents an activity which allows the user to create an account on the XMPP server saved in settings.
- * @author dasilvj
+ * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
  */
 public class CreateAccount extends Activity {
 
@@ -138,7 +138,8 @@
      * @return Registered proxy port
      */
     private int getRegisteredProxyPort() {
-	return Integer.parseInt(mSettings.getString(getString(R.string.settings_key_proxy_port), DEFAULT_STRING_VALUE));
+	return Integer
+	    .parseInt(mSettings.getString(getString(R.string.settings_key_proxy_port), DEFAULT_STRING_VALUE));
     }
 
     /**
@@ -266,8 +267,10 @@
 		else {
 		    if (createAccount(username, passwordFieldValue)) {
 			SharedPreferences.Editor settingsEditor = mSettings.edit();
-			settingsEditor.putString(getString(R.string.settings_key_account_username), usernameFieldValue);
-			settingsEditor.putString(getString(R.string.settings_key_account_password), passwordFieldValue);
+			settingsEditor
+			    .putString(getString(R.string.settings_key_account_username), usernameFieldValue);
+			settingsEditor
+			    .putString(getString(R.string.settings_key_account_password), passwordFieldValue);
 			settingsEditor.putBoolean(getString(R.string.PreferenceIsConfigured), true);
 			settingsEditor.commit();
 			finish();
--- a/src/com/beem/project/beem/ui/Login.java	Sat Nov 14 00:45:45 2009 +0100
+++ b/src/com/beem/project/beem/ui/Login.java	Sat Nov 14 23:53:18 2009 +0100
@@ -29,7 +29,7 @@
 
 /**
  * This class represents an activity which allows the user to connect to an XMPP server with his username/password.
- * @author dasilvj
+ * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
  */
 public class Login extends Activity {
 
@@ -41,7 +41,7 @@
     }
 
     private final Handler mConnectionHandler = new Handler();
-    private ConnectionRunnable mConnectionRunnable = new ConnectionRunnable();
+    private final ConnectionRunnable mConnectionRunnable = new ConnectionRunnable();
     private ProgressDialog mProgressDialog;
 
     private boolean mIsConnectedService;