Search in sources :

Example 1 with ContactFilterView

use of org.thoughtcrime.securesms.components.ContactFilterView 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)

Example 2 with ContactFilterView

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

the class InviteActivity method initializeResources.

private void initializeResources() {
    slideInAnimation = loadAnimation(R.anim.slide_from_bottom);
    slideOutAnimation = loadAnimation(R.anim.slide_to_bottom);
    View shareButton = findViewById(R.id.share_button);
    TextView shareText = findViewById(R.id.share_text);
    View smsButton = findViewById(R.id.sms_button);
    Button smsCancelButton = findViewById(R.id.cancel_sms_button);
    ContactFilterView contactFilter = findViewById(R.id.contact_filter_edit_text);
    inviteText = findViewById(R.id.invite_text);
    smsSendFrame = findViewById(R.id.sms_send_frame);
    smsSendButton = findViewById(R.id.send_sms_button);
    contactsFragment = (ContactSelectionListFragment) getSupportFragmentManager().findFragmentById(R.id.contact_selection_list_fragment);
    inviteText.setText(getString(R.string.InviteActivity_lets_switch_to_signal, getString(R.string.install_url)));
    inviteText.addTextChangedListener(new AfterTextChanged(editable -> {
        boolean isEnabled = editable.length() > 0;
        smsButton.setEnabled(isEnabled);
        shareButton.setEnabled(isEnabled);
        smsButton.animate().alpha(isEnabled ? 1f : 0.5f);
        shareButton.animate().alpha(isEnabled ? 1f : 0.5f);
    }));
    updateSmsButtonText(contactsFragment.getSelectedContacts().size());
    smsCancelButton.setOnClickListener(new SmsCancelClickListener());
    smsSendButton.setOnClickListener(new SmsSendClickListener());
    contactFilter.setOnFilterChangedListener(new ContactFilterChangedListener());
    if (Util.isDefaultSmsProvider(this)) {
        shareButton.setOnClickListener(new ShareClickListener());
        smsButton.setOnClickListener(new SmsClickListener());
    } else {
        smsButton.setVisibility(View.GONE);
        shareText.setText(R.string.InviteActivity_share);
        shareButton.setOnClickListener(new ShareClickListener());
    }
}
Also used : Context(android.content.Context) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) MessageSender(org.thoughtcrime.securesms.sms.MessageSender) Util(org.thoughtcrime.securesms.util.Util) SelectionLimits(org.thoughtcrime.securesms.groups.SelectionLimits) AnimRes(androidx.annotation.AnimRes) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) Intent(android.content.Intent) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) ProgressDialogAsyncTask(org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask) AnimationUtils(android.view.animation.AnimationUtils) DynamicTheme(org.thoughtcrime.securesms.util.DynamicTheme) SuppressLint(android.annotation.SuppressLint) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) DynamicNoActionBarInviteTheme(org.thoughtcrime.securesms.util.DynamicNoActionBarInviteTheme) Toast(android.widget.Toast) View(android.view.View) Button(android.widget.Button) Recipient(org.thoughtcrime.securesms.recipients.Recipient) Animation(android.view.animation.Animation) OutgoingTextMessage(org.thoughtcrime.securesms.sms.OutgoingTextMessage) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) AsyncTask(android.os.AsyncTask) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) ViewGroup(android.view.ViewGroup) OnFilterChangedListener(org.thoughtcrime.securesms.components.ContactFilterView.OnFilterChangedListener) Optional(org.whispersystems.libsignal.util.guava.Optional) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) TextView(android.widget.TextView) SelectedContact(org.thoughtcrime.securesms.contacts.SelectedContact) Toolbar(androidx.appcompat.widget.Toolbar) Listener(org.thoughtcrime.securesms.util.concurrent.ListenableFuture.Listener) EditText(android.widget.EditText) OnClickListener(android.view.View.OnClickListener) DisplayMode(org.thoughtcrime.securesms.contacts.ContactsCursorLoader.DisplayMode) Button(android.widget.Button) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) TextView(android.widget.TextView) View(android.view.View) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) TextView(android.widget.TextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Example 3 with ContactFilterView

use of org.thoughtcrime.securesms.components.ContactFilterView in project Signal-Android by signalapp.

the class InviteActivity method initializeResources.

private void initializeResources() {
    slideInAnimation = loadAnimation(R.anim.slide_from_bottom);
    slideOutAnimation = loadAnimation(R.anim.slide_to_bottom);
    View shareButton = findViewById(R.id.share_button);
    TextView shareText = findViewById(R.id.share_text);
    View smsButton = findViewById(R.id.sms_button);
    Button smsCancelButton = findViewById(R.id.cancel_sms_button);
    ContactFilterView contactFilter = findViewById(R.id.contact_filter_edit_text);
    inviteText = findViewById(R.id.invite_text);
    smsSendFrame = findViewById(R.id.sms_send_frame);
    smsSendButton = findViewById(R.id.send_sms_button);
    contactsFragment = (ContactSelectionListFragment) getSupportFragmentManager().findFragmentById(R.id.contact_selection_list_fragment);
    inviteText.setText(getString(R.string.InviteActivity_lets_switch_to_signal, getString(R.string.install_url)));
    inviteText.addTextChangedListener(new AfterTextChanged(editable -> {
        boolean isEnabled = editable.length() > 0;
        smsButton.setEnabled(isEnabled);
        shareButton.setEnabled(isEnabled);
        smsButton.animate().alpha(isEnabled ? 1f : 0.5f);
        shareButton.animate().alpha(isEnabled ? 1f : 0.5f);
    }));
    updateSmsButtonText(contactsFragment.getSelectedContacts().size());
    smsCancelButton.setOnClickListener(new SmsCancelClickListener());
    smsSendButton.setOnClickListener(new SmsSendClickListener());
    contactFilter.setOnFilterChangedListener(new ContactFilterChangedListener());
    if (Util.isDefaultSmsProvider(this)) {
        shareButton.setOnClickListener(new ShareClickListener());
        smsButton.setOnClickListener(new SmsClickListener());
    } else {
        smsButton.setVisibility(View.GONE);
        shareText.setText(R.string.InviteActivity_share);
        shareButton.setOnClickListener(new ShareClickListener());
    }
}
Also used : Context(android.content.Context) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) MessageSender(org.thoughtcrime.securesms.sms.MessageSender) Util(org.thoughtcrime.securesms.util.Util) SelectionLimits(org.thoughtcrime.securesms.groups.SelectionLimits) AnimRes(androidx.annotation.AnimRes) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) Intent(android.content.Intent) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) ProgressDialogAsyncTask(org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask) AnimationUtils(android.view.animation.AnimationUtils) DynamicTheme(org.thoughtcrime.securesms.util.DynamicTheme) SuppressLint(android.annotation.SuppressLint) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) DynamicNoActionBarInviteTheme(org.thoughtcrime.securesms.util.DynamicNoActionBarInviteTheme) Toast(android.widget.Toast) View(android.view.View) Button(android.widget.Button) Recipient(org.thoughtcrime.securesms.recipients.Recipient) Animation(android.view.animation.Animation) OutgoingTextMessage(org.thoughtcrime.securesms.sms.OutgoingTextMessage) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) AsyncTask(android.os.AsyncTask) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged) ViewGroup(android.view.ViewGroup) OnFilterChangedListener(org.thoughtcrime.securesms.components.ContactFilterView.OnFilterChangedListener) Optional(org.whispersystems.libsignal.util.guava.Optional) ExecutionException(java.util.concurrent.ExecutionException) Consumer(java.util.function.Consumer) TextView(android.widget.TextView) SelectedContact(org.thoughtcrime.securesms.contacts.SelectedContact) Toolbar(androidx.appcompat.widget.Toolbar) Listener(org.thoughtcrime.securesms.util.concurrent.ListenableFuture.Listener) EditText(android.widget.EditText) OnClickListener(android.view.View.OnClickListener) DisplayMode(org.thoughtcrime.securesms.contacts.ContactsCursorLoader.DisplayMode) Button(android.widget.Button) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) TextView(android.widget.TextView) View(android.view.View) ContactFilterView(org.thoughtcrime.securesms.components.ContactFilterView) TextView(android.widget.TextView) AfterTextChanged(org.thoughtcrime.securesms.util.text.AfterTextChanged)

Example 4 with ContactFilterView

use of org.thoughtcrime.securesms.components.ContactFilterView in project Signal-Android by signalapp.

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

View (android.view.View)4 Toolbar (androidx.appcompat.widget.Toolbar)4 ContactFilterView (org.thoughtcrime.securesms.components.ContactFilterView)4 SuppressLint (android.annotation.SuppressLint)2 Context (android.content.Context)2 Intent (android.content.Intent)2 AsyncTask (android.os.AsyncTask)2 Bundle (android.os.Bundle)2 OnClickListener (android.view.View.OnClickListener)2 ViewGroup (android.view.ViewGroup)2 Animation (android.view.animation.Animation)2 AnimationUtils (android.view.animation.AnimationUtils)2 Button (android.widget.Button)2 EditText (android.widget.EditText)2 TextView (android.widget.TextView)2 Toast (android.widget.Toast)2 AnimRes (androidx.annotation.AnimRes)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 Fragment (androidx.fragment.app.Fragment)2 FastOutSlowInInterpolator (androidx.interpolator.view.animation.FastOutSlowInInterpolator)2