Commit 100c71e5 authored by Bastien Le Querrec's avatar Bastien Le Querrec

fix crash if no SIM card is inserted

parent e36f6846
...@@ -371,6 +371,10 @@ ...@@ -371,6 +371,10 @@
<string name="ThreadRecord_draft">Draft:</string> <string name="ThreadRecord_draft">Draft:</string>
<string name="ThreadRecord_media_message">Media message</string> <string name="ThreadRecord_media_message">Media message</string>
<!-- TransportOptions -->
<string name="TransportOptions_sms_disabled">SMS messages disabled</string>
<string name="TransportOptions_no_sim_card_found">No SIM card found</string>
<!-- VerifyIdentityActivity --> <!-- VerifyIdentityActivity -->
<string name="VerifyIdentityActivity_you_do_not_have_an_identity_key">You do not have an identity key.</string> <string name="VerifyIdentityActivity_you_do_not_have_an_identity_key">You do not have an identity key.</string>
<string name="VerifyIdentityActivity_recipient_has_no_identity_key">Recipient has no identity key.</string> <string name="VerifyIdentityActivity_recipient_has_no_identity_key">Recipient has no identity key.</string>
......
...@@ -1300,6 +1300,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity ...@@ -1300,6 +1300,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} }
private void sendMessage() { private void sendMessage() {
TransportOption transportOption = sendButton.getSelectedTransport();
if (transportOption == null || transportOption.getType() == Type.DISABLED) return;
try { try {
Recipients recipients = getRecipients(); Recipients recipients = getRecipients();
......
...@@ -12,6 +12,7 @@ import org.whispersystems.libsignal.util.guava.Optional; ...@@ -12,6 +12,7 @@ import org.whispersystems.libsignal.util.guava.Optional;
public class TransportOption { public class TransportOption {
public enum Type { public enum Type {
DISABLED,
INSECURE_SMS, INSECURE_SMS,
SECURE_SMS SECURE_SMS
} }
......
...@@ -8,6 +8,7 @@ import android.support.annotation.Nullable; ...@@ -8,6 +8,7 @@ import android.support.annotation.Nullable;
import org.smssecure.smssecure.permissions.Permissions; import org.smssecure.smssecure.permissions.Permissions;
import org.smssecure.smssecure.util.CharacterCalculator; import org.smssecure.smssecure.util.CharacterCalculator;
import org.smssecure.smssecure.util.DummyCharacterCalculator;
import org.smssecure.smssecure.util.MmsCharacterCalculator; import org.smssecure.smssecure.util.MmsCharacterCalculator;
import org.smssecure.smssecure.util.SmsCharacterCalculator; import org.smssecure.smssecure.util.SmsCharacterCalculator;
import org.smssecure.smssecure.util.EncryptedSmsCharacterCalculator; import org.smssecure.smssecure.util.EncryptedSmsCharacterCalculator;
...@@ -99,7 +100,7 @@ public class TransportOptions { ...@@ -99,7 +100,7 @@ public class TransportOptions {
} }
} }
throw new AssertionError("No options of default type!"); return getDefaultTransportOption();
} }
public void disableTransport(Type type) { public void disableTransport(Type type) {
...@@ -220,4 +221,15 @@ public class TransportOptions { ...@@ -220,4 +221,15 @@ public class TransportOptions {
public interface OnTransportChangedListener { public interface OnTransportChangedListener {
public void onChange(TransportOption newTransport, boolean manuallySelected); public void onChange(TransportOption newTransport, boolean manuallySelected);
} }
private TransportOption getDefaultTransportOption() {
return new TransportOption(Type.DISABLED,
R.drawable.ic_send_insecure_white_24dp,
context.getResources().getColor(R.color.grey_600),
context.getString(R.string.TransportOptions_sms_disabled),
context.getString(R.string.TransportOptions_no_sim_card_found),
new DummyCharacterCalculator(),
Optional.of((CharSequence) ""),
Optional.of(-1));
}
} }
package org.smssecure.smssecure.util;
public class DummyCharacterCalculator extends CharacterCalculator {
@Override
public CharacterState calculateCharacters(String messageBody) {
return new CharacterState(0, 0, 0);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment