Get forward and back gestures working, and hide the title bar. Hiding the action bar still eludes me.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4219 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
a32bb02223
commit
37edbd9824
@ -9,6 +9,8 @@ import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.webkit.JsResult;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebView;
|
||||
@ -24,12 +26,15 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
WebView web_view;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
WebView web = (WebView)findViewById(R.id.web);
|
||||
web_view = (WebView)findViewById(R.id.web);
|
||||
Log.w("tildefriends", String.format("getFilesDir() is %s", getFilesDir().toString()));
|
||||
Log.w("tildefriends", String.format("getPackageResourcePath() is %s", getPackageResourcePath().toString()));
|
||||
|
||||
@ -75,11 +80,11 @@ public class MainActivity extends Activity {
|
||||
Thread.sleep(1000);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
web.getSettings().setJavaScriptEnabled(true);
|
||||
web.getSettings().setDatabaseEnabled(true);
|
||||
web.getSettings().setDomStorageEnabled(true);
|
||||
web_view.getSettings().setJavaScriptEnabled(true);
|
||||
web_view.getSettings().setDatabaseEnabled(true);
|
||||
web_view.getSettings().setDomStorageEnabled(true);
|
||||
|
||||
web.setWebChromeClient(new WebChromeClient() {
|
||||
web_view.setWebChromeClient(new WebChromeClient() {
|
||||
@Override
|
||||
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
|
||||
new AlertDialog.Builder(view.getContext())
|
||||
@ -105,7 +110,7 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
web.setWebViewClient(new WebViewClient() {
|
||||
web_view.setWebViewClient(new WebViewClient() {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url)
|
||||
{
|
||||
@ -118,6 +123,23 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
web.loadUrl("http://127.0.0.1:12345/");
|
||||
web_view.loadUrl("http://127.0.0.1:12345/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && web_view.canGoBack()) {
|
||||
web_view.goBack();
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_FORWARD && web_view.canGoForward()) {
|
||||
web_view.goForward();
|
||||
return true;
|
||||
/*
|
||||
} else if (keyCode == KeyEvent.KEYCODE_REFRESH) {
|
||||
web_view.reload();
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
<WebView
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user