Add MMS info to conversation settings.

master
Cody Henthorne 2020-09-21 11:20:10 -04:00 committed by Greyson Parrelli
parent 97b7b4a501
commit e3338dc3ff
5 changed files with 77 additions and 32 deletions

View File

@ -23,6 +23,7 @@ import androidx.lifecycle.ViewModelProviders;
import com.google.android.material.snackbar.Snackbar;
import org.thoughtcrime.securesms.AvatarPreviewActivity;
import org.thoughtcrime.securesms.InviteActivity;
import org.thoughtcrime.securesms.LoggingFragment;
import org.thoughtcrime.securesms.MainActivity;
import org.thoughtcrime.securesms.MediaPreviewActivity;
@ -78,7 +79,7 @@ public class ManageGroupFragment extends LoggingFragment {
private TextView pendingAndRequestingCount;
private Toolbar toolbar;
private TextView groupName;
private LearnMoreTextView groupV1Indicator;
private LearnMoreTextView groupInfoText;
private TextView memberCountUnderAvatar;
private TextView memberCountAboveList;
private AvatarImageView avatar;
@ -139,7 +140,7 @@ public class ManageGroupFragment extends LoggingFragment {
avatar = view.findViewById(R.id.group_avatar);
toolbar = view.findViewById(R.id.toolbar);
groupName = view.findViewById(R.id.name);
groupV1Indicator = view.findViewById(R.id.manage_group_group_v1_indicator);
groupInfoText = view.findViewById(R.id.manage_group_info_text);
memberCountUnderAvatar = view.findViewById(R.id.member_count);
memberCountAboveList = view.findViewById(R.id.member_count_2);
groupMemberList = view.findViewById(R.id.group_members);
@ -176,9 +177,6 @@ public class ManageGroupFragment extends LoggingFragment {
groupLinkRow = view.findViewById(R.id.group_link_row);
groupLinkButton = view.findViewById(R.id.group_link_button);
groupV1Indicator.setOnLinkClickListener(v -> GroupsLearnMoreBottomSheetDialogFragment.show(requireFragmentManager()));
groupV1Indicator.setLearnMoreVisible(true);
return view;
}
@ -249,7 +247,6 @@ public class ManageGroupFragment extends LoggingFragment {
viewModel.getTitle().observe(getViewLifecycleOwner(), groupName::setText);
viewModel.getMemberCountSummary().observe(getViewLifecycleOwner(), memberCountUnderAvatar::setText);
viewModel.getShowLegacyIndicator().observe(getViewLifecycleOwner(), showLegacyIndicators -> groupV1Indicator.setVisibility(showLegacyIndicators ? View.VISIBLE : View.GONE));
viewModel.getFullMemberCountSummary().observe(getViewLifecycleOwner(), memberCountAboveList::setText);
viewModel.getGroupRecipient().observe(getViewLifecycleOwner(), groupRecipient -> {
avatar.setRecipient(groupRecipient);
@ -376,6 +373,26 @@ public class ManageGroupFragment extends LoggingFragment {
blockGroup.setVisibility(canBlock ? View.VISIBLE : View.GONE);
unblockGroup.setVisibility(canBlock ? View.GONE : View.VISIBLE);
});
viewModel.getGroupInfoMessage().observe(getViewLifecycleOwner(), message -> {
switch (message) {
case LEGACY_GROUP_LEARN_MORE:
groupInfoText.setText(R.string.ManageGroupActivity_legacy_group_learn_more);
groupInfoText.setOnLinkClickListener(v -> GroupsLearnMoreBottomSheetDialogFragment.show(requireFragmentManager()));
groupInfoText.setLearnMoreVisible(true);
groupInfoText.setVisibility(View.VISIBLE);
break;
case MMS_WARNING:
groupInfoText.setText(R.string.ManageGroupActivity_this_is_an_insecure_mms_group);
groupInfoText.setOnLinkClickListener(v -> startActivity(new Intent(requireContext(), InviteActivity.class)));
groupInfoText.setLearnMoreVisible(true, R.string.ManageGroupActivity_invite_now);
groupInfoText.setVisibility(View.VISIBLE);
break;
default:
groupInfoText.setVisibility(View.GONE);
break;
}
});
}
private static int booleanToOnOff(boolean isOn) {

View File

@ -80,6 +80,7 @@ public class ManageGroupViewModel extends ViewModel {
private final LiveData<Boolean> showLegacyIndicator;
private final LiveData<String> mentionSetting;
private final LiveData<Boolean> groupLinkOn;
private final LiveData<GroupInfoMessage> groupInfoMessage;
private ManageGroupViewModel(@NonNull Context context, @NonNull ManageGroupRepository manageGroupRepository) {
this.context = context;
@ -123,6 +124,16 @@ public class ManageGroupViewModel extends ViewModel {
this.mentionSetting = Transformations.distinctUntilChanged(Transformations.map(this.groupRecipient,
recipient -> MentionUtil.getMentionSettingDisplayValue(context, recipient.getMentionSetting())));
this.groupLinkOn = Transformations.map(liveGroup.getGroupLink(), GroupLinkUrlAndStatus::isEnabled);
this.groupInfoMessage = Transformations.map(this.showLegacyIndicator,
showLegacyInfo -> {
if (showLegacyInfo) {
return GroupInfoMessage.LEGACY_GROUP_LEARN_MORE;
} else if (groupId.isMms()) {
return GroupInfoMessage.MMS_WARNING;
} else {
return GroupInfoMessage.NONE;
}
});
}
@WorkerThread
@ -152,10 +163,6 @@ public class ManageGroupViewModel extends ViewModel {
return fullMemberCountSummary;
}
LiveData<Boolean> getShowLegacyIndicator() {
return showLegacyIndicator;
}
LiveData<Recipient> getGroupRecipient() {
return groupRecipient;
}
@ -228,6 +235,10 @@ public class ManageGroupViewModel extends ViewModel {
return groupLinkOn;
}
LiveData<GroupInfoMessage> getGroupInfoMessage() {
return groupInfoMessage;
}
void handleExpirationSelection() {
manageGroupRepository.getRecipient(groupRecipient ->
ExpirationDialog.show(context,
@ -397,6 +408,12 @@ public class ManageGroupViewModel extends ViewModel {
}
}
enum GroupInfoMessage {
NONE,
LEGACY_GROUP_LEARN_MORE,
MMS_WARNING
}
private enum CollapseState {
OPEN,
COLLAPSED

View File

@ -14,6 +14,7 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.widget.AppCompatTextView;
import org.thoughtcrime.securesms.R;
@ -38,26 +39,7 @@ public class LearnMoreTextView extends AppCompatTextView {
private void init() {
setMovementMethod(LinkMovementMethod.getInstance());
ClickableSpan clickable = new ClickableSpan() {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
ds.setColor(ThemeUtil.getThemedColor(getContext(), R.attr.colorAccent));
}
@Override
public void onClick(@NonNull View widget) {
if (linkListener != null) {
linkListener.onClick(widget);
}
}
};
link = new SpannableString(getContext().getString(R.string.LearnMoreTextView_learn_more));
link.setSpan(clickable, 0, link.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
setLinkTextInternal(R.string.LearnMoreTextView_learn_more);
visible = true;
}
@ -81,6 +63,33 @@ public class LearnMoreTextView extends AppCompatTextView {
setTextInternal(baseText, visible ? BufferType.SPANNABLE : BufferType.NORMAL);
}
public void setLearnMoreVisible(boolean visible, @StringRes int linkText) {
setLinkTextInternal(linkText);
this.visible = visible;
setTextInternal(baseText, visible ? BufferType.SPANNABLE : BufferType.NORMAL);
}
private void setLinkTextInternal(@StringRes int linkText) {
ClickableSpan clickable = new ClickableSpan() {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
ds.setColor(ThemeUtil.getThemedColor(getContext(), R.attr.colorAccent));
}
@Override
public void onClick(@NonNull View widget) {
if (linkListener != null) {
linkListener.onClick(widget);
}
}
};
link = new SpannableString(getContext().getString(linkText));
link.setSpan(clickable, 0, link.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
private void setTextInternal(CharSequence text, BufferType type) {
if (visible) {
SpannableStringBuilder builder = new SpannableStringBuilder();

View File

@ -55,7 +55,7 @@
tools:text="12 members (4 invited)" />
<org.thoughtcrime.securesms.util.views.LearnMoreTextView
android:id="@+id/manage_group_group_v1_indicator"
android:id="@+id/manage_group_info_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
@ -66,10 +66,10 @@
android:paddingTop="10dp"
android:paddingEnd="12dp"
android:paddingBottom="10dp"
android:text="@string/ManageGroupActivity_legacy_group_learn_more"
android:textAppearance="@style/TextAppearance.Signal.Caption"
android:textColor="?title_text_color_secondary"
android:visibility="gone"
tools:text="@string/ManageGroupActivity_legacy_group_learn_more"
tools:visibility="visible" />
</LinearLayout>

View File

@ -623,6 +623,8 @@
<string name="ManageGroupActivity_edit_name_and_picture">Edit name and picture</string>
<string name="ManageGroupActivity_legacy_group">Legacy Group</string>
<string name="ManageGroupActivity_legacy_group_learn_more">This is a Legacy Group. To access features like group admins, create a New Group.</string>
<string name="ManageGroupActivity_this_is_an_insecure_mms_group">This is an insecure MMS Group. To chat privately and access features like group names, invite your contacts to Signal.</string>
<string name="ManageGroupActivity_invite_now">Invite now</string>
<!-- GroupMentionSettingDialog -->
<string name="GroupMentionSettingDialog_notify_me_for_mentions">Notify me for Mentions</string>