You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
First implementation of SWebBrowser for Android
[CL 2712814 by Gareth Martin in Main branch]
This commit is contained in:
committed by
gareth.martin@epicgames.com
parent
8c1764a664
commit
41b63fa034
@@ -133,9 +133,11 @@ public class GameActivity extends NativeActivity
|
||||
private AdView adView;
|
||||
private boolean adInit = false;
|
||||
private LinearLayout adLayout;
|
||||
private LinearLayout activityLayout;
|
||||
private int adGravity = Gravity.TOP;
|
||||
|
||||
// layout required by popups, e.g ads, native controls
|
||||
LinearLayout activityLayout;
|
||||
|
||||
/** true when the application has requested that an ad be displayed */
|
||||
private boolean adWantsToBeShown = false;
|
||||
|
||||
@@ -270,7 +272,13 @@ public class GameActivity extends NativeActivity
|
||||
}
|
||||
|
||||
_activity = this;
|
||||
|
||||
|
||||
// layout required by popups, e.g ads, native controls
|
||||
MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 0, 0);
|
||||
activityLayout = new LinearLayout(_activity);
|
||||
_activity.setContentView(activityLayout, params);
|
||||
|
||||
/*
|
||||
// Turn on and unlock screen.. Assumption is that this
|
||||
// will only really have an effect when for debug launching
|
||||
@@ -960,7 +968,6 @@ public class GameActivity extends NativeActivity
|
||||
adPopupWindow.setClippingEnabled(false);
|
||||
|
||||
adLayout = new LinearLayout(_activity);
|
||||
activityLayout = new LinearLayout(_activity);
|
||||
|
||||
final int padding = (int)(-5*scale);
|
||||
adLayout.setPadding(padding,padding,padding,padding);
|
||||
@@ -973,8 +980,6 @@ public class GameActivity extends NativeActivity
|
||||
adLayout.addView(adView, params);
|
||||
adPopupWindow.setContentView(adLayout);
|
||||
|
||||
_activity.setContentView(activityLayout, params);
|
||||
|
||||
// set up our ad callbacks
|
||||
_activity.adView.setAdListener(new AdListener()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
package com.epicgames.ue4;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewGroup.MarginLayoutParams;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
class WebViewControl
|
||||
{
|
||||
public WebViewControl()
|
||||
{
|
||||
GameActivity._activity.runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
webView = new WebView(GameActivity._activity);
|
||||
webView.getSettings().setJavaScriptEnabled(true);
|
||||
webView.loadUrl("about:blank");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void LoadURL(final String url)
|
||||
{
|
||||
GameActivity._activity.runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
webView.loadUrl(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Update(final int x, final int y, final int width, final int height)
|
||||
{
|
||||
GameActivity._activity.runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (webPopup == null)
|
||||
{
|
||||
webPopup = new PopupWindow(GameActivity._activity);
|
||||
webPopup.setWidth(width);
|
||||
webPopup.setHeight(height);
|
||||
webPopup.setClippingEnabled(false);
|
||||
webPopup.setOutsideTouchable(false); // non-modal
|
||||
webPopup.setBackgroundDrawable((Drawable)null); // no border
|
||||
|
||||
webLayout = new LinearLayout(GameActivity._activity);
|
||||
webLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
webLayout.setPadding(0, 0, 0, 0);
|
||||
|
||||
MarginLayoutParams params = new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
params.setMargins(0, 0, 0, 0);
|
||||
webLayout.addView(webView, params);
|
||||
|
||||
webPopup.setContentView(webLayout);
|
||||
webPopup.showAtLocation(GameActivity._activity.activityLayout, Gravity.NO_GRAVITY, x, y);
|
||||
webPopup.update();
|
||||
}
|
||||
else
|
||||
{
|
||||
webPopup.update(x, y, width, height);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Web Views
|
||||
private PopupWindow webPopup;
|
||||
private LinearLayout webLayout;
|
||||
private WebView webView;
|
||||
}
|
||||
Reference in New Issue
Block a user