mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 17:58:34 +00:00
Avoid crash with Address parcelable.
There seems to be a bad implementation of Address parcelization that pops up in certain scenarios. We can avoid it by just excluding it from the parcel altogether.
This commit is contained in:
parent
31435128f4
commit
a5eb823a17
@ -1,6 +1,5 @@
|
|||||||
package org.thoughtcrime.securesms.components.location;
|
package org.thoughtcrime.securesms.components.location;
|
||||||
|
|
||||||
import android.location.Address;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@ -35,10 +34,8 @@ public class SignalPlace {
|
|||||||
private double longitude;
|
private double longitude;
|
||||||
|
|
||||||
public SignalPlace(@NonNull AddressData place) {
|
public SignalPlace(@NonNull AddressData place) {
|
||||||
Address address = place.getAddress();
|
|
||||||
|
|
||||||
this.name = "";
|
this.name = "";
|
||||||
this.address = address!= null ? address.getAddressLine(0) : "";
|
this.address = place.getAddress();
|
||||||
this.latitude = place.getLatitude();
|
this.latitude = place.getLatitude();
|
||||||
this.longitude = place.getLongitude();
|
this.longitude = place.getLongitude();
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package org.thoughtcrime.securesms.maps;
|
package org.thoughtcrime.securesms.maps;
|
||||||
|
|
||||||
import android.location.Address;
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
public final class AddressData implements Parcelable {
|
public final class AddressData implements Parcelable {
|
||||||
|
|
||||||
private final double latitude;
|
private final double latitude;
|
||||||
private final double longitude;
|
private final double longitude;
|
||||||
private final @Nullable Address address;
|
private final String address;
|
||||||
|
|
||||||
AddressData(double latitude, double longitude, @Nullable Address address) {
|
AddressData(double latitude, double longitude, @NonNull String address) {
|
||||||
this.latitude = latitude;
|
this.latitude = latitude;
|
||||||
this.longitude = longitude;
|
this.longitude = longitude;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable Address getAddress() {
|
public @NonNull String getAddress() {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,9 +32,10 @@ public final class AddressData implements Parcelable {
|
|||||||
public static final Creator<AddressData> CREATOR = new Creator<AddressData>() {
|
public static final Creator<AddressData> CREATOR = new Creator<AddressData>() {
|
||||||
@Override
|
@Override
|
||||||
public AddressData createFromParcel(Parcel in) {
|
public AddressData createFromParcel(Parcel in) {
|
||||||
|
//noinspection ConstantConditions
|
||||||
return new AddressData(in.readDouble(),
|
return new AddressData(in.readDouble(),
|
||||||
in.readDouble(),
|
in.readDouble(),
|
||||||
Address.CREATOR.createFromParcel(in));
|
in.readString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,7 +48,7 @@ public final class AddressData implements Parcelable {
|
|||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
dest.writeDouble(latitude);
|
dest.writeDouble(latitude);
|
||||||
dest.writeDouble(longitude);
|
dest.writeDouble(longitude);
|
||||||
dest.writeParcelable(address, flags);
|
dest.writeString(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -156,8 +156,10 @@ public final class PlacePickerActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void finishWithAddress() {
|
private void finishWithAddress() {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
AddressData addressData = new AddressData(currentLocation.latitude, currentLocation.longitude, currentAddress);
|
String address = currentAddress != null && currentAddress.getAddressLine(0) != null ? currentAddress.getAddressLine(0) : "";
|
||||||
|
AddressData addressData = new AddressData(currentLocation.latitude, currentLocation.longitude, address);
|
||||||
|
|
||||||
returnIntent.putExtra(ADDRESS_INTENT, addressData);
|
returnIntent.putExtra(ADDRESS_INTENT, addressData);
|
||||||
setResult(RESULT_OK, returnIntent);
|
setResult(RESULT_OK, returnIntent);
|
||||||
finish();
|
finish();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user