Skip to content

Commit 887f72f

Browse files
authored
Cosmetic Changes (2)
1 parent dd74c9b commit 887f72f

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/android/InAppBrowser.java

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ Licensed to the Apache Software Foundation (ASF) under one
8585
import java.util.HashMap;
8686
import java.util.StringTokenizer;
8787

88+
import java.net.URI;
89+
import java.net.URISyntaxException;
90+
8891
@SuppressLint("SetJavaScriptEnabled")
8992
public class InAppBrowser extends CordovaPlugin {
9093

@@ -925,10 +928,10 @@ public void onClick(View v) {
925928
edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
926929
edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
927930
edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE
928-
edittext.setTextSize(15);
931+
edittext.setTextSize(17);
929932
edittext.setTextColor(android.graphics.Color.argb(150, 255,255,255));
930933
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));
932935
edittext.setOnKeyListener(new View.OnKeyListener() {
933936
public boolean onKey(View v, int keyCode, KeyEvent event) {
934937
// 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) {
976979
closeButtonContainer.setId(Integer.valueOf(5));
977980

978981
// Close/Done button
979-
int closeButtonId = leftToRight ? 1 : 7;
982+
int closeButtonId = 1;
980983
ImageButton closeButton = createImageButton(closeButtonId, "ic_action_remove_white");
981984
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));
983986
closeButton.setOnClickListener(new View.OnClickListener(){
984987
public void onClick(View v){
985988
closeDialog();
@@ -989,7 +992,7 @@ public void onClick(View v){
989992
// Share button
990993
int shareButtonId=8;
991994
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));
993996
shareButton.setContentDescription("Share Button");
994997
shareButton.setOnClickListener(new View.OnClickListener() {
995998
public void onClick(View v) {
@@ -1004,15 +1007,15 @@ public void onClick(View v) {
10041007
});
10051008

10061009
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);
10081011
closeButton.setLayoutParams(closeLayoutParams);
10091012

10101013
RelativeLayout.LayoutParams shareLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
10111014
shareLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
10121015
shareButton.setLayoutParams(shareLayoutParams);
10131016

10141017

1015-
closeButtonContainer.addView((View)closeButton);
1018+
toolbar.addView((View)closeButton);
10161019
closeButtonContainer.addView((View)shareButton);
10171020

10181021
// WebView
@@ -1467,7 +1470,20 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
14671470

14681471
// Update the UI if we haven't already
14691472
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+
}
14711487
}
14721488

14731489
try {
@@ -1599,3 +1615,4 @@ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, Str
15991615
}
16001616
}
16011617
}
1618+

0 commit comments

Comments
 (0)