diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java index 6a23b2cf8..b4109bfdb 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/AccountAdapter.java @@ -96,7 +96,8 @@ public class AccountAdapter extends ArrayAdapter { } }); - if (this.showColorSelector && activity.xmppConnectionService.getAccounts().size() > 1) { + if (this.showColorSelector && activity.xmppConnectionService.getAccounts().size() > 1 && + activity.xmppConnectionService.getPreferences().getBoolean("show_account_indicator", activity.getResources().getBoolean(R.bool.show_account_indicator))) { int color = UIHelper.getAccountColor(activity, account.getJid()); viewHolder.binding.colorView.setVisibility(View.VISIBLE); ColorUtils.setColorViewValue(viewHolder.binding.colorView, color, false, ColorShape.CIRCLE); diff --git a/src/main/java/eu/siacs/conversations/ui/widget/AccountIndicator.kt b/src/main/java/eu/siacs/conversations/ui/widget/AccountIndicator.kt new file mode 100644 index 000000000..f7343aeca --- /dev/null +++ b/src/main/java/eu/siacs/conversations/ui/widget/AccountIndicator.kt @@ -0,0 +1,37 @@ +package eu.siacs.conversations.ui.widget + +import android.content.Context +import android.util.AttributeSet +import android.view.View +import eu.siacs.conversations.R +import eu.siacs.conversations.ui.XmppActivity + +class AccountIndicator : View { + constructor(context: Context?) : super(context) + constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) + constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) + + constructor( + context: Context?, + attrs: AttributeSet?, + defStyleAttr: Int, + defStyleRes: Int + ) : super(context, attrs, defStyleAttr, defStyleRes) + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + val enabled = (context as? XmppActivity) + ?.xmppConnectionService?.preferences + ?.getBoolean("show_account_indicator", context.resources.getBoolean(R.bool.show_account_indicator)) ?: false + + visibility = if (enabled) { + VISIBLE + } else { + INVISIBLE + } + } +} \ No newline at end of file diff --git a/src/main/java/eu/siacs/conversations/ui/widget/PresenceIndicator.kt b/src/main/java/eu/siacs/conversations/ui/widget/PresenceIndicator.kt index f4ecaf21e..12b12f60b 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/PresenceIndicator.kt +++ b/src/main/java/eu/siacs/conversations/ui/widget/PresenceIndicator.kt @@ -8,8 +8,10 @@ import android.graphics.Paint import android.util.AttributeSet import android.view.View import android.view.ViewOutlineProvider +import eu.siacs.conversations.R import eu.siacs.conversations.entities.Contact import eu.siacs.conversations.entities.Presence +import eu.siacs.conversations.ui.XmppActivity import eu.siacs.conversations.ui.util.StyledAttributes import eu.siacs.conversations.utils.UIHelper import eu.siacs.conversations.xml.Namespace @@ -23,6 +25,8 @@ class PresenceIndicator : View { private var status: Presence.Status? = null + private var enabled = false + constructor(context: Context?) : super(context) constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super( @@ -55,7 +59,18 @@ class PresenceIndicator : View { } } + override fun onAttachedToWindow() { + super.onAttachedToWindow() + enabled = (context as? XmppActivity) + ?.xmppConnectionService?.preferences + ?.getBoolean("show_contact_status", context.resources.getBoolean(R.bool.show_contact_status)) ?: false + } + override fun onDraw(canvas: Canvas) { + if (!enabled) { + return + } + super.onDraw(canvas) val color: Int? = UIHelper.getColorForStatus(status); diff --git a/src/main/res/layout/contact.xml b/src/main/res/layout/contact.xml index db9374f1c..923a80368 100644 --- a/src/main/res/layout/contact.xml +++ b/src/main/res/layout/contact.xml @@ -9,7 +9,7 @@ android:clipToPadding="false" android:padding="@dimen/list_padding"> - - false false rounded_square + true + true diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 92ce2eac0..d56415813 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -612,6 +612,10 @@ Don’t open image editor screen automatically for single image attachments Could not connect to OpenKeychain This device is no longer in use + Contact presence + Show contact presence nearby contact avatar + Account indicator + Mark conversations with different colors in case of several account Computer Mobile phone Tablet diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 7cbd5fedf..602b57d59 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -64,6 +64,16 @@ android:key="always_full_timestamps" android:summary="@string/pref_always_show_full_timestamps_summary" android:title="@string/pref_always_show_full_timestamps" /> + +