Fix conversation title view

This commit is contained in:
Niels Andriesse 2020-01-17 10:37:06 +11:00
parent ec2691a918
commit a2f1eb67f9
6 changed files with 61 additions and 15 deletions

View File

@ -38,6 +38,19 @@
android:textSize="@dimen/large_font_size" android:textSize="@dimen/large_font_size"
android:fontFamily="sans-serif-medium" /> android:fontFamily="sans-serif-medium" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/muteIndicatorImageView"
android:layout_width="12dp"
android:layout_height="12dp"
android:src="@drawable/ic_mute"
android:layout_marginRight="4dp"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/subtitleTextView" android:id="@+id/subtitleTextView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -48,6 +61,8 @@
</LinearLayout> </LinearLayout>
</LinearLayout>
<View <View
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"

View File

@ -14,9 +14,10 @@
<TextView android:id="@+id/no_documents" <TextView android:id="@+id/no_documents"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:textSize="24sp" android:textSize="@dimen/medium_font_size"
android:gravity="center" android:gravity="center"
android:visibility="gone" android:visibility="gone"
android:textColor="@color/text"
android:text="@string/media_overview_documents_fragment__no_documents_found" /> android:text="@string/media_overview_documents_fragment__no_documents_found" />
</RelativeLayout> </RelativeLayout>

View File

@ -14,8 +14,9 @@
<TextView android:id="@+id/no_images" <TextView android:id="@+id/no_images"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:textSize="24sp" android:textSize="@dimen/medium_font_size"
android:gravity="center" android:gravity="center"
android:textColor="@color/text"
android:visibility="gone" android:visibility="gone"
android:text="@string/media_overview_activity__no_media" /> android:text="@string/media_overview_activity__no_media" />

View File

@ -70,6 +70,7 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -159,10 +160,10 @@ import org.thoughtcrime.securesms.loki.LokiMessageDatabase;
import org.thoughtcrime.securesms.loki.LokiThreadDatabase; import org.thoughtcrime.securesms.loki.LokiThreadDatabase;
import org.thoughtcrime.securesms.loki.LokiThreadDatabaseDelegate; import org.thoughtcrime.securesms.loki.LokiThreadDatabaseDelegate;
import org.thoughtcrime.securesms.loki.LokiUserDatabase; import org.thoughtcrime.securesms.loki.LokiUserDatabase;
import org.thoughtcrime.securesms.loki.redesign.views.MentionCandidateSelectionView;
import org.thoughtcrime.securesms.loki.MultiDeviceUtilities; import org.thoughtcrime.securesms.loki.MultiDeviceUtilities;
import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity; import org.thoughtcrime.securesms.loki.redesign.activities.HomeActivity;
import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestViewDelegate; import org.thoughtcrime.securesms.loki.redesign.views.FriendRequestViewDelegate;
import org.thoughtcrime.securesms.loki.redesign.views.MentionCandidateSelectionView;
import org.thoughtcrime.securesms.mediasend.Media; import org.thoughtcrime.securesms.mediasend.Media;
import org.thoughtcrime.securesms.mediasend.MediaSendActivity; import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
import org.thoughtcrime.securesms.mms.AttachmentManager; import org.thoughtcrime.securesms.mms.AttachmentManager;
@ -208,6 +209,7 @@ import org.thoughtcrime.securesms.stickers.StickerPackInstallEvent;
import org.thoughtcrime.securesms.stickers.StickerSearchRepository; import org.thoughtcrime.securesms.stickers.StickerSearchRepository;
import org.thoughtcrime.securesms.util.BitmapUtil; import org.thoughtcrime.securesms.util.BitmapUtil;
import org.thoughtcrime.securesms.util.CommunicationActions; import org.thoughtcrime.securesms.util.CommunicationActions;
import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.Dialogs; import org.thoughtcrime.securesms.util.Dialogs;
import org.thoughtcrime.securesms.util.DirectoryHelper; import org.thoughtcrime.securesms.util.DirectoryHelper;
import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicLanguage;
@ -229,6 +231,7 @@ import org.whispersystems.libsignal.InvalidMessageException;
import org.whispersystems.libsignal.util.guava.Optional; import org.whispersystems.libsignal.util.guava.Optional;
import org.whispersystems.signalservice.loki.api.LokiAPI; import org.whispersystems.signalservice.loki.api.LokiAPI;
import org.whispersystems.signalservice.loki.api.LokiStorageAPI; import org.whispersystems.signalservice.loki.api.LokiStorageAPI;
import org.whispersystems.signalservice.loki.api.PairingAuthorisation;
import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus; import org.whispersystems.signalservice.loki.messaging.LokiMessageFriendRequestStatus;
import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus; import org.whispersystems.signalservice.loki.messaging.LokiThreadFriendRequestStatus;
import org.whispersystems.signalservice.loki.messaging.Mention; import org.whispersystems.signalservice.loki.messaging.Mention;
@ -238,6 +241,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -320,6 +324,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
private ConversationSearchBottomBar searchNav; private ConversationSearchBottomBar searchNav;
private MenuItem searchViewItem; private MenuItem searchViewItem;
private ProgressBar messageStatusProgressBar; private ProgressBar messageStatusProgressBar;
private ImageView muteIndicatorImageView;
private TextView actionBarSubtitleTextView; private TextView actionBarSubtitleTextView;
private AttachmentTypeSelector attachmentTypeSelector; private AttachmentTypeSelector attachmentTypeSelector;
@ -511,6 +516,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
composeText.setTransport(sendButton.getSelectedTransport()); composeText.setTransport(sendButton.getSelectedTransport());
updateTitleTextView(glideRequests, recipient); updateTitleTextView(glideRequests, recipient);
updateSubtitleTextView();
setActionBarColor(recipient.getColor()); setActionBarColor(recipient.getColor());
setBlockedUserState(recipient, isSecureText, isDefaultSms); setBlockedUserState(recipient, isSecureText, isDefaultSms);
setGroupShareProfileReminder(recipient); setGroupShareProfileReminder(recipient);
@ -601,6 +607,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
recipient = Recipient.from(this, data.getParcelableExtra(GroupCreateActivity.GROUP_ADDRESS_EXTRA), true); recipient = Recipient.from(this, data.getParcelableExtra(GroupCreateActivity.GROUP_ADDRESS_EXTRA), true);
recipient.addListener(this); recipient.addListener(this);
updateTitleTextView(glideRequests, recipient); updateTitleTextView(glideRequests, recipient);
updateSubtitleTextView();
NotificationChannels.updateContactChannelName(this, recipient); NotificationChannels.updateContactChannelName(this, recipient);
setBlockedUserState(recipient, isSecureText, isDefaultSms); setBlockedUserState(recipient, isSecureText, isDefaultSms);
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
@ -1622,6 +1629,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
mentionCandidateSelectionViewContainer = ViewUtil.findById(this, R.id.mentionCandidateSelectionViewContainer); mentionCandidateSelectionViewContainer = ViewUtil.findById(this, R.id.mentionCandidateSelectionViewContainer);
mentionCandidateSelectionView = ViewUtil.findById(this, R.id.userSelectionView); mentionCandidateSelectionView = ViewUtil.findById(this, R.id.userSelectionView);
messageStatusProgressBar = ViewUtil.findById(this, R.id.messageStatusProgressBar); messageStatusProgressBar = ViewUtil.findById(this, R.id.messageStatusProgressBar);
muteIndicatorImageView = ViewUtil.findById(this, R.id.muteIndicatorImageView);
actionBarSubtitleTextView = ViewUtil.findById(this, R.id.subtitleTextView); actionBarSubtitleTextView = ViewUtil.findById(this, R.id.subtitleTextView);
ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle); ImageButton quickCameraToggle = ViewUtil.findById(this, R.id.quick_camera_toggle);
@ -1814,6 +1822,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
Util.runOnMain(() -> { Util.runOnMain(() -> {
Log.i(TAG, "onModifiedRun(): " + recipient.getRegistered()); Log.i(TAG, "onModifiedRun(): " + recipient.getRegistered());
updateTitleTextView(glideRequests, recipient); updateTitleTextView(glideRequests, recipient);
updateSubtitleTextView();
// titleView.setVerified(identityRecords.isVerified()); // titleView.setVerified(identityRecords.isVerified());
setBlockedUserState(recipient, isSecureText, isDefaultSms); setBlockedUserState(recipient, isSecureText, isDefaultSms);
setActionBarColor(recipient.getColor()); setActionBarColor(recipient.getColor());
@ -3090,10 +3099,26 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
// region Loki // region Loki
private void updateTitleTextView(GlideRequests glide, Recipient recipient) { private void updateTitleTextView(GlideRequests glide, Recipient recipient) {
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(this);
List<PairingAuthorisation> deviceLinks = DatabaseFactory.getLokiAPIDatabase(this).getPairingAuthorisations(userHexEncodedPublicKey);
HashSet<String> userLinkedDeviceHexEncodedPublicKeys = new HashSet<>();
for (PairingAuthorisation deviceLink : deviceLinks) {
userLinkedDeviceHexEncodedPublicKeys.add(deviceLink.getPrimaryDevicePublicKey().toLowerCase());
userLinkedDeviceHexEncodedPublicKeys.add(deviceLink.getSecondaryDevicePublicKey().toLowerCase());
}
userLinkedDeviceHexEncodedPublicKeys.add(userHexEncodedPublicKey.toLowerCase());
if (recipient == null) {
titleTextView.setText("Compose");
} else if (userLinkedDeviceHexEncodedPublicKeys.contains(recipient.getAddress().toString().toLowerCase())) {
titleTextView.setText("Note to Self");
} else {
titleTextView.setText(recipient.getName());
}
} }
private void updateSubtitleTextView() { private void updateSubtitleTextView() {
muteIndicatorImageView.setVisibility(View.GONE);
actionBarSubtitleTextView.setVisibility(View.VISIBLE);
if (messageStatus != null) { if (messageStatus != null) {
switch (messageStatus) { switch (messageStatus) {
case "calculatingPoW": actionBarSubtitleTextView.setText("Encrypting message"); break; case "calculatingPoW": actionBarSubtitleTextView.setText("Encrypting message"); break;
@ -3102,8 +3127,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
case "messageSent": actionBarSubtitleTextView.setText("Message sent securely"); break; case "messageSent": actionBarSubtitleTextView.setText("Message sent securely"); break;
case "messageFailed": actionBarSubtitleTextView.setText("Message failed to send"); break; case "messageFailed": actionBarSubtitleTextView.setText("Message failed to send"); break;
} }
} else { } else if (recipient.isGroupRecipient()) {
actionBarSubtitleTextView.setText("26 members"); actionBarSubtitleTextView.setText("26 members");
} else if (recipient.isMuted()) {
muteIndicatorImageView.setVisibility(View.VISIBLE);
actionBarSubtitleTextView.setText("Muted until " + DateUtils.getFormattedDateTime(recipient.mutedUntil, "EEE, MMM d, yyyy HH:mm", Locale.getDefault()));
} else {
actionBarSubtitleTextView.setVisibility(View.GONE);
} }
} }

View File

@ -84,7 +84,7 @@ public class Recipient implements RecipientModifiedListener {
private Uri contactUri; private Uri contactUri;
private @Nullable Uri messageRingtone = null; private @Nullable Uri messageRingtone = null;
private @Nullable Uri callRingtone = null; private @Nullable Uri callRingtone = null;
private long mutedUntil = 0; public long mutedUntil = 0;
private boolean blocked = false; private boolean blocked = false;
private VibrateState messageVibrate = VibrateState.DEFAULT; private VibrateState messageVibrate = VibrateState.DEFAULT;
private VibrateState callVibrate = VibrateState.DEFAULT; private VibrateState callVibrate = VibrateState.DEFAULT;

View File

@ -17,17 +17,16 @@
package org.thoughtcrime.securesms.util; package org.thoughtcrime.securesms.util;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import network.loki.messenger.R;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import network.loki.messenger.R;
/** /**
* Utility methods to help display dates in a nice, easily readable way. * Utility methods to help display dates in a nice, easily readable way.
*/ */
@ -49,7 +48,7 @@ public class DateUtils extends android.text.format.DateUtils {
return (int) to.convert(System.currentTimeMillis() - millis, TimeUnit.MILLISECONDS); return (int) to.convert(System.currentTimeMillis() - millis, TimeUnit.MILLISECONDS);
} }
private static String getFormattedDateTime(long time, String template, Locale locale) { public static String getFormattedDateTime(long time, String template, Locale locale) {
final String localizedPattern = getLocalizedPattern(template, locale); final String localizedPattern = getLocalizedPattern(template, locale);
return new SimpleDateFormat(localizedPattern, locale).format(new Date(time)); return new SimpleDateFormat(localizedPattern, locale).format(new Date(time));
} }