Compare commits
70 Commits
android-0.
...
android-0.
Author | SHA1 | Date | |
---|---|---|---|
9654fa24cc | |||
7843b37a7e | |||
1db9128afc | |||
c03d3a8b92 | |||
80b7455602 | |||
1fcf5aa49b | |||
640803418d | |||
56fa0b0302 | |||
9c10eef0e3 | |||
9fd5e43115 | |||
d5bd9b8eaa | |||
5b1203a1c6 | |||
fbe79eee2e | |||
ffa21fc1e0 | |||
5faf1f5bb0 | |||
e15efb6537 | |||
cd1702d53c | |||
5a6ca8a0a4 | |||
82d184cf90 | |||
5162bb604b | |||
3aff2a7a9d | |||
cae565761d | |||
c2b6cee9a2 | |||
84e7b1f41c | |||
7ebed1e6d2 | |||
2e68122b8d | |||
899a3f4cfc | |||
52d49a4ab6 | |||
75f705125f | |||
722ddf8a47 | |||
524d21631e | |||
86e6060217 | |||
b5c7fad876 | |||
5f3ca0fe69 | |||
ddd9bea786 | |||
6aac99e7ea | |||
da763a7c81 | |||
6cb46c3168 | |||
610e963d22 | |||
96b8ed43e0 | |||
812c28cd33 | |||
3f7312653a | |||
c89d3992c7 | |||
d9394685c9 | |||
b140158b24 | |||
4f5b0bd21a | |||
1d17d89ccb | |||
b6074da7c4 | |||
c0fdb4aff7 | |||
e00c9cc449 | |||
423ca46672 | |||
66ed9d94a7 | |||
a68ef9d372 | |||
cb389123c5 | |||
62cca0ed50 | |||
c99e3c0b41 | |||
302c51ccfa | |||
1e34bc2159 | |||
24f6f4789d | |||
2de11a4067 | |||
d83a2f9919 | |||
bf36b4c2e6 | |||
daa0b739a3 | |||
5e1b0d9b50 | |||
917742847a | |||
9460e3202f | |||
5f388a7c6b | |||
39d5de7eb4 | |||
0fb1ef881c | |||
8230769191 |
@ -4,15 +4,15 @@ lang_map = he: iw, id: in, pt_BR: pt-rBR, ru_RU: ru, sv_SE: sv, tr_TR: tr, uk_UA
|
||||
|
||||
[I2P.android]
|
||||
file_filter = app/src/main/res/values-<lang>/strings.xml
|
||||
minimum_perc = 50
|
||||
source_file = app/src/main/res/values/strings.xml
|
||||
source_lang = en
|
||||
type = ANDROID
|
||||
minimum_perc = 50
|
||||
|
||||
[I2P.android_lib_helper]
|
||||
file_filter = lib/helper/src/main/res/values-<lang>/strings.xml
|
||||
minimum_perc = 50
|
||||
source_file = lib/helper/src/main/res/values/strings.xml
|
||||
source_lang = en
|
||||
type = ANDROID
|
||||
minimum_perc = 50
|
||||
|
||||
|
39
CHANGELOG
@ -1,3 +1,42 @@
|
||||
0.9.33 / 2018-02-18
|
||||
* Translation updates
|
||||
|
||||
0.9.32 / 2017-11-28
|
||||
* Fixed "Application Not Responding" error when restarting all tunnels
|
||||
* Fixed crashes when:
|
||||
* opening the console menu
|
||||
* starting the router
|
||||
* starting the router for the first time
|
||||
* viewing tunnels
|
||||
* viewing the addressbook
|
||||
* opening the addressbook menu
|
||||
* configuring addressbook subscriptions
|
||||
* using a configuration wizard
|
||||
* loading a B64 Destination from file
|
||||
* viewing tunnel settings
|
||||
* saving tunnel settings
|
||||
* installing a tunnel's recommended app without a market app
|
||||
* installing a browser without a market app
|
||||
* rotating the screen while using the built-in browser
|
||||
* Added a "sync" icon to more clearly indicate tunnel "starting" status
|
||||
* Updated Firefox browser config instructions for Firefox Quantum
|
||||
* Translation updates
|
||||
|
||||
0.9.31 / 2017-08-19
|
||||
* Fixed various crashes in the Tunnels UI
|
||||
* Updated Firefox browser config instructions
|
||||
* Minor bug fixes
|
||||
* Dependency and translation updates
|
||||
|
||||
0.9.30 / 2017-05-20
|
||||
* Fixed crashes when creating or deleting tunnels, or adding names to the
|
||||
private addressbook
|
||||
* Minor bug fixes
|
||||
* Dependency and translation updates
|
||||
|
||||
0.9.29 / 2017-03-27
|
||||
* Dependency and translation updates
|
||||
|
||||
0.9.28 / 2017-01-02
|
||||
* Bug fixes and translation updates
|
||||
|
||||
|
20
RELEASE-PROCESS.md
Normal file
@ -0,0 +1,20 @@
|
||||
1. Check out a clean copy of i2p.i2p at the correct release version.
|
||||
2. Edit `routerjars/local.properties` to use the clean i2p.i2p copy.
|
||||
3. Pull the latest translations with `tx pull -a` and commit them.
|
||||
4. Ensure that `signing.properties` contains the details of the release key.
|
||||
5. Edit `gradle.properties` to bump the I2P version.
|
||||
6. Edit `app/build.gradle` to bump the Android version number.
|
||||
7. If the helper has changed since the last release, edit
|
||||
`lib/helper/gradle.properties` to bump the version.
|
||||
8. `./gradlew clean assembleRelease`
|
||||
9. `./gradlew :lib:client:uploadArchives`
|
||||
10. If the helper version was changed: `./gradlew :lib:helper:uploadArchives`
|
||||
11. Check on Sonatype that everything worked, and close/release.
|
||||
12. Update local fdroidserver repo
|
||||
13. `cp app/build/outputs/apk/free/release/app-free-release.apk path/to/fdroid/repo/I2P-VERSION.apk`
|
||||
14. Update `path/to/fdroid/metadata/net.i2p.android.txt`
|
||||
15. `fdroid update`
|
||||
16. Push to download server and put in place.
|
||||
17. Check F-Droid repo works, and app works.
|
||||
18. `mtn ci gradle.properties lib/helper/gradle.properties app/build.gradle`
|
||||
19. Push free and donate builds to Google Play.
|
@ -1,12 +1,10 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'witness'
|
||||
|
||||
android {
|
||||
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION as String)
|
||||
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION as String
|
||||
defaultConfig {
|
||||
versionCode 4745235
|
||||
versionName '0.9.28'
|
||||
versionCode 4745241
|
||||
versionName "$I2P_VERSION"
|
||||
minSdkVersion 9
|
||||
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION as String)
|
||||
|
||||
@ -23,6 +21,7 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
debug {
|
||||
debuggable true
|
||||
applicationIdSuffix '.debug'
|
||||
versionNameSuffix '-DEBUG'
|
||||
}
|
||||
@ -37,14 +36,18 @@ android {
|
||||
packagingOptions {
|
||||
exclude 'LICENSE.txt'
|
||||
}
|
||||
flavorDimensions 'tier'
|
||||
productFlavors {
|
||||
free {
|
||||
dimension 'tier'
|
||||
applicationId 'net.i2p.android'
|
||||
}
|
||||
donate {
|
||||
dimension 'tier'
|
||||
applicationId 'net.i2p.android.donate'
|
||||
}
|
||||
legacy {
|
||||
dimension 'tier'
|
||||
applicationId 'net.i2p.android.router'
|
||||
}
|
||||
}
|
||||
@ -52,51 +55,34 @@ android {
|
||||
|
||||
dependencies {
|
||||
// Local dependencies
|
||||
compile project(':lib:client')
|
||||
compile project(':lib:helper')
|
||||
compile project(':routerjars')
|
||||
implementation project(':lib:client')
|
||||
implementation project(':lib:helper')
|
||||
implementation project(path: ':routerjars', configuration: 'routerjars')
|
||||
|
||||
// Android Support Repository dependencies
|
||||
def supportVersion = '25.0.1'
|
||||
compile "com.android.support:support-v4:$supportVersion"
|
||||
compile "com.android.support:appcompat-v7:$supportVersion"
|
||||
compile "com.android.support:preference-v7:$supportVersion"
|
||||
compile "com.android.support:preference-v14:$supportVersion"
|
||||
compile "com.android.support:recyclerview-v7:$supportVersion"
|
||||
def supportVersion = '25.3.1'
|
||||
implementation "com.android.support:support-v4:$supportVersion"
|
||||
implementation "com.android.support:appcompat-v7:$supportVersion"
|
||||
implementation "com.android.support:preference-v7:$supportVersion"
|
||||
implementation "com.android.support:preference-v14:$supportVersion"
|
||||
implementation "com.android.support:recyclerview-v7:$supportVersion"
|
||||
|
||||
// Remote dependencies
|
||||
compile 'com.androidplot:androidplot-core:0.9.8'
|
||||
compile 'com.eowise:recyclerview-stickyheaders:0.5.2@aar'
|
||||
compile ('com.mcxiaoke.viewpagerindicator:library:2.4.1') {
|
||||
exclude group: 'com.android.support', module: 'support-v4'
|
||||
}
|
||||
compile 'com.pnikosis:materialish-progress:1.7'
|
||||
compile 'net.i2p:router:0.9.28'
|
||||
compile 'net.i2p.android.ext:floatingactionbutton:1.10.1'
|
||||
compile 'org.sufficientlysecure:html-textview:1.6'
|
||||
implementation 'com.androidplot:androidplot-core:1.4.1'
|
||||
implementation 'com.eowise:recyclerview-stickyheaders:0.5.2@aar'
|
||||
implementation 'com.inkapplications.viewpageindicator:library:2.4.4'
|
||||
implementation 'com.pnikosis:materialish-progress:1.7'
|
||||
implementation "net.i2p:router:$I2P_VERSION"
|
||||
implementation 'net.i2p.android.ext:floatingactionbutton:1.10.1'
|
||||
implementation 'org.sufficientlysecure:html-textview:3.1'
|
||||
|
||||
// Testing-only dependencies
|
||||
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
|
||||
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2') {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
}
|
||||
}
|
||||
|
||||
dependencyVerification {
|
||||
verify = [
|
||||
'com.android.support:support-v4:50da261acc4ca3d2dea9a43106bf65488711ca97b20a4daa095dba381c205c98',
|
||||
'com.android.support:appcompat-v7:7fead560a22ea4b15848ce3000f312ef611fac0953bf90ca8710a72a1f6e36ea',
|
||||
'com.android.support:preference-v7:d7e3fcb6d5427aa25bfd56c51c24786dbb6f06d998b8b6691e9449e1b11cc205',
|
||||
'com.android.support:preference-v14:9d0269913033d97d8edb29003e1ea19021f2e8f36df4035f819bb948f9a23ed2',
|
||||
'com.android.support:recyclerview-v7:803baba7be537ace8c5cb8a775e37547c22a04c4b028833796c45c26ec1deca2',
|
||||
'com.androidplot:androidplot-core:e44d9e59e06f025330831f7d3c987d2778a3302025184cf0cef05714b5171212',
|
||||
'com.eowise:recyclerview-stickyheaders:7b236da49b33b840e9ba6e7e4182218d1a2d9047236fdbc3ca947352f9b0883b',
|
||||
'com.mcxiaoke.viewpagerindicator:library:1e8aad664137f68abdfee94889f6da3dc98be652a235176a403965a07a25de62',
|
||||
'com.pnikosis:materialish-progress:da089a90d1dab61e9b50038c09081019398f81190d12b0b567ce94b83ef8cf93',
|
||||
'net.i2p:router:de3cf0a0e99823662c938d6a1083f201f8feba7d0ebebaf3179fed7040863b7c',
|
||||
'net.i2p.android.ext:floatingactionbutton:09d43e2d4ac04a91bf7a37e1ec48a8d220204e3a55dca72cd36cd9fa27461ade',
|
||||
'org.sufficientlysecure:html-textview:c409b471618b675e3d2a8588f883c5fe8f3369d00df61ec84b29f29c648370ae',
|
||||
]
|
||||
}
|
||||
|
||||
project.ext.i2pbase = '../i2p.i2p'
|
||||
project.ext.i2pbase = "../i2p.i2p"
|
||||
def Properties props = new Properties()
|
||||
def propFile = new File(project(':routerjars').projectDir, 'local.properties')
|
||||
|
||||
|
@ -11,12 +11,12 @@ import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.news.NewsEntry;
|
||||
import net.i2p.router.news.NewsMetadata;
|
||||
import net.i2p.router.news.NewsXMLParser;
|
||||
import net.i2p.router.util.RFC822Date;
|
||||
import net.i2p.util.EepGet;
|
||||
import net.i2p.util.FileUtil;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.ReusableGZIPInputStream;
|
||||
import net.i2p.util.SecureFileOutputStream;
|
||||
import net.i2p.util.RFC822Date;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.i2p.android.help;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.ColorMatrix;
|
||||
@ -11,6 +12,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.i2p.android.router.R;
|
||||
|
||||
@ -84,7 +86,11 @@ public class BrowserAdapter extends RecyclerView.Adapter<BrowserAdapter.ViewHold
|
||||
String uriMarket = "market://search?q=pname:" + browser.packageName;
|
||||
Uri uri = Uri.parse(uriMarket);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
mCtx.startActivity(intent);
|
||||
try {
|
||||
mCtx.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(mCtx, R.string.no_market_app, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.mStatus.setVisibility(View.VISIBLE);
|
||||
|
@ -30,7 +30,7 @@ public class HelpHtmlFragment extends Fragment {
|
||||
int padH = getResources().getDimensionPixelOffset(R.dimen.activity_horizontal_margin);
|
||||
int padV = getResources().getDimensionPixelOffset(R.dimen.activity_vertical_margin);
|
||||
text.setPadding(padH, padV, padH, padV);
|
||||
text.setHtmlFromRawResource(getActivity(), getArguments().getInt(ARG_HTML_FILE), true);
|
||||
text.setHtml(getArguments().getInt(ARG_HTML_FILE));
|
||||
return scroller;
|
||||
}
|
||||
}
|
||||
|
@ -22,14 +22,17 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.android.i2ptunnel.util.TunnelUtil;
|
||||
import net.i2p.android.router.R;
|
||||
import net.i2p.android.router.util.Util;
|
||||
import net.i2p.android.util.FragmentUtils;
|
||||
import net.i2p.app.ClientAppState;
|
||||
import net.i2p.i2ptunnel.TunnelController;
|
||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||
|
||||
import java.util.List;
|
||||
@ -41,6 +44,7 @@ public class TunnelDetailFragment extends Fragment {
|
||||
private TunnelControllerGroup mGroup;
|
||||
private TunnelEntry mTunnel;
|
||||
private Toolbar mToolbar;
|
||||
private ImageView mStatus;
|
||||
|
||||
public static TunnelDetailFragment newInstance(int tunnelId) {
|
||||
TunnelDetailFragment f = new TunnelDetailFragment();
|
||||
@ -73,21 +77,33 @@ public class TunnelDetailFragment extends Fragment {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
String error;
|
||||
List<TunnelController> controllers;
|
||||
try {
|
||||
mGroup = TunnelControllerGroup.getInstance();
|
||||
error = mGroup == null ? getResources().getString(R.string.i2ptunnel_not_initialized) : null;
|
||||
controllers = mGroup.getControllers();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
mGroup = null;
|
||||
controllers = null;
|
||||
error = iae.toString();
|
||||
}
|
||||
|
||||
if (mGroup == null) {
|
||||
// Show error
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
error, Toast.LENGTH_LONG).show();
|
||||
getActivity().finish();
|
||||
} else if (getArguments().containsKey(TUNNEL_ID)) {
|
||||
int tunnelId = getArguments().getInt(TUNNEL_ID);
|
||||
mTunnel = new TunnelEntry(getActivity(),
|
||||
mGroup.getControllers().get(tunnelId),
|
||||
tunnelId);
|
||||
try {
|
||||
TunnelController controller = controllers.get(tunnelId);
|
||||
mTunnel = new TunnelEntry(getActivity(), controller, tunnelId);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// Tunnel doesn't exist
|
||||
Util.e("Could not load tunnel details", e);
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
R.string.i2ptunnel_no_tunnel_details, Toast.LENGTH_LONG).show();
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,18 +123,18 @@ public class TunnelDetailFragment extends Fragment {
|
||||
updateToolbar();
|
||||
|
||||
if (mTunnel != null) {
|
||||
mStatus = (ImageView) v.findViewById(R.id.tunnel_status);
|
||||
updateStatus();
|
||||
ViewCompat.setTransitionName(mStatus, "status" + mTunnel.getId());
|
||||
|
||||
TextView name = (TextView) v.findViewById(R.id.tunnel_name);
|
||||
name.setText(mTunnel.getName());
|
||||
ViewCompat.setTransitionName(name,
|
||||
getActivity().getString(R.string.TUNNEL_NAME) + mTunnel.getId());
|
||||
|
||||
TextView type = (TextView) v.findViewById(R.id.tunnel_type);
|
||||
type.setText(mTunnel.getType());
|
||||
|
||||
TextView description = (TextView) v.findViewById(R.id.tunnel_description);
|
||||
description.setText(mTunnel.getDescription());
|
||||
ViewCompat.setTransitionName(description,
|
||||
getActivity().getString(R.string.TUNNEL_DESCRIPTION) + mTunnel.getId());
|
||||
|
||||
if (!mTunnel.getDetails().isEmpty()) {
|
||||
v.findViewById(R.id.tunnel_details_container).setVisibility(View.VISIBLE);
|
||||
@ -204,7 +220,13 @@ public class TunnelDetailFragment extends Fragment {
|
||||
Uri uri = mTunnel.getRecommendedAppForTunnel();
|
||||
if (uri != null) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
startActivity(intent);
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Toast.makeText(getContext(),
|
||||
R.string.no_market_app,
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -244,6 +266,14 @@ public class TunnelDetailFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStatus() {
|
||||
mStatus.setImageDrawable(mTunnel.getStatusIcon());
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
|
||||
mStatus.setBackgroundDrawable(mTunnel.getStatusBackground());
|
||||
else
|
||||
mStatus.setBackground(mTunnel.getStatusBackground());
|
||||
}
|
||||
|
||||
private boolean onToolbarItemSelected(MenuItem item) {
|
||||
if (mTunnel == null)
|
||||
return false;
|
||||
@ -257,6 +287,8 @@ public class TunnelDetailFragment extends Fragment {
|
||||
+ ' ' + mTunnel.getName(), Toast.LENGTH_LONG).show();
|
||||
// Reload the toolbar to change the start/stop action
|
||||
updateToolbar();
|
||||
// Update the status icon
|
||||
updateStatus();
|
||||
return true;
|
||||
case R.id.action_stop_tunnel:
|
||||
mTunnel.getController().stopTunnel();
|
||||
@ -265,42 +297,31 @@ public class TunnelDetailFragment extends Fragment {
|
||||
+ ' ' + mTunnel.getName(), Toast.LENGTH_LONG).show();
|
||||
// Reload the toolbar to change the start/stop action
|
||||
updateToolbar();
|
||||
// Update the status icon
|
||||
updateStatus();
|
||||
return true;
|
||||
case R.id.action_edit_tunnel:
|
||||
mCallback.onEditTunnel(mTunnel.getId());
|
||||
return true;
|
||||
case R.id.action_delete_tunnel:
|
||||
DialogFragment dg = new DialogFragment() {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.i2ptunnel_delete_confirm_message)
|
||||
.setPositiveButton(R.string.i2ptunnel_delete_confirm_button,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
List<String> msgs = TunnelUtil.deleteTunnel(
|
||||
I2PAppContext.getGlobalContext(),
|
||||
mGroup, mTunnel.getId(), null);
|
||||
dialog.dismiss();
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
msgs.get(0), Toast.LENGTH_LONG).show();
|
||||
mCallback.onTunnelDeleted(mTunnel.getId(),
|
||||
mGroup.getControllers().size());
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
};
|
||||
dg.show(getFragmentManager(), "delete_tunnel_dialog");
|
||||
DialogFragment dg = DeleteTunnelDialogFragment.newInstance();
|
||||
dg.show(getChildFragmentManager(), "delete_tunnel_dialog");
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void onDeleteTunnel() {
|
||||
List<String> msgs = TunnelUtil.deleteTunnel(
|
||||
I2PAppContext.getGlobalContext(),
|
||||
mGroup, mTunnel.getId(), null);
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
msgs.get(0), Toast.LENGTH_LONG).show();
|
||||
mCallback.onTunnelDeleted(mTunnel.getId(),
|
||||
mGroup.getControllers().size());
|
||||
}
|
||||
|
||||
private void copyToClipbardLegacy() {
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipboard.setText(mTunnel.getDetails());
|
||||
@ -313,4 +334,47 @@ public class TunnelDetailFragment extends Fragment {
|
||||
mTunnel.getName(), mTunnel.getDetails());
|
||||
clipboard.setPrimaryClip(clip);
|
||||
}
|
||||
|
||||
public static class DeleteTunnelDialogFragment extends DialogFragment {
|
||||
TunnelDetailFragment mListener;
|
||||
|
||||
public static DialogFragment newInstance() {
|
||||
return new DeleteTunnelDialogFragment();
|
||||
}
|
||||
|
||||
private void onAttachToParentFragment(Fragment fragment) {
|
||||
// Verify that the host fragment implements the callback interface
|
||||
try {
|
||||
// Instantiate the TunnelDetailFragment so we can send events to the host
|
||||
mListener = (TunnelDetailFragment) fragment;
|
||||
} catch (ClassCastException e) {
|
||||
// The fragment doesn't implement the interface, throw exception
|
||||
throw new ClassCastException(fragment.toString()
|
||||
+ " must be TunnelDetailFragment");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
onAttachToParentFragment(getParentFragment());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.i2ptunnel_delete_confirm_message)
|
||||
.setPositiveButton(R.string.i2ptunnel_delete_confirm_button,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
mListener.onDeleteTunnel();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,15 +6,19 @@ import android.net.Uri;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.android.i2ptunnel.util.SaveTunnelTask;
|
||||
import net.i2p.android.i2ptunnel.util.TunnelUtil;
|
||||
import net.i2p.android.router.R;
|
||||
import net.i2p.android.router.util.Util;
|
||||
import net.i2p.data.Destination;
|
||||
import net.i2p.data.PrivateKeyFile;
|
||||
import net.i2p.i2ptunnel.TunnelController;
|
||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||
import net.i2p.i2ptunnel.ui.TunnelConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class TunnelEntry {
|
||||
public static final int RUNNING = 1;
|
||||
@ -26,18 +30,32 @@ public class TunnelEntry {
|
||||
private final TunnelController mController;
|
||||
private final int mId;
|
||||
|
||||
/**
|
||||
* @return the new TunnelEntry, or null if there was an error.
|
||||
*/
|
||||
public static TunnelEntry createNewTunnel(
|
||||
Context ctx,
|
||||
TunnelControllerGroup tcg,
|
||||
TunnelConfig cfg) {
|
||||
int tunnelId = tcg.getControllers().size();
|
||||
List<String> msgs = TunnelUtil.saveTunnel(
|
||||
I2PAppContext.getGlobalContext(), tcg, -1, cfg);
|
||||
TunnelEntry ret = null;
|
||||
List<String> msgs = new ArrayList<>();
|
||||
SaveTunnelTask task = new SaveTunnelTask(tcg, -1, cfg);
|
||||
try {
|
||||
msgs.addAll(task.execute().get());
|
||||
TunnelController cur = TunnelUtil.getController(tcg, tunnelId);
|
||||
ret = new TunnelEntry(ctx, cur, tunnelId);
|
||||
} catch (InterruptedException e) {
|
||||
Util.e("Interrupted while saving tunnel config", e);
|
||||
msgs.add(ctx.getString(R.string.i2ptunnel_msg_config_save_failed));
|
||||
} catch (ExecutionException e) {
|
||||
Util.e("Error while saving tunnel config", e);
|
||||
msgs.add(ctx.getString(R.string.i2ptunnel_msg_config_save_failed));
|
||||
}
|
||||
// TODO: Do something else with the other messages.
|
||||
Toast.makeText(ctx.getApplicationContext(),
|
||||
msgs.get(0), Toast.LENGTH_LONG).show();
|
||||
TunnelController cur = TunnelUtil.getController(tcg, tunnelId);
|
||||
return new TunnelEntry(ctx, cur, tunnelId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public TunnelEntry(Context context, TunnelController controller, int id) {
|
||||
@ -262,6 +280,8 @@ public class TunnelEntry {
|
||||
return mContext.getResources()
|
||||
.getDrawable(R.drawable.ic_schedule_black_24dp);
|
||||
case STARTING:
|
||||
return mContext.getResources()
|
||||
.getDrawable(R.drawable.ic_sync_black_24dp);
|
||||
case RUNNING:
|
||||
case NOT_RUNNING:
|
||||
default:
|
||||
|
@ -144,16 +144,13 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
tvh.status.setBackgroundDrawable(tunnel.getStatusBackground());
|
||||
else
|
||||
tvh.status.setBackground(tunnel.getStatusBackground());
|
||||
ViewCompat.setTransitionName(tvh.status,
|
||||
"status" + tunnel.getId());
|
||||
|
||||
tvh.name.setText(tunnel.getName());
|
||||
tvh.description.setText(tunnel.getDescription());
|
||||
tvh.interfacePort.setText(tunnel.getTunnelLink(false));
|
||||
|
||||
ViewCompat.setTransitionName(tvh.name,
|
||||
mCtx.getString(R.string.TUNNEL_NAME) + tunnel.getId());
|
||||
ViewCompat.setTransitionName(tvh.description,
|
||||
mCtx.getString(R.string.TUNNEL_DESCRIPTION) + tunnel.getId());
|
||||
|
||||
tvh.itemView.setSelected(mTwoPane.isTwoPane() && position == mActivatedPosition);
|
||||
tvh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -162,13 +159,10 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
||||
mActivatedPosition = position;
|
||||
notifyItemChanged(oldPosition);
|
||||
notifyItemChanged(position);
|
||||
Pair<View, String> namePair = Pair.create(
|
||||
(View)tvh.name,
|
||||
ViewCompat.getTransitionName(tvh.name));
|
||||
Pair<View, String> descPair = Pair.create(
|
||||
(View)tvh.description,
|
||||
ViewCompat.getTransitionName(tvh.description));
|
||||
Pair<View, String>[] pairs = new Pair[]{ namePair, descPair};
|
||||
Pair<View, String> statusPair = Pair.create(
|
||||
(View)tvh.status,
|
||||
ViewCompat.getTransitionName(tvh.status));
|
||||
Pair<View, String>[] pairs = new Pair[]{ statusPair};
|
||||
mListener.onTunnelSelected(tunnel.getId(), pairs);
|
||||
}
|
||||
});
|
||||
|
@ -150,14 +150,21 @@ public class TunnelListFragment extends Fragment implements
|
||||
};
|
||||
|
||||
public void updateState(State state) {
|
||||
if (state == State.STOPPING || state == State.STOPPED ||
|
||||
state == State.MANUAL_STOPPING ||
|
||||
state == State.MANUAL_STOPPED ||
|
||||
state == State.MANUAL_QUITTING ||
|
||||
state == State.MANUAL_QUITTED)
|
||||
getLoaderManager().destroyLoader(mClientTunnels ? CLIENT_LOADER_ID : SERVER_LOADER_ID);
|
||||
else
|
||||
initTunnels();
|
||||
try {
|
||||
if (state == State.INIT ||
|
||||
state == State.STARTING || // Wait until RouterContext is initialised
|
||||
state == State.STOPPING ||
|
||||
state == State.STOPPED ||
|
||||
state == State.MANUAL_STOPPING ||
|
||||
state == State.MANUAL_STOPPED ||
|
||||
state == State.MANUAL_QUITTING ||
|
||||
state == State.MANUAL_QUITTED)
|
||||
getLoaderManager().destroyLoader(mClientTunnels ? CLIENT_LOADER_ID : SERVER_LOADER_ID);
|
||||
else
|
||||
initTunnels();
|
||||
} catch (IllegalStateException ise) {
|
||||
// Fragment isn't attached to any activity, so ignore state change
|
||||
}
|
||||
}
|
||||
|
||||
private void initTunnels() {
|
||||
|
@ -2,6 +2,7 @@ package net.i2p.android.i2ptunnel;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@ -21,26 +22,51 @@ public class TunnelWizardActivity extends AbstractWizardActivity {
|
||||
|
||||
@Override
|
||||
protected DialogFragment onGetFinishWizardDialog() {
|
||||
return new DialogFragment() {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.i2ptunnel_wizard_submit_confirm_message)
|
||||
.setPositiveButton(R.string.i2ptunnel_wizard_submit_confirm_button,
|
||||
new DialogInterface.OnClickListener() {
|
||||
return FinishWizardDialogFragment.newInstance();
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent result = new Intent();
|
||||
result.putExtra(TunnelsContainer.TUNNEL_WIZARD_DATA, mWizardModel.save());
|
||||
setResult(Activity.RESULT_OK, result);
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
public void onFinishWizard() {
|
||||
Intent result = new Intent();
|
||||
result.putExtra(TunnelsContainer.TUNNEL_WIZARD_DATA, mWizardModel.save());
|
||||
setResult(Activity.RESULT_OK, result);
|
||||
finish();
|
||||
}
|
||||
|
||||
public static class FinishWizardDialogFragment extends DialogFragment {
|
||||
TunnelWizardActivity mListener;
|
||||
|
||||
public static DialogFragment newInstance() {
|
||||
return new FinishWizardDialogFragment();
|
||||
}
|
||||
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
// Verify that the host fragment implements the callback interface
|
||||
try {
|
||||
// Instantiate the TunnelWizardActivity so we can send events to the host
|
||||
mListener = (TunnelWizardActivity) context;
|
||||
} catch (ClassCastException e) {
|
||||
// The fragment doesn't implement the interface, throw exception
|
||||
throw new ClassCastException(context.toString()
|
||||
+ " must be TunnelWizardActivity");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.i2ptunnel_wizard_submit_confirm_message)
|
||||
.setPositiveButton(R.string.i2ptunnel_wizard_submit_confirm_button,
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
mListener.onFinishWizard();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,14 @@ public class TunnelsContainer extends Fragment implements
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
private boolean showActions() {
|
||||
RouterContext rCtx = Util.getRouterContext();
|
||||
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance();
|
||||
return rCtx != null && tcg != null &&
|
||||
(tcg.getState() == ClientAppState.STARTING ||
|
||||
tcg.getState() == ClientAppState.RUNNING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.container_tunnels, container, false);
|
||||
@ -72,6 +80,7 @@ public class TunnelsContainer extends Fragment implements
|
||||
mViewPager = (ViewPager) v.findViewById(R.id.pager);
|
||||
mPageIndicator = (TitlePageIndicator) v.findViewById(R.id.page_indicator);
|
||||
mNewTunnel = (ImageButton) v.findViewById(R.id.promoted_action);
|
||||
mNewTunnel.setVisibility(showActions() ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (v.findViewById(R.id.detail_fragment) != null) {
|
||||
// The detail container view will be present only in the
|
||||
@ -154,17 +163,16 @@ public class TunnelsContainer extends Fragment implements
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
RouterContext rCtx = Util.getRouterContext();
|
||||
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance();
|
||||
boolean showActions = rCtx != null && tcg != null &&
|
||||
(tcg.getState() == ClientAppState.STARTING ||
|
||||
tcg.getState() == ClientAppState.RUNNING);
|
||||
boolean showActions = showActions();
|
||||
|
||||
menu.findItem(R.id.action_start_all_tunnels).setVisible(showActions);
|
||||
menu.findItem(R.id.action_stop_all_tunnels).setVisible(showActions);
|
||||
menu.findItem(R.id.action_restart_all_tunnels).setVisible(showActions);
|
||||
|
||||
mNewTunnel.setVisibility(showActions ? View.VISIBLE : View.GONE);
|
||||
// Was causing a NPE in version 4745238 (0.9.31)
|
||||
if (mNewTunnel != null) {
|
||||
mNewTunnel.setVisibility(showActions ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -183,7 +191,10 @@ public class TunnelsContainer extends Fragment implements
|
||||
msgs = tcg.stopAllControllers();
|
||||
break;
|
||||
case R.id.action_restart_all_tunnels:
|
||||
msgs = tcg.restartAllControllers();
|
||||
// Do a manual stop-start cycle, because tcg.restartAllControllers() happens in the
|
||||
// foreground, whereas tcg.startAllControllers() fires off threads for starting.
|
||||
msgs = tcg.stopAllControllers();
|
||||
msgs.addAll(tcg.startAllControllers());
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
@ -205,10 +216,12 @@ public class TunnelsContainer extends Fragment implements
|
||||
TunnelConfig cfg = TunnelUtil.createConfigFromWizard(getActivity(), tcg, tunnelData);
|
||||
TunnelEntry tunnel = TunnelEntry.createNewTunnel(getActivity(), tcg, cfg);
|
||||
|
||||
if (tunnel.isClient() && mClientFrag != null)
|
||||
mClientFrag.addTunnel(tunnel);
|
||||
else if (mServerFrag != null)
|
||||
mServerFrag.addTunnel(tunnel);
|
||||
if (tunnel != null) {
|
||||
if (tunnel.isClient() && mClientFrag != null)
|
||||
mClientFrag.addTunnel(tunnel);
|
||||
else if (mServerFrag != null)
|
||||
mServerFrag.addTunnel(tunnel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,18 @@ import android.os.Bundle;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.android.i2ptunnel.util.SaveTunnelTask;
|
||||
import net.i2p.android.i2ptunnel.util.TunnelUtil;
|
||||
import net.i2p.android.preferences.util.CustomPreferenceFragment;
|
||||
import net.i2p.android.router.R;
|
||||
import net.i2p.android.router.util.Util;
|
||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||
import net.i2p.i2ptunnel.ui.TunnelConfig;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public abstract class BaseTunnelPreferenceFragment extends CustomPreferenceFragment {
|
||||
protected static final String ARG_TUNNEL_ID = "tunnelId";
|
||||
|
||||
@ -31,13 +35,30 @@ public abstract class BaseTunnelPreferenceFragment extends CustomPreferenceFragm
|
||||
}
|
||||
|
||||
if (mGroup == null) {
|
||||
// TODO Show error
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
error, Toast.LENGTH_LONG).show();
|
||||
getActivity().finish();
|
||||
} else if (getArguments().containsKey(ARG_TUNNEL_ID)) {
|
||||
mTunnelId = getArguments().getInt(ARG_TUNNEL_ID, 0);
|
||||
TunnelUtil.writeTunnelToPreferences(getActivity(), mGroup, mTunnelId);
|
||||
try {
|
||||
TunnelUtil.writeTunnelToPreferences(getActivity(), mGroup, mTunnelId);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Tunnel doesn't exist, or the tunnel config file could not be read
|
||||
Util.e("Could not load tunnel details", e);
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
R.string.i2ptunnel_no_tunnel_details, Toast.LENGTH_LONG).show();
|
||||
getActivity().finish();
|
||||
}
|
||||
// https://stackoverflow.com/questions/17880437/which-settings-file-does-preferencefragment-read-write
|
||||
getPreferenceManager().setSharedPreferencesName(TunnelUtil.getPreferencesFilename(mTunnelId));
|
||||
loadPreferences();
|
||||
try {
|
||||
loadPreferences();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// mGroup couldn't load its config file
|
||||
Toast.makeText(getActivity().getApplicationContext(),
|
||||
iae.toString(), Toast.LENGTH_LONG).show();
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +83,17 @@ public abstract class BaseTunnelPreferenceFragment extends CustomPreferenceFragm
|
||||
private void saveTunnel() {
|
||||
if (mGroup != null) {
|
||||
TunnelConfig cfg = TunnelUtil.createConfigFromPreferences(getActivity(), mGroup, mTunnelId);
|
||||
TunnelUtil.saveTunnel(I2PAppContext.getGlobalContext(), mGroup, mTunnelId, cfg);
|
||||
SaveTunnelTask task = new SaveTunnelTask(mGroup, mTunnelId, cfg);
|
||||
try {
|
||||
// TODO: There used to be a possible ANR here, because the underlying I2P code
|
||||
// checks if the session is open as part of updating its config. We may need to save
|
||||
// completely asynchronously (and ensure we do actually save before the app closes).
|
||||
task.execute().get();
|
||||
} catch (InterruptedException e) {
|
||||
Util.e("Interrupted while saving tunnel config", e);
|
||||
} catch (ExecutionException e) {
|
||||
Util.e("Error while saving tunnel config", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.i2p.android.i2ptunnel.preferences;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
@ -135,14 +136,17 @@ public class GeneralTunnelPreferenceFragment extends BaseTunnelPreferenceFragmen
|
||||
protected Void doInBackground(Void... voids) {
|
||||
Set<String> interfaceSet = Addresses.getAllAddresses();
|
||||
final String[] interfaces = interfaceSet.toArray(new String[interfaceSet.size()]);
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
reachableBy.setEntries(interfaces);
|
||||
reachableBy.setEntryValues(interfaces);
|
||||
reachableBy.setEnabled(true);
|
||||
}
|
||||
});
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
reachableBy.setEntries(interfaces);
|
||||
reachableBy.setEntryValues(interfaces);
|
||||
reachableBy.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}.execute();
|
||||
|
@ -0,0 +1,32 @@
|
||||
package net.i2p.android.i2ptunnel.util;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||
import net.i2p.i2ptunnel.ui.TunnelConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Save a TunnelConfig.
|
||||
*
|
||||
* This must be performed in a background thread, because the underlying I2P code calls
|
||||
* InetAddress.getByName(), which will trigger a NetworkOnMainThreadException otherwise.
|
||||
*/
|
||||
public class SaveTunnelTask extends AsyncTask<Void, Void, List<String>> {
|
||||
TunnelControllerGroup mGroup;
|
||||
int mTunnelId;
|
||||
TunnelConfig mCfg;
|
||||
|
||||
public SaveTunnelTask(TunnelControllerGroup group, int tunnelId, TunnelConfig cfg) {
|
||||
mGroup = group;
|
||||
mTunnelId = tunnelId;
|
||||
mCfg = cfg;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> doInBackground(Void... voids) {
|
||||
return TunnelUtil.saveTunnel(I2PAppContext.getGlobalContext(), mGroup, mTunnelId, mCfg);
|
||||
}
|
||||
}
|
@ -68,6 +68,10 @@ public class ConnectionLimitPreference extends EditTextPreference {
|
||||
|
||||
@Override
|
||||
protected boolean persistString(String value) {
|
||||
return value != null && persistInt(Integer.valueOf(value));
|
||||
try {
|
||||
return value != null && persistInt(Integer.valueOf(value));
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ public class IntEditTextPreference extends EditTextPreference {
|
||||
|
||||
@Override
|
||||
protected boolean persistString(String value) {
|
||||
return value != null && persistInt(Integer.valueOf(value));
|
||||
try {
|
||||
return value != null && persistInt(Integer.valueOf(value));
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,13 +63,13 @@ public class ConsoleContainer extends Fragment {
|
||||
startActivity(graphs);
|
||||
}
|
||||
});
|
||||
mConsoleMenu.findViewById(R.id.action_peers).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent peers = new Intent(getActivity(), PeersActivity.class);
|
||||
startActivity(peers);
|
||||
}
|
||||
});
|
||||
// mConsoleMenu.findViewById(R.id.action_peers).setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// Intent peers = new Intent(getActivity(), PeersActivity.class);
|
||||
// startActivity(peers);
|
||||
// }
|
||||
// });
|
||||
mConsoleMenu.findViewById(R.id.action_netdb).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@ -87,11 +87,6 @@ public class ConsoleContainer extends Fragment {
|
||||
inflater.inflate(R.menu.activity_main_actions, menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
setMenuVisibility();
|
||||
}
|
||||
|
||||
private void setMenuVisibility() {
|
||||
boolean routerRunning = Util.getRouterContext() != null;
|
||||
mConsoleMenu.findViewById(R.id.action_logs).setVisibility(routerRunning ? View.VISIBLE : View.GONE);
|
||||
@ -100,8 +95,8 @@ public class ConsoleContainer extends Fragment {
|
||||
if (getActivity() != null) {
|
||||
boolean advanced = PreferenceManager.getDefaultSharedPreferences(getActivity())
|
||||
.getBoolean("i2pandroid.main.showStats", false);
|
||||
mConsoleMenu.findViewById(R.id.action_peers).setVisibility(
|
||||
advanced && routerRunning ? View.VISIBLE : View.GONE);
|
||||
// mConsoleMenu.findViewById(R.id.action_peers).setVisibility(
|
||||
// advanced && routerRunning ? View.VISIBLE : View.GONE);
|
||||
mConsoleMenu.findViewById(R.id.action_netdb).setVisibility(
|
||||
advanced && routerRunning ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ public class MainFragment extends I2PFragmentBase {
|
||||
|
||||
public AlphaComparator(RouterContext ctx) {
|
||||
_ctx = ctx;
|
||||
xsc = _(ctx, SHARED_CLIENTS);
|
||||
xsc = _t(ctx, SHARED_CLIENTS);
|
||||
}
|
||||
|
||||
public int compare(Destination lhs, Destination rhs) {
|
||||
@ -559,12 +559,12 @@ public class MainFragment extends I2PFragmentBase {
|
||||
if (name == null)
|
||||
name = d.calculateHash().toBase64().substring(0, 6);
|
||||
else
|
||||
name = _(ctx, name);
|
||||
name = _t(ctx, name);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
private String _(RouterContext ctx, String s) {
|
||||
private String _t(RouterContext ctx, String s) {
|
||||
if (SHARED_CLIENTS.equals(s))
|
||||
return getString(R.string.shared_clients);
|
||||
else
|
||||
@ -648,9 +648,11 @@ public class MainFragment extends I2PFragmentBase {
|
||||
private void checkFirstStart() {
|
||||
I2PActivityBase ab = (I2PActivityBase) getActivity();
|
||||
boolean firstStart = ab.getPref(PREF_FIRST_START, true);
|
||||
if (firstStart) {
|
||||
// Check ab.isFinishing() because DialogFragment.show() will throw IllegalStateException if
|
||||
// called after ab.onSaveInstanceState().
|
||||
if (firstStart && !ab.isFinishing()) {
|
||||
FirstStartDialog dialog = new FirstStartDialog();
|
||||
dialog.show(getActivity().getSupportFragmentManager(), "firststart");
|
||||
dialog.show(ab.getSupportFragmentManager(), "firststart");
|
||||
ab.setPref(PREF_FIRST_START, false);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.i2p.android.router.addressbook;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@ -20,26 +21,51 @@ public class AddressbookAddWizardActivity extends AbstractWizardActivity {
|
||||
|
||||
@Override
|
||||
protected DialogFragment onGetFinishWizardDialog() {
|
||||
return new DialogFragment() {
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage("Add to private addressbook?")
|
||||
.setPositiveButton("Add",
|
||||
new DialogInterface.OnClickListener() {
|
||||
return FinishWizardDialogFragment.newInstance();
|
||||
}
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent result = new Intent();
|
||||
setResult(Activity.RESULT_OK, result);
|
||||
result.putExtra(AddressbookContainer.ADD_WIZARD_DATA, mWizardModel.save());
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
public void onFinishWizard() {
|
||||
Intent result = new Intent();
|
||||
result.putExtra(AddressbookContainer.ADD_WIZARD_DATA, mWizardModel.save());
|
||||
setResult(Activity.RESULT_OK, result);
|
||||
finish();
|
||||
}
|
||||
|
||||
public static class FinishWizardDialogFragment extends DialogFragment {
|
||||
AddressbookAddWizardActivity mListener;
|
||||
|
||||
public static DialogFragment newInstance() {
|
||||
return new FinishWizardDialogFragment();
|
||||
}
|
||||
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
// Verify that the host fragment implements the callback interface
|
||||
try {
|
||||
// Instantiate the AddressbookAddWizardActivity so we can send events to the host
|
||||
mListener = (AddressbookAddWizardActivity) context;
|
||||
} catch (ClassCastException e) {
|
||||
// The fragment doesn't implement the interface, throw exception
|
||||
throw new ClassCastException(context.toString()
|
||||
+ " must be AddressbookAddWizardActivity");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage("Add to private addressbook?")
|
||||
.setPositiveButton("Add",
|
||||
new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
mListener.onFinishWizard();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import com.eowise.recyclerview.stickyheaders.StickyHeadersBuilder;
|
||||
import com.eowise.recyclerview.stickyheaders.StickyHeadersItemDecoration;
|
||||
import com.pnikosis.materialishprogress.ProgressWheel;
|
||||
|
||||
import net.i2p.addressbook.Daemon;
|
||||
import net.i2p.android.router.R;
|
||||
import net.i2p.android.router.service.RouterService;
|
||||
import net.i2p.android.router.service.State;
|
||||
@ -167,15 +166,23 @@ public class AddressbookFragment extends Fragment implements
|
||||
int loaderId = PRIVATE_BOOK.equals(mBook) ?
|
||||
PRIVATE_LOADER_ID : ROUTER_LOADER_ID;
|
||||
|
||||
if (state == State.STOPPING || state == State.STOPPED ||
|
||||
state == State.MANUAL_STOPPING ||
|
||||
state == State.MANUAL_STOPPED ||
|
||||
state == State.MANUAL_QUITTING ||
|
||||
state == State.MANUAL_QUITTED)
|
||||
getLoaderManager().destroyLoader(loaderId);
|
||||
else {
|
||||
mRecyclerView.setLoading(true);
|
||||
getLoaderManager().initLoader(loaderId, null, this);
|
||||
try {
|
||||
LoaderManager manager = getLoaderManager();
|
||||
if (state == State.INIT ||
|
||||
state == State.STARTING || // Wait until RouterContext is initialised
|
||||
state == State.STOPPING ||
|
||||
state == State.STOPPED ||
|
||||
state == State.MANUAL_STOPPING ||
|
||||
state == State.MANUAL_STOPPED ||
|
||||
state == State.MANUAL_QUITTING ||
|
||||
state == State.MANUAL_QUITTED)
|
||||
manager.destroyLoader(loaderId);
|
||||
else {
|
||||
mRecyclerView.setLoading(true);
|
||||
manager.initLoader(loaderId, null, this);
|
||||
}
|
||||
} catch (IllegalStateException ise) {
|
||||
// Fragment isn't attached to any activity, so ignore state change
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,8 +214,11 @@ public class AddressbookFragment extends Fragment implements
|
||||
mAddToAddressbook.setVisibility(rCtx == null ? View.GONE : View.VISIBLE);
|
||||
|
||||
// Only show "Reload subscriptions" for router addressbook
|
||||
menu.findItem(R.id.action_reload_subscriptions).setVisible(
|
||||
rCtx != null && !PRIVATE_BOOK.equals(mBook));
|
||||
MenuItem reloadSubs = menu.findItem(R.id.action_reload_subscriptions);
|
||||
if (reloadSubs != null) {
|
||||
reloadSubs.setVisible(
|
||||
rCtx != null && !PRIVATE_BOOK.equals(mBook));
|
||||
}
|
||||
|
||||
// Only allow adding to private book
|
||||
if (!PRIVATE_BOOK.equals(mBook) && mAddToAddressbook != null) {
|
||||
@ -223,9 +233,12 @@ public class AddressbookFragment extends Fragment implements
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_reload_subscriptions:
|
||||
Daemon.wakeup();
|
||||
Toast.makeText(getActivity(), "Reloading subscriptions...",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
RouterContext rCtx = Util.getRouterContext();
|
||||
if (rCtx != null) {
|
||||
rCtx.namingService().requestUpdate(null);
|
||||
Toast.makeText(getActivity(), "Reloading subscriptions...",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
@ -61,7 +61,7 @@ public class AddressbookSettingsActivity extends AppCompatActivity {
|
||||
|
||||
private boolean load() {
|
||||
String res = FileUtil.readTextFile(i2pDir.getAbsolutePath(), -1, true);
|
||||
if (res.length() > 0) {
|
||||
if (res != null && res.length() > 0) {
|
||||
text_content_subscriptions.setText(res);
|
||||
return true;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.Job;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.RouterLaunch;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@ -213,16 +212,18 @@ public class RouterService extends Service {
|
||||
//Util.d(MARKER + this + " JBigI speed test finished, launching router");
|
||||
|
||||
// Launch the router!
|
||||
RouterLaunch.main(null);
|
||||
// TODO Store this somewhere instead of relying on global context?
|
||||
Router r = new Router();
|
||||
r.runRouter();
|
||||
synchronized(_stateLock) {
|
||||
if(_state != State.STARTING) {
|
||||
return;
|
||||
}
|
||||
setState(State.RUNNING);
|
||||
_statusBar.replace(StatusBar.ICON_RUNNING, R.string.notification_status_running);
|
||||
_context = Util.getRouterContext();
|
||||
_context = r.getContext();
|
||||
if (_context == null) {
|
||||
throw new IllegalStateException("No contexts. This is usually because the router is either starting up or shutting down.");
|
||||
throw new IllegalStateException("Router has no context?");
|
||||
}
|
||||
_context.router().setKillVMOnEnd(false);
|
||||
Job loadJob = new LoadClientsJob(RouterService.this, _context, _notif);
|
||||
|
@ -39,7 +39,7 @@ public class PeersFragment extends I2PFragmentBase {
|
||||
wv.getSettings().setLoadsImagesAutomatically(true); // was false
|
||||
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
|
||||
wv.getSettings().setUseWideViewPort(true);
|
||||
_wvClient = new I2PWebViewClient();
|
||||
_wvClient = new I2PWebViewClient(this);
|
||||
wv.setWebViewClient(_wvClient);
|
||||
wv.getSettings().setBuiltInZoomControls(true);
|
||||
return v;
|
||||
|
@ -11,9 +11,10 @@ import android.view.ViewGroup;
|
||||
import com.androidplot.xy.BarFormatter;
|
||||
import com.androidplot.xy.BarRenderer;
|
||||
import com.androidplot.xy.BoundaryMode;
|
||||
import com.androidplot.xy.StepMode;
|
||||
import com.androidplot.xy.XYGraphWidget;
|
||||
import com.androidplot.xy.XYPlot;
|
||||
import com.androidplot.xy.XYSeries;
|
||||
import com.androidplot.xy.XYStepMode;
|
||||
|
||||
import net.i2p.android.router.I2PFragmentBase;
|
||||
import net.i2p.android.router.R;
|
||||
@ -120,26 +121,25 @@ public class RateGraphFragment extends I2PFragmentBase {
|
||||
|
||||
_ratePlot.addSeries(rateSeries, new BarFormatter(Color.argb(200, 0, 80, 0), Color.argb(200, 0, 80, 0)));
|
||||
_ratePlot.calculateMinMaxVals();
|
||||
long maxX = _ratePlot.getCalculatedMaxX().longValue();
|
||||
long maxX = _ratePlot.getBounds().getMaxX().longValue();
|
||||
|
||||
Util.d("Adding plot updater to listener");
|
||||
_listener.addObserver(_plotUpdater);
|
||||
|
||||
// Only one line, so hide the legend
|
||||
_ratePlot.getLegendWidget().setVisible(false);
|
||||
_ratePlot.getLegend().setVisible(false);
|
||||
|
||||
BarRenderer renderer = (BarRenderer) _ratePlot.getRenderer(BarRenderer.class);
|
||||
renderer.setBarWidthStyle(BarRenderer.BarWidthStyle.VARIABLE_WIDTH);
|
||||
renderer.setBarGap(0);
|
||||
BarRenderer renderer = _ratePlot.getRenderer(BarRenderer.class);
|
||||
renderer.setBarGroupWidth(BarRenderer.BarGroupWidthMode.FIXED_GAP, 0);
|
||||
|
||||
_ratePlot.setDomainUpperBoundary(maxX, BoundaryMode.GROW);
|
||||
_ratePlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 15 * 60 * 1000);
|
||||
_ratePlot.setTicksPerDomainLabel(4);
|
||||
_ratePlot.setDomainStep(StepMode.INCREMENT_BY_VAL, 15 * 60 * 1000);
|
||||
_ratePlot.setLinesPerDomainLabel(4);
|
||||
|
||||
_ratePlot.setRangeLowerBoundary(0, BoundaryMode.FIXED);
|
||||
_ratePlot.setTicksPerRangeLabel(5);
|
||||
_ratePlot.setLinesPerRangeLabel(5);
|
||||
|
||||
_ratePlot.setDomainValueFormat(new Format() {
|
||||
_ratePlot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.BOTTOM).setFormat(new Format() {
|
||||
private DateFormat dateFormat = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
|
||||
@Override
|
||||
@ -157,13 +157,13 @@ public class RateGraphFragment extends I2PFragmentBase {
|
||||
});
|
||||
|
||||
final int finalK = _k;
|
||||
_ratePlot.setRangeValueFormat(new Format() {
|
||||
_ratePlot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.LEFT).setFormat(new Format() {
|
||||
|
||||
@Override
|
||||
public StringBuffer format(Object obj, @NonNull StringBuffer toAppendTo,
|
||||
@NonNull FieldPosition pos) {
|
||||
double val = ((Number) obj).doubleValue();
|
||||
double maxY = _ratePlot.getCalculatedMaxY().doubleValue();
|
||||
double maxY = _ratePlot.getBounds().getMaxY().doubleValue();
|
||||
|
||||
if (val == 0 || maxY < finalK) {
|
||||
return new DecimalFormat("0").format(val, toAppendTo, pos);
|
||||
@ -194,8 +194,8 @@ public class RateGraphFragment extends I2PFragmentBase {
|
||||
|
||||
private void updatePlot() {
|
||||
_ratePlot.calculateMinMaxVals();
|
||||
double maxY = _ratePlot.getCalculatedMaxY().doubleValue();
|
||||
_ratePlot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, getRangeStep(maxY, _k));
|
||||
double maxY = _ratePlot.getBounds().getMaxY().doubleValue();
|
||||
_ratePlot.setRangeStep(StepMode.INCREMENT_BY_VAL, getRangeStep(maxY, _k));
|
||||
|
||||
_ratePlot.redraw();
|
||||
}
|
||||
|
@ -299,7 +299,15 @@ public abstract class Util implements I2PConstants {
|
||||
|
||||
public static String getFileDir(Context context) {
|
||||
// This needs to be changed so that we can have an alternative place
|
||||
return context.getFilesDir().getAbsolutePath();
|
||||
File f = context.getFilesDir();
|
||||
if (f == null) {
|
||||
// https://code.google.com/p/android/issues/detail?id=8886
|
||||
// Seems to be a race condition; try again.
|
||||
// Supposedly only in pre-4.4 devices, but this was observed on a
|
||||
// Samsung Galaxy Grand Prime (grandprimeve3g), 1024MB RAM, Android 5.1
|
||||
f = context.getFilesDir();
|
||||
}
|
||||
return f.getAbsolutePath();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,12 @@
|
||||
package net.i2p.android.router.web;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.webkit.HttpAuthHandler;
|
||||
@ -29,6 +31,7 @@ import java.io.OutputStream;
|
||||
|
||||
public class I2PWebViewClient extends WebViewClient {
|
||||
|
||||
private Fragment _parentFrag;
|
||||
private BGLoad _lastTask;
|
||||
/** save it here so we can dismiss it in onPageFinished() */
|
||||
private ProgressDialog _lastDialog;
|
||||
@ -40,6 +43,11 @@ public class I2PWebViewClient extends WebViewClient {
|
||||
private static final String ERROR_URL = "<p>Unable to load URL: ";
|
||||
private static final String ERROR_ROUTER = "<p>Your router (or the HTTP proxy) does not appear to be running.</p>";
|
||||
|
||||
public I2PWebViewClient(Fragment parentFrag) {
|
||||
super();
|
||||
_parentFrag = parentFrag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
Util.d("Should override? " + url);
|
||||
@ -102,7 +110,7 @@ public class I2PWebViewClient extends WebViewClient {
|
||||
///////// API 8
|
||||
// Otherwise hangs waiting for CSS
|
||||
view.getSettings().setBlockNetworkLoads(false);
|
||||
_lastDialog = new ProgressDialog(view.getContext());
|
||||
_lastDialog = new ProgressDialog(_parentFrag.getContext());
|
||||
BGLoad task = new BackgroundEepLoad(view, h, _lastDialog);
|
||||
_lastTask = task;
|
||||
task.execute(url);
|
||||
@ -215,10 +223,12 @@ public class I2PWebViewClient extends WebViewClient {
|
||||
|
||||
private abstract static class BGLoad extends AsyncTask<String, Integer, Integer> implements DialogInterface.OnCancelListener {
|
||||
protected final WebView _view;
|
||||
protected final Context _ctx;
|
||||
protected final ProgressDialog _dialog;
|
||||
|
||||
public BGLoad(WebView view, ProgressDialog dialog) {
|
||||
_view = view;
|
||||
_ctx = view.getContext();
|
||||
if (dialog != null)
|
||||
dialog.setCancelable(true);
|
||||
_dialog = dialog;
|
||||
@ -305,9 +315,9 @@ public class I2PWebViewClient extends WebViewClient {
|
||||
protected Integer doInBackground(String... urls) {
|
||||
final String url = urls[0];
|
||||
Uri uri = Uri.parse(url);
|
||||
File cacheFile = AppCache.getInstance(_view.getContext()).getCacheFile(uri);
|
||||
File cacheFile = AppCache.getInstance(_ctx).getCacheFile(uri);
|
||||
if (cacheFile.exists()) {
|
||||
final Uri resUri = AppCache.getInstance(_view.getContext()).getCacheUri(uri);
|
||||
final Uri resUri = AppCache.getInstance(_ctx).getCacheUri(uri);
|
||||
Util.d("Loading " + url + " from resource cache " + resUri);
|
||||
_view.post(new Runnable() {
|
||||
@Override
|
||||
@ -325,7 +335,7 @@ public class I2PWebViewClient extends WebViewClient {
|
||||
//EepGetFetcher fetcher = new EepGetFetcher(url);
|
||||
OutputStream out = null;
|
||||
try {
|
||||
out = AppCache.getInstance(_view.getContext()).createCacheFile(uri);
|
||||
out = AppCache.getInstance(_ctx).createCacheFile(uri);
|
||||
// write error to stream
|
||||
EepGetFetcher fetcher = new EepGetFetcher(url, out, true);
|
||||
fetcher.addStatusListener(this);
|
||||
@ -338,11 +348,11 @@ public class I2PWebViewClient extends WebViewClient {
|
||||
if (success) {
|
||||
// store in cache, get content URL, and load that way
|
||||
// Set as current base
|
||||
final Uri content = AppCache.getInstance(_view.getContext()).addCacheFile(uri, true);
|
||||
final Uri content = AppCache.getInstance(_ctx).addCacheFile(uri, true);
|
||||
if (content != null) {
|
||||
Util.d("Stored cache in " + content);
|
||||
} else {
|
||||
AppCache.getInstance(_view.getContext()).removeCacheFile(uri);
|
||||
AppCache.getInstance(_ctx).removeCacheFile(uri);
|
||||
Util.d("cache create error");
|
||||
return 0;
|
||||
}
|
||||
@ -381,7 +391,7 @@ public class I2PWebViewClient extends WebViewClient {
|
||||
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
||||
}
|
||||
}
|
||||
AppCache.getInstance(_view.getContext()).removeCacheFile(uri);
|
||||
AppCache.getInstance(_ctx).removeCacheFile(uri);
|
||||
Util.d("loading error data URL: " + url);
|
||||
final String finalMsg = msg;
|
||||
_view.post(new Runnable() {
|
||||
@ -403,30 +413,35 @@ public class I2PWebViewClient extends WebViewClient {
|
||||
protected void onProgressUpdate(Integer... progress) {
|
||||
if (isCancelled())
|
||||
return;
|
||||
int prog = progress[0];
|
||||
if (prog < 0) {
|
||||
_dialog.setTitle("Contacting...");
|
||||
_dialog.setMessage(_host);
|
||||
_dialog.setIndeterminate(true);
|
||||
_dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
_dialog.setOnCancelListener(this);
|
||||
_dialog.show();
|
||||
} else if (prog == 0 && _total > 0) {
|
||||
_dialog.setTitle("Downloading...");
|
||||
_dialog.setMessage("...from " + _host);
|
||||
_dialog.setIndeterminate(false);
|
||||
_dialog.setMax(_total);
|
||||
_dialog.setProgress(0);
|
||||
} else if (_total > 0) {
|
||||
// so it isn't at 100% while loading images and CSS
|
||||
_dialog.setProgress(Math.min(prog, _total * 99 / 100));
|
||||
} else if (prog > 0) {
|
||||
// ugly, need custom
|
||||
_dialog.setTitle("Downloading...");
|
||||
_dialog.setMessage("...from " + _host + ": " + DataHelper.formatSize(prog) + 'B');
|
||||
//_dialog.setProgress(prog);
|
||||
} else {
|
||||
// nothing
|
||||
try {
|
||||
int prog = progress[0];
|
||||
if (prog < 0) {
|
||||
_dialog.setTitle("Contacting...");
|
||||
_dialog.setMessage(_host);
|
||||
_dialog.setIndeterminate(true);
|
||||
_dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
_dialog.setOnCancelListener(this);
|
||||
_dialog.show();
|
||||
} else if (prog == 0 && _total > 0) {
|
||||
_dialog.setTitle("Downloading...");
|
||||
_dialog.setMessage("...from " + _host);
|
||||
_dialog.setIndeterminate(false);
|
||||
_dialog.setMax(_total);
|
||||
_dialog.setProgress(0);
|
||||
} else if (_total > 0) {
|
||||
// so it isn't at 100% while loading images and CSS
|
||||
_dialog.setProgress(Math.min(prog, _total * 99 / 100));
|
||||
} else if (prog > 0) {
|
||||
// ugly, need custom
|
||||
_dialog.setTitle("Downloading...");
|
||||
_dialog.setMessage("...from " + _host + ": " + DataHelper.formatSize(prog) + 'B');
|
||||
//_dialog.setProgress(prog);
|
||||
} else {
|
||||
// nothing
|
||||
}
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// throws IAE - not attached to window manager - perhaps due to screen rotation?
|
||||
Util.e("Error while updating I2PWebViewClient dialog", iae);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class WebFragment extends I2PFragmentBase {
|
||||
TextView tv = (TextView) v.findViewById(R.id.browser_status);
|
||||
tv.setText(WARNING);
|
||||
WebView wv = (WebView) v.findViewById(R.id.browser_webview);
|
||||
_wvClient = new I2PWebViewClient();
|
||||
_wvClient = new I2PWebViewClient(this);
|
||||
wv.setWebViewClient(_wvClient);
|
||||
wv.getSettings().setBuiltInZoomControls(true);
|
||||
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
|
||||
|
@ -31,6 +31,7 @@ public class SingleTextFieldPage extends Page {
|
||||
protected String mDef = null;
|
||||
protected String mDesc = "";
|
||||
protected boolean mNumeric = false;
|
||||
private String mFeedback;
|
||||
|
||||
public SingleTextFieldPage(ModelCallbacks callbacks, String title) {
|
||||
super(callbacks, title);
|
||||
@ -81,14 +82,24 @@ public class SingleTextFieldPage extends Page {
|
||||
// Override these in subclasses to add content verification.
|
||||
|
||||
public boolean isValid() {
|
||||
if (mNumeric) {
|
||||
try {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
Integer.parseInt(mData.getString(SIMPLE_DATA_KEY));
|
||||
} catch (NumberFormatException e) {
|
||||
mFeedback = "Not a number";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mFeedback = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean showFeedback() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getFeedback() {
|
||||
return "";
|
||||
return mFeedback;
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,12 @@ public abstract class AbstractWizardActivity extends FragmentActivity implements
|
||||
// Create the WizardModel before super.onCreate() in case a Fragment
|
||||
// is created and tries to call e.g. onGetPage()
|
||||
mWizardModel = onCreateModel();
|
||||
if (savedInstanceState != null)
|
||||
mWizardModel.load(savedInstanceState.getBundle("model"));
|
||||
if (savedInstanceState != null) {
|
||||
Bundle model = savedInstanceState.getBundle("model");
|
||||
if (model != null) {
|
||||
mWizardModel.load(model);
|
||||
}
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_wizard);
|
||||
|
@ -190,6 +190,10 @@ public class I2PB64DestinationFragment extends Fragment {
|
||||
Util.e("Could not find B64 file", fnfe);
|
||||
Toast.makeText(getActivity(), "Could not find B64 file.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} catch (SecurityException se) {
|
||||
Util.e("Could not open B64 file", se);
|
||||
Toast.makeText(getActivity(), "Could not open B64 file.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} finally {
|
||||
if (br != null)
|
||||
try {
|
||||
|
Before Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 337 B |
Before Width: | Height: | Size: 353 B |
Before Width: | Height: | Size: 504 B |
Before Width: | Height: | Size: 423 B |
Before Width: | Height: | Size: 287 B |
Before Width: | Height: | Size: 339 B |
Before Width: | Height: | Size: 246 B |
Before Width: | Height: | Size: 535 B |
Before Width: | Height: | Size: 433 B |
Before Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 430 B |
Before Width: | Height: | Size: 181 B |
Before Width: | Height: | Size: 276 B |
Before Width: | Height: | Size: 282 B |
Before Width: | Height: | Size: 531 B |
Before Width: | Height: | Size: 650 B |
Before Width: | Height: | Size: 504 B |
Before Width: | Height: | Size: 479 B |
Before Width: | Height: | Size: 641 B |
Before Width: | Height: | Size: 767 B |
Before Width: | Height: | Size: 331 B |
Before Width: | Height: | Size: 640 B |
Before Width: | Height: | Size: 180 B |
Before Width: | Height: | Size: 652 B |
Before Width: | Height: | Size: 806 B |
Before Width: | Height: | Size: 174 B |
Before Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 263 B |
Before Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 353 B |
Before Width: | Height: | Size: 314 B |
Before Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 272 B |
Before Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 421 B |
Before Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 211 B |
Before Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 297 B |
Before Width: | Height: | Size: 168 B |
Before Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 454 B |
Before Width: | Height: | Size: 346 B |
Before Width: | Height: | Size: 355 B |
Before Width: | Height: | Size: 464 B |
Before Width: | Height: | Size: 561 B |
Before Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 488 B |
Before Width: | Height: | Size: 533 B |
Before Width: | Height: | Size: 198 B |
Before Width: | Height: | Size: 336 B |
Before Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 402 B |
Before Width: | Height: | Size: 614 B |
Before Width: | Height: | Size: 464 B |
Before Width: | Height: | Size: 330 B |
Before Width: | Height: | Size: 378 B |
Before Width: | Height: | Size: 270 B |
Before Width: | Height: | Size: 737 B |
Before Width: | Height: | Size: 530 B |
Before Width: | Height: | Size: 294 B |