|
|
|
@ -9,6 +9,7 @@ import org.thoughtcrime.securesms.TransportOption;
|
|
|
|
|
import org.thoughtcrime.securesms.TransportOptions;
|
|
|
|
|
import org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener;
|
|
|
|
|
import org.thoughtcrime.securesms.TransportOptionsPopup;
|
|
|
|
|
import org.whispersystems.libaxolotl.util.guava.Optional;
|
|
|
|
|
|
|
|
|
|
public class SendButton extends ImageButton
|
|
|
|
|
implements TransportOptions.OnTransportChangedListener,
|
|
|
|
@ -17,27 +18,25 @@ public class SendButton extends ImageButton
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private final TransportOptions transportOptions;
|
|
|
|
|
private final TransportOptionsPopup transportOptionsPopup;
|
|
|
|
|
|
|
|
|
|
private Optional<TransportOptionsPopup> transportOptionsPopup = Optional.absent();
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
public SendButton(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
this.transportOptions = initializeTransportOptions(false);
|
|
|
|
|
this.transportOptionsPopup = initializeTransportOptionsPopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
public SendButton(Context context, AttributeSet attrs) {
|
|
|
|
|
super(context, attrs);
|
|
|
|
|
this.transportOptions = initializeTransportOptions(false);
|
|
|
|
|
this.transportOptionsPopup = initializeTransportOptionsPopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
public SendButton(Context context, AttributeSet attrs, int defStyle) {
|
|
|
|
|
super(context, attrs, defStyle);
|
|
|
|
|
this.transportOptions = initializeTransportOptions(false);
|
|
|
|
|
this.transportOptionsPopup = initializeTransportOptionsPopup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TransportOptions initializeTransportOptions(boolean media) {
|
|
|
|
@ -49,8 +48,11 @@ public class SendButton extends ImageButton
|
|
|
|
|
return transportOptions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TransportOptionsPopup initializeTransportOptionsPopup() {
|
|
|
|
|
return new TransportOptionsPopup(getContext(), this, this);
|
|
|
|
|
private TransportOptionsPopup getTransportOptionsPopup() {
|
|
|
|
|
if (!transportOptionsPopup.isPresent()) {
|
|
|
|
|
transportOptionsPopup = Optional.of(new TransportOptionsPopup(getContext(), this, this));
|
|
|
|
|
}
|
|
|
|
|
return transportOptionsPopup.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isManualSelection() {
|
|
|
|
@ -80,7 +82,7 @@ public class SendButton extends ImageButton
|
|
|
|
|
@Override
|
|
|
|
|
public void onSelected(TransportOption option) {
|
|
|
|
|
transportOptions.setSelectedTransport(option.getType());
|
|
|
|
|
transportOptionsPopup.dismiss();
|
|
|
|
|
getTransportOptionsPopup().dismiss();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -92,7 +94,7 @@ public class SendButton extends ImageButton
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
|
if (transportOptions.getEnabledTransports().size() > 1) {
|
|
|
|
|
transportOptionsPopup.display(transportOptions.getEnabledTransports());
|
|
|
|
|
getTransportOptionsPopup().display(transportOptions.getEnabledTransports());
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|