From f3d7f72c9e3a71b91e01b6cfa99e092ac1ee4415 Mon Sep 17 00:00:00 2001 From: Landsbankinn Date: Wed, 4 Oct 2017 16:41:31 +0000 Subject: [PATCH 01/18] Lets user adjust color of toolbar, hide navigation buttons and set custom text on close button --- src/android/InAppBrowser.java | 130 ++++++++++++++++++++++------------ src/ios/CDVInAppBrowser.h | 11 +-- src/ios/CDVInAppBrowser.m | 42 +++++++++-- 3 files changed, 126 insertions(+), 57 deletions(-) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 48f6846..62a834d 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -25,6 +25,9 @@ import android.provider.Browser; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; +import android.graphics.Color; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -51,6 +54,7 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; +import android.widget.TextView; import org.apache.cordova.CallbackContext; import org.apache.cordova.Config; @@ -91,6 +95,8 @@ public class InAppBrowser extends CordovaPlugin { private static final String SHOULD_PAUSE = "shouldPauseOnSuspend"; private static final Boolean DEFAULT_HARDWARE_BACK = true; private static final String USER_WIDE_VIEW_PORT = "useWideViewPort"; + private static final String CLOSE_BUTTON_TEXT = "closeButtonText"; + private static final String CLOSE_BUTTON_COLOR = "closeButtonColor"; private InAppBrowserDialog dialog; private WebView inAppWebView; @@ -109,6 +115,8 @@ public class InAppBrowser extends CordovaPlugin { private ValueCallback mUploadCallbackLollipop; private final static int FILECHOOSER_REQUESTCODE = 1; private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2; + private String closeButtonText = ""; + private int closeButtonColor = android.graphics.Color.LTGRAY; /** * Executes the request and returns PluginResult. @@ -127,7 +135,7 @@ public class InAppBrowser extends CordovaPlugin { t = SELF; } final String target = t; - final HashMap features = parseFeature(args.optString(2)); + final HashMap features = parseFeature(args.optString(2)); LOG.d(LOG_TAG, "target = " + target); @@ -366,18 +374,23 @@ public class InAppBrowser extends CordovaPlugin { * @param optString * @return */ - private HashMap parseFeature(String optString) { + private HashMap parseFeature(String optString) { if (optString.equals(NULL)) { return null; } else { - HashMap map = new HashMap(); + HashMap map = new HashMap(); StringTokenizer features = new StringTokenizer(optString, ","); StringTokenizer option; while(features.hasMoreElements()) { option = new StringTokenizer(features.nextToken(), "="); if (option.hasMoreElements()) { String key = option.nextToken(); - Boolean value = option.nextToken().equals("no") ? Boolean.FALSE : Boolean.TRUE; + String value = null; + if (key.equals(CLOSE_BUTTON_TEXT)) value = option.nextToken(); + else { + String token = option.nextToken(); + value = token.equals("yes") || token.equals("no") ? token : "yes"; // hér!! + } map.put(key, value); } } @@ -523,7 +536,7 @@ public class InAppBrowser extends CordovaPlugin { * @param url the url to load. * @param features jsonObject */ - public String showWebPage(final String url, HashMap features) { + public String showWebPage(final String url, HashMap features) { // Determine if we should hide the location bar. showLocationBar = true; showZoomControls = true; @@ -531,44 +544,52 @@ public class InAppBrowser extends CordovaPlugin { mediaPlaybackRequiresUserGesture = false; if (features != null) { - Boolean show = features.get(LOCATION); + String show = features.get(LOCATION); if (show != null) { - showLocationBar = show.booleanValue(); + showLocationBar = show.equals("yes") ? true : false; } - Boolean zoom = features.get(ZOOM); + String zoom = features.get(ZOOM); if (zoom != null) { - showZoomControls = zoom.booleanValue(); + showZoomControls = zoom.equals("yes") ? true : false; } - Boolean hidden = features.get(HIDDEN); + String hidden = features.get(HIDDEN); if (hidden != null) { - openWindowHidden = hidden.booleanValue(); + openWindowHidden = hidden.equals("yes") ? true : false; } - Boolean hardwareBack = features.get(HARDWARE_BACK_BUTTON); + String hardwareBack = features.get(HARDWARE_BACK_BUTTON); if (hardwareBack != null) { - hadwareBackButton = hardwareBack.booleanValue(); + hadwareBackButton = hardwareBack.equals("yes") ? true : false; } else { hadwareBackButton = DEFAULT_HARDWARE_BACK; } - Boolean mediaPlayback = features.get(MEDIA_PLAYBACK_REQUIRES_USER_ACTION); + String mediaPlayback = features.get(MEDIA_PLAYBACK_REQUIRES_USER_ACTION); if (mediaPlayback != null) { - mediaPlaybackRequiresUserGesture = mediaPlayback.booleanValue(); + mediaPlaybackRequiresUserGesture = mediaPlayback.equals("yes") ? true : false; } - Boolean cache = features.get(CLEAR_ALL_CACHE); + String cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { - clearAllCache = cache.booleanValue(); + clearAllCache = cache.equals("yes") ? true : false; } else { cache = features.get(CLEAR_SESSION_CACHE); if (cache != null) { - clearSessionCache = cache.booleanValue(); + clearSessionCache = cache.equals("yes") ? true : false; } } - Boolean shouldPause = features.get(SHOULD_PAUSE); + String shouldPause = features.get(SHOULD_PAUSE); if (shouldPause != null) { - shouldPauseInAppBrowser = shouldPause.booleanValue(); + shouldPauseInAppBrowser = shouldPause.equals("yes") ? true : false; } - Boolean wideViewPort = features.get(USER_WIDE_VIEW_PORT); + String wideViewPort = features.get(USER_WIDE_VIEW_PORT); if (wideViewPort != null ) { - useWideViewPort = wideViewPort.booleanValue(); + useWideViewPort = wideViewPort.equals("yes") ? true : false; + } + String closeButtonTextSet = features.get(CLOSE_BUTTON_TEXT); + if (closeButtonTextSet != null) { + closeButtonText = closeButtonTextSet; + } + String closeButtonTextColorSet = features.get(CLOSE_BUTTON_COLOR); + if (closeButtonTextColorSet != null) { + closeButtonColor = Color.parseColor(closeButtonTextColorSet); } } @@ -612,7 +633,7 @@ public class InAppBrowser extends CordovaPlugin { // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); //Please, no more black! - toolbar.setBackgroundColor(android.graphics.Color.LTGRAY); + toolbar.setBackgroundColor(closeButtonColor); toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); @@ -700,29 +721,46 @@ public class InAppBrowser extends CordovaPlugin { }); // Close/Done button - ImageButton close = new ImageButton(cordova.getActivity()); - RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); - closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); - close.setLayoutParams(closeLayoutParams); - close.setContentDescription("Close Button"); - close.setId(Integer.valueOf(5)); - int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); - Drawable closeIcon = activityRes.getDrawable(closeResId); - if (Build.VERSION.SDK_INT >= 16) - close.setBackground(null); - else - close.setBackgroundDrawable(null); - close.setImageDrawable(closeIcon); - close.setScaleType(ImageView.ScaleType.FIT_CENTER); - back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); - if (Build.VERSION.SDK_INT >= 16) - close.getAdjustViewBounds(); + if (closeButtonText != "") { + /* Use TextView for text */ + TextView close = new TextView(cordova.getActivity()); + close.setText(closeButtonText); + close.setTextSize(25); + back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + close.setId(Integer.valueOf(5)); + close.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + closeDialog(); + } + }); + toolbar.addView(close); + } + else { + ImageButton close = new ImageButton(cordova.getActivity()); + RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); + closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + close.setLayoutParams(closeLayoutParams); + close.setContentDescription("Close Button"); + close.setId(Integer.valueOf(5)); + int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); + Drawable closeIcon = activityRes.getDrawable(closeResId); + if (Build.VERSION.SDK_INT >= 16) + close.setBackground(null); + else + close.setBackgroundDrawable(null); + close.setImageDrawable(closeIcon); + close.setScaleType(ImageView.ScaleType.FIT_CENTER); + back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + if (Build.VERSION.SDK_INT >= 16) + close.getAdjustViewBounds(); - close.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - closeDialog(); - } - }); + close.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + closeDialog(); + } + }); + toolbar.addView(close); + } // WebView inAppWebView = new WebView(cordova.getActivity()); @@ -828,7 +866,7 @@ public class InAppBrowser extends CordovaPlugin { // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); - toolbar.addView(close); + // toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index d258eb0..8f01721 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -49,7 +49,11 @@ @property (nonatomic, assign) BOOL location; @property (nonatomic, assign) BOOL toolbar; @property (nonatomic, copy) NSString* closebuttoncaption; +@property (nonatomic, copy) NSString* closebuttoncolor; @property (nonatomic, copy) NSString* toolbarposition; +@property (nonatomic, copy) NSString* toolbarcolor; +@property (nonatomic, assign) BOOL toolbartranslucent; +@property (nonatomic, assign) BOOL hideToolbarNavigationButtons; @property (nonatomic, assign) BOOL clearcache; @property (nonatomic, assign) BOOL clearsessioncache; @@ -74,13 +78,13 @@ NSString* _prevUserAgent; NSInteger _userAgentLockToken; CDVInAppBrowserOptions *_browserOptions; - + #ifdef __CORDOVA_4_0_0 CDVUIWebViewDelegate* _webViewDelegate; #else CDVWebViewDelegate* _webViewDelegate; #endif - + } @property (nonatomic, strong) IBOutlet UIWebView* webView; @@ -99,7 +103,7 @@ - (void)navigateTo:(NSURL*)url; - (void)showLocationBar:(BOOL)show; - (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition; -- (void)setCloseButtonTitle:(NSString*)title; +- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString; - (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions; @@ -110,4 +114,3 @@ @property (nonatomic, weak) id orientationDelegate; @end - diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index f5d05f0..a890f7f 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -162,8 +162,8 @@ [self.inAppBrowserViewController showLocationBar:browserOptions.location]; [self.inAppBrowserViewController showToolBar:browserOptions.toolbar :browserOptions.toolbarposition]; - if (browserOptions.closebuttoncaption != nil) { - [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption]; + if (browserOptions.closebuttoncaption != nil || browserOptions.closebuttoncolor != nil) { + [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption :browserOptions.closebuttoncolor]; } // Set Presentation Style UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default @@ -599,6 +599,12 @@ self.toolbar.multipleTouchEnabled = NO; self.toolbar.opaque = NO; self.toolbar.userInteractionEnabled = YES; + if (_browserOptions.toolbarcolor != nil) { // Set toolbar color if user sets it in options + self.toolbar.barTintColor = [self colorFromHexString:_browserOptions.toolbarcolor]; + } + if (!_browserOptions.toolbartranslucent) { // Set toolbar translucent to no if user sets it in options + self.toolbar.translucent = NO; + } CGFloat labelInset = 5.0; float locationBarY = toolbarIsAtBottom ? self.view.bounds.size.height - FOOTER_HEIGHT : self.view.bounds.size.height - LOCATIONBAR_HEIGHT; @@ -642,7 +648,13 @@ self.backButton.enabled = YES; self.backButton.imageInsets = UIEdgeInsetsZero; - [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; + // Filter out Navigation Buttons if user requests so + if (_browserOptions.hideToolbarNavigationButtons) { + [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; + } else { + [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; + } + [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; self.view.backgroundColor = [UIColor grayColor]; [self.view addSubview:self.toolbar]; @@ -655,14 +667,16 @@ [self.webView setFrame:frame]; } -- (void)setCloseButtonTitle:(NSString*)title +- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString { // the advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically // but, if you want to set this yourself, knock yourself out (we can't set the title for a system Done button, so we have to create a new one) self.closeButton = nil; - self.closeButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:self action:@selector(close)]; + // Initialize with title if title is set, otherwise the title will be 'Done' localized + self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)]; self.closeButton.enabled = YES; - self.closeButton.tintColor = [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1]; + // If color on closebutton is requested then initialize with that that color, otherwise use initialize with default + self.closeButton.tintColor = colorString != nil ? [self colorFromHexString:colorString] : [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1]; NSMutableArray* items = [self.toolbar.items mutableCopy]; [items replaceObjectAtIndex:0 withObject:self.closeButton]; @@ -877,6 +891,17 @@ } } +// Helper function to convert hex color string to UIColor +// Assumes input like "#00FF00" (#RRGGBB). +// Taken from https://stackoverflow.com/questions/1560081/how-can-i-create-a-uicolor-from-a-hex-string +- (UIColor *)colorFromHexString:(NSString *)hexString { + unsigned rgbValue = 0; + NSScanner *scanner = [NSScanner scannerWithString:hexString]; + [scanner setScanLocation:1]; // bypass '#' character + [scanner scanHexInt:&rgbValue]; + return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0]; +} + #pragma mark UIWebViewDelegate - (void)webViewDidStartLoad:(UIWebView*)theWebView @@ -995,6 +1020,10 @@ self.suppressesincrementalrendering = NO; self.hidden = NO; self.disallowoverscroll = NO; + self.hideToolbarNavigationButtons = NO; + self.closebuttoncolor = nil; + self.toolbarcolor = nil; + self.toolbartranslucent = YES; } return self; @@ -1104,4 +1133,3 @@ @end - From d940b596b634b1a300bc594bb91a798c697bd5ba Mon Sep 17 00:00:00 2001 From: Landsbankinn Date: Fri, 6 Oct 2017 13:05:01 +0000 Subject: [PATCH 02/18] Android works well now, all changes are now documented --- README.md | 14 +++++- src/android/InAppBrowser.java | 84 ++++++++++++++++++++++++++--------- src/ios/CDVInAppBrowser.h | 2 +- src/ios/CDVInAppBrowser.m | 4 +- 4 files changed, 77 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index a4b7cd9..6eb0479 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,8 @@ instance, or the system browser. - __options__: Options for the `InAppBrowser`. Optional, defaulting to: `location=yes`. _(String)_ - The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. - + The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. + All platforms support: - __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off. @@ -112,7 +112,13 @@ instance, or the system browser. - __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. - __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened - __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened + - __closebuttoncaption__: set to a string to use as the close buttons caption instead of a X. Note that you need to localize this value yourself. + - __closebuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the + close button color from default, regardless of being a text or default X. Only has effect if user has location set to `yes`. - __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser. + - __hidenavigationbuttons__: set to `yes` to hide the navigation buttons on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`. + - __hideurlbar__: set to `yes` to hide the url bar on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`. + - __navigationbuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color of both navigation buttons from default. Only has effect if user has location set to `yes` and not hidenavigationbuttons set to `yes`. - __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`. - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). - __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)). @@ -123,9 +129,13 @@ instance, or the system browser. - __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. - __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened - __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened + - __closebuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default __Done__ button's color. Only applicable if toolbar is not disabled. - __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself. - __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property. + - __hidetoolbarnavigationbuttons__: set to `yes` or `no` to turn the toolbar navigation buttons on or off (defaults to `no`). Only applicable if toolbar is not disabled. - __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`) + - __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled. + - __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled. - __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). - __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 62a834d..8f937fb 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -71,6 +71,8 @@ import org.json.JSONObject; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.List; import java.util.HashMap; import java.util.StringTokenizer; @@ -95,8 +97,14 @@ public class InAppBrowser extends CordovaPlugin { private static final String SHOULD_PAUSE = "shouldPauseOnSuspend"; private static final Boolean DEFAULT_HARDWARE_BACK = true; private static final String USER_WIDE_VIEW_PORT = "useWideViewPort"; - private static final String CLOSE_BUTTON_TEXT = "closeButtonText"; - private static final String CLOSE_BUTTON_COLOR = "closeButtonColor"; + private static final String TOOLBAR_COLOR = "toolbarcolor"; + private static final String CLOSE_BUTTON_CAPTION = "closebuttoncaption"; + private static final String CLOSE_BUTTON_COLOR = "closebuttoncolor"; + private static final String HIDE_NAVIGATION = "hidenavigationbuttons"; + private static final String NAVIGATION_COLOR = "navigationbuttoncolor"; + private static final String HIDE_URL = "hideurlbar"; + + private static final List customizableOptions = Arrays.asList(CLOSE_BUTTON_CAPTION, TOOLBAR_COLOR, NAVIGATION_COLOR, CLOSE_BUTTON_COLOR); private InAppBrowserDialog dialog; private WebView inAppWebView; @@ -115,8 +123,12 @@ public class InAppBrowser extends CordovaPlugin { private ValueCallback mUploadCallbackLollipop; private final static int FILECHOOSER_REQUESTCODE = 1; private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2; - private String closeButtonText = ""; - private int closeButtonColor = android.graphics.Color.LTGRAY; + private String closeButtonCaption = ""; + private String closeButtonColor = ""; + private int toolbarColor = android.graphics.Color.LTGRAY; + private boolean hideNavigationButtons = false; + private String navigationButtonColor = ""; + private boolean hideUrlBar = false; /** * Executes the request and returns PluginResult. @@ -386,10 +398,10 @@ public class InAppBrowser extends CordovaPlugin { if (option.hasMoreElements()) { String key = option.nextToken(); String value = null; - if (key.equals(CLOSE_BUTTON_TEXT)) value = option.nextToken(); + if (customizableOptions.contains(key)) value = option.nextToken(); else { String token = option.nextToken(); - value = token.equals("yes") || token.equals("no") ? token : "yes"; // hér!! + value = token.equals("yes") || token.equals("no") ? token : "yes"; } map.put(key, value); } @@ -548,6 +560,12 @@ public class InAppBrowser extends CordovaPlugin { if (show != null) { showLocationBar = show.equals("yes") ? true : false; } + if(showLocationBar) { + String hideNavigation = features.get(HIDE_NAVIGATION); + String hideUrl = features.get(HIDE_URL); + if(hideNavigation != null) hideNavigationButtons = hideNavigation.equals("yes") ? true : false; + if(hideUrl != null) hideUrlBar = hideUrl.equals("yes") ? true : false; + } String zoom = features.get(ZOOM); if (zoom != null) { showZoomControls = zoom.equals("yes") ? true : false; @@ -583,13 +601,21 @@ public class InAppBrowser extends CordovaPlugin { if (wideViewPort != null ) { useWideViewPort = wideViewPort.equals("yes") ? true : false; } - String closeButtonTextSet = features.get(CLOSE_BUTTON_TEXT); - if (closeButtonTextSet != null) { - closeButtonText = closeButtonTextSet; + String closeButtonCaptionSet = features.get(CLOSE_BUTTON_CAPTION); + if (closeButtonCaptionSet != null) { + closeButtonCaption = closeButtonCaptionSet; } - String closeButtonTextColorSet = features.get(CLOSE_BUTTON_COLOR); - if (closeButtonTextColorSet != null) { - closeButtonColor = Color.parseColor(closeButtonTextColorSet); + String closeButtonColorSet = features.get(CLOSE_BUTTON_COLOR); + if (closeButtonColorSet != null) { + closeButtonColor = closeButtonColorSet; + } + String toolbarColorSet = features.get(TOOLBAR_COLOR); + if (toolbarColorSet != null) { + toolbarColor = android.graphics.Color.parseColor(toolbarColorSet); + } + String navigationButtonColorSet = features.get(NAVIGATION_COLOR); + if (navigationButtonColorSet != null) { + navigationButtonColor = navigationButtonColorSet; } } @@ -633,7 +659,7 @@ public class InAppBrowser extends CordovaPlugin { // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); //Please, no more black! - toolbar.setBackgroundColor(closeButtonColor); + toolbar.setBackgroundColor(toolbarColor); toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); @@ -656,6 +682,7 @@ public class InAppBrowser extends CordovaPlugin { Resources activityRes = cordova.getActivity().getResources(); int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName()); Drawable backIcon = activityRes.getDrawable(backResId); + if (navigationButtonColor != "") back.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor)); if (Build.VERSION.SDK_INT >= 16) back.setBackground(null); else @@ -681,6 +708,7 @@ public class InAppBrowser extends CordovaPlugin { forward.setId(Integer.valueOf(3)); int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName()); Drawable fwdIcon = activityRes.getDrawable(fwdResId); + if (navigationButtonColor != "") forward.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor)); if (Build.VERSION.SDK_INT >= 16) forward.setBackground(null); else @@ -721,13 +749,25 @@ public class InAppBrowser extends CordovaPlugin { }); // Close/Done button - if (closeButtonText != "") { - /* Use TextView for text */ + if (closeButtonCaption != "") { + // Use TextView for text TextView close = new TextView(cordova.getActivity()); - close.setText(closeButtonText); - close.setTextSize(25); - back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + close.setText(closeButtonCaption); + close.setTextSize(20); + if (closeButtonColor != "") close.setTextColor(android.graphics.Color.parseColor(closeButtonColor)); + close.setGravity(android.view.Gravity.CENTER_VERTICAL); + RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); + closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + close.setLayoutParams(closeLayoutParams); + + close.setContentDescription("Close Button"); close.setId(Integer.valueOf(5)); + if (Build.VERSION.SDK_INT >= 16) + close.setBackground(null); + else + close.setBackgroundDrawable(null); + back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + close.setPadding(this.dpToPixels(10), 0, this.dpToPixels(10), 0); close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); @@ -744,6 +784,7 @@ public class InAppBrowser extends CordovaPlugin { close.setId(Integer.valueOf(5)); int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); Drawable closeIcon = activityRes.getDrawable(closeResId); + if (closeButtonColor != "") close.setColorFilter(android.graphics.Color.parseColor(closeButtonColor)); if (Build.VERSION.SDK_INT >= 16) close.setBackground(null); else @@ -863,10 +904,9 @@ public class InAppBrowser extends CordovaPlugin { actionButtonContainer.addView(back); actionButtonContainer.addView(forward); - // Add the views to our toolbar - toolbar.addView(actionButtonContainer); - toolbar.addView(edittext); - // toolbar.addView(close); + // Add the views to our toolbar if they haven't been disabled + if (!hideNavigationButtons) toolbar.addView(actionButtonContainer); + if (!hideUrlBar) toolbar.addView(edittext); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index 8f01721..05d72f8 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -53,7 +53,7 @@ @property (nonatomic, copy) NSString* toolbarposition; @property (nonatomic, copy) NSString* toolbarcolor; @property (nonatomic, assign) BOOL toolbartranslucent; -@property (nonatomic, assign) BOOL hideToolbarNavigationButtons; +@property (nonatomic, assign) BOOL hidetoolbarnavigationbuttons; @property (nonatomic, assign) BOOL clearcache; @property (nonatomic, assign) BOOL clearsessioncache; diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index a890f7f..eb3b75d 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -649,7 +649,7 @@ self.backButton.imageInsets = UIEdgeInsetsZero; // Filter out Navigation Buttons if user requests so - if (_browserOptions.hideToolbarNavigationButtons) { + if (_browserOptions.hidetoolbarnavigationbuttons) { [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; } else { [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; @@ -1020,7 +1020,7 @@ self.suppressesincrementalrendering = NO; self.hidden = NO; self.disallowoverscroll = NO; - self.hideToolbarNavigationButtons = NO; + self.hideToolbarnavigationbuttons = NO; self.closebuttoncolor = nil; self.toolbarcolor = nil; self.toolbartranslucent = YES; From 0c6189e1a2214a5d504e21c076087e156f467282 Mon Sep 17 00:00:00 2001 From: Landsbankinn Date: Fri, 6 Oct 2017 15:35:28 +0000 Subject: [PATCH 03/18] change hidetoolbarnavigationbuttons to hidenavigationbuttons in iso --- README.md | 3 ++- src/ios/CDVInAppBrowser.h | 2 +- src/ios/CDVInAppBrowser.m | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6eb0479..c911551 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ instance, or the system browser. - __hidenavigationbuttons__: set to `yes` to hide the navigation buttons on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`. - __hideurlbar__: set to `yes` to hide the url bar on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`. - __navigationbuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color of both navigation buttons from default. Only has effect if user has location set to `yes` and not hidenavigationbuttons set to `yes`. + - __toolbarcolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color the toolbar from default. Only has effect if user has location set to `yes`. - __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`. - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). - __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)). @@ -132,7 +133,7 @@ instance, or the system browser. - __closebuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default __Done__ button's color. Only applicable if toolbar is not disabled. - __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself. - __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property. - - __hidetoolbarnavigationbuttons__: set to `yes` or `no` to turn the toolbar navigation buttons on or off (defaults to `no`). Only applicable if toolbar is not disabled. + - __hidenavigationbuttons__: set to `yes` or `no` to turn the toolbar navigation buttons on or off (defaults to `no`). Only applicable if toolbar is not disabled. - __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`) - __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled. - __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled. diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index 05d72f8..9338c55 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -53,7 +53,7 @@ @property (nonatomic, copy) NSString* toolbarposition; @property (nonatomic, copy) NSString* toolbarcolor; @property (nonatomic, assign) BOOL toolbartranslucent; -@property (nonatomic, assign) BOOL hidetoolbarnavigationbuttons; +@property (nonatomic, assign) BOOL hidenavigationbuttons; @property (nonatomic, assign) BOOL clearcache; @property (nonatomic, assign) BOOL clearsessioncache; diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index eb3b75d..a581472 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -649,7 +649,7 @@ self.backButton.imageInsets = UIEdgeInsetsZero; // Filter out Navigation Buttons if user requests so - if (_browserOptions.hidetoolbarnavigationbuttons) { + if (_browserOptions.hidenavigationbuttons) { [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; } else { [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; @@ -1020,7 +1020,7 @@ self.suppressesincrementalrendering = NO; self.hidden = NO; self.disallowoverscroll = NO; - self.hideToolbarnavigationbuttons = NO; + self.hidenavigationbuttons = NO; self.closebuttoncolor = nil; self.toolbarcolor = nil; self.toolbartranslucent = YES; From 05e37a1ff146a7c74d805a8a39e3aafe67018cef Mon Sep 17 00:00:00 2001 From: Landsbankinn Date: Mon, 9 Oct 2017 13:50:12 +0000 Subject: [PATCH 04/18] ignore idea folder --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2209f42..8bbbbcd 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ Thumbs.db *.user node_modules +.idea @@ -20,5 +21,4 @@ node_modules - - \ No newline at end of file + From cbe3a428f47eca9d0760ac6919b892708505ff4b Mon Sep 17 00:00:00 2001 From: Landsbankinn Date: Tue, 13 Mar 2018 11:39:22 +0000 Subject: [PATCH 05/18] CB-13969 cordova-inappbrowser:iOS&Android now includes a extra, optional parameter to swap position of navigationbuttons and close/done button --- src/android/InAppBrowser.java | 25 ++++++++++++++++++++----- src/ios/CDVInAppBrowser.h | 3 ++- src/ios/CDVInAppBrowser.m | 21 +++++++++++++++------ 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index d8eecdd..69119cc 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -98,6 +98,7 @@ public class InAppBrowser extends CordovaPlugin { private static final String TOOLBAR_COLOR = "toolbarcolor"; private static final String CLOSE_BUTTON_CAPTION = "closebuttoncaption"; private static final String CLOSE_BUTTON_COLOR = "closebuttoncolor"; + private static final String LEFT_TO_RIGHT = "lefttoright"; private static final String HIDE_NAVIGATION = "hidenavigationbuttons"; private static final String NAVIGATION_COLOR = "navigationbuttoncolor"; private static final String HIDE_URL = "hideurlbar"; @@ -125,6 +126,7 @@ public class InAppBrowser extends CordovaPlugin { private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2; private String closeButtonCaption = ""; private String closeButtonColor = ""; + private boolean leftToRight = false; private int toolbarColor = android.graphics.Color.LTGRAY; private boolean hideNavigationButtons = false; private String navigationButtonColor = ""; @@ -609,6 +611,10 @@ public class InAppBrowser extends CordovaPlugin { if (closeButtonColorSet != null) { closeButtonColor = closeButtonColorSet; } + String leftToRightSet = features.get(LEFT_TO_RIGHT); + if (leftToRightSet != null) { + leftToRight = leftToRightSet.equals("yes") ? true : false; + } String toolbarColorSet = features.get(TOOLBAR_COLOR); if (toolbarColorSet != null) { toolbarColor = android.graphics.Color.parseColor(toolbarColorSet); @@ -673,7 +679,8 @@ public class InAppBrowser extends CordovaPlugin { } RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); - closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + if (leftToRight) closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); + else closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); _close.setLayoutParams(closeLayoutParams); if (Build.VERSION.SDK_INT >= 16) @@ -717,15 +724,22 @@ public class InAppBrowser extends CordovaPlugin { toolbar.setBackgroundColor(toolbarColor); toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); - toolbar.setHorizontalGravity(Gravity.LEFT); + if (leftToRight) { + toolbar.setHorizontalGravity(Gravity.LEFT); + } else { + toolbar.setHorizontalGravity(Gravity.RIGHT); + } toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); - actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + RelativeLayout.LayoutParams actionButtonLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + if (leftToRight) actionButtonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + else actionButtonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); + actionButtonContainer.setLayoutParams(actionButtonLayoutParams); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); - actionButtonContainer.setId(Integer.valueOf(1)); + actionButtonContainer.setId(leftToRight ? Integer.valueOf(5) : Integer.valueOf(1)); // Back button ImageButton back = new ImageButton(cordova.getActivity()); @@ -805,7 +819,8 @@ public class InAppBrowser extends CordovaPlugin { // Header Close/Done button - View close = createCloseButton(5); + int closeButtonId = leftToRight ? 1 : 5; + View close = createCloseButton(closeButtonId); toolbar.addView(close); // Footer diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index 9338c55..695a5d3 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -50,6 +50,7 @@ @property (nonatomic, assign) BOOL toolbar; @property (nonatomic, copy) NSString* closebuttoncaption; @property (nonatomic, copy) NSString* closebuttoncolor; +@property (nonatomic, assign) BOOL lefttoright; @property (nonatomic, copy) NSString* toolbarposition; @property (nonatomic, copy) NSString* toolbarcolor; @property (nonatomic, assign) BOOL toolbartranslucent; @@ -103,7 +104,7 @@ - (void)navigateTo:(NSURL*)url; - (void)showLocationBar:(BOOL)show; - (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition; -- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString; +- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex; - (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions; diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index a581472..e7a14ca 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -163,7 +163,8 @@ [self.inAppBrowserViewController showLocationBar:browserOptions.location]; [self.inAppBrowserViewController showToolBar:browserOptions.toolbar :browserOptions.toolbarposition]; if (browserOptions.closebuttoncaption != nil || browserOptions.closebuttoncolor != nil) { - [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption :browserOptions.closebuttoncolor]; + int closeButtonIndex = browserOptions.lefttoright ? (browserOptions.hidenavigationbuttons ? 1 : 4) : 0; + [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption :browserOptions.closebuttoncolor :closeButtonIndex]; } // Set Presentation Style UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default @@ -650,11 +651,18 @@ // Filter out Navigation Buttons if user requests so if (_browserOptions.hidenavigationbuttons) { - [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; + if (_browserOptions.lefttoright) { + [self.toolbar setItems:@[flexibleSpaceButton, self.closeButton]]; + } else { + [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; + } } else { - [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; + if (_browserOptions.lefttoright) { + [self.toolbar setItems:@[self.backButton, fixedSpaceButton, self.forwardButton, flexibleSpaceButton, self.closeButton]]; + } else { + [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; + } } - [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; self.view.backgroundColor = [UIColor grayColor]; [self.view addSubview:self.toolbar]; @@ -667,7 +675,7 @@ [self.webView setFrame:frame]; } -- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString +- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex { // the advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically // but, if you want to set this yourself, knock yourself out (we can't set the title for a system Done button, so we have to create a new one) @@ -679,7 +687,7 @@ self.closeButton.tintColor = colorString != nil ? [self colorFromHexString:colorString] : [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1]; NSMutableArray* items = [self.toolbar.items mutableCopy]; - [items replaceObjectAtIndex:0 withObject:self.closeButton]; + [items replaceObjectAtIndex:buttonIndex withObject:self.closeButton]; [self.toolbar setItems:items]; } @@ -1022,6 +1030,7 @@ self.disallowoverscroll = NO; self.hidenavigationbuttons = NO; self.closebuttoncolor = nil; + self.lefttoright = false; self.toolbarcolor = nil; self.toolbartranslucent = YES; } From b06ad8ed9706a9abc98dc0751cbdb1050b6d62d2 Mon Sep 17 00:00:00 2001 From: Landsbankinn Date: Tue, 13 Mar 2018 11:48:15 +0000 Subject: [PATCH 06/18] CB-13696 fixing for PR --- .gitignore | 9 ++++++++- README.md | 3 ++- src/android/InAppBrowser.java | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 95d76e1..4474e73 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,11 @@ Thumbs.db *.user node_modules -.idea + + + + + + + + diff --git a/README.md b/README.md index 61a23b0..6c3777a 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ instance, or the system browser. All platforms support: - __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off. + - __lefttoright__: Set to `yes` to swap position of the navigation buttons and the close button. Android supports these additional options: @@ -115,7 +116,7 @@ instance, or the system browser. - __closebuttoncaption__: set to a string to use as the close button's caption instead of a X. Note that you need to localize this value yourself. - __closebuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the close button color from default, regardless of being a text or default X. Only has effect if user has location set to `yes`. - - __footer__: set to `yes` to show a close button in the footer similar to the iOS __Done__ button. + - __footer__: set to `yes` to show a close button in the footer similar to the iOS __Done__ button. The close button will appear the same as for the header hence use __closebuttoncaption__ and __closebuttoncolor__ to set its properties. - __footercolor__: set to a valid hex color string, for example `#00ff00` or `#CC00ff00` (`#aarrggbb`) , and it will change the footer color from default. Only has effect if user has __footer__ set to `yes`. diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 69119cc..a73f766 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -6,7 +6,9 @@ to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY From ec6af56fbd0e2d85f932914da576871da507b4c6 Mon Sep 17 00:00:00 2001 From: Fiffi Date: Mon, 23 Apr 2018 16:07:17 +0000 Subject: [PATCH 07/18] remove statusbar when inAppBrowser is open in andriod --- src/android/InAppBrowser.java | 1 + www/inappbrowser.css | 104 +++++++++++++++++----------------- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index a73f766..c61af82 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -713,6 +713,7 @@ public class InAppBrowser extends CordovaPlugin { dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); dialog.setCancelable(true); dialog.setInAppBroswer(getInAppBrowser()); diff --git a/www/inappbrowser.css b/www/inappbrowser.css index 5762c74..3a70cac 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -18,97 +18,97 @@ */ .inAppBrowserWrap { - margin: 0; - padding: 0; - outline: 0; - font-size: 100%; - vertical-align: baseline; - background: 0 0; - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 9999999; - box-sizing: border-box; - border: 40px solid #bfbfbf; - border: 40px solid rgba(0, 0, 0, 0.25); + margin: 0; + padding: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: 0 0; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 9999999; + box-sizing: border-box; + border: 40px solid #bfbfbf; + border: 40px solid rgba(0, 0, 0, 0.25); } .inAppBrowserWrapFullscreen { - border: 0; + border: 0; } .inappbrowser-app-bar { - height: 70px; - background-color: #404040; - z-index: 9999999; + height: 70px; + background-color: #404040; + z-index: 9999999; } .inappbrowser-app-bar-inner { - padding-top: 10px; - height: 60px; - width: 155px; - margin: 0 auto; - background-color: #404040; - z-index: 9999999; + padding-top: 10px; + height: 60px; + width: 155px; + margin: 0 auto; + background-color: #404040; + z-index: 9999999; } .app-bar-action { - width: auto; - height: 40px; - margin-left: 20px; - font-family: "Segoe UI Symbol"; - float: left; - color: white; - font-size: 12px; - text-transform: lowercase; - text-align: center; - cursor: default; + width: auto; + height: 40px; + margin-left: 20px; + font-family: 'Segoe UI Symbol'; + float: left; + color: white; + font-size: 12px; + text-transform: lowercase; + text-align: center; + cursor: default; } .app-bar-action[disabled] { - color: gray; - /*disable click*/ - pointer-events: none; + color: gray; + /*disable click*/ + pointer-events: none; } .app-bar-action::before { - font-size: 28px; - display: block; - height: 36px; + font-size: 28px; + display: block; + height: 36px; } /* Back */ -.action-back { - margin-left: 0px; +.action-back { + margin-left: 0px; } .action-back::before { - content: "\E0BA"; + content: '\E0BA'; } .action-back:not([disabled]):hover::before { - content: "\E0B3"; + content: '\E0B3'; } /* Forward */ .action-forward::before { - content: "\E0AC"; + content: '\E0AC'; } .action-forward:not([disabled]):hover::before { - content: "\E0AF"; + content: '\E0AF'; } /* Close */ .action-close::before { - content: "\E0C7"; - /* close icon is larger so we re-size it to fit other icons */ - font-size: 20px; - line-height: 40px; + content: '\E0C7'; + /* close icon is larger so we re-size it to fit other icons */ + font-size: 20px; + line-height: 40px; } .action-close:not([disabled]):hover::before { - content: "\E0CA"; + content: '\E0CA'; } From 4adf4c7230bb6d2498cd1eb0220d50b93a809339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20=C3=81g=C3=BAst?= Date: Thu, 28 Feb 2019 12:28:58 +0000 Subject: [PATCH 08/18] CB-13969 updating README.MD to better explain lefttoright parameter option, reverting unneccesary indent changes on inappbrowser.css --- README.md | 2 +- www/inappbrowser.css | 219 ++++++++++++++++++++++++++++++++----------- 2 files changed, 167 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index da23eab..a808bb0 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ instance, or the system browser. All platforms support: - __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off. - - __lefttoright__: Set to `yes` to swap position of the navigation buttons and the close button. + - __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically from left to right on iOS, and from right to left for Android(since the default values for the platforms are opposites). Android supports these additional options: diff --git a/www/inappbrowser.css b/www/inappbrowser.css index 3a70cac..9d5cebf 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -1,4 +1,4 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,97 +18,210 @@ */ .inAppBrowserWrap { - margin: 0; - padding: 0; - outline: 0; - font-size: 100%; - vertical-align: baseline; - background: 0 0; - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 9999999; - box-sizing: border-box; - border: 40px solid #bfbfbf; - border: 40px solid rgba(0, 0, 0, 0.25); + margin: 0; + padding: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: 0 0; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 9999999; + box-sizing: border-box; + border: 40px solid #bfbfbf; + border: 40px solid rgba(0, 0, 0, 0.25); } .inAppBrowserWrapFullscreen { - border: 0; + border: 0; } .inappbrowser-app-bar { - height: 70px; - background-color: #404040; - z-index: 9999999; + height: 70px; + background-color: #404040; + z-index: 9999999; } .inappbrowser-app-bar-inner { - padding-top: 10px; - height: 60px; - width: 155px; - margin: 0 auto; - background-color: #404040; - z-index: 9999999; + padding-top: 10px; + height: 60px; + width: 155px; + margin: 0 auto; + background-color: #404040; + z-index: 9999999; } .app-bar-action { - width: auto; - height: 40px; - margin-left: 20px; - font-family: 'Segoe UI Symbol'; - float: left; - color: white; - font-size: 12px; - text-transform: lowercase; - text-align: center; - cursor: default; + width: auto; + height: 40px; + margin-left: 20px; + font-family: "Segoe UI Symbol"; + float: left; + color: white; + font-size: 12px; + text-transform: lowercase; + text-align: center; + cursor: default; } .app-bar-action[disabled] { - color: gray; - /*disable click*/ - pointer-events: none; + color: gray; + /*disable click*/ + pointer-events: none; } .app-bar-action::before { - font-size: 28px; - display: block; - height: 36px; + font-size: 28px; + display: block; + height: 36px; } /* Back */ -.action-back { - margin-left: 0px; +.action-back { + margin-left: 0px; } .action-back::before { - content: '\E0BA'; + content: "\E0BA"; } .action-back:not([disabled]):hover::before { - content: '\E0B3'; + content: "\E0B3"; } /* Forward */ .action-forward::before { - content: '\E0AC'; + content: "\E0AC"; } .action-forward:not([disabled]):hover::before { - content: '\E0AF'; + content: "\E0AF"; } /* Close */ .action-close::before { - content: '\E0C7'; - /* close icon is larger so we re-size it to fit other icons */ - font-size: 20px; - line-height: 40px; + content: "\E0C7"; + /* close icon is larger so we re-size it to fit other icons */ + font-size: 20px; + line-height: 40px; } .action-close:not([disabled]):hover::before { - content: '\E0CA'; + content: "\E0CA"; +}/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +.inAppBrowserWrap { + margin: 0; + padding: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: 0 0; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 9999999; + box-sizing: border-box; + border: 40px solid #bfbfbf; + border: 40px solid rgba(0, 0, 0, 0.25); } + +.inAppBrowserWrapFullscreen { + border: 0; +} + +.inappbrowser-app-bar { + height: 70px; + background-color: #404040; + z-index: 9999999; +} + +.inappbrowser-app-bar-inner { + padding-top: 10px; + height: 60px; + width: 155px; + margin: 0 auto; + background-color: #404040; + z-index: 9999999; +} + +.app-bar-action { + width: auto; + height: 40px; + margin-left: 20px; + font-family: "Segoe UI Symbol"; + float: left; + color: white; + font-size: 12px; + text-transform: lowercase; + text-align: center; + cursor: default; +} + +.app-bar-action[disabled] { + color: gray; + /*disable click*/ + pointer-events: none; +} + +.app-bar-action::before { + font-size: 28px; + display: block; + height: 36px; +} + +/* Back */ +.action-back { + margin-left: 0px; +} + +.action-back::before { + content: "\E0BA"; +} + +.action-back:not([disabled]):hover::before { + content: "\E0B3"; +} + +/* Forward */ +.action-forward::before { + content: "\E0AC"; +} + +.action-forward:not([disabled]):hover::before { + content: "\E0AF"; +} + +/* Close */ +.action-close::before { + content: "\E0C7"; + /* close icon is larger so we re-size it to fit other icons */ + font-size: 20px; + line-height: 40px; +} + +.action-close:not([disabled]):hover::before { + content: "\E0CA"; +} \ No newline at end of file From e2adf1b285c9b17a1d25daa9d9f0928b2f8d352b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20=C3=81g=C3=BAst?= Date: Thu, 28 Feb 2019 12:32:59 +0000 Subject: [PATCH 09/18] CB-13969 fixing inappbrowser.css --- www/inappbrowser.css | 113 ------------------------------------------- 1 file changed, 113 deletions(-) diff --git a/www/inappbrowser.css b/www/inappbrowser.css index 9d5cebf..75da1eb 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -109,119 +109,6 @@ line-height: 40px; } -.action-close:not([disabled]):hover::before { - content: "\E0CA"; -}/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -.inAppBrowserWrap { - margin: 0; - padding: 0; - outline: 0; - font-size: 100%; - vertical-align: baseline; - background: 0 0; - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 9999999; - box-sizing: border-box; - border: 40px solid #bfbfbf; - border: 40px solid rgba(0, 0, 0, 0.25); -} - -.inAppBrowserWrapFullscreen { - border: 0; -} - -.inappbrowser-app-bar { - height: 70px; - background-color: #404040; - z-index: 9999999; -} - -.inappbrowser-app-bar-inner { - padding-top: 10px; - height: 60px; - width: 155px; - margin: 0 auto; - background-color: #404040; - z-index: 9999999; -} - -.app-bar-action { - width: auto; - height: 40px; - margin-left: 20px; - font-family: "Segoe UI Symbol"; - float: left; - color: white; - font-size: 12px; - text-transform: lowercase; - text-align: center; - cursor: default; -} - -.app-bar-action[disabled] { - color: gray; - /*disable click*/ - pointer-events: none; -} - -.app-bar-action::before { - font-size: 28px; - display: block; - height: 36px; -} - -/* Back */ -.action-back { - margin-left: 0px; -} - -.action-back::before { - content: "\E0BA"; -} - -.action-back:not([disabled]):hover::before { - content: "\E0B3"; -} - -/* Forward */ -.action-forward::before { - content: "\E0AC"; -} - -.action-forward:not([disabled]):hover::before { - content: "\E0AF"; -} - -/* Close */ -.action-close::before { - content: "\E0C7"; - /* close icon is larger so we re-size it to fit other icons */ - font-size: 20px; - line-height: 40px; -} - .action-close:not([disabled]):hover::before { content: "\E0CA"; } \ No newline at end of file From c7931faa7e7a3f4dbe8def504609f5421b5130ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20=C3=81g=C3=BAst?= Date: Thu, 28 Feb 2019 12:36:28 +0000 Subject: [PATCH 10/18] CB-13969 adding newline at end of inappbrowser.cs --- www/inappbrowser.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/inappbrowser.css b/www/inappbrowser.css index 75da1eb..e9ccebb 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -111,4 +111,4 @@ .action-close:not([disabled]):hover::before { content: "\E0CA"; -} \ No newline at end of file +} From 5ead1e6a7e6e3394f03371fcffdd819a8d8126ec Mon Sep 17 00:00:00 2001 From: steinaragustli Date: Thu, 28 Feb 2019 12:50:02 +0000 Subject: [PATCH 11/18] CB-13969 trying to remove inappbrowser.css from pr --- www/inappbrowser.css | 1 + 1 file changed, 1 insertion(+) diff --git a/www/inappbrowser.css b/www/inappbrowser.css index e9ccebb..d91fbb6 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -112,3 +112,4 @@ .action-close:not([disabled]):hover::before { content: "\E0CA"; } +sdf From fc0c560bff847a213a29d7fb80f4da3ef4919503 Mon Sep 17 00:00:00 2001 From: steinaragustli Date: Thu, 28 Feb 2019 12:50:53 +0000 Subject: [PATCH 12/18] CB-13969 trying to remove inappbrowser from pr --- www/inappbrowser.css | 1 - 1 file changed, 1 deletion(-) diff --git a/www/inappbrowser.css b/www/inappbrowser.css index d91fbb6..e9ccebb 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -112,4 +112,3 @@ .action-close:not([disabled]):hover::before { content: "\E0CA"; } -sdf From 2bcec4021391da13fbd1f6360468b887b86411d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20=C3=81=2E=20Steinarsson?= Date: Thu, 28 Feb 2019 13:02:04 +0000 Subject: [PATCH 13/18] CB-13969 trying to fix some wierd issue for PR --- www/inappbrowser.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/inappbrowser.css b/www/inappbrowser.css index e9ccebb..3efbe5a 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -1,4 +1,5 @@ -/* +/* sdfsdfsdf + * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information From df84ddabd2295d47ea39c7d96c8c0c1cc569dcf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20=C3=81=2E=20Steinarsson?= Date: Thu, 28 Feb 2019 13:04:21 +0000 Subject: [PATCH 14/18] CB-13969 trying to fix some wierd issue for PR --- www/inappbrowser.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/www/inappbrowser.css b/www/inappbrowser.css index 3efbe5a..e9ccebb 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -1,5 +1,4 @@ -/* sdfsdfsdf - * +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information From 5359f6cf18eadc9fcdd913fe8922afefe43ecdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20=C3=81g=C3=BAst?= Date: Thu, 28 Feb 2019 14:05:05 +0000 Subject: [PATCH 15/18] CB-13969 reverting to older version of inappbrowser.css to leave it out of PR --- www/inappbrowser.css | 106 +++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/www/inappbrowser.css b/www/inappbrowser.css index e9ccebb..3a70cac 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -1,4 +1,4 @@ -/* +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -18,97 +18,97 @@ */ .inAppBrowserWrap { - margin: 0; - padding: 0; - outline: 0; - font-size: 100%; - vertical-align: baseline; - background: 0 0; - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 9999999; - box-sizing: border-box; - border: 40px solid #bfbfbf; - border: 40px solid rgba(0, 0, 0, 0.25); + margin: 0; + padding: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: 0 0; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 9999999; + box-sizing: border-box; + border: 40px solid #bfbfbf; + border: 40px solid rgba(0, 0, 0, 0.25); } .inAppBrowserWrapFullscreen { - border: 0; + border: 0; } .inappbrowser-app-bar { - height: 70px; - background-color: #404040; - z-index: 9999999; + height: 70px; + background-color: #404040; + z-index: 9999999; } .inappbrowser-app-bar-inner { - padding-top: 10px; - height: 60px; - width: 155px; - margin: 0 auto; - background-color: #404040; - z-index: 9999999; + padding-top: 10px; + height: 60px; + width: 155px; + margin: 0 auto; + background-color: #404040; + z-index: 9999999; } .app-bar-action { - width: auto; - height: 40px; - margin-left: 20px; - font-family: "Segoe UI Symbol"; - float: left; - color: white; - font-size: 12px; - text-transform: lowercase; - text-align: center; - cursor: default; + width: auto; + height: 40px; + margin-left: 20px; + font-family: 'Segoe UI Symbol'; + float: left; + color: white; + font-size: 12px; + text-transform: lowercase; + text-align: center; + cursor: default; } .app-bar-action[disabled] { - color: gray; - /*disable click*/ - pointer-events: none; + color: gray; + /*disable click*/ + pointer-events: none; } .app-bar-action::before { - font-size: 28px; - display: block; - height: 36px; + font-size: 28px; + display: block; + height: 36px; } /* Back */ -.action-back { - margin-left: 0px; +.action-back { + margin-left: 0px; } .action-back::before { - content: "\E0BA"; + content: '\E0BA'; } .action-back:not([disabled]):hover::before { - content: "\E0B3"; + content: '\E0B3'; } /* Forward */ .action-forward::before { - content: "\E0AC"; + content: '\E0AC'; } .action-forward:not([disabled]):hover::before { - content: "\E0AF"; + content: '\E0AF'; } /* Close */ .action-close::before { - content: "\E0C7"; - /* close icon is larger so we re-size it to fit other icons */ - font-size: 20px; - line-height: 40px; + content: '\E0C7'; + /* close icon is larger so we re-size it to fit other icons */ + font-size: 20px; + line-height: 40px; } .action-close:not([disabled]):hover::before { - content: "\E0CA"; + content: '\E0CA'; } From 3c0a42e2aedd19a06115e58ac56c3f3ea4a61dc5 Mon Sep 17 00:00:00 2001 From: steinaragustli Date: Thu, 28 Feb 2019 14:11:04 +0000 Subject: [PATCH 16/18] CB-13969 fix inappbrowser.css to be unmodified --- www/inappbrowser.css | 104 +++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/www/inappbrowser.css b/www/inappbrowser.css index 3a70cac..5762c74 100644 --- a/www/inappbrowser.css +++ b/www/inappbrowser.css @@ -18,97 +18,97 @@ */ .inAppBrowserWrap { - margin: 0; - padding: 0; - outline: 0; - font-size: 100%; - vertical-align: baseline; - background: 0 0; - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - z-index: 9999999; - box-sizing: border-box; - border: 40px solid #bfbfbf; - border: 40px solid rgba(0, 0, 0, 0.25); + margin: 0; + padding: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: 0 0; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 9999999; + box-sizing: border-box; + border: 40px solid #bfbfbf; + border: 40px solid rgba(0, 0, 0, 0.25); } .inAppBrowserWrapFullscreen { - border: 0; + border: 0; } .inappbrowser-app-bar { - height: 70px; - background-color: #404040; - z-index: 9999999; + height: 70px; + background-color: #404040; + z-index: 9999999; } .inappbrowser-app-bar-inner { - padding-top: 10px; - height: 60px; - width: 155px; - margin: 0 auto; - background-color: #404040; - z-index: 9999999; + padding-top: 10px; + height: 60px; + width: 155px; + margin: 0 auto; + background-color: #404040; + z-index: 9999999; } .app-bar-action { - width: auto; - height: 40px; - margin-left: 20px; - font-family: 'Segoe UI Symbol'; - float: left; - color: white; - font-size: 12px; - text-transform: lowercase; - text-align: center; - cursor: default; + width: auto; + height: 40px; + margin-left: 20px; + font-family: "Segoe UI Symbol"; + float: left; + color: white; + font-size: 12px; + text-transform: lowercase; + text-align: center; + cursor: default; } .app-bar-action[disabled] { - color: gray; - /*disable click*/ - pointer-events: none; + color: gray; + /*disable click*/ + pointer-events: none; } .app-bar-action::before { - font-size: 28px; - display: block; - height: 36px; + font-size: 28px; + display: block; + height: 36px; } /* Back */ -.action-back { - margin-left: 0px; +.action-back { + margin-left: 0px; } .action-back::before { - content: '\E0BA'; + content: "\E0BA"; } .action-back:not([disabled]):hover::before { - content: '\E0B3'; + content: "\E0B3"; } /* Forward */ .action-forward::before { - content: '\E0AC'; + content: "\E0AC"; } .action-forward:not([disabled]):hover::before { - content: '\E0AF'; + content: "\E0AF"; } /* Close */ .action-close::before { - content: '\E0C7'; - /* close icon is larger so we re-size it to fit other icons */ - font-size: 20px; - line-height: 40px; + content: "\E0C7"; + /* close icon is larger so we re-size it to fit other icons */ + font-size: 20px; + line-height: 40px; } .action-close:not([disabled]):hover::before { - content: '\E0CA'; + content: "\E0CA"; } From 9c7c2f31d8eb60f1a5141dbdd8aa83feb64e6e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20=C3=81g=C3=BAst?= Date: Thu, 28 Feb 2019 14:39:26 +0000 Subject: [PATCH 17/18] CB-13969 functionality extended to WKWebView --- src/ios/CDVWKInAppBrowser.h | 2 +- src/ios/CDVWKInAppBrowser.m | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ios/CDVWKInAppBrowser.h b/src/ios/CDVWKInAppBrowser.h index 0015cea..1f359b1 100644 --- a/src/ios/CDVWKInAppBrowser.h +++ b/src/ios/CDVWKInAppBrowser.h @@ -73,7 +73,7 @@ - (void)navigateTo:(NSURL*)url; - (void)showLocationBar:(BOOL)show; - (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition; -- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString; +- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex; - (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions; diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 6364f4f..3b039f5 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -228,7 +228,8 @@ static CDVWKInAppBrowser* instance = nil; [self.inAppBrowserViewController showLocationBar:browserOptions.location]; [self.inAppBrowserViewController showToolBar:browserOptions.toolbar :browserOptions.toolbarposition]; if (browserOptions.closebuttoncaption != nil || browserOptions.closebuttoncolor != nil) { - [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption :browserOptions.closebuttoncolor]; + int closeButtonIndex = browserOptions.lefttoright ? (browserOptions.hidenavigationbuttons ? 1 : 4) : 0; + [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption :browserOptions.closebuttoncolor :closeButtonIndex]; } // Set Presentation Style UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default @@ -884,9 +885,15 @@ BOOL isExiting = FALSE; // Filter out Navigation Buttons if user requests so if (_browserOptions.hidenavigationbuttons) { - [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; + if (_browserOptions.lefttoright) { + [self.toolbar setItems:@[flexibleSpaceButton, self.closeButton]]; + } else { + [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton]]; + } + } else if (_browserOptions.lefttoright) { + [self.toolbar setItems:@[self.backButton, fixedSpaceButton, self.forwardButton, flexibleSpaceButton, self.closeButton]]; } else { - [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; + [self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]]; } self.view.backgroundColor = [UIColor grayColor]; @@ -900,7 +907,7 @@ BOOL isExiting = FALSE; [self.webView setFrame:frame]; } -- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString +- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex { // the advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically // but, if you want to set this yourself, knock yourself out (we can't set the title for a system Done button, so we have to create a new one) @@ -912,7 +919,7 @@ BOOL isExiting = FALSE; self.closeButton.tintColor = colorString != nil ? [self colorFromHexString:colorString] : [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1]; NSMutableArray* items = [self.toolbar.items mutableCopy]; - [items replaceObjectAtIndex:0 withObject:self.closeButton]; + [items replaceObjectAtIndex:buttonIndex withObject:self.closeButton]; [self.toolbar setItems:items]; } From f8616553824243114901fe2a2b812a82485b78cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steinar=20=C3=81g=C3=BAst?= Date: Thu, 28 Feb 2019 15:17:24 +0000 Subject: [PATCH 18/18] CB-13969 fixing README to be correct for lefttoright option --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a808bb0..a08fad9 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,6 @@ instance, or the system browser. All platforms support: - __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off. - - __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically from left to right on iOS, and from right to left for Android(since the default values for the platforms are opposites). Android supports these additional options: @@ -124,6 +123,7 @@ instance, or the system browser. - __hideurlbar__: set to `yes` to hide the url bar on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`. - __navigationbuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color of both navigation buttons from default. Only has effect if user has location set to `yes` and not hidenavigationbuttons set to `yes`. - __toolbarcolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color the toolbar from default. Only has effect if user has location set to `yes`. + - __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, navigation buttons go to the left and close button to the right. - __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`. - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). - __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)). @@ -145,6 +145,7 @@ instance, or the system browser. - __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`) - __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled. - __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled. + - __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, close button goes to the right and navigation buttons to the left. - __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`) on iOS 10+. - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`). - __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).