mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 22:23:39 +00:00
parent
454c604b86
commit
2c41394892
@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.TransportOption;
|
|||||||
import org.thoughtcrime.securesms.TransportOptions;
|
import org.thoughtcrime.securesms.TransportOptions;
|
||||||
import org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener;
|
import org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener;
|
||||||
import org.thoughtcrime.securesms.TransportOptionsPopup;
|
import org.thoughtcrime.securesms.TransportOptionsPopup;
|
||||||
|
import org.whispersystems.libaxolotl.util.guava.Optional;
|
||||||
|
|
||||||
public class SendButton extends ImageButton
|
public class SendButton extends ImageButton
|
||||||
implements TransportOptions.OnTransportChangedListener,
|
implements TransportOptions.OnTransportChangedListener,
|
||||||
@ -16,28 +17,26 @@ public class SendButton extends ImageButton
|
|||||||
View.OnLongClickListener
|
View.OnLongClickListener
|
||||||
{
|
{
|
||||||
|
|
||||||
private final TransportOptions transportOptions;
|
private final TransportOptions transportOptions;
|
||||||
private final TransportOptionsPopup transportOptionsPopup;
|
|
||||||
|
private Optional<TransportOptionsPopup> transportOptionsPopup = Optional.absent();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public SendButton(Context context) {
|
public SendButton(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
this.transportOptions = initializeTransportOptions(false);
|
||||||
this.transportOptionsPopup = initializeTransportOptionsPopup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public SendButton(Context context, AttributeSet attrs) {
|
public SendButton(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
this.transportOptions = initializeTransportOptions(false);
|
||||||
this.transportOptionsPopup = initializeTransportOptionsPopup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public SendButton(Context context, AttributeSet attrs, int defStyle) {
|
public SendButton(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
this.transportOptions = initializeTransportOptions(false);
|
||||||
this.transportOptionsPopup = initializeTransportOptionsPopup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransportOptions initializeTransportOptions(boolean media) {
|
private TransportOptions initializeTransportOptions(boolean media) {
|
||||||
@ -49,8 +48,11 @@ public class SendButton extends ImageButton
|
|||||||
return transportOptions;
|
return transportOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransportOptionsPopup initializeTransportOptionsPopup() {
|
private TransportOptionsPopup getTransportOptionsPopup() {
|
||||||
return new TransportOptionsPopup(getContext(), this, this);
|
if (!transportOptionsPopup.isPresent()) {
|
||||||
|
transportOptionsPopup = Optional.of(new TransportOptionsPopup(getContext(), this, this));
|
||||||
|
}
|
||||||
|
return transportOptionsPopup.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isManualSelection() {
|
public boolean isManualSelection() {
|
||||||
@ -80,7 +82,7 @@ public class SendButton extends ImageButton
|
|||||||
@Override
|
@Override
|
||||||
public void onSelected(TransportOption option) {
|
public void onSelected(TransportOption option) {
|
||||||
transportOptions.setSelectedTransport(option.getType());
|
transportOptions.setSelectedTransport(option.getType());
|
||||||
transportOptionsPopup.dismiss();
|
getTransportOptionsPopup().dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -92,7 +94,7 @@ public class SendButton extends ImageButton
|
|||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
if (transportOptions.getEnabledTransports().size() > 1) {
|
if (transportOptions.getEnabledTransports().size() > 1) {
|
||||||
transportOptionsPopup.display(transportOptions.getEnabledTransports());
|
getTransportOptionsPopup().display(transportOptions.getEnabledTransports());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user