diff --git a/art/ic_action_send_now.svg b/art/ic_action_send_now.svg new file mode 100644 index 0000000000000000000000000000000000000000..6bde9158fad2bea9936de7738701af2ca5d6b696 --- /dev/null +++ b/art/ic_action_send_now.svg @@ -0,0 +1,69 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/res/drawable-hdpi/ic_action_send_now.png b/res/drawable-hdpi/ic_action_send_now.png deleted file mode 100644 index ff0e369ee4e77c759668f484b413bd8bbadabd7e..0000000000000000000000000000000000000000 Binary files a/res/drawable-hdpi/ic_action_send_now.png and /dev/null differ diff --git a/res/drawable-hdpi/ic_action_send_now_away.png b/res/drawable-hdpi/ic_action_send_now_away.png new file mode 100644 index 0000000000000000000000000000000000000000..505cbe63abc1a4af6e3dd2eef57a82e53edd0e60 Binary files /dev/null and b/res/drawable-hdpi/ic_action_send_now_away.png differ diff --git a/res/drawable-hdpi/ic_action_send_now_dnd.png b/res/drawable-hdpi/ic_action_send_now_dnd.png new file mode 100644 index 0000000000000000000000000000000000000000..a376524d76e2bef02443ca4603222906203063d6 Binary files /dev/null and b/res/drawable-hdpi/ic_action_send_now_dnd.png differ diff --git a/res/drawable-hdpi/ic_action_send_now_offline.png b/res/drawable-hdpi/ic_action_send_now_offline.png new file mode 100644 index 0000000000000000000000000000000000000000..d4d2d5103000557b5c46fce4a6a2602436b747ab Binary files /dev/null and b/res/drawable-hdpi/ic_action_send_now_offline.png differ diff --git a/res/drawable-hdpi/ic_action_send_now_online.png b/res/drawable-hdpi/ic_action_send_now_online.png new file mode 100644 index 0000000000000000000000000000000000000000..48676f7bdfd6584d541b65a8d9768703f483e953 Binary files /dev/null and b/res/drawable-hdpi/ic_action_send_now_online.png differ diff --git a/res/drawable-mdpi/ic_action_send_now_away.png b/res/drawable-mdpi/ic_action_send_now_away.png new file mode 100644 index 0000000000000000000000000000000000000000..0fdca901a5d8443e450e352629fc618bab00be46 Binary files /dev/null and b/res/drawable-mdpi/ic_action_send_now_away.png differ diff --git a/res/drawable-mdpi/ic_action_send_now_dnd.png b/res/drawable-mdpi/ic_action_send_now_dnd.png new file mode 100644 index 0000000000000000000000000000000000000000..c0aef36ccb0a258d97aed7a967b18af587f358b1 Binary files /dev/null and b/res/drawable-mdpi/ic_action_send_now_dnd.png differ diff --git a/res/drawable-mdpi/ic_action_send_now_offline.png b/res/drawable-mdpi/ic_action_send_now_offline.png new file mode 100644 index 0000000000000000000000000000000000000000..7723f4aa94b7a5eec5fc5baf0ce02de7afebd030 Binary files /dev/null and b/res/drawable-mdpi/ic_action_send_now_offline.png differ diff --git a/res/drawable-mdpi/ic_action_send_now_online.png b/res/drawable-mdpi/ic_action_send_now_online.png new file mode 100644 index 0000000000000000000000000000000000000000..39d00ee482965004debc7e134f1ba96469487ff2 Binary files /dev/null and b/res/drawable-mdpi/ic_action_send_now_online.png differ diff --git a/res/drawable-xhdpi/ic_action_send_now.png b/res/drawable-xhdpi/ic_action_send_now.png deleted file mode 100644 index 373dde239e0ebd7e9935ae186473c955cfce9081..0000000000000000000000000000000000000000 Binary files a/res/drawable-xhdpi/ic_action_send_now.png and /dev/null differ diff --git a/res/drawable-xhdpi/ic_action_send_now_away.png b/res/drawable-xhdpi/ic_action_send_now_away.png new file mode 100644 index 0000000000000000000000000000000000000000..bb999d85d4e128d988763034bd6735356693c388 Binary files /dev/null and b/res/drawable-xhdpi/ic_action_send_now_away.png differ diff --git a/res/drawable-xhdpi/ic_action_send_now_dnd.png b/res/drawable-xhdpi/ic_action_send_now_dnd.png new file mode 100644 index 0000000000000000000000000000000000000000..a0bf5561c76fd8479e3268eadd05a19962391656 Binary files /dev/null and b/res/drawable-xhdpi/ic_action_send_now_dnd.png differ diff --git a/res/drawable-xhdpi/ic_action_send_now_offline.png b/res/drawable-xhdpi/ic_action_send_now_offline.png new file mode 100644 index 0000000000000000000000000000000000000000..6da9ff7bd40abf3ffa2437cc91fa4ae1724dc695 Binary files /dev/null and b/res/drawable-xhdpi/ic_action_send_now_offline.png differ diff --git a/res/drawable-xhdpi/ic_action_send_now_online.png b/res/drawable-xhdpi/ic_action_send_now_online.png new file mode 100644 index 0000000000000000000000000000000000000000..348ba657d5efc149aa5f60c89e1a0241b226f77b Binary files /dev/null and b/res/drawable-xhdpi/ic_action_send_now_online.png differ diff --git a/res/drawable-xxhdpi/ic_action_send_now_away.png b/res/drawable-xxhdpi/ic_action_send_now_away.png new file mode 100644 index 0000000000000000000000000000000000000000..12ec4d33f19d18ef0bde48e635cdc671609bcee5 Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_send_now_away.png differ diff --git a/res/drawable-xxhdpi/ic_action_send_now_dnd.png b/res/drawable-xxhdpi/ic_action_send_now_dnd.png new file mode 100644 index 0000000000000000000000000000000000000000..7719f81a9a42aeae09dcd7d226ec6c241b6d6162 Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_send_now_dnd.png differ diff --git a/res/drawable-xxhdpi/ic_action_send_now_offline.png b/res/drawable-xxhdpi/ic_action_send_now_offline.png new file mode 100644 index 0000000000000000000000000000000000000000..1889581322980550b9d312e62980aed751d33286 Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_send_now_offline.png differ diff --git a/res/drawable-xxhdpi/ic_action_send_now_online.png b/res/drawable-xxhdpi/ic_action_send_now_online.png new file mode 100644 index 0000000000000000000000000000000000000000..29bde36e3f72c35ed863e3db4c780dab0ab0de0f Binary files /dev/null and b/res/drawable-xxhdpi/ic_action_send_now_online.png differ diff --git a/res/layout/fragment_conversation.xml b/res/layout/fragment_conversation.xml index b16e41132d323f87c06aa3cce4b5bed9bbd323c9..91921fb56043d29d185e340dcbbf282b4984c101 100644 --- a/res/layout/fragment_conversation.xml +++ b/res/layout/fragment_conversation.xml @@ -58,7 +58,7 @@ android:layout_alignParentRight="true" android:layout_centerVertical="true" android:background="?android:selectableItemBackground" - android:src="@drawable/ic_action_send_now" /> + android:src="@drawable/ic_action_send_now_offline" /> Please be very careful with those Increase font size Use larger font sizes across the entire app + Send button indicates status + Colorize send button to indicate a contacs status \ No newline at end of file diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index f0d64e39cc373b0dcc08c528ead73115ba071334..47508c9e235cbc226d729dc5f10a757db253587b 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -69,6 +69,11 @@ android:key="use_larger_font" android:title="@string/pref_use_larger_font" android:summary="@string/pref_use_larger_font_summary"/> + 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(); + } + }); + } } } diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index b73bcadbe317c7aad72d5759fe023029fcf69d32..c6b129ad7787894e1f8fb6b30237bb8ecbcab6eb 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -12,6 +12,7 @@ import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.MucOptions; +import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.EditMessage.OnEnterPressed; import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected; @@ -61,6 +62,7 @@ public class ConversationFragment extends Fragment { protected String queuedPqpMessage = null; private EditMessage mEditMessage; + private ImageButton mSendButton; private String pastedText = null; private RelativeLayout snackbar; private TextView snackbarMessage; @@ -255,9 +257,8 @@ public class ConversationFragment extends Fragment { } }); - ImageButton sendButton = (ImageButton) view - .findViewById(R.id.textSendButton); - sendButton.setOnClickListener(this.mSendButtonListener); + mSendButton = (ImageButton) view.findViewById(R.id.textSendButton); + mSendButton.setOnClickListener(this.mSendButtonListener); snackbar = (RelativeLayout) view.findViewById(R.id.snackbar); snackbarMessage = (TextView) view.findViewById(R.id.snackbar_message); @@ -485,6 +486,7 @@ public class ConversationFragment extends Fragment { activity.getConversationList(), null, false); activity.updateConversationList(); } + this.updateSendButton(); } } @@ -497,6 +499,51 @@ public class ConversationFragment extends Fragment { updateChatMsgHint(); } + public void updateSendButton() { + Conversation c = this.conversation; + if (activity.useSendButtonToIndicateStatus() && c != null + && c.getAccount().getStatus() == Account.STATUS_ONLINE) { + if (c.getMode() == Conversation.MODE_SINGLE) { + switch (c.getContact().getMostAvailableStatus()) { + case Presences.ONLINE: + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_online); + break; + case Presences.AWAY: + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_away); + break; + case Presences.XA: + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_away); + break; + case Presences.DND: + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_dnd); + break; + default: + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_offline); + break; + } + } else if (c.getMode() == Conversation.MODE_MULTI) { + if (c.getMucOptions().online()) { + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_online); + } else { + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_offline); + } + } else { + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_offline); + } + } else { + this.mSendButton + .setImageResource(R.drawable.ic_action_send_now_offline); + } + } + protected void updateStatusMessages() { if (conversation.getMode() == Conversation.MODE_SINGLE) { for (int i = this.messageList.size() - 1; i >= 0; --i) {