mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Transport options removed. Conversation activity cleanup.
This commit is contained in:
parent
66aec427d4
commit
30af903572
@ -38,14 +38,6 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity implements
|
|||||||
private static final int NOTIFICATION_ID = 1339;
|
private static final int NOTIFICATION_ID = 1339;
|
||||||
|
|
||||||
private enum ExperienceUpgrade {
|
private enum ExperienceUpgrade {
|
||||||
READ_RECEIPTS(299,
|
|
||||||
new IntroPage(0xFF2090EA,
|
|
||||||
ReadReceiptsIntroFragment.newInstance()),
|
|
||||||
R.string.experience_upgrade_preference_fragment__read_receipts_are_here,
|
|
||||||
R.string.experience_upgrade_preference_fragment__optionally_see_and_share_when_messages_have_been_read,
|
|
||||||
R.string.experience_upgrade_preference_fragment__optionally_see_and_share_when_messages_have_been_read,
|
|
||||||
null,
|
|
||||||
false),
|
|
||||||
TYPING_INDICATORS(432,
|
TYPING_INDICATORS(432,
|
||||||
new IntroPage(0xFF2090EA,
|
new IntroPage(0xFF2090EA,
|
||||||
TypingIndicatorIntroFragment.newInstance()),
|
TypingIndicatorIntroFragment.newInstance()),
|
||||||
|
@ -146,7 +146,9 @@ public class PassphrasePromptActivity extends PassphraseActivity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultcode, Intent data) {
|
public void onActivityResult(int requestCode, int resultcode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultcode, data);
|
||||||
if (requestCode != 1) return;
|
if (requestCode != 1) return;
|
||||||
|
|
||||||
if (resultcode == RESULT_OK) {
|
if (resultcode == RESULT_OK) {
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms;
|
|
||||||
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.jobs.MultiDeviceConfigurationUpdateJob;
|
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
public class ReadReceiptsIntroFragment extends Fragment {
|
|
||||||
|
|
||||||
public static ReadReceiptsIntroFragment newInstance() {
|
|
||||||
ReadReceiptsIntroFragment fragment = new ReadReceiptsIntroFragment();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadReceiptsIntroFragment() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
||||||
View v = inflater.inflate(R.layout.experience_upgrade_preference_fragment, container, false);
|
|
||||||
SwitchCompat preference = ViewUtil.findById(v, R.id.preference);
|
|
||||||
|
|
||||||
preference.setChecked(TextSecurePreferences.isReadReceiptsEnabled(getContext()));
|
|
||||||
preference.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
||||||
TextSecurePreferences.setReadReceiptsEnabled(getContext(), isChecked);
|
|
||||||
ApplicationContext.getInstance(getContext())
|
|
||||||
.getJobManager()
|
|
||||||
.add(new MultiDeviceConfigurationUpdateJob(isChecked,
|
|
||||||
TextSecurePreferences.isTypingIndicatorsEnabled(requireContext()),
|
|
||||||
TextSecurePreferences.isShowUnidentifiedDeliveryIndicatorsEnabled(getContext()),
|
|
||||||
TextSecurePreferences.isLinkPreviewsEnabled(getContext())));
|
|
||||||
});
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
}
|
|
@ -73,7 +73,6 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
|
|||||||
public static final String EXTRA_ADDRESS_MARSHALLED = "address_marshalled";
|
public static final String EXTRA_ADDRESS_MARSHALLED = "address_marshalled";
|
||||||
public static final String EXTRA_DISTRIBUTION_TYPE = "distribution_type";
|
public static final String EXTRA_DISTRIBUTION_TYPE = "distribution_type";
|
||||||
|
|
||||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
|
||||||
|
|
||||||
private ContactSelectionListFragment contactsFragment;
|
private ContactSelectionListFragment contactsFragment;
|
||||||
private SearchToolbar searchToolbar;
|
private SearchToolbar searchToolbar;
|
||||||
@ -83,11 +82,6 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private String mimeType;
|
private String mimeType;
|
||||||
private boolean isPassingAlongMedia;
|
private boolean isPassingAlongMedia;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPreCreate() {
|
|
||||||
dynamicLanguage.onCreate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle icicle, boolean ready) {
|
protected void onCreate(Bundle icicle, boolean ready) {
|
||||||
if (!getIntent().hasExtra(ContactSelectionListFragment.DISPLAY_MODE)) {
|
if (!getIntent().hasExtra(ContactSelectionListFragment.DISPLAY_MODE)) {
|
||||||
@ -112,13 +106,6 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
|
|||||||
initializeMedia();
|
initializeMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
Log.i(TAG, "onResume()");
|
|
||||||
super.onResume();
|
|
||||||
dynamicLanguage.onResume(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
@ -291,7 +278,7 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
|
|||||||
InputStream inputStream;
|
InputStream inputStream;
|
||||||
|
|
||||||
if ("file".equals(uris[0].getScheme())) {
|
if ("file".equals(uris[0].getScheme())) {
|
||||||
inputStream = openFileUri(uris[0]);
|
inputStream = new FileInputStream(uris[0].getPath());
|
||||||
} else {
|
} else {
|
||||||
inputStream = context.getContentResolver().openInputStream(uris[0]);
|
inputStream = context.getContentResolver().openInputStream(uris[0]);
|
||||||
}
|
}
|
||||||
@ -333,18 +320,5 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
|
|||||||
resolvedExtra = uri;
|
resolvedExtra = uri;
|
||||||
handleResolvedMedia(getIntent(), true);
|
handleResolvedMedia(getIntent(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream openFileUri(Uri uri) throws IOException {
|
|
||||||
FileInputStream fin = new FileInputStream(uri.getPath());
|
|
||||||
// TODO: Remove the commented code if there are no issues with reading shared files by October 2020
|
|
||||||
// int owner = FileUtils.getFileDescriptorOwner(fin.getFD());
|
|
||||||
|
|
||||||
// if (owner == -1 || owner == Process.myUid()) {
|
|
||||||
// fin.close();
|
|
||||||
// throw new IOException("File owned by application");
|
|
||||||
// }
|
|
||||||
|
|
||||||
return fin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,127 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.CharacterCalculator;
|
|
||||||
import org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState;
|
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
public class TransportOption implements Parcelable {
|
|
||||||
|
|
||||||
public enum Type {
|
|
||||||
SMS,
|
|
||||||
TEXTSECURE
|
|
||||||
}
|
|
||||||
|
|
||||||
private final @NonNull String text;
|
|
||||||
private final @NonNull Type type;
|
|
||||||
private final @NonNull String composeHint;
|
|
||||||
private final @NonNull CharacterCalculator characterCalculator;
|
|
||||||
private final @NonNull Optional<CharSequence> simName;
|
|
||||||
private final @NonNull Optional<Integer> simSubscriptionId;
|
|
||||||
|
|
||||||
public TransportOption(@NonNull Type type,
|
|
||||||
@NonNull String text,
|
|
||||||
@NonNull String composeHint,
|
|
||||||
@NonNull CharacterCalculator characterCalculator)
|
|
||||||
{
|
|
||||||
this(type, text, composeHint, characterCalculator,
|
|
||||||
Optional.<CharSequence>absent(), Optional.<Integer>absent());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransportOption(@NonNull Type type,
|
|
||||||
@NonNull String text,
|
|
||||||
@NonNull String composeHint,
|
|
||||||
@NonNull CharacterCalculator characterCalculator,
|
|
||||||
@NonNull Optional<CharSequence> simName,
|
|
||||||
@NonNull Optional<Integer> simSubscriptionId)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
this.text = text;
|
|
||||||
this.composeHint = composeHint;
|
|
||||||
this.characterCalculator = characterCalculator;
|
|
||||||
this.simName = simName;
|
|
||||||
this.simSubscriptionId = simSubscriptionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
TransportOption(Parcel in) {
|
|
||||||
this(Type.valueOf(in.readString()),
|
|
||||||
in.readString(),
|
|
||||||
in.readString(),
|
|
||||||
CharacterCalculator.readFromParcel(in),
|
|
||||||
Optional.fromNullable(TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in)),
|
|
||||||
in.readInt() == 1 ? Optional.of(in.readInt()) : Optional.absent());
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isType(Type type) {
|
|
||||||
return this.type == type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSms() {
|
|
||||||
return type == Type.SMS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CharacterState calculateCharacters(String messageBody) {
|
|
||||||
return characterCalculator.calculateCharacters(messageBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull String getComposeHint() {
|
|
||||||
return composeHint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull String getDescription() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public Optional<CharSequence> getSimName() {
|
|
||||||
return simName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public Optional<Integer> getSimSubscriptionId() {
|
|
||||||
return simSubscriptionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int describeContents() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
|
||||||
dest.writeString(type.name());
|
|
||||||
dest.writeString(text);
|
|
||||||
dest.writeString(composeHint);
|
|
||||||
CharacterCalculator.writeToParcel(dest, characterCalculator);
|
|
||||||
TextUtils.writeToParcel(simName.orNull(), dest, flags);
|
|
||||||
|
|
||||||
if (simSubscriptionId.isPresent()) {
|
|
||||||
dest.writeInt(1);
|
|
||||||
dest.writeInt(simSubscriptionId.get());
|
|
||||||
} else {
|
|
||||||
dest.writeInt(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Creator<TransportOption> CREATOR = new Creator<TransportOption>() {
|
|
||||||
@Override
|
|
||||||
public TransportOption createFromParcel(Parcel in) {
|
|
||||||
return new TransportOption(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TransportOption[] newArray(int size) {
|
|
||||||
return new TransportOption[size];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,208 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.TypedValue;
|
|
||||||
|
|
||||||
import androidx.annotation.AttrRes;
|
|
||||||
import androidx.annotation.DrawableRes;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
|
||||||
import org.thoughtcrime.securesms.util.CharacterCalculator;
|
|
||||||
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
|
||||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionInfoCompat;
|
|
||||||
import org.thoughtcrime.securesms.util.dualsim.SubscriptionManagerCompat;
|
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
import static org.thoughtcrime.securesms.TransportOption.Type;
|
|
||||||
|
|
||||||
public class TransportOptions {
|
|
||||||
|
|
||||||
private static final String TAG = TransportOptions.class.getSimpleName();
|
|
||||||
|
|
||||||
private final List<OnTransportChangedListener> listeners = new LinkedList<>();
|
|
||||||
private final Context context;
|
|
||||||
private final List<TransportOption> enabledTransports;
|
|
||||||
|
|
||||||
private Type defaultTransportType = Type.TEXTSECURE;
|
|
||||||
private Optional<Integer> defaultSubscriptionId = Optional.absent();
|
|
||||||
private Optional<TransportOption> selectedOption = Optional.absent();
|
|
||||||
|
|
||||||
private final Optional<Integer> systemSubscriptionId;
|
|
||||||
|
|
||||||
public TransportOptions(Context context, boolean media) {
|
|
||||||
this.context = context;
|
|
||||||
this.enabledTransports = initializeAvailableTransports(media);
|
|
||||||
this.systemSubscriptionId = new SubscriptionManagerCompat(context).getPreferredSubscriptionId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset(boolean media) {
|
|
||||||
List<TransportOption> transportOptions = initializeAvailableTransports(media);
|
|
||||||
|
|
||||||
this.enabledTransports.clear();
|
|
||||||
this.enabledTransports.addAll(transportOptions);
|
|
||||||
|
|
||||||
if (selectedOption.isPresent() && !isEnabled(selectedOption.get())) {
|
|
||||||
setSelectedTransport(null);
|
|
||||||
} else {
|
|
||||||
this.defaultTransportType = Type.TEXTSECURE;
|
|
||||||
this.defaultSubscriptionId = Optional.absent();
|
|
||||||
|
|
||||||
notifyTransportChangeListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultTransport(Type type) {
|
|
||||||
this.defaultTransportType = type;
|
|
||||||
|
|
||||||
if (!selectedOption.isPresent()) {
|
|
||||||
notifyTransportChangeListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultSubscriptionId(Optional<Integer> subscriptionId) {
|
|
||||||
if (defaultSubscriptionId.equals(subscriptionId)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.defaultSubscriptionId = subscriptionId;
|
|
||||||
|
|
||||||
if (!selectedOption.isPresent()) {
|
|
||||||
notifyTransportChangeListeners();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectedTransport(@Nullable TransportOption transportOption) {
|
|
||||||
this.selectedOption = Optional.fromNullable(transportOption);
|
|
||||||
notifyTransportChangeListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isManualSelection() {
|
|
||||||
return this.selectedOption.isPresent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull TransportOption getSelectedTransport() {
|
|
||||||
if (selectedOption.isPresent()) return selectedOption.get();
|
|
||||||
|
|
||||||
if (defaultTransportType == Type.SMS) {
|
|
||||||
TransportOption transportOption = findEnabledSmsTransportOption(defaultSubscriptionId.or(systemSubscriptionId));
|
|
||||||
if (transportOption != null) {
|
|
||||||
return transportOption;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (TransportOption transportOption : enabledTransports) {
|
|
||||||
if (transportOption.getType() == defaultTransportType) {
|
|
||||||
return transportOption;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new AssertionError("No options of default type!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private @Nullable TransportOption findEnabledSmsTransportOption(Optional<Integer> subscriptionId) {
|
|
||||||
if (subscriptionId.isPresent()) {
|
|
||||||
final int subId = subscriptionId.get();
|
|
||||||
|
|
||||||
for (TransportOption transportOption : enabledTransports) {
|
|
||||||
if (transportOption.getType() == Type.SMS &&
|
|
||||||
subId == transportOption.getSimSubscriptionId().or(-1)) {
|
|
||||||
return transportOption;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disableTransport(Type type) {
|
|
||||||
TransportOption selected = selectedOption.orNull();
|
|
||||||
|
|
||||||
Iterator<TransportOption> iterator = enabledTransports.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
TransportOption option = iterator.next();
|
|
||||||
|
|
||||||
if (option.isType(type)) {
|
|
||||||
if (selected == option) {
|
|
||||||
setSelectedTransport(null);
|
|
||||||
}
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<TransportOption> getEnabledTransports() {
|
|
||||||
return enabledTransports;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOnTransportChangedListener(OnTransportChangedListener listener) {
|
|
||||||
this.listeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<TransportOption> initializeAvailableTransports(boolean isMediaMessage) {
|
|
||||||
List<TransportOption> results = new LinkedList<>();
|
|
||||||
|
|
||||||
results.add(new TransportOption(Type.TEXTSECURE,
|
|
||||||
context.getString(R.string.ConversationActivity_transport_signal),
|
|
||||||
context.getString(R.string.conversation_activity__type_message_push),
|
|
||||||
new PushCharacterCalculator()));
|
|
||||||
|
|
||||||
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);
|
|
||||||
Collection<SubscriptionInfoCompat> subscriptions;
|
|
||||||
|
|
||||||
if (Permissions.hasAll(context, Manifest.permission.READ_PHONE_STATE)) {
|
|
||||||
subscriptions = subscriptionManager.getActiveAndReadySubscriptionInfos();
|
|
||||||
} else {
|
|
||||||
subscriptions = Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subscriptions.size() < 2) {
|
|
||||||
results.add(new TransportOption(Type.SMS,
|
|
||||||
text, composeHint, characterCalculator));
|
|
||||||
} else {
|
|
||||||
for (SubscriptionInfoCompat subscriptionInfo : subscriptions) {
|
|
||||||
results.add(new TransportOption(Type.SMS,
|
|
||||||
text, composeHint, characterCalculator,
|
|
||||||
Optional.of(subscriptionInfo.getDisplayName()),
|
|
||||||
Optional.of(subscriptionInfo.getSubscriptionId())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyTransportChangeListeners() {
|
|
||||||
for (OnTransportChangedListener listener : listeners) {
|
|
||||||
listener.onChange(getSelectedTransport(), selectedOption.isPresent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isEnabled(TransportOption transportOption) {
|
|
||||||
for (TransportOption option : enabledTransports) {
|
|
||||||
if (option.equals(transportOption)) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnTransportChangedListener {
|
|
||||||
void onChange(TransportOption newTransport, boolean manuallySelected);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
public class TransportOptionsAdapter extends BaseAdapter {
|
|
||||||
|
|
||||||
private final LayoutInflater inflater;
|
|
||||||
|
|
||||||
private List<TransportOption> enabledTransports;
|
|
||||||
|
|
||||||
public TransportOptionsAdapter(@NonNull Context context,
|
|
||||||
@NonNull List<TransportOption> enabledTransports)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.inflater = LayoutInflater.from(context);
|
|
||||||
this.enabledTransports = enabledTransports;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabledTransports(List<TransportOption> enabledTransports) {
|
|
||||||
this.enabledTransports = enabledTransports;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCount() {
|
|
||||||
return enabledTransports.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getItem(int position) {
|
|
||||||
return enabledTransports.get(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getItemId(int position) {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
if (convertView == null) {
|
|
||||||
convertView = inflater.inflate(R.layout.transport_selection_list_item, parent, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
TransportOption transport = (TransportOption) getItem(position);
|
|
||||||
ImageView imageView = ViewUtil.findById(convertView, R.id.icon);
|
|
||||||
TextView textView = ViewUtil.findById(convertView, R.id.text);
|
|
||||||
TextView subtextView = ViewUtil.findById(convertView, R.id.subtext);
|
|
||||||
|
|
||||||
imageView.setImageResource(R.drawable.ic_arrow_up_circle_24);
|
|
||||||
textView.setText(transport.getDescription());
|
|
||||||
|
|
||||||
if (transport.getSimName().isPresent()) {
|
|
||||||
subtextView.setText(transport.getSimName().get());
|
|
||||||
subtextView.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
subtextView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return convertView;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.widget.ListPopupWindow;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
public class TransportOptionsPopup extends ListPopupWindow implements ListView.OnItemClickListener {
|
|
||||||
|
|
||||||
private final TransportOptionsAdapter adapter;
|
|
||||||
private final SelectedListener listener;
|
|
||||||
|
|
||||||
public TransportOptionsPopup(@NonNull Context context, @NonNull View anchor, @NonNull SelectedListener listener) {
|
|
||||||
super(context);
|
|
||||||
this.listener = listener;
|
|
||||||
this.adapter = new TransportOptionsAdapter(context, new LinkedList<TransportOption>());
|
|
||||||
|
|
||||||
setVerticalOffset(context.getResources().getDimensionPixelOffset(R.dimen.transport_selection_popup_yoff));
|
|
||||||
setHorizontalOffset(context.getResources().getDimensionPixelOffset(R.dimen.transport_selection_popup_xoff));
|
|
||||||
setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
|
||||||
setModal(true);
|
|
||||||
setAnchorView(anchor);
|
|
||||||
setAdapter(adapter);
|
|
||||||
setContentWidth(context.getResources().getDimensionPixelSize(R.dimen.transport_selection_popup_width));
|
|
||||||
|
|
||||||
setOnItemClickListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void display(List<TransportOption> enabledTransports) {
|
|
||||||
adapter.setEnabledTransports(enabledTransports);
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
listener.onSelected((TransportOption)adapter.getItem(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SelectedListener {
|
|
||||||
void onSelected(TransportOption option);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -4,13 +4,6 @@ import android.content.Context;
|
|||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.annotation.RequiresApi;
|
|
||||||
import androidx.core.view.inputmethod.EditorInfoCompat;
|
|
||||||
import androidx.core.view.inputmethod.InputConnectionCompat;
|
|
||||||
import androidx.core.view.inputmethod.InputContentInfoCompat;
|
|
||||||
import androidx.core.os.BuildCompat;
|
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
@ -22,7 +15,14 @@ import android.util.AttributeSet;
|
|||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TransportOption;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.core.os.BuildCompat;
|
||||||
|
import androidx.core.view.inputmethod.EditorInfoCompat;
|
||||||
|
import androidx.core.view.inputmethod.InputConnectionCompat;
|
||||||
|
import androidx.core.view.inputmethod.InputContentInfoCompat;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
@ -121,15 +121,14 @@ public class ComposeText extends EmojiEditText {
|
|||||||
return getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
return getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransport(TransportOption transport) {
|
public void setTransport() {
|
||||||
final boolean useSystemEmoji = TextSecurePreferences.isSystemEmojiPreferred(getContext());
|
final boolean useSystemEmoji = TextSecurePreferences.isSystemEmojiPreferred(getContext());
|
||||||
final boolean isIncognito = TextSecurePreferences.isIncognitoKeyboardEnabled(getContext());
|
final boolean isIncognito = TextSecurePreferences.isIncognitoKeyboardEnabled(getContext());
|
||||||
|
|
||||||
int imeOptions = (getImeOptions() & ~EditorInfo.IME_MASK_ACTION) | EditorInfo.IME_ACTION_SEND;
|
int imeOptions = (getImeOptions() & ~EditorInfo.IME_MASK_ACTION) | EditorInfo.IME_ACTION_SEND;
|
||||||
int inputType = getInputType();
|
int inputType = getInputType();
|
||||||
|
|
||||||
if (isLandscape()) setImeActionLabel(transport.getComposeHint(), EditorInfo.IME_ACTION_SEND);
|
setImeActionLabel(null, 0);
|
||||||
else setImeActionLabel(null, 0);
|
|
||||||
|
|
||||||
if (useSystemEmoji) {
|
if (useSystemEmoji) {
|
||||||
inputType = (inputType & ~InputType.TYPE_MASK_VARIATION) | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
|
inputType = (inputType & ~InputType.TYPE_MASK_VARIATION) | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
|
||||||
|
@ -1,130 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms.components;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.widget.AppCompatImageButton;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TransportOption;
|
|
||||||
import org.thoughtcrime.securesms.TransportOptions;
|
|
||||||
import org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener;
|
|
||||||
import org.thoughtcrime.securesms.TransportOptionsPopup;
|
|
||||||
import org.thoughtcrime.securesms.util.ThemeUtil;
|
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
public class SendButton extends AppCompatImageButton
|
|
||||||
implements TransportOptions.OnTransportChangedListener,
|
|
||||||
TransportOptionsPopup.SelectedListener,
|
|
||||||
View.OnLongClickListener {
|
|
||||||
|
|
||||||
private final TransportOptions transportOptions;
|
|
||||||
|
|
||||||
private Optional<TransportOptionsPopup> transportOptionsPopup = Optional.absent();
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public SendButton(Context context) {
|
|
||||||
super(context);
|
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
|
||||||
ViewUtil.mirrorIfRtl(this, getContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public SendButton(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
|
||||||
ViewUtil.mirrorIfRtl(this, getContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public SendButton(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
this.transportOptions = initializeTransportOptions(false);
|
|
||||||
ViewUtil.mirrorIfRtl(this, getContext());
|
|
||||||
}
|
|
||||||
|
|
||||||
private TransportOptions initializeTransportOptions(boolean media) {
|
|
||||||
if (isInEditMode()) return null;
|
|
||||||
|
|
||||||
TransportOptions transportOptions = new TransportOptions(getContext(), media);
|
|
||||||
transportOptions.addOnTransportChangedListener(this);
|
|
||||||
|
|
||||||
setOnLongClickListener(this);
|
|
||||||
|
|
||||||
return transportOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TransportOptionsPopup getTransportOptionsPopup() {
|
|
||||||
if (!transportOptionsPopup.isPresent()) {
|
|
||||||
transportOptionsPopup = Optional.of(new TransportOptionsPopup(getContext(), this, this));
|
|
||||||
}
|
|
||||||
return transportOptionsPopup.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isManualSelection() {
|
|
||||||
return transportOptions.isManualSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOnTransportChangedListener(OnTransportChangedListener listener) {
|
|
||||||
transportOptions.addOnTransportChangedListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransportOption getSelectedTransport() {
|
|
||||||
return transportOptions.getSelectedTransport();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetAvailableTransports(boolean isMediaMessage) {
|
|
||||||
transportOptions.reset(isMediaMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disableTransport(TransportOption.Type type) {
|
|
||||||
transportOptions.disableTransport(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultTransport(TransportOption.Type type) {
|
|
||||||
transportOptions.setDefaultTransport(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTransport(@NonNull TransportOption option) {
|
|
||||||
transportOptions.setSelectedTransport(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultSubscriptionId(Optional<Integer> subscriptionId) {
|
|
||||||
transportOptions.setDefaultSubscriptionId(subscriptionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelected(TransportOption option) {
|
|
||||||
transportOptions.setSelectedTransport(option);
|
|
||||||
getTransportOptionsPopup().dismiss();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(TransportOption newTransport, boolean isManualSelection) {
|
|
||||||
// Map send icon drawable resource from a transport type.
|
|
||||||
//TODO These values should come from XML layout as view's attributes and not be resolved in code like this.
|
|
||||||
@DrawableRes final int sendDrawable;
|
|
||||||
switch (newTransport.getType()) {
|
|
||||||
case SMS:
|
|
||||||
case TEXTSECURE:
|
|
||||||
default: {
|
|
||||||
sendDrawable = ThemeUtil.getThemedDrawableResId(
|
|
||||||
getContext(), R.attr.conversation_transport_sms_indicator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setImageResource(sendDrawable);
|
|
||||||
setContentDescription(newTransport.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View v) {
|
|
||||||
// Loki - Do nothing
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -83,17 +83,24 @@ import com.annimon.stream.Stream;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
import org.greenrobot.eventbus.ThreadMode;
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
import org.session.libsignal.libsignal.InvalidMessageException;
|
||||||
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
|
import org.session.libsignal.service.loki.api.opengroups.PublicChat;
|
||||||
|
import org.session.libsignal.service.loki.protocol.mentions.Mention;
|
||||||
|
import org.session.libsignal.service.loki.protocol.mentions.MentionsManager;
|
||||||
|
import org.session.libsignal.service.loki.protocol.meta.SessionMetaProtocol;
|
||||||
|
import org.session.libsignal.service.loki.protocol.shelved.multidevice.MultiDeviceProtocol;
|
||||||
|
import org.session.libsignal.service.loki.utilities.HexEncodingKt;
|
||||||
|
import org.session.libsignal.service.loki.utilities.PublicKeyValidation;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
import org.thoughtcrime.securesms.ExpirationDialog;
|
import org.thoughtcrime.securesms.ExpirationDialog;
|
||||||
import org.thoughtcrime.securesms.MediaOverviewActivity;
|
import org.thoughtcrime.securesms.MediaOverviewActivity;
|
||||||
import org.thoughtcrime.securesms.MuteDialog;
|
import org.thoughtcrime.securesms.MuteDialog;
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
||||||
import org.thoughtcrime.securesms.ShortcutLauncherActivity;
|
import org.thoughtcrime.securesms.ShortcutLauncherActivity;
|
||||||
import org.thoughtcrime.securesms.TransportOption;
|
|
||||||
import org.thoughtcrime.securesms.VerifyIdentityActivity;
|
import org.thoughtcrime.securesms.VerifyIdentityActivity;
|
||||||
import org.thoughtcrime.securesms.audio.AudioRecorder;
|
import org.thoughtcrime.securesms.audio.AudioRecorder;
|
||||||
import org.thoughtcrime.securesms.audio.AudioSlidePlayer;
|
import org.thoughtcrime.securesms.audio.AudioSlidePlayer;
|
||||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
|
||||||
import org.thoughtcrime.securesms.components.AnimatingToggle;
|
import org.thoughtcrime.securesms.components.AnimatingToggle;
|
||||||
import org.thoughtcrime.securesms.components.AttachmentTypeSelector;
|
import org.thoughtcrime.securesms.components.AttachmentTypeSelector;
|
||||||
import org.thoughtcrime.securesms.components.ComposeText;
|
import org.thoughtcrime.securesms.components.ComposeText;
|
||||||
@ -102,7 +109,6 @@ import org.thoughtcrime.securesms.components.HidingLinearLayout;
|
|||||||
import org.thoughtcrime.securesms.components.InputAwareLayout;
|
import org.thoughtcrime.securesms.components.InputAwareLayout;
|
||||||
import org.thoughtcrime.securesms.components.InputPanel;
|
import org.thoughtcrime.securesms.components.InputPanel;
|
||||||
import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout.OnKeyboardShownListener;
|
import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout.OnKeyboardShownListener;
|
||||||
import org.thoughtcrime.securesms.components.SendButton;
|
|
||||||
import org.thoughtcrime.securesms.components.TooltipPopup;
|
import org.thoughtcrime.securesms.components.TooltipPopup;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
|
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiStrings;
|
import org.thoughtcrime.securesms.components.emoji.EmojiStrings;
|
||||||
@ -128,8 +134,6 @@ import org.thoughtcrime.securesms.database.IdentityDatabase.IdentityRecord;
|
|||||||
import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus;
|
import org.thoughtcrime.securesms.database.IdentityDatabase.VerifiedStatus;
|
||||||
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
import org.thoughtcrime.securesms.database.MessagingDatabase.MarkedMessageInfo;
|
||||||
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
|
import org.thoughtcrime.securesms.database.MmsSmsColumns.Types;
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
|
||||||
import org.thoughtcrime.securesms.database.RecipientDatabase.RegisteredState;
|
|
||||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||||
import org.thoughtcrime.securesms.database.identity.IdentityRecordList;
|
import org.thoughtcrime.securesms.database.identity.IdentityRecordList;
|
||||||
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||||
@ -182,7 +186,6 @@ import org.thoughtcrime.securesms.permissions.Permissions;
|
|||||||
import org.thoughtcrime.securesms.profiles.GroupShareProfileView;
|
import org.thoughtcrime.securesms.profiles.GroupShareProfileView;
|
||||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientExporter;
|
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
import org.thoughtcrime.securesms.recipients.RecipientModifiedListener;
|
||||||
import org.thoughtcrime.securesms.search.model.MessageResult;
|
import org.thoughtcrime.securesms.search.model.MessageResult;
|
||||||
@ -198,10 +201,10 @@ import org.thoughtcrime.securesms.stickers.StickerPackInstallEvent;
|
|||||||
import org.thoughtcrime.securesms.stickers.StickerSearchRepository;
|
import org.thoughtcrime.securesms.stickers.StickerSearchRepository;
|
||||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||||
import org.thoughtcrime.securesms.util.DateUtils;
|
import org.thoughtcrime.securesms.util.DateUtils;
|
||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
|
||||||
import org.thoughtcrime.securesms.util.ExpirationUtil;
|
import org.thoughtcrime.securesms.util.ExpirationUtil;
|
||||||
import org.thoughtcrime.securesms.util.IdentityUtil;
|
import org.thoughtcrime.securesms.util.IdentityUtil;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
||||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences.MediaKeyboardMode;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences.MediaKeyboardMode;
|
||||||
@ -211,15 +214,6 @@ import org.thoughtcrime.securesms.util.concurrent.AssertedSuccessListener;
|
|||||||
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
||||||
import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
|
import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
|
||||||
import org.thoughtcrime.securesms.util.views.Stub;
|
import org.thoughtcrime.securesms.util.views.Stub;
|
||||||
import org.session.libsignal.libsignal.InvalidMessageException;
|
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
|
||||||
import org.session.libsignal.service.loki.api.opengroups.PublicChat;
|
|
||||||
import org.session.libsignal.service.loki.protocol.mentions.Mention;
|
|
||||||
import org.session.libsignal.service.loki.protocol.mentions.MentionsManager;
|
|
||||||
import org.session.libsignal.service.loki.protocol.meta.SessionMetaProtocol;
|
|
||||||
import org.session.libsignal.service.loki.protocol.shelved.multidevice.MultiDeviceProtocol;
|
|
||||||
import org.session.libsignal.service.loki.utilities.HexEncodingKt;
|
|
||||||
import org.session.libsignal.service.loki.utilities.PublicKeyValidation;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -237,9 +231,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
import static org.thoughtcrime.securesms.TransportOption.Type;
|
|
||||||
import static org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
|
||||||
import static org.session.libsignal.libsignal.SessionCipher.SESSION_LOCK;
|
import static org.session.libsignal.libsignal.SessionCipher.SESSION_LOCK;
|
||||||
|
import static org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity for displaying a message thread, as well as
|
* Activity for displaying a message thread, as well as
|
||||||
@ -290,7 +283,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private GlideRequests glideRequests;
|
private GlideRequests glideRequests;
|
||||||
protected ComposeText composeText;
|
protected ComposeText composeText;
|
||||||
private AnimatingToggle buttonToggle;
|
private AnimatingToggle buttonToggle;
|
||||||
private SendButton sendButton;
|
private ImageButton sendButton;
|
||||||
private ImageButton attachButton;
|
private ImageButton attachButton;
|
||||||
private ProfilePictureView profilePictureView;
|
private ProfilePictureView profilePictureView;
|
||||||
private TextView titleTextView;
|
private TextView titleTextView;
|
||||||
@ -329,7 +322,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private long threadId;
|
private long threadId;
|
||||||
private int distributionType;
|
private int distributionType;
|
||||||
private boolean archived;
|
private boolean archived;
|
||||||
private boolean isSecureText; //TODO AC: Refaactor these field, as they are not required anyumore.
|
|
||||||
private boolean isDefaultSms = false;
|
private boolean isDefaultSms = false;
|
||||||
private boolean isMmsEnabled = false;
|
private boolean isMmsEnabled = false;
|
||||||
private boolean isSecurityInitialized = false;
|
private boolean isSecurityInitialized = false;
|
||||||
@ -338,7 +330,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
private int keyboardHeight = 0;
|
private int keyboardHeight = 0;
|
||||||
|
|
||||||
private final IdentityRecordList identityRecords = new IdentityRecordList();
|
private final IdentityRecordList identityRecords = new IdentityRecordList();
|
||||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
|
||||||
|
|
||||||
// Message status bar
|
// Message status bar
|
||||||
private ArrayList<BroadcastReceiver> broadcastReceivers = new ArrayList<>();
|
private ArrayList<BroadcastReceiver> broadcastReceivers = new ArrayList<>();
|
||||||
@ -354,10 +345,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
// Restoration
|
// Restoration
|
||||||
protected SessionRestoreBannerView sessionRestoreBannerView;
|
protected SessionRestoreBannerView sessionRestoreBannerView;
|
||||||
|
|
||||||
@Override
|
private final PushCharacterCalculator characterCalculator = new PushCharacterCalculator();
|
||||||
protected void onPreCreate() {
|
|
||||||
dynamicLanguage.onCreate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle state, boolean ready) {
|
protected void onCreate(Bundle state, boolean ready) {
|
||||||
@ -365,7 +353,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
setContentView(R.layout.conversation_activity);
|
setContentView(R.layout.conversation_activity);
|
||||||
|
|
||||||
fragment = initFragment(R.id.fragment_content, new ConversationFragment(), dynamicLanguage.getCurrentLocale());
|
fragment = initFragment(R.id.fragment_content, new ConversationFragment(), Locale.getDefault());
|
||||||
|
|
||||||
registerMessageStatusObserver("calculatingPoW");
|
registerMessageStatusObserver("calculatingPoW");
|
||||||
registerMessageStatusObserver("contactingNetwork");
|
registerMessageStatusObserver("contactingNetwork");
|
||||||
@ -392,7 +380,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
initializeSecurity(false, isDefaultSms).addListener(new AssertedSuccessListener<Boolean>() {
|
initializeSecurity(false, isDefaultSms).addListener(new AssertedSuccessListener<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(Boolean result) {
|
||||||
initializeProfiles();
|
|
||||||
initializeDraft().addListener(new AssertedSuccessListener<Boolean>() {
|
initializeDraft().addListener(new AssertedSuccessListener<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean loadedDraft) {
|
public void onSuccess(Boolean loadedDraft) {
|
||||||
@ -516,19 +503,17 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
dynamicLanguage.onResume(this);
|
|
||||||
|
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
initializeEnabledCheck();
|
initializeEnabledCheck();
|
||||||
initializeMmsEnabledCheck();
|
initializeMmsEnabledCheck();
|
||||||
initializeIdentityRecords();
|
initializeIdentityRecords();
|
||||||
composeText.setTransport(sendButton.getSelectedTransport());
|
composeText.setTransport();
|
||||||
|
|
||||||
updateTitleTextView(recipient);
|
updateTitleTextView(recipient);
|
||||||
updateProfilePicture();
|
updateProfilePicture();
|
||||||
updateSubtitleTextView();
|
updateSubtitleTextView();
|
||||||
setActionBarColor(recipient.getColor());
|
updateInputUI(recipient);
|
||||||
updateInputUI(recipient, isSecureText, isDefaultSms);
|
|
||||||
setGroupShareProfileReminder(recipient);
|
setGroupShareProfileReminder(recipient);
|
||||||
calculateCharactersRemaining();
|
calculateCharactersRemaining();
|
||||||
|
|
||||||
@ -569,7 +554,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
Log.i(TAG, "onConfigurationChanged(" + newConfig.orientation + ")");
|
Log.i(TAG, "onConfigurationChanged(" + newConfig.orientation + ")");
|
||||||
super.onConfigurationChanged(newConfig);
|
super.onConfigurationChanged(newConfig);
|
||||||
composeText.setTransport(sendButton.getSelectedTransport());
|
composeText.setTransport();
|
||||||
|
|
||||||
if (emojiDrawerStub.resolved() && container.getCurrentInput() == emojiDrawerStub.get()) {
|
if (emojiDrawerStub.resolved() && container.getCurrentInput() == emojiDrawerStub.get()) {
|
||||||
container.hideAttachedInput(true);
|
container.hideAttachedInput(true);
|
||||||
@ -606,13 +591,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
case PICK_AUDIO:
|
case PICK_AUDIO:
|
||||||
setMedia(data.getData(), MediaType.AUDIO);
|
setMedia(data.getData(), MediaType.AUDIO);
|
||||||
break;
|
break;
|
||||||
case PICK_CONTACT:
|
// case PICK_CONTACT:
|
||||||
if (isSecureText && !isSmsForced()) {
|
// if (isSecureText && !isSmsForced()) {
|
||||||
// openContactShareEditor(data.getData());
|
//// openContactShareEditor(data.getData());
|
||||||
} else {
|
// } else {
|
||||||
addAttachmentContactInfo(data.getData());
|
// addAttachmentContactInfo(data.getData());
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case TAKE_PHOTO:
|
case TAKE_PHOTO:
|
||||||
if (attachmentManager.getCaptureUri() != null) {
|
if (attachmentManager.getCaptureUri() != null) {
|
||||||
setMedia(attachmentManager.getCaptureUri(), MediaType.IMAGE);
|
setMedia(attachmentManager.getCaptureUri(), MediaType.IMAGE);
|
||||||
@ -636,22 +621,15 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
data.getIntExtra(GiphyActivity.EXTRA_HEIGHT, 0));
|
data.getIntExtra(GiphyActivity.EXTRA_HEIGHT, 0));
|
||||||
break;
|
break;
|
||||||
case SMS_DEFAULT:
|
case SMS_DEFAULT:
|
||||||
initializeSecurity(isSecureText, isDefaultSms);
|
initializeSecurity(true, isDefaultSms);
|
||||||
break;
|
break;
|
||||||
case MEDIA_SENDER:
|
case MEDIA_SENDER:
|
||||||
long expiresIn = recipient.getExpireMessages() * 1000L;
|
long expiresIn = recipient.getExpireMessages() * 1000L;
|
||||||
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
|
int subscriptionId = -1;
|
||||||
boolean initiating = threadId == -1;
|
boolean initiating = threadId == -1;
|
||||||
TransportOption transport = data.getParcelableExtra(MediaSendActivity.EXTRA_TRANSPORT);
|
|
||||||
String message = data.getStringExtra(MediaSendActivity.EXTRA_MESSAGE);
|
String message = data.getStringExtra(MediaSendActivity.EXTRA_MESSAGE);
|
||||||
SlideDeck slideDeck = new SlideDeck();
|
SlideDeck slideDeck = new SlideDeck();
|
||||||
|
|
||||||
if (transport == null) {
|
|
||||||
throw new IllegalStateException("Received a null transport from the MediaSendActivity.");
|
|
||||||
}
|
|
||||||
|
|
||||||
sendButton.setTransport(transport);
|
|
||||||
|
|
||||||
List<Media> mediaList = data.getParcelableArrayListExtra(MediaSendActivity.EXTRA_MEDIA);
|
List<Media> mediaList = data.getParcelableArrayListExtra(MediaSendActivity.EXTRA_MEDIA);
|
||||||
|
|
||||||
for (Media mediaItem : mediaList) {
|
for (Media mediaItem : mediaList) {
|
||||||
@ -668,7 +646,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
final Context context = ConversationActivity.this.getApplicationContext();
|
final Context context = ConversationActivity.this.getApplicationContext();
|
||||||
|
|
||||||
sendMediaMessage(transport.isSms(),
|
sendMediaMessage(false,
|
||||||
message,
|
message,
|
||||||
slideDeck,
|
slideDeck,
|
||||||
inputPanel.getQuote().orNull(),
|
inputPanel.getQuote().orNull(),
|
||||||
@ -715,7 +693,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
boolean isOpenGroupOrRSSFeed = recipient.getAddress().isOpenGroup() || recipient.getAddress().isRSSFeed();
|
boolean isOpenGroupOrRSSFeed = recipient.getAddress().isOpenGroup() || recipient.getAddress().isRSSFeed();
|
||||||
|
|
||||||
if (isSecureText && !isOpenGroupOrRSSFeed) {
|
if (isOpenGroupOrRSSFeed) {
|
||||||
if (recipient.getExpireMessages() > 0) {
|
if (recipient.getExpireMessages() > 0) {
|
||||||
inflater.inflate(R.menu.conversation_expiring_on, menu);
|
inflater.inflate(R.menu.conversation_expiring_on, menu);
|
||||||
|
|
||||||
@ -757,7 +735,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
inflater.inflate(R.menu.conversation, menu);
|
inflater.inflate(R.menu.conversation, menu);
|
||||||
|
|
||||||
if (isSingleConversation() && isSecureText) {
|
if (isSingleConversation()) {
|
||||||
inflater.inflate(R.menu.conversation_secure, menu);
|
inflater.inflate(R.menu.conversation_secure, menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -826,7 +804,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
searchViewModel.onSearchClosed();
|
searchViewModel.onSearchClosed();
|
||||||
searchNav.setVisibility(View.GONE);
|
searchNav.setVisibility(View.GONE);
|
||||||
inputPanel.setVisibility(View.VISIBLE);
|
inputPanel.setVisibility(View.VISIBLE);
|
||||||
updateInputUI(recipient, isSecureText, isDefaultSms);
|
updateInputUI(recipient);
|
||||||
fragment.onSearchQueryUpdated(null);
|
fragment.onSearchQueryUpdated(null);
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
return true;
|
return true;
|
||||||
@ -1198,7 +1176,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleAddAttachment() {
|
private void handleAddAttachment() {
|
||||||
if (this.isMmsEnabled || isSecureText) {
|
if (this.isMmsEnabled) {
|
||||||
if (attachmentTypeSelector == null) {
|
if (attachmentTypeSelector == null) {
|
||||||
attachmentTypeSelector = new AttachmentTypeSelector(
|
attachmentTypeSelector = new AttachmentTypeSelector(
|
||||||
this,
|
this,
|
||||||
@ -1258,11 +1236,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
private void handleSecurityChange(boolean isSecureText, boolean isDefaultSms) {
|
private void handleSecurityChange(boolean isSecureText, boolean isDefaultSms) {
|
||||||
Log.i(TAG, "handleSecurityChange(" + isSecureText + ", " + isDefaultSms + ")");
|
Log.i(TAG, "handleSecurityChange(" + isSecureText + ", " + isDefaultSms + ")");
|
||||||
if (isSecurityInitialized && isSecureText == this.isSecureText && isDefaultSms == this.isDefaultSms) {
|
if (isSecurityInitialized && isSecureText == true && isDefaultSms == this.isDefaultSms) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isSecureText = isSecureText;
|
|
||||||
this.isDefaultSms = isDefaultSms;
|
this.isDefaultSms = isDefaultSms;
|
||||||
this.isSecurityInitialized = true;
|
this.isSecurityInitialized = true;
|
||||||
|
|
||||||
@ -1270,9 +1247,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
boolean isMediaMessage = recipient.isMmsGroupRecipient() || attachmentManager.isAttachmentPresent();
|
boolean isMediaMessage = recipient.isMmsGroupRecipient() || attachmentManager.isAttachmentPresent();
|
||||||
|
|
||||||
sendButton.resetAvailableTransports(isMediaMessage);
|
|
||||||
sendButton.setDefaultTransport(Type.TEXTSECURE);
|
|
||||||
|
|
||||||
/* Loki - We don't support SMS
|
/* Loki - We don't support SMS
|
||||||
if (!isSecureText && !isPushGroupConversation()) sendButton.disableTransport(Type.TEXTSECURE);
|
if (!isSecureText && !isPushGroupConversation()) sendButton.disableTransport(Type.TEXTSECURE);
|
||||||
if (recipient.isPushGroupRecipient()) sendButton.disableTransport(Type.SMS);
|
if (recipient.isPushGroupRecipient()) sendButton.disableTransport(Type.SMS);
|
||||||
@ -1287,7 +1261,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
calculateCharactersRemaining();
|
calculateCharactersRemaining();
|
||||||
supportInvalidateOptionsMenu();
|
supportInvalidateOptionsMenu();
|
||||||
updateInputUI(recipient, isSecureText, isDefaultSms);
|
updateInputUI(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
///// Initializers
|
///// Initializers
|
||||||
@ -1307,7 +1281,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Util.isEmpty(mediaList)) {
|
if (!Util.isEmpty(mediaList)) {
|
||||||
Intent sendIntent = MediaSendActivity.buildEditorIntent(this, mediaList, recipient, draftText, sendButton.getSelectedTransport());
|
Intent sendIntent = MediaSendActivity.buildEditorIntent(this, mediaList, recipient, draftText);
|
||||||
startActivityForResult(sendIntent, MEDIA_SENDER);
|
startActivityForResult(sendIntent, MEDIA_SENDER);
|
||||||
return new SettableFuture<>(false);
|
return new SettableFuture<>(false);
|
||||||
}
|
}
|
||||||
@ -1382,7 +1356,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
listener.onSuccess(true);
|
listener.onSuccess(true);
|
||||||
break;
|
break;
|
||||||
case Draft.LOCATION:
|
case Draft.LOCATION:
|
||||||
attachmentManager.setLocation(SignalPlace.deserialize(draft.getValue()), getCurrentMediaConstraints()).addListener(listener);
|
attachmentManager.setLocation(SignalPlace.deserialize(draft.getValue()), MediaConstraints.getPushMediaConstraints()).addListener(listener);
|
||||||
break;
|
break;
|
||||||
case Draft.IMAGE:
|
case Draft.IMAGE:
|
||||||
setMedia(Uri.parse(draft.getValue()), MediaType.IMAGE).addListener(listener);
|
setMedia(Uri.parse(draft.getValue()), MediaType.IMAGE).addListener(listener);
|
||||||
@ -1435,19 +1409,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
handleSecurityChange(result[0], result[1]);
|
handleSecurityChange(result[0], result[1]);
|
||||||
}
|
}
|
||||||
future.set(true);
|
future.set(true);
|
||||||
onSecurityUpdated();
|
|
||||||
}
|
}
|
||||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient);
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, recipient);
|
||||||
|
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSecurityUpdated() {
|
|
||||||
if (recipient != null) {
|
|
||||||
updateDefaultSubscriptionId(recipient.getDefaultSubscriptionId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSessionRestoreBanner() {
|
private void updateSessionRestoreBanner() {
|
||||||
Set<String> devices = DatabaseFactory.getLokiThreadDatabase(this).getSessionRestoreDevices(threadId);
|
Set<String> devices = DatabaseFactory.getLokiThreadDatabase(this).getSessionRestoreDevices(threadId);
|
||||||
if (devices.size() > 0) {
|
if (devices.size() > 0) {
|
||||||
@ -1458,11 +1425,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDefaultSubscriptionId(Optional<Integer> defaultSubscriptionId) {
|
|
||||||
Log.i(TAG, "updateDefaultSubscriptionId(" + defaultSubscriptionId.orNull() + ")");
|
|
||||||
sendButton.setDefaultSubscriptionId(defaultSubscriptionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeMmsEnabledCheck() {
|
private void initializeMmsEnabledCheck() {
|
||||||
new AsyncTask<Void, Void, Boolean>() {
|
new AsyncTask<Void, Void, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
@ -1581,12 +1543,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
|
attachButton.setOnLongClickListener(new AttachButtonLongClickListener());
|
||||||
sendButton.setOnClickListener(sendButtonListener);
|
sendButton.setOnClickListener(sendButtonListener);
|
||||||
sendButton.setEnabled(true);
|
sendButton.setEnabled(true);
|
||||||
sendButton.addOnTransportChangedListener((newTransport, manuallySelected) -> {
|
|
||||||
calculateCharactersRemaining();
|
|
||||||
updateLinkPreviewState();
|
|
||||||
composeText.setTransport(newTransport);
|
|
||||||
if (manuallySelected) recordTransportPreference(newTransport);
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
titleView.setOnClickListener(v -> handleConversationSettings());
|
titleView.setOnClickListener(v -> handleConversationSettings());
|
||||||
@ -1734,19 +1690,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
searchViewModel.onMoveDown();
|
searchViewModel.onMoveDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeProfiles() {
|
|
||||||
if (!isSecureText) {
|
|
||||||
Log.i(TAG, "SMS contact, no profile fetch needed.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
ApplicationContext.getInstance(this)
|
|
||||||
.getJobManager()
|
|
||||||
.add(new RetrieveProfileJob(recipient));
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onModified(final Recipient recipient) {
|
public void onModified(final Recipient recipient) {
|
||||||
Log.i(TAG, "onModified(" + recipient.getAddress().serialize() + ")");
|
Log.i(TAG, "onModified(" + recipient.getAddress().serialize() + ")");
|
||||||
@ -1756,11 +1699,9 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
updateProfilePicture();
|
updateProfilePicture();
|
||||||
updateSubtitleTextView();
|
updateSubtitleTextView();
|
||||||
// titleView.setVerified(identityRecords.isVerified());
|
// titleView.setVerified(identityRecords.isVerified());
|
||||||
updateInputUI(recipient, isSecureText, isDefaultSms);
|
updateInputUI(recipient);
|
||||||
setActionBarColor(recipient.getColor());
|
|
||||||
setGroupShareProfileReminder(recipient);
|
setGroupShareProfileReminder(recipient);
|
||||||
updateDefaultSubscriptionId(recipient.getDefaultSubscriptionId());
|
initializeSecurity(true, isDefaultSms);
|
||||||
initializeSecurity(isSecureText, isDefaultSms);
|
|
||||||
|
|
||||||
if (searchViewItem == null || !searchViewItem.isActionViewExpanded()) {
|
if (searchViewItem == null || !searchViewItem.isActionViewExpanded()) {
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
@ -1798,7 +1739,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
securityUpdateReceiver = new BroadcastReceiver() {
|
securityUpdateReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
initializeSecurity(isSecureText, isDefaultSms);
|
initializeSecurity(true, isDefaultSms);
|
||||||
calculateCharactersRemaining();
|
calculateCharactersRemaining();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1816,7 +1757,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
Log.i(TAG, "Selected: " + type);
|
Log.i(TAG, "Selected: " + type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AttachmentTypeSelector.ADD_GALLERY:
|
case AttachmentTypeSelector.ADD_GALLERY:
|
||||||
AttachmentManager.selectGallery(this, MEDIA_SENDER, recipient, composeText.getTextTrimmed(), sendButton.getSelectedTransport()); break;
|
AttachmentManager.selectGallery(this, MEDIA_SENDER, recipient, composeText.getTextTrimmed()); break;
|
||||||
case AttachmentTypeSelector.ADD_DOCUMENT:
|
case AttachmentTypeSelector.ADD_DOCUMENT:
|
||||||
AttachmentManager.selectDocument(this, PICK_DOCUMENT); break;
|
AttachmentManager.selectDocument(this, PICK_DOCUMENT); break;
|
||||||
case AttachmentTypeSelector.ADD_SOUND:
|
case AttachmentTypeSelector.ADD_SOUND:
|
||||||
@ -1834,14 +1775,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
builder.setTitle("Search GIFs?");
|
builder.setTitle("Search GIFs?");
|
||||||
builder.setMessage("You will not have full metadata protection when sending GIFs.");
|
builder.setMessage("You will not have full metadata protection when sending GIFs.");
|
||||||
builder.setPositiveButton("OK", (dialog, which) -> {
|
builder.setPositiveButton("OK", (dialog, which) -> {
|
||||||
AttachmentManager.selectGif(this, PICK_GIF, !isSecureText);
|
AttachmentManager.selectGif(this, PICK_GIF);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
});
|
});
|
||||||
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss());
|
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss());
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
TextSecurePreferences.setHasSeenGIFMetaDataWarning(this);
|
TextSecurePreferences.setHasSeenGIFMetaDataWarning(this);
|
||||||
} else {
|
} else {
|
||||||
AttachmentManager.selectGif(this, PICK_GIF, !isSecureText);
|
AttachmentManager.selectGif(this, PICK_GIF);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1856,14 +1797,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
return new SettableFuture<>(false);
|
return new SettableFuture<>(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MediaType.VCARD.equals(mediaType) && isSecureText) {
|
if (MediaType.VCARD.equals(mediaType)) {
|
||||||
return new SettableFuture<>(false);
|
return new SettableFuture<>(false);
|
||||||
} else if (MediaType.IMAGE.equals(mediaType) || MediaType.GIF.equals(mediaType) || MediaType.VIDEO.equals(mediaType)) {
|
} else if (MediaType.IMAGE.equals(mediaType) || MediaType.GIF.equals(mediaType) || MediaType.VIDEO.equals(mediaType)) {
|
||||||
Media media = new Media(uri, MediaUtil.getMimeType(this, uri), 0, width, height, 0, Optional.absent(), Optional.absent());
|
Media media = new Media(uri, MediaUtil.getMimeType(this, uri), 0, width, height, 0, Optional.absent(), Optional.absent());
|
||||||
startActivityForResult(MediaSendActivity.buildEditorIntent(ConversationActivity.this, Collections.singletonList(media), recipient, composeText.getTextTrimmed(), sendButton.getSelectedTransport()), MEDIA_SENDER);
|
startActivityForResult(MediaSendActivity.buildEditorIntent(ConversationActivity.this, Collections.singletonList(media), recipient, composeText.getTextTrimmed()), MEDIA_SENDER);
|
||||||
return new SettableFuture<>(false);
|
return new SettableFuture<>(false);
|
||||||
} else {
|
} else {
|
||||||
return attachmentManager.setMedia(glideRequests, uri, mediaType, getCurrentMediaConstraints(), width, height);
|
return attachmentManager.setMedia(glideRequests, uri, mediaType, MediaConstraints.getPushMediaConstraints(), width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1876,11 +1817,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendSharedContact(List<Contact> contacts) {
|
private void sendSharedContact(List<Contact> contacts) {
|
||||||
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
|
int subscriptionId = -1;
|
||||||
long expiresIn = recipient.getExpireMessages() * 1000L;
|
long expiresIn = recipient.getExpireMessages() * 1000L;
|
||||||
boolean initiating = threadId == -1;
|
boolean initiating = threadId == -1;
|
||||||
|
|
||||||
sendMediaMessage(isSmsForced(), "", attachmentManager.buildSlideDeck(), null, contacts, Collections.emptyList(), expiresIn, subscriptionId, initiating, false);
|
sendMediaMessage(false, "", attachmentManager.buildSlideDeck(), null, contacts, Collections.emptyList(), expiresIn, subscriptionId, initiating, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectContactInfo(ContactData contactData) {
|
private void selectContactInfo(ContactData contactData) {
|
||||||
@ -1966,16 +1907,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setActionBarColor(MaterialColor color) {
|
private void updateInputUI(Recipient recipient) {
|
||||||
//TODO AC: As we're trying to theme everything properly this method seems a bit broken
|
|
||||||
// and it's not used anyway so it's a subject to be deleted.
|
|
||||||
// ActionBar supportActionBar = getSupportActionBar();
|
|
||||||
// if (supportActionBar == null) throw new AssertionError();
|
|
||||||
// supportActionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.action_bar_background)));
|
|
||||||
// setStatusBarColor(getResources().getColor(R.color.action_bar_background));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateInputUI(Recipient recipient, boolean isSecureText, boolean isDefaultSms) {
|
|
||||||
if (recipient.isGroupRecipient() && !isActiveGroup()) {
|
if (recipient.isGroupRecipient() && !isActiveGroup()) {
|
||||||
unblockButton.setVisibility(View.GONE);
|
unblockButton.setVisibility(View.GONE);
|
||||||
inputPanel.setVisibility(View.GONE);
|
inputPanel.setVisibility(View.GONE);
|
||||||
@ -1984,14 +1916,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
unblockButton.setVisibility(View.VISIBLE);
|
unblockButton.setVisibility(View.VISIBLE);
|
||||||
inputPanel.setVisibility(View.GONE);
|
inputPanel.setVisibility(View.GONE);
|
||||||
makeDefaultSmsButton.setVisibility(View.GONE);
|
makeDefaultSmsButton.setVisibility(View.GONE);
|
||||||
} else if (!isSecureText && isPushGroupConversation()) {
|
// } else if (!isSecureText && isPushGroupConversation()) {
|
||||||
unblockButton.setVisibility(View.GONE);
|
// unblockButton.setVisibility(View.GONE);
|
||||||
inputPanel.setVisibility(View.GONE);
|
// inputPanel.setVisibility(View.GONE);
|
||||||
makeDefaultSmsButton.setVisibility(View.GONE);
|
// makeDefaultSmsButton.setVisibility(View.GONE);
|
||||||
} else if (!isSecureText && !isDefaultSms) {
|
// } else if (!isSecureText && !isDefaultSms) {
|
||||||
unblockButton.setVisibility(View.GONE);
|
// unblockButton.setVisibility(View.GONE);
|
||||||
inputPanel.setVisibility(View.GONE);
|
// inputPanel.setVisibility(View.GONE);
|
||||||
makeDefaultSmsButton.setVisibility(View.GONE);
|
// makeDefaultSmsButton.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
inputPanel.setVisibility(View.VISIBLE);
|
inputPanel.setVisibility(View.VISIBLE);
|
||||||
unblockButton.setVisibility(View.GONE);
|
unblockButton.setVisibility(View.GONE);
|
||||||
@ -2074,10 +2006,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
return getRecipient() != null && getRecipient().isPushGroupRecipient();
|
return getRecipient() != null && getRecipient().isPushGroupRecipient();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSmsForced() {
|
|
||||||
return sendButton.isManualSelection() && sendButton.getSelectedTransport().isSms();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Recipient getRecipient() {
|
protected Recipient getRecipient() {
|
||||||
return this.recipient;
|
return this.recipient;
|
||||||
}
|
}
|
||||||
@ -2123,12 +2051,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
return new Pair<>(bodyText, textSlide);
|
return new Pair<>(bodyText, textSlide);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MediaConstraints getCurrentMediaConstraints() {
|
|
||||||
return sendButton.getSelectedTransport().getType() == Type.TEXTSECURE
|
|
||||||
? MediaConstraints.getPushMediaConstraints()
|
|
||||||
: MediaConstraints.getMmsMediaConstraints(sendButton.getSelectedTransport().getSimSubscriptionId().or(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void markThreadAsRead() {
|
private void markThreadAsRead() {
|
||||||
Recipient recipient = this.recipient;
|
Recipient recipient = this.recipient;
|
||||||
new AsyncTask<Long, Void, Void>() {
|
new AsyncTask<Long, Void, Void>() {
|
||||||
@ -2202,12 +2124,10 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
String message = getMessage();
|
String message = getMessage();
|
||||||
TransportOption transport = sendButton.getSelectedTransport();
|
int subscriptionId = -1;
|
||||||
boolean forceSms = (recipient.isForceSmsSelection() || sendButton.isManualSelection()) && transport.isSms();
|
|
||||||
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
|
|
||||||
long expiresIn = recipient.getExpireMessages() * 1000L;
|
long expiresIn = recipient.getExpireMessages() * 1000L;
|
||||||
boolean initiating = threadId == -1;
|
boolean initiating = threadId == -1;
|
||||||
boolean needsSplit = !transport.isSms() && message.length() > transport.calculateCharacters(message).maxPrimaryMessageSize;
|
boolean needsSplit = message.length() > characterCalculator.calculateCharacters(message).maxPrimaryMessageSize;
|
||||||
boolean isMediaMessage = attachmentManager.isAttachmentPresent() ||
|
boolean isMediaMessage = attachmentManager.isAttachmentPresent() ||
|
||||||
recipient.isGroupRecipient() ||
|
recipient.isGroupRecipient() ||
|
||||||
recipient.getAddress().isEmail() ||
|
recipient.getAddress().isEmail() ||
|
||||||
@ -2216,17 +2136,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
LinkPreviewUtil.isValidMediaUrl(message) || // Loki - Send GIFs as media messages
|
LinkPreviewUtil.isValidMediaUrl(message) || // Loki - Send GIFs as media messages
|
||||||
needsSplit;
|
needsSplit;
|
||||||
|
|
||||||
Log.i(TAG, "isManual Selection: " + sendButton.isManualSelection());
|
if (identityRecords.isUnverified()) {
|
||||||
Log.i(TAG, "forceSms: " + forceSms);
|
|
||||||
|
|
||||||
if (!forceSms && identityRecords.isUnverified()) {
|
|
||||||
handleUnverifiedRecipients();
|
handleUnverifiedRecipients();
|
||||||
}/* else if (!forceSms && identityRecords.isUntrusted()) {
|
} else if (isMediaMessage) {
|
||||||
handleUntrustedRecipients();
|
sendMediaMessage(expiresIn, subscriptionId, initiating);
|
||||||
}*/ else if (isMediaMessage) {
|
|
||||||
sendMediaMessage(forceSms, expiresIn, subscriptionId, initiating);
|
|
||||||
} else {
|
} else {
|
||||||
sendTextMessage(forceSms, expiresIn, subscriptionId, initiating);
|
sendTextMessage(expiresIn, subscriptionId, initiating);
|
||||||
}
|
}
|
||||||
} catch (RecipientFormattingException ex) {
|
} catch (RecipientFormattingException ex) {
|
||||||
Log.w(TAG, ex);
|
Log.w(TAG, ex);
|
||||||
@ -2241,11 +2156,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMediaMessage(final boolean forceSms, final long expiresIn, final int subscriptionId, boolean initiating)
|
private void sendMediaMessage(final long expiresIn, final int subscriptionId, boolean initiating)
|
||||||
throws InvalidMessageException
|
throws InvalidMessageException
|
||||||
{
|
{
|
||||||
Log.i(TAG, "Sending media message...");
|
Log.i(TAG, "Sending media message...");
|
||||||
sendMediaMessage(forceSms, getMessage(), attachmentManager.buildSlideDeck(), inputPanel.getQuote().orNull(), Collections.emptyList(), linkPreviewViewModel.getActiveLinkPreviews(), expiresIn, subscriptionId, initiating, true);
|
sendMediaMessage(false, getMessage(), attachmentManager.buildSlideDeck(), inputPanel.getQuote().orNull(), Collections.emptyList(), linkPreviewViewModel.getActiveLinkPreviews(), expiresIn, subscriptionId, initiating, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListenableFuture<Void> sendMediaMessage(final boolean forceSms,
|
private ListenableFuture<Void> sendMediaMessage(final boolean forceSms,
|
||||||
@ -2259,18 +2174,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
final boolean initiating,
|
final boolean initiating,
|
||||||
final boolean clearComposeBox)
|
final boolean clearComposeBox)
|
||||||
{
|
{
|
||||||
if (!isDefaultSms && (!isSecureText || forceSms)) {
|
|
||||||
showDefaultSmsPrompt();
|
|
||||||
return new SettableFuture<>(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isSecureText && !forceSms) {
|
Pair<String, Optional<Slide>> splitMessage = getSplitMessage(body, characterCalculator.calculateCharacters(body).maxPrimaryMessageSize);
|
||||||
Pair<String, Optional<Slide>> splitMessage = getSplitMessage(body, sendButton.getSelectedTransport().calculateCharacters(body).maxPrimaryMessageSize);
|
body = splitMessage.first;
|
||||||
body = splitMessage.first;
|
|
||||||
|
|
||||||
if (splitMessage.second.isPresent()) {
|
if (splitMessage.second.isPresent()) {
|
||||||
slideDeck.addSlide(splitMessage.second.get());
|
slideDeck.addSlide(splitMessage.second.get());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OutgoingMediaMessage outgoingMessageCandidate = new OutgoingMediaMessage(recipient, slideDeck, body, System.currentTimeMillis(), subscriptionId, expiresIn, distributionType, quote, contacts, previews);
|
OutgoingMediaMessage outgoingMessageCandidate = new OutgoingMediaMessage(recipient, slideDeck, body, System.currentTimeMillis(), subscriptionId, expiresIn, distributionType, quote, contacts, previews);
|
||||||
@ -2280,12 +2189,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
final OutgoingMediaMessage outgoingMessage;
|
final OutgoingMediaMessage outgoingMessage;
|
||||||
|
|
||||||
if (isSecureText && !forceSms) {
|
outgoingMessage = new OutgoingSecureMediaMessage(outgoingMessageCandidate);
|
||||||
outgoingMessage = new OutgoingSecureMediaMessage(outgoingMessageCandidate);
|
ApplicationContext.getInstance(context).getTypingStatusSender().onTypingStopped(threadId);
|
||||||
ApplicationContext.getInstance(context).getTypingStatusSender().onTypingStopped(threadId);
|
|
||||||
} else {
|
|
||||||
outgoingMessage = outgoingMessageCandidate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clearComposeBox) {
|
if (clearComposeBox) {
|
||||||
inputPanel.clearQuote();
|
inputPanel.clearQuote();
|
||||||
@ -2311,25 +2216,16 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendTextMessage(final boolean forceSms, final long expiresIn, final int subscriptionId, final boolean initiatingConversation)
|
private void sendTextMessage(final long expiresIn, final int subscriptionId, final boolean initiatingConversation)
|
||||||
throws InvalidMessageException
|
throws InvalidMessageException
|
||||||
{
|
{
|
||||||
if (!isDefaultSms && (!isSecureText || forceSms)) {
|
|
||||||
showDefaultSmsPrompt();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Context context = getApplicationContext();
|
final Context context = getApplicationContext();
|
||||||
final String messageBody = getMessage();
|
final String messageBody = getMessage();
|
||||||
|
|
||||||
OutgoingTextMessage message;
|
OutgoingTextMessage message;
|
||||||
|
|
||||||
if (isSecureText && !forceSms) {
|
message = new OutgoingEncryptedMessage(recipient, messageBody, expiresIn);
|
||||||
message = new OutgoingEncryptedMessage(recipient, messageBody, expiresIn);
|
ApplicationContext.getInstance(context).getTypingStatusSender().onTypingStopped(threadId);
|
||||||
ApplicationContext.getInstance(context).getTypingStatusSender().onTypingStopped(threadId);
|
|
||||||
} else {
|
|
||||||
message = new OutgoingTextMessage(recipient, messageBody, expiresIn, subscriptionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
silentlySetComposeText("");
|
silentlySetComposeText("");
|
||||||
final long id = fragment.stageOutgoingMessage(message);
|
final long id = fragment.stageOutgoingMessage(message);
|
||||||
@ -2338,7 +2234,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient, true);
|
DatabaseFactory.getRecipientDatabase(context).setProfileSharing(recipient, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
long result = MessageSender.send(context, message, threadId, forceSms, () -> fragment.releaseOutgoingMessage(id));
|
long result = MessageSender.send(context, message, threadId, false, () -> fragment.releaseOutgoingMessage(id));
|
||||||
|
|
||||||
if (!recipient.isGroupRecipient()) {
|
if (!recipient.isGroupRecipient()) {
|
||||||
ApplicationContext.getInstance(context).sendSessionRequestIfNeeded(recipient.getAddress().serialize());
|
ApplicationContext.getInstance(context).sendSessionRequestIfNeeded(recipient.getAddress().serialize());
|
||||||
@ -2380,7 +2276,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLinkPreviewState() {
|
private void updateLinkPreviewState() {
|
||||||
if (TextSecurePreferences.isLinkPreviewsEnabled(this) && !sendButton.getSelectedTransport().isSms() && !attachmentManager.isAttachmentPresent()) {
|
if (TextSecurePreferences.isLinkPreviewsEnabled(this) && !attachmentManager.isAttachmentPresent()) {
|
||||||
linkPreviewViewModel.onEnabled();
|
linkPreviewViewModel.onEnabled();
|
||||||
linkPreviewViewModel.onTextChanged(this, composeText.getTextTrimmed(), composeText.getSelectionStart(), composeText.getSelectionEnd());
|
linkPreviewViewModel.onTextChanged(this, composeText.getTextTrimmed(), composeText.getSelectionStart(), composeText.getSelectionEnd());
|
||||||
} else {
|
} else {
|
||||||
@ -2388,23 +2284,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recordTransportPreference(TransportOption transportOption) {
|
|
||||||
new AsyncTask<Void, Void, Void>() {
|
|
||||||
@Override
|
|
||||||
protected Void doInBackground(Void... params) {
|
|
||||||
RecipientDatabase recipientDatabase = DatabaseFactory.getRecipientDatabase(ConversationActivity.this);
|
|
||||||
|
|
||||||
recipientDatabase.setDefaultSubscriptionId(recipient, transportOption.getSimSubscriptionId().or(-1));
|
|
||||||
|
|
||||||
if (!recipient.isPushGroupRecipient()) {
|
|
||||||
recipientDatabase.setForceSmsSelection(recipient, recipient.getRegistered() == RegisteredState.REGISTERED && transportOption.isSms());
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRecorderPermissionRequired() {
|
public void onRecorderPermissionRequired() {
|
||||||
Permissions.with(this)
|
Permissions.with(this)
|
||||||
@ -2448,15 +2327,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
|
future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final @NonNull Pair<Uri, Long> result) {
|
public void onSuccess(final @NonNull Pair<Uri, Long> result) {
|
||||||
boolean forceSms = sendButton.isManualSelection() && sendButton.getSelectedTransport().isSms();
|
int subscriptionId = -1;
|
||||||
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
|
|
||||||
long expiresIn = recipient.getExpireMessages() * 1000L;
|
long expiresIn = recipient.getExpireMessages() * 1000L;
|
||||||
boolean initiating = threadId == -1;
|
boolean initiating = threadId == -1;
|
||||||
AudioSlide audioSlide = new AudioSlide(ConversationActivity.this, result.first, result.second, MediaUtil.AUDIO_AAC, true);
|
AudioSlide audioSlide = new AudioSlide(ConversationActivity.this, result.first, result.second, MediaUtil.AUDIO_AAC, true);
|
||||||
SlideDeck slideDeck = new SlideDeck();
|
SlideDeck slideDeck = new SlideDeck();
|
||||||
slideDeck.addSlide(audioSlide);
|
slideDeck.addSlide(audioSlide);
|
||||||
|
|
||||||
sendMediaMessage(forceSms, "", slideDeck, inputPanel.getQuote().orNull(), Collections.emptyList(), Collections.emptyList(), expiresIn, subscriptionId, initiating, true).addListener(new AssertedSuccessListener<Void>() {
|
sendMediaMessage(false, "", slideDeck, inputPanel.getQuote().orNull(), Collections.emptyList(), Collections.emptyList(), expiresIn, subscriptionId, initiating, true).addListener(new AssertedSuccessListener<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void nothing) {
|
public void onSuccess(Void nothing) {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
@ -2571,23 +2449,15 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendSticker(@NonNull StickerLocator stickerLocator, @NonNull Uri uri, long size, boolean clearCompose) {
|
private void sendSticker(@NonNull StickerLocator stickerLocator, @NonNull Uri uri, long size, boolean clearCompose) {
|
||||||
if (sendButton.getSelectedTransport().isSms()) {
|
|
||||||
Media media = new Media(uri, MediaUtil.IMAGE_WEBP, System.currentTimeMillis(), StickerSlide.WIDTH, StickerSlide.HEIGHT, size, Optional.absent(), Optional.absent());
|
|
||||||
Intent intent = MediaSendActivity.buildEditorIntent(this, Collections.singletonList(media), recipient, composeText.getTextTrimmed(), sendButton.getSelectedTransport());
|
|
||||||
startActivityForResult(intent, MEDIA_SENDER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long expiresIn = recipient.getExpireMessages() * 1000L;
|
long expiresIn = recipient.getExpireMessages() * 1000L;
|
||||||
int subscriptionId = sendButton.getSelectedTransport().getSimSubscriptionId().or(-1);
|
int subscriptionId = -1;
|
||||||
boolean initiating = threadId == -1;
|
boolean initiating = threadId == -1;
|
||||||
TransportOption transport = sendButton.getSelectedTransport();
|
|
||||||
SlideDeck slideDeck = new SlideDeck();
|
SlideDeck slideDeck = new SlideDeck();
|
||||||
Slide stickerSlide = new StickerSlide(this, uri, size, stickerLocator);
|
Slide stickerSlide = new StickerSlide(this, uri, size, stickerLocator);
|
||||||
|
|
||||||
slideDeck.addSlide(stickerSlide);
|
slideDeck.addSlide(stickerSlide);
|
||||||
|
|
||||||
sendMediaMessage(transport.isSms(), "", slideDeck, null, Collections.emptyList(), Collections.emptyList(), expiresIn, subscriptionId, initiating, clearCompose);
|
sendMediaMessage(false, "", slideDeck, null, Collections.emptyList(), Collections.emptyList(), expiresIn, subscriptionId, initiating, clearCompose);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2610,7 +2480,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
public void onQuickAttachment(Uri uri, String mimeType, String bucketId, long dateTaken, int width, int height, long size) {
|
public void onQuickAttachment(Uri uri, String mimeType, String bucketId, long dateTaken, int width, int height, long size) {
|
||||||
linkPreviewViewModel.onUserCancel();
|
linkPreviewViewModel.onUserCancel();
|
||||||
Media media = new Media(uri, mimeType, dateTaken, width, height, size, Optional.of(Media.ALL_MEDIA_BUCKET_ID), Optional.absent());
|
Media media = new Media(uri, mimeType, dateTaken, width, height, size, Optional.of(Media.ALL_MEDIA_BUCKET_ID), Optional.absent());
|
||||||
startActivityForResult(MediaSendActivity.buildEditorIntent(ConversationActivity.this, Collections.singletonList(media), recipient, composeText.getTextTrimmed(), sendButton.getSelectedTransport()), MEDIA_SENDER);
|
startActivityForResult(MediaSendActivity.buildEditorIntent(ConversationActivity.this, Collections.singletonList(media), recipient, composeText.getTextTrimmed()), MEDIA_SENDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2623,7 +2493,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
.withPermanentDenialDialog(getString(R.string.ConversationActivity_signal_needs_the_camera_permission_to_take_photos_or_video))
|
.withPermanentDenialDialog(getString(R.string.ConversationActivity_signal_needs_the_camera_permission_to_take_photos_or_video))
|
||||||
.onAllGranted(() -> {
|
.onAllGranted(() -> {
|
||||||
composeText.clearFocus();
|
composeText.clearFocus();
|
||||||
startActivityForResult(MediaSendActivity.buildCameraIntent(ConversationActivity.this, recipient, sendButton.getSelectedTransport()), MEDIA_SENDER);
|
startActivityForResult(MediaSendActivity.buildCameraIntent(ConversationActivity.this, recipient), MEDIA_SENDER);
|
||||||
overridePendingTransition(R.anim.camera_slide_from_bottom, R.anim.stationary);
|
overridePendingTransition(R.anim.camera_slide_from_bottom, R.anim.stationary);
|
||||||
})
|
})
|
||||||
.onAnyDenied(() -> Toast.makeText(ConversationActivity.this, R.string.ConversationActivity_signal_needs_camera_permissions_to_take_photos_or_video, Toast.LENGTH_LONG).show())
|
.onAnyDenied(() -> Toast.makeText(ConversationActivity.this, R.string.ConversationActivity_signal_needs_camera_permissions_to_take_photos_or_video, Toast.LENGTH_LONG).show())
|
||||||
@ -2712,7 +2582,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTextChanged(String text) {
|
public void onTextChanged(String text) {
|
||||||
if (enabled && threadId > 0 && isSecureText && !isSmsForced()) {
|
if (enabled && threadId > 0) {
|
||||||
ApplicationContext.getInstance(ConversationActivity.this).getTypingStatusSender().onTypingStarted(threadId);
|
ApplicationContext.getInstance(ConversationActivity.this).getTypingStatusSender().onTypingStarted(threadId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2853,7 +2723,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachmentChanged() {
|
public void onAttachmentChanged() {
|
||||||
handleSecurityChange(isSecureText, isDefaultSms);
|
handleSecurityChange(true, isDefaultSms);
|
||||||
updateToggleButtonState();
|
updateToggleButtonState();
|
||||||
updateLinkPreviewState();
|
updateLinkPreviewState();
|
||||||
}
|
}
|
||||||
|
@ -16,29 +16,25 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity;
|
||||||
import org.thoughtcrime.securesms.TransportOption;
|
|
||||||
import org.thoughtcrime.securesms.database.Address;
|
import org.thoughtcrime.securesms.database.Address;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
|
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
import network.loki.messenger.R;
|
||||||
|
|
||||||
@ -59,13 +55,11 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
|
|
||||||
public static final String EXTRA_MEDIA = "media";
|
public static final String EXTRA_MEDIA = "media";
|
||||||
public static final String EXTRA_MESSAGE = "message";
|
public static final String EXTRA_MESSAGE = "message";
|
||||||
public static final String EXTRA_TRANSPORT = "transport";
|
|
||||||
|
|
||||||
|
|
||||||
private static final String KEY_ADDRESS = "address";
|
private static final String KEY_ADDRESS = "address";
|
||||||
private static final String KEY_BODY = "body";
|
private static final String KEY_BODY = "body";
|
||||||
private static final String KEY_MEDIA = "media";
|
private static final String KEY_MEDIA = "media";
|
||||||
private static final String KEY_TRANSPORT = "transport";
|
|
||||||
private static final String KEY_IS_CAMERA = "is_camera";
|
private static final String KEY_IS_CAMERA = "is_camera";
|
||||||
|
|
||||||
private static final String TAG_FOLDER_PICKER = "folder_picker";
|
private static final String TAG_FOLDER_PICKER = "folder_picker";
|
||||||
@ -73,10 +67,8 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
private static final String TAG_SEND = "send";
|
private static final String TAG_SEND = "send";
|
||||||
private static final String TAG_CAMERA = "camera";
|
private static final String TAG_CAMERA = "camera";
|
||||||
|
|
||||||
private final DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
|
||||||
|
|
||||||
private Recipient recipient;
|
private Recipient recipient;
|
||||||
private TransportOption transport;
|
|
||||||
private MediaSendViewModel viewModel;
|
private MediaSendViewModel viewModel;
|
||||||
|
|
||||||
private View countButton;
|
private View countButton;
|
||||||
@ -86,10 +78,9 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
/**
|
/**
|
||||||
* Get an intent to launch the media send flow starting with the picker.
|
* Get an intent to launch the media send flow starting with the picker.
|
||||||
*/
|
*/
|
||||||
public static Intent buildGalleryIntent(@NonNull Context context, @NonNull Recipient recipient, @NonNull String body, @NonNull TransportOption transport) {
|
public static Intent buildGalleryIntent(@NonNull Context context, @NonNull Recipient recipient, @NonNull String body) {
|
||||||
Intent intent = new Intent(context, MediaSendActivity.class);
|
Intent intent = new Intent(context, MediaSendActivity.class);
|
||||||
intent.putExtra(KEY_ADDRESS, recipient.getAddress().serialize());
|
intent.putExtra(KEY_ADDRESS, recipient.getAddress().serialize());
|
||||||
intent.putExtra(KEY_TRANSPORT, transport);
|
|
||||||
intent.putExtra(KEY_BODY, body);
|
intent.putExtra(KEY_BODY, body);
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
@ -97,8 +88,8 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
/**
|
/**
|
||||||
* Get an intent to launch the media send flow starting with the picker.
|
* Get an intent to launch the media send flow starting with the picker.
|
||||||
*/
|
*/
|
||||||
public static Intent buildCameraIntent(@NonNull Context context, @NonNull Recipient recipient, @NonNull TransportOption transport) {
|
public static Intent buildCameraIntent(@NonNull Context context, @NonNull Recipient recipient) {
|
||||||
Intent intent = buildGalleryIntent(context, recipient, "", transport);
|
Intent intent = buildGalleryIntent(context, recipient, "");
|
||||||
intent.putExtra(KEY_IS_CAMERA, true);
|
intent.putExtra(KEY_IS_CAMERA, true);
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
@ -110,19 +101,13 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
public static Intent buildEditorIntent(@NonNull Context context,
|
public static Intent buildEditorIntent(@NonNull Context context,
|
||||||
@NonNull List<Media> media,
|
@NonNull List<Media> media,
|
||||||
@NonNull Recipient recipient,
|
@NonNull Recipient recipient,
|
||||||
@NonNull String body,
|
@NonNull String body)
|
||||||
@NonNull TransportOption transport)
|
|
||||||
{
|
{
|
||||||
Intent intent = buildGalleryIntent(context, recipient, body, transport);
|
Intent intent = buildGalleryIntent(context, recipient, body);
|
||||||
intent.putParcelableArrayListExtra(KEY_MEDIA, new ArrayList<>(media));
|
intent.putParcelableArrayListExtra(KEY_MEDIA, new ArrayList<>(media));
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPreCreate() {
|
|
||||||
dynamicLanguage.onCreate(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState, boolean ready) {
|
protected void onCreate(Bundle savedInstanceState, boolean ready) {
|
||||||
super.onCreate(savedInstanceState, ready);
|
super.onCreate(savedInstanceState, ready);
|
||||||
@ -140,9 +125,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
|
|
||||||
viewModel = new ViewModelProvider(this, new MediaSendViewModel.Factory(getApplication(), new MediaRepository())).get(MediaSendViewModel.class);
|
viewModel = new ViewModelProvider(this, new MediaSendViewModel.Factory(getApplication(), new MediaRepository())).get(MediaSendViewModel.class);
|
||||||
recipient = Recipient.from(this, Address.fromSerialized(getIntent().getStringExtra(KEY_ADDRESS)), true);
|
recipient = Recipient.from(this, Address.fromSerialized(getIntent().getStringExtra(KEY_ADDRESS)), true);
|
||||||
transport = getIntent().getParcelableExtra(KEY_TRANSPORT);
|
|
||||||
|
|
||||||
viewModel.setTransport(transport);
|
|
||||||
viewModel.onBodyChanged(getIntent().getStringExtra(KEY_BODY));
|
viewModel.onBodyChanged(getIntent().getStringExtra(KEY_BODY));
|
||||||
|
|
||||||
List<Media> media = getIntent().getParcelableArrayListExtra(KEY_MEDIA);
|
List<Media> media = getIntent().getParcelableArrayListExtra(KEY_MEDIA);
|
||||||
@ -157,7 +140,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
} else if (!Util.isEmpty(media)) {
|
} else if (!Util.isEmpty(media)) {
|
||||||
viewModel.onSelectedMediaChanged(this, media);
|
viewModel.onSelectedMediaChanged(this, media);
|
||||||
|
|
||||||
Fragment fragment = MediaSendFragment.newInstance(recipient, transport, dynamicLanguage.getCurrentLocale());
|
Fragment fragment = MediaSendFragment.newInstance(recipient);
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.replace(R.id.mediasend_fragment_container, fragment, TAG_SEND)
|
.replace(R.id.mediasend_fragment_container, fragment, TAG_SEND)
|
||||||
.commit();
|
.commit();
|
||||||
@ -168,7 +151,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
.commit();
|
.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeCountButtonObserver(transport, dynamicLanguage.getCurrentLocale());
|
initializeCountButtonObserver();
|
||||||
initializeCameraButtonObserver();
|
initializeCameraButtonObserver();
|
||||||
initializeErrorObserver();
|
initializeErrorObserver();
|
||||||
|
|
||||||
@ -183,12 +166,6 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
dynamicLanguage.onResume(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
MediaSendFragment sendFragment = (MediaSendFragment) getSupportFragmentManager().findFragmentByTag(TAG_SEND);
|
MediaSendFragment sendFragment = (MediaSendFragment) getSupportFragmentManager().findFragmentByTag(TAG_SEND);
|
||||||
@ -203,6 +180,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
|
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +199,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
@Override
|
@Override
|
||||||
public void onMediaSelected(@NonNull Media media) {
|
public void onMediaSelected(@NonNull Media media) {
|
||||||
viewModel.onSingleMediaSelected(this, media);
|
viewModel.onSingleMediaSelected(this, media);
|
||||||
navigateToMediaSend(recipient, transport, dynamicLanguage.getCurrentLocale());
|
navigateToMediaSend(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -244,7 +222,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSendClicked(@NonNull List<Media> media, @NonNull String message, @NonNull TransportOption transport) {
|
public void onSendClicked(@NonNull List<Media> media, @NonNull String message) {
|
||||||
viewModel.onSendClicked();
|
viewModel.onSendClicked();
|
||||||
|
|
||||||
ArrayList<Media> mediaList = new ArrayList<>(media);
|
ArrayList<Media> mediaList = new ArrayList<>(media);
|
||||||
@ -252,7 +230,6 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
|
|
||||||
intent.putParcelableArrayListExtra(EXTRA_MEDIA, mediaList);
|
intent.putParcelableArrayListExtra(EXTRA_MEDIA, mediaList);
|
||||||
intent.putExtra(EXTRA_MESSAGE, message);
|
intent.putExtra(EXTRA_MESSAGE, message);
|
||||||
intent.putExtra(EXTRA_TRANSPORT, transport);
|
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
finish();
|
finish();
|
||||||
|
|
||||||
@ -310,7 +287,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
Log.i(TAG, "Camera capture stored: " + media.getUri().toString());
|
Log.i(TAG, "Camera capture stored: " + media.getUri().toString());
|
||||||
|
|
||||||
viewModel.onImageCaptured(media);
|
viewModel.onImageCaptured(media);
|
||||||
navigateToMediaSend(recipient, transport, dynamicLanguage.getCurrentLocale());
|
navigateToMediaSend(recipient);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +296,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
return getWindowManager().getDefaultDisplay().getRotation();
|
return getWindowManager().getDefaultDisplay().getRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeCountButtonObserver(@NonNull TransportOption transport, @NonNull Locale locale) {
|
private void initializeCountButtonObserver() {
|
||||||
viewModel.getCountButtonState().observe(this, buttonState -> {
|
viewModel.getCountButtonState().observe(this, buttonState -> {
|
||||||
if (buttonState == null) return;
|
if (buttonState == null) return;
|
||||||
|
|
||||||
@ -328,7 +305,7 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
animateButtonVisibility(countButton, countButton.getVisibility(), buttonState.isVisible() ? View.VISIBLE : View.GONE);
|
animateButtonVisibility(countButton, countButton.getVisibility(), buttonState.isVisible() ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
if (buttonState.getCount() > 0) {
|
if (buttonState.getCount() > 0) {
|
||||||
countButton.setOnClickListener(v -> navigateToMediaSend(recipient, transport, locale));
|
countButton.setOnClickListener(v -> navigateToMediaSend(recipient));
|
||||||
if (buttonState.isVisible()) {
|
if (buttonState.isVisible()) {
|
||||||
animateButtonTextChange(countButton);
|
animateButtonTextChange(countButton);
|
||||||
}
|
}
|
||||||
@ -361,8 +338,8 @@ public class MediaSendActivity extends PassphraseRequiredActionBarActivity imple
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void navigateToMediaSend(@NonNull Recipient recipient, @NonNull TransportOption transport, @NonNull Locale locale) {
|
private void navigateToMediaSend(@NonNull Recipient recipient) {
|
||||||
MediaSendFragment fragment = MediaSendFragment.newInstance(recipient, transport, locale);
|
MediaSendFragment fragment = MediaSendFragment.newInstance(recipient);
|
||||||
String backstackTag = null;
|
String backstackTag = null;
|
||||||
|
|
||||||
if (getSupportFragmentManager().findFragmentByTag(TAG_SEND) != null) {
|
if (getSupportFragmentManager().findFragmentByTag(TAG_SEND) != null) {
|
||||||
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
|
|||||||
import androidx.lifecycle.ViewModelProviders;
|
import androidx.lifecycle.ViewModelProviders;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.PorterDuff;
|
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -26,13 +25,12 @@ import android.view.ViewGroup;
|
|||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TransportOption;
|
|
||||||
import org.thoughtcrime.securesms.components.ComposeText;
|
import org.thoughtcrime.securesms.components.ComposeText;
|
||||||
import org.thoughtcrime.securesms.components.ControllableViewPager;
|
import org.thoughtcrime.securesms.components.ControllableViewPager;
|
||||||
import org.thoughtcrime.securesms.components.InputAwareLayout;
|
import org.thoughtcrime.securesms.components.InputAwareLayout;
|
||||||
import org.thoughtcrime.securesms.components.SendButton;
|
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
import org.thoughtcrime.securesms.components.emoji.EmojiEditText;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
|
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
import org.thoughtcrime.securesms.components.emoji.EmojiToggle;
|
||||||
@ -47,6 +45,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||||||
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
import org.thoughtcrime.securesms.scribbles.ImageEditorFragment;
|
||||||
import org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState;
|
import org.thoughtcrime.securesms.util.CharacterCalculator.CharacterState;
|
||||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.PushCharacterCalculator;
|
||||||
import org.thoughtcrime.securesms.util.Stopwatch;
|
import org.thoughtcrime.securesms.util.Stopwatch;
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
@ -78,12 +77,10 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
private static final String TAG = MediaSendFragment.class.getSimpleName();
|
private static final String TAG = MediaSendFragment.class.getSimpleName();
|
||||||
|
|
||||||
private static final String KEY_ADDRESS = "address";
|
private static final String KEY_ADDRESS = "address";
|
||||||
private static final String KEY_TRANSPORT = "transport";
|
|
||||||
private static final String KEY_LOCALE = "locale";
|
|
||||||
|
|
||||||
private InputAwareLayout hud;
|
private InputAwareLayout hud;
|
||||||
private View captionAndRail;
|
private View captionAndRail;
|
||||||
private SendButton sendButton;
|
private ImageButton sendButton;
|
||||||
private ComposeText composeText;
|
private ComposeText composeText;
|
||||||
private ViewGroup composeContainer;
|
private ViewGroup composeContainer;
|
||||||
private EmojiEditText captionText;
|
private EmojiEditText captionText;
|
||||||
@ -101,15 +98,14 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
private int visibleHeight;
|
private int visibleHeight;
|
||||||
private MediaSendViewModel viewModel;
|
private MediaSendViewModel viewModel;
|
||||||
private Controller controller;
|
private Controller controller;
|
||||||
private Locale locale;
|
|
||||||
|
|
||||||
private final Rect visibleBounds = new Rect();
|
private final Rect visibleBounds = new Rect();
|
||||||
|
|
||||||
public static MediaSendFragment newInstance(@NonNull Recipient recipient, @NonNull TransportOption transport, @NonNull Locale locale) {
|
private final PushCharacterCalculator characterCalculator = new PushCharacterCalculator();
|
||||||
|
|
||||||
|
public static MediaSendFragment newInstance(@NonNull Recipient recipient) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(KEY_ADDRESS, recipient.getAddress());
|
args.putParcelable(KEY_ADDRESS, recipient.getAddress());
|
||||||
args.putParcelable(KEY_TRANSPORT, transport);
|
|
||||||
args.putSerializable(KEY_LOCALE, locale);
|
|
||||||
|
|
||||||
MediaSendFragment fragment = new MediaSendFragment();
|
MediaSendFragment fragment = new MediaSendFragment();
|
||||||
fragment.setArguments(args);
|
fragment.setArguments(args);
|
||||||
@ -136,8 +132,6 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
locale = (Locale) getArguments().getSerializable(KEY_LOCALE);
|
|
||||||
|
|
||||||
initViewModel();
|
initViewModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,12 +161,12 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
processMedia(fragmentPagerAdapter.getAllMedia(), fragmentPagerAdapter.getSavedState());
|
processMedia(fragmentPagerAdapter.getAllMedia(), fragmentPagerAdapter.getSavedState());
|
||||||
});
|
});
|
||||||
|
|
||||||
sendButton.addOnTransportChangedListener((newTransport, manuallySelected) -> {
|
// sendButton.addOnTransportChangedListener((newTransport, manuallySelected) -> {
|
||||||
presentCharactersRemaining();
|
// presentCharactersRemaining();
|
||||||
composeText.setTransport(newTransport);
|
// composeText.setTransport(newTransport);
|
||||||
sendButtonBkg.getBackground().setColorFilter(getResources().getColor(R.color.transparent), PorterDuff.Mode.MULTIPLY);
|
// sendButtonBkg.getBackground().setColorFilter(getResources().getColor(R.color.transparent), PorterDuff.Mode.MULTIPLY);
|
||||||
sendButtonBkg.getBackground().invalidateSelf();
|
// sendButtonBkg.getBackground().invalidateSelf();
|
||||||
});
|
// });
|
||||||
|
|
||||||
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();
|
||||||
|
|
||||||
@ -206,11 +200,6 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TransportOption transportOption = getArguments().getParcelable(KEY_TRANSPORT);
|
|
||||||
|
|
||||||
sendButton.setTransport(transportOption);
|
|
||||||
sendButton.disableTransport(transportOption.getType() == TransportOption.Type.SMS ? TransportOption.Type.TEXTSECURE : TransportOption.Type.SMS);
|
|
||||||
|
|
||||||
composeText.append(viewModel.getBody());
|
composeText.append(viewModel.getBody());
|
||||||
|
|
||||||
Recipient recipient = Recipient.from(requireContext(), getArguments().getParcelable(KEY_ADDRESS), false);
|
Recipient recipient = Recipient.from(requireContext(), getArguments().getParcelable(KEY_ADDRESS), false);
|
||||||
@ -283,40 +272,28 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onKeyboardShown() {
|
public void onKeyboardShown() {
|
||||||
if (sendButton.getSelectedTransport().isSms()) {
|
if (captionText.hasFocus()) {
|
||||||
mediaRail.setVisibility(View.GONE);
|
mediaRail.setVisibility(View.VISIBLE);
|
||||||
|
composeContainer.setVisibility(View.GONE);
|
||||||
|
captionText.setVisibility(View.VISIBLE);
|
||||||
|
} else if (composeText.hasFocus()) {
|
||||||
|
mediaRail.setVisibility(View.VISIBLE);
|
||||||
composeContainer.setVisibility(View.VISIBLE);
|
composeContainer.setVisibility(View.VISIBLE);
|
||||||
captionText.setVisibility(View.GONE);
|
captionText.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
if (captionText.hasFocus()) {
|
mediaRail.setVisibility(View.GONE);
|
||||||
mediaRail.setVisibility(View.VISIBLE);
|
composeContainer.setVisibility(View.VISIBLE);
|
||||||
composeContainer.setVisibility(View.GONE);
|
captionText.setVisibility(View.GONE);
|
||||||
captionText.setVisibility(View.VISIBLE);
|
|
||||||
} else if (composeText.hasFocus()) {
|
|
||||||
mediaRail.setVisibility(View.VISIBLE);
|
|
||||||
composeContainer.setVisibility(View.VISIBLE);
|
|
||||||
captionText.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
mediaRail.setVisibility(View.GONE);
|
|
||||||
composeContainer.setVisibility(View.VISIBLE);
|
|
||||||
captionText.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onKeyboardHidden() {
|
public void onKeyboardHidden() {
|
||||||
composeContainer.setVisibility(View.VISIBLE);
|
composeContainer.setVisibility(View.VISIBLE);
|
||||||
|
mediaRail.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (sendButton.getSelectedTransport().isSms()) {
|
if (!Util.isEmpty(viewModel.getSelectedMedia().getValue()) && viewModel.getSelectedMedia().getValue().size() > 1) {
|
||||||
mediaRail.setVisibility(View.GONE);
|
captionText.setVisibility(View.VISIBLE);
|
||||||
captionText.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
mediaRail.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (!Util.isEmpty(viewModel.getSelectedMedia().getValue()) && viewModel.getSelectedMedia().getValue().size() > 1) {
|
|
||||||
captionText.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +322,7 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
|
|
||||||
fragmentPagerAdapter.setMedia(media);
|
fragmentPagerAdapter.setMedia(media);
|
||||||
|
|
||||||
mediaRail.setVisibility(sendButton.getSelectedTransport().isSms() ? View.GONE : View.VISIBLE);
|
mediaRail.setVisibility(View.VISIBLE);
|
||||||
captionText.setVisibility((media.size() > 1 || media.get(0).getCaption().isPresent()) ? View.VISIBLE : View.GONE);
|
captionText.setVisibility((media.size() > 1 || media.get(0).getCaption().isPresent()) ? View.VISIBLE : View.GONE);
|
||||||
mediaRailAdapter.setMedia(media);
|
mediaRailAdapter.setMedia(media);
|
||||||
});
|
});
|
||||||
@ -388,11 +365,10 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
|
|
||||||
private void presentCharactersRemaining() {
|
private void presentCharactersRemaining() {
|
||||||
String messageBody = composeText.getTextTrimmed();
|
String messageBody = composeText.getTextTrimmed();
|
||||||
TransportOption transportOption = sendButton.getSelectedTransport();
|
CharacterState characterState = characterCalculator.calculateCharacters(messageBody);
|
||||||
CharacterState characterState = transportOption.calculateCharacters(messageBody);
|
|
||||||
|
|
||||||
if (characterState.charactersRemaining <= 15 || characterState.messagesSpent > 1) {
|
if (characterState.charactersRemaining <= 15 || characterState.messagesSpent > 1) {
|
||||||
charactersLeft.setText(String.format(locale,
|
charactersLeft.setText(String.format(Locale.getDefault(),
|
||||||
"%d/%d (%d)",
|
"%d/%d (%d)",
|
||||||
characterState.charactersRemaining,
|
characterState.charactersRemaining,
|
||||||
characterState.maxTotalMessageSize,
|
characterState.maxTotalMessageSize,
|
||||||
@ -496,7 +472,7 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<Media> media) {
|
protected void onPostExecute(List<Media> media) {
|
||||||
controller.onSendClicked(media, composeText.getTextTrimmed(), sendButton.getSelectedTransport());
|
controller.onSendClicked(media, composeText.getTextTrimmed());
|
||||||
Util.cancelRunnableOnMain(progressTimer);
|
Util.cancelRunnableOnMain(progressTimer);
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
@ -568,7 +544,7 @@ public class MediaSendFragment extends Fragment implements ViewTreeObserver.OnGl
|
|||||||
|
|
||||||
public interface Controller {
|
public interface Controller {
|
||||||
void onAddMediaClicked(@NonNull String bucketId);
|
void onAddMediaClicked(@NonNull String bucketId);
|
||||||
void onSendClicked(@NonNull List<Media> media, @NonNull String body, @NonNull TransportOption transport);
|
void onSendClicked(@NonNull List<Media> media, @NonNull String body);
|
||||||
void onNoMediaAvailable();
|
void onNoMediaAvailable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import android.text.TextUtils;
|
|||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TransportOption;
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||||
@ -34,8 +33,7 @@ class MediaSendViewModel extends ViewModel {
|
|||||||
|
|
||||||
private static final String TAG = MediaSendViewModel.class.getSimpleName();
|
private static final String TAG = MediaSendViewModel.class.getSimpleName();
|
||||||
|
|
||||||
private static final int MAX_PUSH = 32;
|
private static final int MAX_SELECTION = 32;
|
||||||
private static final int MAX_SMS = 1;
|
|
||||||
|
|
||||||
private final Application application;
|
private final Application application;
|
||||||
private final MediaRepository repository;
|
private final MediaRepository repository;
|
||||||
@ -49,12 +47,12 @@ class MediaSendViewModel extends ViewModel {
|
|||||||
private final SingleLiveEvent<Error> error;
|
private final SingleLiveEvent<Error> error;
|
||||||
private final Map<Uri, Object> savedDrawState;
|
private final Map<Uri, Object> savedDrawState;
|
||||||
|
|
||||||
private MediaConstraints mediaConstraints;
|
private final MediaConstraints mediaConstraints = MediaConstraints.getPushMediaConstraints();
|
||||||
|
|
||||||
private CharSequence body;
|
private CharSequence body;
|
||||||
private CountButtonState.Visibility countButtonVisibility;
|
private CountButtonState.Visibility countButtonVisibility;
|
||||||
private boolean sentMedia;
|
private boolean sentMedia;
|
||||||
private Optional<Media> lastImageCapture;
|
private Optional<Media> lastImageCapture;
|
||||||
private int maxSelection;
|
|
||||||
|
|
||||||
private MediaSendViewModel(@NonNull Application application, @NonNull MediaRepository repository) {
|
private MediaSendViewModel(@NonNull Application application, @NonNull MediaRepository repository) {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
@ -77,16 +75,6 @@ class MediaSendViewModel extends ViewModel {
|
|||||||
cameraButtonVisibility.setValue(false);
|
cameraButtonVisibility.setValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTransport(@NonNull TransportOption transport) {
|
|
||||||
if (transport.isSms()) {
|
|
||||||
maxSelection = MAX_SMS;
|
|
||||||
mediaConstraints = MediaConstraints.getMmsMediaConstraints(transport.getSimSubscriptionId().or(-1));
|
|
||||||
} else {
|
|
||||||
maxSelection = MAX_PUSH;
|
|
||||||
mediaConstraints = MediaConstraints.getPushMediaConstraints();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void onSelectedMediaChanged(@NonNull Context context, @NonNull List<Media> newMedia) {
|
void onSelectedMediaChanged(@NonNull Context context, @NonNull List<Media> newMedia) {
|
||||||
repository.getPopulatedMedia(context, newMedia, populatedMedia -> {
|
repository.getPopulatedMedia(context, newMedia, populatedMedia -> {
|
||||||
Util.runOnMain(() -> {
|
Util.runOnMain(() -> {
|
||||||
@ -95,8 +83,8 @@ class MediaSendViewModel extends ViewModel {
|
|||||||
|
|
||||||
if (filteredMedia.size() != newMedia.size()) {
|
if (filteredMedia.size() != newMedia.size()) {
|
||||||
error.setValue(Error.ITEM_TOO_LARGE);
|
error.setValue(Error.ITEM_TOO_LARGE);
|
||||||
} else if (filteredMedia.size() > maxSelection) {
|
} else if (filteredMedia.size() > MAX_SELECTION) {
|
||||||
filteredMedia = filteredMedia.subList(0, maxSelection);
|
filteredMedia = filteredMedia.subList(0, MAX_SELECTION);
|
||||||
error.setValue(Error.TOO_MANY_ITEMS);
|
error.setValue(Error.TOO_MANY_ITEMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +199,7 @@ class MediaSendViewModel extends ViewModel {
|
|||||||
selected = new LinkedList<>();
|
selected = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected.size() >= maxSelection) {
|
if (selected.size() >= MAX_SELECTION) {
|
||||||
error.setValue(Error.TOO_MANY_ITEMS);
|
error.setValue(Error.TOO_MANY_ITEMS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -302,7 +290,7 @@ class MediaSendViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getMaxSelection() {
|
int getMaxSelection() {
|
||||||
return maxSelection;
|
return MAX_SELECTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NonNull List<Media> getSelectedMediaOrDefault() {
|
private @NonNull List<Media> getSelectedMediaOrDefault() {
|
||||||
|
@ -39,7 +39,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
||||||
import org.thoughtcrime.securesms.TransportOption;
|
|
||||||
import org.thoughtcrime.securesms.attachments.Attachment;
|
import org.thoughtcrime.securesms.attachments.Attachment;
|
||||||
import org.thoughtcrime.securesms.loki.views.MessageAudioView;
|
import org.thoughtcrime.securesms.loki.views.MessageAudioView;
|
||||||
import org.thoughtcrime.securesms.components.DocumentView;
|
import org.thoughtcrime.securesms.components.DocumentView;
|
||||||
@ -375,11 +374,11 @@ public class AttachmentManager {
|
|||||||
selectMediaType(activity, "*/*", null, requestCode);
|
selectMediaType(activity, "*/*", null, requestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void selectGallery(Activity activity, int requestCode, @NonNull Recipient recipient, @NonNull String body, @NonNull TransportOption transport) {
|
public static void selectGallery(Activity activity, int requestCode, @NonNull Recipient recipient, @NonNull String body) {
|
||||||
Permissions.with(activity)
|
Permissions.with(activity)
|
||||||
.request(Manifest.permission.READ_EXTERNAL_STORAGE)
|
.request(Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||||
.withPermanentDenialDialog(activity.getString(R.string.AttachmentManager_signal_requires_the_external_storage_permission_in_order_to_attach_photos_videos_or_audio))
|
.withPermanentDenialDialog(activity.getString(R.string.AttachmentManager_signal_requires_the_external_storage_permission_in_order_to_attach_photos_videos_or_audio))
|
||||||
.onAllGranted(() -> activity.startActivityForResult(MediaSendActivity.buildGalleryIntent(activity, recipient, body, transport), requestCode))
|
.onAllGranted(() -> activity.startActivityForResult(MediaSendActivity.buildGalleryIntent(activity, recipient, body), requestCode))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,9 +413,9 @@ public class AttachmentManager {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void selectGif(Activity activity, int requestCode, boolean isForMms) {
|
public static void selectGif(Activity activity, int requestCode) {
|
||||||
Intent intent = new Intent(activity, GiphyActivity.class);
|
Intent intent = new Intent(activity, GiphyActivity.class);
|
||||||
intent.putExtra(GiphyActivity.EXTRA_IS_MMS, isForMms);
|
intent.putExtra(GiphyActivity.EXTRA_IS_MMS, false);
|
||||||
activity.startActivityForResult(intent, requestCode);
|
activity.startActivityForResult(intent, requestCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@
|
|||||||
android:contentDescription="@string/ConversationActivity_add_attachment"
|
android:contentDescription="@string/ConversationActivity_add_attachment"
|
||||||
android:nextFocusLeft="@+id/embedded_text_editor" />
|
android:nextFocusLeft="@+id/embedded_text_editor" />
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.SendButton
|
<ImageButton
|
||||||
android:id="@+id/send_button"
|
android:id="@+id/send_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
@ -201,7 +201,7 @@
|
|||||||
android:contentDescription="@string/conversation_activity__send"
|
android:contentDescription="@string/conversation_activity__send"
|
||||||
android:nextFocusLeft="@+id/embedded_text_editor"
|
android:nextFocusLeft="@+id/embedded_text_editor"
|
||||||
android:src="?conversation_transport_sms_indicator"
|
android:src="?conversation_transport_sms_indicator"
|
||||||
android:background="@drawable/circle_touch_highlight_background" />
|
android:background="@drawable/circle_touch_highlight_background"/>
|
||||||
|
|
||||||
</org.thoughtcrime.securesms.components.AnimatingToggle>
|
</org.thoughtcrime.securesms.components.AnimatingToggle>
|
||||||
|
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:background="#FF2090ea">
|
|
||||||
|
|
||||||
<TextView android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
|
||||||
android:id="@+id/blurb"
|
|
||||||
android:textSize="@dimen/onboarding_title_size"
|
|
||||||
android:textIsSelectable="false"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:paddingStart="20dp"
|
|
||||||
android:paddingEnd="20dp"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:text="@string/experience_upgrade_preference_fragment__read_receipts_are_here"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:textColor="@android:color/white" />
|
|
||||||
|
|
||||||
<FrameLayout android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:layout_marginBottom="20dp"
|
|
||||||
android:layout_marginTop="20dp">
|
|
||||||
|
|
||||||
<ImageView android:layout_width="170dp"
|
|
||||||
android:layout_height="170dp"
|
|
||||||
android:src="@drawable/circle_tintable"
|
|
||||||
android:scaleType="fitCenter"/>
|
|
||||||
|
|
||||||
<ImageView android:layout_width="100dp"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
app:srcCompat="@drawable/read_receipt_vector"/>
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<TextView android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/subblurb"
|
|
||||||
android:textSize="@dimen/onboarding_subtitle_size"
|
|
||||||
android:textIsSelectable="false"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:paddingStart="20dp"
|
|
||||||
android:paddingEnd="20dp"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:text="@string/experience_upgrade_preference_fragment__optionally_see_and_share_when_messages_have_been_read"
|
|
||||||
android:textColor="@android:color/white" />
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
|
||||||
android:id="@+id/preference"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
android:enabled="true"
|
|
||||||
android:checked="true"
|
|
||||||
android:text="@string/experience_upgrade_preference_fragment__enable_read_receipts"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
app:theme="@style/Color1SwitchStyle"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -114,18 +114,16 @@
|
|||||||
android:layout_width="@dimen/conversation_compose_height"
|
android:layout_width="@dimen/conversation_compose_height"
|
||||||
android:layout_height="@dimen/conversation_compose_height"
|
android:layout_height="@dimen/conversation_compose_height"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom">
|
||||||
android:background="@drawable/circle_tintable"
|
|
||||||
tools:backgroundTint="@color/core_blue">
|
|
||||||
|
|
||||||
<org.thoughtcrime.securesms.components.SendButton
|
<ImageButton
|
||||||
android:id="@+id/mediasend_send_button"
|
android:id="@+id/mediasend_send_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="fitXY"
|
android:scaleType="fitXY"
|
||||||
android:contentDescription="@string/conversation_activity__send"
|
android:contentDescription="@string/conversation_activity__send"
|
||||||
android:src="?conversation_transport_sms_indicator"
|
android:src="?conversation_transport_sms_indicator"
|
||||||
android:background="@drawable/circle_touch_highlight_background" />
|
android:background="@drawable/circle_touch_highlight_background"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="@dimen/transport_selection_popup_width"
|
|
||||||
android:layout_height="60dp"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingStart="10dp"
|
|
||||||
android:paddingEnd="10dp">
|
|
||||||
|
|
||||||
<ImageView android:id="@+id/icon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="7dp"
|
|
||||||
android:background="@drawable/circle_tintable"
|
|
||||||
android:contentDescription="@string/transport_selection_list_item__transport_icon"
|
|
||||||
tools:src="@drawable/ic_send_push_white_24dp"
|
|
||||||
tools:backgroundTint="@color/textsecure_primary" />
|
|
||||||
|
|
||||||
<LinearLayout android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingStart="10dp">
|
|
||||||
|
|
||||||
<TextView android:id="@+id/text"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
tools:text="TextSecure" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/subtext"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:textSize="12dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:text="From Home"
|
|
||||||
tools:visibility="visible"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
Loading…
Reference in New Issue
Block a user