author | Da Risk <darisk972@gmail.com> |
Tue, 19 May 2009 22:45:03 +0200 | |
changeset 218 | 5a7653411251 |
parent 190 | 079488da1bfc |
child 224 | d8e2cb1eb895 |
permissions | -rw-r--r-- |
147 | 1 |
/** |
2 |
* |
|
3 |
*/ |
|
4 |
package com.beem.project.beem.ui; |
|
5 |
||
155 | 6 |
import org.jivesoftware.smack.packet.Presence; |
7 |
import org.jivesoftware.smack.packet.Presence.Type; |
|
8 |
||
9 |
import com.beem.project.beem.BeemApplication; |
|
147 | 10 |
import com.beem.project.beem.R; |
155 | 11 |
import com.beem.project.beem.service.PresenceAdapter; |
12 |
import com.beem.project.beem.service.aidl.IXmppFacade; |
|
147 | 13 |
|
14 |
import android.app.Activity; |
|
15 |
import android.os.Bundle; |
|
155 | 16 |
import android.os.RemoteException; |
17 |
import android.view.View; |
|
18 |
import android.view.View.OnClickListener; |
|
218
5a7653411251
tite modification sur l'activity subscription.
Da Risk <darisk972@gmail.com>
parents:
190
diff
changeset
|
19 |
import android.widget.TextView; |
155 | 20 |
import android.widget.Toast; |
147 | 21 |
|
22 |
/** |
|
23 |
* @author nikita |
|
24 |
* |
|
25 |
*/ |
|
26 |
public class Subscription extends Activity { |
|
190 | 27 |
|
155 | 28 |
private IXmppFacade mService; |
29 |
private String mContact; |
|
190 | 30 |
|
147 | 31 |
@Override |
32 |
protected void onCreate(Bundle savedInstanceState) { |
|
33 |
super.onCreate(savedInstanceState); |
|
34 |
setContentView(R.layout.subscription); |
|
155 | 35 |
findViewById(R.id.SubscriptionAccept).setOnClickListener(mClickListener); |
36 |
findViewById(R.id.SubscriptionRefuse).setOnClickListener(mClickListener); |
|
37 |
mContact = getIntent().getStringExtra("from"); |
|
218
5a7653411251
tite modification sur l'activity subscription.
Da Risk <darisk972@gmail.com>
parents:
190
diff
changeset
|
38 |
TextView tv = (TextView) findViewById(R.id.SubscriptionText); |
5a7653411251
tite modification sur l'activity subscription.
Da Risk <darisk972@gmail.com>
parents:
190
diff
changeset
|
39 |
String str = String.format(getString(R.string.SubscriptText), mContact); |
5a7653411251
tite modification sur l'activity subscription.
Da Risk <darisk972@gmail.com>
parents:
190
diff
changeset
|
40 |
tv.setText(str); |
155 | 41 |
mService = BeemApplication.getApplication(this).getXmppFacade(); |
147 | 42 |
} |
190 | 43 |
|
155 | 44 |
private OnClickListener mClickListener = new OnClickListener() { |
45 |
||
46 |
@Override |
|
47 |
public void onClick(View v) { |
|
48 |
switch (v.getId()) { |
|
49 |
case R.id.SubscriptionAccept: |
|
50 |
Presence presence = new Presence(Type.subscribed); |
|
51 |
presence.setTo(mContact); |
|
52 |
PresenceAdapter preAdapt = new PresenceAdapter(presence); |
|
53 |
try { |
|
54 |
mService.sendPresencePacket(preAdapt); |
|
190 | 55 |
Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept), |
56 |
Toast.LENGTH_SHORT).show(); |
|
155 | 57 |
finish(); |
58 |
} catch (RemoteException e) { |
|
190 | 59 |
Toast.makeText(Subscription.this, getString(R.string.SubscriptError), |
60 |
Toast.LENGTH_SHORT).show(); |
|
155 | 61 |
e.printStackTrace(); |
62 |
} |
|
63 |
break ; |
|
64 |
case R.id.SubscriptionRefuse: |
|
190 | 65 |
Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused), |
66 |
Toast.LENGTH_SHORT).show(); |
|
67 |
||
155 | 68 |
break ; |
69 |
default: |
|
190 | 70 |
Toast.makeText(Subscription.this, getString(R.string.SubscriptError), |
71 |
Toast.LENGTH_SHORT).show(); |
|
155 | 72 |
}; |
190 | 73 |
|
155 | 74 |
} |
190 | 75 |
|
155 | 76 |
}; |
147 | 77 |
} |