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