notification update
author"Vincent Veronis"
Tue, 25 Oct 2011 01:41:19 +0200
changeset 910 9458ad77117f
parent 909 45ba9cc90c22
child 911 e5c194ea9307
notification update
src/com/beem/project/beem/ui/BeemNotification.java
src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/ui/BeemNotification.java	Tue Oct 25 01:12:20 2011 +0200
+++ b/src/com/beem/project/beem/ui/BeemNotification.java	Tue Oct 25 01:41:19 2011 +0200
@@ -1,3 +1,32 @@
+/*
+    BEEM is a videoconference application on the Android Platform.
+
+    Copyright (C) 2009 by Frederic-Charles Barthelery,
+                          Jean-Manuel Da Silva,
+                          Nikita Kozlov,
+                          Philippe Lago,
+                          Jean Baptiste Vergely,
+                          Vincent Veronis.
+
+    This file is part of BEEM.
+
+    BEEM is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    BEEM is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with BEEM.  If not, see <http://www.gnu.org/licenses/>.
+
+    Please send bug reports with examples or suggestions to
+    contact@beem-project.com or http://dev.beem-project.com/
+ */
+
 package com.beem.project.beem.ui;
 
 import android.app.Notification;
@@ -5,7 +34,6 @@
 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;
@@ -24,28 +52,30 @@
     /**
      * Constructor.
      */
-    protected BeemNotification() {
+    protected BeemNotification(Context c) {
 	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;	
+	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) {
+    public static void BindNotification(Context c) {
 	if (instance == null) {
-	    mContext = c;
-	    instance = new BeemNotification();
-	}		
+	    instance = new BeemNotification(c);
+	}
 	instance.contentView.setTextViewText(R.id.msgstatus, "TODO: X messages unread");
 	instance.mNotificationManager.notify(R.string.app_name, instance);
+
+    }
+    
+    public static void SyncNotification(Context c) {
 	
-	return instance;
     }
 
     public void deleteNotification(int id) {
--- a/src/com/beem/project/beem/ui/ContactList.java	Tue Oct 25 01:12:20 2011 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Tue Oct 25 01:41:19 2011 +0200
@@ -201,8 +201,8 @@
 		return true;
 	    case R.id.contact_list_menu_sync:
 		//TODO: Manual Sync operation
-		Log.i(TAG, "performSync: " + mAccountName);	
-		Intent intent = new Intent(BeemIntent.ACTION_SYNC );
+		Log.i(TAG, "performSync: " + mAccountName);
+		Intent intent = new Intent(BeemIntent.ACTION_SYNC);
 		intent.putExtra(BeemIntent.EXTRA_ACCOUNT, mAccountName);
 		startService(intent);
 		return true;
@@ -313,12 +313,11 @@
 	    View v = stub.inflate();
 	    Gallery g = (Gallery) v.findViewById(R.id.contactlist_banner);
 	    g.setOnItemClickListener(new OnItemClickGroupName());
-	    g.setAdapter(mAdapterBanner);
-	    g.setSelection(0);
+	    g.setAdapter(mAdapterBanner);   	    
 	} else {
 	    ((LinearLayout) findViewById(R.id.contactlist_groupstub)).setVisibility(View.VISIBLE);
 	    Gallery g = (Gallery) findViewById(R.id.contactlist_banner);
-	    g.setSelection(0);
+	    //g.setSelection(0);
 	}
     }
 
@@ -353,29 +352,31 @@
 
 	@Override
 	public void bindView(View view, Context context, Cursor cursor) {
-	    String name = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.SOURCE_ID));
-	    String jid = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.SOURCE_ID));
-	    TextView nameText = (TextView) view.findViewById(R.id.contactlistpseudo);
-	    if (nameText != null) {
-		nameText.setText(name);
-	    }
+	    if (cursor.getCount() > 0) {
+		String name = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.SOURCE_ID));
+		String jid = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.SOURCE_ID));
+		TextView nameText = (TextView) view.findViewById(R.id.contactlistpseudo);
+		if (nameText != null) {
+		    nameText.setText(name);
+		}
 
-	    // String msgStatus = cursor.getString(cursor
-	    // .getColumnIndex(ContactsContract.Contacts.CONTACT_STATUS));
-	    // TextView msgStatusText = (TextView) view
-	    // .findViewById(R.id.contactlistmsgperso);
-	    // if (msgStatusText != null) {
-	    // msgStatusText.setText(msgStatus);
-	    // }
+		// String msgStatus = cursor.getString(cursor
+		// .getColumnIndex(ContactsContract.Contacts.CONTACT_STATUS));
+		// TextView msgStatusText = (TextView) view
+		// .findViewById(R.id.contactlistmsgperso);
+		// if (msgStatusText != null) {
+		// msgStatusText.setText(msgStatus);
+		// }
 
-	    view.setTag(jid);
+		view.setTag(jid);
 
-	    // ImageView img = (ImageView) view.findViewById(R.id.avatar);
-	    // String avatarId = curContact.getAvatarId();
-	    // int contactStatus = curContact.getStatus();
-	    // Drawable avatar = getAvatarStatusDrawable(avatarId);
-	    // img.setImageDrawable(avatar);
-	    // img.setImageLevel(contactStatus);
+		// ImageView img = (ImageView) view.findViewById(R.id.avatar);
+		// String avatarId = curContact.getAvatarId();
+		// int contactStatus = curContact.getStatus();
+		// Drawable avatar = getAvatarStatusDrawable(avatarId);
+		// img.setImageDrawable(avatar);
+		// img.setImageLevel(contactStatus);
+	    }
 	}
 
 	// @Override