diff --git a/build.gradle b/build.gradle
index 7a0766773..a0d9d1c8b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -64,7 +64,6 @@ dependencies {
implementation 'de.measite.minidns:minidns-hla:0.2.4'
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
implementation 'org.whispersystems:signal-protocol-java:2.6.2'
- implementation 'com.makeramen:roundedimageview:2.3.0'
implementation "com.wefika:flowlayout:0.4.1"
//noinspection GradleDependency
implementation('com.github.natario1:Transcoder:v0.9.1') {
diff --git a/src/main/java/eu/siacs/conversations/ui/widget/AvatarView.kt b/src/main/java/eu/siacs/conversations/ui/widget/AvatarView.kt
new file mode 100644
index 000000000..c51a1e977
--- /dev/null
+++ b/src/main/java/eu/siacs/conversations/ui/widget/AvatarView.kt
@@ -0,0 +1,71 @@
+package eu.siacs.conversations.ui.widget
+
+import android.content.Context
+import android.content.SharedPreferences
+import android.graphics.Outline
+import android.preference.PreferenceManager
+import android.util.AttributeSet
+import android.view.View
+import android.view.ViewOutlineProvider
+import androidx.appcompat.widget.AppCompatImageView
+import eu.siacs.conversations.R
+
+class AvatarView : AppCompatImageView {
+ private var currentShape: String = ""
+
+ private val preferencesListener = SharedPreferences.OnSharedPreferenceChangeListener { _, _ -> invalidateShape() }
+
+ constructor(context: Context) : super(context)
+ constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
+ constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
+ context,
+ attrs,
+ defStyleAttr
+ )
+
+ override fun onAttachedToWindow() {
+ super.onAttachedToWindow()
+ invalidateShape()
+ PreferenceManager.getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(preferencesListener)
+ }
+
+ override fun onDetachedFromWindow() {
+ super.onDetachedFromWindow()
+ PreferenceManager.getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(preferencesListener)
+ }
+
+ private fun invalidateShape() {
+ val shape = PreferenceManager.getDefaultSharedPreferences(context).getString("avatar_shape", context.getString(R.string.avatar_shape))
+
+ if (shape == currentShape) {
+ return
+ }
+
+ when {
+ shape == "oval" -> {
+ clipToOutline = true
+ outlineProvider = object : ViewOutlineProvider() {
+ override fun getOutline(view: View, outline: Outline) {
+ outline.setOval(0, 0, view.width, view.height)
+ }
+ }
+ }
+ shape == "rounded_square" -> {
+ clipToOutline = true
+ outlineProvider = object : ViewOutlineProvider() {
+ override fun getOutline(view: View, outline: Outline) {
+ val maxRadius = minOf(view.width, view.height) / 2f
+ val radius = minOf(context.resources.getDimension(R.dimen.avatar_corners_radius), maxRadius)
+ outline.setRoundRect(0, 0, view.width, view.height, radius)
+ }
+ }
+ }
+ shape == "square" -> {
+ clipToOutline = false
+ outlineProvider = ViewOutlineProvider.BACKGROUND
+ }
+ }
+
+ currentShape = shape!!
+ }
+}
\ No newline at end of file
diff --git a/src/main/res/layout/account_row.xml b/src/main/res/layout/account_row.xml
index 92cb0801d..dfe0e1d22 100644
--- a/src/main/res/layout/account_row.xml
+++ b/src/main/res/layout/account_row.xml
@@ -10,13 +10,12 @@
android:paddingBottom="8dp"
android:paddingTop="8dp">
-
+ android:contentDescription="@string/account_image_description" />
-
-
+ android:contentDescription="@string/account_image_description" />
-
-
diff --git a/src/main/res/layout/contact.xml b/src/main/res/layout/contact.xml
index d8fb128a7..f1d9496c7 100644
--- a/src/main/res/layout/contact.xml
+++ b/src/main/res/layout/contact.xml
@@ -8,13 +8,12 @@
android:background="?selectableItemBackground"
android:padding="@dimen/list_padding">
-
+ android:scaleType="centerCrop"/>
-
+ android:scaleType="centerCrop" />
-
+ android:scaleType="fitXY" />
-
+ android:scaleType="fitXY" />
-
+ android:scaleType="fitXY" />
-
+ android:scaleType="centerCrop" />
-
diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml
index 3ddf86d9c..6a5636b01 100644
--- a/src/main/res/values/arrays.xml
+++ b/src/main/res/values/arrays.xml
@@ -89,6 +89,18 @@
- SEND_LOCATION
+
+ - @string/avater_shape_rounded_square
+ - @string/avater_shape_oval
+ - @string/avater_shape_square
+
+
+
+ - rounded_square
+ - oval
+ - square
+
+
- never
- auto
diff --git a/src/main/res/values/defaults.xml b/src/main/res/values/defaults.xml
index e1a5e3b14..bbd3581ca 100644
--- a/src/main/res/values/defaults.xml
+++ b/src/main/res/values/defaults.xml
@@ -54,4 +54,5 @@
none
false
false
+ rounded_square
diff --git a/src/main/res/values/dimens.xml b/src/main/res/values/dimens.xml
index f1e1b4ede..a6544901a 100644
--- a/src/main/res/values/dimens.xml
+++ b/src/main/res/values/dimens.xml
@@ -78,4 +78,6 @@
16dp
30dp
+
+ 8dp
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 3ad0b48a6..022ee687f 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -599,6 +599,8 @@
Dark
Show navigation bar
Use alternative navigation way via navigation bar on the bottom of the screen
+ Avatars shape
+ Allows you to select avatars shape globally
Green Background
Use green background for received messages
Show full timestamps
@@ -1099,4 +1101,7 @@
Couldn\'t remove background image
Background image removed
No custom background set
+ Oval
+ Rounded Square
+ Square
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 583651446..b881c5e80 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -183,6 +183,13 @@
android:key="show_nav_bar"
android:summary="@string/pref_show_navigation_bar_summary"
android:title="@string/pref_show_navigation_bar" />
+