de la doc en plus
authorNikita Kozlov <nikita@beem-project.com>
Sun, 27 Sep 2009 20:11:47 +0200
changeset 414 79e07130a059
parent 413 a6ad4afc4fd6
child 418 8c3dd8a7064e
de la doc en plus
res/layout/contactlistcontact.xml
res/layout/edit_settings.xml
src/com/beem/project/beem/service/XmppConnectionAdapter.java
src/com/beem/project/beem/ui/Login.java
src/com/beem/project/beem/ui/SendIM.java
src/com/beem/project/beem/ui/Subscription.java
src/com/beem/project/beem/utils/BeemBroadcastReceiver.java
--- a/res/layout/contactlistcontact.xml	Sun Sep 27 19:10:23 2009 +0200
+++ b/res/layout/contactlistcontact.xml	Sun Sep 27 20:11:47 2009 +0200
@@ -19,7 +19,7 @@
 		<TextView android:id="@+id/contactlistmsgperso"
 			android:layout_width="fill_parent" android:layout_height="wrap_content"
 			android:paddingLeft="20sp" android:singleLine="true"
-			android:maxLines="1" android:autoLink="all" />
+			android:maxLines="1" android:linksClickable="false" android:autoLink="all" />
 	</LinearLayout>
 
 	<ImageView android:id="@+id/contactlistavatar"
--- a/res/layout/edit_settings.xml	Sun Sep 27 19:10:23 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<TabHost android:id="@+id/settings_tab_host" xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-	android:layout_height="fill_parent">
-	<LinearLayout 
-		android:orientation="vertical"
-    	android:layout_width="fill_parent"
-    	android:layout_height="fill_parent">
-    	<TabWidget android:id="@android:id/tabs"
-    		android:layout_width="fill_parent"
-    		android:layout_height="wrap_content" />
-    	<FrameLayout android:id="@android:id/tabcontent"
-    		android:layout_width="fill_parent"
-    		android:layout_height="fill_parent">
-    		
-    		<!--
-    			Account Tab
-    		-->
-    		<ScrollView
-    			android:orientation="vertical"
-    			android:layout_width="fill_parent"
-    			android:layout_height="fill_parent">
-    		<RelativeLayout android:id="@+id/settings_account"
-    			android:orientation="vertical"
-    			android:layout_width="fill_parent"
-    			android:layout_height="fill_parent"
-    			android:padding="10dip">
-    			<TextView android:id="@+id/settings_account_label_username"
-    				android:layout_width="fill_parent"
-    				android:layout_height="wrap_content"
-    				android:text="@string/settings_account_username"
-    				style="@style/Label" />
-				<EditText android:id="@+id/settings_account_username"
-					android:layout_width="fill_parent"
-					android:layout_height="wrap_content"
-					android:layout_below="@id/settings_account_label_username"
-					android:singleLine="true" />
-    			<TextView android:id="@+id/settings_account_label_password"
-    				android:layout_width="fill_parent"
-    				android:layout_height="wrap_content"
-					android:layout_below="@id/settings_account_username"
-    				android:text="@string/settings_account_password"
-    				style="@style/Label" />
-				<EditText android:id="@+id/settings_account_password"
-					android:layout_width="fill_parent"
-					android:layout_height="wrap_content"
-					android:layout_below="@id/settings_account_label_password"
-					android:password="true"
-					android:singleLine="true" />
-    			<Button android:id="@+id/settings_account_button_save"
-					android:layout_width="wrap_content"
-					android:layout_height="wrap_content"
-					android:layout_below="@id/settings_account_password"
-					android:layout_alignParentRight="true"
-					android:text="@string/button_save" />
-    		</RelativeLayout>
-    		</ScrollView>
-    		
-    		<!-- 
-    			XMPP Tab
-    		-->
-    		<ScrollView
-    			android:layout_width="fill_parent"
-    			android:layout_height="fill_parent"
-    			android:orientation="vertical">
-    		<RelativeLayout android:id="@+id/settings_xmpp"
-    			android:orientation="vertical"
-    			android:layout_width="fill_parent"
-    			android:layout_height="fill_parent"
-    			android:padding="10dip">
-	  			<TableLayout android:id="@+id/settings_xmpp_table_sp"
-  					android:layout_width="fill_parent"
-  					android:layout_height="wrap_content"
-  					android:stretchColumns="1">
-  					<TableRow>
-   						<TextView android:id="@+id/settings_xmpp_label_server"
-   							android:layout_column="1"
-  							android:layout_width="223dp"
-  							android:layout_height="wrap_content"
-  							android:text="@string/settings_xmpp_server"
-  							style="@style/Label" />
-  						<TextView android:id="@+id/settings_xmpp_label_port"
-  							android:layout_column="2"
-  							android:layout_width="wrap_content"
-  							android:layout_height="wrap_content"
-  							android:text="@string/settings_xmpp_port"
-  							style="@style/Label" />
-					</TableRow>
-					<TableRow>
-						<EditText android:id="@+id/settings_xmpp_server"
-							android:layout_column="1"
-							android:layout_width="wrap_content"
-							android:layout_height="wrap_content"
-							android:maxWidth="223dp"
-							android:singleLine="true" />
-						<EditText android:id="@+id/settings_xmpp_port"
-							android:layout_column="2"
-							android:layout_width="wrap_content"
-							android:layout_height="wrap_content"
-							android:minWidth="77dp"
-							android:numeric="integer"
-							android:maxLength="5"
-							android:singleLine="true" />
-					</TableRow>
-				</TableLayout>
-    			<CheckBox android:id="@+id/settings_xmpp_use_tls"
-    				android:layout_width="wrap_content"
-    				android:layout_height="wrap_content"
-    				android:text="@string/settings_xmpp_use_tls"
-    				android:layout_below="@id/settings_xmpp_table_sp"
-    				android:focusable="true"
-    				style="@style/CheckBoxLabel" />
-				<Button android:id="@+id/settings_xmpp_button_save"
-					android:layout_width="wrap_content"
-					android:layout_height="wrap_content"
-					android:layout_alignParentRight="true"
-					android:layout_below="@id/settings_xmpp_use_tls"
-					android:text="@string/button_save" />
-    		</RelativeLayout>
-    		</ScrollView>
-    		
-    		<!--
-    			Proxy Tab
-    		-->
-    		<ScrollView
-    			android:layout_width="fill_parent"
-    			android:layout_height="fill_parent"
-    			android:orientation="vertical">
-    		<RelativeLayout android:id="@+id/settings_proxy"
-    			android:orientation="vertical"
-    			android:layout_width="fill_parent"
-    			android:layout_height="fill_parent"
-    			android:padding="10dip">
-    			<CheckBox android:id="@+id/settings_proxy_use"
-    				android:layout_width="wrap_content"
-    				android:layout_height="wrap_content"
-    				android:text="@string/settings_proxy_use"
-    				android:focusable="true"
-    				style="@style/CheckBoxLabel" />
-    			<LinearLayout android:id="@+id/settings_proxy_parameters"
-    				android:layout_width="fill_parent"
-    				android:layout_height="fill_parent"
-    				android:layout_below="@id/settings_proxy_use"
-    				android:orientation="vertical">
-    				<Spinner android:id="@+id/settings_proxy_type"
-    					android:layout_width="fill_parent"
-    					android:layout_height="wrap_content" />
-    				<TableLayout android:id="@+id/settings_proxy_table_sp"
-    					android:layout_width="fill_parent"
-    					android:layout_height="wrap_content"
-    					android:stretchColumns="1">
-    					<TableRow>
-     						<TextView android:id="@+id/settings_proxy_label_server"
-     							android:layout_column="1"
-    							android:layout_width="223dp"
-    							android:layout_height="wrap_content"
-    							android:text="@string/settings_proxy_server"
-    							style="@style/Label" />
-    						<TextView android:id="@+id/settings_proxy_label_port"
-    							android:layout_column="2"
-    							android:layout_width="wrap_content"
-    							android:layout_height="wrap_content"
-    							android:text="@string/settings_proxy_port"
-    							style="@style/Label" />
-						</TableRow>
-						<TableRow>
-							<EditText android:id="@+id/settings_proxy_server"
-								android:layout_column="1"
-								android:layout_width="wrap_content"
-								android:layout_height="wrap_content"
-    							android:maxWidth="223dp"
-								android:singleLine="true" />
-							<EditText android:id="@+id/settings_proxy_port"
-								android:layout_column="2"
-								android:layout_width="wrap_content"
-								android:layout_height="wrap_content"
-								android:minWidth="77dp"
-								android:numeric="integer"
-								android:maxLength="5"
-								android:singleLine="true" />
-						</TableRow>
-					</TableLayout>
-     				<TextView android:id="@+id/settings_proxy_label_username"
-    					android:layout_width="fill_parent"
-    					android:layout_height="wrap_content"
-    					android:text="@string/settings_proxy_username"
-    					style="@style/Label" />
-					<EditText android:id="@+id/settings_proxy_username"
-						android:layout_width="fill_parent"
-						android:layout_height="wrap_content"
-						android:singleLine="true" />
-     				<TextView android:id="@+id/settings_proxy_label_password"
-    					android:layout_width="fill_parent"
-    					android:layout_height="wrap_content"
-    					android:text="@string/settings_proxy_password"
-    					style="@style/Label" />
-					<EditText android:id="@+id/settings_proxy_password"
-						android:layout_width="fill_parent"
-						android:layout_height="wrap_content"
-    					android:password="true"
-    					android:singleLine="true" />
-				</LinearLayout>
-				<Button android:id="@+id/settings_proxy_button_save"
-					android:layout_width="wrap_content"
-					android:layout_height="wrap_content"
-					android:layout_alignParentRight="true"
-					android:text="@string/button_save" />
-    		</RelativeLayout>
-    		</ScrollView>
-    	</FrameLayout>
-	</LinearLayout>
-</TabHost>
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Sun Sep 27 19:10:23 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Sun Sep 27 20:11:47 2009 +0200
@@ -39,7 +39,7 @@
     /**
      * Beem connection closed Intent name.
      */
-    
+
     private static final String TAG = "XMPPConnectionAdapter";
     private XMPPConnection mAdaptee;
     private IChatManager mChatManager;
--- a/src/com/beem/project/beem/ui/Login.java	Sun Sep 27 19:10:23 2009 +0200
+++ b/src/com/beem/project/beem/ui/Login.java	Sun Sep 27 20:11:47 2009 +0200
@@ -81,7 +81,7 @@
 	setContentView(R.layout.login);
 	mProgressDialog = new ProgressDialog(this);
     }
-    
+
     /**
      * {@inheritDoc}
      */
--- a/src/com/beem/project/beem/ui/SendIM.java	Sun Sep 27 19:10:23 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Sun Sep 27 20:11:47 2009 +0200
@@ -217,7 +217,7 @@
 		mSmyDialog.show();
 		return true;
 	    case R.id.sendim_call:
-		// TODO start the jingle call 
+		// TODO start the jingle call
 		// Bug a besoin du jid complet (resource compris)
 		try {
 		    mXmppFacade.call(mContact.getJID());
@@ -332,8 +332,6 @@
 	    Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT);
 	    msg.setBody(text);
 	    try {
-		// TODO: PAs connecter au serveur BING grosse Error !
-		// INTERDICTION !
 		mChat.sendMessage(msg);
 		if (mSpeak != 1)
 		    mText.append(getString(R.string.SendIMYouSay, text));
@@ -344,7 +342,6 @@
 		mToSend.requestFocus();
 		mSpeak = 1;
 	    } catch (RemoteException e) {
-		// TODO Auto-generated catch block
 		e.printStackTrace();
 	    }
 	}
--- a/src/com/beem/project/beem/ui/Subscription.java	Sun Sep 27 19:10:23 2009 +0200
+++ b/src/com/beem/project/beem/ui/Subscription.java	Sun Sep 27 20:11:47 2009 +0200
@@ -1,19 +1,12 @@
-/**
- * 
- */
 package com.beem.project.beem.ui;
 
 import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smack.packet.Presence.Type;
 
-import com.beem.project.beem.BeemService;
-import com.beem.project.beem.R;
-import com.beem.project.beem.service.PresenceAdapter;
-import com.beem.project.beem.service.aidl.IXmppFacade;
-
 import android.app.Activity;
 import android.content.ComponentName;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.os.Bundle;
 import android.os.IBinder;
@@ -23,22 +16,40 @@
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.beem.project.beem.BeemService;
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.PresenceAdapter;
+import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
+
 /**
+ * This activity is used to accept a subscription request.
  * @author nikita
- *
  */
 public class Subscription extends Activity {
 
-    public static final String TAG = "Subscription";
+    private static final Intent SERVICE_INTENT = new Intent();
     private IXmppFacade mService;
     private String mContact;
     private ServiceConnection mServConn = new BeemServiceConnection();
+    private BeemBroadcastReceiver mReceiver;
+    private MyOnClickListener mClickListener = new MyOnClickListener();
+
+    static {
+	SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+    }
+
+    /**
+     * Constructor.
+     */
+    public Subscription() {
+    }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
 	super.onCreate(savedInstanceState);
 	setContentView(R.layout.subscription);
-	bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+	mReceiver = new BeemBroadcastReceiver(mServConn);
 	findViewById(R.id.SubscriptionAccept).setOnClickListener(mClickListener);
 	findViewById(R.id.SubscriptionRefuse).setOnClickListener(mClickListener);
 	mContact = getIntent().getStringExtra("from");
@@ -48,12 +59,31 @@
     }
 
     @Override
-    protected void onDestroy() {
-	super.onDestroy();
-	unbindService(mServConn);
+    protected void onResume() {
+	super.onResume();
+	this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
+	bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+	mReceiver.setBinded();
     }
 
-    private OnClickListener mClickListener = new OnClickListener() {
+    @Override
+    protected void onPause() {
+	super.onPause();
+	this.unregisterReceiver(mReceiver);
+	if (mReceiver.isBinded())
+	    unbindService(mServConn);
+    }
+
+    /**
+     * Event simple click on buttons.
+     */
+    private class MyOnClickListener implements OnClickListener {
+
+	/**
+	 * Constructor.
+	 */
+	public MyOnClickListener() {
+	}
 
 	@Override
 	public void onClick(View v) {
@@ -72,24 +102,33 @@
 			    Toast.LENGTH_SHORT).show();
 			e.printStackTrace();
 		    }
-		    break ;
+		    break;
 		case R.id.SubscriptionRefuse:
 		    Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused),
 			Toast.LENGTH_SHORT).show();
 
-		    break ;
+		    break;
 		default:
 		    Toast.makeText(Subscription.this, getString(R.string.SubscriptError),
 			Toast.LENGTH_SHORT).show();
-	    };
+	    }
 	}
     };
 
+    /**
+     * The ServiceConnection used to connect to the Beem service.
+     */
     private class BeemServiceConnection implements ServiceConnection {
 
+	/**
+	 * Constructor.
+	 */
+	public BeemServiceConnection() {
+	}
+
 	@Override
 	public void onServiceConnected(ComponentName name, IBinder service) {
-	    mService = IXmppFacade.Stub.asInterface(service);			
+	    mService = IXmppFacade.Stub.asInterface(service);
 	}
 
 	@Override
--- a/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java	Sun Sep 27 19:10:23 2009 +0200
+++ b/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java	Sun Sep 27 20:11:47 2009 +0200
@@ -14,14 +14,18 @@
  */
 public class BeemBroadcastReceiver extends BroadcastReceiver {
 
+    /**
+     * Broadcast intent type.
+     */
     public static final String BEEM_CONNECTION_CLOSED = "BeemConnectionClosed";
     private ServiceConnection mService;
     private boolean mIsBinded;
-    
+
     /**
      * constructor.
+     * @param service service observed
      */
-    public BeemBroadcastReceiver(ServiceConnection service) {
+    public BeemBroadcastReceiver(final ServiceConnection service) {
 	mService = service;
 	mIsBinded = false;
     }
@@ -34,14 +38,21 @@
 	context.unbindService(mService);
 	mIsBinded = false;
 	context.startActivity(new Intent(context, Login.class));
-	CharSequence message = intent.getCharSequenceExtra("message");	
+	CharSequence message = intent.getCharSequenceExtra("message");
 	Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
     }
-    
+
+    /**
+     * service is binded.
+     */
     public void setBinded() {
 	mIsBinded = true;
     }
 
+    /**
+     * return service bind status.
+     * @return service bind status.
+     */
     public boolean isBinded() {
 	return mIsBinded;
     }