aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--art/ic_action_send_now.svg69
-rw-r--r--res/drawable-hdpi/ic_action_send_now.pngbin578 -> 0 bytes
-rw-r--r--res/drawable-hdpi/ic_action_send_now_away.pngbin0 -> 932 bytes
-rw-r--r--res/drawable-hdpi/ic_action_send_now_dnd.pngbin0 -> 1135 bytes
-rw-r--r--res/drawable-hdpi/ic_action_send_now_offline.pngbin0 -> 767 bytes
-rw-r--r--res/drawable-hdpi/ic_action_send_now_online.pngbin0 -> 1095 bytes
-rw-r--r--res/drawable-mdpi/ic_action_send_now_away.pngbin0 -> 650 bytes
-rw-r--r--res/drawable-mdpi/ic_action_send_now_dnd.pngbin0 -> 784 bytes
-rw-r--r--res/drawable-mdpi/ic_action_send_now_offline.pngbin0 -> 535 bytes
-rw-r--r--res/drawable-mdpi/ic_action_send_now_online.pngbin0 -> 779 bytes
-rw-r--r--res/drawable-xhdpi/ic_action_send_now.pngbin759 -> 0 bytes
-rw-r--r--res/drawable-xhdpi/ic_action_send_now_away.pngbin0 -> 1180 bytes
-rw-r--r--res/drawable-xhdpi/ic_action_send_now_dnd.pngbin0 -> 1438 bytes
-rw-r--r--res/drawable-xhdpi/ic_action_send_now_offline.pngbin0 -> 968 bytes
-rw-r--r--res/drawable-xhdpi/ic_action_send_now_online.pngbin0 -> 1395 bytes
-rw-r--r--res/drawable-xxhdpi/ic_action_send_now_away.pngbin0 -> 1426 bytes
-rw-r--r--res/drawable-xxhdpi/ic_action_send_now_dnd.pngbin0 -> 1456 bytes
-rw-r--r--res/drawable-xxhdpi/ic_action_send_now_offline.pngbin0 -> 1433 bytes
-rw-r--r--res/drawable-xxhdpi/ic_action_send_now_online.pngbin0 -> 1458 bytes
-rw-r--r--res/layout/fragment_conversation.xml2
-rw-r--r--res/values/strings.xml2
-rw-r--r--res/xml/preferences.xml5
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java11
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java104
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java53
25 files changed, 205 insertions, 41 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ id="svg3621"
+ version="1.1"
+ inkscape:version="0.48.4 r9939"
+ width="96"
+ height="96"
+ sodipodi:docname="ic_action_send_now.svg"
+ inkscape:export-filename="/home/daniel/workspace/Conversations/res/drawable-xxhdpi/ic_action_send_now_online.png"
+ inkscape:export-xdpi="154.28572"
+ inkscape:export-ydpi="154.28572">
+ <metadata
+ id="metadata3627">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs3625" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1916"
+ inkscape:window-height="1161"
+ id="namedview3623"
+ showgrid="true"
+ showguides="true"
+ inkscape:zoom="1"
+ inkscape:cx="47.28873"
+ inkscape:cy="43.262706"
+ inkscape:window-x="0"
+ inkscape:window-y="18"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg3621">
+ <inkscape:grid
+ type="xygrid"
+ id="grid3631" />
+ </sodipodi:namedview>
+ <path
+ style="fill:#e51c28;fill-opacity:0.627451;stroke:none"
+ d="M 20.012575,21.028577 76,49 20.012575,77.028577 26,52 58.012575,49.028577 26,46 z"
+ id="path3633"
+ inkscape:connector-curvature="0"
+ sodipodi:nodetypes="ccccccc"
+ inkscape:export-filename="/home/daniel/workspace/Conversations/res/drawable-mdpi/ic_action_send_now_dnd.png"
+ inkscape:export-xdpi="51.42857"
+ inkscape:export-ydpi="51.42857" />
+</svg>
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
--- a/res/drawable-hdpi/ic_action_send_now.png
+++ /dev/null
Binary files 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
--- /dev/null
+++ b/res/drawable-hdpi/ic_action_send_now_away.png
Binary files 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
--- /dev/null
+++ b/res/drawable-hdpi/ic_action_send_now_dnd.png
Binary files 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
--- /dev/null
+++ b/res/drawable-hdpi/ic_action_send_now_offline.png
Binary files 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
--- /dev/null
+++ b/res/drawable-hdpi/ic_action_send_now_online.png
Binary files 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
--- /dev/null
+++ b/res/drawable-mdpi/ic_action_send_now_away.png
Binary files 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
--- /dev/null
+++ b/res/drawable-mdpi/ic_action_send_now_dnd.png
Binary files 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
--- /dev/null
+++ b/res/drawable-mdpi/ic_action_send_now_offline.png
Binary files 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
--- /dev/null
+++ b/res/drawable-mdpi/ic_action_send_now_online.png
Binary files 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
--- a/res/drawable-xhdpi/ic_action_send_now.png
+++ /dev/null
Binary files 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
--- /dev/null
+++ b/res/drawable-xhdpi/ic_action_send_now_away.png
Binary files 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
--- /dev/null
+++ b/res/drawable-xhdpi/ic_action_send_now_dnd.png
Binary files 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
--- /dev/null
+++ b/res/drawable-xhdpi/ic_action_send_now_offline.png
Binary files 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
--- /dev/null
+++ b/res/drawable-xhdpi/ic_action_send_now_online.png
Binary files 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
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_action_send_now_away.png
Binary files 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
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_action_send_now_dnd.png
Binary files 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
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_action_send_now_offline.png
Binary files 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
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_action_send_now_online.png
Binary files 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" />
</RelativeLayout>
<RelativeLayout
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 75ddbbc4..0ede2039 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -254,4 +254,6 @@
<string name="pref_expert_options_summary">Please be very careful with those</string>
<string name="pref_use_larger_font">Increase font size</string>
<string name="pref_use_larger_font_summary">Use larger font sizes across the entire app</string>
+ <string name="pref_use_send_button_to_indicate_status">Send button indicates status</string>
+ <string name="pref_use_send_button_to_indicate_status_summary">Colorize send button to indicate a contacs status</string>
</resources> \ 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"/>
+ <CheckBoxPreference
+ android:key="send_button_status"
+ android:defaultValue="false"
+ android:title="@string/pref_use_send_button_to_indicate_status"
+ android:summary="@string/pref_use_send_button_to_indicate_status_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_advanced_options" >
<PreferenceScreen
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index f272486c..c019682e 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -109,6 +109,7 @@ public class XmppConnectionService extends Service {
private OnAccountUpdate mOnAccountUpdate = null;
private int accountChangedListenerCount = 0;
private OnRosterUpdate mOnRosterUpdate = null;
+ private int rosterChangedListenerCount = 0;
public OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() {
@Override
@@ -997,12 +998,16 @@ public class XmppConnectionService extends Service {
switchToForeground();
}
this.mOnRosterUpdate = listener;
+ this.rosterChangedListenerCount++;
}
public void removeOnRosterUpdateListener() {
- this.mOnRosterUpdate = null;
- if (checkListeners()) {
- switchToBackground();
+ this.rosterChangedListenerCount--;
+ if (this.rosterChangedListenerCount == 0) {
+ this.mOnRosterUpdate = null;
+ if (checkListeners()) {
+ switchToBackground();
+ }
}
}
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();
+ }
+ });
+ }
}
}
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) {