@@ -98,6 +98,7 @@ public class InAppBrowser extends CordovaPlugin {
98
98
private static final String TOOLBAR_COLOR = "toolbarcolor" ;
99
99
private static final String CLOSE_BUTTON_CAPTION = "closebuttoncaption" ;
100
100
private static final String CLOSE_BUTTON_COLOR = "closebuttoncolor" ;
101
+ private static final String LEFT_TO_RIGHT = "lefttoright" ;
101
102
private static final String HIDE_NAVIGATION = "hidenavigationbuttons" ;
102
103
private static final String NAVIGATION_COLOR = "navigationbuttoncolor" ;
103
104
private static final String HIDE_URL = "hideurlbar" ;
@@ -125,6 +126,7 @@ public class InAppBrowser extends CordovaPlugin {
125
126
private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2 ;
126
127
private String closeButtonCaption = "" ;
127
128
private String closeButtonColor = "" ;
129
+ private boolean leftToRight = false ;
128
130
private int toolbarColor = android .graphics .Color .LTGRAY ;
129
131
private boolean hideNavigationButtons = false ;
130
132
private String navigationButtonColor = "" ;
@@ -609,6 +611,10 @@ public String showWebPage(final String url, HashMap<String, String> features) {
609
611
if (closeButtonColorSet != null ) {
610
612
closeButtonColor = closeButtonColorSet ;
611
613
}
614
+ String leftToRightSet = features .get (LEFT_TO_RIGHT );
615
+ if (leftToRightSet != null ) {
616
+ leftToRight = leftToRightSet .equals ("yes" ) ? true : false ;
617
+ }
612
618
String toolbarColorSet = features .get (TOOLBAR_COLOR );
613
619
if (toolbarColorSet != null ) {
614
620
toolbarColor = android .graphics .Color .parseColor (toolbarColorSet );
@@ -673,7 +679,8 @@ private View createCloseButton(int id){
673
679
}
674
680
675
681
RelativeLayout .LayoutParams closeLayoutParams = new RelativeLayout .LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .MATCH_PARENT );
676
- closeLayoutParams .addRule (RelativeLayout .ALIGN_PARENT_RIGHT );
682
+ if (leftToRight ) closeLayoutParams .addRule (RelativeLayout .ALIGN_PARENT_LEFT );
683
+ else closeLayoutParams .addRule (RelativeLayout .ALIGN_PARENT_RIGHT );
677
684
_close .setLayoutParams (closeLayoutParams );
678
685
679
686
if (Build .VERSION .SDK_INT >= 16 )
@@ -717,15 +724,22 @@ public void run() {
717
724
toolbar .setBackgroundColor (toolbarColor );
718
725
toolbar .setLayoutParams (new RelativeLayout .LayoutParams (LayoutParams .MATCH_PARENT , this .dpToPixels (44 )));
719
726
toolbar .setPadding (this .dpToPixels (2 ), this .dpToPixels (2 ), this .dpToPixels (2 ), this .dpToPixels (2 ));
720
- toolbar .setHorizontalGravity (Gravity .LEFT );
727
+ if (leftToRight ) {
728
+ toolbar .setHorizontalGravity (Gravity .LEFT );
729
+ } else {
730
+ toolbar .setHorizontalGravity (Gravity .RIGHT );
731
+ }
721
732
toolbar .setVerticalGravity (Gravity .TOP );
722
733
723
734
// Action Button Container layout
724
735
RelativeLayout actionButtonContainer = new RelativeLayout (cordova .getActivity ());
725
- actionButtonContainer .setLayoutParams (new RelativeLayout .LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .WRAP_CONTENT ));
736
+ RelativeLayout .LayoutParams actionButtonLayoutParams = new RelativeLayout .LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .WRAP_CONTENT );
737
+ if (leftToRight ) actionButtonLayoutParams .addRule (RelativeLayout .ALIGN_PARENT_RIGHT );
738
+ else actionButtonLayoutParams .addRule (RelativeLayout .ALIGN_PARENT_LEFT );
739
+ actionButtonContainer .setLayoutParams (actionButtonLayoutParams );
726
740
actionButtonContainer .setHorizontalGravity (Gravity .LEFT );
727
741
actionButtonContainer .setVerticalGravity (Gravity .CENTER_VERTICAL );
728
- actionButtonContainer .setId (Integer .valueOf (1 ));
742
+ actionButtonContainer .setId (leftToRight ? Integer . valueOf ( 5 ) : Integer .valueOf (1 ));
729
743
730
744
// Back button
731
745
ImageButton back = new ImageButton (cordova .getActivity ());
@@ -805,7 +819,8 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
805
819
806
820
807
821
// Header Close/Done button
808
- View close = createCloseButton (5 );
822
+ int closeButtonId = leftToRight ? 1 : 5 ;
823
+ View close = createCloseButton (closeButtonId );
809
824
toolbar .addView (close );
810
825
811
826
// Footer
0 commit comments