mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 12:35:17 +00:00
f818cfa32b
Fixes #1841 // FREEBIE
43 lines
1.4 KiB
Java
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);
|
|
}
|
|
}
|