Merge pull request #853 from deltachat/show-location-states

show current state of the location-streaming in chatlist and chat
This commit is contained in:
björn petersen
2019-04-19 02:15:32 +02:00
committed by GitHub
15 changed files with 87 additions and 89 deletions
+6
View File
@@ -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);
Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

+29 -26
View File
@@ -16,23 +16,6 @@
android:clipChildren="false"
android:clipToPadding="false"/>
<TextView android:id="@+id/scroll_date_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center_horizontal|top"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:layout_marginTop="8dp"
style="@style/Signal.Text.Caption"
android:textColor="?attr/conversation_item_sticky_date_text_color"
android:background="?attr/conversation_item_sticky_date_background"
android:elevation="9dp"
android:visibility="gone"
tools:text="March 1, 2015" />
<TextView
android:id="@+id/no_messages_text_view"
android:layout_width="wrap_content"
@@ -50,21 +33,41 @@
android:background="@drawable/compose_divider_background"
android:alpha="1" />
<ImageButton
android:id="@+id/scroll_to_bottom_button"
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="20dp"
android:layout_gravity="bottom|end"
android:orientation="vertical">
<ImageButton
android:id="@+id/scroll_to_bottom_button"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:background="@drawable/circle_floating_mini_button"
android:tint="@color/gray50"
android:elevation="1dp"
android:alpha="0.9"
android:contentDescription="@string/menu_scroll_to_bottom"
android:src="@drawable/ic_scroll_down"/>
<ImageButton
android:id="@+id/floating_location_button"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="15dp"
android:padding="5dp"
android:layout_gravity="bottom|end"
android:background="@drawable/circle_floating_mini_button"
android:tint="@color/gray50"
android:elevation="1dp"
android:alpha="0.9"
android:contentDescription="@string/menu_scroll_to_bottom"
android:src="@drawable/ic_scroll_down"/>
android:contentDescription="Location streaming enabled"
android:src="@drawable/ic_location_chat"/>
</LinearLayout>
</FrameLayout>
@@ -94,6 +94,7 @@
<TextView android:id="@id/date"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:drawablePadding="5dp"
style="@style/Signal.Text.Caption"
android:textColor="?attr/conversation_list_item_date_color"
tools:text="30 mins"
+1
View File
@@ -65,6 +65,7 @@
style="@style/TextSecure.SubtitleTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="5dp"
android:ellipsize="end"
android:maxLines="1"
android:textDirection="ltr"
-1
View File
@@ -135,7 +135,6 @@
<string-array name="share_location_durations">
<item>@string/share_location_once</item>
<item>@string/share_location_for_5_minutes</item>
<item>@string/share_location_for_30_minutes</item>
<item>@string/share_location_for_one_hour</item>
+1
View File
@@ -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
@@ -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);
@@ -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<int[]> 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();
}
}
@@ -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();
@@ -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() {
@@ -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);
@@ -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);
}
@@ -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;
}
}