diff options
author | Nick Chalko <nchalko@google.com> | 2017-05-09 14:07:44 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2017-05-10 09:49:18 -0700 |
commit | 0550a7221be0581b0bd421a9d70400ff8699a6e7 (patch) | |
tree | 14d9836ff9283690321c166560ee3450792236ad /src/com/android/tv/guide/ProgramTableAdapter.java | |
parent | 430c2be3b91676005fdd243553e38acff8dfc3de (diff) | |
download | TV-0550a7221be0581b0bd421a9d70400ff8699a6e7.tar.gz |
Sync to ub-tv-dev at lost+android-o-preview-3android-n-iot-preview-4n-iot-preview-4
hash 550cbec17259717c5453f6be1eb05736ba10ef1d
Bug: 37849928
Test: tested on vendor branch
Change-Id: I82190481d2bcef2b89e78414b6b92ed97720749d
Merged-In: I4199ec04cacb4a78be58b85302a39d917658dc28
Diffstat (limited to 'src/com/android/tv/guide/ProgramTableAdapter.java')
-rw-r--r-- | src/com/android/tv/guide/ProgramTableAdapter.java | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/src/com/android/tv/guide/ProgramTableAdapter.java b/src/com/android/tv/guide/ProgramTableAdapter.java index e4a67972..b9a0593d 100644 --- a/src/com/android/tv/guide/ProgramTableAdapter.java +++ b/src/com/android/tv/guide/ProgramTableAdapter.java @@ -45,19 +45,21 @@ import android.view.ViewGroup; import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityManager; +import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.android.tv.R; import com.android.tv.TvApplication; +import com.android.tv.common.TvCommonUtils; import com.android.tv.common.feature.CommonFeatures; import com.android.tv.data.Channel; import com.android.tv.data.Program; import com.android.tv.data.Program.CriticScore; import com.android.tv.dvr.DvrDataManager; import com.android.tv.dvr.DvrManager; -import com.android.tv.dvr.ScheduledRecording; +import com.android.tv.dvr.data.ScheduledRecording; import com.android.tv.guide.ProgramManager.TableEntriesUpdatedListener; import com.android.tv.parental.ParentalControlSettings; import com.android.tv.ui.HardwareLayerAnimatorListenerAdapter; @@ -241,16 +243,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte notifyItemChanged(channelIndex, true); } - @Override - public void onViewAttachedToWindow(ProgramRowHolder holder) { - holder.onAttachedToWindow(); - } - - @Override - public void onViewDetachedFromWindow(ProgramRowHolder holder) { - holder.onDetachedFromWindow(); - } - // TODO: make it static public class ProgramRowHolder extends RecyclerView.ViewHolder implements ProgramRow.ChildFocusListener { @@ -312,11 +304,40 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte private final ImageView mInputLogoView; private boolean mIsInputLogoVisible; + private AccessibilityStateChangeListener mAccessibilityStateChangeListener = + new AccessibilityManager.AccessibilityStateChangeListener() { + @Override + public void onAccessibilityStateChanged(boolean enable) { + enable &= !TvCommonUtils.isRunningInTest(); + mDetailView.setFocusable(enable); + mChannelHeaderView.setFocusable(enable); + } + }; public ProgramRowHolder(View itemView) { super(itemView); mContainer = (ViewGroup) itemView; + mContainer.addOnAttachStateChangeListener( + new View.OnAttachStateChangeListener() { + @Override + public void onViewAttachedToWindow(View v) { + mContainer + .getViewTreeObserver() + .addOnGlobalFocusChangeListener(mGlobalFocusChangeListener); + mAccessibilityManager.addAccessibilityStateChangeListener( + mAccessibilityStateChangeListener); + } + + @Override + public void onViewDetachedFromWindow(View v) { + mContainer + .getViewTreeObserver() + .removeOnGlobalFocusChangeListener(mGlobalFocusChangeListener); + mAccessibilityManager.removeAccessibilityStateChangeListener( + mAccessibilityStateChangeListener); + } + }); mProgramRow = (ProgramRow) mContainer.findViewById(R.id.row); mDetailView = (ViewGroup) mContainer.findViewById(R.id.detail); @@ -339,16 +360,11 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte mChannelLogoView = (ImageView) mContainer.findViewById(R.id.channel_logo); mChannelBlockView = (ImageView) mContainer.findViewById(R.id.channel_block); mInputLogoView = (ImageView) mContainer.findViewById(R.id.input_logo); - mDetailView.setFocusable(mAccessibilityManager.isEnabled()); - mChannelHeaderView.setFocusable(mAccessibilityManager.isEnabled()); - mAccessibilityManager.addAccessibilityStateChangeListener( - new AccessibilityManager.AccessibilityStateChangeListener() { - @Override - public void onAccessibilityStateChanged(boolean enable) { - mDetailView.setFocusable(enable); - mChannelHeaderView.setFocusable(enable); - } - }); + // TODO: Find a better way to handle talk back. + boolean accessibilityEnabled = mAccessibilityManager.isEnabled() + && !TvCommonUtils.isRunningInTest(); + mDetailView.setFocusable(accessibilityEnabled); + mChannelHeaderView.setFocusable(accessibilityEnabled); } public void onBind(int position) { @@ -508,16 +524,6 @@ public class ProgramTableAdapter extends RecyclerView.Adapter<ProgramTableAdapte }); } - private void onAttachedToWindow() { - mContainer.getViewTreeObserver() - .addOnGlobalFocusChangeListener(mGlobalFocusChangeListener); - } - - private void onDetachedFromWindow() { - mContainer.getViewTreeObserver() - .removeOnGlobalFocusChangeListener(mGlobalFocusChangeListener); - } - private void updateDetailView() { if (mSelectedEntry == null) { // The view holder is never on focus before. |