Update custom notification layout
author"Vincent Veronis"
Tue, 18 Oct 2011 12:10:07 +0200
changeset 907 d26b442143f9
parent 906 4ee4a608f97b
child 908 1f746f930962
Update custom notification layout
res/values/styles.xml
src/com/beem/project/beem/BeemService.java
--- a/res/values/styles.xml	Tue Oct 18 01:02:23 2011 +0200
+++ b/res/values/styles.xml	Tue Oct 18 12:10:07 2011 +0200
@@ -9,25 +9,27 @@
 		<item name="android:focusable">false</item>
 		<item name="android:padding">4px</item>
 	</style>
-	<style name="CheckBoxLabel" parent="@style/Label">
+	<style
+		name="CheckBoxLabel"
+		parent="@style/Label">
 		<item name="android:enabled">true</item>
 	</style>
-	<style name="Theme.BEEM.Default" parent="@android:style/Theme">
+	<style
+		name="Theme.BEEM.Default"
+		parent="@android:style/Theme">
 		<item name="android:windowBackground">@drawable/background</item>
 	</style>
-	
 
-<!-- Old PC style -->
-
+	<!-- Old PC style -->
 	<style name="OldTheme">
-		<item name="android:textViewStyle" >@style/OldThemeTextView</item>
+		<item name="android:textViewStyle">@style/OldThemeTextView</item>
 	</style>
-	<style name="OldThemeTextView" parent="@android:style/Widget.TextView">
+	<style
+		name="OldThemeTextView"
+		parent="@android:style/Widget.TextView">
 		<item name="android:textColor">#ff009900</item>
 		<item name="android:background">@color/black</item>
 	</style>
-	
-	
-<!-- Other style -->
 
-</resources>
+	<!-- Other style -->
+</resources>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemService.java	Tue Oct 18 01:02:23 2011 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Tue Oct 18 12:10:07 2011 +0200
@@ -78,6 +78,7 @@
 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;
@@ -160,7 +161,7 @@
     @Override
     public void onCreate() {
 	super.onCreate();
-
+	Log.d(TAG, "ONCREATE");
 	HandlerThread thread = new HandlerThread("BeemServiceThread");
 	thread.start();
 	mServiceLooper = thread.getLooper();
@@ -169,18 +170,20 @@
 	configure(ProviderManager.getInstance());
 	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
-	Log.d(TAG, "ONCREATE");
 
-	Notification mStatusNotification;
-	mStatusNotification = new Notification(com.beem.project.beem.R.drawable.beem_status_icon, "Beem",
-	    System.currentTimeMillis());
-	mStatusNotification.defaults = Notification.DEFAULT_LIGHTS;
-	mStatusNotification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
-
-	mStatusNotification.setLatestEventInfo(this, "Beem", "Beem",
-	    PendingIntent.getActivity(this, 0, new Intent(this, Login.class), 0));
-	// bypass the preferences for notification
-	mNotificationManager.notify(BeemService.NOTIFICATION_STATUS_ID, mStatusNotification);
+	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);
 
     }