X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fdialogs%2FAddDomainDialog.java;h=5b18fe4dced69b8a0206e00cbc3e631a3e4b8add;hp=e4cf59f05d9a5da9c2f88da7245d55df7e57856b;hb=ade33e21bbdc373ee391b1105d94aeb1aac1b80d;hpb=b3b4105e9acd9cf8e202abef3b811d49c6c36bec diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java b/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java index e4cf59f0..5b18fe4d 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/dialogs/AddDomainDialog.java @@ -24,6 +24,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.net.Uri; import android.os.Bundle; // We have to use `AppCompatDialogFragment` instead of `DialogFragment` or an error is produced on API <= 22. import android.support.annotation.NonNull; @@ -34,6 +35,7 @@ import android.view.WindowManager; import android.widget.EditText; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; public class AddDomainDialog extends AppCompatDialogFragment { // The public interface is used to send information back to the parent activity. @@ -93,11 +95,17 @@ public class AddDomainDialog extends AppCompatDialogFragment { // Show the keyboard when the `AlertDialog` is displayed on the screen. alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); - // We need to show the `AlertDialog` before w3e can call `setOnKeyListener()` below. + // We need to show the `AlertDialog` before we can edit the contents. alertDialog.show(); - // Allow the `enter` key on the keyboard to create the domain from `add_domain_edittext`. + // Get a handle for `domain_name_edittext`. EditText addDomainEditText = (EditText) alertDialog.findViewById(R.id.domain_name_edittext); + + // Get the current domain from `formattedUrlString`. + Uri currentUri = Uri.parse(MainWebViewActivity.formattedUrlString); + addDomainEditText.setText(currentUri.getHost()); + + // Allow the `enter` key on the keyboard to create the domain from `add_domain_edittext`. addDomainEditText.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View view, int keyCode, KeyEvent event) { // If the event is a key-down on the `enter` key, select the `PositiveButton` `Add`.