mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-04 07:25:16 +00:00
prevent blocking recipient resolution on UI thread
fixes #4058 Closes #4059 // FREEBIE
This commit is contained in:
parent
2c48155769
commit
8933e03c02
@ -38,7 +38,7 @@ public class SmsSendtoActivity extends Activity {
|
|||||||
destination = getDestinationForView(original);
|
destination = getDestinationForView(original);
|
||||||
}
|
}
|
||||||
|
|
||||||
Recipients recipients = RecipientFactory.getRecipientsFromString(this, destination.getDestination(), false);
|
Recipients recipients = RecipientFactory.getRecipientsFromString(this, destination.getDestination(), true);
|
||||||
long threadId = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipients);
|
long threadId = DatabaseFactory.getThreadDatabase(this).getThreadIdIfExistsFor(recipients);
|
||||||
|
|
||||||
final Intent nextIntent;
|
final Intent nextIntent;
|
||||||
|
@ -36,6 +36,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients.RecipientsModifiedListener;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -49,7 +50,7 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author Moxie Marlinspike
|
* @author Moxie Marlinspike
|
||||||
*/
|
*/
|
||||||
public class PushRecipientsPanel extends RelativeLayout {
|
public class PushRecipientsPanel extends RelativeLayout implements RecipientsModifiedListener {
|
||||||
private final String TAG = PushRecipientsPanel.class.getSimpleName();
|
private final String TAG = PushRecipientsPanel.class.getSimpleName();
|
||||||
private RecipientsPanelChangedListener panelChangeListener;
|
private RecipientsPanelChangedListener panelChangeListener;
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ public class PushRecipientsPanel extends RelativeLayout {
|
|||||||
|
|
||||||
public Recipients getRecipients() throws RecipientFormattingException {
|
public Recipients getRecipients() throws RecipientFormattingException {
|
||||||
String rawText = recipientsText.getText().toString();
|
String rawText = recipientsText.getText().toString();
|
||||||
Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(), rawText, false);
|
Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(), rawText, true);
|
||||||
|
|
||||||
if (recipients.isEmpty())
|
if (recipients.isEmpty())
|
||||||
throw new RecipientFormattingException("Recipient List Is Empty!");
|
throw new RecipientFormattingException("Recipient List Is Empty!");
|
||||||
@ -129,6 +130,7 @@ public class PushRecipientsPanel extends RelativeLayout {
|
|||||||
} catch (RecipientFormattingException e) {
|
} catch (RecipientFormattingException e) {
|
||||||
recipients = RecipientFactory.getRecipientsFor(getContext(), new LinkedList<Recipient>(), true);
|
recipients = RecipientFactory.getRecipientsFor(getContext(), new LinkedList<Recipient>(), true);
|
||||||
}
|
}
|
||||||
|
recipients.addListener(this);
|
||||||
|
|
||||||
recipientsText.setAdapter(new RecipientsAdapter(this.getContext()));
|
recipientsText.setAdapter(new RecipientsAdapter(this.getContext()));
|
||||||
recipientsText.populate(recipients);
|
recipientsText.populate(recipients);
|
||||||
@ -149,6 +151,10 @@ public class PushRecipientsPanel extends RelativeLayout {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void onModified(Recipients recipients) {
|
||||||
|
recipientsText.populate(recipients);
|
||||||
|
}
|
||||||
|
|
||||||
private class FocusChangedListener implements View.OnFocusChangeListener {
|
private class FocusChangedListener implements View.OnFocusChangeListener {
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if (!hasFocus && (panelChangeListener != null)) {
|
if (!hasFocus && (panelChangeListener != null)) {
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
package org.thoughtcrime.securesms.components;
|
package org.thoughtcrime.securesms.components;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@ -33,6 +32,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||||||
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients.RecipientsModifiedListener;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -44,7 +44,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Moxie Marlinspike
|
* @author Moxie Marlinspike
|
||||||
*/
|
*/
|
||||||
public class SingleRecipientPanel extends RelativeLayout {
|
public class SingleRecipientPanel extends RelativeLayout implements RecipientsModifiedListener {
|
||||||
private final String TAG = SingleRecipientPanel.class.getSimpleName();
|
private final String TAG = SingleRecipientPanel.class.getSimpleName();
|
||||||
private RecipientsPanelChangedListener panelChangeListener;
|
private RecipientsPanelChangedListener panelChangeListener;
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public class SingleRecipientPanel extends RelativeLayout {
|
|||||||
|
|
||||||
public Recipients getRecipients() throws RecipientFormattingException {
|
public Recipients getRecipients() throws RecipientFormattingException {
|
||||||
String rawText = recipientsText.getText().toString();
|
String rawText = recipientsText.getText().toString();
|
||||||
Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(), rawText, false);
|
Recipients recipients = RecipientFactory.getRecipientsFromString(getContext(), rawText, true);
|
||||||
|
|
||||||
if (recipients.isEmpty())
|
if (recipients.isEmpty())
|
||||||
throw new RecipientFormattingException("Recipient List Is Empty!");
|
throw new RecipientFormattingException("Recipient List Is Empty!");
|
||||||
@ -132,6 +132,7 @@ public class SingleRecipientPanel extends RelativeLayout {
|
|||||||
} catch (RecipientFormattingException e) {
|
} catch (RecipientFormattingException e) {
|
||||||
recipients = RecipientFactory.getRecipientsFor(getContext(), new LinkedList<Recipient>(), true);
|
recipients = RecipientFactory.getRecipientsFor(getContext(), new LinkedList<Recipient>(), true);
|
||||||
}
|
}
|
||||||
|
recipients.addListener(this);
|
||||||
|
|
||||||
recipientsText.setAdapter(new RecipientsAdapter(this.getContext()));
|
recipientsText.setAdapter(new RecipientsAdapter(this.getContext()));
|
||||||
recipientsText.populate(recipients);
|
recipientsText.populate(recipients);
|
||||||
@ -152,6 +153,10 @@ public class SingleRecipientPanel extends RelativeLayout {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void onModified(Recipients recipients) {
|
||||||
|
recipientsText.populate(recipients);
|
||||||
|
}
|
||||||
|
|
||||||
private class FocusChangedListener implements OnFocusChangeListener {
|
private class FocusChangedListener implements OnFocusChangeListener {
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if (!hasFocus && (panelChangeListener != null)) {
|
if (!hasFocus && (panelChangeListener != null)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user