Skip to content

Commit

Permalink
Added option to load webui in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
poliva committed Jan 5, 2013
1 parent 4204559 commit 14a08f1
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 80 deletions.
6 changes: 3 additions & 3 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.radare.installer"
android:versionCode="20"
android:versionName="2.0">
android:versionCode="21"
android:versionName="2.1">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="jackpal.androidterm.permission.RUN_SCRIPT" />
Expand Down Expand Up @@ -30,7 +30,7 @@
</intent-filter>
</activity>
<activity android:name=".MainActivity" android:label="radare2 installer" android:launchMode="singleInstance" android:configChanges="orientation|screenSize" />
<activity android:name=".WebActivity" android:label="radare2 web" android:launchMode="singleInstance" android:configChanges="keyboardHidden|orientation|screenSize" />
<activity android:name=".WebActivity" android:label="radare2 http" android:launchMode="singleInstance" android:configChanges="keyboardHidden|orientation|screenSize" />
<activity android:name=".LauncherActivity" android:label="radare2 console" android:excludeFromRecents="true" android:launchMode="singleInstance" />
<activity android:name=".SettingsActivity" android:label="radare2 settings" />
<receiver android:name=".BootReceiver">
Expand Down
9 changes: 8 additions & 1 deletion res/layout/launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ android:padding="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Web" />
android:text="WebView" />

<RadioButton
android:textColor="#ff000000"
android:id="@+id/radiobutton_browser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Browser" />

<RadioButton
android:textColor="#ff000000"
Expand Down
16 changes: 16 additions & 0 deletions src/org/radare/installer/LaunchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public void onCreate(Bundle savedInstanceState) {
if (open_mode.equals("web")) {
radiogroup.check(R.id.radiobutton_web);
}
if (open_mode.equals("browser")) {
radiogroup.check(R.id.radiobutton_browser);
}
if (open_mode.equals("console")) {
radiogroup.check(R.id.radiobutton_console);
}
Expand Down Expand Up @@ -88,6 +91,13 @@ public void onCreate(Bundle savedInstanceState) {
}
}

@Override
public void onDestroy()
{
mUtils.killradare();
super.onDestroy();
}

public void addListenerOnButton() {

radiogroup = (RadioGroup) findViewById(R.id.radiogroup1);
Expand All @@ -112,6 +122,12 @@ public void onClick(View v) {
intent1.putExtras(b);
startActivity(intent1);
break;
case R.id.radiobutton_browser :
mUtils.StorePref("open_mode","browser");
Intent intent3 = new Intent(LaunchActivity.this, WebActivity.class);
intent3.putExtras(b);
startActivity(intent3);
break;
case R.id.radiobutton_console :
mUtils.StorePref("open_mode","console");
Intent intent2 = new Intent(LaunchActivity.this, LauncherActivity.class);
Expand Down
9 changes: 9 additions & 0 deletions src/org/radare/installer/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,13 @@ public void output(int id, String line)
return radare_output.toString();
}

public void killradare() {
RootTools.useRoot = false;
if (RootTools.isProcessRunning("radare2")) {
RootTools.killProcess("radare2");
}
}



}
157 changes: 81 additions & 76 deletions src/org/radare/installer/WebActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;

import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.net.Uri;

import android.widget.Toast;

Expand Down Expand Up @@ -55,11 +57,7 @@ public void onCreate(Bundle savedInstanceState) {
}

// make sure we don't start a second instance of radare webserver
// we can't use killradare() here because it finishes the activity
if (RootTools.isProcessRunning("radare2")) {
RootTools.killProcess("radare2");
Log.v(TAG, "killed radare2");
}
mUtils.killradare();

Bundle b = getIntent().getExtras();
String file_to_open = b.getString("filename");
Expand Down Expand Up @@ -92,61 +90,73 @@ public void onCreate(Bundle savedInstanceState) {
}

if (RootTools.isProcessRunning("radare2")) {
webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new RadareWebViewClient());
webview.setWebChromeClient(new WebChromeClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setLoadWithOverviewMode(true);

/*
webview.getSettings().setAllowFileAccess(true);
webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setSupportMultipleWindows(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setAppCacheMaxSize(1024*1024*16);
String appCachePath = "/data/data/" + getPackageName() + "/cache/";
webview.getSettings().setAppCachePath(appCachePath);
webview.getSettings().setAllowFileAccess(true);
webview.getSettings().setAppCacheEnabled(true);
webview.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
webview.getSettings().setDatabaseEnabled(true);
String databasePath = "/data/data/" + getPackageName() + "/databases/";
webview.getSettings().setDatabasePath(databasePath);
webview.getSettings().setGeolocationEnabled(true);
webview.getSettings().setSaveFormData(true);
webview.getSettings().setAllowContentAccess(true);
webview.getSettings().setAllowFileAccess(true);
// webview.getSettings().setAllowFileAccessFromFileURLs(true);
// webview.getSettings().setAllowUniversalAccessFromFileURLs(true);
webview.getSettings().setAppCacheEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setDatabaseEnabled(true);
webview.getSettings().setDisplayZoomControls(true);
webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setEnableSmoothTransition(true);
webview.getSettings().setGeolocationEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setLightTouchEnabled(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setLoadsImagesAutomatically(true);
webview.getSettings().setPluginsEnabled(true);
webview.getSettings().setSupportMultipleWindows(true);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON_DEMAND);
webview.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);
webview.setHorizontalScrollBarEnabled(false);
*/
webview.loadUrl("http://localhost:9090");
Log.v(TAG, "WebView started successfully");
String open_mode = mUtils.GetPref("open_mode");
if (open_mode.equals("browser")) {
String url = "http://localhost:9090";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Log.v(TAG, "Browser started");
finish();
}
if (open_mode.equals("web")) {

webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new RadareWebViewClient());
webview.setWebChromeClient(new WebChromeClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setLoadWithOverviewMode(true);

/*
webview.getSettings().setAllowFileAccess(true);
webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setSupportMultipleWindows(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setAppCacheMaxSize(1024*1024*16);
String appCachePath = "/data/data/" + getPackageName() + "/cache/";
webview.getSettings().setAppCachePath(appCachePath);
webview.getSettings().setAllowFileAccess(true);
webview.getSettings().setAppCacheEnabled(true);
webview.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
webview.getSettings().setDatabaseEnabled(true);
String databasePath = "/data/data/" + getPackageName() + "/databases/";
webview.getSettings().setDatabasePath(databasePath);
webview.getSettings().setGeolocationEnabled(true);
webview.getSettings().setSaveFormData(true);
webview.getSettings().setAllowContentAccess(true);
webview.getSettings().setAllowFileAccess(true);
// webview.getSettings().setAllowFileAccessFromFileURLs(true);
// webview.getSettings().setAllowUniversalAccessFromFileURLs(true);
webview.getSettings().setAppCacheEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setDatabaseEnabled(true);
webview.getSettings().setDisplayZoomControls(true);
webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setEnableSmoothTransition(true);
webview.getSettings().setGeolocationEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setLightTouchEnabled(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setLoadsImagesAutomatically(true);
webview.getSettings().setPluginsEnabled(true);
webview.getSettings().setSupportMultipleWindows(true);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON_DEMAND);
webview.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
webview.setScrollbarFadingEnabled(false);
webview.setHorizontalScrollBarEnabled(false);
*/
webview.loadUrl("http://localhost:9090");
Log.v(TAG, "WebView started successfully");
}
} else {
Log.v(TAG, "could not open file" + file_to_open);
mUtils.myToast("Could not open file " + file_to_open, Toast.LENGTH_SHORT);
Expand All @@ -156,23 +166,12 @@ public void onCreate(Bundle savedInstanceState) {

}

private void killradare() {
Log.v(TAG, "killdadare() called");
RootTools.useRoot = false;
if (RootTools.isProcessRunning("radare2")) {
RootTools.killProcess("radare2");
Log.v(TAG, "killdadare() killed radare2");
}
Log.v(TAG, "killradare() finishing WebActivity");
finish();
}

@Override
public void onStop()
{
super.onStop();
Log.v(TAG, "onStop() called");
killradare();
mUtils.killradare();
}

private class RadareWebViewClient extends WebViewClient {
Expand All @@ -192,10 +191,16 @@ public void onReceivedError(WebView view, int errorCode, String description, Str
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
webview.goBack();
killradare();
return true;
try {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
Log.v(TAG, "onKeyDown() called");
//webview.goBack();
mUtils.killradare();
finish();
return true;
}
} catch (Exception e){
e.printStackTrace();
}
return super.onKeyDown(keyCode, event);
}
Expand Down

0 comments on commit 14a08f1

Please sign in to comment.