2014-07-19 02:31:03 +00:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2015-02-16 10:38:09 +00:00
|
|
|
import org.thoughtcrime.securesms.util.CharacterCalculator;
|
|
|
|
import org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState;
|
|
|
|
import org.thoughtcrime.securesms.util.EncryptedSmsCharacterCalculator;
|
|
|
|
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
|
|
|
import org.thoughtcrime.securesms.util.SmsCharacterCalculator;
|
|
|
|
|
2014-07-19 02:31:03 +00:00
|
|
|
public class TransportOption {
|
2015-02-16 10:38:09 +00:00
|
|
|
public int drawable;
|
|
|
|
public String text;
|
|
|
|
public String key;
|
|
|
|
public String composeHint;
|
|
|
|
public CharacterCalculator characterCalculator;
|
2014-07-19 02:31:03 +00:00
|
|
|
|
|
|
|
public TransportOption(String key, int drawable, String text, String composeHint) {
|
|
|
|
this.key = key;
|
|
|
|
this.drawable = drawable;
|
|
|
|
this.text = text;
|
|
|
|
this.composeHint = composeHint;
|
2015-02-16 10:38:09 +00:00
|
|
|
|
|
|
|
if (isPlaintext() && isSms()) {
|
|
|
|
this.characterCalculator = new SmsCharacterCalculator();
|
|
|
|
} else if (isSms()) {
|
|
|
|
this.characterCalculator = new EncryptedSmsCharacterCalculator();
|
|
|
|
} else {
|
|
|
|
this.characterCalculator = new PushCharacterCalculator();
|
|
|
|
}
|
2014-07-19 02:31:03 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 10:38:09 +00:00
|
|
|
public boolean isPlaintext() {
|
2014-07-19 02:31:03 +00:00
|
|
|
return key.equals("insecure_sms");
|
|
|
|
}
|
|
|
|
|
2015-02-16 10:38:09 +00:00
|
|
|
public boolean isSms() {
|
2014-07-19 02:31:03 +00:00
|
|
|
return key.equals("insecure_sms") || key.equals("secure_sms");
|
|
|
|
}
|
|
|
|
|
2015-02-16 10:38:09 +00:00
|
|
|
public CharacterState calculateCharacters(int charactersSpent) {
|
|
|
|
return characterCalculator.calculateCharacters(charactersSpent);
|
|
|
|
}
|
|
|
|
}
|