mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 15:58:34 +00:00
Infer contact multi-select allowing assertion removal.
Hide count on invite friends. Fixes #10125
This commit is contained in:
parent
3f983a5c82
commit
4099154dc0
@ -105,11 +105,11 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||||||
public static final int NO_LIMIT = Integer.MAX_VALUE;
|
public static final int NO_LIMIT = Integer.MAX_VALUE;
|
||||||
|
|
||||||
public static final String DISPLAY_MODE = "display_mode";
|
public static final String DISPLAY_MODE = "display_mode";
|
||||||
public static final String MULTI_SELECT = "multi_select";
|
|
||||||
public static final String REFRESHABLE = "refreshable";
|
public static final String REFRESHABLE = "refreshable";
|
||||||
public static final String RECENTS = "recents";
|
public static final String RECENTS = "recents";
|
||||||
public static final String SELECTION_LIMITS = "selection_limits";
|
public static final String SELECTION_LIMITS = "selection_limits";
|
||||||
public static final String CURRENT_SELECTION = "current_selection";
|
public static final String CURRENT_SELECTION = "current_selection";
|
||||||
|
public static final String HIDE_COUNT = "hide_count";
|
||||||
|
|
||||||
private ConstraintLayout constraintLayout;
|
private ConstraintLayout constraintLayout;
|
||||||
private TextView emptyText;
|
private TextView emptyText;
|
||||||
@ -135,6 +135,7 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||||||
private SelectionLimits selectionLimit = SelectionLimits.NO_LIMITS;
|
private SelectionLimits selectionLimit = SelectionLimits.NO_LIMITS;
|
||||||
private Set<RecipientId> currentSelection;
|
private Set<RecipientId> currentSelection;
|
||||||
private boolean isMulti;
|
private boolean isMulti;
|
||||||
|
private boolean hideCount;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(@NonNull Context context) {
|
public void onAttach(@NonNull Context context) {
|
||||||
@ -213,20 +214,13 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||||||
|
|
||||||
swipeRefresh.setEnabled(intent.getBooleanExtra(REFRESHABLE, true));
|
swipeRefresh.setEnabled(intent.getBooleanExtra(REFRESHABLE, true));
|
||||||
|
|
||||||
|
hideCount = intent.getBooleanExtra(HIDE_COUNT, false);
|
||||||
selectionLimit = intent.getParcelableExtra(SELECTION_LIMITS);
|
selectionLimit = intent.getParcelableExtra(SELECTION_LIMITS);
|
||||||
isMulti = intent.getBooleanExtra(MULTI_SELECT, false);
|
isMulti = selectionLimit != null;
|
||||||
|
|
||||||
if (isMulti) {
|
if (!isMulti) {
|
||||||
if (selectionLimit == null) {
|
|
||||||
throw new AssertionError("Selection limits not supplied in args for multi-select");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (selectionLimit != null) {
|
|
||||||
throw new AssertionError("Selection limits supplied in args for a non-multi selection use");
|
|
||||||
} else {
|
|
||||||
selectionLimit = SelectionLimits.NO_LIMITS;
|
selectionLimit = SelectionLimits.NO_LIMITS;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
currentSelection = getCurrentSelection();
|
currentSelection = getCurrentSelection();
|
||||||
|
|
||||||
@ -238,7 +232,7 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||||||
private void updateGroupLimit(int chipCount) {
|
private void updateGroupLimit(int chipCount) {
|
||||||
int members = currentSelection.size() + chipCount;
|
int members = currentSelection.size() + chipCount;
|
||||||
groupLimit.setText(getResources().getQuantityString(R.plurals.ContactSelectionListFragment_d_members, members, members));
|
groupLimit.setText(getResources().getQuantityString(R.plurals.ContactSelectionListFragment_d_members, members, members));
|
||||||
groupLimit.setVisibility(isMulti ? View.VISIBLE : View.GONE);
|
groupLimit.setVisibility(isMulti && !hideCount ? View.VISIBLE : View.GONE);
|
||||||
groupLimit.setWarning(selectionWarningLimitExceeded());
|
groupLimit.setWarning(selectionWarningLimitExceeded());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import org.thoughtcrime.securesms.components.ContactFilterToolbar.OnFilterChange
|
|||||||
import org.thoughtcrime.securesms.contacts.ContactsCursorLoader.DisplayMode;
|
import org.thoughtcrime.securesms.contacts.ContactsCursorLoader.DisplayMode;
|
||||||
import org.thoughtcrime.securesms.contacts.SelectedContact;
|
import org.thoughtcrime.securesms.contacts.SelectedContact;
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||||
|
import org.thoughtcrime.securesms.groups.SelectionLimits;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||||
@ -62,7 +63,8 @@ public class InviteActivity extends PassphraseRequiredActivity implements Contac
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState, boolean ready) {
|
protected void onCreate(Bundle savedInstanceState, boolean ready) {
|
||||||
getIntent().putExtra(ContactSelectionListFragment.DISPLAY_MODE, DisplayMode.FLAG_SMS);
|
getIntent().putExtra(ContactSelectionListFragment.DISPLAY_MODE, DisplayMode.FLAG_SMS);
|
||||||
getIntent().putExtra(ContactSelectionListFragment.MULTI_SELECT, true);
|
getIntent().putExtra(ContactSelectionListFragment.SELECTION_LIMITS, SelectionLimits.NO_LIMITS);
|
||||||
|
getIntent().putExtra(ContactSelectionListFragment.HIDE_COUNT, true);
|
||||||
getIntent().putExtra(ContactSelectionListFragment.REFRESHABLE, false);
|
getIntent().putExtra(ContactSelectionListFragment.REFRESHABLE, false);
|
||||||
|
|
||||||
setContentView(R.layout.invite_activity);
|
setContentView(R.layout.invite_activity);
|
||||||
|
@ -42,7 +42,6 @@ public class PushContactSelectionActivity extends ContactSelectionActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle, boolean ready) {
|
protected void onCreate(Bundle icicle, boolean ready) {
|
||||||
getIntent().putExtra(ContactSelectionListFragment.MULTI_SELECT, true);
|
|
||||||
super.onCreate(icicle, ready);
|
super.onCreate(icicle, ready);
|
||||||
|
|
||||||
initializeToolbar();
|
initializeToolbar();
|
||||||
|
@ -4,7 +4,7 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public final class SelectionLimits implements Parcelable {
|
public final class SelectionLimits implements Parcelable {
|
||||||
public static final int NO_LIMIT = Integer.MAX_VALUE;
|
private static final int NO_LIMIT = Integer.MAX_VALUE;
|
||||||
|
|
||||||
public static final SelectionLimits NO_LIMITS = new SelectionLimits(NO_LIMIT, NO_LIMIT);
|
public static final SelectionLimits NO_LIMITS = new SelectionLimits(NO_LIMIT, NO_LIMIT);
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ public final class AddToGroupsActivity extends ContactSelectionActivity {
|
|||||||
{
|
{
|
||||||
Intent intent = new Intent(context, AddToGroupsActivity.class);
|
Intent intent = new Intent(context, AddToGroupsActivity.class);
|
||||||
|
|
||||||
intent.putExtra(ContactSelectionListFragment.MULTI_SELECT, false);
|
|
||||||
intent.putExtra(ContactSelectionListFragment.REFRESHABLE, false);
|
intent.putExtra(ContactSelectionListFragment.REFRESHABLE, false);
|
||||||
intent.putExtra(ContactSelectionListFragment.RECENTS, true);
|
intent.putExtra(ContactSelectionListFragment.RECENTS, true);
|
||||||
intent.putExtra(ContactSelectionActivity.EXTRA_LAYOUT_RES_ID, R.layout.add_to_group_activity);
|
intent.putExtra(ContactSelectionActivity.EXTRA_LAYOUT_RES_ID, R.layout.add_to_group_activity);
|
||||||
|
@ -48,7 +48,6 @@ public class CreateGroupActivity extends ContactSelectionActivity {
|
|||||||
public static Intent newIntent(@NonNull Context context) {
|
public static Intent newIntent(@NonNull Context context) {
|
||||||
Intent intent = new Intent(context, CreateGroupActivity.class);
|
Intent intent = new Intent(context, CreateGroupActivity.class);
|
||||||
|
|
||||||
intent.putExtra(ContactSelectionListFragment.MULTI_SELECT, true);
|
|
||||||
intent.putExtra(ContactSelectionListFragment.REFRESHABLE, false);
|
intent.putExtra(ContactSelectionListFragment.REFRESHABLE, false);
|
||||||
intent.putExtra(ContactSelectionActivity.EXTRA_LAYOUT_RES_ID, R.layout.create_group_activity);
|
intent.putExtra(ContactSelectionActivity.EXTRA_LAYOUT_RES_ID, R.layout.create_group_activity);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user