Fix unexpected highlight

Check a key of preferences also.

Bug: 172699068
Test: Manual
      make RunSettingsRoboTests
      ROBOTEST_FILTER=HighlightablePreferenceGroupAdapterTest

Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
Change-Id: I9bb0ea68de0ab1bcc2134345905644d869f69e28
This commit is contained in:
Taesu Lee
2020-11-07 16:47:00 +09:00
parent b75c952800
commit ed51eed0c3
2 changed files with 9 additions and 2 deletions

View File

@@ -23,7 +23,6 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
@@ -114,7 +113,9 @@ public class HighlightablePreferenceGroupAdapter extends PreferenceGroupAdapter
@VisibleForTesting
void updateBackground(PreferenceViewHolder holder, int position) {
View v = holder.itemView;
if (position == mHighlightPosition) {
if (position == mHighlightPosition
&& (mHighlightKey != null
&& TextUtils.equals(mHighlightKey, getItem(position).getKey()))) {
// This position should be highlighted. If it's highlighted before - skip animation.
addHighlightBackground(v, !mFadeInAnimated);
} else if (Boolean.TRUE.equals(v.getTag(R.id.preference_highlighted))) {