mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-24 08:08:43 +00:00
Redesign conversation and conversation preferences layouts
Remove avatars from conversation items unless in a group chat. // FREEBIE
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user