--- 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" />
<uses-sdk
android:minSdkVersion="7"
- android:targetSdkVersion="7" />
+ android:targetSdkVersion="8" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/notification.xml Tue Oct 25 01:12:20 2011 +0200
@@ -0,0 +1,28 @@
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/layout"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:padding="10dp">
+ <ImageButton
+ android:id="@+id/status"
+ android:background="@drawable/beem_launcher_icon_silver"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:layout_alignParentLeft="true"
+ android:layout_marginRight="10dp" />
+ <TextView
+ android:id="@+id/pseudo"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/status"
+ style="@style/NotificationTitle" />
+ <TextView
+ android:id="@+id/msgstatus"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/status"
+ android:layout_below="@id/pseudo"
+ style="@style/NotificationText" />
+</RelativeLayout>
\ No newline at end of file
--- 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">
<item name="android:windowBackground">@drawable/background</item>
</style>
-
<!-- Old PC style -->
<style name="OldTheme">
<item name="android:textViewStyle">@style/OldThemeTextView</item>
@@ -30,6 +29,14 @@
<item name="android:textColor">#ff009900</item>
<item name="android:background">@color/black</item>
</style>
-
- <!-- Other style -->
+ <!-- Notification style -->
+ <style name="NotificationTitle">
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ <item name="android:textStyle">bold</item>
+ </style>
+ <style name="NotificationText">
+ <item name="android:textColor">?android:attr/textColorPrimary</item>
+ </style>
+ <!-- If you want a slightly different color for some text, consider using
+ ?android:attr/textColorSecondary -->
</resources>
\ No newline at end of file
--- 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<String, XmppConnectionAdapter> mConnection = new HashMap<String, XmppConnectionAdapter>();
private Map<String, BeemConnection> mBeemConnection = new HashMap<String, BeemConnection>();
private Map<String, IXmppFacade.Stub> mBind = new HashMap<String, IXmppFacade.Stub>();
@@ -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);
}
}
}
--- 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");
- }
-
}
--- 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);
+// }
}
/**
--- /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. <marseille@beem-project.com>
+ */
+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);
+ }
+
+}
--- 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;
--- 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;
}
}