// @SuppressLint("RtlHardcoded")
public void addWebView(LinearLayout parent) {
boolean isPortrait = CommonUtils.isPortrait();
boolean isWebView = isWebViewShowing(parent);
parent.setTag(TAG);
if (!isWebView ||
isWindowConfigurationChanged ||
isPortrait!=isLaidOutForPortrait) {
Log.d(TAG, "Layout web view");
List<Window> windows = windowControl.getWindowRepository().getVisibleWindows();
// ensure we have a known starting point - could be none, 1, or 2 webviews present
removeChildViews(previousParent);
parent.setOrientation(isPortrait? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
ViewGroup currentWindowFrameLayout = null;
Separator previousSeparator = null;
int windowNo = 0;
for (Window window : windows) {
Log.d(TAG, "Layout screen "+window.getScreenNo() + " of "+windows.size());
currentWindowFrameLayout = new FrameLayout(this.mainBibleActivity);
BibleView bibleView = getCleanView(window);
// trigger recalc of verse positions in case width changes e.g. minimize/restore web view
bibleView.setVersePositionRecalcRequired(true);
float windowWeight = window.getWindowLayout().getWeight();
LinearLayout.LayoutParams lp = isPortrait? new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, windowWeight) :
new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, windowWeight);
parent.addView(currentWindowFrameLayout, lp);
// add bible to framelayout
LayoutParams frameLayoutParamsBibleWebView = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
currentWindowFrameLayout.addView(bibleView, frameLayoutParamsBibleWebView);
if (windowNo>0) {
Separator separator = previousSeparator;
// extend touch area of separator
addTopOrLeftSeparatorExtension(isPortrait, currentWindowFrameLayout, lp, separator);
}
// Add screen separator
if (windowNo<windows.size()-1) {
Window nextWindow = windows.get(windowNo+1);
Separator separator = createSeparator(parent, window, nextWindow, isPortrait, windows.size());
// extend touch area of separator
addBottomOrRightSeparatorExtension(isPortrait, currentWindowFrameLayout, lp, separator);
// Add actual separator line dividing two windows
parent.addView(separator, isPortrait ? new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, WINDOW_SEPARATOR_WIDTH_PX, 0) :
new LinearLayout.LayoutParams(WINDOW_SEPARATOR_WIDTH_PX, LayoutParams.MATCH_PARENT, 0));
// allow extension to be added in next screen
previousSeparator = separator;
}
// leave main window clear of distracting minimise button, but simplify unmaximise
if (windowNo!=0 || window.isMaximised()) {
// create default action button for top right of each window
View defaultWindowActionButton = createDefaultWindowActionButton(window);
currentWindowFrameLayout.addView(defaultWindowActionButton, new FrameLayout.LayoutParams(BUTTON_SIZE_PX, BUTTON_SIZE_PX, Gravity.TOP|Gravity.RIGHT));
}
windowNo++;
}
// Display minimised screens
ViewGroup minimisedWindowsFrameContainer = new LinearLayout(mainBibleActivity);
currentWindowFrameLayout.addView(minimisedWindowsFrameContainer, new FrameLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, BUTTON_SIZE_PX, Gravity.BOTTOM|Gravity.RIGHT));
List<Window> minimisedScreens = windowControl.getWindowRepository().getMinimisedScreens();
for (int i=0; i<minimisedScreens.size(); i++) {
Log.d(TAG, "Show restore button");
Button restoreButton = createRestoreButton(minimisedScreens.get(i));
minimisedWindowsFrameContainer.addView(restoreButton, new LinearLayout.LayoutParams(BUTTON_SIZE_PX, BUTTON_SIZE_PX));
}
previousParent = parent;
isLaidOutForPortrait = isPortrait;
isWindowConfigurationChanged = false;
}
}