Add indicator for system contacts.

fork-5.53.8
Greyson Parrelli 2020-07-14 07:37:09 -07:00 zatwierdzone przez GitHub
rodzic 325e0c6781
commit d1b61bfed3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
10 zmienionych plików z 142 dodań i 21 usunięć

Wyświetl plik

@ -159,7 +159,7 @@ public class DirectoryHelper {
RegisteredState originalRegisteredState = recipient.resolve().getRegistered();
RegisteredState newRegisteredState = null;
if (recipient.getUuid().isPresent()) {
if (recipient.hasUuid() && !recipient.hasE164()) {
boolean isRegistered = isUuidRegistered(context, recipient);
if (isRegistered) {
recipientDatabase.markRegistered(recipient.getId(), recipient.getUuid().get());

Wyświetl plik

@ -54,15 +54,15 @@ public class ConversationTitleView extends RelativeLayout {
public void onFinishInflate() {
super.onFinishInflate();
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.subtitleContainer = ViewUtil.findById(this, R.id.subtitle_container);
this.verifiedSubtitle = ViewUtil.findById(this, R.id.verified_subtitle);
this.avatar = ViewUtil.findById(this, R.id.contact_photo_image);
this.expirationBadgeContainer = ViewUtil.findById(this, R.id.expiration_badge_container);
this.expirationBadgeTime = ViewUtil.findById(this, R.id.expiration_badge);
this.content = findViewById(R.id.content);
this.title = findViewById(R.id.title);
this.subtitle = findViewById(R.id.subtitle);
this.verified = findViewById(R.id.verified_indicator);
this.subtitleContainer = findViewById(R.id.subtitle_container);
this.verifiedSubtitle = findViewById(R.id.verified_subtitle);
this.avatar = findViewById(R.id.contact_photo_image);
this.expirationBadgeContainer = findViewById(R.id.expiration_badge_container);
this.expirationBadgeTime = findViewById(R.id.expiration_badge);
ViewUtil.setTextViewGravityStart(this.title, getContext());
ViewUtil.setTextViewGravityStart(this.subtitle, getContext());
@ -85,14 +85,22 @@ public class ConversationTitleView extends RelativeLayout {
if (recipient == null) setComposeTitle();
else setRecipientTitle(recipient);
int startDrawable = 0;
int endDrawable = 0;
if (recipient != null && recipient.isBlocked()) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_block_white_18dp, 0, 0, 0);
startDrawable = R.drawable.ic_block_white_18dp;
} else if (recipient != null && recipient.isMuted()) {
title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_volume_off_white_18dp, 0, 0, 0);
} else {
title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
startDrawable = R.drawable.ic_volume_off_white_18dp;
}
if (recipient != null && recipient.isSystemContact() && !recipient.isLocalNumber()) {
endDrawable = R.drawable.ic_profile_circle_outline_16;
}
title.setCompoundDrawablesRelativeWithIntrinsicBounds(startDrawable, 0, endDrawable, 0);
if (recipient != null) {
this.avatar.setAvatar(glideRequests, recipient, false);
}

Wyświetl plik

@ -44,6 +44,7 @@ import org.thoughtcrime.securesms.mms.GlideApp;
import org.thoughtcrime.securesms.notifications.NotificationChannels;
import org.thoughtcrime.securesms.profiles.edit.EditProfileActivity;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientExporter;
import org.thoughtcrime.securesms.recipients.RecipientId;
import org.thoughtcrime.securesms.recipients.ui.notifications.CustomNotificationsDialogFragment;
import org.thoughtcrime.securesms.util.DateUtils;
@ -58,13 +59,17 @@ public class ManageRecipientFragment extends LoggingFragment {
private static final String RECIPIENT_ID = "RECIPIENT_ID";
private static final String FROM_CONVERSATION = "FROM_CONVERSATION";
private static final int RETURN_FROM_MEDIA = 405;
private static final int REQUEST_CODE_RETURN_FROM_MEDIA = 405;
private static final int REQUEST_CODE_ADD_CONTACT = 588;
private ManageRecipientViewModel viewModel;
private GroupMemberListView sharedGroupList;
private Toolbar toolbar;
private TextView title;
private TextView subtitle;
private View contactRow;
private TextView contactText;
private ImageView contactIcon;
private AvatarImageView avatar;
private ThreadPhotoRailView threadPhotoRailView;
private View mediaCard;
@ -114,6 +119,9 @@ public class ManageRecipientFragment extends LoggingFragment {
avatar = view.findViewById(R.id.recipient_avatar);
toolbar = view.findViewById(R.id.toolbar);
contactRow = view.findViewById(R.id.recipient_contact_row);
contactText = view.findViewById(R.id.recipient_contact_text);
contactIcon = view.findViewById(R.id.recipient_contact_icon);
title = view.findViewById(R.id.name);
subtitle = view.findViewById(R.id.username_number);
sharedGroupList = view.findViewById(R.id.shared_group_list);
@ -182,6 +190,7 @@ public class ManageRecipientFragment extends LoggingFragment {
notificationsCard.setVisibility(View.GONE);
groupMembershipCard.setVisibility(View.GONE);
blockUnblockCard.setVisibility(View.GONE);
contactRow.setVisibility(View.GONE);
} else {
viewModel.getVisibleSharedGroups().observe(getViewLifecycleOwner(), members -> sharedGroupList.setMembers(members));
viewModel.getSharedGroupsCountSummary().observe(getViewLifecycleOwner(), members -> groupsInCommonCount.setText(members));
@ -246,12 +255,28 @@ public class ManageRecipientFragment extends LoggingFragment {
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RETURN_FROM_MEDIA) {
if (requestCode == REQUEST_CODE_RETURN_FROM_MEDIA) {
applyMediaCursorFactory();
} else if (requestCode == REQUEST_CODE_ADD_CONTACT) {
viewModel.onAddedToContacts();
}
}
private void presentRecipient(@NonNull Recipient recipient) {
if (recipient.isSystemContact()) {
contactText.setText(R.string.ManageRecipientActivity_this_person_is_in_your_contacts);
contactIcon.setVisibility(View.VISIBLE);
contactRow.setOnClickListener(v -> {
startActivity(new Intent(Intent.ACTION_VIEW, recipient.getContactUri()));
});
} else {
contactText.setText(R.string.ManageRecipientActivity_add_to_system_contacts);
contactIcon.setVisibility(View.GONE);
contactRow.setOnClickListener(v -> {
startActivityForResult(RecipientExporter.export(recipient).asAddContactIntent(), REQUEST_CODE_ADD_CONTACT);
});
}
disappearingMessagesCard.setVisibility(recipient.isRegistered() ? View.VISIBLE : View.GONE);
addToAGroup.setVisibility(recipient.isRegistered() ? View.VISIBLE : View.GONE);
@ -294,7 +319,7 @@ public class ManageRecipientFragment extends LoggingFragment {
startActivityForResult(MediaPreviewActivity.intentFromMediaRecord(requireContext(),
mediaRecord,
ViewCompat.getLayoutDirection(threadPhotoRailView) == ViewCompat.LAYOUT_DIRECTION_LTR),
RETURN_FROM_MEDIA));
REQUEST_CODE_RETURN_FROM_MEDIA));
}
private void presentMuteState(@NonNull ManageRecipientViewModel.MuteState muteState) {

Wyświetl plik

@ -10,10 +10,12 @@ import com.annimon.stream.Stream;
import org.thoughtcrime.securesms.color.MaterialColor;
import org.thoughtcrime.securesms.color.MaterialColors;
import org.thoughtcrime.securesms.contacts.sync.DirectoryHelper;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.GroupDatabase;
import org.thoughtcrime.securesms.database.IdentityDatabase;
import org.thoughtcrime.securesms.database.ThreadDatabase;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientId;
@ -21,11 +23,14 @@ import org.thoughtcrime.securesms.sms.MessageSender;
import org.thoughtcrime.securesms.util.concurrent.SignalExecutors;
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
final class ManageRecipientRepository {
private static final String TAG = Log.tag(ManageRecipientRepository.class);
private final Context context;
private final RecipientId recipientId;
@ -95,6 +100,16 @@ final class ManageRecipientRepository {
});
}
void refreshRecipient() {
SignalExecutors.UNBOUNDED.execute(() -> {
try {
DirectoryHelper.refreshDirectoryFor(context, Recipient.resolved(recipientId), false);
} catch (IOException e) {
Log.w(TAG, "Failed to refresh user after adding to contacts.");
}
});
}
@WorkerThread
@NonNull List<Recipient> getSharedGroups(@NonNull RecipientId recipientId) {
return Stream.of(DatabaseFactory.getGroupDatabase(context)

Wyświetl plik

@ -257,6 +257,10 @@ public final class ManageRecipientViewModel extends ViewModel {
withRecipient(r -> CommunicationActions.startVideoCall(activity, r));
}
void onAddedToContacts() {
manageRecipientRepository.refreshRecipient();
}
static final class MediaCursor {
private final long threadId;
@NonNull private final CursorFactory mediaCursorFactory;

Wyświetl plik

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="16dp"
android:height="16dp"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:fillColor="#FF000000"
android:pathData="M8,1a7,7 0,1 0,7 7A7,7 0,0 0,8 1ZM8,2.5A5.51,5.51 0,0 1,13.5 8a5.41,5.41 0,0 1,-0.9 3,4 4,0 0,0 -2.14,-0.95 4.43,4.43 0,0 0,0.79 -2.52A3.33,3.33 0,0 0,8 4,3.33 3.33,0 0,0 4.75,7.53a4.43,4.43 0,0 0,0.79 2.52A4,4 0,0 0,3.4 11a5.41,5.41 0,0 1,-0.9 -3A5.51,5.51 0,0 1,8 2.5ZM8,10c-0.9,0 -1.75,-1.2 -1.75,-2.47A1.84,1.84 0,0 1,8 5.5a1.84,1.84 0,0 1,1.75 2C9.75,8.8 8.9,10 8,10ZM4.37,12.12A2.48,2.48 0,0 1,6 11.5h4a2.48,2.48 0,0 1,1.63 0.62,5.46 5.46,0 0,1 -7.26,0Z"/>
</vector>

Wyświetl plik

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,1C9.8244,1 7.6977,1.6451 5.8887,2.8538C4.0798,4.0625 2.6699,5.7805 1.8373,7.7905C1.0048,9.8005 0.7869,12.0122 1.2114,14.146C1.6358,16.2798 2.6834,18.2398 4.2218,19.7782C5.7602,21.3166 7.7202,22.3642 9.854,22.7886C11.9878,23.2131 14.1995,22.9952 16.2095,22.1627C18.2195,21.3301 19.9375,19.9202 21.1462,18.1113C22.3549,16.3023 23,14.1756 23,12C23,9.0826 21.8411,6.2847 19.7782,4.2218C17.7153,2.1589 14.9174,1 12,1V1ZM12,2.5C13.762,2.4964 15.4902,2.9838 16.9906,3.9077C18.491,4.8315 19.7042,6.1552 20.4942,7.7302C21.2842,9.3052 21.6197,11.0692 21.4629,12.8242C21.3062,14.5793 20.6635,16.2559 19.607,17.666C19.0621,17.0096 18.383,16.4775 17.6152,16.1056C16.8474,15.7337 16.0089,15.5306 15.156,15.51C16.3543,14.1749 17.0118,12.441 17,10.647C17,7.333 14.761,5 12,5C9.239,5 7,7.333 7,10.647C6.9883,12.441 7.6457,14.1749 8.844,15.51C7.9911,15.5306 7.1526,15.7337 6.3848,16.1056C5.6171,16.4775 4.9379,17.0096 4.393,17.666C3.3365,16.2559 2.6938,14.5793 2.5371,12.8242C2.3804,11.0692 2.7158,9.3052 3.5058,7.7302C4.2958,6.1552 5.509,4.8315 7.0094,3.9077C8.5098,2.9838 10.238,2.4964 12,2.5V2.5ZM8.5,10.647C8.5,8.283 10.005,6.5 12,6.5C13.995,6.5 15.5,8.283 15.5,10.647C15.5,13.187 13.832,15.5 12,15.5C10.168,15.5 8.5,13.187 8.5,10.647ZM5.408,18.825C5.8222,18.261 6.363,17.802 6.9868,17.4851C7.6107,17.1681 8.3002,17.002 9,17H15C15.6998,17.002 16.3893,17.1681 17.0132,17.4851C17.637,17.802 18.1778,18.261 18.592,18.825C16.8264,20.5404 14.4617,21.4999 12,21.4999C9.5383,21.4999 7.1736,20.5404 5.408,18.825V18.825Z"
android:fillColor="#000000"/>
</vector>

Wyświetl plik

@ -39,13 +39,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:drawablePadding="5dp"
android:drawablePadding="3dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:transitionName="recipient_name"
android:drawableTint="@color/transparent_white_90"
tools:ignore="UnusedAttribute"
tools:text="Contact name" />
tools:text="J. Jonah Jameson" />
<LinearLayout
android:id="@+id/subtitle_container"

Wyświetl plik

@ -153,7 +153,7 @@
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.Signal.Body1.Bold"
tools:text="Rob Aneesh" />
tools:text="Gwen Stacy" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
@ -167,13 +167,61 @@
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:id="@+id/recipient_disappearing_messages_card"
android:id="@+id/recipient_contact_card"
style="@style/Widget.Signal.CardView.PreferenceRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/group_manage_fragment_card_vertical_padding"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="@+id/recipient_contact_row"
android:layout_width="match_parent"
android:layout_height="@dimen/group_manage_fragment_row_height"
android:background="?selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal">
<TextView
android:id="@+id/recipient_contact_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:gravity="center_vertical|start"
android:paddingStart="@dimen/group_manage_fragment_row_horizontal_padding"
android:paddingEnd="@dimen/group_manage_fragment_row_horizontal_padding"
android:text="@string/ManageRecipientActivity_this_person_is_in_your_contacts"
android:textAlignment="viewStart"
android:textAppearance="@style/Signal.Text.Body" />
<ImageView
android:id="@+id/recipient_contact_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:minWidth="48dp"
android:paddingStart="@dimen/group_manage_fragment_row_horizontal_padding"
android:paddingEnd="@dimen/group_manage_fragment_row_horizontal_padding"
android:textAppearance="@style/Signal.Text.Body"
android:textColor="@color/ultramarine_text_button"
android:tint="?colorAccent"
app:srcCompat="@drawable/ic_profile_circle_outline_24"
tools:text="Off" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/recipient_disappearing_messages_card"
style="@style/Widget.Signal.CardView.PreferenceRow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/group_manage_fragment_card_vertical_padding"
app:layout_constraintTop_toBottomOf="@id/recipient_contact_card">
<LinearLayout
android:id="@+id/disappearing_messages_row"
android:layout_width="match_parent"

Wyświetl plik

@ -544,6 +544,8 @@
<!-- ManageRecipientActivity -->
<string name="ManageRecipientActivity_add_to_system_contacts">Add to system contacts</string>
<string name="ManageRecipientActivity_this_person_is_in_your_contacts">This person is in your contacts</string>
<string name="ManageRecipientActivity_disappearing_messages">Disappearing messages</string>
<string name="ManageRecipientActivity_chat_color">Chat color</string>
<string name="ManageRecipientActivity_block">Block</string>