MMS proof new group UI.
This commit is contained in:
parent
ac93d81032
commit
b27198286d
7 changed files with 33 additions and 17 deletions
|
@ -300,7 +300,7 @@ public class ContactsCursorLoader extends CursorLoader {
|
|||
private Cursor getNewNumberCursor() {
|
||||
MatrixCursor newNumberCursor = new MatrixCursor(CONTACT_PROJECTION, 1);
|
||||
newNumberCursor.addRow(new Object[] { null,
|
||||
getContext().getString(R.string.contact_selection_list__unknown_contact),
|
||||
getUnknownContactTitle(),
|
||||
filter,
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM,
|
||||
"\u21e2",
|
||||
|
@ -311,7 +311,7 @@ public class ContactsCursorLoader extends CursorLoader {
|
|||
private Cursor getUsernameSearchCursor() {
|
||||
MatrixCursor cursor = new MatrixCursor(CONTACT_PROJECTION, 1);
|
||||
cursor.addRow(new Object[] { null,
|
||||
getContext().getString(R.string.contact_selection_list__unknown_contact),
|
||||
getUnknownContactTitle(),
|
||||
filter,
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_CUSTOM,
|
||||
"\u21e2",
|
||||
|
@ -319,6 +319,11 @@ public class ContactsCursorLoader extends CursorLoader {
|
|||
return cursor;
|
||||
}
|
||||
|
||||
private String getUnknownContactTitle() {
|
||||
return getContext().getString(newConversation(mode) ? R.string.contact_selection_list__unknown_contact
|
||||
: R.string.contact_selection_list__unknown_contact_add_to_group);
|
||||
}
|
||||
|
||||
private @NonNull Cursor filterNonPushContacts(@NonNull Cursor cursor) {
|
||||
try {
|
||||
final long startMillis = System.currentTimeMillis();
|
||||
|
@ -355,6 +360,10 @@ public class ContactsCursorLoader extends CursorLoader {
|
|||
return flagSet(mode, DisplayMode.FLAG_SELF);
|
||||
}
|
||||
|
||||
private static boolean newConversation(int mode) {
|
||||
return groupsEnabled(mode);
|
||||
}
|
||||
|
||||
private static boolean pushEnabled(int mode) {
|
||||
return flagSet(mode, DisplayMode.FLAG_PUSH);
|
||||
}
|
||||
|
|
|
@ -1019,8 +1019,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
|
||||
private void handleConversationSettings() {
|
||||
if (FeatureFlags.newGroupUI() && isGroupConversation()) {
|
||||
startActivitySceneTransition(ManageGroupActivity.newIntent(this, getRecipient().requireGroupId()),
|
||||
if (FeatureFlags.newGroupUI() && isPushGroupConversation()) {
|
||||
startActivitySceneTransition(ManageGroupActivity.newIntent(this, getRecipient().requireGroupId().requirePush()),
|
||||
titleView.findViewById(R.id.contact_photo_image),
|
||||
"avatar");
|
||||
return;
|
||||
|
@ -1190,7 +1190,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||
}
|
||||
|
||||
private void handleManagePushGroup() {
|
||||
startActivityForResult(ManageGroupActivity.newIntent(ConversationActivity.this, recipient.get().requireGroupId()), GROUP_EDIT);
|
||||
startActivityForResult(ManageGroupActivity.newIntent(ConversationActivity.this, recipient.get().requireGroupId().requirePush()), GROUP_EDIT);
|
||||
}
|
||||
|
||||
private void handleDistributionBroadcastEnabled(MenuItem item) {
|
||||
|
|
|
@ -118,7 +118,12 @@ public class AddGroupDetailsFragment extends Fragment {
|
|||
create.setOnClickListener(v -> handleCreateClicked());
|
||||
viewModel.getMembers().observe(getViewLifecycleOwner(), members::setMembers);
|
||||
viewModel.getCanSubmitForm().observe(getViewLifecycleOwner(), isFormValid -> setCreateEnabled(isFormValid, true));
|
||||
viewModel.getIsMms().observe(getViewLifecycleOwner(), isMms -> mmsWarning.setVisibility(isMms ? View.VISIBLE : View.GONE));
|
||||
viewModel.getIsMms().observe(getViewLifecycleOwner(), isMms -> {
|
||||
mmsWarning.setVisibility(isMms ? View.VISIBLE : View.GONE);
|
||||
name.setVisibility(isMms ? View.GONE : View.VISIBLE);
|
||||
avatar.setVisibility(isMms ? View.GONE : View.VISIBLE);
|
||||
toolbar.setTitle(isMms ? R.string.AddGroupDetailsFragment__create_group : R.string.AddGroupDetailsFragment__name_this_group);
|
||||
});
|
||||
viewModel.getAvatar().observe(getViewLifecycleOwner(), avatarBytes -> {
|
||||
if (avatarBytes == null) {
|
||||
avatar.setImageDrawable(new InsetDrawable(avatarPlaceholder, ViewUtil.dpToPx(AVATAR_PLACEHOLDER_INSET_DP)));
|
||||
|
|
|
@ -14,11 +14,9 @@ import com.annimon.stream.Collectors;
|
|||
import com.annimon.stream.Stream;
|
||||
|
||||
import org.thoughtcrime.securesms.groups.ui.GroupMemberEntry;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.DefaultValueLiveData;
|
||||
import org.thoughtcrime.securesms.util.SingleLiveEvent;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.livedata.LiveDataUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -32,9 +30,9 @@ public final class AddGroupDetailsViewModel extends ViewModel {
|
|||
private final DefaultValueLiveData<Set<RecipientId>> deleted = new DefaultValueLiveData<>(new HashSet<>());
|
||||
private final MutableLiveData<String> name = new MutableLiveData<>("");
|
||||
private final MutableLiveData<byte[]> avatar = new MutableLiveData<>();
|
||||
private final LiveData<Boolean> isMms;
|
||||
private final SingleLiveEvent<GroupCreateResult> groupCreateResult = new SingleLiveEvent<>();
|
||||
private final LiveData<Boolean> canSubmitForm = Transformations.map(name, name -> !TextUtils.isEmpty(name));
|
||||
private final LiveData<Boolean> isMms;
|
||||
private final LiveData<Boolean> canSubmitForm;
|
||||
private final AddGroupDetailsRepository repository;
|
||||
|
||||
private AddGroupDetailsViewModel(@NonNull RecipientId[] recipientIds,
|
||||
|
@ -44,8 +42,10 @@ public final class AddGroupDetailsViewModel extends ViewModel {
|
|||
|
||||
MutableLiveData<List<GroupMemberEntry.NewGroupCandidate>> initialMembers = new MutableLiveData<>();
|
||||
|
||||
LiveData<Boolean> isValidName = Transformations.map(name, name -> !TextUtils.isEmpty(name));
|
||||
members = LiveDataUtil.combineLatest(initialMembers, deleted, AddGroupDetailsViewModel::filterDeletedMembers);
|
||||
isMms = Transformations.map(members, this::isAnyForcedSms);
|
||||
canSubmitForm = LiveDataUtil.combineLatest(isMms, isValidName, (mms, validName) -> mms || validName);
|
||||
|
||||
repository.resolveMembers(recipientIds, initialMembers::postValue);
|
||||
}
|
||||
|
@ -93,10 +93,10 @@ public final class AddGroupDetailsViewModel extends ViewModel {
|
|||
List<GroupMemberEntry.NewGroupCandidate> members = Objects.requireNonNull(this.members.getValue());
|
||||
Set<RecipientId> memberIds = Stream.of(members).map(member -> member.getMember().getId()).collect(Collectors.toSet());
|
||||
byte[] avatarBytes = avatar.getValue();
|
||||
String groupName = name.getValue();
|
||||
boolean isGroupMms = isMms.getValue() == Boolean.TRUE;
|
||||
String groupName = isGroupMms ? "" : name.getValue();
|
||||
|
||||
if (TextUtils.isEmpty(groupName)) {
|
||||
if (!isGroupMms && TextUtils.isEmpty(groupName)) {
|
||||
groupCreateResult.postValue(GroupCreateResult.error(GroupCreateResult.Error.Type.ERROR_INVALID_NAME));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class ManageGroupActivity extends PassphraseRequiredActionBarActivity {
|
|||
|
||||
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
|
||||
|
||||
public static Intent newIntent(@NonNull Context context, @NonNull GroupId groupId) {
|
||||
public static Intent newIntent(@NonNull Context context, @NonNull GroupId.Push groupId) {
|
||||
Intent intent = new Intent(context, ManageGroupActivity.class);
|
||||
intent.putExtra(GROUP_ID, groupId.toString());
|
||||
return intent;
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
android:layout_height="?actionBarSize"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navigationIcon="@drawable/ic_arrow_left_24"
|
||||
app:title="@string/AddGroupDetailsFragment__name_this_group"
|
||||
app:titleTextAppearance="@style/TextAppearance.Signal.Body1.Bold" />
|
||||
app:titleTextAppearance="@style/TextAppearance.Signal.Body1.Bold"
|
||||
tools:title="@string/AddGroupDetailsFragment__name_this_group" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/group_avatar"
|
||||
|
|
|
@ -499,6 +499,7 @@
|
|||
|
||||
<!-- AddGroupDetailsFragment -->
|
||||
<string name="AddGroupDetailsFragment__name_this_group">Name this group</string>
|
||||
<string name="AddGroupDetailsFragment__create_group">Create group</string>
|
||||
<string name="AddGroupDetailsFragment__create">Create</string>
|
||||
<string name="AddGroupDetailsFragment__members">Members</string>
|
||||
<string name="AddGroupDetailsFragment__group_name_required">Group name (required)</string>
|
||||
|
@ -1895,6 +1896,7 @@
|
|||
|
||||
<!-- contact_selection_list -->
|
||||
<string name="contact_selection_list__unknown_contact">New message to…</string>
|
||||
<string name="contact_selection_list__unknown_contact_add_to_group">Add to group</string>
|
||||
|
||||
<!-- conversation_callable_insecure -->
|
||||
<string name="conversation_callable_insecure__menu_call">Call</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue