From 43db9cdf4b300183cfd58ad9c7b3ad57ee63ad31 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 3 May 2015 09:30:30 +0200 Subject: turn send button in cancel button while in whisper mode --- art/ic_send_cancel_away.svg | 54 +++++++++++++++++++++ art/ic_send_cancel_dnd.svg | 54 +++++++++++++++++++++ art/ic_send_cancel_offline.svg | 54 +++++++++++++++++++++ art/ic_send_cancel_online.svg | 54 +++++++++++++++++++++ art/render.rb | 4 ++ .../conversations/ui/ConversationFragment.java | 42 +++++++++++----- src/main/res/drawable-hdpi/ic_send_cancel_away.png | Bin 0 -> 1396 bytes src/main/res/drawable-hdpi/ic_send_cancel_dnd.png | Bin 0 -> 1559 bytes .../res/drawable-hdpi/ic_send_cancel_offline.png | Bin 0 -> 1206 bytes .../res/drawable-hdpi/ic_send_cancel_online.png | Bin 0 -> 1531 bytes src/main/res/drawable-mdpi/ic_send_cancel_away.png | Bin 0 -> 901 bytes src/main/res/drawable-mdpi/ic_send_cancel_dnd.png | Bin 0 -> 1040 bytes .../res/drawable-mdpi/ic_send_cancel_offline.png | Bin 0 -> 837 bytes .../res/drawable-mdpi/ic_send_cancel_online.png | Bin 0 -> 1052 bytes .../res/drawable-xhdpi/ic_send_cancel_away.png | Bin 0 -> 1724 bytes src/main/res/drawable-xhdpi/ic_send_cancel_dnd.png | Bin 0 -> 1940 bytes .../res/drawable-xhdpi/ic_send_cancel_offline.png | Bin 0 -> 1519 bytes .../res/drawable-xhdpi/ic_send_cancel_online.png | Bin 0 -> 1978 bytes .../res/drawable-xxhdpi/ic_send_cancel_away.png | Bin 0 -> 2583 bytes .../res/drawable-xxhdpi/ic_send_cancel_dnd.png | Bin 0 -> 2911 bytes .../res/drawable-xxhdpi/ic_send_cancel_offline.png | Bin 0 -> 2290 bytes .../res/drawable-xxhdpi/ic_send_cancel_online.png | Bin 0 -> 2998 bytes .../res/drawable-xxxhdpi/ic_send_cancel_away.png | Bin 0 -> 3377 bytes .../res/drawable-xxxhdpi/ic_send_cancel_dnd.png | Bin 0 -> 3791 bytes .../drawable-xxxhdpi/ic_send_cancel_offline.png | Bin 0 -> 2956 bytes .../res/drawable-xxxhdpi/ic_send_cancel_online.png | Bin 0 -> 3835 bytes 26 files changed, 250 insertions(+), 12 deletions(-) create mode 100644 art/ic_send_cancel_away.svg create mode 100644 art/ic_send_cancel_dnd.svg create mode 100644 art/ic_send_cancel_offline.svg create mode 100644 art/ic_send_cancel_online.svg create mode 100644 src/main/res/drawable-hdpi/ic_send_cancel_away.png create mode 100644 src/main/res/drawable-hdpi/ic_send_cancel_dnd.png create mode 100644 src/main/res/drawable-hdpi/ic_send_cancel_offline.png create mode 100644 src/main/res/drawable-hdpi/ic_send_cancel_online.png create mode 100644 src/main/res/drawable-mdpi/ic_send_cancel_away.png create mode 100644 src/main/res/drawable-mdpi/ic_send_cancel_dnd.png create mode 100644 src/main/res/drawable-mdpi/ic_send_cancel_offline.png create mode 100644 src/main/res/drawable-mdpi/ic_send_cancel_online.png create mode 100644 src/main/res/drawable-xhdpi/ic_send_cancel_away.png create mode 100644 src/main/res/drawable-xhdpi/ic_send_cancel_dnd.png create mode 100644 src/main/res/drawable-xhdpi/ic_send_cancel_offline.png create mode 100644 src/main/res/drawable-xhdpi/ic_send_cancel_online.png create mode 100644 src/main/res/drawable-xxhdpi/ic_send_cancel_away.png create mode 100644 src/main/res/drawable-xxhdpi/ic_send_cancel_dnd.png create mode 100644 src/main/res/drawable-xxhdpi/ic_send_cancel_offline.png create mode 100644 src/main/res/drawable-xxhdpi/ic_send_cancel_online.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_send_cancel_away.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_send_cancel_dnd.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_send_cancel_offline.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_send_cancel_online.png diff --git a/art/ic_send_cancel_away.svg b/art/ic_send_cancel_away.svg new file mode 100644 index 000000000..1ee9c40f6 --- /dev/null +++ b/art/ic_send_cancel_away.svg @@ -0,0 +1,54 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/art/ic_send_cancel_dnd.svg b/art/ic_send_cancel_dnd.svg new file mode 100644 index 000000000..54e02a918 --- /dev/null +++ b/art/ic_send_cancel_dnd.svg @@ -0,0 +1,54 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/art/ic_send_cancel_offline.svg b/art/ic_send_cancel_offline.svg new file mode 100644 index 000000000..b88ade09d --- /dev/null +++ b/art/ic_send_cancel_offline.svg @@ -0,0 +1,54 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/art/ic_send_cancel_online.svg b/art/ic_send_cancel_online.svg new file mode 100644 index 000000000..40946af67 --- /dev/null +++ b/art/ic_send_cancel_online.svg @@ -0,0 +1,54 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/art/render.rb b/art/render.rb index 32d06f8f7..ad53b1f4f 100755 --- a/art/render.rb +++ b/art/render.rb @@ -26,6 +26,10 @@ images = { 'ic_send_voice_offline.svg' => ['ic_send_voice_offline', 36], 'ic_send_voice_away.svg' => ['ic_send_voice_away', 36], 'ic_send_voice_dnd.svg' => ['ic_send_voice_dnd', 36], + 'ic_send_cancel_online.svg' => ['ic_send_cancel_online', 36], + 'ic_send_cancel_offline.svg' => ['ic_send_cancel_offline', 36], + 'ic_send_cancel_away.svg' => ['ic_send_cancel_away', 36], + 'ic_send_cancel_dnd.svg' => ['ic_send_cancel_dnd', 36], } images.each do |source, result| resolutions.each do |name, factor| diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 37ae00a30..6b11d3109 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -245,6 +245,13 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa case RECORD_VOICE: activity.attachFile(ConversationActivity.ATTACHMENT_CHOICE_RECORD_VOICE); break; + case CANCEL: + if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) { + conversation.setNextCounterpart(null); + updateChatMsgHint(); + updateSendButton(); + } + break; default: sendMessage(); } @@ -257,8 +264,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa @Override public void onClick(View v) { - Intent intent = new Intent(getActivity(), - ConferenceDetailsActivity.class); + Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class); intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC); intent.putExtra("uuid", conversation.getUuid()); startActivity(intent); @@ -271,13 +277,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa if (this.conversation == null) { return; } - if (mEditMessage.getText().length() < 1) { - if (this.conversation.getMode() == Conversation.MODE_MULTI) { - conversation.setNextCounterpart(null); - updateChatMsgHint(); - } - return; - } Message message = new Message(conversation, mEditMessage.getText() .toString(), conversation.getNextEncryption(activity .forceEncryption())); @@ -558,6 +557,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa this.mEditMessage.setText(""); this.conversation.setNextCounterpart(counterpart); updateChatMsgHint(); + updateSendButton(); } protected void highlightInConference(String nick) { @@ -808,7 +808,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa updateChatMsgHint(); } - enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE} + enum SendButtonAction {TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL} private int getSendButtonImageResource(SendButtonAction action, int status) { switch (action) { @@ -864,6 +864,19 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa default: return R.drawable.ic_send_location_offline; } + case CANCEL: + switch (status) { + case Presences.CHAT: + case Presences.ONLINE: + return R.drawable.ic_send_cancel_online; + case Presences.AWAY: + return R.drawable.ic_send_cancel_away; + case Presences.XA: + case Presences.DND: + return R.drawable.ic_send_cancel_dnd; + default: + return R.drawable.ic_send_cancel_offline; + } } return R.drawable.ic_send_text_offline; } @@ -872,10 +885,15 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa final Conversation c = this.conversation; final SendButtonAction action; final int status; + final boolean empty = this.mEditMessage == null || this.mEditMessage.getText().length() == 0; if (c.getMode() == Conversation.MODE_MULTI) { - action = SendButtonAction.TEXT; + if (empty && c.getNextCounterpart() != null) { + action = SendButtonAction.CANCEL; + } else { + action = SendButtonAction.TEXT; + } } else { - if (this.mEditMessage == null || this.mEditMessage.getText().length() == 0) { + if (empty) { String setting = activity.getPreferences().getString("quick_action","recent"); if (setting.equals("recent")) { setting = activity.getPreferences().getString("recently_used_quick_action","text"); diff --git a/src/main/res/drawable-hdpi/ic_send_cancel_away.png b/src/main/res/drawable-hdpi/ic_send_cancel_away.png new file mode 100644 index 000000000..9525c040f Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_send_cancel_away.png differ diff --git a/src/main/res/drawable-hdpi/ic_send_cancel_dnd.png b/src/main/res/drawable-hdpi/ic_send_cancel_dnd.png new file mode 100644 index 000000000..cbfd8e76c Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_send_cancel_dnd.png differ diff --git a/src/main/res/drawable-hdpi/ic_send_cancel_offline.png b/src/main/res/drawable-hdpi/ic_send_cancel_offline.png new file mode 100644 index 000000000..2cb4f4f38 Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_send_cancel_offline.png differ diff --git a/src/main/res/drawable-hdpi/ic_send_cancel_online.png b/src/main/res/drawable-hdpi/ic_send_cancel_online.png new file mode 100644 index 000000000..cb3bc3b56 Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_send_cancel_online.png differ diff --git a/src/main/res/drawable-mdpi/ic_send_cancel_away.png b/src/main/res/drawable-mdpi/ic_send_cancel_away.png new file mode 100644 index 000000000..bbc86b45a Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_send_cancel_away.png differ diff --git a/src/main/res/drawable-mdpi/ic_send_cancel_dnd.png b/src/main/res/drawable-mdpi/ic_send_cancel_dnd.png new file mode 100644 index 000000000..e4fa38a3e Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_send_cancel_dnd.png differ diff --git a/src/main/res/drawable-mdpi/ic_send_cancel_offline.png b/src/main/res/drawable-mdpi/ic_send_cancel_offline.png new file mode 100644 index 000000000..604dfefaf Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_send_cancel_offline.png differ diff --git a/src/main/res/drawable-mdpi/ic_send_cancel_online.png b/src/main/res/drawable-mdpi/ic_send_cancel_online.png new file mode 100644 index 000000000..1b0d1811f Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_send_cancel_online.png differ diff --git a/src/main/res/drawable-xhdpi/ic_send_cancel_away.png b/src/main/res/drawable-xhdpi/ic_send_cancel_away.png new file mode 100644 index 000000000..44b5f0963 Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_send_cancel_away.png differ diff --git a/src/main/res/drawable-xhdpi/ic_send_cancel_dnd.png b/src/main/res/drawable-xhdpi/ic_send_cancel_dnd.png new file mode 100644 index 000000000..276ad0242 Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_send_cancel_dnd.png differ diff --git a/src/main/res/drawable-xhdpi/ic_send_cancel_offline.png b/src/main/res/drawable-xhdpi/ic_send_cancel_offline.png new file mode 100644 index 000000000..53a9ac909 Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_send_cancel_offline.png differ diff --git a/src/main/res/drawable-xhdpi/ic_send_cancel_online.png b/src/main/res/drawable-xhdpi/ic_send_cancel_online.png new file mode 100644 index 000000000..23a5f2632 Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_send_cancel_online.png differ diff --git a/src/main/res/drawable-xxhdpi/ic_send_cancel_away.png b/src/main/res/drawable-xxhdpi/ic_send_cancel_away.png new file mode 100644 index 000000000..07113f020 Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_send_cancel_away.png differ diff --git a/src/main/res/drawable-xxhdpi/ic_send_cancel_dnd.png b/src/main/res/drawable-xxhdpi/ic_send_cancel_dnd.png new file mode 100644 index 000000000..93fbc44d4 Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_send_cancel_dnd.png differ diff --git a/src/main/res/drawable-xxhdpi/ic_send_cancel_offline.png b/src/main/res/drawable-xxhdpi/ic_send_cancel_offline.png new file mode 100644 index 000000000..10412faba Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_send_cancel_offline.png differ diff --git a/src/main/res/drawable-xxhdpi/ic_send_cancel_online.png b/src/main/res/drawable-xxhdpi/ic_send_cancel_online.png new file mode 100644 index 000000000..6fa18239a Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_send_cancel_online.png differ diff --git a/src/main/res/drawable-xxxhdpi/ic_send_cancel_away.png b/src/main/res/drawable-xxxhdpi/ic_send_cancel_away.png new file mode 100644 index 000000000..a9340a886 Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_send_cancel_away.png differ diff --git a/src/main/res/drawable-xxxhdpi/ic_send_cancel_dnd.png b/src/main/res/drawable-xxxhdpi/ic_send_cancel_dnd.png new file mode 100644 index 000000000..02ab1d0fb Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_send_cancel_dnd.png differ diff --git a/src/main/res/drawable-xxxhdpi/ic_send_cancel_offline.png b/src/main/res/drawable-xxxhdpi/ic_send_cancel_offline.png new file mode 100644 index 000000000..abd3af2c2 Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_send_cancel_offline.png differ diff --git a/src/main/res/drawable-xxxhdpi/ic_send_cancel_online.png b/src/main/res/drawable-xxxhdpi/ic_send_cancel_online.png new file mode 100644 index 000000000..80be8edfc Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_send_cancel_online.png differ -- cgit v1.2.3