# HG changeset patch # User Da Risk # Date 1273926973 -7200 # Node ID a91db9ddc46fff1bf74513819e84634f55adceee # Parent 106f089f8cde631ffb6cf3e7412d19424ffb3c5e Fixes a little bug in contactlist activity. Refactor and clean of some codes. refs #262 Check for translation needed. diff -r 106f089f8cde -r a91db9ddc46f res/layout/preferences.xml --- a/res/layout/preferences.xml Mon May 10 20:13:12 2010 +0200 +++ b/res/layout/preferences.xml Sat May 15 14:36:13 2010 +0200 @@ -25,11 +25,11 @@ android:hint="@string/away_message_hint" /> - + diff -r 106f089f8cde -r a91db9ddc46f res/values-de/strings.xml --- a/res/values-de/strings.xml Mon May 10 20:13:12 2010 +0200 +++ b/res/values-de/strings.xml Sat May 15 14:36:13 2010 +0200 @@ -21,11 +21,6 @@ Beem Service erstellt Beem Service verworfen - - Status - status_text - preference_is_configured - Server Verbindung Benutzer id: @@ -122,8 +117,8 @@ Angezeigte Abwesendheitsnachricht Ich bin abwesend, mein Telefonbildschirm ist aus Benachrichtigungseinstellungen - Vibrieren - Deaktivieren Sie vibriert bei eingehenden Nachrichten + Vibrieren + Aktivieren Sie vibriert bei eingehenden Nachrichten Nachrichtensignalton Lege den Signalton für eingehende Nachrichten fest diff -r 106f089f8cde -r a91db9ddc46f res/values-fr/strings.xml --- a/res/values-fr/strings.xml Mon May 10 20:13:12 2010 +0200 +++ b/res/values-fr/strings.xml Sat May 15 14:36:13 2010 +0200 @@ -119,8 +119,8 @@ Votre Message d\'absence Je suis absent car mon ecran est éteind Paramètres des notifications - Vibreur - Désactiver le vibreur pour les messages entrants + Activer le vibreur + Activer le vibreur pour les messages entrants Sonnerie des messages Configurer la sonnerie des messages entrants diff -r 106f089f8cde -r a91db9ddc46f res/values-ru/strings.xml --- a/res/values-ru/strings.xml Mon May 10 20:13:12 2010 +0200 +++ b/res/values-ru/strings.xml Sat May 15 14:36:13 2010 +0200 @@ -21,12 +21,6 @@ - -Статус - -preference_is_configured - - Соединение Имя пользователя: @@ -125,8 +119,8 @@ Настройка оповещений -Вибрация -Отключить вибрировать на входящие сообщения +Вибрация +Активировать вибрировать на входящие сообщения Сигнал сообщений diff -r 106f089f8cde -r a91db9ddc46f res/values/strings.xml --- a/res/values/strings.xml Mon May 10 20:13:12 2010 +0200 +++ b/res/values/strings.xml Sat May 15 14:36:13 2010 +0200 @@ -119,8 +119,8 @@ The away message that will be displayed I\'m away, my cellphone screen is off Notification settings - Vibrate - Disable vibrate on incoming messages + Enable vibrate + Enable vibrate on incoming messages Message ringtone Set your incoming message ringtone diff -r 106f089f8cde -r a91db9ddc46f src/com/beem/project/beem/BeemApplication.java --- a/src/com/beem/project/beem/BeemApplication.java Mon May 10 20:13:12 2010 +0200 +++ b/src/com/beem/project/beem/BeemApplication.java Sat May 15 14:36:13 2010 +0200 @@ -79,6 +79,11 @@ public static final String PROXY_USERNAME_KEY = "proxy_username"; /** Preference key for the proxy password */ public static final String PROXY_PASSWORD_KEY = "proxy_password"; + /** Preference key for vibrate on notification */ + public static final String NOTIFICATION_VIBRATE_KEY = "notification_vibrate"; + /** Preference key for notification sound */ + public static final String NOTIFICATION_SOUND_KEY = "notification_sound"; + //TODO add the other one private boolean mIsConnected; diff -r 106f089f8cde -r a91db9ddc46f src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Mon May 10 20:13:12 2010 +0200 +++ b/src/com/beem/project/beem/BeemService.java Sat May 15 14:36:13 2010 +0200 @@ -64,6 +64,7 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.net.ConnectivityManager; +import android.net.Uri; import android.os.IBinder; import android.os.RemoteException; import android.preference.PreferenceManager; @@ -163,7 +164,6 @@ public boolean onUnbind(Intent intent) { Log.d(TAG, "ONUNBIND()"); if (!mConnection.getAdaptee().isConnected()) { - Log.d(TAG, "DESTROYED"); this.stopSelf(); } return true; @@ -220,7 +220,6 @@ @Override public void onDestroy() { super.onDestroy(); - Log.d("Service", "onDestroy"); resetStatus(); mNotificationManager.cancelAll(); unregisterReceiver(mReceiver); @@ -247,11 +246,16 @@ } /** - * Show a notification. + * Show a notification using the preference of the user. * @param id the id of the notification. * @param notif the notification to show */ public void sendNotification(int id, Notification notif) { + if (mSettings.getBoolean(BeemApplication.NOTIFICATION_VIBRATE_KEY, true)) + notif.defaults |= Notification.DEFAULT_VIBRATE; + notif.defaults |= Notification.DEFAULT_LIGHTS; + String ringtoneStr = mSettings.getString(BeemApplication.NOTIFICATION_SOUND_KEY, ""); + notif.sound = Uri.parse(ringtoneStr); mNotificationManager.notify(id, notif); } diff -r 106f089f8cde -r a91db9ddc46f src/com/beem/project/beem/service/BeemChatManager.java --- a/src/com/beem/project/beem/service/BeemChatManager.java Mon May 10 20:13:12 2010 +0200 +++ b/src/com/beem/project/beem/service/BeemChatManager.java Sat May 15 14:36:13 2010 +0200 @@ -75,8 +75,8 @@ * @author darisk */ public class BeemChatManager extends IChatManager.Stub { - /** Tag to use with log methods. */ - public static final String TAG = "BeemChatManager"; + + private static final String TAG = "BeemChatManager"; private final ChatManager mAdaptee; private final Map mChats = new HashMap(); private final ChatListener mChatListener = new ChatListener(); @@ -95,9 +95,6 @@ mAdaptee.addChatListener(mChatListener); } - /** - * {@inheritDoc} - */ @Override public void addChatCreationListener(IChatManagerListener listener) throws RemoteException { if (listener != null) @@ -258,7 +255,7 @@ */ private PendingIntent makeChatIntent(IChat chat) { Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class); - chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); + chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); try { chatIntent.setData(chat.getParticipant().toUri()); } catch (RemoteException e) { @@ -280,13 +277,9 @@ .getName(); Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System .currentTimeMillis()); - if (!pref.getBoolean("settings_notification_disable_vibrate", true)) - notification.defaults -= Notification.DEFAULT_VIBRATE; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.setLatestEventInfo(mService, tickerText, mService .getString(R.string.BeemChatManagerNewMessage), makeChatIntent(chat)); - String ringtoneStr = pref.getString("settings_notification_snd", ""); - notification.sound = Uri.parse(ringtoneStr); mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification); } catch (RemoteException e) { Log.e(TAG, e.getMessage()); diff -r 106f089f8cde -r a91db9ddc46f src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Mon May 10 20:13:12 2010 +0200 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Sat May 15 14:36:13 2010 +0200 @@ -112,20 +112,6 @@ Log.e(TAG, "Error while adding new contact", e); return null; } - if (groups != null) { - for (String groupStr : groups) { - RosterGroup group = mAdaptee.getGroup(groupStr); - if (group == null) { - group = mAdaptee.createGroup(groupStr); - } - try { - group.addEntry(contact); - } catch (XMPPException e) { - e.printStackTrace(); - return null; - } - } - } return getContactFromRosterEntry(contact); } @@ -147,11 +133,8 @@ */ @Override public void createGroup(String groupname) throws RemoteException { - try { + if (mAdaptee.getGroup(groupname) == null) mAdaptee.createGroup(groupname); - } catch (IllegalArgumentException e) { - Log.v(TAG, "Error while creating group", e); - } } /** @@ -170,16 +153,9 @@ @Override public List getContactList() throws RemoteException { boolean add = true; - List coList = new ArrayList(mAdaptee.getEntries().size()); - for (RosterEntry entry : mAdaptee.getEntries()) { - for (Contact c : coList) { - if (c.getJID().equals(entry.getUser())) { - add = false; - break; - } - } - // Because getEntries return duplicated user. - if (add) + Collection list = mAdaptee.getEntries(); + List coList = new ArrayList(list.size()); + for (RosterEntry entry : list) { coList.add(getContactFromRosterEntry(entry)); } return coList; diff -r 106f089f8cde -r a91db9ddc46f src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Mon May 10 20:13:12 2010 +0200 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sat May 15 14:36:13 2010 +0200 @@ -571,10 +571,10 @@ String from = packet.getFrom(); Notification notif = new Notification(android.R.drawable.stat_notify_more, mService.getString( R.string.AcceptContactRequest, from), System.currentTimeMillis()); - notif.defaults = Notification.DEFAULT_ALL; notif.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); - intent.putExtra("from", from); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + .putExtra("from", from); notif.setLatestEventInfo(mService, from, mService .getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); @@ -620,16 +620,11 @@ if (p.getType() != Presence.Type.subscribe) return; String from = p.getFrom(); - SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService); Notification notification = new Notification(android.R.drawable.stat_notify_more, mService.getString( R.string.AcceptContactRequest, from), System.currentTimeMillis()); - if (!pref.getBoolean("settings_notification_disable_vibrate", true)) - notification.defaults -= Notification.DEFAULT_VIBRATE; notification.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); intent.putExtra("from", from); - String ringtoneStr = pref.getString("settings_notification_snd", ""); - notification.sound = Uri.parse(ringtoneStr); notification.setLatestEventInfo(mService, from, mService .getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); diff -r 106f089f8cde -r a91db9ddc46f src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Mon May 10 20:13:12 2010 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Sat May 15 14:36:13 2010 +0200 @@ -127,6 +127,7 @@ private IXmppFacade mXmppFacade; private SharedPreferences mSettings; private LayoutInflater mInflater; + private boolean mBinded; /** * Constructor. @@ -289,8 +290,10 @@ @Override protected void onResume() { super.onResume(); - if (mXmppFacade == null) - bindService(SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); + if (!mBinded) { + mBinded = bindService(SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); + Log.d(TAG, "on resume bind = " + mBinded); + } else { if (!mSettings.getBoolean("settings_key_hide_groups", false)) buildBanner(); @@ -314,7 +317,10 @@ } catch (RemoteException e) { Log.d("ContactList", "Remote exception", e); } - unbindService(mServConn); + if (mBinded) { + unbindService(mServConn); + mBinded = false; + } mXmppFacade = null; }