session-android/src/org/thoughtcrime/securesms/TransportOption.java
Jake McGinty f818cfa32b Unjank character count indicators
Fixes #1841
// FREEBIE
2015-02-16 13:25:44 -08:00

43 lines
1.4 KiB
Java

package org.thoughtcrime.securesms;
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;
public class TransportOption {
public int drawable;
public String text;
public String key;
public String composeHint;
public CharacterCalculator characterCalculator;
public TransportOption(String key, int drawable, String text, String composeHint) {
this.key = key;
this.drawable = drawable;
this.text = text;
this.composeHint = composeHint;
if (isPlaintext() && isSms()) {
this.characterCalculator = new SmsCharacterCalculator();
} else if (isSms()) {
this.characterCalculator = new EncryptedSmsCharacterCalculator();
} else {
this.characterCalculator = new PushCharacterCalculator();
}
}
public boolean isPlaintext() {
return key.equals("insecure_sms");
}
public boolean isSms() {
return key.equals("insecure_sms") || key.equals("secure_sms");
}
public CharacterState calculateCharacters(int charactersSpent) {
return characterCalculator.calculateCharacters(charactersSpent);
}
}