Redesign conversation and conversation preferences layouts

Remove avatars from conversation items unless in a group chat.

// FREEBIE
master
Moxie Marlinspike 2017-09-12 22:48:30 -07:00
parent 30916d8e19
commit 65124fd1f2
19 changed files with 253 additions and 181 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:startColor="#3A000000"
android:centerColor="#1D000000"
android:endColor="@android:color/transparent"/>
</shape>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:startColor="#26000000"
android:centerColor="#0C000000"
android:endColor="@android:color/transparent"/>
</shape>

View File

@ -1,52 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<org.thoughtcrime.securesms.ConversationTitleView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:gravity="center_vertical">
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center_vertical"
android:gravity="center_vertical">
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:transitionName="recipient_name"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
style="@style/TextSecure.TitleTextStyle"
tools:ignore="UnusedAttribute"/>
<ImageView android:id="@+id/up_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_arrow_back_white_24dp"
android:clickable="true"
android:layout_marginRight="15dp"
android:layout_marginEnd="15dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:visibility="visible"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<org.thoughtcrime.securesms.components.AvatarImageView
android:id="@+id/contact_photo_image"
android:foreground="@drawable/contact_photo_background"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_toRightOf="@id/up_button"
android:layout_toEndOf="@id/up_button"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:cropToPadding="true"
android:transitionName="contact_photo"
app:inverted="true"
tools:src="@drawable/ic_contact_picture"
android:contentDescription="@string/conversation_list_item_view__contact_photo_image"/>
<RelativeLayout android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/contact_photo_image"
android:layout_toEndOf="@id/contact_photo_image"
android:layout_centerVertical="true">
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:textSize="18dp"
android:transitionName="recipient_name"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:layout_gravity="center_vertical"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
style="@style/TextSecure.TitleTextStyle"
tools:ignore="UnusedAttribute"/>
<ImageView android:id="@+id/verified_indicator"
android:src="@drawable/ic_check_circle_white_18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_marginEnd="3dp"
android:layout_gravity="bottom"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@id/title"
android:alpha="0.7"
android:visibility="gone"/>
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:layout_gravity="center_vertical|start"
android:gravity="center_vertical"
android:textDirection="ltr"
tools:text="(123) 123-1234"
style="@style/TextSecure.SubtitleTextStyle"/>
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:layout_gravity="center_vertical|start"
android:gravity="center_vertical"
android:layout_toRightOf="@id/verified_indicator"
android:layout_toEndOf="@id/verified_indicator"
android:layout_below="@id/title"
android:textDirection="ltr"
android:textSize="13dp"
tools:text="(123) 123-1234"
style="@style/TextSecure.SubtitleTextStyle"/>
</LinearLayout>
</RelativeLayout>
</org.thoughtcrime.securesms.ConversationTitleView>

View File

@ -1,69 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"
xmlns:tools="http://schemas.android.com/tools">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="130dp"
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/TextSecure.LightActionBar">
android:layout_height="300dp"
android:background="@color/transparent">
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center_vertical">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<org.thoughtcrime.securesms.components.AvatarImageView
android:id="@+id/avatar"
android:foreground="@drawable/contact_photo_background"
android:layout_width="50dp"
android:layout_height="50dp"
android:cropToPadding="true"
app:inverted="true" />
<ImageView android:id="@+id/avatar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:background="@color/black"
android:transitionName="avatar"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"/>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp">
<View
android:layout_width="match_parent"
android:layout_height="88dp"
android:background="@drawable/recipient_preference_scrim_top"
app:layout_collapseMode="pin"/>
<org.thoughtcrime.securesms.components.emoji.EmojiTextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:transitionName="recipient_name"
style="@style/TextSecure.TitleTextStyle"
tools:ignore="UnusedAttribute" />
<View
android:layout_width="match_parent"
android:layout_height="98dp"
android:layout_gravity="bottom"
android:layout_alignBottom="@+id/image"
android:background="@drawable/recipient_preference_scrim_bottom"/>
<TextView android:id="@+id/blocked_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/recipient_preference_activity__blocked"
android:textSize="12sp"
android:textStyle="bold"
android:textColor="?recipient_preference_blocked"
android:textAllCaps="true"
android:background="@drawable/blocked_indicator_background"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_marginTop="2dp"
tools:ignore="UnusedAttribute" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/TextSecure.LightActionBar"
android:background="@color/transparent"
android:layout_marginTop="24dp"
app:layout_collapseMode="pin" >
</LinearLayout>
</android.support.v7.widget.Toolbar>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout android:id="@+id/preference_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout android:id="@+id/preference_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

View File

@ -13,7 +13,7 @@
<dimen name="transport_selection_popup_width">200sp</dimen>
<dimen name="transport_selection_popup_xoff">2dp</dimen>
<dimen name="transport_selection_popup_yoff">2dp</dimen>
<dimen name="contact_photo_target_size">64dp</dimen>
<dimen name="contact_photo_target_size">300dp</dimen>
<dimen name="contact_selection_photo_size">50dp</dimen>
<dimen name="thumbnail_max_size">230dp</dimen>
<dimen name="preference_fragment_padding_side">8dp</dimen>

View File

@ -1201,31 +1201,18 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
}
});
titleView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ConversationActivity.this, RecipientPreferenceActivity.class);
intent.putExtra(RecipientPreferenceActivity.ADDRESS_EXTRA, recipient.getAddress());
intent.putExtra(RecipientPreferenceActivity.CAN_HAVE_SAFETY_NUMBER_EXTRA,
isSecureText && !isSelfConversation());
titleView.setOnClickListener(v -> {
Intent intent = new Intent(ConversationActivity.this, RecipientPreferenceActivity.class);
intent.putExtra(RecipientPreferenceActivity.ADDRESS_EXTRA, recipient.getAddress());
intent.putExtra(RecipientPreferenceActivity.CAN_HAVE_SAFETY_NUMBER_EXTRA,
isSecureText && !isSelfConversation());
startActivitySceneTransition(intent, titleView.findViewById(R.id.title), "recipient_name");
}
startActivitySceneTransition(intent, titleView.findViewById(R.id.contact_photo_image), "avatar");
});
unblockButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
handleUnblock();
}
});
makeDefaultSmsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
handleMakeDefaultSms();
}
});
titleView.setOnBackClickedListener(view -> onBackPressed());
unblockButton.setOnClickListener(v -> handleUnblock());
makeDefaultSmsButton.setOnClickListener(v -> handleMakeDefaultSms());
composeText.setOnKeyListener(composeKeyPressedListener);
composeText.addTextChangedListener(composeKeyPressedListener);
@ -1243,7 +1230,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
}
protected void initializeActionBar() {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setCustomView(R.layout.conversation_title_view);
getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);

View File

@ -123,7 +123,7 @@ public class ConversationItem extends LinearLayout
private AlertView alertView;
private @NonNull Set<MessageRecord> batchSelected = new HashSet<>();
private @Nullable Recipient conversationRecipient;
private @NonNull Recipient conversationRecipient;
private @NonNull Stub<ThumbnailView> mediaThumbnailStub;
private @NonNull Stub<AudioView> audioViewStub;
private @NonNull Stub<DocumentView> documentViewStub;
@ -404,9 +404,14 @@ public class ConversationItem extends LinearLayout
}
}
private void setContactPhoto(Recipient recipient) {
if (! messageRecord.isOutgoing()) {
setContactPhotoForRecipient(recipient);
private void setContactPhoto(@NonNull Recipient recipient) {
if (contactPhoto == null) return;
if (messageRecord.isOutgoing() || !groupThread) {
contactPhoto.setVisibility(View.GONE);
} else {
contactPhoto.setAvatar(recipient, true);
contactPhoto.setVisibility(View.VISIBLE);
}
}
@ -547,15 +552,6 @@ public class ConversationItem extends LinearLayout
}
}
/// Helper Methods
private void setContactPhotoForRecipient(final Recipient recipient) {
if (contactPhoto == null) return;
contactPhoto.setAvatar(recipient, true);
contactPhoto.setVisibility(View.VISIBLE);
}
/// Event handlers
private void handleApproveIdentity() {
@ -570,15 +566,12 @@ public class ConversationItem extends LinearLayout
@Override
public void onModified(final Recipient modified) {
Util.runOnMain(new Runnable() {
@Override
public void run() {
setBubbleState(messageRecord, recipient);
setContactPhoto(recipient);
setGroupMessageStatus(messageRecord, recipient);
setAudioViewTint(messageRecord, conversationRecipient);
setDocumentViewTint(messageRecord, conversationRecipient);
}
Util.runOnMain(() -> {
setBubbleState(messageRecord, recipient);
setContactPhoto(recipient);
setGroupMessageStatus(messageRecord, recipient);
setAudioViewTint(messageRecord, conversationRecipient);
setDocumentViewTint(messageRecord, conversationRecipient);
});
}

View File

@ -1,24 +1,36 @@
package org.thoughtcrime.securesms;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.annimon.stream.Collectors;
import com.annimon.stream.Stream;
import org.thoughtcrime.securesms.components.AvatarImageView;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.ViewUtil;
public class ConversationTitleView extends LinearLayout {
import java.lang.ref.WeakReference;
public class ConversationTitleView extends RelativeLayout {
private static final String TAG = ConversationTitleView.class.getSimpleName();
private TextView title;
private TextView subtitle;
private ImageView verified;
private View content;
private ImageView back;
private AvatarImageView avatar;
private TextView title;
private TextView subtitle;
private ImageView verified;
public ConversationTitleView(Context context) {
this(context, null);
@ -33,9 +45,12 @@ public class ConversationTitleView extends LinearLayout {
public void onFinishInflate() {
super.onFinishInflate();
this.title = (TextView) findViewById(R.id.title);
this.subtitle = (TextView) findViewById(R.id.subtitle);
this.verified = (ImageView) findViewById(R.id.verified_indicator);
this.back = ViewUtil.findById(this, R.id.up_button);
this.content = ViewUtil.findById(this, R.id.content);
this.title = ViewUtil.findById(this, R.id.title);
this.subtitle = ViewUtil.findById(this, R.id.subtitle);
this.verified = ViewUtil.findById(this, R.id.verified_indicator);
this.avatar = ViewUtil.findById(this, R.id.contact_photo_image);
ViewUtil.setTextViewGravityStart(this.title, getContext());
ViewUtil.setTextViewGravityStart(this.subtitle, getContext());
@ -52,12 +67,25 @@ public class ConversationTitleView extends LinearLayout {
} else {
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
if (recipient != null) {
this.avatar.setAvatar(recipient, false);
}
}
public void setVerified(boolean verified) {
this.verified.setVisibility(verified ? View.VISIBLE : View.GONE);
}
@Override
public void setOnClickListener(@Nullable OnClickListener listener) {
this.content.setOnClickListener(listener);
}
public void setOnBackClickedListener(@Nullable OnClickListener listener) {
this.back.setOnClickListener(listener);
}
private void setComposeTitle() {
this.title.setText(R.string.ConversationActivity_compose_message);
this.subtitle.setText(null);
@ -71,9 +99,15 @@ public class ConversationTitleView extends LinearLayout {
}
private void setGroupRecipientTitle(Recipient recipient) {
String localNumber = TextSecurePreferences.getLocalNumber(getContext());
this.title.setText(recipient.getName());
this.subtitle.setText(null);
this.subtitle.setVisibility(View.GONE);
this.subtitle.setText(Stream.of(recipient.getParticipants())
.filter(r -> !r.getAddress().serialize().equals(localNumber))
.map(Recipient::toShortString)
.collect(Collectors.joining(",")));
this.subtitle.setVisibility(View.VISIBLE);
}
private void setNonContactRecipientTitle(Recipient recipient) {

View File

@ -5,30 +5,30 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v4.app.Fragment;
import android.support.v4.preference.PreferenceFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.view.WindowManager;
import android.widget.ImageView;
import org.thoughtcrime.securesms.color.MaterialColor;
import org.thoughtcrime.securesms.color.MaterialColors;
import org.thoughtcrime.securesms.components.AvatarImageView;
import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable;
import org.thoughtcrime.securesms.crypto.MasterSecret;
import org.thoughtcrime.securesms.database.Address;
@ -49,6 +49,7 @@ import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
import org.thoughtcrime.securesms.util.DynamicTheme;
import org.thoughtcrime.securesms.util.IdentityUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
import org.whispersystems.libsignal.util.guava.Optional;
@ -71,11 +72,9 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
private AvatarImageView avatar;
private Toolbar toolbar;
private TextView title;
private TextView blockedIndicator;
private BroadcastReceiver staleReceiver;
private ImageView avatar;
private CollapsingToolbarLayout toolbarLayout;
private BroadcastReceiver staleReceiver;
@Override
public void onPreCreate() {
@ -125,25 +124,35 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
super.onOptionsItemSelected(item);
switch (item.getItemId()) {
case android.R.id.home:
super.onBackPressed();
onBackPressed();
return true;
}
return false;
}
@Override
public void onBackPressed() {
finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
private void initializeToolbar() {
this.toolbar = (Toolbar) findViewById(R.id.toolbar);
this.toolbar.setLogo(null);
this.toolbarLayout = ViewUtil.findById(this, R.id.collapsing_toolbar);
this.avatar = ViewUtil.findById(this, R.id.avatar);
this.toolbarLayout.setExpandedTitleColor(getResources().getColor(R.color.white));
this.toolbarLayout.setCollapsedTitleTextColor(getResources().getColor(R.color.white));
Toolbar toolbar = ViewUtil.findById(this, R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setLogo(null);
this.avatar = (AvatarImageView) toolbar.findViewById(R.id.avatar);
this.title = (TextView) toolbar.findViewById(R.id.name);
this.blockedIndicator = (TextView) toolbar.findViewById(R.id.blocked_indicator);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
}
private void initializeReceivers() {
@ -163,27 +172,15 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
registerReceiver(staleReceiver, staleFilter);
}
private void setHeader(Recipient recipient) {
this.avatar.setAvatar(recipient, true);
this.title.setText(recipient.toShortString());
this.toolbar.setBackgroundColor(recipient.getColor().toActionBarColor(this));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(recipient.getColor().toStatusBarColor(this));
}
if (recipient.isBlocked()) this.blockedIndicator.setVisibility(View.VISIBLE);
else this.blockedIndicator.setVisibility(View.GONE);
private void setHeader(@NonNull Recipient recipient) {
this.avatar.setImageDrawable(recipient.getContactPhoto().asCallCard(this));
this.toolbarLayout.setTitle(recipient.toShortString());
this.toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(this));
}
@Override
public void onModified(final Recipient recipient) {
title.post(new Runnable() {
@Override
public void run() {
setHeader(recipient);
}
});
Util.runOnMain(() -> setHeader(recipient));
}
public static class RecipientPreferenceFragment