mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 20:33:07 +08:00
Death to tabs while working on CB-1864
This commit is contained in:
parent
e1d608443a
commit
04b9a0b09e
@ -99,8 +99,8 @@ public class CordovaWebView extends WebView {
|
|||||||
|
|
||||||
private long lastMenuEventTime = 0;
|
private long lastMenuEventTime = 0;
|
||||||
|
|
||||||
NativeToJsMessageQueue jsMessageQueue;
|
NativeToJsMessageQueue jsMessageQueue;
|
||||||
ExposedJsApi exposedJsApi;
|
ExposedJsApi exposedJsApi;
|
||||||
|
|
||||||
/** custom view created by the browser (a video player for example) */
|
/** custom view created by the browser (a video player for example) */
|
||||||
private View mCustomView;
|
private View mCustomView;
|
||||||
@ -184,8 +184,8 @@ public class CordovaWebView extends WebView {
|
|||||||
* @param defStyle
|
* @param defStyle
|
||||||
* @param privateBrowsing
|
* @param privateBrowsing
|
||||||
*/
|
*/
|
||||||
@TargetApi(11)
|
@TargetApi(11)
|
||||||
public CordovaWebView(Context context, AttributeSet attrs, int defStyle, boolean privateBrowsing) {
|
public CordovaWebView(Context context, AttributeSet attrs, int defStyle, boolean privateBrowsing) {
|
||||||
super(context, attrs, defStyle, privateBrowsing);
|
super(context, attrs, defStyle, privateBrowsing);
|
||||||
if (CordovaInterface.class.isInstance(context))
|
if (CordovaInterface.class.isInstance(context))
|
||||||
{
|
{
|
||||||
@ -249,7 +249,7 @@ public class CordovaWebView extends WebView {
|
|||||||
// Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
|
// Jellybean rightfully tried to lock this down. Too bad they didn't give us a whitelist
|
||||||
// while we do this
|
// while we do this
|
||||||
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
|
if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
|
||||||
Level16Apis.enableUniversalAccess(settings);
|
Level16Apis.enableUniversalAccess(settings);
|
||||||
// Enable database
|
// Enable database
|
||||||
settings.setDatabaseEnabled(true);
|
settings.setDatabaseEnabled(true);
|
||||||
String databasePath = this.cordova.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
|
String databasePath = this.cordova.getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
|
||||||
@ -285,7 +285,7 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUserAgentString() {
|
private void updateUserAgentString() {
|
||||||
this.getSettings().getUserAgentString();
|
this.getSettings().getUserAgentString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exposeJsInterface() {
|
private void exposeJsInterface() {
|
||||||
@ -608,7 +608,7 @@ public class CordovaWebView extends WebView {
|
|||||||
// Check webview first to see if there is a history
|
// Check webview first to see if there is a history
|
||||||
// This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
|
// This is needed to support curPage#diffLink, since they are added to appView's history, but not our history url array (JQMobile behavior)
|
||||||
if (super.canGoBack()) {
|
if (super.canGoBack()) {
|
||||||
printBackForwardList();
|
printBackForwardList();
|
||||||
super.goBack();
|
super.goBack();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -839,27 +839,27 @@ public class CordovaWebView extends WebView {
|
|||||||
// If back key
|
// If back key
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
// A custom view is currently displayed (e.g. playing a video)
|
// A custom view is currently displayed (e.g. playing a video)
|
||||||
if(mCustomView != null) {
|
if(mCustomView != null) {
|
||||||
this.hideCustomView();
|
this.hideCustomView();
|
||||||
} else {
|
} else {
|
||||||
// The webview is currently displayed
|
// The webview is currently displayed
|
||||||
// If back key is bound, then send event to JavaScript
|
// If back key is bound, then send event to JavaScript
|
||||||
if (this.bound) {
|
if (this.bound) {
|
||||||
this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');");
|
this.loadUrl("javascript:cordova.fireDocumentEvent('backbutton');");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// If not bound
|
// If not bound
|
||||||
// Go to previous page in webview if it is possible to go back
|
// Go to previous page in webview if it is possible to go back
|
||||||
if (this.backHistory()) {
|
if (this.backHistory()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// If not, then invoke default behaviour
|
// If not, then invoke default behaviour
|
||||||
else {
|
else {
|
||||||
//this.activityState = ACTIVITY_EXITING;
|
//this.activityState = ACTIVITY_EXITING;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Legacy
|
// Legacy
|
||||||
else if (keyCode == KeyEvent.KEYCODE_MENU) {
|
else if (keyCode == KeyEvent.KEYCODE_MENU) {
|
||||||
@ -1002,14 +1002,14 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void printBackForwardList() {
|
public void printBackForwardList() {
|
||||||
WebBackForwardList currentList = this.copyBackForwardList();
|
WebBackForwardList currentList = this.copyBackForwardList();
|
||||||
int currentSize = currentList.getSize();
|
int currentSize = currentList.getSize();
|
||||||
for(int i = 0; i < currentSize; ++i)
|
for(int i = 0; i < currentSize; ++i)
|
||||||
{
|
{
|
||||||
WebHistoryItem item = currentList.getItemAtIndex(i);
|
WebHistoryItem item = currentList.getItemAtIndex(i);
|
||||||
String url = item.getUrl();
|
String url = item.getUrl();
|
||||||
LOG.d(TAG, "The URL at index: " + Integer.toString(i) + "is " + url );
|
LOG.d(TAG, "The URL at index: " + Integer.toString(i) + "is " + url );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1026,8 +1026,8 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
|
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
|
||||||
// This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
|
// This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
|
||||||
Log.d(TAG, "showing Custom View");
|
Log.d(TAG, "showing Custom View");
|
||||||
// if a view already exists then immediately terminate the new one
|
// if a view already exists then immediately terminate the new one
|
||||||
if (mCustomView != null) {
|
if (mCustomView != null) {
|
||||||
callback.onCustomViewHidden();
|
callback.onCustomViewHidden();
|
||||||
@ -1035,46 +1035,46 @@ public class CordovaWebView extends WebView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store the view and its callback for later (to kill it properly)
|
// Store the view and its callback for later (to kill it properly)
|
||||||
mCustomView = view;
|
mCustomView = view;
|
||||||
mCustomViewCallback = callback;
|
mCustomViewCallback = callback;
|
||||||
|
|
||||||
// Add the custom view to its container.
|
// Add the custom view to its container.
|
||||||
ViewGroup parent = (ViewGroup) this.getParent();
|
ViewGroup parent = (ViewGroup) this.getParent();
|
||||||
parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
|
parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
|
||||||
|
|
||||||
// Hide the content view.
|
// Hide the content view.
|
||||||
this.setVisibility(View.GONE);
|
this.setVisibility(View.GONE);
|
||||||
|
|
||||||
// Finally show the custom view container.
|
// Finally show the custom view container.
|
||||||
parent.setVisibility(View.VISIBLE);
|
parent.setVisibility(View.VISIBLE);
|
||||||
parent.bringToFront();
|
parent.bringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideCustomView() {
|
public void hideCustomView() {
|
||||||
// This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
|
// This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
|
||||||
Log.d(TAG, "Hidding Custom View");
|
Log.d(TAG, "Hidding Custom View");
|
||||||
if (mCustomView == null) return;
|
if (mCustomView == null) return;
|
||||||
|
|
||||||
// Hide the custom view.
|
// Hide the custom view.
|
||||||
mCustomView.setVisibility(View.GONE);
|
mCustomView.setVisibility(View.GONE);
|
||||||
|
|
||||||
// Remove the custom view from its container.
|
// Remove the custom view from its container.
|
||||||
ViewGroup parent = (ViewGroup) this.getParent();
|
ViewGroup parent = (ViewGroup) this.getParent();
|
||||||
parent.removeView(mCustomView);
|
parent.removeView(mCustomView);
|
||||||
mCustomView = null;
|
mCustomView = null;
|
||||||
mCustomViewCallback.onCustomViewHidden();
|
mCustomViewCallback.onCustomViewHidden();
|
||||||
|
|
||||||
// Show the content view.
|
// Show the content view.
|
||||||
this.setVisibility(View.VISIBLE);
|
this.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if the video overlay is showing then we need to know
|
* if the video overlay is showing then we need to know
|
||||||
* as it effects back button handling
|
* as it effects back button handling
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isCustomViewShowing() {
|
public boolean isCustomViewShowing() {
|
||||||
return mCustomView != null;
|
return mCustomView != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user