Infer contact multi-select allowing assertion removal.
Hide count on invite friends. Fixes #10125
This commit is contained in:
parent
3f983a5c82
commit
4099154dc0
6 changed files with 11 additions and 18 deletions
|
@ -105,11 +105,11 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||
public static final int NO_LIMIT = Integer.MAX_VALUE;
|
||||
|
||||
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 RECENTS = "recents";
|
||||
public static final String SELECTION_LIMITS = "selection_limits";
|
||||
public static final String CURRENT_SELECTION = "current_selection";
|
||||
public static final String HIDE_COUNT = "hide_count";
|
||||
|
||||
private ConstraintLayout constraintLayout;
|
||||
private TextView emptyText;
|
||||
|
@ -135,6 +135,7 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||
private SelectionLimits selectionLimit = SelectionLimits.NO_LIMITS;
|
||||
private Set<RecipientId> currentSelection;
|
||||
private boolean isMulti;
|
||||
private boolean hideCount;
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
|
@ -213,19 +214,12 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||
|
||||
swipeRefresh.setEnabled(intent.getBooleanExtra(REFRESHABLE, true));
|
||||
|
||||
hideCount = intent.getBooleanExtra(HIDE_COUNT, false);
|
||||
selectionLimit = intent.getParcelableExtra(SELECTION_LIMITS);
|
||||
isMulti = intent.getBooleanExtra(MULTI_SELECT, false);
|
||||
isMulti = selectionLimit != null;
|
||||
|
||||
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;
|
||||
}
|
||||
if (!isMulti) {
|
||||
selectionLimit = SelectionLimits.NO_LIMITS;
|
||||
}
|
||||
|
||||
currentSelection = getCurrentSelection();
|
||||
|
@ -238,7 +232,7 @@ public final class ContactSelectionListFragment extends LoggingFragment
|
|||
private void updateGroupLimit(int chipCount) {
|
||||
int members = currentSelection.size() + chipCount;
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.thoughtcrime.securesms.components.ContactFilterToolbar.OnFilterChange
|
|||
import org.thoughtcrime.securesms.contacts.ContactsCursorLoader.DisplayMode;
|
||||
import org.thoughtcrime.securesms.contacts.SelectedContact;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.groups.SelectionLimits;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||
|
@ -62,7 +63,8 @@ public class InviteActivity extends PassphraseRequiredActivity implements Contac
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState, boolean ready) {
|
||||
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);
|
||||
|
||||
setContentView(R.layout.invite_activity);
|
||||
|
|
|
@ -42,7 +42,6 @@ public class PushContactSelectionActivity extends ContactSelectionActivity {
|
|||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle, boolean ready) {
|
||||
getIntent().putExtra(ContactSelectionListFragment.MULTI_SELECT, true);
|
||||
super.onCreate(icicle, ready);
|
||||
|
||||
initializeToolbar();
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.os.Parcel;
|
|||
import android.os.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);
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ public final class AddToGroupsActivity extends ContactSelectionActivity {
|
|||
{
|
||||
Intent intent = new Intent(context, AddToGroupsActivity.class);
|
||||
|
||||
intent.putExtra(ContactSelectionListFragment.MULTI_SELECT, false);
|
||||
intent.putExtra(ContactSelectionListFragment.REFRESHABLE, false);
|
||||
intent.putExtra(ContactSelectionListFragment.RECENTS, true);
|
||||
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) {
|
||||
Intent intent = new Intent(context, CreateGroupActivity.class);
|
||||
|
||||
intent.putExtra(ContactSelectionListFragment.MULTI_SELECT, true);
|
||||
intent.putExtra(ContactSelectionListFragment.REFRESHABLE, false);
|
||||
intent.putExtra(ContactSelectionActivity.EXTRA_LAYOUT_RES_ID, R.layout.create_group_activity);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue