aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2017-08-02 11:49:12 +0200
committersteckbrief <steckbrief@chefmail.de>2017-08-02 11:51:37 +0200
commit8c5208bacd95ebd1ad6a6c192e536fd1ed47bfe2 (patch)
tree7cef44d8f2c1e075f59dee51b477f9c7ea9f47d4 /src
parenta9491140276305b3c45f675e765e17111362b7c3 (diff)
Implements FS#247 and FS#248: Show online status and typing notification in title
Diffstat (limited to '')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java57
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java23
-rw-r--r--src/main/res/layout/actionbar_title.xml34
-rw-r--r--src/main/res/values-de/strings.xml8
-rw-r--r--src/main/res/values/strings.xml2
6 files changed, 109 insertions, 19 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
index ce1eb439..0167ef4b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
@@ -11,6 +11,7 @@ import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.content.pm.PackageManager;
+import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -32,6 +33,7 @@ import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
+import android.widget.TextView;
import android.widget.Toast;
import net.java.otr4j.session.SessionStatus;
@@ -44,8 +46,11 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import de.thedevstack.android.logcat.Logging;
+import de.thedevstack.conversationsplus.entities.Presence;
import de.thedevstack.conversationsplus.services.filetransfer.FileTransferManager;
import de.thedevstack.conversationsplus.utils.AccountUtil;
+import de.thedevstack.conversationsplus.utils.UIHelper;
+import de.thedevstack.conversationsplus.xmpp.chatstate.ChatState;
import de.timroes.android.listview.EnhancedListView;
import de.thedevstack.conversationsplus.Config;
@@ -353,20 +358,44 @@ public class ConversationActivity extends XmppActivity
final ActionBar ab = getActionBar();
final Conversation conversation = getSelectedConversation();
if (ab != null) {
- if (titleShouldBeName && conversation != null) {
- ab.setDisplayHomeAsUpEnabled(true);
- ab.setHomeButtonEnabled(true);
- if (conversation.getMode() == Conversation.MODE_SINGLE || ConversationsPlusPreferences.useSubject()) {
- ab.setTitle(conversation.getName());
- } else {
- ab.setTitle(conversation.getJid().toBareJid().toString());
- }
- } else {
- ab.setDisplayHomeAsUpEnabled(false);
- ab.setHomeButtonEnabled(false);
- ab.setTitle(R.string.app_name);
- }
- }
+ if (titleShouldBeName && conversation != null) {
+ if ((ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) != ActionBar.DISPLAY_HOME_AS_UP) {
+ ab.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
+ }
+ ab.setDisplayShowTitleEnabled(false);
+ ab.setDisplayShowCustomEnabled(true);
+ ab.setCustomView(R.layout.actionbar_title);
+ TextView abtitle = (TextView) findViewById(R.id.abTitle);
+ TextView subtitle = (TextView) findViewById(R.id.abSubstitle);
+ abtitle.setText(conversation.getName());
+ //abtitle.setOnClickListener(this);
+ abtitle.setSelected(true);
+ if (conversation.getMode() == Conversation.MODE_SINGLE) {
+ ChatState state = conversation.getIncomingChatState();
+ if (state == ChatState.COMPOSING) {
+ subtitle.setText(getString(R.string.is_typing));
+ subtitle.setSelected(true);
+ subtitle.setTypeface(null, Typeface.BOLD_ITALIC);
+ //absubtitle.setOnClickListener(this);
+ } else if (state == ChatState.PAUSED) {
+ subtitle.setText(R.string.contact_paused_typing);
+ subtitle.setTypeface(null, Typeface.BOLD_ITALIC);
+ } else {
+ subtitle.setText(UIHelper.getStatusText(conversation.getContact().getMostAvailableStatus()));
+ }
+ } else {
+ }
+
+ } else {
+ if ((ab.getDisplayOptions() & ActionBar.DISPLAY_HOME_AS_UP) == ActionBar.DISPLAY_HOME_AS_UP) {
+ ab.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE);
+ }
+ ab.setDisplayShowTitleEnabled(true);
+ ab.setDisplayShowCustomEnabled(false);
+ ab.setTitle(R.string.app_name);
+ ab.setSubtitle(null);
+ }
+ }
}
private void openConversation() {
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
index 0f32e762..d25fa461 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
@@ -1097,9 +1097,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
if (conversation.getMode() == Conversation.MODE_SINGLE) {
ChatState state = conversation.getIncomingChatState();
if (state == ChatState.COMPOSING) {
- this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_is_typing, conversation.getName())));
+ //this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_is_typing, conversation.getName())));
} else if (state == ChatState.PAUSED) {
- this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_has_stopped_typing, conversation.getName())));
+ //this.messageList.add(Message.createStatusMessage(conversation, getString(R.string.contact_has_stopped_typing, conversation.getName())));
} else {
for (int i = this.messageList.size() - 1; i >= 0; --i) {
if (this.messageList.get(i).getStatus() == Message.STATUS_RECEIVED) {
diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java
index e3680b81..d27481df 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java
@@ -12,6 +12,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.ConversationsPlusColors;
import de.thedevstack.conversationsplus.R;
import de.thedevstack.conversationsplus.entities.Contact;
@@ -253,6 +254,28 @@ public class UIHelper {
}
}
+ public static String getStatusText(Presence.Status status) {
+ int statusResId = R.string.contact_status_offline;
+ switch (status) {
+ case ONLINE:
+ statusResId = R.string.contact_status_online;
+ break;
+ case CHAT:
+ statusResId = R.string.contact_status_free_to_chat;
+ break;
+ case AWAY:
+ statusResId = R.string.contact_status_away;
+ break;
+ case XA:
+ statusResId = R.string.contact_status_extended_away;
+ break;
+ case DND:
+ statusResId = R.string.contact_status_do_not_disturb;
+ break;
+ }
+ return ConversationsPlusApplication.getAppContext().getString(statusResId);
+ }
+
public static int getStatusColor(Presence.Status status) {
switch (status) {
case ONLINE:
diff --git a/src/main/res/layout/actionbar_title.xml b/src/main/res/layout/actionbar_title.xml
new file mode 100644
index 00000000..b2d25ed3
--- /dev/null
+++ b/src/main/res/layout/actionbar_title.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="start|center_vertical">
+
+ <github.ankushsachdeva.emojicon.EmojiconTextView
+ android:id="@+id/abTitle"
+ style="@style/Base.TextAppearance.AppCompat.Widget.ActionBar.Title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ellipsize="end"
+ android:gravity="start|center_vertical"
+ android:paddingTop="1dp"
+ android:scrollHorizontally="true"
+ android:singleLine="true"
+ android:textColor="@color/grey200" />
+
+ <github.ankushsachdeva.emojicon.EmojiconTextView
+ android:id="@+id/abSubstitle"
+ style="@style/Base.TextAppearance.AppCompat.Widget.ActionBar.Subtitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:singleLine="true"
+ android:ellipsize="end"
+ android:scrollHorizontally="true"
+ android:layout_below="@id/abTitle"
+ android:textSize="12sp"
+ android:textColor="@color/grey50"
+ android:gravity="start|center_vertical"
+ android:paddingBottom="1dp" />
+
+</RelativeLayout> \ No newline at end of file
diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index 826bbbb7..d514f08f 100644
--- a/src/main/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
@@ -189,10 +189,10 @@
<string name="error_out_of_memory">Zu wenig Speicher vorhanden. Das Bild ist zu groß</string>
<string name="add_phone_book_text">%s zum Telefonbuch hinzufügen</string>
<string name="contact_status_online">online</string>
- <string name="contact_status_free_to_chat">bereit</string>
+ <string name="contact_status_free_to_chat">Frei zum Chatten</string>
<string name="contact_status_away">abwesend</string>
- <string name="contact_status_extended_away">länger abwesend</string>
- <string name="contact_status_do_not_disturb">nicht stören</string>
+ <string name="contact_status_extended_away">nicht verfügbar</string>
+ <string name="contact_status_do_not_disturb">beschäftigt</string>
<string name="contact_status_offline">offline</string>
<string name="muc_details_conference">Konferenz</string>
<string name="muc_details_other_members">Andere Mitglieder</string>
@@ -637,4 +637,6 @@
<string name="cplus_are_you_sure">Bist du dir sicher?</string>
<string name="pref_log_stanzas_summary">Stanzas protokollieren, um das Debugging zu erleichtern</string>
<string name="pref_log_stanzas">Stanzas protokollieren</string>
+ <string name="contact_paused_typing">...macht eine Schreibpause</string>
+ <string name="is_typing">...schreibt</string>
</resources>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index b76be95d..2055c5de 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -688,4 +688,6 @@
<string name="checking_remote_filesize">Checking file size on remote host.</string>
<string name="pref_log_stanzas_summary">Log stanzas messages to logcat to improve debugging</string>
<string name="pref_log_stanzas">Log stanzas</string>
+ <string name="contact_paused_typing">...has stopped typing</string>
+ <string name="is_typing">...is writing</string>
</resources>