Add MMS info to conversation settings.
parent
97b7b4a501
commit
e3338dc3ff
|
@ -23,6 +23,7 @@ import androidx.lifecycle.ViewModelProviders;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.AvatarPreviewActivity;
|
import org.thoughtcrime.securesms.AvatarPreviewActivity;
|
||||||
|
import org.thoughtcrime.securesms.InviteActivity;
|
||||||
import org.thoughtcrime.securesms.LoggingFragment;
|
import org.thoughtcrime.securesms.LoggingFragment;
|
||||||
import org.thoughtcrime.securesms.MainActivity;
|
import org.thoughtcrime.securesms.MainActivity;
|
||||||
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
||||||
|
@ -78,7 +79,7 @@ public class ManageGroupFragment extends LoggingFragment {
|
||||||
private TextView pendingAndRequestingCount;
|
private TextView pendingAndRequestingCount;
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
private TextView groupName;
|
private TextView groupName;
|
||||||
private LearnMoreTextView groupV1Indicator;
|
private LearnMoreTextView groupInfoText;
|
||||||
private TextView memberCountUnderAvatar;
|
private TextView memberCountUnderAvatar;
|
||||||
private TextView memberCountAboveList;
|
private TextView memberCountAboveList;
|
||||||
private AvatarImageView avatar;
|
private AvatarImageView avatar;
|
||||||
|
@ -139,7 +140,7 @@ public class ManageGroupFragment extends LoggingFragment {
|
||||||
avatar = view.findViewById(R.id.group_avatar);
|
avatar = view.findViewById(R.id.group_avatar);
|
||||||
toolbar = view.findViewById(R.id.toolbar);
|
toolbar = view.findViewById(R.id.toolbar);
|
||||||
groupName = view.findViewById(R.id.name);
|
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);
|
memberCountUnderAvatar = view.findViewById(R.id.member_count);
|
||||||
memberCountAboveList = view.findViewById(R.id.member_count_2);
|
memberCountAboveList = view.findViewById(R.id.member_count_2);
|
||||||
groupMemberList = view.findViewById(R.id.group_members);
|
groupMemberList = view.findViewById(R.id.group_members);
|
||||||
|
@ -176,9 +177,6 @@ public class ManageGroupFragment extends LoggingFragment {
|
||||||
groupLinkRow = view.findViewById(R.id.group_link_row);
|
groupLinkRow = view.findViewById(R.id.group_link_row);
|
||||||
groupLinkButton = view.findViewById(R.id.group_link_button);
|
groupLinkButton = view.findViewById(R.id.group_link_button);
|
||||||
|
|
||||||
groupV1Indicator.setOnLinkClickListener(v -> GroupsLearnMoreBottomSheetDialogFragment.show(requireFragmentManager()));
|
|
||||||
groupV1Indicator.setLearnMoreVisible(true);
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +247,6 @@ public class ManageGroupFragment extends LoggingFragment {
|
||||||
|
|
||||||
viewModel.getTitle().observe(getViewLifecycleOwner(), groupName::setText);
|
viewModel.getTitle().observe(getViewLifecycleOwner(), groupName::setText);
|
||||||
viewModel.getMemberCountSummary().observe(getViewLifecycleOwner(), memberCountUnderAvatar::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.getFullMemberCountSummary().observe(getViewLifecycleOwner(), memberCountAboveList::setText);
|
||||||
viewModel.getGroupRecipient().observe(getViewLifecycleOwner(), groupRecipient -> {
|
viewModel.getGroupRecipient().observe(getViewLifecycleOwner(), groupRecipient -> {
|
||||||
avatar.setRecipient(groupRecipient);
|
avatar.setRecipient(groupRecipient);
|
||||||
|
@ -376,6 +373,26 @@ public class ManageGroupFragment extends LoggingFragment {
|
||||||
blockGroup.setVisibility(canBlock ? View.VISIBLE : View.GONE);
|
blockGroup.setVisibility(canBlock ? View.VISIBLE : View.GONE);
|
||||||
unblockGroup.setVisibility(canBlock ? View.GONE : View.VISIBLE);
|
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) {
|
private static int booleanToOnOff(boolean isOn) {
|
||||||
|
|
|
@ -80,6 +80,7 @@ public class ManageGroupViewModel extends ViewModel {
|
||||||
private final LiveData<Boolean> showLegacyIndicator;
|
private final LiveData<Boolean> showLegacyIndicator;
|
||||||
private final LiveData<String> mentionSetting;
|
private final LiveData<String> mentionSetting;
|
||||||
private final LiveData<Boolean> groupLinkOn;
|
private final LiveData<Boolean> groupLinkOn;
|
||||||
|
private final LiveData<GroupInfoMessage> groupInfoMessage;
|
||||||
|
|
||||||
private ManageGroupViewModel(@NonNull Context context, @NonNull ManageGroupRepository manageGroupRepository) {
|
private ManageGroupViewModel(@NonNull Context context, @NonNull ManageGroupRepository manageGroupRepository) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -123,6 +124,16 @@ public class ManageGroupViewModel extends ViewModel {
|
||||||
this.mentionSetting = Transformations.distinctUntilChanged(Transformations.map(this.groupRecipient,
|
this.mentionSetting = Transformations.distinctUntilChanged(Transformations.map(this.groupRecipient,
|
||||||
recipient -> MentionUtil.getMentionSettingDisplayValue(context, recipient.getMentionSetting())));
|
recipient -> MentionUtil.getMentionSettingDisplayValue(context, recipient.getMentionSetting())));
|
||||||
this.groupLinkOn = Transformations.map(liveGroup.getGroupLink(), GroupLinkUrlAndStatus::isEnabled);
|
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
|
@WorkerThread
|
||||||
|
@ -152,10 +163,6 @@ public class ManageGroupViewModel extends ViewModel {
|
||||||
return fullMemberCountSummary;
|
return fullMemberCountSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveData<Boolean> getShowLegacyIndicator() {
|
|
||||||
return showLegacyIndicator;
|
|
||||||
}
|
|
||||||
|
|
||||||
LiveData<Recipient> getGroupRecipient() {
|
LiveData<Recipient> getGroupRecipient() {
|
||||||
return groupRecipient;
|
return groupRecipient;
|
||||||
}
|
}
|
||||||
|
@ -228,6 +235,10 @@ public class ManageGroupViewModel extends ViewModel {
|
||||||
return groupLinkOn;
|
return groupLinkOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LiveData<GroupInfoMessage> getGroupInfoMessage() {
|
||||||
|
return groupInfoMessage;
|
||||||
|
}
|
||||||
|
|
||||||
void handleExpirationSelection() {
|
void handleExpirationSelection() {
|
||||||
manageGroupRepository.getRecipient(groupRecipient ->
|
manageGroupRepository.getRecipient(groupRecipient ->
|
||||||
ExpirationDialog.show(context,
|
ExpirationDialog.show(context,
|
||||||
|
@ -397,6 +408,12 @@ public class ManageGroupViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum GroupInfoMessage {
|
||||||
|
NONE,
|
||||||
|
LEGACY_GROUP_LEARN_MORE,
|
||||||
|
MMS_WARNING
|
||||||
|
}
|
||||||
|
|
||||||
private enum CollapseState {
|
private enum CollapseState {
|
||||||
OPEN,
|
OPEN,
|
||||||
COLLAPSED
|
COLLAPSED
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
import androidx.appcompat.widget.AppCompatTextView;
|
import androidx.appcompat.widget.AppCompatTextView;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
|
@ -38,26 +39,7 @@ public class LearnMoreTextView extends AppCompatTextView {
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
setMovementMethod(LinkMovementMethod.getInstance());
|
setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
setLinkTextInternal(R.string.LearnMoreTextView_learn_more);
|
||||||
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);
|
|
||||||
|
|
||||||
visible = true;
|
visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +63,33 @@ public class LearnMoreTextView extends AppCompatTextView {
|
||||||
setTextInternal(baseText, visible ? BufferType.SPANNABLE : BufferType.NORMAL);
|
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) {
|
private void setTextInternal(CharSequence text, BufferType type) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
SpannableStringBuilder builder = new SpannableStringBuilder();
|
SpannableStringBuilder builder = new SpannableStringBuilder();
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
tools:text="12 members (4 invited)" />
|
tools:text="12 members (4 invited)" />
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.util.views.LearnMoreTextView
|
<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_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
|
@ -66,10 +66,10 @@
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="10dp"
|
||||||
android:paddingEnd="12dp"
|
android:paddingEnd="12dp"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
android:text="@string/ManageGroupActivity_legacy_group_learn_more"
|
|
||||||
android:textAppearance="@style/TextAppearance.Signal.Caption"
|
android:textAppearance="@style/TextAppearance.Signal.Caption"
|
||||||
android:textColor="?title_text_color_secondary"
|
android:textColor="?title_text_color_secondary"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
tools:text="@string/ManageGroupActivity_legacy_group_learn_more"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -623,6 +623,8 @@
|
||||||
<string name="ManageGroupActivity_edit_name_and_picture">Edit name and picture</string>
|
<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">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_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 -->
|
<!-- GroupMentionSettingDialog -->
|
||||||
<string name="GroupMentionSettingDialog_notify_me_for_mentions">Notify me for Mentions</string>
|
<string name="GroupMentionSettingDialog_notify_me_for_mentions">Notify me for Mentions</string>
|
||||||
|
|
Loading…
Reference in New Issue