diff --git a/jni/dc_wrapper.c b/jni/dc_wrapper.c
index bf6264345..e1b95d4a3 100644
--- a/jni/dc_wrapper.c
+++ b/jni/dc_wrapper.c
@@ -1008,6 +1008,12 @@ JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isVerified(JNIEnv *env, jobjec
}
+JNIEXPORT jboolean Java_com_b44t_messenger_DcChat_isSendingLocations(JNIEnv *env, jobject obj)
+{
+ return dc_chat_is_sending_locations(get_dc_chat(env, obj))!=0;
+}
+
+
JNIEXPORT jintArray Java_com_b44t_messenger_DcContext_getChatMedia(JNIEnv *env, jobject obj, jint chat_id, jint type1, jint type2, jint type3)
{
dc_array_t* ca = dc_get_chat_media(get_dc_context(env, obj), chat_id, type1, type2, type3);
diff --git a/res/drawable-xhdpi/ic_location_chat.png b/res/drawable-xhdpi/ic_location_chat.png
new file mode 100644
index 000000000..4f40c82bc
Binary files /dev/null and b/res/drawable-xhdpi/ic_location_chat.png differ
diff --git a/res/drawable-xhdpi/ic_location_chatlist.png b/res/drawable-xhdpi/ic_location_chatlist.png
new file mode 100644
index 000000000..35137740b
Binary files /dev/null and b/res/drawable-xhdpi/ic_location_chatlist.png differ
diff --git a/res/layout/conversation_fragment.xml b/res/layout/conversation_fragment.xml
index ad4fe24e0..8dc4d11bd 100644
--- a/res/layout/conversation_fragment.xml
+++ b/res/layout/conversation_fragment.xml
@@ -16,23 +16,6 @@
android:clipChildren="false"
android:clipToPadding="false"/>
-
-
-
+
+
+
+
+ android:contentDescription="Location streaming enabled"
+ android:src="@drawable/ic_location_chat"/>
+
+
diff --git a/res/layout/conversation_list_item_view.xml b/res/layout/conversation_list_item_view.xml
index 89e8ca79f..6032ed4a8 100644
--- a/res/layout/conversation_list_item_view.xml
+++ b/res/layout/conversation_list_item_view.xml
@@ -94,6 +94,7 @@
- - @string/share_location_once
- @string/share_location_for_5_minutes
- @string/share_location_for_30_minutes
- @string/share_location_for_one_hour
diff --git a/src/com/b44t/messenger/DcChat.java b/src/com/b44t/messenger/DcChat.java
index e654d9495..30f95a3d6 100644
--- a/src/com/b44t/messenger/DcChat.java
+++ b/src/com/b44t/messenger/DcChat.java
@@ -29,6 +29,7 @@ public class DcChat {
public native boolean isUnpromoted ();
public native boolean isSelfTalk ();
public native boolean isVerified ();
+ public native boolean isSendingLocations();
// working with raw c-data
private long chatCPtr; // CAVE: the name is referenced in the JNI
diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java
index 5b96476d0..9eb8fc240 100644
--- a/src/org/thoughtcrime/securesms/ConversationActivity.java
+++ b/src/org/thoughtcrime/securesms/ConversationActivity.java
@@ -1302,6 +1302,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override
public void handleEvent(int eventId, Object data1, Object data2) {
if (eventId==DcContext.DC_EVENT_CHAT_MODIFIED || eventId==DcContext.DC_EVENT_CONTACTS_CHANGED) {
+ dcChat = dcContext.getChat(chatId);
titleView.setTitle(glideRequests, dcChat);
updateReminders();
initializeSecurity(isSecureText, isDefaultSms);
diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java
index d7c8dd1c4..49209eea0 100644
--- a/src/org/thoughtcrime/securesms/ConversationFragment.java
+++ b/src/org/thoughtcrime/securesms/ConversationFragment.java
@@ -113,7 +113,7 @@ public class ConversationFragment extends Fragment
private RecyclerView list;
private RecyclerView.ItemDecoration lastSeenDecoration;
private View scrollToBottomButton;
- private TextView scrollDateHeader;
+ private View floatingLocationButton;
private TextView noMessageTextView;
private ApplicationDcContext dcContext;
@@ -125,11 +125,12 @@ public class ConversationFragment extends Fragment
this.locale = (Locale) getArguments().getSerializable(PassphraseRequiredActionBarActivity.LOCALE_EXTRA);
this.dcContext = DcHelper.getContext(getContext());
- dcContext.eventCenter.addObserver(this, DcContext.DC_EVENT_INCOMING_MSG);
- dcContext.eventCenter.addObserver(this, DcContext.DC_EVENT_MSGS_CHANGED);
- dcContext.eventCenter.addObserver(this, DcContext.DC_EVENT_MSG_DELIVERED);
- dcContext.eventCenter.addObserver(this, DcContext.DC_EVENT_MSG_FAILED);
- dcContext.eventCenter.addObserver(this, DcContext.DC_EVENT_MSG_READ);
+ dcContext.eventCenter.addObserver(DcContext.DC_EVENT_INCOMING_MSG, this);
+ dcContext.eventCenter.addObserver(DcContext.DC_EVENT_MSGS_CHANGED, this);
+ dcContext.eventCenter.addObserver(DcContext.DC_EVENT_MSG_DELIVERED, this);
+ dcContext.eventCenter.addObserver(DcContext.DC_EVENT_MSG_FAILED, this);
+ dcContext.eventCenter.addObserver(DcContext.DC_EVENT_MSG_READ, this);
+ dcContext.eventCenter.addObserver(DcContext.DC_EVENT_CHAT_MODIFIED, this);
markseenDebouncer = new Debouncer(800);
}
@@ -138,10 +139,10 @@ public class ConversationFragment extends Fragment
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle bundle) {
final View view = inflater.inflate(R.layout.conversation_fragment, container, false);
- list = ViewUtil.findById(view, android.R.id.list);
- scrollToBottomButton = ViewUtil.findById(view, R.id.scroll_to_bottom_button);
- scrollDateHeader = ViewUtil.findById(view, R.id.scroll_date_header);
- noMessageTextView = ViewUtil.findById(view, R.id.no_messages_text_view);
+ list = ViewUtil.findById(view, android.R.id.list);
+ scrollToBottomButton = ViewUtil.findById(view, R.id.scroll_to_bottom_button);
+ floatingLocationButton = ViewUtil.findById(view, R.id.floating_location_button);
+ noMessageTextView = ViewUtil.findById(view, R.id.no_messages_text_view);
scrollToBottomButton.setOnClickListener(v -> scrollToBottom());
@@ -226,6 +227,7 @@ public class ConversationFragment extends Fragment
if (threadId == -1) {
reloadList();
+ updateLocationButton();
}
}
@@ -262,6 +264,7 @@ public class ConversationFragment extends Fragment
setLastSeen(lastSeen);
reloadList();
+ updateLocationButton();
}
}
@@ -442,7 +445,7 @@ public class ConversationFragment extends Fragment
});
}
- public void reloadList() {
+ private void reloadList() {
ConversationAdapter adapter = getListAdapter();
if (adapter == null) {
return;
@@ -465,6 +468,10 @@ public class ConversationFragment extends Fragment
}
}
+ private void updateLocationButton() {
+ floatingLocationButton.setVisibility(dcContext.isSendingLocationsToChat((int)threadId)? View.VISIBLE : View.GONE);
+ }
+
@Override
public Loader onCreateLoader(int id, Bundle args) {
Log.w(TAG, "onCreateLoader");
@@ -552,7 +559,6 @@ public class ConversationFragment extends Fragment
private final Animation scrollButtonInAnimation;
private final Animation scrollButtonOutAnimation;
- private final ConversationDateHeader conversationDateHeader;
private boolean wasAtBottom = true;
private boolean wasAtZoomScrollHeight = false;
@@ -561,7 +567,6 @@ public class ConversationFragment extends Fragment
ConversationScrollListener(@NonNull Context context) {
this.scrollButtonInAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_scale_in);
this.scrollButtonOutAnimation = AnimationUtils.loadAnimation(context, R.anim.fade_scale_out);
- this.conversationDateHeader = new ConversationDateHeader(context, scrollDateHeader);
this.scrollButtonInAnimation.setDuration(100);
this.scrollButtonOutAnimation.setDuration(50);
@@ -851,50 +856,12 @@ public class ConversationFragment extends Fragment
}
}
- private static class ConversationDateHeader extends HeaderViewHolder {
-
- private final Animation animateIn;
- private final Animation animateOut;
-
- private boolean pendingHide = false;
-
- private ConversationDateHeader(Context context, TextView textView) {
- super(textView);
- this.animateIn = AnimationUtils.loadAnimation(context, R.anim.slide_from_top);
- this.animateOut = AnimationUtils.loadAnimation(context, R.anim.slide_to_top);
-
- this.animateIn.setDuration(100);
- this.animateOut.setDuration(100);
- }
-
- public void show() {
- if (pendingHide) {
- pendingHide = false;
- } else {
- ViewUtil.animateIn(textView, animateIn);
- }
- }
-
- public void hide() {
- pendingHide = true;
-
- textView.postDelayed(new Runnable() {
- @Override
- public void run() {
- if (pendingHide) {
- pendingHide = false;
- ViewUtil.animateOut(textView, animateOut, View.GONE);
- }
- }
- }, 400);
- }
- }
-
@Override
public void handleEvent(int eventId, Object data1, Object data2) {
- if(eventId== DcContext.DC_EVENT_MSG_DELIVERED) {
- Log.w(TAG, "DC_EVENT_MSG_DELIVERED reveived for msg#"+(Long)data1);
+ if (eventId==DcContext.DC_EVENT_CHAT_MODIFIED) {
+ updateLocationButton();
}
+
reloadList();
}
}
diff --git a/src/org/thoughtcrime/securesms/ConversationListItem.java b/src/org/thoughtcrime/securesms/ConversationListItem.java
index 8e5793a5e..1f1841665 100644
--- a/src/org/thoughtcrime/securesms/ConversationListItem.java
+++ b/src/org/thoughtcrime/securesms/ConversationListItem.java
@@ -157,6 +157,8 @@ public class ConversationListItem extends RelativeLayout
dateView.setText("");
}
+ dateView.setCompoundDrawablesWithIntrinsicBounds(0, 0,
+ thread.isSendingLocations()? R.drawable.ic_location_chatlist : 0, 0);
setStatusIcons(thread);
setBatchState(batchMode);
@@ -193,8 +195,10 @@ public class ConversationListItem extends RelativeLayout
this.glideRequests = glideRequests;
fromView.setText(getHighlightedSpan(locale, contact.getDisplayName(), highlightSubstring));
+ fromView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
subjectView.setText(getHighlightedSpan(locale, contact.getAddr(), highlightSubstring));
dateView.setText("");
+ dateView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
archivedView.setVisibility(GONE);
unreadIndicator.setVisibility(GONE);
deliveryStatusIndicator.setNone();
@@ -217,6 +221,7 @@ public class ConversationListItem extends RelativeLayout
this.glideRequests = glideRequests;
fromView.setText(recipient, true);
+ fromView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
subjectView.setText(getHighlightedSpan(locale, messageResult.getSummarytext(512), highlightSubstring));
long timestamp = messageResult.getTimestamp();
@@ -226,6 +231,7 @@ public class ConversationListItem extends RelativeLayout
else {
dateView.setText("");
}
+ dateView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
archivedView.setVisibility(GONE);
unreadIndicator.setVisibility(GONE);
deliveryStatusIndicator.setNone();
diff --git a/src/org/thoughtcrime/securesms/ConversationTitleView.java b/src/org/thoughtcrime/securesms/ConversationTitleView.java
index 642162c50..f4a198e94 100644
--- a/src/org/thoughtcrime/securesms/ConversationTitleView.java
+++ b/src/org/thoughtcrime/securesms/ConversationTitleView.java
@@ -55,6 +55,7 @@ public class ConversationTitleView extends RelativeLayout {
int imgLeft = 0;
int imgRight = 0;
+ //int imgSubtitleRight = 0;
if (dcChat == null) {
setComposeTitle();
@@ -67,9 +68,14 @@ public class ConversationTitleView extends RelativeLayout {
imgRight = R.drawable.ic_verified;
}
this.avatar.setAvatar(glideRequests, DcHelper.getContext(getContext()).getRecipient(dcChat), false);
+
+ //if (dcChat.isSendingLocations()) {
+ // imgSubtitleRight = R.drawable.ic_location_chatlist;
+ //}
}
title.setCompoundDrawablesWithIntrinsicBounds(imgLeft, 0, imgRight, 0);
+ //subtitle.setCompoundDrawablesWithIntrinsicBounds(0, 0, imgSubtitleRight, 0);
}
public void hideAvatar() {
diff --git a/src/org/thoughtcrime/securesms/ShareLocationDialog.java b/src/org/thoughtcrime/securesms/ShareLocationDialog.java
index 1acde1306..c353d7fab 100644
--- a/src/org/thoughtcrime/securesms/ShareLocationDialog.java
+++ b/src/org/thoughtcrime/securesms/ShareLocationDialog.java
@@ -33,12 +33,11 @@ public class ShareLocationDialog extends AlertDialog {
switch (which) {
default:
- case 0: shareLocationUnit = 1; break;
- case 1: shareLocationUnit = 5 * 60; break;
- case 2: shareLocationUnit = 30 * 60; break;
- case 3: shareLocationUnit = 60 * 60; break;
- case 4: shareLocationUnit = 60 * 60 * 2; break;
- case 5: shareLocationUnit = 60 * 60 * 6; break;
+ case 0: shareLocationUnit = 5 * 60; break;
+ case 1: shareLocationUnit = 30 * 60; break;
+ case 2: shareLocationUnit = 60 * 60; break;
+ case 3: shareLocationUnit = 2 * 60 * 60; break;
+ case 4: shareLocationUnit = 6 * 60 * 60; break;
}
listener.onSelected(shareLocationUnit);
diff --git a/src/org/thoughtcrime/securesms/connect/ApplicationDcContext.java b/src/org/thoughtcrime/securesms/connect/ApplicationDcContext.java
index 1632b8683..051ab59ec 100644
--- a/src/org/thoughtcrime/securesms/connect/ApplicationDcContext.java
+++ b/src/org/thoughtcrime/securesms/connect/ApplicationDcContext.java
@@ -259,7 +259,7 @@ public class ApplicationDcContext extends DcContext {
return new ThreadRecord(context, body, recipient, date,
unreadCount, chatId,
- archived, verified, summary);
+ archived, verified, chat.isSendingLocations(), summary);
}
diff --git a/src/org/thoughtcrime/securesms/database/model/ThreadRecord.java b/src/org/thoughtcrime/securesms/database/model/ThreadRecord.java
index cd735e2b3..30cc9af54 100644
--- a/src/org/thoughtcrime/securesms/database/model/ThreadRecord.java
+++ b/src/org/thoughtcrime/securesms/database/model/ThreadRecord.java
@@ -47,13 +47,16 @@ public class ThreadRecord {
private final int unreadCount;
private final boolean archived;
private final boolean verified;
+ private final boolean isSendingLocations;
private @Nullable final DcLot dcSummary;
public ThreadRecord(@NonNull Context context, @NonNull String body,
@NonNull Recipient recipient, long dateReceived, int unreadCount,
long threadId,
boolean archived,
- boolean verified, @Nullable DcLot dcSummary)
+ boolean verified,
+ boolean isSendingLocations,
+ @Nullable DcLot dcSummary)
{
this.context = context.getApplicationContext();
this.threadId = threadId;
@@ -63,6 +66,7 @@ public class ThreadRecord {
this.unreadCount = unreadCount;
this.archived = archived;
this.verified = verified;
+ this.isSendingLocations = isSendingLocations;
this.dcSummary = dcSummary;
}
@@ -113,4 +117,8 @@ public class ThreadRecord {
public boolean isVerified() {
return verified;
}
+
+ public boolean isSendingLocations() {
+ return isSendingLocations;
+ }
}