Skip to content

Commit

Permalink
Allow ChildBrowser to read file:// links
Browse files Browse the repository at this point in the history
  • Loading branch information
macdonst authored and purplecabbage committed May 16, 2012
1 parent 9dd92c1 commit b1d1f3c
Showing 1 changed file with 7 additions and 4 deletions.
Expand Up @@ -179,10 +179,11 @@ private void navigate(String url) {
InputMethodManager imm = (InputMethodManager)this.ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);

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

Expand Down Expand Up @@ -238,6 +239,7 @@ public void onDismiss(DialogInterface dialog) {
main.setOrientation(LinearLayout.VERTICAL);

LinearLayout toolbar = new LinearLayout(ctx.getContext());
toolbar.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
toolbar.setOrientation(LinearLayout.HORIZONTAL);

ImageButton back = new ImageButton(ctx.getContext());
Expand Down Expand Up @@ -284,7 +286,7 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {
edittext.setText(url);
edittext.setLayoutParams(editParams);

ImageButton close = new ImageButton((Context) ctx);
ImageButton close = new ImageButton(ctx.getContext());
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
closeDialog();
Expand All @@ -301,6 +303,7 @@ public void onClick(View v) {
webview = new WebView(ctx.getContext());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setPluginsEnabled(true);
WebViewClient client = new ChildBrowserClient(edittext);
webview.setWebViewClient(client);
webview.loadUrl(url);
Expand Down Expand Up @@ -379,7 +382,7 @@ public ChildBrowserClient(EditText mEditText) {
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
String newloc;
if (url.startsWith("http:") || url.startsWith("https:")) {
if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
newloc = url;
} else {
newloc = "http://" + url;
Expand Down

0 comments on commit b1d1f3c

Please sign in to comment.