Merge pull request #340 from loki-project/ui

Fix Message Details Screen
This commit is contained in:
Niels Andriesse 2020-09-17 11:41:52 +10:00 committed by GitHub
commit fc16622fcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 111 additions and 55 deletions

View File

@ -310,7 +310,7 @@
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
android:label="Message Details"
android:screenOrientation="portrait"
android:theme="@style/Theme.Session.DayNight"
android:theme="@style/Theme.TextSecure.DayNight"
android:launchMode="singleTask"
android:windowSoftInputMode="stateHidden" />
<activity

Binary file not shown.

Before

Width:  |  Height:  |  Size: 693 B

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M11,7h2v2h-2zM11,11h2v6h-2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
</vector>

View File

@ -41,13 +41,14 @@
android:id="@+id/resend_button"
android:layout_width="wrap_content"
android:layout_height="38sp"
style="@style/InfoButton"
style="@style/Widget.Session.Button.Common.ProminentOutline"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_gravity="center_vertical"
android:drawableStart="@drawable/ic_refresh_white_18dp"
android:drawableStart="@drawable/ic_baseline_refresh_24"
android:drawablePadding="4dp"
android:text="@string/message_recipients_list_item__resend"
android:visibility="gone"
tools:visibility="visible" />
@ -150,4 +151,11 @@
</TableLayout>
</LinearLayout>
<View
android:id="@+id/separator"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="?android:dividerHorizontal" />
</LinearLayout>

View File

@ -8,25 +8,21 @@
android:layout_height="wrap_content"
android:padding="16dp">
<org.thoughtcrime.securesms.components.AvatarImageView
android:id="@+id/contact_photo_image"
android:foreground="@drawable/contact_photo_background"
android:layout_width="40dp"
android:layout_height="40dp"
<org.thoughtcrime.securesms.loki.views.ProfilePictureView
android:id="@+id/profilePictureView"
android:layout_width="@dimen/medium_profile_picture_size"
android:layout_height="@dimen/medium_profile_picture_size"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:layout_marginEnd="10dp"
android:cropToPadding="true"
tools:src="@drawable/ic_contact_picture"
android:contentDescription="@string/SingleContactSelectionActivity_contact_photo" />
android:layout_marginEnd="10dp" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dip"
android:layout_marginBottom="4dip"
android:layout_toEndOf="@id/contact_photo_image"
android:layout_toEndOf="@id/profilePictureView"
android:layout_centerVertical="true"
android:gravity="center_vertical"
android:orientation="horizontal">

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- <item android:title="@string/conversation_context__menu_message_details"
<item android:title="@string/conversation_context__menu_message_details"
android:id="@+id/menu_context_details"
android:icon="?menu_info_icon"
app:showAsAction="always" /> -->
app:showAsAction="always" />
<item android:title="@string/conversation_context__menu_delete_message"
android:id="@+id/menu_context_delete_message"

View File

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Widget.Session.Button.Common.ProminentOutline">
<item name="android:background">@drawable/prominent_outline_button_medium_background</item>
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:drawableTint" tools:ignore="NewApi">?android:textColorPrimary</item>
</style>
<style name="Widget.Session.Button.Common.ProminentFilled">
<item name="android:background">@drawable/prominent_filled_button_medium_background</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:drawableTint" tools:ignore="NewApi">@android:color/white</item>
</style>
<style name="FakeChatViewMessageBubble.Incoming">

View File

@ -25,6 +25,8 @@
<item name="quick_camera_icon">@drawable/ic_outline_photo_camera_24</item>
<item name="media_keyboard_button_color">@color/core_grey_60</item>
<item name="menu_info_icon">@drawable/ic_outline_info_24</item>
</style>
<style name="Theme.Session.DayNight" parent="Theme.Session.Light">

View File

@ -113,6 +113,7 @@
<attr name="menu_block_icon" format="reference" />
<attr name="menu_photo_library_icon" format="reference" />
<attr name="menu_delete_icon" format="reference" />
<attr name="menu_info_icon" format="reference" />
<attr name="pref_icon_tint" format="color"/>

View File

@ -74,21 +74,25 @@
<style name="Widget.Session.Button.Common.ProminentFilled">
<item name="android:background">@drawable/prominent_filled_button_medium_background</item>
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:drawableTint" tools:ignore="NewApi">?android:textColorPrimary</item>
</style>
<style name="Widget.Session.Button.Common.ProminentOutline">
<item name="android:background">@drawable/prominent_outline_button_medium_background</item>
<item name="android:textColor">@color/accent</item>
<item name="android:drawableTint" tools:ignore="NewApi">@color/accent</item>
</style>
<style name="Widget.Session.Button.Common.UnimportantFilled">
<item name="android:background">@drawable/unimportant_filled_button_medium_background</item>
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:drawableTint" tools:ignore="NewApi">?android:textColorPrimary</item>
</style>
<style name="Widget.Session.Button.Common.UnimportantOutline">
<item name="android:background">@drawable/unimportant_outline_button_medium_background</item>
<item name="android:textColor">?android:textColorPrimary</item>
<item name="android:drawableTint" tools:ignore="NewApi">?android:textColorPrimary</item>
</style>
<style name="Widget.Session.Button.Dialog" parent="">

View File

@ -77,6 +77,7 @@
<item name="menu_selectall_icon">@drawable/ic_baseline_select_all_24</item>
<item name="menu_split_icon">@drawable/ic_baseline_call_split_24</item>
<item name="menu_popup_expand">@drawable/ic_baseline_launch_24</item>
<item name="menu_info_icon">@drawable/ic_baseline_info_24</item>
<item name="conversation_emoji_toggle">@drawable/ic_emoji_filled_keyboard_24</item>
<item name="conversation_sticker_toggle">@drawable/ic_sticker_filled_keyboard_24</item>

View File

@ -24,10 +24,6 @@ import android.database.Cursor;
import android.graphics.drawable.ColorDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.Loader;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@ -35,6 +31,11 @@ import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.Loader;
import org.thoughtcrime.securesms.MessageDetailsRecipientAdapter.RecipientDeliveryStatus;
import org.thoughtcrime.securesms.color.MaterialColor;
import org.thoughtcrime.securesms.conversation.ConversationItem;
@ -55,10 +56,10 @@ import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.DynamicLanguage;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.ExpirationUtil;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.loki.api.opengroups.PublicChat;
import java.lang.ref.WeakReference;
import java.sql.Date;
@ -97,17 +98,16 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
private View receivedContainer;
private TextView transport;
private TextView toFrom;
private View separator;
private ListView recipientsList;
private LayoutInflater inflater;
private DynamicTheme dynamicTheme = new DynamicTheme();
private DynamicLanguage dynamicLanguage = new DynamicLanguage();
private boolean running;
@Override
protected void onPreCreate() {
dynamicTheme.onCreate(this);
dynamicLanguage.onCreate(this);
}
@ -119,14 +119,12 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
initializeResources();
initializeActionBar();
getWindow().setNavigationBarColor(getResources().getColor(R.color.navigation_bar_background));
getSupportLoaderManager().initLoader(0, null, this);
}
@Override
protected void onResume() {
super.onResume();
dynamicTheme.onResume(this);
dynamicLanguage.onResume(this);
assert getSupportActionBar() != null;
@ -181,6 +179,7 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
receivedDate = header.findViewById(R.id.received_time);
transport = header.findViewById(R.id.transport);
toFrom = header.findViewById(R.id.tofrom);
separator = header.findViewById(R.id.separator);
expiresContainer = header.findViewById(R.id.expires_container);
expiresInText = header.findViewById(R.id.expires_in);
recipientsList.setHeaderDividersEnabled(false);
@ -266,6 +265,12 @@ public class MessageDetailsActivity extends PassphraseRequiredActionBarActivity
toFromRes = R.string.message_details_header__from;
}
toFrom.setText(toFromRes);
long threadID = messageRecord.getThreadId();
PublicChat openGroup = DatabaseFactory.getLokiThreadDatabase(this).getPublicChat(threadID);
if (openGroup != null && messageRecord.isOutgoing()) {
toFrom.setVisibility(View.GONE);
separator.setVisibility(View.GONE);
}
conversationItem.bind(messageRecord, Optional.absent(), Optional.absent(), glideRequests, dynamicLanguage.getCurrentLocale(), new HashSet<>(), recipient, null, false);
recipientsList.setAdapter(new MessageDetailsRecipientAdapter(this, glideRequests, messageRecord, recipients, isPushGroup));
}

View File

@ -1,14 +1,15 @@
package org.thoughtcrime.securesms;
import android.content.Context;
import androidx.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.database.model.MessageRecord;
import org.thoughtcrime.securesms.loki.views.UserView;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.Conversions;
@ -17,8 +18,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import network.loki.messenger.R;
class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.RecyclerListener {
private final Context context;
@ -59,14 +58,11 @@ class MessageDetailsRecipientAdapter extends BaseAdapter implements AbsListView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.message_recipient_list_item, parent, false);
}
RecipientDeliveryStatus member = members.get(position);
((MessageRecipientListItem)convertView).set(glideRequests, record, member, isPushGroup);
return convertView;
UserView result = new UserView(context);
Recipient recipient = members.get(position).getRecipient();
result.setOpenGroupThreadID(record.getThreadId());
result.bind(recipient, glideRequests, UserView.ActionIndicator.None, false);
return result;
}
@Override

View File

@ -103,8 +103,6 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
initializeResources();
initializeSearch();
initializeMedia();
getWindow().setNavigationBarColor(getResources().getColor(R.color.navigation_bar_background));
}
@Override

View File

@ -6,6 +6,7 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.provider.ContactsContract;
import androidx.annotation.NonNull;
@ -21,6 +22,7 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactColors;
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
import org.thoughtcrime.securesms.database.Address;
import org.thoughtcrime.securesms.loki.utilities.AvatarPlaceholderGenerator;
import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.recipients.Recipient;
@ -128,17 +130,21 @@ public class AvatarImageView extends AppCompatImageView {
requestManager.clear(this);
recipientContactPhoto = photo;
Drawable fallbackContactPhotoDrawable = photo.recipient.getFallbackContactPhotoDrawable(getContext(), inverted);
Drawable photoPlaceholderDrawable = AvatarPlaceholderGenerator.generate(
getContext(), 128, recipient.getAddress().serialize(), recipient.getName());
if (photo.contactPhoto != null) {
requestManager.load(photo.contactPhoto)
.fallback(fallbackContactPhotoDrawable)
.error(fallbackContactPhotoDrawable)
.fallback(photoPlaceholderDrawable)
.error(photoPlaceholderDrawable)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.circleCrop()
.into(this);
} else {
setImageDrawable(fallbackContactPhotoDrawable);
requestManager.load(photoPlaceholderDrawable)
.circleCrop()
.into(this);
// setImageDrawable(photoPlaceholderDrawable);
}
}
}

View File

@ -376,12 +376,14 @@ public class ConversationFragment extends Fragment
}
if (messageRecords.size() > 1) {
menu.findItem(R.id.menu_context_details).setVisible(false);
menu.findItem(R.id.menu_context_reply).setVisible(false);
menu.findItem(R.id.menu_context_save_attachment).setVisible(false);
menu.findItem(R.id.menu_context_resend).setVisible(false);
} else {
MessageRecord messageRecord = messageRecords.iterator().next();
menu.findItem(R.id.menu_context_details).setVisible(true);
menu.findItem(R.id.menu_context_resend).setVisible(messageRecord.isFailed());
menu.findItem(R.id.menu_context_save_attachment).setVisible(!actionMessage &&
messageRecord.isMms() &&
@ -1131,16 +1133,14 @@ public class ConversationFragment extends Fragment
handleDeleteMessages(getListAdapter().getSelectedItems());
actionMode.finish();
return true;
/*
case R.id.menu_context_details:
handleDisplayDetails(getSelectedMessageRecord());
actionMode.finish();
return true;
case R.id.menu_context_forward:
handleForwardMessage(getSelectedMessageRecord());
actionMode.finish();
return true;
*/
// case R.id.menu_context_forward:
// handleForwardMessage(getSelectedMessageRecord());
// actionMode.finish();
// return true;
case R.id.menu_context_resend:
handleResendMessage(getSelectedMessageRecord());
actionMode.finish();

View File

@ -793,7 +793,7 @@ public class ConversationItem extends LinearLayout
}
private void setContactPhoto(@NonNull Recipient recipient) {
if (messageRecord == null) return; // TODO: Figure out how this happens
if (messageRecord == null) { return; } // TODO: Figure out how this happens
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)bodyBubble.getLayoutParams();
int groupThreadMargin = (int)((12 * getResources().getDisplayMetrics().density) + getResources().getDimension(R.dimen.small_profile_picture_size));
int defaultMargin = 0;
@ -803,7 +803,7 @@ public class ConversationItem extends LinearLayout
boolean isRSSFeed = threadName != null && (threadName.equals("Loki News") || threadName.equals("Session Updates"));
layoutParams.setMarginStart((groupThread && !isRSSFeed) ? groupThreadMargin : defaultMargin);
bodyBubble.setLayoutParams(layoutParams);
if (profilePictureView == null) return;
if (profilePictureView == null) { return; }
String publicKey = recipient.getAddress().toString();
profilePictureView.setPublicKey(publicKey);
String displayName = recipient.getName();

View File

@ -15,6 +15,7 @@ object AvatarPlaceholderGenerator {
private const val EMPTY_LABEL = "0";
@JvmStatic
fun generate(context: Context, pixelSize: Int, hashString: String, displayName: String?): BitmapDrawable {
//TODO That should be replaced with a proper hash extraction code.
val hash: Long

View File

@ -96,7 +96,7 @@ class ProfilePictureView : RelativeLayout {
}
} else {
publicKey = recipient.address.toString()
displayName = recipient.name
displayName = getUserDisplayName(publicKey)
additionalPublicKey = null
isRSSFeed = false
}

View File

@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.recipients.Recipient
import org.whispersystems.signalservice.loki.protocol.mentions.MentionsManager
class UserView : LinearLayout {
var openGroupThreadID: Long = -1 // FIXME: This is a bit ugly
enum class ActionIndicator {
None,
@ -53,7 +54,12 @@ class UserView : LinearLayout {
if (publicKey == null || publicKey.isBlank()) {
return null
} else {
return DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey!!)
var result = DatabaseFactory.getLokiUserDatabase(context).getDisplayName(publicKey)
val publicChat = DatabaseFactory.getLokiThreadDatabase(context).getPublicChat(openGroupThreadID)
if (result == null && publicChat != null) {
result = DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(publicChat.id, publicKey)
}
return result
}
}
val address = user.address.serialize()
@ -84,7 +90,7 @@ class UserView : LinearLayout {
actionIndicatorImageView.setImageResource(R.drawable.ic_baseline_edit_24)
profilePictureView.glide = glide
profilePictureView.update()
nameTextView.text = user.name ?: "Unknown Contact"
nameTextView.text = getUserDisplayName(address)
when (actionIndicator) {
ActionIndicator.None -> {
actionIndicatorImageView.visibility = View.GONE

View File

@ -326,6 +326,6 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
? TextSecurePreferences.getMasterHexEncodedPublicKey(context)
: publicKey;
String displayName = recipient.getName();
return AvatarPlaceholderGenerator.INSTANCE.generate(context, 128, hepk, displayName);
return AvatarPlaceholderGenerator.generate(context, 128, hepk, displayName);
}
}