mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 12:38:33 +00:00
Handle missing profile photos better.
There were a couple funny behaviors you could run into if you had a contact that previously had a profile photo, but then removed it.
This commit is contained in:
parent
1df28c6564
commit
048d859881
@ -9,6 +9,7 @@ import androidx.annotation.Nullable;
|
|||||||
import org.thoughtcrime.securesms.database.Address;
|
import org.thoughtcrime.securesms.database.Address;
|
||||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
@ -30,7 +31,8 @@ public class ProfileContactPhoto implements ContactPhoto {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Uri getUri(@NonNull Context context) {
|
public @Nullable Uri getUri(@NonNull Context context) {
|
||||||
return Uri.fromFile(AvatarHelper.getAvatarFile(context, address));
|
File avatarFile = AvatarHelper.getAvatarFile(context, address);
|
||||||
|
return avatarFile.exists() ? Uri.fromFile(avatarFile) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,6 +13,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.annimon.stream.Stream;
|
import com.annimon.stream.Stream;
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
import org.thoughtcrime.securesms.contactshare.Contact.Phone;
|
import org.thoughtcrime.securesms.contactshare.Contact.Phone;
|
||||||
@ -103,7 +104,11 @@ class ContactFieldAdapter extends RecyclerView.Adapter<ContactFieldAdapter.Conta
|
|||||||
|
|
||||||
if (field.iconUri != null) {
|
if (field.iconUri != null) {
|
||||||
avatar.setVisibility(View.VISIBLE);
|
avatar.setVisibility(View.VISIBLE);
|
||||||
glideRequests.load(field.iconUri).circleCrop().into(avatar);
|
glideRequests.load(field.iconUri)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||||
|
.skipMemoryCache(true)
|
||||||
|
.circleCrop()
|
||||||
|
.into(avatar);
|
||||||
} else {
|
} else {
|
||||||
avatar.setVisibility(View.GONE);
|
avatar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.bumptech.glide.load.data.DataFetcher;
|
|||||||
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
@ -30,6 +31,8 @@ class ContactPhotoFetcher implements DataFetcher<InputStream> {
|
|||||||
try {
|
try {
|
||||||
inputStream = contactPhoto.openInputStream(context);
|
inputStream = contactPhoto.openInputStream(context);
|
||||||
callback.onDataReady(inputStream);
|
callback.onDataReady(inputStream);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
callback.onDataReady(null);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
callback.onLoadFailed(e);
|
callback.onLoadFailed(e);
|
||||||
}
|
}
|
||||||
|
@ -242,8 +242,6 @@ public class MediaUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasVideoThumbnail(Uri uri) {
|
public static boolean hasVideoThumbnail(Uri uri) {
|
||||||
Log.i(TAG, "Checking: " + uri);
|
|
||||||
|
|
||||||
if (uri == null || !ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
|
if (uri == null || !ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user