Skip to content

Commit

Permalink
Fix for Issue #139: New Child Browser: can't get keyboard when show l…
Browse files Browse the repository at this point in the history
…oc bar : true (android)
  • Loading branch information
macdonst authored and Jesse MacFadyen committed Oct 20, 2011
1 parent c216d57 commit cc12250
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.json.JSONObject;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
Expand All @@ -26,6 +27,7 @@
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
Expand All @@ -46,6 +48,7 @@ public class ChildBrowser extends Plugin {

private Dialog dialog;
private WebView webview;
private EditText edittext;
private boolean showLocationBar = true;

/**
Expand Down Expand Up @@ -166,11 +169,15 @@ private void goForward() {
*
* @param url to load
*/
private void navigate(String url) {
private void navigate(String url) {
InputMethodManager imm = (InputMethodManager)this.ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);

if (!url.startsWith("http")) {
this.webview.loadUrl("http://" + url);
}
this.webview.loadUrl(url);
this.webview.requestFocus();
}


Expand Down Expand Up @@ -255,7 +262,7 @@ public void onClick(View v) {
}
forward.setLayoutParams(forwardParams);

final EditText edittext = new EditText(ctx);
edittext = new EditText(ctx);
edittext.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "enter" button
Expand All @@ -270,7 +277,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
edittext.setSingleLine(true);
edittext.setText(url);
edittext.setLayoutParams(editParams);

ImageButton close = new ImageButton(ctx);
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Expand All @@ -292,6 +299,7 @@ public void onClick(View v) {
webview.loadUrl(url);
webview.setId(5);
webview.setLayoutParams(wvParams);
webview.requestFocus();

toolbar.addView(back);
toolbar.addView(forward);
Expand Down

0 comments on commit cc12250

Please sign in to comment.