From 5a644af56f9e80cfa911698f4c4c175da6569259 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Thu, 18 Apr 2019 17:17:35 +0200 Subject: [PATCH 1/3] show current state of the location-streaming in chatlist and chat --- jni/dc_wrapper.c | 6 ++++++ res/drawable-xhdpi/ic_location_state.png | Bin 0 -> 811 bytes res/layout/conversation_list_item_view.xml | 1 + res/layout/conversation_title_view.xml | 1 + src/com/b44t/messenger/DcChat.java | 1 + .../securesms/ConversationActivity.java | 1 + .../securesms/ConversationListItem.java | 6 ++++++ .../securesms/ConversationTitleView.java | 6 ++++++ .../securesms/connect/ApplicationDcContext.java | 2 +- .../securesms/database/model/ThreadRecord.java | 10 +++++++++- 10 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 res/drawable-xhdpi/ic_location_state.png 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_state.png b/res/drawable-xhdpi/ic_location_state.png new file mode 100644 index 0000000000000000000000000000000000000000..35137740be6eeb503d791966e10e9450cd03dd7d GIT binary patch literal 811 zcmV+`1JwM9P)a%g5sM(r-@u05ayx@uuz`(QYQSj4C)~R|ak?wBu@k4eGU48> z)QYD>FQS-QxnP1ZO#??V@{*#o@ATFp8F?9jX5@miiiFZiR+$4pC>N|j$7#z6BDBh! z*3UI@LgI_m^q^K_(`{cS6`LBZHOrhv0$4_=cZG=AG#g7>Zs%$?w&ixNnr35(AZ(;p zvFDnJ`L}oRIWRD-<>v99BQ~<~Si~|sT>oMhs$5+0Y0k@nC?Y0B*~KGED-j&2Xqpvd zMNNZ_BNY_~pE}*uNOAU3aHKd(dm2-7HW2<;1L*3z1sw=~T@T?##*aD2IDNBOz^4GUG=4ZUl#03|30tjLq&x4E Date: Fri, 19 Apr 2019 00:23:41 +0200 Subject: [PATCH 2/3] remove one-time location-streaming; it's not implemented and it's unclear ux-wise --- res/values/arrays.xml | 1 - .../thoughtcrime/securesms/ShareLocationDialog.java | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 21df85153..d0955e1e3 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -135,7 +135,6 @@ - @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/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); From afd84312200d04dd4979d948140129845f14ce58 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Fri, 19 Apr 2019 02:14:50 +0200 Subject: [PATCH 3/3] playing around with location-streaming-state as floating icon --- res/drawable-xhdpi/ic_location_chat.png | Bin 0 -> 828 bytes ...ion_state.png => ic_location_chatlist.png} | Bin res/layout/conversation_fragment.xml | 55 +++++++------ .../securesms/ConversationFragment.java | 75 +++++------------- .../securesms/ConversationListItem.java | 2 +- .../securesms/ConversationTitleView.java | 10 +-- 6 files changed, 56 insertions(+), 86 deletions(-) create mode 100644 res/drawable-xhdpi/ic_location_chat.png rename res/drawable-xhdpi/{ic_location_state.png => ic_location_chatlist.png} (100%) diff --git a/res/drawable-xhdpi/ic_location_chat.png b/res/drawable-xhdpi/ic_location_chat.png new file mode 100644 index 0000000000000000000000000000000000000000..4f40c82bca5454371bc09d5d043cae1e9e6f423f GIT binary patch literal 828 zcmV-C1H=4@P)C@+dvSHz_Lka@GZF`QcSWb>*JzQ|$5bm#NM3sOkIK!P-|VWS)wxTZTd zRfZaVtCuHYma^zRzPsFeyX)+&?pE&OyGxd`D9hi%mfP@KJ#8QhTa`?qN#QU^333E(X#?dIKOqIzc?N)x zHjo6FW@Zl=rp_}dvtt$l@l>$PZEQNVb-#K3SP`w5mAYQ`3W0c%sRd-%b-T8(;kPa( z_cr|2Mcu9~7zkTBF_l`!&e_Mv!e*tg4*gmxE3Xc*l*jw4pWLY`H5GJR@I}Z(hHaw! zqNox}2`CZCI8WTFCPAi&NTvrm_S(ydpk!L0L{OqKf+%(Sh=oH5Aoa5YGGgKINxJ={ zCB!@)=>o+(9zAR^Qv(42L_8X%Qi`%Lsgxq((NNW28R*z+FNZw5EejO#@V3mbU;5Os zbM_%rovT^OqW#s+GiBoAvOt8A8jF7hgS?-A7FT0000 - - - + + + + + android:contentDescription="Location streaming enabled" + android:src="@drawable/ic_location_chat"/> + + 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 63cc2ef80..1f1841665 100644 --- a/src/org/thoughtcrime/securesms/ConversationListItem.java +++ b/src/org/thoughtcrime/securesms/ConversationListItem.java @@ -158,7 +158,7 @@ public class ConversationListItem extends RelativeLayout } dateView.setCompoundDrawablesWithIntrinsicBounds(0, 0, - thread.isSendingLocations()? R.drawable.ic_location_state : 0, 0); + thread.isSendingLocations()? R.drawable.ic_location_chatlist : 0, 0); setStatusIcons(thread); setBatchState(batchMode); diff --git a/src/org/thoughtcrime/securesms/ConversationTitleView.java b/src/org/thoughtcrime/securesms/ConversationTitleView.java index 320e65425..f4a198e94 100644 --- a/src/org/thoughtcrime/securesms/ConversationTitleView.java +++ b/src/org/thoughtcrime/securesms/ConversationTitleView.java @@ -55,7 +55,7 @@ public class ConversationTitleView extends RelativeLayout { int imgLeft = 0; int imgRight = 0; - int imgSubtitleRight = 0; + //int imgSubtitleRight = 0; if (dcChat == null) { setComposeTitle(); @@ -69,13 +69,13 @@ public class ConversationTitleView extends RelativeLayout { } this.avatar.setAvatar(glideRequests, DcHelper.getContext(getContext()).getRecipient(dcChat), false); - if (dcChat.isSendingLocations()) { - imgSubtitleRight = R.drawable.ic_location_state; - } + //if (dcChat.isSendingLocations()) { + // imgSubtitleRight = R.drawable.ic_location_chatlist; + //} } title.setCompoundDrawablesWithIntrinsicBounds(imgLeft, 0, imgRight, 0); - subtitle.setCompoundDrawablesWithIntrinsicBounds(0, 0, imgSubtitleRight, 0); + //subtitle.setCompoundDrawablesWithIntrinsicBounds(0, 0, imgSubtitleRight, 0); } public void hideAvatar() {