Merge remote-tracking branch 'upstream/master'
diff --git a/README.md b/README.md
index 3ca029f..da23eab 100644
--- a/README.md
+++ b/README.md
@@ -104,6 +104,7 @@
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:
diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java
index 895b543..048b02a 100644
--- a/src/android/InAppBrowser.java
+++ b/src/android/InAppBrowser.java
@@ -110,6 +110,7 @@
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";
@@ -138,6 +139,7 @@
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 = "";
@@ -679,6 +681,10 @@
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);
@@ -746,7 +752,8 @@
}
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)
@@ -777,6 +784,7 @@
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());
@@ -790,15 +798,22 @@
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());
@@ -878,7 +893,8 @@
// 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/CDVInAppBrowserOptions.h b/src/ios/CDVInAppBrowserOptions.h
index 29fd6e1..d9f46bf 100644
--- a/src/ios/CDVInAppBrowserOptions.h
+++ b/src/ios/CDVInAppBrowserOptions.h
@@ -25,6 +25,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;
diff --git a/src/ios/CDVInAppBrowserOptions.m b/src/ios/CDVInAppBrowserOptions.m
index 60e45fc..4e62539 100644
--- a/src/ios/CDVInAppBrowserOptions.m
+++ b/src/ios/CDVInAppBrowserOptions.m
@@ -44,6 +44,7 @@
self.disallowoverscroll = NO;
self.hidenavigationbuttons = NO;
self.closebuttoncolor = nil;
+ self.lefttoright = false;
self.toolbarcolor = nil;
self.toolbartranslucent = YES;
self.beforeload = @"";
diff --git a/src/ios/CDVUIInAppBrowser.h b/src/ios/CDVUIInAppBrowser.h
index a545833..0a58d2b 100644
--- a/src/ios/CDVUIInAppBrowser.h
+++ b/src/ios/CDVUIInAppBrowser.h
@@ -84,7 +84,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/CDVUIInAppBrowser.m b/src/ios/CDVUIInAppBrowser.m
index 5e3e900..a294a2b 100644
--- a/src/ios/CDVUIInAppBrowser.m
+++ b/src/ios/CDVUIInAppBrowser.m
@@ -172,7 +172,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
@@ -763,9 +764,15 @@
// 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];
@@ -779,7 +786,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)
@@ -791,7 +798,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];
}
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';
}