Commit 9b6702f0 authored by Zhiheng Li's avatar Zhiheng Li Committed by Commit Bot

Add method in CastWebContentsView to return ContentView and ContentViewRendererView.

Bug: internal b/143071435
Test: tested on AndroidThings device
Change-Id: I4b93f9ed7c39dbfa1e669c285515234f2acc241d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902075Reviewed-by: default avatarSimeon Anfinrud <sanfin@chromium.org>
Commit-Queue: Zhiheng(Vincent) Li <vincentli@google.com>
Auto-Submit: Zhiheng(Vincent) Li <vincentli@google.com>
Cr-Commit-Position: refs/heads/master@{#714835}
parent adc1382f
......@@ -26,6 +26,8 @@ class CastWebContentsScopes {
IBinder provideWindowToken();
}
static final String VIEW_TAG_CONTENT_VIEW = "ContentView";
public static Observer<WebContents> onLayoutActivity(
Activity activity, FrameLayout layout, @ColorInt int backgroundColor) {
layout.setBackgroundColor(backgroundColor);
......@@ -77,6 +79,7 @@ class CastWebContentsScopes {
layout.addView(contentView, matchParent);
contentView.setFocusable(true);
contentView.requestFocus();
contentView.setTag(VIEW_TAG_CONTENT_VIEW);
contentViewRenderView.setCurrentWebContents(webContents);
return () -> {
layout.setForeground(new ColorDrawable(backgroundColor));
......
......@@ -12,6 +12,9 @@ import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityNodeProvider;
import android.widget.FrameLayout;
import org.chromium.base.Log;
......@@ -41,9 +44,10 @@ public class CastWebContentsView extends FrameLayout {
private void initView() {
FrameLayout.LayoutParams matchParent = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
addView(LayoutInflater.from(getContext())
.inflate(R.layout.cast_web_contents_activity, null), matchParent);
.inflate(R.layout.cast_web_contents_activity, null),
matchParent);
}
public void onStart(Bundle startArgumentsBundle) {
......@@ -91,4 +95,40 @@ public class CastWebContentsView extends FrameLayout {
private void sendIntentSync(Intent in) {
CastWebContentsIntentUtils.getLocalBroadcastManager().sendBroadcastSync(in);
}
@Override
public AccessibilityNodeProvider getAccessibilityNodeProvider() {
View contentView = getContentView();
if (contentView != null) {
return contentView.getAccessibilityNodeProvider();
} else {
Log.w(TAG, "Content view is null! Returns a null AccessibilityNodeProvider.");
return null;
}
}
@Override
public void setAccessibilityDelegate(AccessibilityDelegate delegate) {
View contentView = getContentView();
if (contentView != null) {
contentView.setAccessibilityDelegate(delegate);
} else {
Log.w(TAG, "Content view is null!");
}
}
@Override
public boolean onHoverEvent(MotionEvent event) {
View contentView = getContentView();
if (contentView != null) {
return contentView.onHoverEvent(event);
} else {
Log.w(TAG, "Content view is null!");
return false;
}
}
private View getContentView() {
return findViewWithTag(CastWebContentsScopes.VIEW_TAG_CONTENT_VIEW);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment