- Delete old temp files on startup

- Catch loadUrl() exception
- Stub out settings and menus
- Enable double-tap to zoom in webview on Droid
This commit is contained in:
zzz
2011-06-21 20:48:20 +00:00
parent d71ead3f53
commit 097883c1ee
12 changed files with 120 additions and 14 deletions

View File

@ -16,7 +16,7 @@
android:label="@string/app_name"
android:icon="@drawable/ic_launcher_itoopie" />
<activity android:name=".activity.MainActivity"
android:label="@string/app_name"
android:label="I2P Main Page"
android:icon="@drawable/ic_launcher_itoopie"
android.theme="@android:style/Theme.NoTitleBar"
android:launchMode="singleTask" >
@ -26,19 +26,23 @@
</intent-filter>
</activity>
<activity android:name=".activity.NewsActivity"
android:label="@string/app_name"
android:label="I2P News"
android.theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity android:name=".activity.TextResourceActivity"
android:label="@string/app_name"
android:label="I2P Information"
android.theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity android:name=".activity.LicenseActivity"
android:label="@string/app_name"
android:label="Licenses"
android.theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity android:name=".activity.WebActivity"
android:label="@string/app_name"
android:label="Web Browser"
android.theme="@android:style/Theme.NoTitleBar" >
</activity>
<activity android:name=".activity.SettingsActivity"
android:label="Settings"
android.theme="@android:style/Theme.NoTitleBar" >
</activity>
</application>

View File

@ -24,19 +24,19 @@
android:id="@+id/website_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Web Site"
android:text="Web Site\n(non-anon)"
/>
<Button
android:id="@+id/faq_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FAQ"
android:text="FAQ\n(non-anon)"
/>
<Button
android:id="@+id/welcome_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome"
android:text="Welcome\nPage"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

17
res/menu/menu1.xml Executable file
View File

@ -0,0 +1,17 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="Preferences"
android:titleCondensed="Settings"
android:id="@+id/menu_settings"
android:icon="@android:drawable/ic_menu_preferences" >
</item>
<item android:title="Start Router"
android:id="@+id/menu_start"
android:titleCondensed="Start"
android:icon="@drawable/ic_menu_play_clip" >
</item>
<item android:title="Stop Router"
android:id="@+id/menu_stop"
android:titleCondensed="Stop"
android:icon="@android:drawable/ic_menu_close_clear_cancel" >
</item>
</menu>

View File

@ -2,7 +2,7 @@
WARNING - This is ALPHA SOFTWARE. It may crash your phone. Do not rely upon it for strong anonymity. Tunnels may be as short as one hop.
Minimum Android OS is 2.1 (SDK 7). The app is only tested on the Motorola Droid. It uses a lot of RAM. You need at least 256 MB of RAM. 512 should be much better.
Minimum Android OS is 2.2 (API 8). The app is only tested on the Motorola Droid. It uses a lot of RAM. You need at least 256 MB of RAM. 512 should be much better.
The app may use a lot of RAM even after the router has stopped and there is no icon in the notification bar. Go to Settings -> Applications -> Running Services and stop the I2P service if necessary. Or Settings -> Applications -> Manage Applications -> Running -> I2P and force stop.
@ -35,6 +35,7 @@ For eepsites, there are several other things to note:
- No way to type in addresses
- No addressbook app yet, so you only have what is in the standard hosts.txt
- Eepsites are not found in the cache when hitting the back button
- Fetches are aborted when you rotate the screen
Using clients with the router

6
res/xml/settings1.xml Normal file
View File

@ -0,0 +1,6 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="settings1">
<CheckBoxPreference
android:key="test" android:title="Check it or not"/>
</PreferenceScreen>

View File

@ -26,7 +26,7 @@ SDK=`grep 'android:minSdkVersion' $MANIFEST | \
cut -d '"' -f 2`
# don't let build number get too long
VERSIONSTRING="${CORE}-${ROUTERBUILD}_b$(($ANDROIDBUILD % 256))-SDK$SDK"
VERSIONSTRING="${CORE}-${ROUTERBUILD}_b$(($ANDROIDBUILD % 512))-API$SDK"
#
# Android version code is an integer.

View File

@ -6,7 +6,11 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import net.i2p.android.router.R;
import net.i2p.android.router.binder.RouterBinder;
import net.i2p.android.router.service.RouterService;
import net.i2p.router.CommSystemFacade;
@ -98,6 +102,35 @@ public abstract class I2PActivityBase extends Activity {
super.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu1, menu);
return true;
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
// add/hide items here
return super.onPrepareOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_settings:
Intent intent = new Intent(I2PActivityBase.this, SettingsActivity.class);
startActivityForResult(intent, 0);
return true;
case R.id.menu_start:
case R.id.menu_stop:
default:
return super.onOptionsItemSelected(item);
}
}
////// Service stuff
protected boolean bindRouter() {
Intent intent = new Intent();
intent.setClassName(this, "net.i2p.android.router.service.RouterService");
@ -130,6 +163,8 @@ public abstract class I2PActivityBase extends Activity {
}
}
////// Router stuff
protected RouterContext getRouterContext() {
if (_routerService == null || !_isBound)
return null;

View File

@ -127,7 +127,12 @@ class I2PWebViewClient extends WebViewClient {
protected Integer doInBackground(String... urls) {
publishProgress(Integer.valueOf(-1));
_view.loadUrl(urls[0]);
try {
_view.loadUrl(urls[0]);
} catch (Exception e) {
// CalledFromWrongThreadException
cancel(false);
}
return Integer.valueOf(0);
}
@ -181,7 +186,12 @@ class I2PWebViewClient extends WebViewClient {
System.err.println("Fetch cancelled for " + url);
return Integer.valueOf(0);
}
_view.loadDataWithBaseURL(url, d, t, e, url);
try {
_view.loadDataWithBaseURL(url, d, t, e, url);
} catch (Exception exc) {
// CalledFromWrongThreadException
cancel(false);
}
return Integer.valueOf(0);
}

View File

@ -38,6 +38,8 @@ public class NewsActivity extends I2PActivityBase {
setContentView(R.layout.news);
WebView wv = (WebView) findViewById(R.id.news_webview);
wv.getSettings().setLoadsImagesAutomatically(false);
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
wv.getSettings().setUseWideViewPort(true);
_wvClient = new I2PWebViewClient();
wv.setWebViewClient(_wvClient);
wv.getSettings().setBuiltInZoomControls(true);

View File

@ -0,0 +1,15 @@
package net.i2p.android.router.activity;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import net.i2p.android.router.R;
public class SettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings1);
}
}

View File

@ -36,6 +36,8 @@ public class WebActivity extends I2PActivityBase {
_wvClient = new I2PWebViewClient();
wv.setWebViewClient(_wvClient);
wv.getSettings().setBuiltInZoomControls(true);
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
wv.getSettings().setUseWideViewPort(true);
Intent intent = getIntent();
Uri uri = intent.getData();
if (uri != null) {

View File

@ -19,8 +19,9 @@ import net.i2p.data.DataHelper;
import net.i2p.router.Router;
import net.i2p.router.RouterContext;
import net.i2p.router.RouterLaunch;
import net.i2p.util.OrderedProperties;
import net.i2p.util.FileUtil;
import net.i2p.util.NativeBigInteger;
import net.i2p.util.OrderedProperties;
class Init {
@ -93,7 +94,7 @@ class Init {
copyResourceToFile(R.raw.blocklist_txt, "blocklist.txt");
}
(new File(myDir, "wrapper.log")).delete();
deleteOldFiles();
// Set up the locations so Router and WorkingDir can find them
System.setProperty("i2p.dir.base", myDir);
@ -200,4 +201,17 @@ class Init {
}
return newVersion;
}
private void deleteOldFiles() {
(new File(myDir, "wrapper.log")).delete();
File tmp = new File(myDir, "tmp");
File[] files = tmp.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
File f = files[i];
System.err.println("Deleting old file/dir " + f);
FileUtil.rmdir(f, false);
}
}
}
}