# HG changeset patch
# User "Vincent Veronis"
# Date 1319497940 -7200
# Node ID 45ba9cc90c22cef7bbb4eccd5fbd54095586b109
# Parent 1f746f930962f7f8405ff14c003461ba6c5c2126
Notification now in an separate class
diff -r 1f746f930962 -r 45ba9cc90c22 AndroidManifest.xml
--- a/AndroidManifest.xml Tue Oct 25 01:06:19 2011 +0200
+++ b/AndroidManifest.xml Tue Oct 25 01:12:20 2011 +0200
@@ -244,7 +244,7 @@
android:name="android.permission.WRITE_SYNC_SETTINGS" />
+ android:targetSdkVersion="8" />
+
+
+
+
\ No newline at end of file
diff -r 1f746f930962 -r 45ba9cc90c22 res/values/styles.xml
--- a/res/values/styles.xml Tue Oct 25 01:06:19 2011 +0200
+++ b/res/values/styles.xml Tue Oct 25 01:12:20 2011 +0200
@@ -19,7 +19,6 @@
parent="@android:style/Theme">
- @drawable/background
-
-
-
+
+
+
+
\ No newline at end of file
diff -r 1f746f930962 -r 45ba9cc90c22 src/com/beem/project/beem/BeemService.java
--- a/src/com/beem/project/beem/BeemService.java Tue Oct 25 01:06:19 2011 +0200
+++ b/src/com/beem/project/beem/BeemService.java Tue Oct 25 01:12:20 2011 +0200
@@ -61,7 +61,6 @@
import android.app.Notification;
import android.app.NotificationManager;
-import android.app.PendingIntent;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -78,7 +77,6 @@
import android.os.Message;
import android.os.RemoteException;
import android.util.Log;
-import android.widget.RemoteViews;
import com.beem.project.beem.service.XmppConnectionAdapter;
import com.beem.project.beem.service.XmppFacade;
@@ -86,7 +84,7 @@
import com.beem.project.beem.smack.avatar.AvatarMetadataProvider;
import com.beem.project.beem.smack.avatar.AvatarProvider;
import com.beem.project.beem.smack.caps.CapsProvider;
-import com.beem.project.beem.ui.Login;
+import com.beem.project.beem.ui.BeemNotification;
import com.beem.project.beem.utils.BeemBroadcastReceiver;
import com.beem.project.beem.utils.BeemConnectivity;
import com.beem.project.beem.utils.Status;
@@ -107,7 +105,6 @@
private static final int MESSAGE_SEND_MSG = 0x3;
private static final int MESSAGE_SYNC = 0x4;
- private NotificationManager mNotificationManager;
private Map mConnection = new HashMap();
private Map mBeemConnection = new HashMap();
private Map mBind = new HashMap();
@@ -168,23 +165,9 @@
mHandler = new BeemServiceHandler(mServiceLooper);
registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
configure(ProviderManager.getInstance());
- mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ BeemNotification.BindNotification(this);
Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
- Notification notification = new Notification();
- Intent notificationIntent = new Intent();
- PendingIntent contentIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
- notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
- RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification);
- //contentView.setImageViewResource(R.id.status, R.drawable.beem_status_icon);
- contentView.setTextViewText(R.id.pseudo, "Custom notification");
- contentView.setTextViewText(R.id.msgstatus, "This is a custom layout");
- notification.contentView = contentView;
- notification.contentIntent = contentIntent;
- notification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
- notification.icon = R.drawable.beem_status_icon;
- mNotificationManager.notify(R.string.app_name, notification);
-
}
/**
@@ -193,7 +176,6 @@
@Override
public void onDestroy() {
super.onDestroy();
- mNotificationManager.cancelAll();
unregisterReceiver(mReceiver);
if (mOnOffReceiverIsRegistered)
@@ -224,14 +206,6 @@
}
/**
- * Delete a notification.
- * @param id the id of the notification
- */
- public void deleteNotification(int id) {
- mNotificationManager.cancel(id);
- }
-
- /**
* Reset the status to online after a disconnect.
*/
public void resetStatus() {
@@ -269,14 +243,6 @@
}
/**
- * Get the notification manager system service.
- * @return the notification manager service.
- */
- public NotificationManager getNotificationManager() {
- return mNotificationManager;
- }
-
- /**
* A sort of patch from this thread: http://www.igniterealtime.org/community/thread/31118. Avoid ClassCastException
* by bypassing the classloading shit of Smack.
* @param pm The ProviderManager.
@@ -388,6 +354,8 @@
mOnOffReceiverIsRegistered = false;
unregisterReceiver(mOnOffReceiver);
}
+ } else if (BeemApplication.STATUS_TEXT_KEY.equals(key)) {
+ BeemNotification.BindNotification(BeemService.this);
}
}
}
diff -r 1f746f930962 -r 45ba9cc90c22 src/com/beem/project/beem/account/SyncAdapter.java
--- a/src/com/beem/project/beem/account/SyncAdapter.java Tue Oct 25 01:06:19 2011 +0200
+++ b/src/com/beem/project/beem/account/SyncAdapter.java Tue Oct 25 01:12:20 2011 +0200
@@ -71,10 +71,4 @@
}
- @Override
- public void onSyncCanceled() {
- super.onSyncCanceled();
- Log.e(TAG, "SYNCCANCELED");
- }
-
}
diff -r 1f746f930962 -r 45ba9cc90c22 src/com/beem/project/beem/service/BeemChatManager.java
--- a/src/com/beem/project/beem/service/BeemChatManager.java Tue Oct 25 01:06:19 2011 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java Tue Oct 25 01:12:20 2011 +0200
@@ -68,7 +68,6 @@
import com.beem.project.beem.BeemApplication;
import com.beem.project.beem.BeemService;
-import com.beem.project.beem.providers.MessageProvider;
import com.beem.project.beem.providers.Messages;
import com.beem.project.beem.service.aidl.IChat;
import com.beem.project.beem.service.aidl.IChatManager;
@@ -161,11 +160,11 @@
*/
@Override
public void deleteChatNotification(IChat chat) {
- try {
- mService.deleteNotification(chat.getParticipant().getJID().hashCode());
- } catch (RemoteException e) {
- Log.v(TAG, "Remote exception ", e);
- }
+// try {
+// //TODO: BeemNotification.BindNotification(BeemChatManager.this).deleteNotification(chat.getParticipant().getJID().hashCode());
+// } catch (RemoteException e) {
+// Log.v(TAG, "Remote exception ", e);
+// }
}
/**
diff -r 1f746f930962 -r 45ba9cc90c22 src/com/beem/project/beem/ui/BeemNotification.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/BeemNotification.java Tue Oct 25 01:12:20 2011 +0200
@@ -0,0 +1,55 @@
+package com.beem.project.beem.ui;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+import com.beem.project.beem.R;
+
+/**
+ * SingletonClass notification.
+ * @author Vincent V.
+ */
+public class BeemNotification extends Notification {
+
+ private static Context mContext;
+ private NotificationManager mNotificationManager;
+
+ private static BeemNotification instance = null;
+
+ /**
+ * Constructor.
+ */
+ protected BeemNotification() {
+ super();
+
+ mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+ Intent notificationIntent = new Intent();
+ contentIntent = PendingIntent.getActivity(mContext, (int) System.currentTimeMillis(), notificationIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ icon = R.drawable.beem_status_icon;
+ flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
+ contentView = new RemoteViews(mContext.getPackageName(), R.layout.notification);
+ contentView.setTextViewText(R.id.pseudo, "Beem");
+ }
+
+ public static BeemNotification BindNotification(Context c) {
+ if (instance == null) {
+ mContext = c;
+ instance = new BeemNotification();
+ }
+ instance.contentView.setTextViewText(R.id.msgstatus, "TODO: X messages unread");
+ instance.mNotificationManager.notify(R.string.app_name, instance);
+
+ return instance;
+ }
+
+ public void deleteNotification(int id) {
+ mNotificationManager.cancel(id);
+ }
+
+}
diff -r 1f746f930962 -r 45ba9cc90c22 src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/ui/ContactList.java Tue Oct 25 01:06:19 2011 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Tue Oct 25 01:12:20 2011 +0200
@@ -42,7 +42,6 @@
*/
package com.beem.project.beem.ui;
-import java.net.URI;
import java.util.Comparator;
import java.util.List;
@@ -68,14 +67,14 @@
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.AdapterView;
+import android.widget.AdapterView.AdapterContextMenuInfo;
+import android.widget.AdapterView.OnItemClickListener;
import android.widget.Filterable;
import android.widget.Gallery;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
-import android.widget.AdapterView.AdapterContextMenuInfo;
-import android.widget.AdapterView.OnItemClickListener;
import com.beem.project.beem.BeemIntent;
import com.beem.project.beem.R;
diff -r 1f746f930962 -r 45ba9cc90c22 src/com/beem/project/beem/utils/Status.java
--- a/src/com/beem/project/beem/utils/Status.java Tue Oct 25 01:06:19 2011 +0200
+++ b/src/com/beem/project/beem/utils/Status.java Tue Oct 25 01:12:20 2011 +0200
@@ -46,8 +46,6 @@
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Mode;
-import android.provider.ContactsContract;
-
/**
* Utility class to deal with status and presence value.
* @author marseille
@@ -113,32 +111,32 @@
* @return an int representing the status
*/
public static int getStatusFromPresence(final Presence presence) {
- int res = ContactsContract.StatusUpdates.OFFLINE;
+ int res = Status.CONTACT_STATUS_DISCONNECT;
if (presence.getType().equals(Presence.Type.unavailable)) {
- res = ContactsContract.StatusUpdates.OFFLINE;
+ res = Status.CONTACT_STATUS_DISCONNECT;
} else {
Mode mode = presence.getMode();
if (mode == null) {
- res = ContactsContract.StatusUpdates.AVAILABLE;
+ res = Status.CONTACT_STATUS_AVAILABLE;
} else {
switch (mode) {
case available:
- res = ContactsContract.StatusUpdates.AVAILABLE;
+ res = Status.CONTACT_STATUS_AVAILABLE;
break;
case away:
- res = ContactsContract.StatusUpdates.AWAY;
+ res = Status.CONTACT_STATUS_AWAY;
break;
case chat:
- res = ContactsContract.StatusUpdates.AVAILABLE;
+ res = Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
break;
case dnd:
- res = ContactsContract.StatusUpdates.DO_NOT_DISTURB;
+ res = Status.CONTACT_STATUS_BUSY;
break;
case xa:
- res = ContactsContract.StatusUpdates.INVISIBLE;
+ res = Status.CONTACT_STATUS_UNAVAILABLE;
break;
default:
- res = ContactsContract.StatusUpdates.OFFLINE;
+ res = Status.CONTACT_STATUS_DISCONNECT;
break;
}
}