# HG changeset patch # User Da Risk # Date 1274386667 -7200 # Node ID 5ec323334955c69fc7b650eceb6ba924a0ecbce6 # Parent ebc57b51acf2b74bf4ad32143e90455588c9652d# Parent 93afbe80ec1a26ad4c4364cfbab921420dbb868a merge diff -r 93afbe80ec1a -r 5ec323334955 doc/asmack-beem/beem-build-process.patch --- a/doc/asmack-beem/beem-build-process.patch Wed May 19 15:22:38 2010 +0200 +++ b/doc/asmack-beem/beem-build-process.patch Thu May 20 22:17:47 2010 +0200 @@ -1,5 +1,5 @@ ---- asmack-org/build.bash 2010-03-05 02:42:58.978546820 +0100 -+++ asmack/build.bash 2010-03-05 02:35:43.689307349 +0100 +--- asmack-git/build.bash 2010-05-07 22:08:18.000000000 +0200 ++++ asmack/build.bash 2010-05-07 22:06:53.000000000 +0200 @@ -15,11 +15,11 @@ if ! [ -f "${2}/.svn/entries" ]; then mkdir "${2}" @@ -20,83 +20,14 @@ fetchall() { - gitfetch "git://github.com/rtreffer/smack.git" "smack" - fetch "http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/management/common/src/main/" "qpid" -- fetch "http://svn.apache.org/repos/asf/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/" "harmony" +- fetch "http://svn.apache.org/repos/asf/harmony/enhanced/java/trunk/classlib/modules/auth/src/main/java/common/" "harmony" - fetch "https://dnsjava.svn.sourceforge.net/svnroot/dnsjava/trunk" "dnsjava" - fetch "https://kenai.com/svn/jbosh~main/trunk/jbosh/src/main/java" "jbosh" + fetch "http://svn.igniterealtime.org/svn/repos/smack/trunk" "smack" "11644" + fetch "http://svn.apache.org/repos/asf/qpid/trunk/qpid/java/management/common/src/main/" "qpid" "HEAD" -+ fetch "http://svn.apache.org/repos/asf/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/" "harmony" "HEAD" ++ fetch "http://svn.apache.org/repos/asf/harmony/enhanced/java/trunk/classlib/modules/auth/src/main/java/common/" "harmony" "HEAD" + fetch "https://dnsjava.svn.sourceforge.net/svnroot/dnsjava/trunk" "dnsjava" "HEAD" + fetch "https://kenai.com/svn/jbosh~main/trunk/jbosh/src/main/java" "jbosh" "HEAD" } copyfolder() { -@@ -95,7 +95,7 @@ - buildsrc - patchsrc "patch" - patchsrc "${dir}" -- ant -Djar.suffix=`echo ${dir}|sed 's:patch/:-:'` -+ ant -Dbuild.all=true -Djar.suffix=`echo ${dir}|sed 's:patch/:-:'` - done - } - ---- asmack3/build.xml 2010-02-24 16:09:39.000000000 +0100 -+++ asmack-org/build.xml 2010-02-24 00:18:40.000000000 +0100 -@@ -36,6 +36,13 @@ - - - -+ -+ -+ -+ -+ -+ -+ - - - -@@ -65,6 +72,34 @@ - /> - - -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - - -@@ -208,7 +243,7 @@ - - - diff -r 93afbe80ec1a -r 5ec323334955 res/layout/preferences.xml --- a/res/layout/preferences.xml Wed May 19 15:22:38 2010 +0200 +++ b/res/layout/preferences.xml Thu May 20 22:17:47 2010 +0200 @@ -25,11 +25,11 @@ android:hint="@string/away_message_hint" /> - + @@ -56,31 +56,31 @@ android:summary="@string/settings_proxy_sum"> + android:key="proxy_use" /> - + android:key="proxy_type" /> + android:key="proxy_server" /> + android:key="proxy_port" android:numeric="signed" android:hint="@string/comments_proxy_port" /> + android:key="proxy_username" /> + android:title="@string/settings_proxy_password" android:key="proxy_password" /> 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 93afbe80ec1a -r 5ec323334955 res/values-fr/strings.xml --- a/res/values-fr/strings.xml Wed May 19 15:22:38 2010 +0200 +++ b/res/values-fr/strings.xml Thu May 20 22:17:47 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 93afbe80ec1a -r 5ec323334955 res/values-ru/strings.xml --- a/res/values-ru/strings.xml Wed May 19 15:22:38 2010 +0200 +++ b/res/values-ru/strings.xml Thu May 20 22:17:47 2010 +0200 @@ -21,12 +21,6 @@ - -Статус - -preference_is_configured - - Соединение Имя пользователя: @@ -125,8 +119,8 @@ Настройка оповещений -Вибрация -Отключить вибрировать на входящие сообщения +Вибрация +Активировать вибрировать на входящие сообщения Сигнал сообщений diff -r 93afbe80ec1a -r 5ec323334955 res/values/strings.xml --- a/res/values/strings.xml Wed May 19 15:22:38 2010 +0200 +++ b/res/values/strings.xml Thu May 20 22:17:47 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 93afbe80ec1a -r 5ec323334955 src/com/beem/project/beem/BeemApplication.java --- a/src/com/beem/project/beem/BeemApplication.java Wed May 19 15:22:38 2010 +0200 +++ b/src/com/beem/project/beem/BeemApplication.java Thu May 20 22:17:47 2010 +0200 @@ -67,6 +67,23 @@ public static final String STATUS_KEY = "status"; /** Preference key for status message. */ public static final String STATUS_TEXT_KEY = "status_text"; + /** Preference key for the use of a proxy */ + public static final String PROXY_USE_KEY = "proxy_use"; + /** Preference key for the type of proxy */ + public static final String PROXY_TYPE_KEY = "proxy_type"; + /** Preference key for the proxy server */ + public static final String PROXY_SERVER_KEY = "proxy_server"; + /** Preference key for the proxy port */ + public static final String PROXY_PORT_KEY = "proxy_port"; + /** Preference key for the proxy username */ + 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 93afbe80ec1a -r 5ec323334955 src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Wed May 19 15:22:38 2010 +0200 +++ b/src/com/beem/project/beem/BeemService.java Thu May 20 22:17:47 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; @@ -77,7 +78,9 @@ import com.beem.project.beem.utils.Status; /** - * This class is for the Beem service. The connection to the xmpp server will be made asynchronously when the service + * This class is for the Beem service. + * It must contains every global informations needed to maintain the background service. + * The connection to the xmpp server will be made asynchronously when the service * will start. * @author darisk */ @@ -119,13 +122,13 @@ * Initialize the connection. */ private void initConnectionConfig() { - mUseProxy = mSettings.getBoolean("settings_key_proxy_use", false); + mUseProxy = mSettings.getBoolean(BeemApplication.PROXY_USE_KEY, false); if (mUseProxy) { - String stype = mSettings.getString("settings_key_proxy_type", "HTTP"); - String phost = mSettings.getString("settings_key_proxy_server", ""); - String puser = mSettings.getString("settings_key_proxy_username", ""); - String ppass = mSettings.getString("settings_key_proxy_password", ""); - int pport = Integer.parseInt(mSettings.getString("settings_key_proxy_port", "1080")); + String stype = mSettings.getString(BeemApplication.PROXY_TYPE_KEY, "HTTP"); + String phost = mSettings.getString(BeemApplication.PROXY_SERVER_KEY, ""); + String puser = mSettings.getString(BeemApplication.PROXY_USERNAME_KEY, ""); + String ppass = mSettings.getString(BeemApplication.PROXY_PASSWORD_KEY, ""); + int pport = Integer.parseInt(mSettings.getString(BeemApplication.PROXY_PORT_KEY, "1080")); ProxyInfo.ProxyType type = ProxyType.valueOf(stype); mProxyInfo = new ProxyInfo(type, phost, pport, puser, ppass); } else { @@ -156,21 +159,16 @@ return mBind; } - /* (non-Javadoc) - * @see android.app.Service#onUnbind(android.content.Intent) - */ @Override public boolean onUnbind(Intent intent) { Log.d(TAG, "ONUNBIND()"); if (!mConnection.getAdaptee().isConnected()) { - Log.d(TAG, "DESTROYED"); this.stopSelf(); } return true; } - /** * {@inheritDoc} */ @@ -220,7 +218,6 @@ @Override public void onDestroy() { super.onDestroy(); - Log.d("Service", "onDestroy"); resetStatus(); mNotificationManager.cancelAll(); unregisterReceiver(mReceiver); @@ -247,11 +244,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); } @@ -397,9 +399,6 @@ public BeemServicePreferenceListener() { } - /** - * {@inheritDoc} - */ @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if ("settings_away_chk".equals(key)) { @@ -424,14 +423,11 @@ private int mOldMode; /** - * ctor. + * Constructor. */ public BeemServiceBroadcastReceiver() { } - /** - * {@inheritDoc} - */ @Override public void onReceive(final Context context, final Intent intent) { String intentAction = intent.getAction(); diff -r 93afbe80ec1a -r 5ec323334955 src/com/beem/project/beem/service/BeemChatManager.java --- a/src/com/beem/project/beem/service/BeemChatManager.java Wed May 19 15:22:38 2010 +0200 +++ b/src/com/beem/project/beem/service/BeemChatManager.java Thu May 20 22:17:47 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 93afbe80ec1a -r 5ec323334955 src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Wed May 19 15:22:38 2010 +0200 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Thu May 20 22:17:47 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 93afbe80ec1a -r 5ec323334955 src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Wed May 19 15:22:38 2010 +0200 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu May 20 22:17:47 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 93afbe80ec1a -r 5ec323334955 src/com/beem/project/beem/ui/Chat.java --- a/src/com/beem/project/beem/ui/Chat.java Wed May 19 15:22:38 2010 +0200 +++ b/src/com/beem/project/beem/ui/Chat.java Thu May 20 22:17:47 2010 +0200 @@ -133,6 +133,7 @@ private final BeemBroadcastReceiver mBroadcastReceiver = new BeemBroadcastReceiver(); private final BeemRosterListener mBeemRosterListener = new BeemRosterListener(); private IXmppFacade mXmppFacade; + private boolean mBinded; /** * Constructor. @@ -174,8 +175,10 @@ protected void onResume() { super.onResume(); mContact = new Contact(getIntent().getData()); - if (mXmppFacade == null) + if (!mBinded) { bindService(SERVICE_INTENT, mConn, BIND_AUTO_CREATE); + mBinded = true; + } } /** @@ -205,8 +208,10 @@ } catch (RemoteException e) { Log.e(TAG, e.getMessage()); } - if (mXmppFacade != null) + if (mBinded) { unbindService(mConn); + mBinded = false; + } mXmppFacade = null; mRoster = null; mChat = null; diff -r 93afbe80ec1a -r 5ec323334955 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Wed May 19 15:22:38 2010 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Thu May 20 22:17:47 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; } diff -r 93afbe80ec1a -r 5ec323334955 src/com/beem/project/beem/ui/CreateAccount.java --- a/src/com/beem/project/beem/ui/CreateAccount.java Wed May 19 15:22:38 2010 +0200 +++ b/src/com/beem/project/beem/ui/CreateAccount.java Thu May 20 22:17:47 2010 +0200 @@ -172,7 +172,7 @@ * @return Registered proxy password */ private String getRegisteredProxyPassword() { - return mSettings.getString("settings_key_proxy_password", DEFAULT_STRING_VALUE); + return mSettings.getString(BeemApplication.PROXY_PASSWORD_KEY, DEFAULT_STRING_VALUE); } /** @@ -180,7 +180,7 @@ * @return Registered proxy port */ private int getRegisteredProxyPort() { - return Integer.parseInt(mSettings.getString("settings_key_proxy_port", DEFAULT_STRING_VALUE)); + return Integer.parseInt(mSettings.getString(BeemApplication.PROXY_PORT_KEY, DEFAULT_STRING_VALUE)); } /** @@ -188,7 +188,7 @@ * @return Registered proxy server */ private String getRegisteredProxyServer() { - return mSettings.getString("settings_key_proxy_server", DEFAULT_STRING_VALUE); + return mSettings.getString(BeemApplication.PROXY_SERVER_KEY, DEFAULT_STRING_VALUE); } /** @@ -197,8 +197,8 @@ */ private ProxyInfo.ProxyType getRegisteredProxyType() { ProxyInfo.ProxyType result = ProxyInfo.ProxyType.NONE; - if (mSettings.getBoolean("settings_key_proxy_use", false)) { - String type = mSettings.getString("settings_key_proxy_type", "none"); + if (mSettings.getBoolean(BeemApplication.PROXY_USE_KEY, false)) { + String type = mSettings.getString(BeemApplication.PROXY_TYPE_KEY, "none"); if ("HTTP".equals(type)) result = ProxyInfo.ProxyType.HTTP; else if ("SOCKS4".equals(type)) @@ -216,7 +216,7 @@ * @return Registered proxy use */ private boolean getRegisteredProxyUse() { - return mSettings.getBoolean("settings_key_proxy_use", DEFAULT_BOOLEAN_VALUE); + return mSettings.getBoolean(BeemApplication.PROXY_USE_KEY, DEFAULT_BOOLEAN_VALUE); } /** @@ -224,7 +224,7 @@ * @return Registered proxy username */ private String getRegisteredProxyUsername() { - return mSettings.getString("settings_key_proxy_username", DEFAULT_STRING_VALUE); + return mSettings.getString(BeemApplication.PROXY_USERNAME_KEY, DEFAULT_STRING_VALUE); } /**