properly theme adapter filter highlighting

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-04 14:22:42 +02:00
parent 8c266fe229
commit 34d6da68a1
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
7 changed files with 22 additions and 23 deletions

View File

@ -32,6 +32,7 @@ import autodagger.AutoInjector
import com.nextcloud.talk.R import com.nextcloud.talk.R
import com.nextcloud.talk.application.NextcloudTalkApplication import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.events.CertificateEvent import com.nextcloud.talk.events.CertificateEvent
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.SecurityUtils import com.nextcloud.talk.utils.SecurityUtils
import com.nextcloud.talk.utils.preferences.AppPreferences import com.nextcloud.talk.utils.preferences.AppPreferences
import com.nextcloud.talk.utils.ssl.MagicTrustManager import com.nextcloud.talk.utils.ssl.MagicTrustManager
@ -53,6 +54,9 @@ open class BaseActivity : AppCompatActivity() {
@Inject @Inject
lateinit var appPreferences: AppPreferences lateinit var appPreferences: AppPreferences
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
@Inject @Inject
lateinit var context: Context lateinit var context: Context
@ -113,7 +117,7 @@ open class BaseActivity : AppCompatActivity() {
LovelyStandardDialog(this) LovelyStandardDialog(this)
.setTopColorRes(R.color.nc_darkRed) .setTopColorRes(R.color.nc_darkRed)
.setNegativeButtonColorRes(R.color.nc_darkRed) .setNegativeButtonColorRes(R.color.nc_darkRed)
.setPositiveButtonColorRes(R.color.colorPrimary) .setPositiveButtonColor(viewThemeUtils.getScheme(this).primary)
.setIcon(R.drawable.ic_security_white_24dp) .setIcon(R.drawable.ic_security_white_24dp)
.setTitle(R.string.nc_certificate_dialog_title) .setTitle(R.string.nc_certificate_dialog_title)
.setMessage(dialogText) .setMessage(dialogText)

View File

@ -34,6 +34,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.data.user.model.User; import com.nextcloud.talk.data.user.model.User;
import com.nextcloud.talk.databinding.AccountItemBinding; import com.nextcloud.talk.databinding.AccountItemBinding;
import com.nextcloud.talk.models.json.participants.Participant; import com.nextcloud.talk.models.json.participants.Participant;
import com.nextcloud.talk.ui.theme.ViewThemeUtils;
import com.nextcloud.talk.utils.ApiUtils; import com.nextcloud.talk.utils.ApiUtils;
import com.nextcloud.talk.utils.DisplayUtils; import com.nextcloud.talk.utils.DisplayUtils;
@ -54,11 +55,16 @@ public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.User
private final User user; private final User user;
@Nullable @Nullable
private final Account account; private final Account account;
private final ViewThemeUtils viewThemeUtils;
public AdvancedUserItem(Participant participant, User user, @Nullable Account account) { public AdvancedUserItem(Participant participant,
User user,
@Nullable Account account,
ViewThemeUtils viewThemeUtils) {
this.participant = participant; this.participant = participant;
this.user = user; this.user = user;
this.account = account; this.account = account;
this.viewThemeUtils = viewThemeUtils;
} }
@Override @Override
@ -110,9 +116,7 @@ public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.User
holder.binding.userName, holder.binding.userName,
participant.getDisplayName(), participant.getDisplayName(),
String.valueOf(adapter.getFilter(String.class)), String.valueOf(adapter.getFilter(String.class)),
NextcloudTalkApplication.Companion.getSharedApplication() viewThemeUtils.getScheme(holder.binding.userName.getContext()).getPrimary());
.getResources()
.getColor(R.color.colorPrimary));
} else { } else {
holder.binding.userName.setText(participant.getDisplayName()); holder.binding.userName.setText(participant.getDisplayName());
} }

View File

@ -135,19 +135,15 @@ public class ContactItem extends AbstractFlexibleItem<ContactItem.ContactItemVie
holder.binding.avatarDraweeView.setAlpha(1.0f); holder.binding.avatarDraweeView.setAlpha(1.0f);
} }
holder.binding.nameText.setText(participant.getDisplayName());
if (adapter.hasFilter()) { if (adapter.hasFilter()) {
FlexibleUtils.highlightText(holder.binding.nameText, FlexibleUtils.highlightText(holder.binding.nameText,
participant.getDisplayName(), participant.getDisplayName(),
String.valueOf(adapter.getFilter(String.class)), String.valueOf(adapter.getFilter(String.class)),
NextcloudTalkApplication viewThemeUtils.getScheme(holder.binding.nameText.getContext()).getPrimary());
.Companion
.getSharedApplication()
.getResources()
.getColor(R.color.colorPrimary));
} }
holder.binding.nameText.setText(participant.getDisplayName());
if (TextUtils.isEmpty(participant.getDisplayName()) && if (TextUtils.isEmpty(participant.getDisplayName()) &&
(participant.getType().equals(Participant.ParticipantType.GUEST) || (participant.getType().equals(Participant.ParticipantType.GUEST) ||
participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) { participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {

View File

@ -131,16 +131,14 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
holder.binding.avatarDraweeView.setAlpha(1.0f); holder.binding.avatarDraweeView.setAlpha(1.0f);
} }
holder.binding.nameText.setText(participant.getDisplayName());
if (adapter.hasFilter()) { if (adapter.hasFilter()) {
FlexibleUtils.highlightText(holder.binding.nameText, participant.getDisplayName(), FlexibleUtils.highlightText(holder.binding.nameText, participant.getDisplayName(),
String.valueOf(adapter.getFilter(String.class)), String.valueOf(adapter.getFilter(String.class)),
NextcloudTalkApplication.Companion.getSharedApplication() viewThemeUtils.getScheme(holder.binding.nameText.getContext()).getPrimary());
.getResources()
.getColor(R.color.colorPrimary));
} }
holder.binding.nameText.setText(participant.getDisplayName());
if (TextUtils.isEmpty(participant.getDisplayName()) && if (TextUtils.isEmpty(participant.getDisplayName()) &&
(participant.getType().equals(Participant.ParticipantType.GUEST) || (participant.getType().equals(Participant.ParticipantType.GUEST) ||
participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) { participant.getType().equals(Participant.ParticipantType.USER_FOLLOWING_LINK))) {

View File

@ -138,7 +138,7 @@ class SwitchAccountController(args: Bundle? = null) :
participant.actorType = Participant.ActorType.USERS participant.actorType = Participant.ActorType.USERS
participant.actorId = userId participant.actorId = userId
participant.displayName = user.displayName participant.displayName = user.displayName
userItems.add(AdvancedUserItem(participant, user, null)) userItems.add(AdvancedUserItem(participant, user, null, viewThemeUtils))
} }
} }
adapter!!.addListener(onSwitchItemClickListener) adapter!!.addListener(onSwitchItemClickListener)
@ -156,7 +156,7 @@ class SwitchAccountController(args: Bundle? = null) :
participant.displayName = importAccount.getUsername() participant.displayName = importAccount.getUsername()
user = User() user = User()
user.baseUrl = importAccount.getBaseUrl() user.baseUrl = importAccount.getBaseUrl()
userItems.add(AdvancedUserItem(participant, user, account)) userItems.add(AdvancedUserItem(participant, user, account, viewThemeUtils))
} }
adapter!!.addListener(onImportItemClickListener) adapter!!.addListener(onImportItemClickListener)
adapter!!.updateDataSet(userItems, false) adapter!!.updateDataSet(userItems, false)

View File

@ -65,9 +65,6 @@ class MessageSearchActivity : BaseActivity() {
@Inject @Inject
lateinit var userProvider: CurrentUserProviderNew lateinit var userProvider: CurrentUserProviderNew
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
private lateinit var binding: ActivityMessageSearchBinding private lateinit var binding: ActivityMessageSearchBinding
private lateinit var searchView: SearchView private lateinit var searchView: SearchView

View File

@ -203,7 +203,7 @@ public class ChooseAccountDialogFragment extends DialogFragment {
participant.setActorType(Participant.ActorType.USERS); participant.setActorType(Participant.ActorType.USERS);
participant.setActorId(userId); participant.setActorId(userId);
participant.setDisplayName(userEntity.getDisplayName()); participant.setDisplayName(userEntity.getDisplayName());
userItems.add(new AdvancedUserItem(participant, userEntity, null)); userItems.add(new AdvancedUserItem(participant, userEntity, null, viewThemeUtils));
} }
} }