Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package io.flutter.plugin.platform;

import android.content.Context;
import android.support.annotation.StyleRes;

import io.flutter.plugin.common.MessageCodec;

public abstract class PlatformViewFactory {
Expand All @@ -29,6 +31,16 @@ public PlatformViewFactory(MessageCodec<Object> createArgsCodec) {
*/
public abstract PlatformView create(Context context, int viewId, Object args);

/**
* Used to customize the Theme of Presentation. This is useful when need a translucent AndroidView.
* Return 0 by default, will use the theme defined by com.android.internal.R.attr.presentationTheme attribute.
* @return A style resource describing the theme to use for the window.
*/
@StyleRes
protected int getPresentationTheme() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know how this works.

Though it seems a bit unfortunate to create this parallel mechanism to side-load this. Can it not be passed via args from the Flutter side and then use context.setTheme or something instead?

return 0;
}

/**
* Returns the codec to be used for decoding the args parameter of {@link #create}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public SingleViewPresentation(
Object createParams,
OnFocusChangeListener focusChangeListener
) {
super(outerContext, display);
super(outerContext, display, viewFactory.getPresentationTheme());
this.viewFactory = viewFactory;
this.accessibilityEventsDelegate = accessibilityEventsDelegate;
this.viewId = viewId;
Expand All @@ -122,9 +122,10 @@ public SingleViewPresentation(
AccessibilityEventsDelegate accessibilityEventsDelegate,
PresentationState state,
OnFocusChangeListener focusChangeListener,
boolean startFocused
boolean startFocused,
int themeId
) {
super(outerContext, display);
super(outerContext, display, themeId);
this.accessibilityEventsDelegate = accessibilityEventsDelegate;
viewFactory = null;
this.state = state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static VirtualDisplayController create(
private VirtualDisplay virtualDisplay;
private SingleViewPresentation presentation;
private Surface surface;
private int presentationThemeId;


private VirtualDisplayController(
Expand All @@ -81,6 +82,7 @@ private VirtualDisplayController(
this.surface = surface;
this.virtualDisplay = virtualDisplay;
densityDpi = context.getResources().getDisplayMetrics().densityDpi;
presentationThemeId = viewFactory.getPresentationTheme();
presentation = new SingleViewPresentation(
context,
this.virtualDisplay.getDisplay(),
Expand Down Expand Up @@ -145,7 +147,8 @@ public void onViewDetachedFromWindow(View v) {}
accessibilityEventsDelegate,
presentationState,
focusChangeListener,
isFocused);
isFocused,
presentationThemeId);
presentation.show();
}

Expand Down