2014-07-19 02:31:03 +00:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2015-07-01 00:45:39 +00:00
|
|
|
import android.support.annotation.DrawableRes;
|
2016-02-06 00:10:33 +00:00
|
|
|
import android.support.annotation.NonNull;
|
2015-07-01 00:45:39 +00:00
|
|
|
|
2015-02-16 10:38:09 +00:00
|
|
|
import org.thoughtcrime.securesms.util.CharacterCalculator;
|
|
|
|
import org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState;
|
2016-03-23 17:34:41 +00:00
|
|
|
import org.whispersystems.libsignal.util.guava.Optional;
|
2015-02-16 10:38:09 +00:00
|
|
|
|
2014-07-19 02:31:03 +00:00
|
|
|
public class TransportOption {
|
2015-03-11 21:23:45 +00:00
|
|
|
|
|
|
|
public enum Type {
|
|
|
|
SMS,
|
|
|
|
TEXTSECURE
|
|
|
|
}
|
|
|
|
|
2016-02-06 00:10:33 +00:00
|
|
|
private final int drawable;
|
|
|
|
private final int backgroundColor;
|
|
|
|
private final @NonNull String text;
|
|
|
|
private final @NonNull Type type;
|
|
|
|
private final @NonNull String composeHint;
|
|
|
|
private final @NonNull CharacterCalculator characterCalculator;
|
|
|
|
private final @NonNull Optional<CharSequence> simName;
|
|
|
|
private final @NonNull Optional<Integer> simSubscriptionId;
|
2015-03-11 21:23:45 +00:00
|
|
|
|
2016-02-06 00:10:33 +00:00
|
|
|
public TransportOption(@NonNull Type type,
|
2015-07-01 00:45:39 +00:00
|
|
|
@DrawableRes int drawable,
|
|
|
|
int backgroundColor,
|
2016-02-06 00:10:33 +00:00
|
|
|
@NonNull String text,
|
|
|
|
@NonNull String composeHint,
|
|
|
|
@NonNull CharacterCalculator characterCalculator)
|
|
|
|
{
|
|
|
|
this(type, drawable, backgroundColor, text, composeHint, characterCalculator,
|
|
|
|
Optional.<CharSequence>absent(), Optional.<Integer>absent());
|
|
|
|
}
|
|
|
|
|
|
|
|
public TransportOption(@NonNull Type type,
|
|
|
|
@DrawableRes int drawable,
|
|
|
|
int backgroundColor,
|
|
|
|
@NonNull String text,
|
|
|
|
@NonNull String composeHint,
|
|
|
|
@NonNull CharacterCalculator characterCalculator,
|
|
|
|
@NonNull Optional<CharSequence> simName,
|
|
|
|
@NonNull Optional<Integer> simSubscriptionId)
|
2015-03-11 21:23:45 +00:00
|
|
|
{
|
|
|
|
this.type = type;
|
|
|
|
this.drawable = drawable;
|
2015-07-01 00:45:39 +00:00
|
|
|
this.backgroundColor = backgroundColor;
|
2015-03-11 21:23:45 +00:00
|
|
|
this.text = text;
|
|
|
|
this.composeHint = composeHint;
|
|
|
|
this.characterCalculator = characterCalculator;
|
2016-02-06 00:10:33 +00:00
|
|
|
this.simName = simName;
|
|
|
|
this.simSubscriptionId = simSubscriptionId;
|
2015-03-11 21:23:45 +00:00
|
|
|
}
|
|
|
|
|
2016-02-06 00:10:33 +00:00
|
|
|
|
|
|
|
public @NonNull Type getType() {
|
2015-03-11 21:23:45 +00:00
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isType(Type type) {
|
|
|
|
return this.type == type;
|
2014-07-19 02:31:03 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 10:38:09 +00:00
|
|
|
public boolean isSms() {
|
2015-03-11 21:23:45 +00:00
|
|
|
return type == Type.SMS;
|
2014-07-19 02:31:03 +00:00
|
|
|
}
|
|
|
|
|
2016-04-17 16:09:31 +00:00
|
|
|
public CharacterState calculateCharacters(String messageBody) {
|
|
|
|
return characterCalculator.calculateCharacters(messageBody);
|
2015-02-16 10:38:09 +00:00
|
|
|
}
|
2015-03-11 21:23:45 +00:00
|
|
|
|
2015-07-01 00:45:39 +00:00
|
|
|
public @DrawableRes int getDrawable() {
|
2015-03-11 21:23:45 +00:00
|
|
|
return drawable;
|
|
|
|
}
|
|
|
|
|
2015-07-01 00:45:39 +00:00
|
|
|
public int getBackgroundColor() {
|
|
|
|
return backgroundColor;
|
|
|
|
}
|
|
|
|
|
2016-02-06 00:10:33 +00:00
|
|
|
public @NonNull String getComposeHint() {
|
2015-03-11 21:23:45 +00:00
|
|
|
return composeHint;
|
|
|
|
}
|
|
|
|
|
2016-02-06 00:10:33 +00:00
|
|
|
public @NonNull String getDescription() {
|
2015-03-11 21:23:45 +00:00
|
|
|
return text;
|
|
|
|
}
|
2016-02-06 00:10:33 +00:00
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public Optional<CharSequence> getSimName() {
|
|
|
|
return simName;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public Optional<Integer> getSimSubscriptionId() {
|
|
|
|
return simSubscriptionId;
|
|
|
|
}
|
|
|
|
|
2015-02-16 10:38:09 +00:00
|
|
|
}
|