# HG changeset patch # User Da Risk # Date 1303603115 -7200 # Node ID 7b5e29b3603b261b0b98c32707cc71831084fb68 # Parent 5315a5713dd55776d1d6027bfbda6181e8b0c253 Move some preferences key diff -r 5315a5713dd5 -r 7b5e29b3603b res/layout/preferences.xml --- a/res/layout/preferences.xml Thu Mar 31 22:42:14 2011 +0200 +++ b/res/layout/preferences.xml Sun Apr 24 01:58:35 2011 +0200 @@ -12,16 +12,16 @@ android:title="@string/contact_list_preferences" android:summary="@string/contact_list_preferences_sum"> + android:key="show_offline_contacts" /> + android:key="hide_groups" /> - + + android:key="use_compact_chat_ui" /> @@ -60,10 +60,10 @@ android:title="@string/settings_account_password" android:key="account_password" /> - - diff -r 5315a5713dd5 -r 7b5e29b3603b src/com/beem/project/beem/BeemApplication.java --- a/src/com/beem/project/beem/BeemApplication.java Thu Mar 31 22:42:14 2011 +0200 +++ b/src/com/beem/project/beem/BeemApplication.java Sun Apr 24 01:58:35 2011 +0200 @@ -67,6 +67,10 @@ public static final String STATUS_KEY = "status"; /** Preference key for status message. */ public static final String STATUS_TEXT_KEY = "status_text"; + /** Preference key for connection resource . */ + public static final String CONNECTION_RESOURCE_KEY = "connection_resource"; + /** Preference key for connection priority. */ + public static final String CONNECTION_PRIORITY_KEY = "connection_priority"; /** Preference key for the use of a proxy. */ public static final String PROXY_USE_KEY = "proxy_use"; /** Preference key for the type of proxy. */ @@ -87,6 +91,16 @@ public static final String SMACK_DEBUG_KEY = "smack_debug"; /** Preference key for full Jid for login. */ public static final String FULL_JID_LOGIN_KEY = "full_jid_login"; + /** Preference key for display offline contact. */ + public static final String SHOW_OFFLINE_CONTACTS_KEY = "show_offline_contacts"; + /** Preference key for hide the groups. */ + public static final String HIDE_GROUPS_KEY = "hide_groups"; + /** Preference key for auto away enable. */ + public static final String USE_AUTO_AWAY_KEY = "use_auto_away"; + /** Preference key for auto away message. */ + public static final String AUTO_AWAY_MSG_KEY = "auto_away_msg"; + /** Preference key for compact chat ui. */ + public static final String USE_COMPACT_CHAT_UI_KEY = "use_compact_chat_ui"; /** Preference key for history path on the SDCard. */ public static final String CHAT_HISTORY_KEY = "settings_chat_history_path"; diff -r 5315a5713dd5 -r 7b5e29b3603b src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Thu Mar 31 22:42:14 2011 +0200 +++ b/src/com/beem/project/beem/BeemService.java Sun Apr 24 01:58:35 2011 +0200 @@ -75,6 +75,7 @@ import android.os.IBinder; import android.os.RemoteException; import android.preference.PreferenceManager; +import android.provider.Settings; import android.util.Log; import com.beem.project.beem.service.XmppConnectionAdapter; @@ -191,7 +192,7 @@ registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); mSettings = PreferenceManager.getDefaultSharedPreferences(this); mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener); - if (mSettings.getBoolean("settings_away_chk", false)) { + if (mSettings.getBoolean(BeemApplication.USE_AUTO_AWAY_KEY, false)) { mOnOffReceiverIsRegistered = true; registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); @@ -224,7 +225,7 @@ Roster.setDefaultSubscriptionMode(SubscriptionMode.manual); mBind = new XmppFacade(mConnection); - Log.d(TAG, "ONCREATE"); + Log.d(TAG, "Create BeemService"); } /** @@ -240,7 +241,7 @@ unregisterReceiver(mOnOffReceiver); if (mConnection.isAuthentificated() && BeemConnectivity.isConnected(this)) mConnection.disconnect(); - Log.d(TAG, "ONDESTROY"); + Log.i(TAG, "Stopping the service"); } /** @@ -266,7 +267,7 @@ 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, ""); + String ringtoneStr = mSettings.getString(BeemApplication.NOTIFICATION_SOUND_KEY, Settings.System.DEFAULT_NOTIFICATION_URI.toString()); notif.sound = Uri.parse(ringtoneStr); mNotificationManager.notify(id, notif); } @@ -454,8 +455,8 @@ @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { - if ("settings_away_chk".equals(key)) { - if (sharedPreferences.getBoolean("settings_away_chk", false)) { + if (BeemApplication.USE_AUTO_AWAY_KEY.equals(key)) { + if (sharedPreferences.getBoolean(BeemApplication.USE_AUTO_AWAY_KEY, false)) { mOnOffReceiverIsRegistered = true; registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); @@ -489,7 +490,7 @@ mOldStatus = mConnection.getPreviousStatus(); if (mConnection.isAuthentificated()) mConnection.changeStatus(Status.CONTACT_STATUS_AWAY, - mSettings.getString("settings_away_message", "Away")); + mSettings.getString(BeemApplication.AUTO_AWAY_MSG_KEY, "Away")); } else if (intentAction.equals(Intent.ACTION_SCREEN_ON)) { if (mConnection.isAuthentificated()) mConnection.changeStatus(mOldMode, mOldStatus); diff -r 5315a5713dd5 -r 7b5e29b3603b src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Mar 31 22:42:14 2011 +0200 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sun Apr 24 01:58:35 2011 +0200 @@ -169,11 +169,11 @@ } mPref = mService.getServicePreference(); try { - mPreviousPriority = Integer.parseInt(mPref.getString("settings_key_priority", "0")); + mPreviousPriority = Integer.parseInt(mPref.getString(BeemApplication.CONNECTION_PRIORITY_KEY, "0")); } catch (NumberFormatException ex) { mPreviousPriority = 0; } - mResource = mPref.getString("settings_key_resource", "BEEM"); + mResource = mPref.getString(BeemApplication.CONNECTION_RESOURCE_KEY, "Beem"); } /** diff -r 5315a5713dd5 -r 7b5e29b3603b src/com/beem/project/beem/ui/Chat.java --- a/src/com/beem/project/beem/ui/Chat.java Thu Mar 31 22:42:14 2011 +0200 +++ b/src/com/beem/project/beem/ui/Chat.java Sun Apr 24 01:58:35 2011 +0200 @@ -93,6 +93,7 @@ import com.beem.project.beem.R; +import com.beem.project.beem.BeemApplication; import com.beem.project.beem.providers.AvatarProvider; import com.beem.project.beem.service.Contact; import com.beem.project.beem.service.Message; @@ -165,7 +166,7 @@ super.onCreate(savedBundle); this.registerReceiver(mBroadcastReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); - mCompact = settings.getBoolean("settings_chat_compact_key", false); + mCompact = settings.getBoolean(BeemApplication.USE_COMPACT_CHAT_UI_KEY, false); // UI if (!mCompact) { setContentView(R.layout.chat); diff -r 5315a5713dd5 -r 7b5e29b3603b src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Thu Mar 31 22:42:14 2011 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Sun Apr 24 01:58:35 2011 +0200 @@ -91,6 +91,7 @@ import android.graphics.drawable.LayerDrawable; import com.beem.project.beem.R; +import com.beem.project.beem.BeemApplication; import com.beem.project.beem.providers.AvatarProvider; import com.beem.project.beem.service.Contact; import com.beem.project.beem.service.PresenceAdapter; @@ -116,7 +117,6 @@ SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); } - private static final String SETTINGS_HIDDEN_CONTACT = "settings_key_hidden_contact"; private static final String TAG = "ContactList"; private final BeemContactList mAdapterContactList = new BeemContactList(); private final List mListGroup = new ArrayList(); @@ -386,7 +386,7 @@ */ @Override public void onEntriesAdded(final List addresses) throws RemoteException { - final boolean hideDisconnected = mSettings.getBoolean(SETTINGS_HIDDEN_CONTACT, false); + final boolean hideDisconnected = mSettings.getBoolean(BeemApplication.SHOW_OFFLINE_CONTACTS_KEY, false); for (String newName : addresses) { Contact contact = mRoster.getContact(newName); boolean visible = !hideDisconnected || Status.statusOnline(contact.getStatus()); @@ -457,7 +457,7 @@ */ @Override public void onEntriesUpdated(final List addresses) throws RemoteException { - final boolean hideDisconnected = mSettings.getBoolean(SETTINGS_HIDDEN_CONTACT, false); + final boolean hideDisconnected = mSettings.getBoolean(BeemApplication.SHOW_OFFLINE_CONTACTS_KEY, false); for (String adr : addresses) { Contact contact = mRoster.getContact(adr); boolean visible = !hideDisconnected || Status.statusOnline(contact.getStatus()); @@ -504,7 +504,7 @@ public void onPresenceChanged(PresenceAdapter presence) throws RemoteException { Log.d(TAG, "presence"); String from = presence.getFrom(); - final boolean hideDisconnected = mSettings.getBoolean(SETTINGS_HIDDEN_CONTACT, false); + final boolean hideDisconnected = mSettings.getBoolean(BeemApplication.SHOW_OFFLINE_CONTACTS_KEY, false); final Contact contact = mRoster.getContact(StringUtils.parseBareAddress(from)); boolean visible = !hideDisconnected || Status.statusOnline(contact.getStatus()); List groups = contact.getGroups(); @@ -552,7 +552,7 @@ * @param contact contact to update */ private void updateCurrentList(String listName, final Contact contact) { - final boolean hideDisconnected = mSettings.getBoolean(SETTINGS_HIDDEN_CONTACT, false); + final boolean hideDisconnected = mSettings.getBoolean(BeemApplication.SHOW_OFFLINE_CONTACTS_KEY, false); final List groups = contact.getGroups(); String noGroup = getString(R.string.contact_list_no_group); String allGroup = getString(R.string.contact_list_all_contact); @@ -807,7 +807,7 @@ mListGroup.add(getString(R.string.contact_list_no_group)); assignContactToGroups(mRoster.getContactList(), tmpGroupList); makeSortedList(mContactOnGroup); - if (!mSettings.getBoolean("settings_key_hide_groups", false)) + if (!mSettings.getBoolean(BeemApplication.HIDE_GROUPS_KEY, false)) showGroups(); else hideGroups(); @@ -846,7 +846,7 @@ * @param groupNames list of existing groups */ private void assignContactToGroups(List contacts, List groupNames) { - boolean hideDisconnected = mSettings.getBoolean(SETTINGS_HIDDEN_CONTACT, false); + boolean hideDisconnected = mSettings.getBoolean(BeemApplication.SHOW_OFFLINE_CONTACTS_KEY, false); mContactOnGroup.clear(); List all = new LinkedList(); List noGroups = new LinkedList();