use correct send and attach buttons
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 754 B |
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 496 B |
Before Width: | Height: | Size: 956 B After Width: | Height: | Size: 988 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
@ -211,7 +211,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@drawable/circle_touch_highlight_background"
|
android:background="@drawable/circle_touch_highlight_background"
|
||||||
android:src="@drawable/ic_add_white_24dp"
|
android:src="@drawable/ic_attach_white_24dp"
|
||||||
android:contentDescription="@string/ConversationActivity_add_attachment"
|
android:contentDescription="@string/ConversationActivity_add_attachment"
|
||||||
android:nextFocusLeft="@+id/embedded_text_editor" />
|
android:nextFocusLeft="@+id/embedded_text_editor" />
|
||||||
|
|
||||||
|
|
|
@ -757,6 +757,7 @@
|
||||||
<string name="contact_selection_list_fragment__show_contacts">Show Contacts</string>
|
<string name="contact_selection_list_fragment__show_contacts">Show Contacts</string>
|
||||||
|
|
||||||
<!-- conversation_activity -->
|
<!-- conversation_activity -->
|
||||||
|
<string name="conversation_activity__type_message">Message</string>
|
||||||
<string name="conversation_activity__type_message_push">Delta Chat message</string>
|
<string name="conversation_activity__type_message_push">Delta Chat message</string>
|
||||||
<string name="conversation_activity__type_message_sms_insecure">Unsecured SMS</string>
|
<string name="conversation_activity__type_message_sms_insecure">Unsecured SMS</string>
|
||||||
<string name="conversation_activity__type_message_mms_insecure">Unsecured MMS</string>
|
<string name="conversation_activity__type_message_mms_insecure">Unsecured MMS</string>
|
||||||
|
|
|
@ -873,15 +873,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
this.isDefaultSms = isDefaultSms;
|
this.isDefaultSms = isDefaultSms;
|
||||||
this.isSecurityInitialized = true;
|
this.isSecurityInitialized = true;
|
||||||
|
|
||||||
boolean isMediaMessage = recipient.isMmsGroupRecipient() || attachmentManager.isAttachmentPresent();
|
sendButton.resetAvailableTransports();
|
||||||
|
sendButton.setDefaultTransport(Type.TEXTSECURE);
|
||||||
sendButton.resetAvailableTransports(isMediaMessage);
|
|
||||||
|
|
||||||
if (!isSecureText && !isPushGroupConversation()) sendButton.disableTransport(Type.TEXTSECURE);
|
|
||||||
if (recipient.isPushGroupRecipient()) sendButton.disableTransport(Type.SMS);
|
|
||||||
|
|
||||||
if (isSecureText || isPushGroupConversation()) sendButton.setDefaultTransport(Type.TEXTSECURE);
|
|
||||||
else sendButton.setDefaultTransport(Type.SMS);
|
|
||||||
|
|
||||||
calculateCharactersRemaining();
|
calculateCharactersRemaining();
|
||||||
supportInvalidateOptionsMenu();
|
supportInvalidateOptionsMenu();
|
||||||
|
@ -1003,7 +996,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
private void onSecurityUpdated() {
|
private void onSecurityUpdated() {
|
||||||
Log.w(TAG, "onSecurityUpdated()");
|
Log.w(TAG, "onSecurityUpdated()");
|
||||||
updateReminders();
|
updateReminders();
|
||||||
updateDefaultSubscriptionId(recipient.getDefaultSubscriptionId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateReminders() {
|
protected void updateReminders() {
|
||||||
|
@ -1014,11 +1006,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDefaultSubscriptionId(Optional<Integer> defaultSubscriptionId) {
|
|
||||||
Log.w(TAG, "updateDefaultSubscriptionId(" + defaultSubscriptionId.orNull() + ")");
|
|
||||||
sendButton.setDefaultSubscriptionId(defaultSubscriptionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeViews() {
|
private void initializeViews() {
|
||||||
ActionBar supportActionBar = getSupportActionBar();
|
ActionBar supportActionBar = getSupportActionBar();
|
||||||
if (supportActionBar == null) throw new AssertionError();
|
if (supportActionBar == null) throw new AssertionError();
|
||||||
|
@ -1123,7 +1110,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||||
setBlockedUserState(recipient, isSecureText, isDefaultSms);
|
setBlockedUserState(recipient, isSecureText, isDefaultSms);
|
||||||
setGroupShareProfileReminder(recipient);
|
setGroupShareProfileReminder(recipient);
|
||||||
updateReminders();
|
updateReminders();
|
||||||
updateDefaultSubscriptionId(recipient.getDefaultSubscriptionId());
|
|
||||||
initializeSecurity(isSecureText, isDefaultSms);
|
initializeSecurity(isSecureText, isDefaultSms);
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
package org.thoughtcrime.securesms;
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.CharacterCalculator;
|
|
||||||
import org.thoughtcrime.securesms.util.MmsCharacterCalculator;
|
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
|
||||||
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
||||||
import org.thoughtcrime.securesms.util.SmsCharacterCalculator;
|
|
||||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat;
|
|
||||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat;
|
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -27,18 +20,16 @@ public class TransportOptions {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final List<TransportOption> enabledTransports;
|
private final List<TransportOption> enabledTransports;
|
||||||
|
|
||||||
private Type defaultTransportType = Type.SMS;
|
private Type defaultTransportType = Type.TEXTSECURE;
|
||||||
private Optional<Integer> defaultSubscriptionId = Optional.absent();
|
|
||||||
private Optional<TransportOption> selectedOption = Optional.absent();
|
private Optional<TransportOption> selectedOption = Optional.absent();
|
||||||
|
|
||||||
public TransportOptions(Context context, boolean media) {
|
public TransportOptions(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.enabledTransports = initializeAvailableTransports(media);
|
this.enabledTransports = initializeAvailableTransports();
|
||||||
this.defaultSubscriptionId = new SubscriptionManagerCompat(context).getPreferredSubscriptionId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(boolean media) {
|
public void reset() {
|
||||||
List<TransportOption> transportOptions = initializeAvailableTransports(media);
|
List<TransportOption> transportOptions = initializeAvailableTransports();
|
||||||
|
|
||||||
this.enabledTransports.clear();
|
this.enabledTransports.clear();
|
||||||
this.enabledTransports.addAll(transportOptions);
|
this.enabledTransports.addAll(transportOptions);
|
||||||
|
@ -46,8 +37,7 @@ public class TransportOptions {
|
||||||
if (selectedOption.isPresent() && !isEnabled(selectedOption.get())) {
|
if (selectedOption.isPresent() && !isEnabled(selectedOption.get())) {
|
||||||
setSelectedTransport(null);
|
setSelectedTransport(null);
|
||||||
} else {
|
} else {
|
||||||
this.defaultTransportType = Type.SMS;
|
this.defaultTransportType = Type.TEXTSECURE;
|
||||||
this.defaultSubscriptionId = Optional.absent();
|
|
||||||
|
|
||||||
notifyTransportChangeListeners();
|
notifyTransportChangeListeners();
|
||||||
}
|
}
|
||||||
|
@ -61,14 +51,6 @@ public class TransportOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultSubscriptionId(Optional<Integer> subscriptionId) {
|
|
||||||
this.defaultSubscriptionId = subscriptionId;
|
|
||||||
|
|
||||||
if (!selectedOption.isPresent()) {
|
|
||||||
notifyTransportChangeListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectedTransport(@Nullable TransportOption transportOption) {
|
public void setSelectedTransport(@Nullable TransportOption transportOption) {
|
||||||
this.selectedOption = Optional.fromNullable(transportOption);
|
this.selectedOption = Optional.fromNullable(transportOption);
|
||||||
notifyTransportChangeListeners();
|
notifyTransportChangeListeners();
|
||||||
|
@ -81,16 +63,6 @@ public class TransportOptions {
|
||||||
public @NonNull TransportOption getSelectedTransport() {
|
public @NonNull TransportOption getSelectedTransport() {
|
||||||
if (selectedOption.isPresent()) return selectedOption.get();
|
if (selectedOption.isPresent()) return selectedOption.get();
|
||||||
|
|
||||||
if (defaultSubscriptionId.isPresent()) {
|
|
||||||
for (TransportOption transportOption : enabledTransports) {
|
|
||||||
if (transportOption.getType() == defaultTransportType &&
|
|
||||||
(int)defaultSubscriptionId.get() == transportOption.getSimSubscriptionId().or(-1))
|
|
||||||
{
|
|
||||||
return transportOption;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TransportOption transportOption : enabledTransports) {
|
for (TransportOption transportOption : enabledTransports) {
|
||||||
if (transportOption.getType() == defaultTransportType) {
|
if (transportOption.getType() == defaultTransportType) {
|
||||||
return transportOption;
|
return transportOption;
|
||||||
|
@ -120,59 +92,18 @@ public class TransportOptions {
|
||||||
this.listeners.add(listener);
|
this.listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TransportOption> initializeAvailableTransports(boolean isMediaMessage) {
|
private List<TransportOption> initializeAvailableTransports() {
|
||||||
List<TransportOption> results = new LinkedList<>();
|
List<TransportOption> results = new LinkedList<>();
|
||||||
|
|
||||||
if (isMediaMessage) {
|
results.add(new TransportOption(Type.TEXTSECURE, R.drawable.ic_send_sms_white_24dp,
|
||||||
results.addAll(getTransportOptionsForSimCards(context.getString(R.string.ConversationActivity_transport_insecure_mms),
|
|
||||||
context.getString(R.string.conversation_activity__type_message_mms_insecure),
|
|
||||||
new MmsCharacterCalculator()));
|
|
||||||
} else {
|
|
||||||
results.addAll(getTransportOptionsForSimCards(context.getString(R.string.ConversationActivity_transport_insecure_sms),
|
|
||||||
context.getString(R.string.conversation_activity__type_message_sms_insecure),
|
|
||||||
new SmsCharacterCalculator()));
|
|
||||||
}
|
|
||||||
|
|
||||||
results.add(new TransportOption(Type.TEXTSECURE, R.drawable.ic_send_push_white_24dp,
|
|
||||||
context.getResources().getColor(R.color.textsecure_primary),
|
context.getResources().getColor(R.color.textsecure_primary),
|
||||||
context.getString(R.string.ConversationActivity_transport_signal),
|
context.getString(R.string.ConversationActivity_transport_signal),
|
||||||
context.getString(R.string.conversation_activity__type_message_push),
|
context.getString(R.string.conversation_activity__type_message),
|
||||||
new PushCharacterCalculator()));
|
new PushCharacterCalculator()));
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NonNull List<TransportOption> getTransportOptionsForSimCards(@NonNull String text,
|
|
||||||
@NonNull String composeHint,
|
|
||||||
@NonNull CharacterCalculator characterCalculator)
|
|
||||||
{
|
|
||||||
List<TransportOption> results = new LinkedList<>();
|
|
||||||
SubscriptionManagerCompat subscriptionManager = new SubscriptionManagerCompat(context);
|
|
||||||
List<SubscriptionInfoCompat> subscriptions;
|
|
||||||
|
|
||||||
if (Permissions.hasAll(context, Manifest.permission.READ_PHONE_STATE)) {
|
|
||||||
subscriptions = subscriptionManager.getActiveSubscriptionInfoList();
|
|
||||||
} else {
|
|
||||||
subscriptions = new LinkedList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subscriptions.size() < 2) {
|
|
||||||
results.add(new TransportOption(Type.SMS, R.drawable.ic_send_sms_white_24dp,
|
|
||||||
context.getResources().getColor(R.color.grey_600),
|
|
||||||
text, composeHint, characterCalculator));
|
|
||||||
} else {
|
|
||||||
for (SubscriptionInfoCompat subscriptionInfo : subscriptions) {
|
|
||||||
results.add(new TransportOption(Type.SMS, R.drawable.ic_send_sms_white_24dp,
|
|
||||||
context.getResources().getColor(R.color.grey_600),
|
|
||||||
text, composeHint, characterCalculator,
|
|
||||||
Optional.of(subscriptionInfo.getDisplayName()),
|
|
||||||
Optional.of(subscriptionInfo.getSubscriptionId())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyTransportChangeListeners() {
|
private void notifyTransportChangeListeners() {
|
||||||
for (OnTransportChangedListener listener : listeners) {
|
for (OnTransportChangedListener listener : listeners) {
|
||||||
listener.onChange(getSelectedTransport(), selectedOption.isPresent());
|
listener.onChange(getSelectedTransport(), selectedOption.isPresent());
|
||||||
|
|
|
@ -25,26 +25,26 @@ public class SendButton extends ImageButton
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public SendButton(Context context) {
|
public SendButton(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
this.transportOptions = initializeTransportOptions();
|
||||||
ViewUtil.mirrorIfRtl(this, getContext());
|
ViewUtil.mirrorIfRtl(this, getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public SendButton(Context context, AttributeSet attrs) {
|
public SendButton(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
this.transportOptions = initializeTransportOptions();
|
||||||
ViewUtil.mirrorIfRtl(this, getContext());
|
ViewUtil.mirrorIfRtl(this, getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public SendButton(Context context, AttributeSet attrs, int defStyle) {
|
public SendButton(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
this.transportOptions = initializeTransportOptions();
|
||||||
ViewUtil.mirrorIfRtl(this, getContext());
|
ViewUtil.mirrorIfRtl(this, getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransportOptions initializeTransportOptions(boolean media) {
|
private TransportOptions initializeTransportOptions() {
|
||||||
TransportOptions transportOptions = new TransportOptions(getContext(), media);
|
TransportOptions transportOptions = new TransportOptions(getContext());
|
||||||
transportOptions.addOnTransportChangedListener(this);
|
transportOptions.addOnTransportChangedListener(this);
|
||||||
|
|
||||||
setOnLongClickListener(this);
|
setOnLongClickListener(this);
|
||||||
|
@ -71,8 +71,8 @@ public class SendButton extends ImageButton
|
||||||
return transportOptions.getSelectedTransport();
|
return transportOptions.getSelectedTransport();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetAvailableTransports(boolean isMediaMessage) {
|
public void resetAvailableTransports() {
|
||||||
transportOptions.reset(isMediaMessage);
|
transportOptions.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableTransport(TransportOption.Type type) {
|
public void disableTransport(TransportOption.Type type) {
|
||||||
|
@ -83,10 +83,6 @@ public class SendButton extends ImageButton
|
||||||
transportOptions.setDefaultTransport(type);
|
transportOptions.setDefaultTransport(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultSubscriptionId(Optional<Integer> subscriptionId) {
|
|
||||||
transportOptions.setDefaultSubscriptionId(subscriptionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelected(TransportOption option) {
|
public void onSelected(TransportOption option) {
|
||||||
transportOptions.setSelectedTransport(option);
|
transportOptions.setSelectedTransport(option);
|
||||||
|
|