diff --git a/art/ic_action_send_now.svg b/art/ic_action_send_now.svg new file mode 100644 index 00000000..6bde9158 --- /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 ff0e369e..00000000 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 00000000..505cbe63 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 00000000..a376524d 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 00000000..d4d2d510 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 00000000..48676f7b 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 00000000..0fdca901 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 00000000..c0aef36c 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 00000000..7723f4aa 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 00000000..39d00ee4 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 373dde23..00000000 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 00000000..bb999d85 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 00000000..a0bf5561 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 00000000..6da9ff7b 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 00000000..348ba657 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 00000000..12ec4d33 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 00000000..7719f81a 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 00000000..18895813 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 00000000..29bde36e 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 b16e4113..91921fb5 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 f0d64e39..47508c9e 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 b73bcadb..c6b129ad 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) {