diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-09-10 17:59:57 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-09-10 17:59:57 +0200 |
commit | 31f11070e37636e9c47d74ad080c4786b14ff1b7 (patch) | |
tree | a784db787be53b14138f184aed6066a189575087 /src/eu/siacs/conversations/ui/ConversationActivity.java | |
parent | a6d4a9cda1684d9a316146de4c6797834f7b0121 (diff) |
IT'S CHRISTMAS ALREADY!
Diffstat (limited to 'src/eu/siacs/conversations/ui/ConversationActivity.java')
-rw-r--r-- | src/eu/siacs/conversations/ui/ConversationActivity.java | 104 |
1 files changed, 70 insertions, 34 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 5eedda1c..40ad0f33 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -7,7 +7,9 @@ import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; +import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate; import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate; +import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.ui.adapter.ConversationAdapter; import eu.siacs.conversations.utils.ExceptionHelper; import eu.siacs.conversations.utils.UIHelper; @@ -39,7 +41,8 @@ import android.widget.PopupMenu; import android.widget.PopupMenu.OnMenuItemClickListener; import android.widget.Toast; -public class ConversationActivity extends XmppActivity { +public class ConversationActivity extends XmppActivity implements + OnAccountUpdate, OnConversationUpdate, OnRosterUpdate { public static final String VIEW_CONVERSATION = "viewConversation"; public static final String CONVERSATION = "conversationUuid"; @@ -67,34 +70,6 @@ public class ConversationActivity extends XmppActivity { private boolean paneShouldBeOpen = true; private ArrayAdapter<Conversation> listAdapter; - private OnConversationUpdate onConvChanged = new OnConversationUpdate() { - - @Override - public void onConversationUpdate() { - runOnUiThread(new Runnable() { - - @Override - public void run() { - updateConversationList(); - if (paneShouldBeOpen) { - if (conversationList.size() >= 1) { - swapConversationFragment(); - } else { - startActivity(new Intent(getApplicationContext(), - StartConversationActivity.class)); - finish(); - } - } - ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager() - .findFragmentByTag("conversation"); - if (selectedFragment != null) { - selectedFragment.updateMessages(); - } - } - }); - } - }; - protected ConversationActivity activity = this; private Toast prepareImageToast; @@ -602,7 +577,7 @@ public class ConversationActivity extends XmppActivity { this.onBackendConnected(); } if (conversationList.size() >= 1) { - onConvChanged.onConversationUpdate(); + this.onConversationUpdate(); } } @@ -610,6 +585,8 @@ public class ConversationActivity extends XmppActivity { protected void onStop() { if (xmppConnectionServiceBound) { xmppConnectionService.removeOnConversationListChangedListener(); + xmppConnectionService.removeOnAccountListChangedListener(); + xmppConnectionService.removeOnRosterUpdateListener(); } super.onStop(); } @@ -672,8 +649,9 @@ public class ConversationActivity extends XmppActivity { public void registerListener() { if (xmppConnectionServiceBound) { - xmppConnectionService - .setOnConversationListChangedListener(this.onConvChanged); + xmppConnectionService.setOnConversationListChangedListener(this); + xmppConnectionService.setOnAccountListChangedListener(this); + xmppConnectionService.setOnRosterUpdateListener(this); } } @@ -806,7 +784,65 @@ public class ConversationActivity extends XmppActivity { } public boolean forceEncryption() { - return PreferenceManager.getDefaultSharedPreferences( - getApplicationContext()).getBoolean("force_encryption", false); + return getPreferences().getBoolean("force_encryption", false); + } + + public boolean useSendButtonToIndicateStatus() { + return getPreferences().getBoolean("send_button_status", false); + } + + @Override + public void onAccountUpdate() { + final ConversationFragment fragment = (ConversationFragment) getFragmentManager() + .findFragmentByTag("conversation"); + if (fragment != null) { + runOnUiThread(new Runnable() { + + @Override + public void run() { + fragment.updateMessages(); + } + }); + } + } + + @Override + public void onConversationUpdate() { + runOnUiThread(new Runnable() { + + @Override + public void run() { + updateConversationList(); + if (paneShouldBeOpen) { + if (conversationList.size() >= 1) { + swapConversationFragment(); + } else { + startActivity(new Intent(getApplicationContext(), + StartConversationActivity.class)); + finish(); + } + } + ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager() + .findFragmentByTag("conversation"); + if (selectedFragment != null) { + selectedFragment.updateMessages(); + } + } + }); + } + + @Override + public void onRosterUpdate() { + final ConversationFragment fragment = (ConversationFragment) getFragmentManager() + .findFragmentByTag("conversation"); + if (fragment != null) { + runOnUiThread(new Runnable() { + + @Override + public void run() { + fragment.updateMessages(); + } + }); + } } } |