clean up location
parent
8c016b3802
commit
0ec940ea32
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue