mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Display contact color in background for generated avatars
Fixes #7028 // FREEBIE
This commit is contained in:
parent
42f613e722
commit
ac282ccf70
@ -1,5 +1,5 @@
|
||||
<vector android:height="480dp"
|
||||
android:width="480dp"
|
||||
<vector android:height="260dp"
|
||||
android:width="260dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
@ -1,4 +1,4 @@
|
||||
<vector android:height="480dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="480dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<vector android:height="260dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="260dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@color/gray20" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
|
||||
</vector>
|
||||
|
@ -25,7 +25,6 @@
|
||||
<ImageView android:id="@+id/avatar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
android:transitionName="avatar"
|
||||
app:layout_collapseMode="parallax"
|
||||
app:layout_collapseParallaxMultiplier="0.7"/>
|
||||
|
@ -36,6 +36,7 @@ import android.widget.TextView;
|
||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||
import org.thoughtcrime.securesms.color.MaterialColors;
|
||||
import org.thoughtcrime.securesms.components.ThreadPhotoRailView;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyParcelable;
|
||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
@ -203,7 +204,13 @@ public class RecipientPreferenceActivity extends PassphraseRequiredActionBarActi
|
||||
}
|
||||
|
||||
private void setHeader(@NonNull Recipient recipient) {
|
||||
this.avatar.setImageDrawable(recipient.getContactPhoto().asCallCard(this));
|
||||
ContactPhoto contactPhoto = recipient.getContactPhoto();
|
||||
|
||||
if (contactPhoto.isGenerated() || contactPhoto.isResource()) this.avatar.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
else this.avatar.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
|
||||
this.avatar.setImageDrawable(contactPhoto.asCallCard(this));
|
||||
this.avatar.setBackgroundColor(recipient.getColor().toActionBarColor(this));
|
||||
this.toolbarLayout.setTitle(recipient.toShortString());
|
||||
this.toolbarLayout.setContentScrimColor(recipient.getColor().toActionBarColor(this));
|
||||
}
|
||||
|
@ -37,4 +37,9 @@ public class BitmapContactPhoto implements ContactPhoto {
|
||||
public boolean isGenerated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ public interface ContactPhoto {
|
||||
public Drawable asDrawable(Context context, int color, boolean inverted);
|
||||
public Drawable asCallCard(Context context);
|
||||
public boolean isGenerated();
|
||||
public boolean isResource();
|
||||
|
||||
}
|
||||
|
@ -55,4 +55,9 @@ public class GeneratedContactPhoto implements ContactPhoto {
|
||||
public boolean isGenerated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,11 @@ public class ResourceContactPhoto implements ContactPhoto {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class ExpandingLayerDrawable extends LayerDrawable {
|
||||
public ExpandingLayerDrawable(Drawable[] layers) {
|
||||
super(layers);
|
||||
|
@ -31,4 +31,9 @@ public class TransparentContactPhoto implements ContactPhoto {
|
||||
public boolean isGenerated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isResource() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user