allow to disable presence and account indicators

This commit is contained in:
kosyak 2024-09-08 23:51:05 +02:00
parent c64e0925f4
commit c32809b963
8 changed files with 72 additions and 3 deletions

View file

@ -96,7 +96,8 @@ public class AccountAdapter extends ArrayAdapter<Account> {
}
});
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);

View file

@ -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
}
}
}

View file

@ -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);

View file

@ -9,7 +9,7 @@
android:clipToPadding="false"
android:padding="@dimen/list_padding">
<View
<eu.siacs.conversations.ui.widget.AccountIndicator
android:id="@+id/account_indicator"
android:layout_width="@dimen/account_indicator_width"
android:layout_marginStart="-4dp"

View file

@ -20,7 +20,7 @@
android:clipToPadding="false"
android:padding="8dp">
<View
<eu.siacs.conversations.ui.widget.AccountIndicator
android:id="@+id/account_indicator"
android:layout_width="@dimen/account_indicator_width"
android:layout_marginStart="-4dp"

View file

@ -55,4 +55,6 @@
<bool name="always_full_timestamps">false</bool>
<bool name="skip_image_editor_screen">false</bool>
<string name="avatar_shape">rounded_square</string>
<bool name="show_contact_status">true</bool>
<bool name="show_account_indicator">true</bool>
</resources>

View file

@ -612,6 +612,10 @@
<string name="pref_skip_image_editor_screen_summary">Dont open image editor screen automatically for single image attachments</string>
<string name="unable_to_connect_to_keychain">Could not connect to OpenKeychain</string>
<string name="this_device_is_no_longer_in_use">This device is no longer in use</string>
<string name="pref_show_contact_presence">Contact presence</string>
<string name="pref_show_contact_presence_details">Show contact presence nearby contact avatar</string>
<string name="pref_show_account_indicator">Account indicator</string>
<string name="pref_show_account_indicator_details">Mark conversations with different colors in case of several account</string>
<string name="type_pc">Computer</string>
<string name="type_phone">Mobile phone</string>
<string name="type_tablet">Tablet</string>

View file

@ -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" />
<CheckBoxPreference
android:defaultValue="@bool/use_green_background"
android:key="show_contact_status"
android:summary="@string/pref_show_contact_presence_details"
android:title="@string/pref_show_contact_presence" />
<CheckBoxPreference
android:defaultValue="@bool/use_green_background"
android:key="show_account_indicator"
android:summary="@string/pref_show_account_indicator_details"
android:title="@string/pref_show_account_indicator" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_navigation">