@@ -85,6 +85,9 @@ Licensed to the Apache Software Foundation (ASF) under one
85
85
import java .util .HashMap ;
86
86
import java .util .StringTokenizer ;
87
87
88
+ import java .net .URI ;
89
+ import java .net .URISyntaxException ;
90
+
88
91
@ SuppressLint ("SetJavaScriptEnabled" )
89
92
public class InAppBrowser extends CordovaPlugin {
90
93
@@ -925,10 +928,10 @@ public void onClick(View v) {
925
928
edittext .setInputType (InputType .TYPE_TEXT_VARIATION_URI );
926
929
edittext .setImeOptions (EditorInfo .IME_ACTION_GO );
927
930
edittext .setInputType (InputType .TYPE_NULL ); // Will not except input... Makes the text NON-EDITABLE
928
- edittext .setTextSize (15 );
931
+ edittext .setTextSize (17 );
929
932
edittext .setTextColor (android .graphics .Color .argb (150 , 255 ,255 ,255 ));
930
933
edittext .setBackgroundColor (android .graphics .Color .argb (0 ,0 ,0 ,0 ));
931
- edittext .setPadding (0 , this .dpToPixels (10 ), this . dpToPixels ( 8 ) , this .dpToPixels (10 ));
934
+ edittext .setPadding (10 , this .dpToPixels (10 ), 10 , this .dpToPixels (10 ));
932
935
edittext .setOnKeyListener (new View .OnKeyListener () {
933
936
public boolean onKey (View v , int keyCode , KeyEvent event ) {
934
937
// If the event is a key-down event on the "enter" button
@@ -976,10 +979,10 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
976
979
closeButtonContainer .setId (Integer .valueOf (5 ));
977
980
978
981
// Close/Done button
979
- int closeButtonId = leftToRight ? 1 : 7 ;
982
+ int closeButtonId = 1 ;
980
983
ImageButton closeButton = createImageButton (closeButtonId , "ic_action_remove_white" );
981
984
closeButton .setContentDescription ("Close Button" );
982
- closeButton .setPadding (0 , this .dpToPixels (15 ), 0 , this .dpToPixels (15 ));
985
+ closeButton .setPadding (15 , this .dpToPixels (10 ), 15 , this .dpToPixels (10 ));
983
986
closeButton .setOnClickListener (new View .OnClickListener (){
984
987
public void onClick (View v ){
985
988
closeDialog ();
@@ -989,7 +992,7 @@ public void onClick(View v){
989
992
// Share button
990
993
int shareButtonId =8 ;
991
994
ImageButton shareButton = createImageButton (shareButtonId , "ic_action_share" );
992
- shareButton .setPadding (5 , this .dpToPixels (15 ), 5 , this .dpToPixels (15 ));
995
+ shareButton .setPadding (15 , this .dpToPixels (10 ), 15 , this .dpToPixels (10 ));
993
996
shareButton .setContentDescription ("Share Button" );
994
997
shareButton .setOnClickListener (new View .OnClickListener () {
995
998
public void onClick (View v ) {
@@ -1004,15 +1007,15 @@ public void onClick(View v) {
1004
1007
});
1005
1008
1006
1009
RelativeLayout .LayoutParams closeLayoutParams = new RelativeLayout .LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .MATCH_PARENT );
1007
- closeLayoutParams .addRule (RelativeLayout .RIGHT_OF , shareButtonId );
1010
+ closeLayoutParams .addRule (RelativeLayout .ALIGN_LEFT );
1008
1011
closeButton .setLayoutParams (closeLayoutParams );
1009
1012
1010
1013
RelativeLayout .LayoutParams shareLayoutParams = new RelativeLayout .LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .MATCH_PARENT );
1011
1014
shareLayoutParams .addRule (RelativeLayout .ALIGN_LEFT );
1012
1015
shareButton .setLayoutParams (shareLayoutParams );
1013
1016
1014
1017
1015
- closeButtonContainer .addView ((View )closeButton );
1018
+ toolbar .addView ((View )closeButton );
1016
1019
closeButtonContainer .addView ((View )shareButton );
1017
1020
1018
1021
// WebView
@@ -1467,7 +1470,20 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
1467
1470
1468
1471
// Update the UI if we haven't already
1469
1472
if (!newloc .equals (edittext .getText ().toString ())) {
1470
- edittext .setText (newloc );
1473
+ try {
1474
+ URI uri = new URI (newloc );
1475
+ String domain = uri .getHost (); // Extract the domain from the URL
1476
+ if (domain != null ) {
1477
+ // Removing any leading "www." from the domain
1478
+ if (domain .startsWith ("www." )) {
1479
+ domain = domain .substring (4 );
1480
+ }
1481
+ edittext .setText (domain ); // Set the domain to the EditText
1482
+ }
1483
+ } catch (URISyntaxException e ) {
1484
+ e .printStackTrace ();
1485
+ edittext .setText (newloc );
1486
+ }
1471
1487
}
1472
1488
1473
1489
try {
@@ -1599,3 +1615,4 @@ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, Str
1599
1615
}
1600
1616
}
1601
1617
}
1618
+
0 commit comments