debut de la subscription
authornikita@nikita-rack
Thu, 23 Apr 2009 15:37:24 +0200
changeset 147 472d56ba57c6
parent 146 89bbb1c560ad
child 148 c169121bd07e
child 155 7919a49cd5c6
debut de la subscription
AndroidManifest.xml
res/layout/subscription.xml
res/values/strings.xml
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/service/BeemChatManager.java
src/com/beem/project/beem/ui/Subscription.java
--- a/AndroidManifest.xml	Thu Apr 23 12:54:56 2009 +0200
+++ b/AndroidManifest.xml	Thu Apr 23 15:37:24 2009 +0200
@@ -15,6 +15,7 @@
 		<activity android:name=".ui.ChangeStatus" android:label="@string/app_name" />
 		<activity android:name=".ui.AccountCreation" android:label="@string/app_name" />
 		<activity android:name=".ui.AddContact" android:label="@string/app_name" />
+		<activity android:name=".ui.Subscription" android:label="@string/app_name" />
 		<service android:name="BeemService" android:enabled="true"
 			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
 			<intent-filter>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/subscription.xml	Thu Apr 23 15:37:24 2009 +0200
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent">
+   	<LinearLayout
+   		android:orientation="horizontal"
+   		android:layout_width="fill_parent"
+   		android:layout_height="wrap_content">
+   		
+	   	<Button android:id="@+id/SubscriptionAccept"
+	   		android:layout_width="fill_parent"
+	   		android:layout_height="fill_parent"
+	   		android:layout_weight="1"
+	   		android:text="@string/AcceptButton"/>
+	   		
+		<Button android:id="@+id/SubscriptionRefuse"
+	   		android:layout_width="fill_parent"
+	   		android:layout_height="fill_parent"
+	   		android:layout_weight="1"
+	   		android:text="@string/RefuseButton"/>
+   	</LinearLayout>
+</LinearLayout>
\ No newline at end of file
--- a/res/values/strings.xml	Thu Apr 23 12:54:56 2009 +0200
+++ b/res/values/strings.xml	Thu Apr 23 15:37:24 2009 +0200
@@ -3,6 +3,8 @@
 	<string name="app_name">Beem</string>
 	<string name="OkButton">Ok</string>
 	<string name="ClearButton">Clear</string>
+	<string name="AcceptButton">Accept</string>
+	<string name="RefuseButton">Refuse</string>
 	
 	<!--  Beem class -->
 	
@@ -59,4 +61,5 @@
 	<string name="ChangeStatusOk">Updating status</string>
 	<string name="ChangeStatusNoChange">Nothing to change</string>
 
+
 </resources>
--- a/src/com/beem/project/beem/BeemService.java	Thu Apr 23 12:54:56 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Thu Apr 23 15:37:24 2009 +0200
@@ -14,6 +14,7 @@
 import org.jivesoftware.smack.proxy.ProxyInfo.ProxyType;
 import android.app.Notification;
 import android.app.NotificationManager;
+import android.app.PendingIntent;
 import android.app.Service;
 import android.content.Intent;
 import android.content.SharedPreferences;
@@ -26,6 +27,8 @@
 import com.beem.project.beem.service.aidl.IBeemConnectionListener;
 import com.beem.project.beem.service.aidl.IXmppConnection;
 import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.ui.SendIM;
+import com.beem.project.beem.ui.Subscription;
 
 /**
  * This class is for the Beem service.
@@ -72,7 +75,7 @@
      */
     @Override
     public void onCreate() {
-	
+
 	super.onCreate();
 	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
 	mLogin = mSettings.getString(getString(R.string.PreferenceLoginKey), "");
@@ -117,7 +120,7 @@
     public void sendNotification(int id, Notification notif) {
 	mNotificationManager.notify(id, notif);
     }
-    
+
     /**
      * Initialise la configuration de la connexion.
      */
@@ -168,7 +171,7 @@
 			@Override
 			public void processPacket(Packet packet) {
 			    // TODO Auto-generated method stub
-			    Log.i("TEST", "Une demande recue");
+			    Log.d("TEST", "Une demande recue");
 			}
 		    }, filter);
 		}
@@ -185,7 +188,7 @@
 
 		}
 
-		
+
 		@Override
 		public void onConnect() throws RemoteException {
 		    // TODO Auto-generated method stub
@@ -205,8 +208,17 @@
 
 			@Override
 			public void processPacket(Packet packet) {
-			    // TODO Auto-generated method stub
-			    Log.i("TEST", "Une demande recue");
+			    String from = packet.getFrom();
+			    Notification notif = new Notification(com.beem.project.beem.R.drawable.signal, "Demande d'ajout", System
+				.currentTimeMillis());
+			    notif.defaults = Notification.DEFAULT_ALL;
+			    notif.flags = Notification.FLAG_AUTO_CANCEL;
+			    Intent intent = new Intent(BeemService.this, Subscription.class);
+			    intent.putExtra("from", from);
+			    notif.setLatestEventInfo(BeemService.this, from, "demande d'ajout de " + from, PendingIntent.getActivity(BeemService.this, 0,
+				intent, PendingIntent.FLAG_ONE_SHOT));
+			    int id = packet.hashCode();
+			    sendNotification(id, notif);
 			}
 		    }, filter);
 
@@ -228,7 +240,7 @@
 		@Override
 		public void connectionFailed(String errorMsg) throws RemoteException {
 		    // TODO Auto-generated method stub
-		    
+
 		}
 	    });
 	} catch (RemoteException e) {
@@ -245,5 +257,5 @@
 	    mConnection.disconnect();
     }
 
-    
+
 }
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Thu Apr 23 12:54:56 2009 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Thu Apr 23 15:37:24 2009 +0200
@@ -15,7 +15,6 @@
 import org.jivesoftware.smackx.ChatState;
 import org.jivesoftware.smackx.ChatStateListener;
 
-import android.R;
 import android.app.Notification;
 import android.app.PendingIntent;
 import android.content.Intent;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/Subscription.java	Thu Apr 23 15:37:24 2009 +0200
@@ -0,0 +1,23 @@
+/**
+ * 
+ */
+package com.beem.project.beem.ui;
+
+import com.beem.project.beem.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.Button;
+
+/**
+ * @author nikita
+ *
+ */
+public class Subscription extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.subscription);
+	//mOk = (Button) findViewById(R.id.SubscriptionAccept);
+    }
+}