mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-27 12:20:11 +08:00
CB-8545 Don't add a layout as a parent of the WebView
Sanity checked mobilespec with --thirdpartyplugins that this doesn't break any of them.
This commit is contained in:
parent
d6da2ef096
commit
3950818030
@ -37,11 +37,10 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewParent;
|
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the main Android activity that represents the Cordova
|
* This class is the main Android activity that represents the Cordova
|
||||||
@ -163,31 +162,20 @@ public class CordovaActivity extends Activity {
|
|||||||
//Suppressing warnings in AndroidStudio
|
//Suppressing warnings in AndroidStudio
|
||||||
@SuppressWarnings({"deprecation", "ResourceType"})
|
@SuppressWarnings({"deprecation", "ResourceType"})
|
||||||
protected void createViews() {
|
protected void createViews() {
|
||||||
LinearLayout root = new LinearLayout(this);
|
|
||||||
root.setOrientation(LinearLayout.VERTICAL);
|
|
||||||
root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
|
|
||||||
|
|
||||||
//Why are we setting a constant as the ID? This should be investigated
|
//Why are we setting a constant as the ID? This should be investigated
|
||||||
appView.getView().setId(100);
|
appView.getView().setId(100);
|
||||||
appView.getView().setLayoutParams(new LinearLayout.LayoutParams(
|
appView.getView().setLayoutParams(new FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
1.0F));
|
|
||||||
|
setContentView(appView.getView());
|
||||||
|
|
||||||
// need to remove appView from any existing parent before invoking root.addView(appView)
|
|
||||||
ViewParent parent = appView.getView().getParent();
|
|
||||||
if ((parent != null) && (parent != root)) {
|
|
||||||
LOG.d(TAG, "removing appView from existing parent");
|
|
||||||
ViewGroup parentGroup = (ViewGroup) parent;
|
|
||||||
parentGroup.removeView(appView.getView());
|
|
||||||
if (preferences.contains("BackgroundColor")) {
|
if (preferences.contains("BackgroundColor")) {
|
||||||
int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
|
int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
|
||||||
// Background of activity:
|
// Background of activity:
|
||||||
appView.getView().setBackgroundColor(backgroundColor);
|
appView.getView().setBackgroundColor(backgroundColor);
|
||||||
}
|
}
|
||||||
root.addView(appView.getView());
|
|
||||||
setContentView(root);
|
|
||||||
appView.getView().requestFocusFromTouch();
|
appView.getView().requestFocusFromTouch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user