Search in sources :

Example 1 with ContactSelectionListFragment

use of org.thoughtcrime.securesms.ContactSelectionListFragment in project Signal-Android by WhisperSystems.

the class ShareActivity method initializeResources.

private void initializeResources() {
    searchToolbar = findViewById(R.id.search_toolbar);
    searchAction = findViewById(R.id.search_action);
    shareConfirm = findViewById(R.id.share_confirm);
    shareContainer = findViewById(R.id.container);
    contactsFragment = new ContactSelectionListFragment();
    adapter = new ShareSelectionAdapter();
    contactsRecycler = findViewById(R.id.selected_list);
    contactsRecyclerDivider = findViewById(R.id.divider);
    contactsRecycler.setAdapter(adapter);
    RecyclerView.ItemAnimator itemAnimator = Objects.requireNonNull(contactsRecycler.getItemAnimator());
    ShareFlowConstants.applySelectedContactsRecyclerAnimationSpeeds(itemAnimator);
    getSupportFragmentManager().beginTransaction().replace(R.id.contact_selection_list_fragment, contactsFragment).commit();
    shareConfirm.setOnClickListener(unused -> {
        Set<ShareContact> shareContacts = viewModel.getShareContacts();
        if (shareContacts.isEmpty())
            throw new AssertionError();
        else if (shareContacts.size() == 1)
            onConfirmSingleDestination(shareContacts.iterator().next());
        else
            onConfirmMultipleDestinations(shareContacts);
    });
    viewModel.getSelectedContactModels().observe(this, models -> {
        adapter.submitList(models, () -> contactsRecycler.scrollToPosition(models.size() - 1));
        shareConfirm.setEnabled(!models.isEmpty());
        shareConfirm.setAlpha(models.isEmpty() ? 0.5f : 1f);
        if (models.isEmpty()) {
            animateOutSelection();
        } else {
            animateInSelection();
        }
    });
    viewModel.getSmsShareRestriction().observe(this, smsShareRestriction -> {
        final int displayMode;
        switch(smsShareRestriction) {
            case NO_RESTRICTIONS:
                disallowMultiShare = false;
                displayMode = getIntent().getIntExtra(ContactSelectionListFragment.DISPLAY_MODE, -1);
                if (displayMode == -1) {
                    Log.w(TAG, "DisplayMode not set yet.");
                    return;
                }
                if (Util.isDefaultSmsProvider(this) && (displayMode & DisplayMode.FLAG_SMS) == 0) {
                    getIntent().putExtra(ContactSelectionListFragment.DISPLAY_MODE, displayMode | DisplayMode.FLAG_SMS);
                    contactsFragment.setQueryFilter(null);
                }
                break;
            case DISALLOW_SMS_CONTACTS:
                disallowMultiShare = false;
                displayMode = getIntent().getIntExtra(ContactSelectionListFragment.DISPLAY_MODE, -1);
                if (displayMode == -1) {
                    Log.w(TAG, "DisplayMode not set yet.");
                    return;
                }
                getIntent().putExtra(ContactSelectionListFragment.DISPLAY_MODE, displayMode & ~DisplayMode.FLAG_SMS);
                contactsFragment.setQueryFilter(null);
                break;
            case DISALLOW_MULTI_SHARE:
                disallowMultiShare = true;
                break;
        }
        validateAvailableRecipients();
    });
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) ContactSelectionListFragment(org.thoughtcrime.securesms.ContactSelectionListFragment)

Example 2 with ContactSelectionListFragment

use of org.thoughtcrime.securesms.ContactSelectionListFragment in project Signal-Android by WhisperSystems.

the class PaymentRecipientSelectionFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    toolbar = view.findViewById(R.id.payment_recipient_selection_fragment_toolbar);
    toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
    contactFilterView = view.findViewById(R.id.contact_filter_edit_text);
    Bundle arguments = new Bundle();
    arguments.putBoolean(ContactSelectionListFragment.REFRESHABLE, false);
    arguments.putInt(ContactSelectionListFragment.DISPLAY_MODE, DisplayMode.FLAG_PUSH | DisplayMode.FLAG_HIDE_NEW);
    arguments.putBoolean(ContactSelectionListFragment.CAN_SELECT_SELF, false);
    Fragment child = getChildFragmentManager().findFragmentById(R.id.contact_selection_list_fragment_holder);
    if (child == null) {
        FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
        contactsFragment = new ContactSelectionListFragment();
        contactsFragment.setArguments(arguments);
        transaction.add(R.id.contact_selection_list_fragment_holder, contactsFragment);
        transaction.commit();
    } else {
        contactsFragment = (ContactSelectionListFragment) child;
    }
    initializeSearch();
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) Bundle(android.os.Bundle) ContactSelectionListFragment(org.thoughtcrime.securesms.ContactSelectionListFragment) Fragment(androidx.fragment.app.Fragment) LoggingFragment(org.thoughtcrime.securesms.LoggingFragment) ContactSelectionListFragment(org.thoughtcrime.securesms.ContactSelectionListFragment)

Example 3 with ContactSelectionListFragment

use of org.thoughtcrime.securesms.ContactSelectionListFragment in project Signal-Android by WhisperSystems.

the class BlockedUsersActivity method handleAddUserToBlockedList.

@Override
public void handleAddUserToBlockedList() {
    ContactSelectionListFragment fragment = new ContactSelectionListFragment();
    Intent intent = getIntent();
    intent.putExtra(ContactSelectionListFragment.REFRESHABLE, false);
    intent.putExtra(ContactSelectionListFragment.SELECTION_LIMITS, 1);
    intent.putExtra(ContactSelectionListFragment.HIDE_COUNT, true);
    intent.putExtra(ContactSelectionListFragment.DISPLAY_MODE, ContactsCursorLoader.DisplayMode.FLAG_PUSH | ContactsCursorLoader.DisplayMode.FLAG_SMS | ContactsCursorLoader.DisplayMode.FLAG_ACTIVE_GROUPS | ContactsCursorLoader.DisplayMode.FLAG_INACTIVE_GROUPS | ContactsCursorLoader.DisplayMode.FLAG_BLOCK);
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment, CONTACT_SELECTION_FRAGMENT).addToBackStack(null).commit();
}
Also used : Intent(android.content.Intent) ContactSelectionListFragment(org.thoughtcrime.securesms.ContactSelectionListFragment)

Example 4 with ContactSelectionListFragment

use of org.thoughtcrime.securesms.ContactSelectionListFragment in project Signal-Android by WhisperSystems.

the class BlockedUsersActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
    super.onCreate(savedInstanceState, ready);
    dynamicTheme.onCreate(this);
    setContentView(R.layout.blocked_users_activity);
    BlockedUsersRepository repository = new BlockedUsersRepository(this);
    BlockedUsersViewModel.Factory factory = new BlockedUsersViewModel.Factory(repository);
    viewModel = ViewModelProviders.of(this, factory).get(BlockedUsersViewModel.class);
    Toolbar toolbar = findViewById(R.id.toolbar);
    ContactFilterView contactFilterView = findViewById(R.id.contact_filter_edit_text);
    View container = findViewById(R.id.fragment_container);
    toolbar.setNavigationOnClickListener(unused -> onBackPressed());
    contactFilterView.setOnFilterChangedListener(query -> {
        Fragment fragment = getSupportFragmentManager().findFragmentByTag(CONTACT_SELECTION_FRAGMENT);
        if (fragment != null) {
            ((ContactSelectionListFragment) fragment).setQueryFilter(query);
        }
    });
    contactFilterView.setHint(R.string.BlockedUsersActivity__add_blocked_user);
    // noinspection CodeBlock2Expr
    getSupportFragmentManager().addOnBackStackChangedListener(() -> {
        if (getSupportFragmentManager().getBackStackEntryCount() == 1) {
            contactFilterView.setVisibility(View.VISIBLE);
            contactFilterView.focusAndShowKeyboard();
        } else {
            contactFilterView.setVisibility(View.GONE);
        }
    });
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, new BlockedUsersFragment()).commit();
    viewModel.getEvents().observe(this, event -> handleEvent(container, event));
}
Also used : ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) View(android.view.View) ContactSelectionListFragment(org.thoughtcrime.securesms.ContactSelectionListFragment) Fragment(androidx.fragment.app.Fragment) Toolbar(androidx.appcompat.widget.Toolbar) ContactSelectionListFragment(org.thoughtcrime.securesms.ContactSelectionListFragment)

Aggregations

ContactSelectionListFragment (org.thoughtcrime.securesms.ContactSelectionListFragment)4 Fragment (androidx.fragment.app.Fragment)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 View (android.view.View)1 Toolbar (androidx.appcompat.widget.Toolbar)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 LoggingFragment (org.thoughtcrime.securesms.LoggingFragment)1 ContactFilterView (org.thoughtcrime.securesms.components.ContactFilterView)1