From c178804efe96cd9ef36f70b4181678c841620006 Mon Sep 17 00:00:00 2001 From: Ivan Kupalov Date: Tue, 9 Feb 2021 18:41:40 +0100 Subject: [PATCH] Fix TalkBack not initializing old views in recycler (#2036) --- .../tusky/fragment/TimelineFragment.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index ebaa8be82..6f42dd159 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -24,11 +24,13 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.accessibility.AccessibilityManager; import android.widget.ProgressBar; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.arch.core.util.Function; +import androidx.core.content.ContextCompat; import androidx.core.util.Pair; import androidx.core.widget.ContentLoadingProgressBar; import androidx.lifecycle.Lifecycle; @@ -95,6 +97,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.inject.Inject; @@ -1471,9 +1474,21 @@ public class TimelineFragment extends SFragment implements } }; + AccessibilityManager a11yManager; + boolean talkBackWasEnabled; + @Override public void onResume() { super.onResume(); + a11yManager = Objects.requireNonNull( + ContextCompat.getSystemService(requireContext(), AccessibilityManager.class) + ); + boolean wasEnabled = this.talkBackWasEnabled; + talkBackWasEnabled = a11yManager.isEnabled(); + Log.d(TAG, "talkback was enabled: " + wasEnabled + ", now " + talkBackWasEnabled); + if (talkBackWasEnabled && !wasEnabled) { + this.adapter.notifyDataSetChanged(); + } startUpdateTimestamp(); }