mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
clean up location
This commit is contained in:
parent
8c016b3802
commit
0ec940ea32
@ -1,7 +1,6 @@
|
||||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
@ -104,23 +103,10 @@ public class ComposeText extends EmojiEditText {
|
||||
}
|
||||
}
|
||||
|
||||
public void appendInvite(String invite) {
|
||||
if (!TextUtils.isEmpty(getText()) && !getText().toString().equals(" ")) {
|
||||
append(" ");
|
||||
}
|
||||
|
||||
append(invite);
|
||||
setSelection(getText().length());
|
||||
}
|
||||
|
||||
public void setCursorPositionChangedListener(@Nullable CursorPositionChangedListener listener) {
|
||||
this.cursorPositionChangedListener = listener;
|
||||
}
|
||||
|
||||
private boolean isLandscape() {
|
||||
return getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||
}
|
||||
|
||||
public void setTransport() {
|
||||
final boolean useSystemEmoji = TextSecurePreferences.isSystemEmojiPreferred(getContext());
|
||||
final boolean isIncognito = TextSecurePreferences.isIncognitoKeyboardEnabled(getContext());
|
||||
@ -140,12 +126,6 @@ public class ComposeText extends EmojiEditText {
|
||||
} else {
|
||||
setImeOptions(imeOptions);
|
||||
}
|
||||
/*
|
||||
setHint(transport.getComposeHint(),
|
||||
transport.getSimName().isPresent()
|
||||
? getContext().getString(R.string.conversation_activity__from_sim_name, transport.getSimName().get())
|
||||
: null);
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,59 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.location;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
public class SignalMapView extends LinearLayout {
|
||||
|
||||
private ImageView imageView;
|
||||
private TextView textView;
|
||||
|
||||
public SignalMapView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public SignalMapView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize(context);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
public SignalMapView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initialize(context);
|
||||
}
|
||||
|
||||
private void initialize(Context context) {
|
||||
setOrientation(LinearLayout.VERTICAL);
|
||||
LayoutInflater.from(context).inflate(R.layout.signal_map_view, this, true);
|
||||
|
||||
this.imageView = ViewUtil.findById(this, R.id.image_view);
|
||||
this.textView = ViewUtil.findById(this, R.id.address_view);
|
||||
}
|
||||
|
||||
public ListenableFuture<Bitmap> display(final SignalPlace place) {
|
||||
final SettableFuture<Bitmap> future = new SettableFuture<>();
|
||||
|
||||
this.imageView.setVisibility(View.GONE);
|
||||
|
||||
this.textView.setText(place.getDescription());
|
||||
|
||||
return future;
|
||||
}
|
||||
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
package org.thoughtcrime.securesms.components.location;
|
||||
|
||||
import android.net.Uri;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
|
||||
import org.session.libsignal.utilities.JsonUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class SignalPlace {
|
||||
|
||||
/* Loki - Temporary Placeholders */
|
||||
class LatLng {
|
||||
double latitude;
|
||||
double longitude;
|
||||
LatLng(double latitude, double longitude) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
}
|
||||
|
||||
class Place {
|
||||
public CharSequence getName() { return ""; }
|
||||
public CharSequence getAddress() { return ""; }
|
||||
LatLng getLatLng() { return new LatLng(0, 0); }
|
||||
}
|
||||
|
||||
private static final String URL = "https://maps.google.com/maps";
|
||||
private static final String TAG = SignalPlace.class.getSimpleName();
|
||||
|
||||
@JsonProperty
|
||||
private CharSequence name;
|
||||
|
||||
@JsonProperty
|
||||
private CharSequence address;
|
||||
|
||||
@JsonProperty
|
||||
private double latitude;
|
||||
|
||||
@JsonProperty
|
||||
private double longitude;
|
||||
|
||||
public SignalPlace(Place place) {
|
||||
this.name = place.getName();
|
||||
this.address = place.getAddress();
|
||||
this.latitude = place.getLatLng().latitude;
|
||||
this.longitude = place.getLatLng().longitude;
|
||||
}
|
||||
|
||||
public SignalPlace() {}
|
||||
|
||||
@JsonIgnore
|
||||
public LatLng getLatLong() {
|
||||
return new LatLng(latitude, longitude);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getDescription() {
|
||||
String description = "";
|
||||
|
||||
if (!TextUtils.isEmpty(name)) {
|
||||
description += (name + "\n");
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(address)) {
|
||||
description += (address + "\n");
|
||||
}
|
||||
|
||||
description += Uri.parse(URL)
|
||||
.buildUpon()
|
||||
.appendQueryParameter("q", String.format("%s,%s", latitude, longitude))
|
||||
.build().toString();
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
public @Nullable String serialize() {
|
||||
try {
|
||||
return JsonUtil.toJsonThrows(this);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static SignalPlace deserialize(@NonNull String serialized) throws IOException {
|
||||
return JsonUtil.fromJson(serialized, SignalPlace.class);
|
||||
}
|
||||
}
|
@ -110,11 +110,9 @@ import org.thoughtcrime.securesms.components.HidingLinearLayout;
|
||||
import org.thoughtcrime.securesms.components.InputAwareLayout;
|
||||
import org.thoughtcrime.securesms.components.InputPanel;
|
||||
import org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout.OnKeyboardShownListener;
|
||||
import org.thoughtcrime.securesms.components.TooltipPopup;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider;
|
||||
import org.thoughtcrime.securesms.components.emoji.EmojiStrings;
|
||||
import org.thoughtcrime.securesms.components.emoji.MediaKeyboard;
|
||||
import org.thoughtcrime.securesms.components.location.SignalPlace;
|
||||
import org.thoughtcrime.securesms.contacts.ContactAccessor;
|
||||
import org.thoughtcrime.securesms.contacts.ContactAccessor.ContactData;
|
||||
import org.thoughtcrime.securesms.contactshare.ContactUtil;
|
||||
@ -158,7 +156,6 @@ import org.thoughtcrime.securesms.mms.GifSlide;
|
||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.mms.ImageSlide;
|
||||
import org.thoughtcrime.securesms.mms.LocationSlide;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingExpirationUpdateMessage;
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
|
||||
@ -1277,32 +1274,25 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
};
|
||||
|
||||
for (Draft draft : drafts) {
|
||||
try {
|
||||
switch (draft.getType()) {
|
||||
case Draft.TEXT:
|
||||
composeText.setText(draft.getValue());
|
||||
listener.onSuccess(true);
|
||||
break;
|
||||
case Draft.LOCATION:
|
||||
attachmentManager.setLocation(SignalPlace.deserialize(draft.getValue()), MediaConstraints.getPushMediaConstraints()).addListener(listener);
|
||||
break;
|
||||
case Draft.IMAGE:
|
||||
setMedia(Uri.parse(draft.getValue()), MediaType.IMAGE).addListener(listener);
|
||||
break;
|
||||
case Draft.AUDIO:
|
||||
setMedia(Uri.parse(draft.getValue()), MediaType.AUDIO).addListener(listener);
|
||||
break;
|
||||
case Draft.VIDEO:
|
||||
setMedia(Uri.parse(draft.getValue()), MediaType.VIDEO).addListener(listener);
|
||||
break;
|
||||
case Draft.QUOTE:
|
||||
SettableFuture<Boolean> quoteResult = new SettableFuture<>();
|
||||
new QuoteRestorationTask(draft.getValue(), quoteResult).execute();
|
||||
quoteResult.addListener(listener);
|
||||
break;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
switch (draft.getType()) {
|
||||
case Draft.TEXT:
|
||||
composeText.setText(draft.getValue());
|
||||
listener.onSuccess(true);
|
||||
break;
|
||||
case Draft.IMAGE:
|
||||
setMedia(Uri.parse(draft.getValue()), MediaType.IMAGE).addListener(listener);
|
||||
break;
|
||||
case Draft.AUDIO:
|
||||
setMedia(Uri.parse(draft.getValue()), MediaType.AUDIO).addListener(listener);
|
||||
break;
|
||||
case Draft.VIDEO:
|
||||
setMedia(Uri.parse(draft.getValue()), MediaType.VIDEO).addListener(listener);
|
||||
break;
|
||||
case Draft.QUOTE:
|
||||
SettableFuture<Boolean> quoteResult = new SettableFuture<>();
|
||||
new QuoteRestorationTask(draft.getValue(), quoteResult).execute();
|
||||
quoteResult.addListener(listener);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1659,7 +1649,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
for (Slide slide : attachmentManager.buildSlideDeck().getSlides()) {
|
||||
if (slide.hasAudio() && slide.getUri() != null) drafts.add(new Draft(Draft.AUDIO, slide.getUri().toString()));
|
||||
else if (slide.hasVideo() && slide.getUri() != null) drafts.add(new Draft(Draft.VIDEO, slide.getUri().toString()));
|
||||
else if (slide.hasLocation()) drafts.add(new Draft(Draft.LOCATION, ((LocationSlide)slide).getPlace().serialize()));
|
||||
else if (slide.hasImage() && slide.getUri() != null) drafts.add(new Draft(Draft.IMAGE, slide.getUri().toString()));
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ public class DraftDatabase extends Database {
|
||||
public static final String IMAGE = "image";
|
||||
public static final String VIDEO = "video";
|
||||
public static final String AUDIO = "audio";
|
||||
public static final String LOCATION = "location";
|
||||
public static final String QUOTE = "quote";
|
||||
|
||||
private final String type;
|
||||
@ -125,7 +124,6 @@ public class DraftDatabase extends Database {
|
||||
case IMAGE: return context.getString(R.string.DraftDatabase_Draft_image_snippet);
|
||||
case VIDEO: return context.getString(R.string.DraftDatabase_Draft_video_snippet);
|
||||
case AUDIO: return context.getString(R.string.DraftDatabase_Draft_audio_snippet);
|
||||
case LOCATION: return context.getString(R.string.DraftDatabase_Draft_location_snippet);
|
||||
case QUOTE: return context.getString(R.string.DraftDatabase_Draft_quote_snippet);
|
||||
default: return null;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
@ -38,15 +37,11 @@ import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
import org.session.libsession.utilities.MediaTypes;
|
||||
import org.thoughtcrime.securesms.MediaPreviewActivity;
|
||||
import org.thoughtcrime.securesms.loki.views.MessageAudioView;
|
||||
import org.thoughtcrime.securesms.components.DocumentView;
|
||||
import org.thoughtcrime.securesms.components.RemovableEditableMediaView;
|
||||
import org.thoughtcrime.securesms.components.ThumbnailView;
|
||||
import org.thoughtcrime.securesms.components.location.SignalMapView;
|
||||
import org.thoughtcrime.securesms.components.location.SignalPlace;
|
||||
import org.session.libsignal.utilities.externalstorage.NoExternalStorageException;
|
||||
import org.thoughtcrime.securesms.giph.ui.GiphyActivity;
|
||||
import org.session.libsignal.utilities.logging.Log;
|
||||
@ -54,7 +49,6 @@ import org.thoughtcrime.securesms.mediasend.MediaSendActivity;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.providers.BlobProvider;
|
||||
import org.thoughtcrime.securesms.providers.DeprecatedPersistentBlobProvider;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.session.libsignal.utilities.externalstorage.ExternalStorageUtil;
|
||||
import org.thoughtcrime.securesms.util.FileProviderUtil;
|
||||
import org.thoughtcrime.securesms.util.MediaUtil;
|
||||
@ -65,8 +59,6 @@ import org.session.libsession.messaging.threads.recipients.Recipient;
|
||||
import org.session.libsession.utilities.ThemeUtil;
|
||||
import org.session.libsession.utilities.ViewUtil;
|
||||
import org.session.libsession.utilities.views.Stub;
|
||||
import org.session.libsession.utilities.Util;
|
||||
import org.session.libsession.utilities.concurrent.AssertedSuccessListener;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture;
|
||||
import org.session.libsignal.utilities.concurrent.ListenableFuture.Listener;
|
||||
import org.session.libsignal.utilities.concurrent.SettableFuture;
|
||||
@ -95,7 +87,6 @@ public class AttachmentManager {
|
||||
private ThumbnailView thumbnail;
|
||||
private MessageAudioView audioView;
|
||||
private DocumentView documentView;
|
||||
private SignalMapView mapView;
|
||||
|
||||
private @NonNull List<Uri> garbage = new LinkedList<>();
|
||||
private @NonNull Optional<Slide> slide = Optional.absent();
|
||||
@ -114,7 +105,6 @@ public class AttachmentManager {
|
||||
this.thumbnail = ViewUtil.findById(root, R.id.attachment_thumbnail);
|
||||
this.audioView = ViewUtil.findById(root, R.id.attachment_audio);
|
||||
this.documentView = ViewUtil.findById(root, R.id.attachment_document);
|
||||
this.mapView = ViewUtil.findById(root, R.id.attachment_location);
|
||||
this.removableMediaView = ViewUtil.findById(root, R.id.removable_media_view);
|
||||
|
||||
removableMediaView.setRemoveClickListener(new RemoveButtonListener());
|
||||
@ -196,38 +186,6 @@ public class AttachmentManager {
|
||||
this.slide = Optional.of(slide);
|
||||
}
|
||||
|
||||
public ListenableFuture<Boolean> setLocation(@NonNull final SignalPlace place,
|
||||
@NonNull final MediaConstraints constraints)
|
||||
{
|
||||
inflateStub();
|
||||
|
||||
SettableFuture<Boolean> returnResult = new SettableFuture<>();
|
||||
ListenableFuture<Bitmap> future = mapView.display(place);
|
||||
|
||||
attachmentViewStub.get().setVisibility(View.VISIBLE);
|
||||
removableMediaView.display(mapView, false);
|
||||
|
||||
future.addListener(new AssertedSuccessListener<Bitmap>() {
|
||||
@Override
|
||||
public void onSuccess(@NonNull Bitmap result) {
|
||||
byte[] blob = BitmapUtil.toByteArray(result);
|
||||
Uri uri = BlobProvider.getInstance()
|
||||
.forData(blob)
|
||||
.withMimeType(MediaTypes.IMAGE_JPEG)
|
||||
.createForSingleSessionInMemory();
|
||||
LocationSlide locationSlide = new LocationSlide(context, uri, blob.length, place);
|
||||
|
||||
Util.runOnMain(() -> {
|
||||
setSlide(locationSlide);
|
||||
attachmentListener.onAttachmentChanged();
|
||||
returnResult.set(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return returnResult;
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public ListenableFuture<Boolean> setMedia(@NonNull final GlideRequests glideRequests,
|
||||
@NonNull final Uri uri,
|
||||
|
@ -1,37 +0,0 @@
|
||||
package org.thoughtcrime.securesms.mms;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.thoughtcrime.securesms.components.location.SignalPlace;
|
||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||
|
||||
public class LocationSlide extends ImageSlide {
|
||||
|
||||
@NonNull
|
||||
private final SignalPlace place;
|
||||
|
||||
public LocationSlide(@NonNull Context context, @NonNull Uri uri, long size, @NonNull SignalPlace place)
|
||||
{
|
||||
super(context, uri, size, 0, 0);
|
||||
this.place = place;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Optional<String> getBody() {
|
||||
return Optional.of(place.getDescription());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public SignalPlace getPlace() {
|
||||
return place;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLocation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -127,10 +127,6 @@ public abstract class Slide {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasLocation() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public @NonNull String getContentDescription() { return ""; }
|
||||
|
||||
public @NonNull Attachment asAttachment() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user