Enable WebView prompts and localStorage and stuff.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4216 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		| @@ -1,12 +1,16 @@ | ||||
| package com.unprompted.tildefriends; | ||||
|  | ||||
| import android.app.Activity; | ||||
| import android.app.AlertDialog; | ||||
| import android.content.DialogInterface; | ||||
| import android.content.Intent; | ||||
| import android.net.Uri; | ||||
| import android.os.Bundle; | ||||
| import android.os.CountDownTimer; | ||||
| import android.os.SystemClock; | ||||
| import android.util.Log; | ||||
| import android.webkit.JsResult; | ||||
| import android.webkit.WebChromeClient; | ||||
| import android.webkit.WebView; | ||||
| import android.webkit.WebViewClient; | ||||
| import java.lang.Process; | ||||
| @@ -72,8 +76,37 @@ public class MainActivity extends Activity { | ||||
| 		} catch (java.lang.InterruptedException e) { | ||||
| 		} | ||||
|  		web.getSettings().setJavaScriptEnabled(true); | ||||
|  		web.getSettings().setDatabaseEnabled(true); | ||||
|  		web.getSettings().setDomStorageEnabled(true); | ||||
|  | ||||
| 		web.setWebChromeClient(new WebChromeClient() { | ||||
| 			@Override | ||||
| 			public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { | ||||
| 				new AlertDialog.Builder(view.getContext()) | ||||
| 					.setTitle("Tilde Friends") | ||||
| 					.setMessage(message) | ||||
| 					.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() | ||||
| 					{ | ||||
| 						public void onClick(DialogInterface dialog, int which) | ||||
| 						{ | ||||
| 							result.confirm(); | ||||
| 						} | ||||
| 					}) | ||||
| 					.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() | ||||
| 					{ | ||||
| 						public void onClick(DialogInterface dialog, int which) | ||||
| 						{ | ||||
| 							result.cancel(); | ||||
| 						} | ||||
| 					}) | ||||
| 					.create() | ||||
| 					.show(); | ||||
| 				return true; | ||||
| 			} | ||||
| 		}); | ||||
|  | ||||
| 		web.setWebViewClient(new WebViewClient() { | ||||
| 			@Override | ||||
| 			public boolean shouldOverrideUrlLoading(WebView view, String url) | ||||
| 			{ | ||||
| 				if (url != null && url.startsWith("http://127.0.0.1:12345/")) { | ||||
| @@ -85,6 +118,6 @@ public class MainActivity extends Activity { | ||||
| 			} | ||||
| 		}); | ||||
|  | ||||
| 		web.loadUrl("http://127.0.0.1:12345/~core/apps/"); | ||||
| 		web.loadUrl("http://127.0.0.1:12345/"); | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user