Compare commits
287 Commits
android-0.
...
android-1.
Author | SHA1 | Date | |
---|---|---|---|
dec68432bc | |||
f93fc155ef | |||
e348af340a | |||
aa3631ed33 | |||
f2088ad1e5 | |||
008e9b7961 | |||
90a46bcc3f | |||
f69f748064 | |||
640a2e1918 | |||
8aead91700 | |||
b18a2e6241 | |||
09c3e6e12c | |||
74bf0eade2 | |||
2fa6e7f3cb | |||
24b741be1e | |||
ac8ce6f916 | |||
cd7d0ad723 | |||
c5a0c3608d | |||
3863c0e183 | |||
69ea3d8bde | |||
7cafe6da48 | |||
9464b46ad0 | |||
c230a5a101 | |||
3d37f2ae07 | |||
f88aafe292 | |||
aa2dab1d3c | |||
8e85eaa2f0 | |||
6a1848caf6 | |||
aa36b4cb14 | |||
78d4b12142 | |||
c2f3a80dec | |||
a679784aab | |||
835667437b | |||
f016edec7a | |||
1e3b517219 | |||
f4e3b15fcf | |||
fc4154be67 | |||
5bf0b18767 | |||
eb5ef3129b | |||
6e87d248c0 | |||
c9b0aff142 | |||
5acac0dbc4 | |||
0b42a7ee64 | |||
c3a798ee3d | |||
e682369311 | |||
14b953f145 | |||
036c807d6b | |||
a41fca95df | |||
26fdf40f25 | |||
070af6529c | |||
7ba0892351 | |||
5b9cdb9f9f | |||
b79d39a74a | |||
5fc5aed0c9 | |||
aec25ab374 | |||
9d5c495936 | |||
4dc2bb6b01 | |||
373e013911 | |||
83bb7096a7 | |||
cc1c4690a2 | |||
69ad581235 | |||
4be227631d | |||
3f3f1f8e3d | |||
22290da1a4 | |||
7caf21d552 | |||
701860a525 | |||
7615aca89e | |||
cae8ed2ae3 | |||
a523e1cb4a | |||
5e048af9c1 | |||
77b6c4d30f | |||
983a94e1c4 | |||
1f79323d66 | |||
d86d3ad5ae | |||
c41b064045 | |||
4c299ecda3 | |||
761f427366 | |||
f4c4bfe8be | |||
7f15a6f1e1 | |||
5734760d58 | |||
3244adfcd2 | |||
ce62b0fb97 | |||
64673ee185 | |||
a36cabdcc8 | |||
1e8531c731 | |||
0935659d6d | |||
bef5f7e746 | |||
d64e8359c1 | |||
5fd77ea62d | |||
8626ac2913 | |||
1258f18bc3 | |||
8b677abd3c | |||
f3d1e89002 | |||
f39c9a0fc4 | |||
3186caa6bb | |||
fc1259d8a8 | |||
848d07331e | |||
9794d26d0c | |||
76cd9c85ef | |||
d4c7c480fb | |||
00aa80d104 | |||
20086685aa | |||
86a8effd82 | |||
55d6e6d24e | |||
3b05046df3 | |||
b8587cd0ab | |||
61dd550040 | |||
478ff63889 | |||
e747619b85 | |||
f043bb3d72 | |||
98d8106f56 | |||
74eb0ce4f6 | |||
d79813d6d1 | |||
8f60c6ce9e | |||
7e0d017858 | |||
8470435ee2 | |||
5023d69222 | |||
34c7464f5b | |||
2da6fe9c62 | |||
1927c9e5a3 | |||
1ace085d13 | |||
95e6c1f7a6 | |||
03bdd575a7 | |||
98c5313d75 | |||
c047bdf085 | |||
e113ef0002 | |||
3e9b47307d | |||
2d864ad8b1 | |||
5b7f9bd452 | |||
3c89749f94 | |||
edbd5fd7ea | |||
faf8bf74af | |||
851e774e7a | |||
dcea801116 | |||
cb5235e6da | |||
5c7eaf2484 | |||
764cfc91ec | |||
177a2c6dc1 | |||
4dccd1dbae | |||
50141eb24b | |||
4dab632bc8 | |||
350515041a | |||
5ba294c2c2 | |||
a215363206 | |||
4bd647c67c | |||
b951892c05 | |||
16e05e0dd8 | |||
5bdf119b81 | |||
b73b72c9c8 | |||
0bae211da5 | |||
709392e8b6 | |||
80ed1e71da | |||
6c0a60892f | |||
7f13aa26fb | |||
7167a11844 | |||
1f140bf95a | |||
940b2b83a1 | |||
bdbebe11c4 | |||
51ca137102 | |||
f0ff4eeab7 | |||
93d103e5ad | |||
b87d77d5e3 | |||
ffbd8cfb76 | |||
2d1664574d | |||
5d3aa1f625 | |||
3fa53c7654 | |||
84ecf55ff8 | |||
72ad40ecfc | |||
2f48898235 | |||
39758c8cf4 | |||
ecc5509007 | |||
0e75b3e957 | |||
7b4c80216d | |||
70bbc18054 | |||
09fcef23a4 | |||
333f09073a | |||
58cb33aa77 | |||
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 | |||
19036a71cb | |||
40f3fbf9c5 | |||
1127fb0195 | |||
df81efe6bc | |||
784ca3691b | |||
0fa4241ce6 | |||
5063d276de | |||
81d0e43f0f | |||
1637a9007d | |||
ce0f01cf46 | |||
dd579d4f5b | |||
5703d8cc6d | |||
b8768ae9fe | |||
54dc2c88bf | |||
dba01b8c18 | |||
b7b3eb7019 | |||
430e2ab826 | |||
87383a2ec8 | |||
f63bfe1dea | |||
ff2021c0aa | |||
51f7e07080 | |||
7797e067a5 | |||
cf09a21f1e | |||
914294927d | |||
bd0455c413 | |||
97f3d937ee | |||
ff102bfe73 | |||
e31a350398 | |||
43a8f29794 | |||
bbca783b20 | |||
6d4fe52f8e | |||
ecb08a54fb | |||
7bd4524fd8 | |||
40f08d56f6 | |||
fe61e35146 | |||
be3f74d71f | |||
8dcfa816e3 | |||
ae05e22670 | |||
79a4fa0407 | |||
bb958b969a |
3
.dockerignore
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
app/pkg-temp
|
||||||
|
app/build
|
||||||
|
app/pkg-mavencentral
|
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
etc/docker.signing.properties
|
||||||
|
signing.properties
|
52
.mtn-ignore
@ -1,52 +0,0 @@
|
|||||||
# Just to try and prevent some noob disasters.
|
|
||||||
# Use mtn add --no-respect-ignore foo.jar to ignore this ignore list
|
|
||||||
_jsp\.java$
|
|
||||||
\.bz2$
|
|
||||||
\.class$
|
|
||||||
\.diff$
|
|
||||||
\.exe$
|
|
||||||
\.fba$
|
|
||||||
\.gz$
|
|
||||||
\.jar$
|
|
||||||
\.out$
|
|
||||||
\.patch$
|
|
||||||
\.sig$
|
|
||||||
\.sud$
|
|
||||||
\.su2$
|
|
||||||
\.tar$
|
|
||||||
\.war$
|
|
||||||
\.zip$
|
|
||||||
^\.
|
|
||||||
^build/
|
|
||||||
^pkg-temp/
|
|
||||||
~$
|
|
||||||
/build/
|
|
||||||
/classes/
|
|
||||||
|
|
||||||
# Android-specific ignores
|
|
||||||
^lib/client/libs
|
|
||||||
^routerjars/libs
|
|
||||||
local.properties
|
|
||||||
signing.properties
|
|
||||||
|
|
||||||
#IntelliJ IDEA
|
|
||||||
^.idea
|
|
||||||
.*.iml
|
|
||||||
.*.ipr
|
|
||||||
.*.iws
|
|
||||||
|
|
||||||
#Gradle
|
|
||||||
build
|
|
||||||
|
|
||||||
# I2P-specific ignores
|
|
||||||
^app/src/main/res/drawable/i2plogo.png
|
|
||||||
^app/src/main/res/raw/blocklist_txt
|
|
||||||
^app/src/main/res/raw/hosts_txt
|
|
||||||
^app/src/main/res/raw/.*_ht
|
|
||||||
^app/src/main/res/raw/license_
|
|
||||||
^app/src/main/res/raw/certificates_zip
|
|
||||||
^app/src/main/assets/themes/console/images
|
|
||||||
^app/src/main/assets/themes/console/light/console.css
|
|
||||||
^app/src/main/assets/themes/console/light/images/header.png
|
|
||||||
^scripts/build.number
|
|
||||||
^scripts/version.properties
|
|
@ -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]
|
[I2P.android]
|
||||||
file_filter = app/src/main/res/values-<lang>/strings.xml
|
file_filter = app/src/main/res/values-<lang>/strings.xml
|
||||||
|
minimum_perc = 22
|
||||||
source_file = app/src/main/res/values/strings.xml
|
source_file = app/src/main/res/values/strings.xml
|
||||||
source_lang = en
|
source_lang = en
|
||||||
type = ANDROID
|
type = ANDROID
|
||||||
minimum_perc = 50
|
|
||||||
|
|
||||||
[I2P.android_lib_helper]
|
[I2P.android_lib_helper]
|
||||||
file_filter = lib/helper/src/main/res/values-<lang>/strings.xml
|
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_file = lib/helper/src/main/res/values/strings.xml
|
||||||
source_lang = en
|
source_lang = en
|
||||||
type = ANDROID
|
type = ANDROID
|
||||||
minimum_perc = 50
|
|
||||||
|
|
||||||
|
130
CHANGELOG
@ -1,4 +1,132 @@
|
|||||||
0.9.25
|
0.9.50 2021-05-18
|
||||||
|
* This release updates the underlying I2P libraries to I2P version 0.9.50
|
||||||
|
|
||||||
|
0.9.48 2020-12-02
|
||||||
|
* This release updates the underlying I2P libraries to I2P version 0.9.48
|
||||||
|
* Updates to browser configuration documentation
|
||||||
|
|
||||||
|
0.9.47-1 2020-10-29
|
||||||
|
* This release fixes a number of bugs arising from a misconfigured bootclasspath
|
||||||
|
* Fix a battery-management issue arising on some phones
|
||||||
|
|
||||||
|
0.9.47 / 2020-08-26
|
||||||
|
* Notification bug-fixes on platforms >8.0
|
||||||
|
|
||||||
|
0.9.46 / 2020-06-03
|
||||||
|
* catch ActivityNotFound exception in MainActivity
|
||||||
|
|
||||||
|
0.9.45 / 2020-03-07
|
||||||
|
* No significant changes
|
||||||
|
|
||||||
|
0.9.44 / 2019-12-03
|
||||||
|
* Updated translations
|
||||||
|
* Bumped target sdk version to 28, enforced by google
|
||||||
|
|
||||||
|
0.9.43-1 / 2019-10-28
|
||||||
|
* Fix crash at startup in TCG
|
||||||
|
|
||||||
|
0.9.43 / 2019-10-27
|
||||||
|
* Save state in background thread (tickets #2595, #2632)
|
||||||
|
* Fix ISE in language dialog (ticket #2631)
|
||||||
|
* Fix NPE in create tunnel (ticket #2629)
|
||||||
|
* Update logo after router killed in background
|
||||||
|
* Fix message in tunnels tabs when tunnels not up yet
|
||||||
|
* Hide tunnel actions while TCG is starting
|
||||||
|
* Add battery permissions dialog (ticket #2607)
|
||||||
|
|
||||||
|
0.9.42 / 2019-08-28
|
||||||
|
* Possible fix for tunnel edit dialog crash (ticket #2598)
|
||||||
|
|
||||||
|
0.9.41 / 2019-07-03
|
||||||
|
* New 64 bit libjbigi (ticket #2503)
|
||||||
|
* Update 32 bit jbigi to GMP 6.1.2
|
||||||
|
* Fix for client tunnels not starting after reseed
|
||||||
|
* UPnP Fixes (ticket #2499)
|
||||||
|
* WebView crash fixes (ticket #2390)
|
||||||
|
* i2ptunnel crash fix (ticket #2552)
|
||||||
|
* i2ptunnel ANR fix (ticket #2491)
|
||||||
|
* Browser help pages improvements (tickets #2521, 2523)
|
||||||
|
* Code cleanups and fixes
|
||||||
|
* Update visibility of floating menu items
|
||||||
|
* Put our router info at top of list
|
||||||
|
* Table layout cleanups
|
||||||
|
* Fixes for threads remaining after router stop
|
||||||
|
* Remove BOB
|
||||||
|
* Remove welterde IRC tunnel
|
||||||
|
* Various lint fixes
|
||||||
|
* New translations: Add cs, da, el
|
||||||
|
* Add missing translations to menu: ar, fi, gl, hu, zh_TW
|
||||||
|
|
||||||
|
0.9.40 / 2019-05-10
|
||||||
|
* Open local I2CP socket for 3rd party apps
|
||||||
|
* Fix News URLs
|
||||||
|
* Numerous bug fixes (see trac)
|
||||||
|
|
||||||
|
0.9.39 / 2019-03-23
|
||||||
|
* Set App ID
|
||||||
|
|
||||||
|
0.9.38 / 2019-01-27
|
||||||
|
|
||||||
|
0.9.37 / 2018-10-10
|
||||||
|
|
||||||
|
0.9.36 / 2018-08-27
|
||||||
|
|
||||||
|
0.9.35 / 2018-07-03
|
||||||
|
|
||||||
|
0.9.34 / 2018-04-25
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
0.9.27 / 2016-11-20 / 64ff68efe98c345acb6ba1d0432fa49d1d650358
|
||||||
|
* Removed kytv's IRC server from default tunnel list
|
||||||
|
* Translation updates
|
||||||
|
|
||||||
|
0.9.26 / 2016-06-13 / b003272c8b504bb0d904edca2e95359a57c9a52c
|
||||||
|
* Fixed "I2CP already listening" bug
|
||||||
|
* Fixed crash when adding tunnel to empty list
|
||||||
|
* Translation updates
|
||||||
|
|
||||||
|
0.9.25 / 2016-04-17 / 46d45a878a2b73394b26ca27dbe6c696dedcf1c3
|
||||||
* Fixed a bug on Samsung Android 4.2 devices
|
* Fixed a bug on Samsung Android 4.2 devices
|
||||||
* Dependency improvements
|
* Dependency improvements
|
||||||
* Translation updates
|
* Translation updates
|
||||||
|
11
DEVELOPMENT-README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Development Readme
|
||||||
|
|
||||||
|
## How to build development builds of the router core for android?
|
||||||
|
|
||||||
|
Check the RELEASE-PROCESS.md file for general information about how to build and to bump the version.
|
||||||
|
|
||||||
|
In your i2p.i2p codebase checkout, execute `./installer/resources/maven-dev-release.sh` with your build number as first argument.
|
||||||
|
The script locates itself and uses the same codebase as it's in, to produce the maven builds which will be locally installed.
|
||||||
|
|
||||||
|
Next, add the build number to the gradle.properties and build the android build as usual.
|
||||||
|
|
91
DOCKER.md
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
Docker Build Instructions
|
||||||
|
=========================
|
||||||
|
|
||||||
|
It is possible to build a container with a pre-installed environment for
|
||||||
|
correctly compiling an I2P for Android development build. Unlike the i2p.i2p
|
||||||
|
container, zero attempt has been made to optimize the size of the container,
|
||||||
|
as it contains a copy of the latest Android SDK, toolchains, and Android NDK,
|
||||||
|
which it must download. To save time, this is cached locally. It is likely to
|
||||||
|
take up to 30 GB of disk space to compile in this way, however, it is very easy
|
||||||
|
and convenient compared to the steps in RELEASE-PROCESS.md and may make
|
||||||
|
building Android reproducibly easier in the future.
|
||||||
|
|
||||||
|
Container dependencies
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
- `menny/android_ndk` (third-party image) (reviewed by idk) (depends on menny/android_sdk
|
||||||
|
- `menny/android_sdk` (third-party image) (reviewed by idk) (depends on ubuntu/18.04)
|
||||||
|
- `ubuntu/18.04` (official docker container) (base container)
|
||||||
|
|
||||||
|
Build the container locally
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
docker build -t i2p.android.base .
|
||||||
|
|
||||||
|
To build the container. It will have a lot to download the first time, so it may take
|
||||||
|
a while to complete.
|
||||||
|
|
||||||
|
Run an Android build in the container
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
Copy the `etc/docker.signing.example.proprties` file to `etc/docker.signing.proprties`,
|
||||||
|
edit it to match your key information and rebuild the container.
|
||||||
|
|
||||||
|
Run:
|
||||||
|
|
||||||
|
docker run -it \
|
||||||
|
-u $(id -u):$(id -g) \
|
||||||
|
--name i2p.android.base \
|
||||||
|
-v $HOME/.gnupg/:/.gnupg/:ro \
|
||||||
|
-v $HOME/.i2p-plugin-keys/:/.i2p-plugin-keys/:ro \
|
||||||
|
-v /run/user/$(id -u)/:/run/user/$(id -u)/:ro \
|
||||||
|
i2p.android.base
|
||||||
|
|
||||||
|
To get the build artifacts for uploading to Maven out of the container, use:
|
||||||
|
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/pkg-mavencentral app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-i2p.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-mstreaming.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-router.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-servlet-i2p.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-streaming.jar app/pkg-mavencentral
|
||||||
|
|
||||||
|
To get the Android build artifacts out of the container, use:
|
||||||
|
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.android.base/app/build/ app/build
|
||||||
|
|
||||||
|
And your android applications will appear in the `app/build` directory, in the same
|
||||||
|
place where non-container builds would go.
|
||||||
|
|
||||||
|
If you encounter a permissions error when rebuilding, delete the `app/build`,
|
||||||
|
`app/pkg-mavencentral` and `app/pkg-temp` path.
|
||||||
|
|
||||||
|
rm -rf app/pkg-temp app/build app/pkg-mavencentral
|
||||||
|
|
||||||
|
Copypasta
|
||||||
|
---------
|
||||||
|
|
||||||
|
Once you have set up builds for the first time, from then on you can update the container and
|
||||||
|
build a fresh set of Maven jars and a new I2P for Android app by copy-pasting the following
|
||||||
|
commands:
|
||||||
|
|
||||||
|
``` sh
|
||||||
|
rm -rf app/pkg-temp app/build app/pkg-mavencentral
|
||||||
|
docker build -t i2p.android.base .
|
||||||
|
docker run -it \
|
||||||
|
-u $(id -u):$(id -g) \
|
||||||
|
--name i2p.android.base \
|
||||||
|
-v $HOME/.gnupg/:/.gnupg/:ro \
|
||||||
|
-v $HOME/.i2p-plugin-keys/:/.i2p-plugin-keys/:ro \
|
||||||
|
-v /run/user/$(id -u)/:/run/user/$(id -u)/:ro \
|
||||||
|
i2p.android.base
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/pkg-mavencentral app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-i2p.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-mstreaming.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-router.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-servlet-i2p.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.i2p/mavencentral-streaming.jar app/pkg-mavencentral
|
||||||
|
docker cp i2p.android.base:/opt/workspace/i2p.android.base/app/build/ app/build
|
||||||
|
```
|
39
Dockerfile
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
FROM menny/android_ndk
|
||||||
|
ENV VERSION=0.9.50
|
||||||
|
ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
|
||||||
|
RUN echo 'deb http://deb.i2p2.de/ sid main' >> /etc/apt/sources.list
|
||||||
|
RUN echo 'deb-src http://deb.i2p2.de/ sid main' >> /etc/apt/sources.list
|
||||||
|
RUN echo 'deb http://archive.ubuntu.com/ubuntu trusty universe' >> /etc/apt/sources.list
|
||||||
|
RUN wget -O /etc/apt/trusted.gpg.d/i2p-debian-repo.key.asc https://geti2p.net/_static/i2p-debian-repo.key.asc
|
||||||
|
COPY etc/debian-jessie-repo.key.asc /etc/apt/trusted.gpg.d
|
||||||
|
RUN mkdir -p /opt/packages && wget -O /opt/packages/openjdk-7-jre-headless.deb http://security.debian.org/debian-security/pool/updates/main/o/openjdk-7/openjdk-7-jre-headless_7u261-2.6.22-1~deb8u1_amd64.deb
|
||||||
|
RUN apt-get update
|
||||||
|
RUN apt-get build-dep -y i2p i2p-router
|
||||||
|
RUN apt-get install -y ant openjdk-8* libxml2-utils junit4 libhamcrest-java libmockito-java libmaven-ant-tasks-java dpkg-sig maven
|
||||||
|
RUN cd /opt/packages && dpkg-sig -l openjdk-7-jre-headless.deb && dpkg -x openjdk-7-jre-headless.deb /opt/packages/openjdk-7-jre
|
||||||
|
RUN git clone https://github.com/i2p/i2p.i2p --depth=1 -b i2p-$VERSION /opt/workspace/i2p.i2p
|
||||||
|
RUN update-java-alternatives --jre-headless --set java-1.8.0-openjdk-amd64
|
||||||
|
RUN update-java-alternatives --set java-1.8.0-openjdk-amd64
|
||||||
|
RUN update-alternatives --set javac /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
|
||||||
|
RUN update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
|
||||||
|
RUN rm /opt/java/openjdk/ -rfv
|
||||||
|
COPY . /opt/workspace/i2p.android.base
|
||||||
|
COPY etc/docker.local.ndk.properties /opt/workspace/i2p.android.base/client/local.properties
|
||||||
|
COPY etc/docker.local.router.properties /opt/workspace/i2p.android.base/routerjars/local.properties
|
||||||
|
COPY etc/docker.local.sdk.properties /opt/workspace/i2p.android.base/local.properties
|
||||||
|
COPY etc/docker.override.properties /opt/workspace/i2p.android.base/override.properties
|
||||||
|
COPY etc/docker.override.properties /opt/workspace/i2p.i2p/override.properties
|
||||||
|
COPY etc/docker.signing.properties /opt/workspace/i2p.android.base/signing.properties
|
||||||
|
WORKDIR /opt/workspace/i2p.android.base
|
||||||
|
RUN find /opt/android-sdk-linux -type d -print0 | xargs -0 chown -R 1000:1000
|
||||||
|
RUN find /opt/android-sdk-linux -type d -print0 | xargs -0 chmod -Rc o+rw
|
||||||
|
RUN find /opt/android-sdk-linux -type d -print0 | xargs -0 chmod -c 0755
|
||||||
|
RUN find /opt/workspace -type d -print0 | xargs -0 chown -R 1000:1000
|
||||||
|
RUN find /opt/workspace -type d -print0 | xargs -0 chmod -Rc o+rw
|
||||||
|
RUN find /opt/workspace -type d -print0 | xargs -0 chmod -c 0755
|
||||||
|
CMD cd /opt/workspace/i2p.i2p && \
|
||||||
|
ant -k mavenCentral; \
|
||||||
|
cp -v *.jar pkg-mavencentral/; \
|
||||||
|
cd /opt/workspace/i2p.android.base && \
|
||||||
|
./gradlew --continue dependencies || true ; \
|
||||||
|
./gradlew --continue assembleRelease; tail -f README.md
|
15
README.md
@ -7,8 +7,8 @@
|
|||||||
- Java SDK (preferably Oracle/Sun or OpenJDK) 1.6.0 or higher
|
- Java SDK (preferably Oracle/Sun or OpenJDK) 1.6.0 or higher
|
||||||
- Apache Ant 1.8.0 or higher
|
- Apache Ant 1.8.0 or higher
|
||||||
- I2P source
|
- I2P source
|
||||||
- Android SDK for API 21
|
- Android SDK for API 28 or higher
|
||||||
- Android Build Tools 21.1.2
|
- Android Build Tools 28.0.0 or higher
|
||||||
- Android Support Repository
|
- Android Support Repository
|
||||||
- Gradle 2.2.1
|
- Gradle 2.2.1
|
||||||
|
|
||||||
@ -51,7 +51,6 @@ systemProp.socksProxyPort=9150
|
|||||||
3. Create a `local.properties` file in `i2p.android.base/lib/client` containing:
|
3. Create a `local.properties` file in `i2p.android.base/lib/client` containing:
|
||||||
|
|
||||||
```
|
```
|
||||||
i2psrc=/path/to/i2p.i2p
|
|
||||||
ndk.dir=/path/to/ndk
|
ndk.dir=/path/to/ndk
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -68,10 +67,18 @@ systemProp.socksProxyPort=9150
|
|||||||
```
|
```
|
||||||
sdk.dir=/path/to/android-studio/sdk
|
sdk.dir=/path/to/android-studio/sdk
|
||||||
```
|
```
|
||||||
|
1a. For building with a local router development build:
|
||||||
|
cd ../i2p.i2p
|
||||||
|
installer/resources/maven-dev-release.sh x // x is the build number, e.g. 6
|
||||||
|
cd back here
|
||||||
|
edit gradle.properties, add the build number x to I2P_PROPERTIES=0.9.xx-x
|
||||||
|
|
||||||
2. `gradle assembleDebug`
|
2. `gradle assembleDebug`
|
||||||
|
|
||||||
3. The APK will be placed in `i2p.android.base/app/build/outputs/apk`.
|
3. The APK files will be placed in `i2p.android.base/app/build/outputs/apk` subdirectories.
|
||||||
|
|
||||||
|
4. Install debug build on phone in USB debugging mode
|
||||||
|
adb install app/build/outputs/apk/free/debug/app-free-debug.apk
|
||||||
|
|
||||||
### Building with Android Studio
|
### Building with Android Studio
|
||||||
|
|
||||||
|
120
RELEASE-PROCESS.md
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
# Release Process
|
||||||
|
|
||||||
|
Note to all future maintainers: We have 4 channels that need to be updated in order to have a successful
|
||||||
|
Android release. Many of these channels are updated at different rates, and at times you must wait on a
|
||||||
|
third-party service to complete it's tasks before you may continue. When completing an Android release,
|
||||||
|
keep in mind that you must update 1) Maven 2) Google Play 3) f-droid.i2p.io and 4) F-Droid main
|
||||||
|
repository.
|
||||||
|
|
||||||
|
At the time of this revision, 2020/09/13, the main Android maintainer is idk. idk updates Maven, Google
|
||||||
|
Play, and f-droid.i2p.io, and nextl00p handles working with the F-Droid project to provide an I2P release
|
||||||
|
in their main repository.
|
||||||
|
|
||||||
|
NOTE: The docker container built by the Dockerfile in this repostory ensures that the Pre-requisites and
|
||||||
|
Dependencies are properly met by obtaining them from the Debian package in `oldoldstable` and pre-configuring
|
||||||
|
the override.properties that is used in the Docker container.
|
||||||
|
|
||||||
|
**>> Beginning of Docker-enabled Steps <<**
|
||||||
|
|
||||||
|
## Prerequirements
|
||||||
|
|
||||||
|
1. Ensure you have the deprecated maven ant tasks. ( https://maven.apache.org/ant-tasks/download.cgi )
|
||||||
|
2. It should exist at `~/.ant/lib/maven-ant-tasks-2.1.3.jar`
|
||||||
|
3. Ensure you have hamcrest-integration, hamcrest-library, hamcrest-core in the hamcrest.home directory.
|
||||||
|
4. Ensure junit 4.12 at least in junit.home, ensure the jar file is named `junit4.jar`.
|
||||||
|
5. Ensure you have the Mockito framework and accompanying documentation in your $JAVA_HOME
|
||||||
|
6. Ensure to have updated the changelog with the changes done.
|
||||||
|
7. Ensure that you are configured to build i2p.i2p with Java 8. On Debian it is easiest to set with
|
||||||
|
`update-java-alternatives --set java-8-openjdk-amd64` and picking Java 8. **TODO:** add instructions for non-Debian-based
|
||||||
|
systems.
|
||||||
|
8. Ensure that you have a Java 1.7 bootclasspath available. (See **Maven Central** step 2A.)
|
||||||
|
|
||||||
|
## Get all the dependencies ready
|
||||||
|
|
||||||
|
### Maven Central
|
||||||
|
|
||||||
|
1. Check out a clean copy of i2p.i2p at the correct release version. (Make a clean checkout)
|
||||||
|
2. Build the maven packages via `ant mavenCentral` where you end up with mavencentral-*.jar files in the
|
||||||
|
current directory.
|
||||||
|
2. **A)** I2P for Android requires a Java 1.7 bootclasspath, but the servlet jar requires Java 8. So, to do the builds:
|
||||||
|
- First set `javac.compilerargs=-bootclasspath /path/to/java/7/rt.jar:/path/to/java/7/jce.jar` in override.properties
|
||||||
|
- Build with `ant mavenCentral`
|
||||||
|
|
||||||
|
**>> End of Docker-enabled Steps for Maven <<**
|
||||||
|
|
||||||
|
3. Login to http://oss.sonatype.org for uploading the mavencentral-*.jar bundles.
|
||||||
|
4. In nexus, choose "Staging Upload" and upload all of the files with upload mode set to "Artifacts with POM".
|
||||||
|
When uploading the files to nexus, you *must* upload the pom.xml files, and all of their artifacts. For each
|
||||||
|
component, you will need to upload a *.jar, a *.jar.asc, a *sources.jar, a *sources.jar.asc, a javadoc.jar,
|
||||||
|
and a javadoc.jar.asc, and a pom.xml and a pom.xml.asc from the pkg-mavencentral directory during the "Upload
|
||||||
|
Artifacts with POM" operation. You will need to do this once for each component you upload to Nexus.
|
||||||
|
5. Under "Staging Repositories" ensure all where uploaded correctly, select them all and press "Release"
|
||||||
|
in the toolbar.
|
||||||
|
|
||||||
|
#### Example override.properties:
|
||||||
|
|
||||||
|
javac.version=1.7
|
||||||
|
javac.target=1.7
|
||||||
|
javac.source=1.8
|
||||||
|
javac.compilerargs=-bootclasspath /home/user/StudioProjects/java7bootclasspath/rt.jar:/home/user/StudioProjects/java7bootclasspath/jce.jar
|
||||||
|
javac.compilerargs7=-bootclasspath /home/user/StudioProjects/java7bootclasspath/rt.jar:/home/user/StudioProjects/java7bootclasspath/jce.jar
|
||||||
|
build.built-by=name
|
||||||
|
|
||||||
|
### Android Common Build
|
||||||
|
|
||||||
|
Using Docker: in order to use Docker to generate a new Android apk for release, you will
|
||||||
|
need to run the build twice, once for the mavenCentral jars, and once for the actual Android
|
||||||
|
app. After doing the Maven release, follow these steps in the i2p.android.base repository, and re-run
|
||||||
|
the `docker run` step described in `DOCKER.md`
|
||||||
|
|
||||||
|
1. Edit `routerjars/local.properties` to use the clean i2p.i2p copy.
|
||||||
|
2. Pull the latest translations with `tx pull -a` and commit them. (If you don't have the `tx` command,
|
||||||
|
do `pip install transifex-client` )
|
||||||
|
- If there are any new translations, `mtn add` them, and add them to `app/src/main/res/values/arrays.xml`
|
||||||
|
(two places, alphabetical order please)
|
||||||
|
3. Ensure that `signing.properties` contains the details of the release key. If you are using Docker, see
|
||||||
|
`DOCKER.md` to perform this step for Docker builds by editing `etc/docker.signing.properties` instead.
|
||||||
|
4. Edit `gradle.properties` to bump the I2P version.
|
||||||
|
5. Edit `app/build.gradle` to bump the Android version number.
|
||||||
|
6. Edit `CHANGELOG` to add the release and date.
|
||||||
|
7. If the helper has changed since the last release, edit
|
||||||
|
`lib/helper/gradle.properties` to bump the version.
|
||||||
|
8. `./gradlew clean assembleRelease`
|
||||||
|
|
||||||
|
### Libraries
|
||||||
|
|
||||||
|
1. `./gradlew :lib:client:uploadArchives`
|
||||||
|
2. If the helper version was changed and should be released: `./gradlew :lib:helper:uploadArchives`
|
||||||
|
3. Check on Sonatype that everything worked, and close/release.
|
||||||
|
|
||||||
|
## Release Packages
|
||||||
|
|
||||||
|
### F-Droid Guide
|
||||||
|
|
||||||
|
This guide is for f-droid.i2p.io, not for F-Droid's main repository. The repository keystore **and** the
|
||||||
|
config.py used to generate the repository are required to complete this process successfully.
|
||||||
|
|
||||||
|
1. Ensure you have the release keys, the keyfile must be placed at `~/.local/share/fdroidserver/keystore.jks`
|
||||||
|
2. If it's the first time, or you have reinstalled anything, ensure `path/to/fdroid/config.py` has correct
|
||||||
|
information.
|
||||||
|
3. Assuming you already have ran `./gradlew clean assembleRelease` from a earlier step, continue.
|
||||||
|
4. `cp app/build/outputs/apk/free/release/app-free-release.apk path/to/fdroid/repo/I2P-VERSION.apk`
|
||||||
|
5. Update `path/to/fdroid/metadata/net.i2p.android.txt` (The versions at the bottom of the file)
|
||||||
|
6. Run `fdroid update` from inside the fdroid path (install fdroid command via `pip install fdroidserver`)
|
||||||
|
7. Zip/tar the local fdroid repo and archive. `rm fdroid.tgz && tar czf fdroid.tgz archive/ repo/` from the
|
||||||
|
fdroid directory.
|
||||||
|
8. Push to download server and put in place. (via SSH for example, `scp fdroid.tgz download.i2p2.de:~/`)
|
||||||
|
9. On the server run `bin-fd/update-fdroid` and `sudo bin-fd/update-app i2p 0.9.40` (This ensures we use the
|
||||||
|
exact same apk file for the download page as in fdroid and gplay)
|
||||||
|
10. Check F-Droid repo works, and app works.
|
||||||
|
|
||||||
|
### Google Play and finishing up
|
||||||
|
|
||||||
|
1. Verify which files that are changed via `mtn ls cha`. It shouldn't be much more than those bellow this
|
||||||
|
line and possible translations (`mtn ls unk`).
|
||||||
|
2. Commit your release changes, `mtn ci gradle.properties lib/helper/gradle.properties app/build.gradle`
|
||||||
|
3. Push free and donate builds to Google Play via https://play.google.com/apps/publish/
|
||||||
|
4. Tag the new release. Example `mtn tag h: android-0.9.36`
|
||||||
|
5. Push the monotone changes. Make sure that they are there at the next git sync.
|
||||||
|
6. Update download page (version and hash, including F-Droid)
|
||||||
|
|
25
TODO
@ -19,38 +19,61 @@
|
|||||||
- Style for addressbook headers
|
- Style for addressbook headers
|
||||||
- Change console FAM icon when possible
|
- Change console FAM icon when possible
|
||||||
<zzz> on the bottom right, the + and x icons might be better as a double-up arrow and double-down arrow?
|
<zzz> on the bottom right, the + and x icons might be better as a double-up arrow and double-down arrow?
|
||||||
|
- Use Material design for LongPressButton
|
||||||
|
- Highlight selected tunnel in two-pane mode
|
||||||
|
|
||||||
# Short-term
|
# Short-term
|
||||||
|
|
||||||
|
- Remove peers page (HTML version)
|
||||||
|
- Add firewall help page showing current port settings
|
||||||
|
- GMP 6
|
||||||
|
- Fetch all JARs from Maven Central (ie. upload everything that I2P Android uses)
|
||||||
- Disable uPnP when on cell networks
|
- Disable uPnP when on cell networks
|
||||||
<zzz> spewing UPnP out into cell networks is a waste of time at best and a security risk at worst, but you really want it for wifi
|
<zzz> spewing UPnP out into cell networks is a waste of time at best and a security risk at worst, but you really want it for wifi
|
||||||
|
- Rewrite settings config handling
|
||||||
|
- Rewrite InitActivities
|
||||||
- I2PTunnel
|
- I2PTunnel
|
||||||
- Improve tunnel list status indicators
|
- Improve tunnel list status indicators
|
||||||
|
- Icon overlay to indicate which tunnels are shared
|
||||||
|
- Or reorder / group tunnels?
|
||||||
- Show all messages somewhere
|
- Show all messages somewhere
|
||||||
|
- Bottom toolbar?
|
||||||
- Icons/header images for tunnel types on details page
|
- Icons/header images for tunnel types on details page
|
||||||
|
- Setting to close when not on WiFi
|
||||||
- Progress feedback for addressbook subscriptions reload
|
- Progress feedback for addressbook subscriptions reload
|
||||||
- Display release notes directly on new router version
|
- Display release notes directly on new router version
|
||||||
- Fill out help pages
|
- Fill out help pages
|
||||||
|
- Fix navigation to specific settings pages
|
||||||
- Rewrite release notes to be release-specific
|
- Rewrite release notes to be release-specific
|
||||||
- Fix release notes UI, either make back button use clear or add buttons
|
- Fix release notes UI, either make back button use clear or add buttons
|
||||||
|
- Notify user when autostart fails?
|
||||||
- NetDB tablet view fixes
|
- NetDB tablet view fixes
|
||||||
- Refresh detail fragment when changing tab
|
- Refresh detail fragment when changing tab
|
||||||
- Move list to correct item when changing tab
|
- Move list to correct item when changing tab
|
||||||
- Create nav history when viewing RI from LS
|
- Create nav history when viewing RI from LS
|
||||||
|
- Handle NetDB null cases (failed lookup of requested hash in detail page)
|
||||||
- Include GeoIP db for country info
|
- Include GeoIP db for country info
|
||||||
- Maybe change router-off mechanic for various pages? Enable as they become available?
|
- Maybe change router-off mechanic for various pages? Enable as they become available?
|
||||||
|
|
||||||
# Medium-term
|
# Medium-term
|
||||||
|
|
||||||
|
- SQLite naming service backend to store addresses more effectively
|
||||||
|
- Leverage for name completion in e.g. browsers
|
||||||
|
- Create/edit tunnels while router is not running
|
||||||
|
- Separate out shared tunnel config
|
||||||
|
- Convey to users that one config controls all shared tunnels
|
||||||
- Network profiles
|
- Network profiles
|
||||||
- User selects profile in settings
|
- User selects profile in settings
|
||||||
- Change network participation etc. based on profile
|
- Change network participation etc. based on profile
|
||||||
- Also look at connection type: Connectivity.isConnectionFast()
|
- Also look at connection type: Connectivity.isConnectionFast()
|
||||||
- Expose log level overrides
|
- Expose log level overrides
|
||||||
|
- Bug report feature
|
||||||
|
- Replace peers page (native version)
|
||||||
- Improve graphs
|
- Improve graphs
|
||||||
- Show fixed x range, not only available data
|
- Show fixed x range, not only available data
|
||||||
- Think about pan/zoom
|
- Think about pan/zoom
|
||||||
- How to persist data across restarts?
|
- How to persist data across restarts?
|
||||||
|
- Enable apps to specify when they don't need the router anymore
|
||||||
|
|
||||||
# Silent Store approval checks to confirm/implement
|
# Silent Store approval checks to confirm/implement
|
||||||
|
|
||||||
@ -98,6 +121,8 @@
|
|||||||
|
|
||||||
# Long-term
|
# Long-term
|
||||||
|
|
||||||
|
- Reproducible builds
|
||||||
|
- Extract RouterService into a library
|
||||||
- Remote router support
|
- Remote router support
|
||||||
- Implement a "router wrapper" that can represent a local or remote router
|
- Implement a "router wrapper" that can represent a local or remote router
|
||||||
- Implement/use client APIs to talk to remote router
|
- Implement/use client APIs to talk to remote router
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'witness'
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION as String)
|
compileSdkVersion 28
|
||||||
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION as String
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
versionCode 4745232
|
versionCode 4745264
|
||||||
versionName '0.9.25'
|
versionName "$I2P_VERSION"
|
||||||
minSdkVersion 9
|
minSdkVersion 14
|
||||||
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION as String)
|
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION as String)
|
||||||
|
|
||||||
// For Espresso
|
// For Espresso
|
||||||
@ -23,6 +25,7 @@ android {
|
|||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
|
debuggable true
|
||||||
applicationIdSuffix '.debug'
|
applicationIdSuffix '.debug'
|
||||||
versionNameSuffix '-DEBUG'
|
versionNameSuffix '-DEBUG'
|
||||||
}
|
}
|
||||||
@ -33,68 +36,59 @@ android {
|
|||||||
}
|
}
|
||||||
lintOptions {
|
lintOptions {
|
||||||
abortOnError false
|
abortOnError false
|
||||||
|
disable 'MissingDefaultResource'
|
||||||
}
|
}
|
||||||
packagingOptions {
|
packagingOptions {
|
||||||
exclude 'LICENSE.txt'
|
exclude 'LICENSE.txt'
|
||||||
}
|
}
|
||||||
|
flavorDimensions 'tier'
|
||||||
productFlavors {
|
productFlavors {
|
||||||
free {
|
free {
|
||||||
|
dimension 'tier'
|
||||||
applicationId 'net.i2p.android'
|
applicationId 'net.i2p.android'
|
||||||
}
|
}
|
||||||
donate {
|
donate {
|
||||||
|
dimension 'tier'
|
||||||
applicationId 'net.i2p.android.donate'
|
applicationId 'net.i2p.android.donate'
|
||||||
}
|
}
|
||||||
legacy {
|
legacy {
|
||||||
|
dimension 'tier'
|
||||||
applicationId 'net.i2p.android.router'
|
applicationId 'net.i2p.android.router'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
buildToolsVersion '28.0.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Local dependencies
|
// Local dependencies
|
||||||
compile project(':lib:client')
|
implementation project(':lib:client')
|
||||||
compile project(':routerjars')
|
implementation project(':lib:helper')
|
||||||
|
implementation project(path: ':routerjars', configuration: 'routerjars')
|
||||||
// Android Support Repository dependencies
|
// Android Support Repository dependencies
|
||||||
def supportVersion = '23.2.1'
|
def supportVersion = '28.0.0'
|
||||||
compile "com.android.support:support-v4:$supportVersion"
|
implementation "com.android.support:support-v4:$supportVersion"
|
||||||
compile "com.android.support:appcompat-v7:$supportVersion"
|
implementation "com.android.support:appcompat-v7:$supportVersion"
|
||||||
compile "com.android.support:preference-v7:$supportVersion"
|
implementation "com.android.support:preference-v7:$supportVersion"
|
||||||
compile "com.android.support:preference-v14:$supportVersion"
|
implementation "com.android.support:preference-v14:$supportVersion"
|
||||||
compile "com.android.support:recyclerview-v7:$supportVersion"
|
implementation "com.android.support:recyclerview-v7:$supportVersion"
|
||||||
|
|
||||||
// Remote dependencies
|
// Remote dependencies
|
||||||
compile 'com.androidplot:androidplot-core:0.9.6'
|
implementation 'com.androidplot:androidplot-core:1.4.1'
|
||||||
compile 'com.eowise:recyclerview-stickyheaders:0.5.2@aar'
|
implementation 'com.eowise:recyclerview-stickyheaders:0.5.2@aar'
|
||||||
compile ('com.mcxiaoke.viewpagerindicator:library:2.4.1') {
|
implementation 'com.inkapplications.viewpageindicator:library:2.4.4'
|
||||||
exclude group: 'com.android.support', module: 'support-v4'
|
implementation 'com.pnikosis:materialish-progress:1.7'
|
||||||
}
|
implementation "net.i2p:router:$I2P_VERSION"
|
||||||
compile 'com.pnikosis:materialish-progress:1.7'
|
implementation "net.i2p:i2p:$I2P_VERSION"
|
||||||
compile 'net.i2p.android.ext:floatingactionbutton:1.10.1'
|
implementation "net.i2p.client:mstreaming:$I2P_VERSION"
|
||||||
compile 'org.sufficientlysecure:html-textview:1.3'
|
implementation "net.i2p.client:streaming:$I2P_VERSION"
|
||||||
|
implementation 'net.i2p.android.ext:floatingactionbutton:1.10.1'
|
||||||
|
implementation 'org.sufficientlysecure:html-textview:3.1'
|
||||||
// Testing-only dependencies
|
// Testing-only dependencies
|
||||||
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
|
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2') {
|
||||||
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
|
exclude group: 'com.android.support', module: 'support-annotations'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyVerification {
|
project.ext.i2pbase = "../i2p.i2p"
|
||||||
verify = [
|
|
||||||
'com.android.support:support-v4:81ce890f26d35c75ad17d0f998a7e3230330c3b41e0b629566bc744bee89e448',
|
|
||||||
'com.android.support:appcompat-v7:00f9d93acacd6731f309724054bf51492814b4b2869f16d7d5c0038dcb8c9a0d',
|
|
||||||
'com.android.support:preference-v7:775101bd07bd052e455761c5c5d9523d7ad59f2f320e3e8cbde241fd6b1d6025',
|
|
||||||
'com.android.support:preference-v14:44881bb46094e86d0bc2426f205419674a5b4eb514b44b5a4659b5de29f71eb7',
|
|
||||||
'com.android.support:recyclerview-v7:44040a888e23e0c93162a3377cfe06751080e3c22d369ab0d4301ef60d63b0fe',
|
|
||||||
'com.androidplot:androidplot-core:1aaa931974da9d351976ed3d4b67170ac2a78be6c6afd13559ded5534eefc264',
|
|
||||||
'com.eowise:recyclerview-stickyheaders:7b236da49b33b840e9ba6e7e4182218d1a2d9047236fdbc3ca947352f9b0883b',
|
|
||||||
'com.mcxiaoke.viewpagerindicator:library:1e8aad664137f68abdfee94889f6da3dc98be652a235176a403965a07a25de62',
|
|
||||||
'com.pnikosis:materialish-progress:da089a90d1dab61e9b50038c09081019398f81190d12b0b567ce94b83ef8cf93',
|
|
||||||
'net.i2p.android.ext:floatingactionbutton:09d43e2d4ac04a91bf7a37e1ec48a8d220204e3a55dca72cd36cd9fa27461ade',
|
|
||||||
'org.sufficientlysecure:html-textview:39048e35894e582adada388e6c00631803283f8defed8e07ad58a5f284f272ee',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
project.ext.i2pbase = '../i2p.i2p'
|
|
||||||
def Properties props = new Properties()
|
def Properties props = new Properties()
|
||||||
def propFile = new File(project(':routerjars').projectDir, 'local.properties')
|
def propFile = new File(project(':routerjars').projectDir, 'local.properties')
|
||||||
|
|
||||||
@ -120,7 +114,7 @@ task copyI2PResources(type: Copy) {
|
|||||||
outputs.upToDateWhen { false }
|
outputs.upToDateWhen { false }
|
||||||
into 'src/main/res'
|
into 'src/main/res'
|
||||||
into('drawable') {
|
into('drawable') {
|
||||||
from file(i2pbase + '/installer/resources/themes/console/images/i2plogo.png')
|
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/images/i2plogo.png')
|
||||||
}
|
}
|
||||||
into('raw') {
|
into('raw') {
|
||||||
from(i2pbase + '/installer/resources/blocklist.txt') { rename { 'blocklist_txt' } }
|
from(i2pbase + '/installer/resources/blocklist.txt') { rename { 'blocklist_txt' } }
|
||||||
@ -183,15 +177,15 @@ task copyI2PAssets(type: Copy) {
|
|||||||
outputs.upToDateWhen { false }
|
outputs.upToDateWhen { false }
|
||||||
into 'src/main/assets/themes/console'
|
into 'src/main/assets/themes/console'
|
||||||
into('images') {
|
into('images') {
|
||||||
from file(i2pbase + '/installer/resources/themes/console/images/i2plogo.png')
|
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/images/i2plogo.png')
|
||||||
from file(i2pbase + '/installer/resources/themes/console/images/inbound.png')
|
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/images/inbound.png')
|
||||||
from file(i2pbase + '/installer/resources/themes/console/images/outbound.png')
|
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/images/outbound.png')
|
||||||
}
|
}
|
||||||
into('light') {
|
into('light') {
|
||||||
from file(i2pbase + '/installer/resources/themes/console/light/console.css')
|
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/light/console.css')
|
||||||
}
|
}
|
||||||
into('light/images') {
|
into('light/images') {
|
||||||
from file(i2pbase + '/installer/resources/themes/console/light/images/header.png')
|
from file(i2pbase + '/apps/routerconsole/jsp/themes/console/light/images/header.png')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
app/proguard-rules.pro
vendored
@ -6,6 +6,10 @@
|
|||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
# Add any project specific keep options here:
|
||||||
|
-dontobfuscate
|
||||||
|
-dontoptimize
|
||||||
|
-dontpreverify
|
||||||
|
-dontshrink
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
# If your project uses WebView with JS, uncomment the following
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
@ -21,8 +25,5 @@
|
|||||||
# https://code.google.com/p/android/issues/detail?id=78377#c302
|
# https://code.google.com/p/android/issues/detail?id=78377#c302
|
||||||
-keepattributes **
|
-keepattributes **
|
||||||
-keep class !android.support.v7.view.menu.**,** {*;}
|
-keep class !android.support.v7.view.menu.**,** {*;}
|
||||||
-dontpreverify
|
|
||||||
-dontoptimize
|
|
||||||
-dontshrink
|
|
||||||
-dontwarn **
|
-dontwarn **
|
||||||
-dontnote **
|
-dontnote **
|
@ -16,6 +16,7 @@ import static android.support.test.espresso.matcher.ViewMatchers.hasSibling;
|
|||||||
import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA;
|
import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||||
|
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
|
||||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||||
import static org.hamcrest.Matchers.allOf;
|
import static org.hamcrest.Matchers.allOf;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
@ -57,13 +58,13 @@ public class I2PActivityTest extends ActivityInstrumentationTestCase2<I2PActivit
|
|||||||
public void testMainSwipe() {
|
public void testMainSwipe() {
|
||||||
onView(withId(R.id.router_onoff_button)).check(matches(isDisplayed()));
|
onView(withId(R.id.router_onoff_button)).check(matches(isDisplayed()));
|
||||||
|
|
||||||
onView(allOf(withId(R.id.pager), hasSibling(withId(R.id.main_toolbar)))).perform(swipeLeft());
|
onView(allOf(withId(R.id.pager), withParent(hasSibling(withId(R.id.main_toolbar))))).perform(swipeLeft());
|
||||||
onView(withId(R.id.router_onoff_button)).check(matches(not(isDisplayed())));
|
onView(withId(R.id.router_onoff_button)).check(matches(not(isDisplayed())));
|
||||||
onView(withText(R.string.label_i2ptunnel_client)).check(matches(isDisplayed()));
|
onView(withText(R.string.label_i2ptunnel_client)).check(matches(isDisplayed()));
|
||||||
|
|
||||||
onView(allOf(withId(R.id.pager), hasSibling(withId(R.id.main_toolbar)))).perform(swipeLeft());
|
onView(allOf(withId(R.id.pager), withParent(hasSibling(withId(R.id.main_toolbar))))).perform(swipeLeft());
|
||||||
// TODO: test tunnels ViewPager
|
// TODO: test tunnels ViewPager
|
||||||
onView(allOf(withId(R.id.pager), hasSibling(withId(R.id.main_toolbar)))).perform(swipeLeft());
|
onView(allOf(withId(R.id.pager), withParent(hasSibling(withId(R.id.main_toolbar))))).perform(swipeLeft());
|
||||||
onView(withText(R.string.label_i2ptunnel_client)).check(matches(not(isDisplayed())));
|
onView(withText(R.string.label_i2ptunnel_client)).check(matches(not(isDisplayed())));
|
||||||
onView(withText(R.string.label_router)).check(matches(isDisplayed()));
|
onView(withText(R.string.label_router)).check(matches(isDisplayed()));
|
||||||
// TODO: test addressbook ViewPager
|
// TODO: test addressbook ViewPager
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="net.i2p.android.router"
|
package="net.i2p.android.router"
|
||||||
android:installLocation="auto">
|
android:installLocation="auto"
|
||||||
|
android:sharedUserId="net.i2p">
|
||||||
|
|
||||||
<uses-sdk xmlns:tools="http://schemas.android.com/tools"
|
<uses-sdk xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:overrideLibrary="android.support.v14.preference" />
|
tools:overrideLibrary="android.support.v14.preference" />
|
||||||
@ -9,6 +10,15 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<!-- following two are for UPnP -->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
|
||||||
|
<!-- required for reliable core functionality on Android, see:
|
||||||
|
https://geti2p.net/en/docs/applications/embedding
|
||||||
|
heading: "Design for and Encourage Long Uptimes"
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:icon="@drawable/ic_launcher_itoopie"
|
android:icon="@drawable/ic_launcher_itoopie"
|
||||||
|
@ -31,6 +31,13 @@ public class CustomViewPager extends ViewPager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||||
|
// See Nov. 20, 2013 comment at:
|
||||||
|
// https://github.com/JakeWharton/ViewPagerIndicator/pull/257
|
||||||
|
// Our ticket #2488
|
||||||
|
|
||||||
|
// prevent NPE if fake dragging and touching ViewPager
|
||||||
|
if(isFakeDragging()) return false;
|
||||||
|
|
||||||
return mEnabled && mFixedPage < 0 && super.onInterceptTouchEvent(event);
|
return mEnabled && mFixedPage < 0 && super.onInterceptTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,8 @@ public class MaterialSeekBarController implements SeekBar.OnSeekBarChangeListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setPaddedValue(int value) {
|
private void setPaddedValue(int value) {
|
||||||
mSeekBarValue.setText(String.format("%0" + mMaxDigits +"d", value));
|
//mSeekBarValue.setText(String.format("%0" + mMaxDigits +"d", value));
|
||||||
|
mSeekBarValue.setText(String.format("%" + mMaxDigits +"d", value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class InitActivities {
|
|||||||
|
|
||||||
File docsDir = new File(myDir, "docs");
|
File docsDir = new File(myDir, "docs");
|
||||||
docsDir.mkdir();
|
docsDir.mkdir();
|
||||||
copyResourceToFile(R.raw.ahelper_conflict_header_ht, "docs/ahelper-conflict-header.ht");
|
/*copyResourceToFile(R.raw.ahelper_conflict_header_ht, "docs/ahelper-conflict-header.ht");
|
||||||
copyResourceToFile(R.raw.ahelper_new_header_ht, "docs/ahelper-new-header.ht");
|
copyResourceToFile(R.raw.ahelper_new_header_ht, "docs/ahelper-new-header.ht");
|
||||||
copyResourceToFile(R.raw.ahelper_notfound_header_ht, "docs/ahelper-notfound-header.ht");
|
copyResourceToFile(R.raw.ahelper_notfound_header_ht, "docs/ahelper-notfound-header.ht");
|
||||||
copyResourceToFile(R.raw.auth_header_ht, "docs/auth-header.ht");
|
copyResourceToFile(R.raw.auth_header_ht, "docs/auth-header.ht");
|
||||||
@ -110,7 +110,7 @@ class InitActivities {
|
|||||||
copyResourceToFile(R.raw.noproxy_header_ht, "docs/noproxy-header.ht");
|
copyResourceToFile(R.raw.noproxy_header_ht, "docs/noproxy-header.ht");
|
||||||
copyResourceToFile(R.raw.protocol_header_ht, "docs/protocol-header.ht");
|
copyResourceToFile(R.raw.protocol_header_ht, "docs/protocol-header.ht");
|
||||||
copyResourceToFile(R.raw.reset_header_ht, "docs/reset-header.ht");
|
copyResourceToFile(R.raw.reset_header_ht, "docs/reset-header.ht");
|
||||||
copyResourceToFile(R.raw.resetp_header_ht, "docs/resetp-header.ht");
|
copyResourceToFile(R.raw.resetp_header_ht, "docs/resetp-header.ht");*/
|
||||||
|
|
||||||
File cssDir = new File(docsDir, "themes/console/light");
|
File cssDir = new File(docsDir, "themes/console/light");
|
||||||
cssDir.mkdirs();
|
cssDir.mkdirs();
|
||||||
|
@ -5,6 +5,8 @@ import java.io.FileInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.util.EepGet;
|
import net.i2p.util.EepGet;
|
||||||
@ -83,7 +85,7 @@ public class EepGetFetcher implements EepGet.StatusListener {
|
|||||||
int semi = rv.indexOf(";");
|
int semi = rv.indexOf(";");
|
||||||
if (semi > 0)
|
if (semi > 0)
|
||||||
rv = rv.substring(0, semi);
|
rv = rv.substring(0, semi);
|
||||||
return rv.toLowerCase();
|
return rv.toLowerCase(Locale.US);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,18 +5,23 @@ import android.content.Context;
|
|||||||
import net.i2p.android.router.NewsActivity;
|
import net.i2p.android.router.NewsActivity;
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
import net.i2p.android.router.util.Notifications;
|
import net.i2p.android.router.util.Notifications;
|
||||||
|
import net.i2p.app.ClientApp;
|
||||||
|
import net.i2p.app.ClientAppManager;
|
||||||
|
import net.i2p.app.ClientAppState;
|
||||||
|
import static net.i2p.app.ClientAppState.*;
|
||||||
import net.i2p.crypto.SU3File;
|
import net.i2p.crypto.SU3File;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
import net.i2p.router.news.NewsEntry;
|
import net.i2p.router.news.NewsEntry;
|
||||||
import net.i2p.router.news.NewsMetadata;
|
import net.i2p.router.news.NewsMetadata;
|
||||||
import net.i2p.router.news.NewsXMLParser;
|
import net.i2p.router.news.NewsXMLParser;
|
||||||
import net.i2p.router.util.RFC822Date;
|
|
||||||
import net.i2p.util.EepGet;
|
import net.i2p.util.EepGet;
|
||||||
import net.i2p.util.FileUtil;
|
import net.i2p.util.FileUtil;
|
||||||
|
import net.i2p.util.I2PAppThread;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.ReusableGZIPInputStream;
|
import net.i2p.util.ReusableGZIPInputStream;
|
||||||
import net.i2p.util.SecureFileOutputStream;
|
import net.i2p.util.SecureFileOutputStream;
|
||||||
|
import net.i2p.util.RFC822Date;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -32,8 +37,11 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* From router console, simplified since we don't deal with router versions
|
* From router console, simplified since we don't deal with router versions
|
||||||
* or updates.
|
* or updates.
|
||||||
|
*
|
||||||
|
* As of 0.9.41, implements ClientApp to hang us off the ClientAppManager,
|
||||||
|
* so we can remove the static reference.
|
||||||
*/
|
*/
|
||||||
public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
public class NewsFetcher implements Runnable, EepGet.StatusListener, ClientApp {
|
||||||
private final Context mCtx;
|
private final Context mCtx;
|
||||||
private final RouterContext _context;
|
private final RouterContext _context;
|
||||||
private final Notifications _notif;
|
private final Notifications _notif;
|
||||||
@ -44,20 +52,18 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
|||||||
private boolean _invalidated;
|
private boolean _invalidated;
|
||||||
private File _newsFile;
|
private File _newsFile;
|
||||||
private File _tempFile;
|
private File _tempFile;
|
||||||
private static NewsFetcher _instance;
|
|
||||||
private volatile boolean _isRunning = true;
|
private volatile boolean _isRunning = true;
|
||||||
private Thread _thread;
|
private Thread _thread;
|
||||||
|
private final ClientAppManager _mgr;
|
||||||
|
private volatile ClientAppState _state = UNINITIALIZED;
|
||||||
|
public static final String APP_NAME = "NewsFetcher";
|
||||||
|
|
||||||
public static /*final */ NewsFetcher getInstance() {
|
/**
|
||||||
return _instance;
|
* As of 0.9.41, returns a new one every time. Only call once.
|
||||||
}
|
*/
|
||||||
|
|
||||||
public static /* final */ synchronized NewsFetcher getInstance(
|
public static /* final */ synchronized NewsFetcher getInstance(
|
||||||
Context context, RouterContext ctx, Notifications notif) {
|
Context context, RouterContext ctx, Notifications notif) {
|
||||||
if (_instance != null)
|
return new NewsFetcher(context, ctx, notif);
|
||||||
return _instance;
|
|
||||||
_instance = new NewsFetcher(context, ctx, notif);
|
|
||||||
return _instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String NEWS_DIR = "docs";
|
private static final String NEWS_DIR = "docs";
|
||||||
@ -71,18 +77,17 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
|||||||
*
|
*
|
||||||
* @since 0.7.14 not configurable
|
* @since 0.7.14 not configurable
|
||||||
*/
|
*/
|
||||||
private static final String BACKUP_NEWS_URL_SU3 = "http://avviiexdngd32ccoy4kuckvc3mkf53ycvzbz6vz75vzhv4tbpk5a.b32.i2p/news.su3";
|
private static final String BACKUP_NEWS_URL_SU3 = "http://dn3tvalnjz432qkqsvpfdqrwpqkw3ye4n4i2uyfr4jexvo3sp5ka.b32.i2p/news/news.su3";
|
||||||
private static final String PROP_LAST_CHECKED = "router.newsLastChecked";
|
private static final String PROP_LAST_CHECKED = "router.newsLastChecked";
|
||||||
private static final String PROP_REFRESH_FREQUENCY = "router.newsRefreshFrequency";
|
private static final String PROP_REFRESH_FREQUENCY = "router.newsRefreshFrequency";
|
||||||
private static final String DEFAULT_REFRESH_FREQUENCY = 24 * 60 * 60 * 1000 + "";
|
private static final String DEFAULT_REFRESH_FREQUENCY = 24 * 60 * 60 * 1000 + "";
|
||||||
private static final String PROP_NEWS_URL = "router.newsURL";
|
private static final String PROP_NEWS_URL = "router.newsURL";
|
||||||
public static final String DEFAULT_NEWS_URL_SU3 = "http://echelon.i2p/news/news.su3";
|
public static final String DEFAULT_NEWS_URL_SU3 = "http://tc73n4kivdroccekirco7rhgxdg5f3cjvbaapabupeyzrqwv5guq.b32.i2p/news.su3";
|
||||||
|
|
||||||
private NewsFetcher(Context context, RouterContext ctx, Notifications notif) {
|
private NewsFetcher(Context context, RouterContext ctx, Notifications notif) {
|
||||||
mCtx = context;
|
mCtx = context;
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
_notif = notif;
|
_notif = notif;
|
||||||
_context.addShutdownTask(new Shutdown());
|
|
||||||
_log = ctx.logManager().getLog(NewsFetcher.class);
|
_log = ctx.logManager().getLog(NewsFetcher.class);
|
||||||
try {
|
try {
|
||||||
String last = ctx.getProperty(PROP_LAST_CHECKED);
|
String last = ctx.getProperty(PROP_LAST_CHECKED);
|
||||||
@ -96,6 +101,9 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
|||||||
_newsFile = new File(newsDir, NEWS_FILE);
|
_newsFile = new File(newsDir, NEWS_FILE);
|
||||||
_tempFile = new File(_context.getTempDir(), TEMP_NEWS_FILE);
|
_tempFile = new File(_context.getTempDir(), TEMP_NEWS_FILE);
|
||||||
updateLastFetched();
|
updateLastFetched();
|
||||||
|
_mgr = ctx.clientAppManager();
|
||||||
|
changeState(INITIALIZED);
|
||||||
|
_mgr.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLastFetched() {
|
private void updateLastFetched() {
|
||||||
@ -134,7 +142,17 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
|||||||
private static final long RUN_DELAY = 30 * 60 * 1000;
|
private static final long RUN_DELAY = 30 * 60 * 1000;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
_thread = Thread.currentThread();
|
changeState(RUNNING);
|
||||||
|
try {
|
||||||
|
run2();
|
||||||
|
} finally {
|
||||||
|
_mgr.unregister(this);
|
||||||
|
changeState(STOPPED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void run2() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(INITIAL_DELAY);
|
Thread.sleep(INITIAL_DELAY);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
@ -276,14 +294,6 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
|||||||
public void attempting(String url) {
|
public void attempting(String url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Shutdown implements Runnable {
|
|
||||||
public void run() {
|
|
||||||
_isRunning = false;
|
|
||||||
if (_thread != null)
|
|
||||||
_thread.interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// SU3 handlers
|
// SU3 handlers
|
||||||
//
|
//
|
||||||
@ -417,4 +427,69 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
|||||||
} catch (IOException ioe) {}
|
} catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////// begin ClientApp interface
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.41
|
||||||
|
*/
|
||||||
|
public synchronized void startup() {
|
||||||
|
changeState(STARTING);
|
||||||
|
_thread = new I2PAppThread(this, "NewsFetcher", true);
|
||||||
|
_thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.41
|
||||||
|
*/
|
||||||
|
public synchronized void shutdown(String[] args) {
|
||||||
|
if (_state != RUNNING)
|
||||||
|
return;
|
||||||
|
changeState(STOPPING);
|
||||||
|
_isRunning = false;
|
||||||
|
if (_thread != null)
|
||||||
|
_thread.interrupt();
|
||||||
|
changeState(STOPPED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.41
|
||||||
|
*/
|
||||||
|
public ClientAppState getState() {
|
||||||
|
return _state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.41
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return APP_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.41
|
||||||
|
*/
|
||||||
|
public String getDisplayName() {
|
||||||
|
return APP_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
////// end ClientApp interface
|
||||||
|
////// begin ClientApp helpers
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.41
|
||||||
|
*/
|
||||||
|
private void changeState(ClientAppState state) {
|
||||||
|
changeState(state, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 0.9.41
|
||||||
|
*/
|
||||||
|
private synchronized void changeState(ClientAppState state, Exception e) {
|
||||||
|
_state = state;
|
||||||
|
_mgr.notify(this, state, null, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
////// end ClientApp helpers
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,26 @@
|
|||||||
package net.i2p.android.help;
|
package net.i2p.android.help;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.Uri;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Browser implements Comparable<Browser> {
|
public class Browser implements Comparable<Browser> {
|
||||||
public final String packageName;
|
public final String packageName;
|
||||||
public final CharSequence label;
|
public final CharSequence label;
|
||||||
public final Drawable icon;
|
public final Drawable icon;
|
||||||
public final boolean isInstalled;
|
|
||||||
public final boolean isKnown;
|
public final boolean isKnown;
|
||||||
public final boolean isSupported;
|
public final boolean isSupported;
|
||||||
public final boolean isRecommended;
|
public final boolean isRecommended;
|
||||||
|
|
||||||
|
private boolean isInstalled;
|
||||||
/**
|
/**
|
||||||
* A browser that we don't know about.
|
* A browser that we don't know about.
|
||||||
*
|
*
|
||||||
@ -80,4 +87,23 @@ public class Browser implements Comparable<Browser> {
|
|||||||
} else
|
} else
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInstalled(Context context){
|
||||||
|
if (isInstalled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Find all installed browsers that listen for ".i2p"
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setData(Uri.parse("http://stats.i2p"));
|
||||||
|
|
||||||
|
final PackageManager pm = context.getPackageManager();
|
||||||
|
List<ResolveInfo> installedBrowsers = pm.queryIntentActivities(intent, 0);
|
||||||
|
for (ResolveInfo browser : installedBrowsers) {
|
||||||
|
if (browser.activityInfo.packageName.equals(packageName)) {
|
||||||
|
isInstalled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isInstalled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.android.help;
|
package net.i2p.android.help;
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.ColorMatrix;
|
import android.graphics.ColorMatrix;
|
||||||
@ -11,6 +12,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
|
|
||||||
@ -71,11 +73,15 @@ public class BrowserAdapter extends RecyclerView.Adapter<BrowserAdapter.ViewHold
|
|||||||
holder.mLabel.setText(browser.label);
|
holder.mLabel.setText(browser.label);
|
||||||
|
|
||||||
if (browser.isKnown) {
|
if (browser.isKnown) {
|
||||||
if (browser.isRecommended && browser.isInstalled) {
|
if (browser.isRecommended && browser.isInstalled(mCtx)) {
|
||||||
holder.mStatus.setImageDrawable(
|
holder.mStatus.setImageDrawable(
|
||||||
mCtx.getResources().getDrawable(R.drawable.ic_stars_white_24dp));
|
mCtx.getResources().getDrawable(R.drawable.ic_stars_white_24dp));
|
||||||
holder.mStatus.setVisibility(View.VISIBLE);
|
holder.mStatus.setVisibility(View.VISIBLE);
|
||||||
} else if (browser.isSupported && !browser.isInstalled) {
|
} else if (browser.isSupported && browser.isInstalled(mCtx)) {
|
||||||
|
holder.mStatus.setImageDrawable(
|
||||||
|
mCtx.getResources().getDrawable(R.drawable.ic_stars_white_24dp));
|
||||||
|
holder.mStatus.setVisibility(View.INVISIBLE);
|
||||||
|
} else if (browser.isSupported && !browser.isInstalled(mCtx)) {
|
||||||
holder.mStatus.setImageDrawable(
|
holder.mStatus.setImageDrawable(
|
||||||
mCtx.getResources().getDrawable(R.drawable.ic_shop_white_24dp));
|
mCtx.getResources().getDrawable(R.drawable.ic_shop_white_24dp));
|
||||||
holder.mStatus.setOnClickListener(new View.OnClickListener() {
|
holder.mStatus.setOnClickListener(new View.OnClickListener() {
|
||||||
@ -84,11 +90,15 @@ public class BrowserAdapter extends RecyclerView.Adapter<BrowserAdapter.ViewHold
|
|||||||
String uriMarket = "market://search?q=pname:" + browser.packageName;
|
String uriMarket = "market://search?q=pname:" + browser.packageName;
|
||||||
Uri uri = Uri.parse(uriMarket);
|
Uri uri = Uri.parse(uriMarket);
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
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);
|
holder.mStatus.setVisibility(View.VISIBLE);
|
||||||
} else if (!browser.isSupported) {
|
} else if (browser.isInstalled(mCtx) && !browser.isSupported) {
|
||||||
// Make the icon gray-scale to show it is unsupported
|
// Make the icon gray-scale to show it is unsupported
|
||||||
ColorMatrix matrix = new ColorMatrix();
|
ColorMatrix matrix = new ColorMatrix();
|
||||||
matrix.setSaturation(0);
|
matrix.setSaturation(0);
|
||||||
|
@ -26,6 +26,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -121,8 +123,9 @@ public class BrowserListFragment extends Fragment implements
|
|||||||
intent.setData(Uri.parse("http://stats.i2p"));
|
intent.setData(Uri.parse("http://stats.i2p"));
|
||||||
|
|
||||||
final PackageManager pm = getContext().getPackageManager();
|
final PackageManager pm = getContext().getPackageManager();
|
||||||
List<ResolveInfo> installedBrowsers = pm.queryIntentActivities(intent, 0);
|
Set<ResolveInfo> installedBrowsers = new HashSet<>(pm.queryIntentActivities(intent, 0));
|
||||||
|
|
||||||
|
// Compare installed browsers to supported browsers
|
||||||
for (ResolveInfo browser : installedBrowsers) {
|
for (ResolveInfo browser : installedBrowsers) {
|
||||||
if (recommended.contains(browser.activityInfo.packageName)) {
|
if (recommended.contains(browser.activityInfo.packageName)) {
|
||||||
browsers.add(new Browser(pm, browser, true, true));
|
browsers.add(new Browser(pm, browser, true, true));
|
||||||
|
@ -30,7 +30,7 @@ public class HelpHtmlFragment extends Fragment {
|
|||||||
int padH = getResources().getDimensionPixelOffset(R.dimen.activity_horizontal_margin);
|
int padH = getResources().getDimensionPixelOffset(R.dimen.activity_horizontal_margin);
|
||||||
int padV = getResources().getDimensionPixelOffset(R.dimen.activity_vertical_margin);
|
int padV = getResources().getDimensionPixelOffset(R.dimen.activity_vertical_margin);
|
||||||
text.setPadding(padH, padV, padH, padV);
|
text.setPadding(padH, padV, padH, padV);
|
||||||
text.setHtmlFromRawResource(getActivity(), getArguments().getInt(ARG_HTML_FILE), true);
|
text.setHtml(getArguments().getInt(ARG_HTML_FILE));
|
||||||
return scroller;
|
return scroller;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,17 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.android.i2ptunnel.util.TunnelUtil;
|
import net.i2p.android.i2ptunnel.util.TunnelUtil;
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
|
import net.i2p.android.router.util.Util;
|
||||||
import net.i2p.android.util.FragmentUtils;
|
import net.i2p.android.util.FragmentUtils;
|
||||||
import net.i2p.app.ClientAppState;
|
import net.i2p.app.ClientAppState;
|
||||||
|
import net.i2p.i2ptunnel.TunnelController;
|
||||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,6 +44,7 @@ public class TunnelDetailFragment extends Fragment {
|
|||||||
private TunnelControllerGroup mGroup;
|
private TunnelControllerGroup mGroup;
|
||||||
private TunnelEntry mTunnel;
|
private TunnelEntry mTunnel;
|
||||||
private Toolbar mToolbar;
|
private Toolbar mToolbar;
|
||||||
|
private ImageView mStatus;
|
||||||
|
|
||||||
public static TunnelDetailFragment newInstance(int tunnelId) {
|
public static TunnelDetailFragment newInstance(int tunnelId) {
|
||||||
TunnelDetailFragment f = new TunnelDetailFragment();
|
TunnelDetailFragment f = new TunnelDetailFragment();
|
||||||
@ -73,21 +77,33 @@ public class TunnelDetailFragment extends Fragment {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
String error;
|
String error;
|
||||||
|
List<TunnelController> controllers;
|
||||||
try {
|
try {
|
||||||
mGroup = TunnelControllerGroup.getInstance();
|
mGroup = TunnelControllerGroup.getInstance();
|
||||||
error = mGroup == null ? getResources().getString(R.string.i2ptunnel_not_initialized) : null;
|
error = mGroup == null ? getResources().getString(R.string.i2ptunnel_not_initialized) : null;
|
||||||
|
controllers = mGroup == null ? null : mGroup.getControllers();
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
mGroup = null;
|
mGroup = null;
|
||||||
|
controllers = null;
|
||||||
error = iae.toString();
|
error = iae.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mGroup == null) {
|
if (mGroup == null) {
|
||||||
// Show error
|
Toast.makeText(getActivity().getApplicationContext(),
|
||||||
|
error, Toast.LENGTH_LONG).show();
|
||||||
|
getActivity().finish();
|
||||||
} else if (getArguments().containsKey(TUNNEL_ID)) {
|
} else if (getArguments().containsKey(TUNNEL_ID)) {
|
||||||
int tunnelId = getArguments().getInt(TUNNEL_ID);
|
int tunnelId = getArguments().getInt(TUNNEL_ID);
|
||||||
mTunnel = new TunnelEntry(getActivity(),
|
try {
|
||||||
mGroup.getControllers().get(tunnelId),
|
TunnelController controller = controllers.get(tunnelId);
|
||||||
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();
|
updateToolbar();
|
||||||
|
|
||||||
if (mTunnel != null) {
|
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);
|
TextView name = (TextView) v.findViewById(R.id.tunnel_name);
|
||||||
name.setText(mTunnel.getName());
|
name.setText(mTunnel.getName());
|
||||||
ViewCompat.setTransitionName(name,
|
|
||||||
getActivity().getString(R.string.TUNNEL_NAME) + mTunnel.getId());
|
|
||||||
|
|
||||||
TextView type = (TextView) v.findViewById(R.id.tunnel_type);
|
TextView type = (TextView) v.findViewById(R.id.tunnel_type);
|
||||||
type.setText(mTunnel.getType());
|
type.setText(mTunnel.getType());
|
||||||
|
|
||||||
TextView description = (TextView) v.findViewById(R.id.tunnel_description);
|
TextView description = (TextView) v.findViewById(R.id.tunnel_description);
|
||||||
description.setText(mTunnel.getDescription());
|
description.setText(mTunnel.getDescription());
|
||||||
ViewCompat.setTransitionName(description,
|
|
||||||
getActivity().getString(R.string.TUNNEL_DESCRIPTION) + mTunnel.getId());
|
|
||||||
|
|
||||||
if (!mTunnel.getDetails().isEmpty()) {
|
if (!mTunnel.getDetails().isEmpty()) {
|
||||||
v.findViewById(R.id.tunnel_details_container).setVisibility(View.VISIBLE);
|
v.findViewById(R.id.tunnel_details_container).setVisibility(View.VISIBLE);
|
||||||
@ -204,11 +220,17 @@ public class TunnelDetailFragment extends Fragment {
|
|||||||
Uri uri = mTunnel.getRecommendedAppForTunnel();
|
Uri uri = mTunnel.getRecommendedAppForTunnel();
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(net.i2p.android.lib.client.R.string.no, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
public void onClick(DialogInterface dialogInterface, int i) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -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) {
|
private boolean onToolbarItemSelected(MenuItem item) {
|
||||||
if (mTunnel == null)
|
if (mTunnel == null)
|
||||||
return false;
|
return false;
|
||||||
@ -257,6 +287,8 @@ public class TunnelDetailFragment extends Fragment {
|
|||||||
+ ' ' + mTunnel.getName(), Toast.LENGTH_LONG).show();
|
+ ' ' + mTunnel.getName(), Toast.LENGTH_LONG).show();
|
||||||
// Reload the toolbar to change the start/stop action
|
// Reload the toolbar to change the start/stop action
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
|
// Update the status icon
|
||||||
|
updateStatus();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_stop_tunnel:
|
case R.id.action_stop_tunnel:
|
||||||
mTunnel.getController().stopTunnel();
|
mTunnel.getController().stopTunnel();
|
||||||
@ -265,42 +297,31 @@ public class TunnelDetailFragment extends Fragment {
|
|||||||
+ ' ' + mTunnel.getName(), Toast.LENGTH_LONG).show();
|
+ ' ' + mTunnel.getName(), Toast.LENGTH_LONG).show();
|
||||||
// Reload the toolbar to change the start/stop action
|
// Reload the toolbar to change the start/stop action
|
||||||
updateToolbar();
|
updateToolbar();
|
||||||
|
// Update the status icon
|
||||||
|
updateStatus();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_edit_tunnel:
|
case R.id.action_edit_tunnel:
|
||||||
mCallback.onEditTunnel(mTunnel.getId());
|
mCallback.onEditTunnel(mTunnel.getId());
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_delete_tunnel:
|
case R.id.action_delete_tunnel:
|
||||||
DialogFragment dg = new DialogFragment() {
|
DialogFragment dg = DeleteTunnelDialogFragment.newInstance();
|
||||||
@NonNull
|
dg.show(getChildFragmentManager(), "delete_tunnel_dialog");
|
||||||
@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");
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
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() {
|
private void copyToClipbardLegacy() {
|
||||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
clipboard.setText(mTunnel.getDetails());
|
clipboard.setText(mTunnel.getDetails());
|
||||||
@ -313,4 +334,47 @@ public class TunnelDetailFragment extends Fragment {
|
|||||||
mTunnel.getName(), mTunnel.getDetails());
|
mTunnel.getName(), mTunnel.getDetails());
|
||||||
clipboard.setPrimaryClip(clip);
|
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,16 +6,24 @@ import android.net.Uri;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
|
import net.i2p.android.i2ptunnel.util.SaveTunnelTask;
|
||||||
import net.i2p.android.i2ptunnel.util.TunnelUtil;
|
import net.i2p.android.i2ptunnel.util.TunnelUtil;
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
|
import net.i2p.android.router.util.Util;
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
import net.i2p.data.PrivateKeyFile;
|
import net.i2p.data.PrivateKeyFile;
|
||||||
import net.i2p.i2ptunnel.TunnelController;
|
import net.i2p.i2ptunnel.TunnelController;
|
||||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||||
import net.i2p.i2ptunnel.ui.TunnelConfig;
|
import net.i2p.i2ptunnel.ui.TunnelConfig;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A single tunnel.
|
||||||
|
* Stored by the TunnelEntryAdapter.
|
||||||
|
*/
|
||||||
public class TunnelEntry {
|
public class TunnelEntry {
|
||||||
public static final int RUNNING = 1;
|
public static final int RUNNING = 1;
|
||||||
public static final int STARTING = 2;
|
public static final int STARTING = 2;
|
||||||
@ -26,18 +34,33 @@ public class TunnelEntry {
|
|||||||
private final TunnelController mController;
|
private final TunnelController mController;
|
||||||
private final int mId;
|
private final int mId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tcg non-null
|
||||||
|
* @return the new TunnelEntry, or null if there was an error.
|
||||||
|
*/
|
||||||
public static TunnelEntry createNewTunnel(
|
public static TunnelEntry createNewTunnel(
|
||||||
Context ctx,
|
Context ctx,
|
||||||
TunnelControllerGroup tcg,
|
TunnelControllerGroup tcg,
|
||||||
TunnelConfig cfg) {
|
TunnelConfig cfg) {
|
||||||
int tunnelId = tcg.getControllers().size();
|
int tunnelId = tcg.getControllers().size();
|
||||||
List<String> msgs = TunnelUtil.saveTunnel(
|
TunnelEntry ret = null;
|
||||||
I2PAppContext.getGlobalContext(), tcg, -1, cfg);
|
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.
|
// TODO: Do something else with the other messages.
|
||||||
Toast.makeText(ctx.getApplicationContext(),
|
Toast.makeText(ctx.getApplicationContext(),
|
||||||
msgs.get(0), Toast.LENGTH_LONG).show();
|
msgs.get(0), Toast.LENGTH_LONG).show();
|
||||||
TunnelController cur = TunnelUtil.getController(tcg, tunnelId);
|
return ret;
|
||||||
return new TunnelEntry(ctx, cur, tunnelId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TunnelEntry(Context context, TunnelController controller, int id) {
|
public TunnelEntry(Context context, TunnelController controller, int id) {
|
||||||
@ -262,6 +285,8 @@ public class TunnelEntry {
|
|||||||
return mContext.getResources()
|
return mContext.getResources()
|
||||||
.getDrawable(R.drawable.ic_schedule_black_24dp);
|
.getDrawable(R.drawable.ic_schedule_black_24dp);
|
||||||
case STARTING:
|
case STARTING:
|
||||||
|
return mContext.getResources()
|
||||||
|
.getDrawable(R.drawable.ic_sync_black_24dp);
|
||||||
case RUNNING:
|
case RUNNING:
|
||||||
case NOT_RUNNING:
|
case NOT_RUNNING:
|
||||||
default:
|
default:
|
||||||
|
@ -5,22 +5,31 @@ import android.os.Build;
|
|||||||
import android.support.v4.util.Pair;
|
import android.support.v4.util.Pair;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
import net.i2p.android.util.FragmentUtils;
|
import net.i2p.android.util.FragmentUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains the List of TunnelEntries.
|
||||||
|
* There's two of these, one for client tunnels and
|
||||||
|
* one for server tunnels.
|
||||||
|
* Created by the TunnelListFragment.
|
||||||
|
*/
|
||||||
public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
private Context mCtx;
|
private final Context mCtx;
|
||||||
private boolean mClientTunnels;
|
private final boolean mClientTunnels;
|
||||||
private TunnelListFragment.OnTunnelSelectedListener mListener;
|
private final TunnelListFragment.OnTunnelSelectedListener mListener;
|
||||||
private FragmentUtils.TwoPaneProvider mTwoPane;
|
private final FragmentUtils.TwoPaneProvider mTwoPane;
|
||||||
private List<TunnelEntry> mTunnels;
|
private List<TunnelEntry> mTunnels;
|
||||||
/**
|
/**
|
||||||
* The current activated item position. Only used on tablets.
|
* The current activated item position. Only used on tablets.
|
||||||
@ -34,10 +43,10 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class TunnelViewHolder extends RecyclerView.ViewHolder {
|
public static class TunnelViewHolder extends RecyclerView.ViewHolder {
|
||||||
public ImageView status;
|
public final ImageView status;
|
||||||
public TextView name;
|
public final TextView name;
|
||||||
public TextView description;
|
public final TextView description;
|
||||||
public TextView interfacePort;
|
public final TextView interfacePort;
|
||||||
|
|
||||||
public TunnelViewHolder(View itemView) {
|
public TunnelViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
@ -65,8 +74,15 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addTunnel(TunnelEntry tunnel) {
|
public void addTunnel(TunnelEntry tunnel) {
|
||||||
|
if (mTunnels == null)
|
||||||
|
mTunnels = new ArrayList<TunnelEntry>();
|
||||||
|
boolean wasEmpty = mTunnels.isEmpty();
|
||||||
mTunnels.add(tunnel);
|
mTunnels.add(tunnel);
|
||||||
notifyItemInserted(mTunnels.size()-1);
|
if (wasEmpty) {
|
||||||
|
notifyDataSetChanged();
|
||||||
|
} else {
|
||||||
|
notifyItemInserted(mTunnels.size() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TunnelEntry getTunnel(int position) {
|
public TunnelEntry getTunnel(int position) {
|
||||||
@ -115,13 +131,24 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setClipboard(Context context, String text) {
|
||||||
|
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
clipboard.setText(text);
|
||||||
|
} else {
|
||||||
|
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
android.content.ClipData clip = android.content.ClipData.newPlainText("Copied Text", text);
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Replace the contents of a view (invoked by the layout manager)
|
// Replace the contents of a view (invoked by the layout manager)
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
|
||||||
switch (holder.getItemViewType()) {
|
switch (holder.getItemViewType()) {
|
||||||
case R.string.router_not_running:
|
case R.string.router_not_running:
|
||||||
((TextView) holder.itemView).setText(
|
((TextView) holder.itemView).setText(
|
||||||
mCtx.getString(R.string.router_not_running));
|
mCtx.getString(R.string.i2ptunnel_not_initialized));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.layout.listitem_empty:
|
case R.layout.listitem_empty:
|
||||||
@ -139,32 +166,49 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
tvh.status.setBackgroundDrawable(tunnel.getStatusBackground());
|
tvh.status.setBackgroundDrawable(tunnel.getStatusBackground());
|
||||||
else
|
else
|
||||||
tvh.status.setBackground(tunnel.getStatusBackground());
|
tvh.status.setBackground(tunnel.getStatusBackground());
|
||||||
|
ViewCompat.setTransitionName(tvh.status,
|
||||||
|
"status" + tunnel.getId());
|
||||||
|
|
||||||
tvh.name.setText(tunnel.getName());
|
tvh.name.setText(tunnel.getName());
|
||||||
tvh.description.setText(tunnel.getDescription());
|
tvh.description.setText(tunnel.getDescription());
|
||||||
tvh.interfacePort.setText(tunnel.getTunnelLink(false));
|
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.setSelected(mTwoPane.isTwoPane() && position == mActivatedPosition);
|
||||||
tvh.itemView.setOnClickListener(new View.OnClickListener() {
|
tvh.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
// TODO
|
||||||
|
// lint priority 8/10
|
||||||
|
// lint: Do not treat position as fixed; only use immediately and call holder.getAdapterPosition() to look it up later
|
||||||
|
// javadocs: Note that unlike ListView, RecyclerView will not call this method again
|
||||||
|
// if the position of the item changes in the data set unless the item itself is invalidated
|
||||||
|
// or the new position cannot be determined.
|
||||||
|
// For this reason, you should only use the position parameter while acquiring
|
||||||
|
// the related data item inside this method and should not keep a copy of it.
|
||||||
|
// If you need the position of an item later on (e.g. in a click listener),
|
||||||
|
// use RecyclerView.ViewHolder.getAdapterPosition() which will have the updated adapter position.
|
||||||
int oldPosition = mActivatedPosition;
|
int oldPosition = mActivatedPosition;
|
||||||
mActivatedPosition = position;
|
mActivatedPosition = position;
|
||||||
notifyItemChanged(oldPosition);
|
notifyItemChanged(oldPosition);
|
||||||
notifyItemChanged(position);
|
notifyItemChanged(position);
|
||||||
Pair<View, String> namePair = Pair.create(
|
Pair<View, String> statusPair = Pair.create(
|
||||||
(View)tvh.name,
|
(View)tvh.status,
|
||||||
ViewCompat.getTransitionName(tvh.name));
|
ViewCompat.getTransitionName(tvh.status));
|
||||||
Pair<View, String> descPair = Pair.create(
|
Pair<View, String>[] pairs = new Pair[]{ statusPair};
|
||||||
(View)tvh.description,
|
|
||||||
ViewCompat.getTransitionName(tvh.description));
|
|
||||||
Pair<View, String>[] pairs = new Pair[]{ namePair, descPair};
|
|
||||||
mListener.onTunnelSelected(tunnel.getId(), pairs);
|
mListener.onTunnelSelected(tunnel.getId(), pairs);
|
||||||
|
view.invalidate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tvh.itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
|
//@Override
|
||||||
|
public boolean onLongClick(View view) {
|
||||||
|
setClipboard(mCtx, tunnel.getDestHashBase32());
|
||||||
|
Toast clipboardMessage = Toast.makeText(mCtx, R.string.copied_base32_system_notification_title, Toast. LENGTH_LONG);
|
||||||
|
clipboardMessage.setGravity(Gravity.TOP, 0, 0); //optional
|
||||||
|
clipboardMessage.show();
|
||||||
|
view.invalidate();
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -172,6 +216,7 @@ public class TunnelEntryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHo
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the size of the dataset (invoked by the layout manager)
|
// Return the size of the dataset (invoked by the layout manager)
|
||||||
|
@ -13,10 +13,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TunnelEntryLoader extends AsyncTaskLoader<List<TunnelEntry>> {
|
public class TunnelEntryLoader extends AsyncTaskLoader<List<TunnelEntry>> {
|
||||||
private TunnelControllerGroup mGroup;
|
private final TunnelControllerGroup mGroup;
|
||||||
private boolean mClientTunnels;
|
private final boolean mClientTunnels;
|
||||||
private List<TunnelEntry> mData;
|
private List<TunnelEntry> mData;
|
||||||
private Handler mHandler;
|
private final Handler mHandler;
|
||||||
private TunnelControllerMonitor mMonitor;
|
private TunnelControllerMonitor mMonitor;
|
||||||
|
|
||||||
public TunnelEntryLoader(Context context, TunnelControllerGroup tcg, boolean clientTunnels) {
|
public TunnelEntryLoader(Context context, TunnelControllerGroup tcg, boolean clientTunnels) {
|
||||||
|
@ -31,6 +31,12 @@ import net.i2p.i2ptunnel.TunnelControllerGroup;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of tunnels.
|
||||||
|
* There's two of these, one for client tunnels and
|
||||||
|
* one for server tunnels.
|
||||||
|
* Creates the TunnelEntryAdapter.
|
||||||
|
*/
|
||||||
public class TunnelListFragment extends Fragment implements
|
public class TunnelListFragment extends Fragment implements
|
||||||
LoaderManager.LoaderCallbacks<List<TunnelEntry>> {
|
LoaderManager.LoaderCallbacks<List<TunnelEntry>> {
|
||||||
public static final String SHOW_CLIENT_TUNNELS = "show_client_tunnels";
|
public static final String SHOW_CLIENT_TUNNELS = "show_client_tunnels";
|
||||||
@ -150,14 +156,21 @@ public class TunnelListFragment extends Fragment implements
|
|||||||
};
|
};
|
||||||
|
|
||||||
public void updateState(State state) {
|
public void updateState(State state) {
|
||||||
if (state == State.STOPPING || state == State.STOPPED ||
|
try {
|
||||||
state == State.MANUAL_STOPPING ||
|
if (state == State.INIT ||
|
||||||
state == State.MANUAL_STOPPED ||
|
state == State.STARTING || // Wait until RouterContext is initialised
|
||||||
state == State.MANUAL_QUITTING ||
|
state == State.STOPPING ||
|
||||||
state == State.MANUAL_QUITTED)
|
state == State.STOPPED ||
|
||||||
getLoaderManager().destroyLoader(mClientTunnels ? CLIENT_LOADER_ID : SERVER_LOADER_ID);
|
state == State.MANUAL_STOPPING ||
|
||||||
else
|
state == State.MANUAL_STOPPED ||
|
||||||
initTunnels();
|
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() {
|
private void initTunnels() {
|
||||||
|
@ -2,6 +2,7 @@ package net.i2p.android.i2ptunnel;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -21,26 +22,51 @@ public class TunnelWizardActivity extends AbstractWizardActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DialogFragment onGetFinishWizardDialog() {
|
protected DialogFragment onGetFinishWizardDialog() {
|
||||||
return new DialogFragment() {
|
return FinishWizardDialogFragment.newInstance();
|
||||||
@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) {
|
public void onFinishWizard() {
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
result.putExtra(TunnelsContainer.TUNNEL_WIZARD_DATA, mWizardModel.save());
|
result.putExtra(TunnelsContainer.TUNNEL_WIZARD_DATA, mWizardModel.save());
|
||||||
setResult(Activity.RESULT_OK, result);
|
setResult(Activity.RESULT_OK, result);
|
||||||
dialog.dismiss();
|
finish();
|
||||||
finish();
|
}
|
||||||
}
|
|
||||||
})
|
public static class FinishWizardDialogFragment extends DialogFragment {
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
TunnelWizardActivity mListener;
|
||||||
.create();
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,11 @@ import net.i2p.router.RouterContext;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The top level Fragment of the tunnels tabs.
|
||||||
|
* Creates client and server TunnelListFragments,
|
||||||
|
* the options menu, and the new tunnel wizard button.
|
||||||
|
*/
|
||||||
public class TunnelsContainer extends Fragment implements
|
public class TunnelsContainer extends Fragment implements
|
||||||
FragmentUtils.TwoPaneProvider,
|
FragmentUtils.TwoPaneProvider,
|
||||||
TunnelListFragment.OnTunnelSelectedListener,
|
TunnelListFragment.OnTunnelSelectedListener,
|
||||||
@ -65,6 +70,13 @@ public class TunnelsContainer extends Fragment implements
|
|||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean showActions() {
|
||||||
|
RouterContext rCtx = Util.getRouterContext();
|
||||||
|
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance();
|
||||||
|
return rCtx != null && tcg != null &&
|
||||||
|
tcg.getState() == ClientAppState.RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View v = inflater.inflate(R.layout.container_tunnels, container, false);
|
View v = inflater.inflate(R.layout.container_tunnels, container, false);
|
||||||
@ -72,6 +84,7 @@ public class TunnelsContainer extends Fragment implements
|
|||||||
mViewPager = (ViewPager) v.findViewById(R.id.pager);
|
mViewPager = (ViewPager) v.findViewById(R.id.pager);
|
||||||
mPageIndicator = (TitlePageIndicator) v.findViewById(R.id.page_indicator);
|
mPageIndicator = (TitlePageIndicator) v.findViewById(R.id.page_indicator);
|
||||||
mNewTunnel = (ImageButton) v.findViewById(R.id.promoted_action);
|
mNewTunnel = (ImageButton) v.findViewById(R.id.promoted_action);
|
||||||
|
mNewTunnel.setVisibility(showActions() ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
if (v.findViewById(R.id.detail_fragment) != null) {
|
if (v.findViewById(R.id.detail_fragment) != null) {
|
||||||
// The detail container view will be present only in the
|
// The detail container view will be present only in the
|
||||||
@ -154,17 +167,16 @@ public class TunnelsContainer extends Fragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
public void onPrepareOptionsMenu(Menu menu) {
|
||||||
RouterContext rCtx = Util.getRouterContext();
|
boolean showActions = showActions();
|
||||||
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance();
|
|
||||||
boolean showActions = rCtx != null && tcg != null &&
|
|
||||||
(tcg.getState() == ClientAppState.STARTING ||
|
|
||||||
tcg.getState() == ClientAppState.RUNNING);
|
|
||||||
|
|
||||||
menu.findItem(R.id.action_start_all_tunnels).setVisible(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_stop_all_tunnels).setVisible(showActions);
|
||||||
menu.findItem(R.id.action_restart_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
|
@Override
|
||||||
@ -183,7 +195,10 @@ public class TunnelsContainer extends Fragment implements
|
|||||||
msgs = tcg.stopAllControllers();
|
msgs = tcg.stopAllControllers();
|
||||||
break;
|
break;
|
||||||
case R.id.action_restart_all_tunnels:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
@ -200,15 +215,26 @@ public class TunnelsContainer extends Fragment implements
|
|||||||
if (requestCode == TUNNEL_WIZARD_REQUEST) {
|
if (requestCode == TUNNEL_WIZARD_REQUEST) {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
Bundle tunnelData = data.getExtras().getBundle(TUNNEL_WIZARD_DATA);
|
Bundle tunnelData = data.getExtras().getBundle(TUNNEL_WIZARD_DATA);
|
||||||
|
// ticket #2483
|
||||||
|
if (tunnelData == null)
|
||||||
|
return;
|
||||||
// TODO fetch earlier
|
// TODO fetch earlier
|
||||||
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance();
|
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance();
|
||||||
|
if (tcg == null) {
|
||||||
|
// router went away
|
||||||
|
Toast.makeText(getActivity().getApplicationContext(),
|
||||||
|
R.string.router_not_running, Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
TunnelConfig cfg = TunnelUtil.createConfigFromWizard(getActivity(), tcg, tunnelData);
|
TunnelConfig cfg = TunnelUtil.createConfigFromWizard(getActivity(), tcg, tunnelData);
|
||||||
TunnelEntry tunnel = TunnelEntry.createNewTunnel(getActivity(), tcg, cfg);
|
TunnelEntry tunnel = TunnelEntry.createNewTunnel(getActivity(), tcg, cfg);
|
||||||
|
|
||||||
if (tunnel.isClient() && mClientFrag != null)
|
if (tunnel != null) {
|
||||||
mClientFrag.addTunnel(tunnel);
|
if (tunnel.isClient() && mClientFrag != null)
|
||||||
else if (mServerFrag != null)
|
mClientFrag.addTunnel(tunnel);
|
||||||
mServerFrag.addTunnel(tunnel);
|
else if (mServerFrag != null)
|
||||||
|
mServerFrag.addTunnel(tunnel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,21 @@ import android.os.Bundle;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceGroup;
|
import android.support.v7.preference.PreferenceGroup;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
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.i2ptunnel.util.TunnelUtil;
|
||||||
import net.i2p.android.preferences.util.CustomPreferenceFragment;
|
import net.i2p.android.preferences.util.CustomPreferenceFragment;
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
|
import net.i2p.android.router.util.Util;
|
||||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||||
import net.i2p.i2ptunnel.ui.TunnelConfig;
|
import net.i2p.i2ptunnel.ui.TunnelConfig;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public abstract class BaseTunnelPreferenceFragment extends CustomPreferenceFragment {
|
public abstract class BaseTunnelPreferenceFragment extends CustomPreferenceFragment {
|
||||||
protected static final String ARG_TUNNEL_ID = "tunnelId";
|
protected static final String ARG_TUNNEL_ID = "tunnelId";
|
||||||
|
|
||||||
@ -31,13 +38,30 @@ public abstract class BaseTunnelPreferenceFragment extends CustomPreferenceFragm
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mGroup == null) {
|
if (mGroup == null) {
|
||||||
// TODO Show error
|
Toast.makeText(getActivity().getApplicationContext(),
|
||||||
|
error, Toast.LENGTH_LONG).show();
|
||||||
|
getActivity().finish();
|
||||||
} else if (getArguments().containsKey(ARG_TUNNEL_ID)) {
|
} else if (getArguments().containsKey(ARG_TUNNEL_ID)) {
|
||||||
mTunnelId = getArguments().getInt(ARG_TUNNEL_ID, 0);
|
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
|
// https://stackoverflow.com/questions/17880437/which-settings-file-does-preferencefragment-read-write
|
||||||
getPreferenceManager().setSharedPreferencesName(TunnelUtil.getPreferencesFilename(mTunnelId));
|
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 +86,21 @@ public abstract class BaseTunnelPreferenceFragment extends CustomPreferenceFragm
|
|||||||
private void saveTunnel() {
|
private void saveTunnel() {
|
||||||
if (mGroup != null) {
|
if (mGroup != null) {
|
||||||
TunnelConfig cfg = TunnelUtil.createConfigFromPreferences(getActivity(), mGroup, mTunnelId);
|
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(2, TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Util.e("Interrupted while saving tunnel config", e);
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
Util.e("Error while saving tunnel config", e);
|
||||||
|
} catch (CancellationException e) {
|
||||||
|
Util.e("Cancelled while saving tunnel config", e);
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
Util.e("Timed out while savomg tunnel config", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.android.i2ptunnel.preferences;
|
package net.i2p.android.i2ptunnel.preferences;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@ -110,7 +111,8 @@ public class GeneralTunnelPreferenceFragment extends BaseTunnelPreferenceFragmen
|
|||||||
generalCategory.removePreference(generalCategory.findPreference(getString(R.string.TUNNEL_SHARED_CLIENT)));
|
generalCategory.removePreference(generalCategory.findPreference(getString(R.string.TUNNEL_SHARED_CLIENT)));
|
||||||
addPreferencesFromResource(R.xml.tunnel_gen_server_port, portCategory);
|
addPreferencesFromResource(R.xml.tunnel_gen_server_port, portCategory);
|
||||||
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_TARGET_PORT)));
|
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_TARGET_PORT)));
|
||||||
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_USE_SSL)));
|
// # TODO: See trac issue #2296
|
||||||
|
//portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_USE_SSL)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,14 +137,17 @@ public class GeneralTunnelPreferenceFragment extends BaseTunnelPreferenceFragmen
|
|||||||
protected Void doInBackground(Void... voids) {
|
protected Void doInBackground(Void... voids) {
|
||||||
Set<String> interfaceSet = Addresses.getAllAddresses();
|
Set<String> interfaceSet = Addresses.getAllAddresses();
|
||||||
final String[] interfaces = interfaceSet.toArray(new String[interfaceSet.size()]);
|
final String[] interfaces = interfaceSet.toArray(new String[interfaceSet.size()]);
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
Activity activity = getActivity();
|
||||||
@Override
|
if (activity != null) {
|
||||||
public void run() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
reachableBy.setEntries(interfaces);
|
@Override
|
||||||
reachableBy.setEntryValues(interfaces);
|
public void run() {
|
||||||
reachableBy.setEnabled(true);
|
reachableBy.setEntries(interfaces);
|
||||||
}
|
reachableBy.setEntryValues(interfaces);
|
||||||
});
|
reachableBy.setEnabled(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
@ -164,8 +169,11 @@ public class GeneralTunnelPreferenceFragment extends BaseTunnelPreferenceFragmen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void generalClientStandardOrIrc(boolean isStandardOrIrc) {
|
protected void generalClientStandardOrIrc(boolean isStandardOrIrc) {
|
||||||
|
/*
|
||||||
|
# TODO: See trac issue #2296
|
||||||
if (!isStandardOrIrc)
|
if (!isStandardOrIrc)
|
||||||
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_USE_SSL)));
|
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_USE_SSL)));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -181,7 +189,8 @@ public class GeneralTunnelPreferenceFragment extends BaseTunnelPreferenceFragmen
|
|||||||
@Override
|
@Override
|
||||||
protected void generalServerHttpBidirOrStreamr(boolean isStreamr) {
|
protected void generalServerHttpBidirOrStreamr(boolean isStreamr) {
|
||||||
addPreferencesFromResource(R.xml.tunnel_gen_client_port, portCategory);
|
addPreferencesFromResource(R.xml.tunnel_gen_client_port, portCategory);
|
||||||
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_USE_SSL)));
|
// # TODO: See trac issue #2296
|
||||||
|
//portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_USE_SSL)));
|
||||||
if (isStreamr)
|
if (isStreamr)
|
||||||
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_LISTEN_PORT)));
|
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_LISTEN_PORT)));
|
||||||
|
|
||||||
@ -197,7 +206,8 @@ public class GeneralTunnelPreferenceFragment extends BaseTunnelPreferenceFragmen
|
|||||||
protected void generalServerPortStreamr(boolean isStreamr) {
|
protected void generalServerPortStreamr(boolean isStreamr) {
|
||||||
if (isStreamr) {
|
if (isStreamr) {
|
||||||
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_TARGET_HOST)));
|
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_TARGET_HOST)));
|
||||||
portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_USE_SSL)));
|
// # TODO: See trac issue #2296
|
||||||
|
//portCategory.removePreference(portCategory.findPreference(getString(R.string.TUNNEL_USE_SSL)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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>> {
|
||||||
|
final TunnelControllerGroup mGroup;
|
||||||
|
final int mTunnelId;
|
||||||
|
final 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);
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@ package net.i2p.android.i2ptunnel.util;
|
|||||||
* tunnel properties always exist.
|
* tunnel properties always exist.
|
||||||
*/
|
*/
|
||||||
public abstract class TunnelLogic {
|
public abstract class TunnelLogic {
|
||||||
protected String mType;
|
protected final String mType;
|
||||||
|
|
||||||
public TunnelLogic(String type) {
|
public TunnelLogic(String type) {
|
||||||
mType = type;
|
mType = type;
|
||||||
|
@ -7,6 +7,7 @@ import android.os.Bundle;
|
|||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
|
import net.i2p.android.router.util.Util;
|
||||||
import net.i2p.android.wizard.model.Page;
|
import net.i2p.android.wizard.model.Page;
|
||||||
import net.i2p.i2ptunnel.TunnelController;
|
import net.i2p.i2ptunnel.TunnelController;
|
||||||
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
import net.i2p.i2ptunnel.TunnelControllerGroup;
|
||||||
@ -99,6 +100,7 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
public static void writeTunnelToPreferences(Context ctx, TunnelControllerGroup tcg, int tunnel) {
|
public static void writeTunnelToPreferences(Context ctx, TunnelControllerGroup tcg, int tunnel) {
|
||||||
new TunnelUtil(tcg).writeTunnelToPreferences(ctx, tunnel);
|
new TunnelUtil(tcg).writeTunnelToPreferences(ctx, tunnel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeTunnelToPreferences(Context ctx, int tunnel) {
|
public void writeTunnelToPreferences(Context ctx, int tunnel) {
|
||||||
Resources res = ctx.getResources();
|
Resources res = ctx.getResources();
|
||||||
|
|
||||||
@ -122,9 +124,9 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TunnelToPreferences extends TunnelLogic {
|
class TunnelToPreferences extends TunnelLogic {
|
||||||
SharedPreferences.Editor ed;
|
final SharedPreferences.Editor ed;
|
||||||
Resources res;
|
final Resources res;
|
||||||
int tunnel;
|
final int tunnel;
|
||||||
|
|
||||||
public TunnelToPreferences(SharedPreferences.Editor ed, Resources res, int tunnel, String type) {
|
public TunnelToPreferences(SharedPreferences.Editor ed, Resources res, int tunnel, String type) {
|
||||||
super(type);
|
super(type);
|
||||||
@ -182,8 +184,10 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void generalClientStandardOrIrc(boolean isStandardOrIrc) {
|
protected void generalClientStandardOrIrc(boolean isStandardOrIrc) {
|
||||||
|
/* # TODO: See trac issue #2296
|
||||||
if (isStandardOrIrc)
|
if (isStandardOrIrc)
|
||||||
ed.putBoolean(res.getString(R.string.TUNNEL_USE_SSL), isSSLEnabled(tunnel));
|
ed.putBoolean(res.getString(R.string.TUNNEL_USE_SSL), isSSLEnabled(tunnel));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -212,7 +216,8 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
protected void generalServerPortStreamr(boolean isStreamr) {
|
protected void generalServerPortStreamr(boolean isStreamr) {
|
||||||
if (!isStreamr) {
|
if (!isStreamr) {
|
||||||
ed.putString(res.getString(R.string.TUNNEL_TARGET_HOST), getTargetHost(tunnel));
|
ed.putString(res.getString(R.string.TUNNEL_TARGET_HOST), getTargetHost(tunnel));
|
||||||
ed.putBoolean(res.getString(R.string.TUNNEL_USE_SSL), isSSLEnabled(tunnel));
|
// # TODO: See trac issue #2296
|
||||||
|
//ed.putBoolean(res.getString(R.string.TUNNEL_USE_SSL), isSSLEnabled(tunnel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,6 +330,7 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
public static TunnelConfig createConfigFromPreferences(Context ctx, TunnelControllerGroup tcg, int tunnel) {
|
public static TunnelConfig createConfigFromPreferences(Context ctx, TunnelControllerGroup tcg, int tunnel) {
|
||||||
return new TunnelUtil(tcg).createConfigFromPreferences(ctx, tunnel);
|
return new TunnelUtil(tcg).createConfigFromPreferences(ctx, tunnel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TunnelConfig createConfigFromPreferences(Context ctx, int tunnel) {
|
public TunnelConfig createConfigFromPreferences(Context ctx, int tunnel) {
|
||||||
Resources res = ctx.getResources();
|
Resources res = ctx.getResources();
|
||||||
|
|
||||||
@ -345,11 +351,11 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TunnelConfigFromPreferences extends TunnelLogic {
|
class TunnelConfigFromPreferences extends TunnelLogic {
|
||||||
TunnelConfig cfg;
|
final TunnelConfig cfg;
|
||||||
SharedPreferences prefs;
|
final SharedPreferences prefs;
|
||||||
Resources res;
|
final Resources res;
|
||||||
TunnelControllerGroup tcg;
|
final TunnelControllerGroup tcg;
|
||||||
int tunnel;
|
final int tunnel;
|
||||||
|
|
||||||
public TunnelConfigFromPreferences(TunnelConfig cfg, SharedPreferences prefs, Resources res,
|
public TunnelConfigFromPreferences(TunnelConfig cfg, SharedPreferences prefs, Resources res,
|
||||||
TunnelControllerGroup tcg, int tunnel, String type) {
|
TunnelControllerGroup tcg, int tunnel, String type) {
|
||||||
@ -414,8 +420,10 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void generalClientStandardOrIrc(boolean isStandardOrIrc) {
|
protected void generalClientStandardOrIrc(boolean isStandardOrIrc) {
|
||||||
|
/* # TODO: See trac issue #2296
|
||||||
if (isStandardOrIrc)
|
if (isStandardOrIrc)
|
||||||
cfg.setUseSSL(prefs.getBoolean(res.getString(R.string.TUNNEL_USE_SSL), false));
|
cfg.setUseSSL(prefs.getBoolean(res.getString(R.string.TUNNEL_USE_SSL), false));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -444,7 +452,8 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
protected void generalServerPortStreamr(boolean isStreamr) {
|
protected void generalServerPortStreamr(boolean isStreamr) {
|
||||||
if (!isStreamr) {
|
if (!isStreamr) {
|
||||||
cfg.setTargetHost(prefs.getString(res.getString(R.string.TUNNEL_TARGET_HOST), "127.0.0.1"));
|
cfg.setTargetHost(prefs.getString(res.getString(R.string.TUNNEL_TARGET_HOST), "127.0.0.1"));
|
||||||
cfg.setUseSSL(prefs.getBoolean(res.getString(R.string.TUNNEL_USE_SSL), false));
|
// # TODO: See trac issue #2296
|
||||||
|
//cfg.setUseSSL(prefs.getBoolean(res.getString(R.string.TUNNEL_USE_SSL), false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,10 +569,17 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param data non-null
|
||||||
|
*/
|
||||||
public static TunnelConfig createConfigFromWizard(
|
public static TunnelConfig createConfigFromWizard(
|
||||||
Context ctx, TunnelControllerGroup tcg, Bundle data) {
|
Context ctx, TunnelControllerGroup tcg, Bundle data) {
|
||||||
return new TunnelUtil(tcg).createConfigFromWizard(ctx, data);
|
return new TunnelUtil(tcg).createConfigFromWizard(ctx, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param data non-null
|
||||||
|
*/
|
||||||
public TunnelConfig createConfigFromWizard(Context ctx, Bundle data) {
|
public TunnelConfig createConfigFromWizard(Context ctx, Bundle data) {
|
||||||
// Get the Bundle keys
|
// Get the Bundle keys
|
||||||
Resources res = ctx.getResources();
|
Resources res = ctx.getResources();
|
||||||
@ -574,21 +590,26 @@ public class TunnelUtil extends GeneralHelper {
|
|||||||
// Update the TunnelConfig from the tunnel wizard settings
|
// Update the TunnelConfig from the tunnel wizard settings
|
||||||
String kClientServer = res.getString(R.string.i2ptunnel_wizard_k_client_server);
|
String kClientServer = res.getString(R.string.i2ptunnel_wizard_k_client_server);
|
||||||
String kType = res.getString(R.string.i2ptunnel_wizard_k_type);
|
String kType = res.getString(R.string.i2ptunnel_wizard_k_type);
|
||||||
String clientServer = data.getBundle(kClientServer).getString(Page.SIMPLE_DATA_KEY);
|
try {
|
||||||
String typeName = data.getBundle(clientServer + ":" + kType).getString(Page.SIMPLE_DATA_KEY);
|
String clientServer = data.getBundle(kClientServer).getString(Page.SIMPLE_DATA_KEY);
|
||||||
String type = getTypeFromName(typeName, ctx);
|
String typeName = data.getBundle(clientServer + ":" + kType).getString(Page.SIMPLE_DATA_KEY);
|
||||||
cfg.setType(type);
|
String type = getTypeFromName(typeName, ctx);
|
||||||
|
cfg.setType(type);
|
||||||
|
|
||||||
|
new TunnelConfigFromWizard(cfg, data, res, _group, type).runLogic();
|
||||||
|
} catch (NullPointerException ex) {
|
||||||
|
Util.e("Exception while trying to create config from wizard: "+ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
new TunnelConfigFromWizard(cfg, data, res, _group, type).runLogic();
|
|
||||||
|
|
||||||
return cfg;
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TunnelConfigFromWizard extends TunnelLogic {
|
class TunnelConfigFromWizard extends TunnelLogic {
|
||||||
TunnelConfig cfg;
|
final TunnelConfig cfg;
|
||||||
Bundle data;
|
final Bundle data;
|
||||||
Resources res;
|
final Resources res;
|
||||||
TunnelControllerGroup tcg;
|
final TunnelControllerGroup tcg;
|
||||||
|
|
||||||
public TunnelConfigFromWizard(TunnelConfig cfg, Bundle data, Resources res,
|
public TunnelConfigFromWizard(TunnelConfig cfg, Bundle data, Resources res,
|
||||||
TunnelControllerGroup tcg, String type) {
|
TunnelControllerGroup tcg, String type) {
|
||||||
|
@ -3,12 +3,11 @@ package net.i2p.android.preferences;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceFragmentCompat;
|
|
||||||
|
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
import net.i2p.android.router.SettingsActivity;
|
import net.i2p.android.router.SettingsActivity;
|
||||||
|
|
||||||
public class AdvancedPreferenceFragment extends PreferenceFragmentCompat {
|
public class AdvancedPreferenceFragment extends I2PreferenceFragment {
|
||||||
private static final String PREFERENCE_CATEGORY_TRANSPORTS = "preference_category_transports";
|
private static final String PREFERENCE_CATEGORY_TRANSPORTS = "preference_category_transports";
|
||||||
private static final String PREFERENCE_CATEGORY_EXPL_TUNNELS = "preference_category_expl_tunnels";
|
private static final String PREFERENCE_CATEGORY_EXPL_TUNNELS = "preference_category_expl_tunnels";
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.android.preferences;
|
package net.i2p.android.preferences;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -30,6 +31,7 @@ public class TransportsPreferenceFragment extends I2PreferenceFragment {
|
|||||||
((SettingsActivity) getActivity()).getSupportActionBar().setTitle(R.string.settings_label_transports);
|
((SettingsActivity) getActivity()).getSupportActionBar().setTitle(R.string.settings_label_transports);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ApplySharedPref")
|
||||||
private void loadProperties() {
|
private void loadProperties() {
|
||||||
Context context= getActivity();
|
Context context= getActivity();
|
||||||
RouterContext ctx = Util.getRouterContext();
|
RouterContext ctx = Util.getRouterContext();
|
||||||
|
@ -68,6 +68,10 @@ public class ConnectionLimitPreference extends EditTextPreference {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean persistString(String value) {
|
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
|
@Override
|
||||||
protected boolean persistString(String value) {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public class IntListPreference extends ListPreference {
|
|||||||
getPersistedInt(0);
|
getPersistedInt(0);
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
// Fix for where this preference was previously stored in a ListPreference
|
// Fix for where this preference was previously stored in a ListPreference
|
||||||
getSharedPreferences().edit().remove(getKey()).commit();
|
getSharedPreferences().edit().remove(getKey()).apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import net.i2p.android.ext.floatingactionbutton.FloatingActionsMenu;
|
import net.i2p.android.ext.floatingactionbutton.FloatingActionsMenu;
|
||||||
|
import net.i2p.android.ext.floatingactionbutton.FloatingActionsMenu.OnFloatingActionsMenuUpdateListener;
|
||||||
import net.i2p.android.router.dialog.AboutDialog;
|
import net.i2p.android.router.dialog.AboutDialog;
|
||||||
import net.i2p.android.router.dialog.TextResourceDialog;
|
import net.i2p.android.router.dialog.TextResourceDialog;
|
||||||
import net.i2p.android.router.log.LogActivity;
|
import net.i2p.android.router.log.LogActivity;
|
||||||
@ -42,6 +43,17 @@ public class ConsoleContainer extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mConsoleMenu = (FloatingActionsMenu) v.findViewById(R.id.console_action_menu);
|
mConsoleMenu = (FloatingActionsMenu) v.findViewById(R.id.console_action_menu);
|
||||||
|
// update visibility based on router state
|
||||||
|
mConsoleMenu.setOnFloatingActionsMenuUpdateListener(new OnFloatingActionsMenuUpdateListener() {
|
||||||
|
public void onMenuExpanded() {
|
||||||
|
// this is called after the animation starts, sadly
|
||||||
|
setMenuVisibility();
|
||||||
|
}
|
||||||
|
public void onMenuCollapsed() {
|
||||||
|
// call it here too so the expand animation isn't glitchy as often
|
||||||
|
setMenuVisibility();
|
||||||
|
}
|
||||||
|
});
|
||||||
mConsoleMenu.findViewById(R.id.action_news).setOnClickListener(new View.OnClickListener() {
|
mConsoleMenu.findViewById(R.id.action_news).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -63,13 +75,13 @@ public class ConsoleContainer extends Fragment {
|
|||||||
startActivity(graphs);
|
startActivity(graphs);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mConsoleMenu.findViewById(R.id.action_peers).setOnClickListener(new View.OnClickListener() {
|
// mConsoleMenu.findViewById(R.id.action_peers).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
// @Override
|
||||||
public void onClick(View view) {
|
// public void onClick(View view) {
|
||||||
Intent peers = new Intent(getActivity(), PeersActivity.class);
|
// Intent peers = new Intent(getActivity(), PeersActivity.class);
|
||||||
startActivity(peers);
|
// startActivity(peers);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
mConsoleMenu.findViewById(R.id.action_netdb).setOnClickListener(new View.OnClickListener() {
|
mConsoleMenu.findViewById(R.id.action_netdb).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@ -87,11 +99,6 @@ public class ConsoleContainer extends Fragment {
|
|||||||
inflater.inflate(R.menu.activity_main_actions, menu);
|
inflater.inflate(R.menu.activity_main_actions, menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPrepareOptionsMenu(Menu menu) {
|
|
||||||
setMenuVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setMenuVisibility() {
|
private void setMenuVisibility() {
|
||||||
boolean routerRunning = Util.getRouterContext() != null;
|
boolean routerRunning = Util.getRouterContext() != null;
|
||||||
mConsoleMenu.findViewById(R.id.action_logs).setVisibility(routerRunning ? View.VISIBLE : View.GONE);
|
mConsoleMenu.findViewById(R.id.action_logs).setVisibility(routerRunning ? View.VISIBLE : View.GONE);
|
||||||
@ -100,8 +107,8 @@ public class ConsoleContainer extends Fragment {
|
|||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
boolean advanced = PreferenceManager.getDefaultSharedPreferences(getActivity())
|
boolean advanced = PreferenceManager.getDefaultSharedPreferences(getActivity())
|
||||||
.getBoolean("i2pandroid.main.showStats", false);
|
.getBoolean("i2pandroid.main.showStats", false);
|
||||||
mConsoleMenu.findViewById(R.id.action_peers).setVisibility(
|
// mConsoleMenu.findViewById(R.id.action_peers).setVisibility(
|
||||||
advanced && routerRunning ? View.VISIBLE : View.GONE);
|
// advanced && routerRunning ? View.VISIBLE : View.GONE);
|
||||||
mConsoleMenu.findViewById(R.id.action_netdb).setVisibility(
|
mConsoleMenu.findViewById(R.id.action_netdb).setVisibility(
|
||||||
advanced && routerRunning ? View.VISIBLE : View.GONE);
|
advanced && routerRunning ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,22 @@
|
|||||||
package net.i2p.android.router;
|
package net.i2p.android.router;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.PowerManager;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.util.AndroidRuntimeException;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -23,6 +28,7 @@ import android.widget.ScrollView;
|
|||||||
import android.widget.TableLayout;
|
import android.widget.TableLayout;
|
||||||
import android.widget.TableRow;
|
import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
import android.widget.ToggleButton;
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
import net.i2p.android.I2PActivityBase;
|
import net.i2p.android.I2PActivityBase;
|
||||||
@ -69,6 +75,7 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
private TextView vAdvStatusText;
|
private TextView vAdvStatusText;
|
||||||
|
|
||||||
private static final String PREF_CONFIGURE_BROWSER = "app.dialog.configureBrowser";
|
private static final String PREF_CONFIGURE_BROWSER = "app.dialog.configureBrowser";
|
||||||
|
private static final String PREF_CONFIGURE_BATTERY = "app.dialog.configureBattery";
|
||||||
private static final String PREF_FIRST_START = "app.router.firstStart";
|
private static final String PREF_FIRST_START = "app.router.firstStart";
|
||||||
private static final String PREF_SHOW_STATS = "i2pandroid.main.showStats";
|
private static final String PREF_SHOW_STATS = "i2pandroid.main.showStats";
|
||||||
protected static final String PROP_NEW_INSTALL = "i2p.newInstall";
|
protected static final String PROP_NEW_INSTALL = "i2p.newInstall";
|
||||||
@ -320,7 +327,10 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateState(State newState) {
|
/**
|
||||||
|
* Changes the logo based on the state.
|
||||||
|
*/
|
||||||
|
private void updateState(State newState) {
|
||||||
if (newState == State.INIT ||
|
if (newState == State.INIT ||
|
||||||
newState == State.STOPPED ||
|
newState == State.STOPPED ||
|
||||||
newState == State.MANUAL_STOPPED ||
|
newState == State.MANUAL_STOPPED ||
|
||||||
@ -328,13 +338,13 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
newState == State.NETWORK_STOPPED) {
|
newState == State.NETWORK_STOPPED) {
|
||||||
mConsoleLights.setImageResource(R.drawable.routerlogo_0);
|
mConsoleLights.setImageResource(R.drawable.routerlogo_0);
|
||||||
} else if (newState == State.STARTING ||
|
} else if (newState == State.STARTING ||
|
||||||
//newState == State.GRACEFUL_SHUTDOWN || // Don't change lights for graceful
|
|
||||||
newState == State.STOPPING ||
|
newState == State.STOPPING ||
|
||||||
newState == State.MANUAL_STOPPING ||
|
newState == State.MANUAL_STOPPING ||
|
||||||
newState == State.MANUAL_QUITTING ||
|
newState == State.MANUAL_QUITTING ||
|
||||||
newState == State.NETWORK_STOPPING) {
|
newState == State.NETWORK_STOPPING) {
|
||||||
mConsoleLights.setImageResource(R.drawable.routerlogo_1);
|
mConsoleLights.setImageResource(R.drawable.routerlogo_1);
|
||||||
} else if (newState == State.RUNNING) {
|
} else if (newState == State.RUNNING ||
|
||||||
|
newState == State.GRACEFUL_SHUTDOWN) {
|
||||||
mConsoleLights.setImageResource(R.drawable.routerlogo_2);
|
mConsoleLights.setImageResource(R.drawable.routerlogo_2);
|
||||||
} else if (newState == State.ACTIVE) {
|
} else if (newState == State.ACTIVE) {
|
||||||
mConsoleLights.setImageResource(R.drawable.routerlogo_3);
|
mConsoleLights.setImageResource(R.drawable.routerlogo_3);
|
||||||
@ -375,9 +385,9 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
String uptime = DataHelper.formatDuration(ctx.router().getUptime());
|
String uptime = DataHelper.formatDuration(ctx.router().getUptime());
|
||||||
int active = ctx.commSystem().countActivePeers();
|
int active = ctx.commSystem().countActivePeers();
|
||||||
int known = Math.max(ctx.netDb().getKnownRouters() - 1, 0);
|
int known = Math.max(ctx.netDb().getKnownRouters() - 1, 0);
|
||||||
vUptime.setText("" + uptime);
|
vUptime.setText(uptime);
|
||||||
vActive.setText("" + active);
|
vActive.setText(Integer.toString(active));
|
||||||
vKnown.setText("" + known);
|
vKnown.setText(Integer.toString(known));
|
||||||
|
|
||||||
// Load running tunnels
|
// Load running tunnels
|
||||||
loadDestinations(ctx);
|
loadDestinations(ctx);
|
||||||
@ -437,6 +447,7 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
// network but no router context
|
// network but no router context
|
||||||
vStatusContainer.setVisibility(View.GONE);
|
vStatusContainer.setVisibility(View.GONE);
|
||||||
getActivity().findViewById(R.id.console_usage_stats).setVisibility(View.INVISIBLE);
|
getActivity().findViewById(R.id.console_usage_stats).setVisibility(View.INVISIBLE);
|
||||||
|
updateState(State.STOPPED);
|
||||||
/**
|
/**
|
||||||
* **
|
* **
|
||||||
* RouterService svc = _routerService; String status = "connected? "
|
* RouterService svc = _routerService; String status = "connected? "
|
||||||
@ -526,12 +537,12 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
* compare translated nicknames - put "shared clients" first in the sort
|
* compare translated nicknames - put "shared clients" first in the sort
|
||||||
*/
|
*/
|
||||||
private class AlphaComparator implements Comparator<Destination> {
|
private class AlphaComparator implements Comparator<Destination> {
|
||||||
private String xsc;
|
private final String xsc;
|
||||||
private RouterContext _ctx;
|
private final RouterContext _ctx;
|
||||||
|
|
||||||
public AlphaComparator(RouterContext ctx) {
|
public AlphaComparator(RouterContext ctx) {
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
xsc = _(ctx, SHARED_CLIENTS);
|
xsc = _t(ctx, SHARED_CLIENTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(Destination lhs, Destination rhs) {
|
public int compare(Destination lhs, Destination rhs) {
|
||||||
@ -559,12 +570,12 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
if (name == null)
|
if (name == null)
|
||||||
name = d.calculateHash().toBase64().substring(0, 6);
|
name = d.calculateHash().toBase64().substring(0, 6);
|
||||||
else
|
else
|
||||||
name = _(ctx, name);
|
name = _t(ctx, name);
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String _(RouterContext ctx, String s) {
|
private String _t(RouterContext ctx, String s) {
|
||||||
if (SHARED_CLIENTS.equals(s))
|
if (SHARED_CLIENTS.equals(s))
|
||||||
return getString(R.string.shared_clients);
|
return getString(R.string.shared_clients);
|
||||||
else
|
else
|
||||||
@ -578,16 +589,18 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
);
|
);
|
||||||
if (language == null) {
|
if (language == null) {
|
||||||
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
||||||
|
// avoid ISE caused by fragment detachment ticket #2631
|
||||||
|
final String languages[] = getResources().getStringArray(R.array.languages);
|
||||||
b.setTitle(R.string.choose_language)
|
b.setTitle(R.string.choose_language)
|
||||||
.setItems(R.array.language_names, new DialogInterface.OnClickListener() {
|
.setItems(R.array.language_names, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
// Save the language choice
|
// Save the language choice
|
||||||
String language = getResources().getStringArray(R.array.languages)[which];
|
String language = languages[which];
|
||||||
PreferenceManager.getDefaultSharedPreferences(getActivity())
|
PreferenceManager.getDefaultSharedPreferences(getActivity())
|
||||||
.edit()
|
.edit()
|
||||||
.putString(getString(R.string.PREF_LANGUAGE), language)
|
.putString(getString(R.string.PREF_LANGUAGE), language)
|
||||||
.commit();
|
.apply();
|
||||||
// Close the dialog
|
// Close the dialog
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
// Broadcast the change to RouterService just in case the router is running
|
// Broadcast the change to RouterService just in case the router is running
|
||||||
@ -614,16 +627,62 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
ab.setPref(PREF_CONFIGURE_BROWSER, false);
|
ab.setPref(PREF_CONFIGURE_BROWSER, false);
|
||||||
Intent hi = new Intent(getActivity(), BrowserConfigActivity.class);
|
Intent hi = new Intent(getActivity(), BrowserConfigActivity.class);
|
||||||
startActivity(hi);
|
startActivity(hi);
|
||||||
|
checkDialog();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int i) {
|
public void onClick(DialogInterface dialog, int i) {
|
||||||
dialog.cancel();
|
dialog.dismiss();
|
||||||
ab.setPref(PREF_CONFIGURE_BROWSER, false);
|
ab.setPref(PREF_CONFIGURE_BROWSER, false);
|
||||||
|
checkDialog();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
|
} else if (ab.getPref(PREF_CONFIGURE_BATTERY, true)) {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||||
|
// only for Marshmallow and newer versions
|
||||||
|
final Intent intent = new Intent();
|
||||||
|
final Context mContext = ab.getApplicationContext();
|
||||||
|
String packageName = mContext.getPackageName();
|
||||||
|
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||||
|
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
|
||||||
|
AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
|
||||||
|
b.setTitle(R.string.configure_no_doze_title);
|
||||||
|
b.setMessage(R.string.configure_no_doze);
|
||||||
|
b.setCancelable(false);
|
||||||
|
b.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int i) {
|
||||||
|
String packageName = mContext.getPackageName();
|
||||||
|
ab.setPref(PREF_CONFIGURE_BATTERY, false);
|
||||||
|
dialog.dismiss();
|
||||||
|
// Simply do not re-attempt a battery optimization after the first time,
|
||||||
|
// even if an error occurs. http://trac.i2p2.i2p/ticket/2783
|
||||||
|
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||||
|
intent.setData(Uri.parse("package:" + packageName));
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
try {
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
} catch (ActivityNotFoundException activityNotFound) {
|
||||||
|
ab.setPref(PREF_CONFIGURE_BATTERY, false);
|
||||||
|
} catch (AndroidRuntimeException activityNotFound) {
|
||||||
|
ab.setPref(PREF_CONFIGURE_BATTERY, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
b.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int i) {
|
||||||
|
dialog.cancel();
|
||||||
|
ab.setPref(PREF_CONFIGURE_BATTERY, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
b.show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ab.setPref(PREF_CONFIGURE_BATTERY, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*VersionDialog dialog = new VersionDialog();
|
/*VersionDialog dialog = new VersionDialog();
|
||||||
String oldVersion = ((I2PActivityBase) getActivity()).getPref(PREF_INSTALLED_VERSION, "??");
|
String oldVersion = ((I2PActivityBase) getActivity()).getPref(PREF_INSTALLED_VERSION, "??");
|
||||||
@ -648,9 +707,11 @@ public class MainFragment extends I2PFragmentBase {
|
|||||||
private void checkFirstStart() {
|
private void checkFirstStart() {
|
||||||
I2PActivityBase ab = (I2PActivityBase) getActivity();
|
I2PActivityBase ab = (I2PActivityBase) getActivity();
|
||||||
boolean firstStart = ab.getPref(PREF_FIRST_START, true);
|
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();
|
FirstStartDialog dialog = new FirstStartDialog();
|
||||||
dialog.show(getActivity().getSupportFragmentManager(), "firststart");
|
dialog.show(ab.getSupportFragmentManager(), "firststart");
|
||||||
ab.setPref(PREF_FIRST_START, false);
|
ab.setPref(PREF_FIRST_START, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import net.i2p.android.apps.NewsFetcher;
|
import net.i2p.android.apps.NewsFetcher;
|
||||||
import net.i2p.android.router.util.Util;
|
import net.i2p.android.router.util.Util;
|
||||||
|
import net.i2p.router.RouterContext;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -33,12 +34,16 @@ public class NewsFragment extends I2PFragmentBase {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
NewsFetcher nf = NewsFetcher.getInstance();
|
RouterContext ctx = getRouterContext();
|
||||||
if (nf != null) {
|
if (ctx != null) {
|
||||||
// Always update the status
|
NewsFetcher nf = (NewsFetcher) ctx.clientAppManager().getRegisteredApp(NewsFetcher.APP_NAME);
|
||||||
TextView tv = (TextView) getActivity().findViewById(R.id.news_status);
|
if (nf != null) {
|
||||||
tv.setText(nf.status().replace(" ", " "));
|
// Always update the status
|
||||||
tv.setVisibility(View.VISIBLE);
|
// This is the news last updated/checked text at the bottom
|
||||||
|
TextView tv = (TextView) getActivity().findViewById(R.id.news_status);
|
||||||
|
tv.setText(nf.status().replace(" ", " "));
|
||||||
|
tv.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only update the content if we need to
|
// Only update the content if we need to
|
||||||
|
@ -2,6 +2,7 @@ package net.i2p.android.router.addressbook;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -20,26 +21,51 @@ public class AddressbookAddWizardActivity extends AbstractWizardActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DialogFragment onGetFinishWizardDialog() {
|
protected DialogFragment onGetFinishWizardDialog() {
|
||||||
return new DialogFragment() {
|
return FinishWizardDialogFragment.newInstance();
|
||||||
@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) {
|
public void onFinishWizard() {
|
||||||
Intent result = new Intent();
|
Intent result = new Intent();
|
||||||
setResult(Activity.RESULT_OK, result);
|
result.putExtra(AddressbookContainer.ADD_WIZARD_DATA, mWizardModel.save());
|
||||||
result.putExtra(AddressbookContainer.ADD_WIZARD_DATA, mWizardModel.save());
|
setResult(Activity.RESULT_OK, result);
|
||||||
dialog.dismiss();
|
finish();
|
||||||
finish();
|
}
|
||||||
}
|
|
||||||
})
|
public static class FinishWizardDialogFragment extends DialogFragment {
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
AddressbookAddWizardActivity mListener;
|
||||||
.create();
|
|
||||||
|
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.eowise.recyclerview.stickyheaders.StickyHeadersItemDecoration;
|
||||||
import com.pnikosis.materialishprogress.ProgressWheel;
|
import com.pnikosis.materialishprogress.ProgressWheel;
|
||||||
|
|
||||||
import net.i2p.addressbook.Daemon;
|
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
import net.i2p.android.router.service.RouterService;
|
import net.i2p.android.router.service.RouterService;
|
||||||
import net.i2p.android.router.service.State;
|
import net.i2p.android.router.service.State;
|
||||||
@ -167,15 +166,23 @@ public class AddressbookFragment extends Fragment implements
|
|||||||
int loaderId = PRIVATE_BOOK.equals(mBook) ?
|
int loaderId = PRIVATE_BOOK.equals(mBook) ?
|
||||||
PRIVATE_LOADER_ID : ROUTER_LOADER_ID;
|
PRIVATE_LOADER_ID : ROUTER_LOADER_ID;
|
||||||
|
|
||||||
if (state == State.STOPPING || state == State.STOPPED ||
|
try {
|
||||||
state == State.MANUAL_STOPPING ||
|
LoaderManager manager = getLoaderManager();
|
||||||
state == State.MANUAL_STOPPED ||
|
if (state == State.INIT ||
|
||||||
state == State.MANUAL_QUITTING ||
|
state == State.STARTING || // Wait until RouterContext is initialised
|
||||||
state == State.MANUAL_QUITTED)
|
state == State.STOPPING ||
|
||||||
getLoaderManager().destroyLoader(loaderId);
|
state == State.STOPPED ||
|
||||||
else {
|
state == State.MANUAL_STOPPING ||
|
||||||
mRecyclerView.setLoading(true);
|
state == State.MANUAL_STOPPED ||
|
||||||
getLoaderManager().initLoader(loaderId, null, this);
|
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);
|
mAddToAddressbook.setVisibility(rCtx == null ? View.GONE : View.VISIBLE);
|
||||||
|
|
||||||
// Only show "Reload subscriptions" for router addressbook
|
// Only show "Reload subscriptions" for router addressbook
|
||||||
menu.findItem(R.id.action_reload_subscriptions).setVisible(
|
MenuItem reloadSubs = menu.findItem(R.id.action_reload_subscriptions);
|
||||||
rCtx != null && !PRIVATE_BOOK.equals(mBook));
|
if (reloadSubs != null) {
|
||||||
|
reloadSubs.setVisible(
|
||||||
|
rCtx != null && !PRIVATE_BOOK.equals(mBook));
|
||||||
|
}
|
||||||
|
|
||||||
// Only allow adding to private book
|
// Only allow adding to private book
|
||||||
if (!PRIVATE_BOOK.equals(mBook) && mAddToAddressbook != null) {
|
if (!PRIVATE_BOOK.equals(mBook) && mAddToAddressbook != null) {
|
||||||
@ -223,9 +233,12 @@ public class AddressbookFragment extends Fragment implements
|
|||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_reload_subscriptions:
|
case R.id.action_reload_subscriptions:
|
||||||
Daemon.wakeup();
|
RouterContext rCtx = Util.getRouterContext();
|
||||||
Toast.makeText(getActivity(), "Reloading subscriptions...",
|
if (rCtx != null) {
|
||||||
Toast.LENGTH_SHORT).show();
|
rCtx.namingService().requestUpdate(null);
|
||||||
|
Toast.makeText(getActivity(), "Reloading subscriptions...",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
@ -61,7 +61,7 @@ public class AddressbookSettingsActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private boolean load() {
|
private boolean load() {
|
||||||
String res = FileUtil.readTextFile(i2pDir.getAbsolutePath(), -1, true);
|
String res = FileUtil.readTextFile(i2pDir.getAbsolutePath(), -1, true);
|
||||||
if (res.length() > 0) {
|
if (res != null && res.length() > 0) {
|
||||||
text_content_subscriptions.setText(res);
|
text_content_subscriptions.setText(res);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,8 @@ public class NetDbDetailFragment extends I2PFragmentBase {
|
|||||||
String val = (String)e.getValue();
|
String val = (String)e.getValue();
|
||||||
addTableRow(table, DataHelper.stripHTML(key), DataHelper.stripHTML(val));
|
addTableRow(table, DataHelper.stripHTML(key), DataHelper.stripHTML(val));
|
||||||
}
|
}
|
||||||
|
// spacer
|
||||||
|
addTableRow(table, "", "");
|
||||||
|
|
||||||
addresses.addView(table);
|
addresses.addView(table);
|
||||||
}
|
}
|
||||||
@ -230,9 +232,11 @@ public class NetDbDetailFragment extends I2PFragmentBase {
|
|||||||
TextView tl1, tl2;
|
TextView tl1, tl2;
|
||||||
|
|
||||||
row = new TableRow(getActivity());
|
row = new TableRow(getActivity());
|
||||||
|
// left top right bottom
|
||||||
row.setPadding(10, 0, 0, 0);
|
row.setPadding(10, 0, 0, 0);
|
||||||
|
|
||||||
tl1 = new TextView(getActivity());
|
tl1 = new TextView(getActivity());
|
||||||
|
tl1.setPadding(0, 0, 20, 0);
|
||||||
tl2 = new TextView(getActivity());
|
tl2 = new TextView(getActivity());
|
||||||
|
|
||||||
tl1.setText(key);
|
tl1.setText(key);
|
||||||
|
@ -5,6 +5,7 @@ import android.support.v4.content.AsyncTaskLoader;
|
|||||||
|
|
||||||
import net.i2p.android.router.util.Util;
|
import net.i2p.android.router.util.Util;
|
||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.data.LeaseSet;
|
import net.i2p.data.LeaseSet;
|
||||||
import net.i2p.data.router.RouterInfo;
|
import net.i2p.data.router.RouterInfo;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
@ -24,14 +25,27 @@ public class NetDbEntryLoader extends AsyncTaskLoader<List<NetDbEntry>> {
|
|||||||
mRouters = routers;
|
mRouters = routers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** put us on top */
|
||||||
private static class RouterInfoComparator implements Comparator<RouterInfo> {
|
private static class RouterInfoComparator implements Comparator<RouterInfo> {
|
||||||
|
private final Hash _us;
|
||||||
|
|
||||||
|
public RouterInfoComparator(Hash us) {
|
||||||
|
_us = us;
|
||||||
|
}
|
||||||
|
|
||||||
public int compare(RouterInfo l, RouterInfo r) {
|
public int compare(RouterInfo l, RouterInfo r) {
|
||||||
return l.getIdentity().getHash().toBase64().compareTo(r.getIdentity().getHash().toBase64());
|
Hash lh = l.getIdentity().getHash();
|
||||||
|
Hash rh = r.getIdentity().getHash();
|
||||||
|
if (lh.equals(_us))
|
||||||
|
return -1;
|
||||||
|
if (rh.equals(_us))
|
||||||
|
return 1;
|
||||||
|
return lh.toBase64().compareTo(rh.toBase64());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LeaseSetComparator implements Comparator<LeaseSet> {
|
private class LeaseSetComparator implements Comparator<LeaseSet> {
|
||||||
private RouterContext mRContext;
|
private final RouterContext mRContext;
|
||||||
|
|
||||||
public LeaseSetComparator(RouterContext rContext) {
|
public LeaseSetComparator(RouterContext rContext) {
|
||||||
super();
|
super();
|
||||||
@ -53,9 +67,9 @@ public class NetDbEntryLoader extends AsyncTaskLoader<List<NetDbEntry>> {
|
|||||||
public List<NetDbEntry> loadInBackground() {
|
public List<NetDbEntry> loadInBackground() {
|
||||||
List<NetDbEntry> ret = new ArrayList<>();
|
List<NetDbEntry> ret = new ArrayList<>();
|
||||||
RouterContext routerContext = Util.getRouterContext();
|
RouterContext routerContext = Util.getRouterContext();
|
||||||
if (routerContext != null && routerContext.netDb().isInitialized()) {
|
if (routerContext != null && routerContext.netDb().isInitialized() && routerContext.routerHash() != null) {
|
||||||
if (mRouters) {
|
if (mRouters) {
|
||||||
Set<RouterInfo> routers = new TreeSet<>(new RouterInfoComparator());
|
Set<RouterInfo> routers = new TreeSet<>(new RouterInfoComparator(routerContext.routerHash()));
|
||||||
routers.addAll(routerContext.netDb().getRouters());
|
routers.addAll(routerContext.netDb().getRouters());
|
||||||
for (RouterInfo ri : routers) {
|
for (RouterInfo ri : routers) {
|
||||||
NetDbEntry entry = NetDbEntry.fromRouterInfo(routerContext, ri);
|
NetDbEntry entry = NetDbEntry.fromRouterInfo(routerContext, ri);
|
||||||
|
@ -17,7 +17,7 @@ import java.util.Set;
|
|||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
public class NetDbStatsLoader extends AsyncTaskLoader<List<ObjectCounter<String>>> {
|
public class NetDbStatsLoader extends AsyncTaskLoader<List<ObjectCounter<String>>> {
|
||||||
private RouterContext mRContext;
|
private final RouterContext mRContext;
|
||||||
private List<ObjectCounter<String>> mData;
|
private List<ObjectCounter<String>> mData;
|
||||||
|
|
||||||
public NetDbStatsLoader(Context context, RouterContext rContext) {
|
public NetDbStatsLoader(Context context, RouterContext rContext) {
|
||||||
@ -95,7 +95,7 @@ public class NetDbStatsLoader extends AsyncTaskLoader<List<ObjectCounter<String>
|
|||||||
int rv = 0;
|
int rv = 0;
|
||||||
for (RouterAddress addr : info.getAddresses()) {
|
for (RouterAddress addr : info.getAddresses()) {
|
||||||
String style = addr.getTransportStyle();
|
String style = addr.getTransportStyle();
|
||||||
if (style.equals("NTCP")) {
|
if (style.equals("NTCP") || style.equals("NTCP2")) {
|
||||||
rv |= NTCP;
|
rv |= NTCP;
|
||||||
} else if (style.equals("SSU")) {
|
} else if (style.equals("SSU")) {
|
||||||
if (addr.getOption("iport0") != null)
|
if (addr.getOption("iport0") != null)
|
||||||
@ -108,7 +108,12 @@ public class NetDbStatsLoader extends AsyncTaskLoader<List<ObjectCounter<String>
|
|||||||
rv |= IPV6;
|
rv |= IPV6;
|
||||||
|
|
||||||
}
|
}
|
||||||
return getContext().getString(TNAMES[rv]);
|
int tname = TNAMES[rv];
|
||||||
|
// remap cases with no string to "Hidden or starting up"
|
||||||
|
// so we don't crash NotFoundException
|
||||||
|
if (tname == 0)
|
||||||
|
tname = TNAMES[0];
|
||||||
|
return getContext().getString(tname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,6 +77,7 @@ public class NetDbSummaryTableFragment extends Fragment {
|
|||||||
titleRow.setPadding(10, 0, 0, 0);
|
titleRow.setPadding(10, 0, 0, 0);
|
||||||
|
|
||||||
tl1 = new TextView(getActivity());
|
tl1 = new TextView(getActivity());
|
||||||
|
tl1.setPadding(0, 0, 20, 0);
|
||||||
tl1.setTextSize(20);
|
tl1.setTextSize(20);
|
||||||
tl2 = new TextView(getActivity());
|
tl2 = new TextView(getActivity());
|
||||||
tl2.setTextSize(20);
|
tl2.setTextSize(20);
|
||||||
@ -108,6 +109,7 @@ public class NetDbSummaryTableFragment extends Fragment {
|
|||||||
row.setPadding(10, 0, 0, 0);
|
row.setPadding(10, 0, 0, 0);
|
||||||
|
|
||||||
tl1 = new TextView(getActivity());
|
tl1 = new TextView(getActivity());
|
||||||
|
tl1.setPadding(0, 0, 20, 0);
|
||||||
tl2 = new TextView(getActivity());
|
tl2 = new TextView(getActivity());
|
||||||
|
|
||||||
tl1.setText(name);
|
tl1.setText(name);
|
||||||
|
@ -2,6 +2,7 @@ package net.i2p.android.router.provider;
|
|||||||
|
|
||||||
import android.content.ContentProvider;
|
import android.content.ContentProvider;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -18,6 +19,7 @@ import java.io.IOException;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,7 +155,7 @@ public class CacheProvider extends ContentProvider {
|
|||||||
// first seg is empty since string starts with /
|
// first seg is empty since string starts with /
|
||||||
String nonce = segs.length > 1 ? segs[1] : null;
|
String nonce = segs.length > 1 ? segs[1] : null;
|
||||||
String scheme = segs.length > 2 ? segs[2] : null;
|
String scheme = segs.length > 2 ? segs[2] : null;
|
||||||
String host = segs.length > 3 ? segs[3].toLowerCase() : null;
|
String host = segs.length > 3 ? segs[3].toLowerCase(Locale.US) : null;
|
||||||
String realPath = segs.length > 4 ? segs[4] : "";
|
String realPath = segs.length > 4 ? segs[4] : "";
|
||||||
String query = uri.getEncodedQuery();
|
String query = uri.getEncodedQuery();
|
||||||
if (query == null) {
|
if (query == null) {
|
||||||
@ -230,10 +232,11 @@ public class CacheProvider extends ContentProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ParcelFileDescriptor eepFetch(Uri uri) throws FileNotFoundException {
|
private ParcelFileDescriptor eepFetch(Uri uri) throws FileNotFoundException {
|
||||||
AppCache cache = AppCache.getInstance(getContext());
|
Context ctx = getContext();
|
||||||
|
AppCache cache = AppCache.getInstance(ctx);
|
||||||
OutputStream out;
|
OutputStream out;
|
||||||
try {
|
try {
|
||||||
out = cache.createCacheFile(uri);
|
out = cache.createCacheFile(ctx, uri);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new FileNotFoundException(ioe.toString());
|
throw new FileNotFoundException(ioe.toString());
|
||||||
}
|
}
|
||||||
@ -244,7 +247,7 @@ public class CacheProvider extends ContentProvider {
|
|||||||
File file = cache.getCacheFile(uri);
|
File file = cache.getCacheFile(uri);
|
||||||
if (file.length() > 0) {
|
if (file.length() > 0) {
|
||||||
// this call will insert it back to us (don't set as current base)
|
// this call will insert it back to us (don't set as current base)
|
||||||
Uri content = cache.addCacheFile(uri, false);
|
Uri content = cache.addCacheFile(ctx, uri, false);
|
||||||
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
|
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
|
||||||
} else {
|
} else {
|
||||||
Util.d("CacheProvider Sucess but no data " + uri);
|
Util.d("CacheProvider Sucess but no data " + uri);
|
||||||
@ -252,7 +255,7 @@ public class CacheProvider extends ContentProvider {
|
|||||||
} else {
|
} else {
|
||||||
Util.d("CacheProvider Eepget fail " + uri);
|
Util.d("CacheProvider Eepget fail " + uri);
|
||||||
}
|
}
|
||||||
AppCache.getInstance().removeCacheFile(uri);
|
cache.removeCacheFile(ctx, uri);
|
||||||
throw new FileNotFoundException("eepget fail");
|
throw new FileNotFoundException("eepget fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +322,7 @@ public class CacheProvider extends ContentProvider {
|
|||||||
for (String key : toDelete) {
|
for (String key : toDelete) {
|
||||||
edit.remove(key);
|
edit.remove(key);
|
||||||
}
|
}
|
||||||
edit.commit();
|
edit.apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,11 +358,10 @@ public class CacheProvider extends ContentProvider {
|
|||||||
return _sharedPrefs.getString(pref, null);
|
return _sharedPrefs.getString(pref, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return success */
|
private void setPref(String pref, String val) {
|
||||||
private boolean setPref(String pref, String val) {
|
|
||||||
SharedPreferences.Editor edit = _sharedPrefs.edit();
|
SharedPreferences.Editor edit = _sharedPrefs.edit();
|
||||||
edit.putString(pref, val);
|
edit.putString(pref, val);
|
||||||
return edit.commit();
|
edit.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return success */
|
/** @return success */
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import net.i2p.android.router.util.Util;
|
||||||
|
|
||||||
import net.i2p.android.router.I2PConstants;
|
import net.i2p.android.router.I2PConstants;
|
||||||
import net.i2p.android.router.service.RouterService;
|
import net.i2p.android.router.service.RouterService;
|
||||||
@ -14,12 +15,26 @@ public class OnBootReceiver extends BroadcastReceiver implements I2PConstants {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||||
|
Util.e("spoofed BOOT_COMPLETED");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean startOnBoot = prefs.getBoolean(PREF_START_ON_BOOT, false);
|
boolean startOnBoot = prefs.getBoolean(PREF_START_ON_BOOT, false);
|
||||||
|
|
||||||
if (startOnBoot) {
|
if (startOnBoot) {
|
||||||
Intent routerService = new Intent(context, RouterService.class);
|
Intent routerService = new Intent(context, RouterService.class);
|
||||||
context.startService(routerService);
|
// Ticket #2404
|
||||||
|
try {
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O){
|
||||||
|
context.startForegroundService(routerService);
|
||||||
|
} else {
|
||||||
|
context.startService(routerService);
|
||||||
|
}
|
||||||
|
} catch (IllegalStateException ex) {
|
||||||
|
Util.e("Error: ", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@ package net.i2p.android.router.service;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import net.i2p.BOB.BOB;
|
//import net.i2p.BOB.BOB;
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.addressbook.DaemonThread;
|
import net.i2p.addressbook.DaemonThread;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import net.i2p.android.apps.NewsFetcher;
|
import net.i2p.android.apps.NewsFetcher;
|
||||||
import net.i2p.android.router.util.Notifications;
|
import net.i2p.android.router.util.Notifications;
|
||||||
import net.i2p.android.router.util.Util;
|
import net.i2p.android.router.util.Util;
|
||||||
@ -12,9 +13,13 @@ import net.i2p.i2ptunnel.TunnelControllerGroup;
|
|||||||
import net.i2p.router.Job;
|
import net.i2p.router.Job;
|
||||||
import net.i2p.router.JobImpl;
|
import net.i2p.router.JobImpl;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
|
import net.i2p.router.startup.RouterAppManager;
|
||||||
import net.i2p.util.I2PAppThread;
|
import net.i2p.util.I2PAppThread;
|
||||||
|
import net.i2p.sam.SAMBridge;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the clients we want.
|
* Load the clients we want.
|
||||||
@ -37,13 +42,14 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
class LoadClientsJob extends JobImpl {
|
class LoadClientsJob extends JobImpl {
|
||||||
|
|
||||||
private Context mCtx;
|
private final Context mCtx;
|
||||||
private Notifications _notif;
|
private final Notifications _notif;
|
||||||
private DaemonThread _addressbook;
|
private DaemonThread _addressbook;
|
||||||
private BOB _bob;
|
public SAMBridge SAM_BRIDGE;
|
||||||
|
//private BOB _bob;
|
||||||
|
|
||||||
/** this is the delay to load (and start) the clients. */
|
/** this is the delay to load (and start) the clients. */
|
||||||
private static final long LOAD_DELAY = 90*1000;
|
private static final long LOAD_DELAY = 60*1000;
|
||||||
|
|
||||||
|
|
||||||
public LoadClientsJob(Context ctx, RouterContext rCtx, Notifications notif) {
|
public LoadClientsJob(Context ctx, RouterContext rCtx, Notifications notif) {
|
||||||
@ -56,28 +62,28 @@ class LoadClientsJob extends JobImpl {
|
|||||||
public String getName() { return "Start Clients"; }
|
public String getName() { return "Start Clients"; }
|
||||||
|
|
||||||
public void runJob() {
|
public void runJob() {
|
||||||
Job j = new RunI2PTunnel(getContext());
|
Job jtunnel = new RunI2PTunnel(getContext());
|
||||||
getContext().jobQueue().addJob(j);
|
getContext().jobQueue().addJob(jtunnel);
|
||||||
|
|
||||||
|
|
||||||
Thread t = new I2PAppThread(new StatSummarizer(), "StatSummarizer", true);
|
Thread t = new I2PAppThread(new StatSummarizer(), "StatSummarizer", true);
|
||||||
t.setPriority(Thread.NORM_PRIORITY - 1);
|
t.setPriority(Thread.NORM_PRIORITY - 1);
|
||||||
t.start();
|
t.start();
|
||||||
|
|
||||||
NewsFetcher fetcher = NewsFetcher.getInstance(mCtx, getContext(), _notif);
|
|
||||||
t = new I2PAppThread(fetcher, "NewsFetcher", true);
|
|
||||||
t.start();
|
|
||||||
|
|
||||||
_addressbook = new DaemonThread(new String[] {"addressbook"});
|
|
||||||
_addressbook.setName("Addressbook");
|
|
||||||
_addressbook.setDaemon(true);
|
|
||||||
_addressbook.start();
|
|
||||||
|
|
||||||
// add other clients here
|
// add other clients here
|
||||||
_bob = new BOB(I2PAppContext.getGlobalContext(), null, new String[0]);
|
//_bob = new BOB(I2PAppContext.getGlobalContext(), null, new String[0]);
|
||||||
try {
|
//try {
|
||||||
_bob.startup();
|
// _bob.startup();
|
||||||
} catch (IOException ioe) {}
|
//} catch (IOException ioe) {}
|
||||||
|
boolean useSAM = PreferenceManager.getDefaultSharedPreferences(mCtx).getBoolean("i2pandroid.client.SAM", true);
|
||||||
|
Util.i("SAM API " + useSAM);
|
||||||
|
if (useSAM) {
|
||||||
|
Job jsam = new RunI2PSAM(getContext());
|
||||||
|
getContext().jobQueue().addJob(jsam);
|
||||||
|
Util.i("SAM API started successfully" + useSAM);
|
||||||
|
}else{
|
||||||
|
Util.i("SAM API disabled, not starting "+useSAM);
|
||||||
|
}
|
||||||
getContext().addShutdownTask(new ClientShutdownHook());
|
getContext().addShutdownTask(new ClientShutdownHook());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,12 +96,30 @@ class LoadClientsJob extends JobImpl {
|
|||||||
public String getName() { return "Start I2P Tunnel"; }
|
public String getName() { return "Start I2P Tunnel"; }
|
||||||
|
|
||||||
public void runJob() {
|
public void runJob() {
|
||||||
|
if (!getContext().router().isRunning()) {
|
||||||
|
if (getContext().router().isAlive()) {
|
||||||
|
requeue(1000);
|
||||||
|
} else {
|
||||||
|
Util.e("Router stopped before i2ptunnel could start");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
Util.d("Starting i2ptunnel");
|
Util.d("Starting i2ptunnel");
|
||||||
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance();
|
TunnelControllerGroup tcg = TunnelControllerGroup.getInstance(getContext());
|
||||||
try {
|
try {
|
||||||
tcg.startup();
|
tcg.startup();
|
||||||
int sz = tcg.getControllers().size();
|
int sz = tcg.getControllers().size();
|
||||||
Util.d("i2ptunnel started " + sz + " clients");
|
Util.d("i2ptunnel started " + sz + " clients");
|
||||||
|
|
||||||
|
// no use starting these until i2ptunnel starts
|
||||||
|
RouterContext ctx = getContext();
|
||||||
|
NewsFetcher fetcher = NewsFetcher.getInstance(mCtx, getContext(), _notif);
|
||||||
|
ctx.routerAppManager().addAndStart(fetcher, new String[0]);
|
||||||
|
|
||||||
|
_addressbook = new DaemonThread(new String[] {"addressbook"});
|
||||||
|
_addressbook.setName("Addressbook");
|
||||||
|
_addressbook.setDaemon(true);
|
||||||
|
_addressbook.start();
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
Util.e("i2ptunnel failed to start", iae);
|
Util.e("i2ptunnel failed to start", iae);
|
||||||
}
|
}
|
||||||
@ -103,14 +127,56 @@ class LoadClientsJob extends JobImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RunI2PSAM extends JobImpl {
|
||||||
|
|
||||||
|
public RunI2PSAM(RouterContext ctx) {
|
||||||
|
super(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() { return "Start SAM API"; }
|
||||||
|
|
||||||
|
public void runJob() {
|
||||||
|
if (!getContext().router().isRunning()) {
|
||||||
|
if (getContext().router().isAlive()) {
|
||||||
|
requeue(1000);
|
||||||
|
} else {
|
||||||
|
Util.e("Router stopped before SAM API could start");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Util.d("Starting SAM");
|
||||||
|
try {
|
||||||
|
Util.i("Starting the SAM API");
|
||||||
|
SAM_BRIDGE = new SAMBridge("127.0.0.1",
|
||||||
|
7656,
|
||||||
|
false,
|
||||||
|
SAM_PROPERTIES(),
|
||||||
|
"sam.keys",
|
||||||
|
new File("sam_config"));
|
||||||
|
SAM_BRIDGE.run();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Util.e( e.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties SAM_PROPERTIES() throws IOException {
|
||||||
|
Util.i("Getting the default properties");
|
||||||
|
Properties sam_properties = new Properties();
|
||||||
|
return sam_properties;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class ClientShutdownHook implements Runnable {
|
private class ClientShutdownHook implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
Util.d("client shutdown hook");
|
Util.d("client shutdown hook");
|
||||||
// i2ptunnel registers its own hook
|
// i2ptunnel registers its own hook
|
||||||
// StatSummarizer registers its own hook
|
// StatSummarizer registers its own hook
|
||||||
// NewsFetcher registers its own hook
|
// NewsFetcher registers its own hook
|
||||||
if (_bob != null)
|
//if (_bob != null)
|
||||||
_bob.shutdown(null);
|
// _bob.shutdown(null);
|
||||||
|
if (SAM_BRIDGE != null)
|
||||||
|
SAM_BRIDGE.shutdown(null);
|
||||||
if (_addressbook != null)
|
if (_addressbook != null)
|
||||||
_addressbook.halt();
|
_addressbook.halt();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
@ -23,7 +24,6 @@ import net.i2p.data.DataHelper;
|
|||||||
import net.i2p.router.Job;
|
import net.i2p.router.Job;
|
||||||
import net.i2p.router.Router;
|
import net.i2p.router.Router;
|
||||||
import net.i2p.router.RouterContext;
|
import net.i2p.router.RouterContext;
|
||||||
import net.i2p.router.RouterLaunch;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class RouterService extends Service {
|
|||||||
if(lastState == State.RUNNING || lastState == State.ACTIVE) {
|
if(lastState == State.RUNNING || lastState == State.ACTIVE) {
|
||||||
Intent intent = new Intent(this, RouterService.class);
|
Intent intent = new Intent(this, RouterService.class);
|
||||||
intent.putExtra(EXTRA_RESTART, true);
|
intent.putExtra(EXTRA_RESTART, true);
|
||||||
onStartCommand(intent, 12345, 67890);
|
onStartCommand(intent, START_FLAG_REDELIVERY | START_FLAG_RETRY, 67890);
|
||||||
} else if(lastState == State.MANUAL_QUITTING || lastState == State.GRACEFUL_SHUTDOWN) {
|
} else if(lastState == State.MANUAL_QUITTING || lastState == State.GRACEFUL_SHUTDOWN) {
|
||||||
synchronized(_stateLock) {
|
synchronized(_stateLock) {
|
||||||
setState(State.MANUAL_QUITTED);
|
setState(State.MANUAL_QUITTED);
|
||||||
@ -169,10 +169,18 @@ public class RouterService extends Service {
|
|||||||
}
|
}
|
||||||
_handler.removeCallbacks(_updater);
|
_handler.removeCallbacks(_updater);
|
||||||
_handler.postDelayed(_updater, 50);
|
_handler.postDelayed(_updater, 50);
|
||||||
|
|
||||||
|
// We need to *not* check if we're restarting on Android greater than Oreo due to
|
||||||
|
// changes in how notifications work and the use of NotificationChannels.
|
||||||
if(!restart) {
|
if(!restart) {
|
||||||
startForeground(1337, _statusBar.getNote());
|
startForeground(1337, _statusBar.getNote());
|
||||||
|
} else {
|
||||||
|
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||||
|
startForeground(1337, _statusBar.getNote());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//return START_STICKY;
|
//return START_STICKY;
|
||||||
return START_NOT_STICKY;
|
return START_NOT_STICKY;
|
||||||
}
|
}
|
||||||
@ -213,16 +221,19 @@ public class RouterService extends Service {
|
|||||||
//Util.d(MARKER + this + " JBigI speed test finished, launching router");
|
//Util.d(MARKER + this + " JBigI speed test finished, launching router");
|
||||||
|
|
||||||
// Launch the router!
|
// Launch the router!
|
||||||
RouterLaunch.main(null);
|
// TODO Store this somewhere instead of relying on global context?
|
||||||
|
Router r = new Router();
|
||||||
|
r.setUPnPScannerCallback(new SSDPLocker(RouterService.this));
|
||||||
|
r.runRouter();
|
||||||
synchronized(_stateLock) {
|
synchronized(_stateLock) {
|
||||||
if(_state != State.STARTING) {
|
if(_state != State.STARTING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(State.RUNNING);
|
setState(State.RUNNING);
|
||||||
_statusBar.replace(StatusBar.ICON_RUNNING, R.string.notification_status_running);
|
_statusBar.replace(StatusBar.ICON_RUNNING, R.string.notification_status_running);
|
||||||
_context = Util.getRouterContext();
|
_context = r.getContext();
|
||||||
if (_context == null) {
|
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);
|
_context.router().setKillVMOnEnd(false);
|
||||||
Job loadJob = new LoadClientsJob(RouterService.this, _context, _notif);
|
Job loadJob = new LoadClientsJob(RouterService.this, _context, _notif);
|
||||||
@ -793,12 +804,12 @@ public class RouterService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return success
|
* Saves state in background thread
|
||||||
*/
|
*/
|
||||||
private boolean saveState() {
|
private void saveState() {
|
||||||
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS, 0);
|
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS, 0);
|
||||||
SharedPreferences.Editor edit = prefs.edit();
|
SharedPreferences.Editor edit = prefs.edit();
|
||||||
edit.putString(LAST_STATE, _state.toString());
|
edit.putString(LAST_STATE, _state.toString());
|
||||||
return edit.commit();
|
edit.apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package net.i2p.android.router.service;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.net.wifi.WifiManager.MulticastLock;
|
||||||
|
|
||||||
|
import net.i2p.router.transport.UPnPScannerCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To lock/unlock UPnP, so it works on some phones.
|
||||||
|
* Many many phones don't require this, but do be safe...
|
||||||
|
*
|
||||||
|
* @since 0.9.41
|
||||||
|
*/
|
||||||
|
public class SSDPLocker implements UPnPScannerCallback {
|
||||||
|
|
||||||
|
private final MulticastLock lock;
|
||||||
|
|
||||||
|
public SSDPLocker(Context context) {
|
||||||
|
WifiManager wifi = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||||
|
lock = wifi.createMulticastLock("ssdp");
|
||||||
|
lock.setReferenceCounted(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void beforeScan() {
|
||||||
|
lock.acquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void afterScan() {
|
||||||
|
if (lock.isHeld())
|
||||||
|
lock.release();
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,15 @@
|
|||||||
package net.i2p.android.router.service;
|
package net.i2p.android.router.service;
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.i2p.android.I2PActivity;
|
import net.i2p.android.I2PActivity;
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
@ -16,6 +20,9 @@ class StatusBar {
|
|||||||
private final NotificationManager mNotificationManager;
|
private final NotificationManager mNotificationManager;
|
||||||
private final NotificationCompat.Builder mNotifyBuilder;
|
private final NotificationCompat.Builder mNotifyBuilder;
|
||||||
private Notification mNotif;
|
private Notification mNotif;
|
||||||
|
private final String NOTIFICATION_CHANNEL_ID = "net.i2p.android.STARTUP_STATE_CHANNEL";
|
||||||
|
private final String channelName = "I2P Router Service";
|
||||||
|
NotificationChannel mNotificationChannel;
|
||||||
|
|
||||||
private static final int ID = 1337;
|
private static final int ID = 1337;
|
||||||
|
|
||||||
@ -28,25 +35,33 @@ class StatusBar {
|
|||||||
|
|
||||||
StatusBar(Context ctx) {
|
StatusBar(Context ctx) {
|
||||||
mCtx = ctx;
|
mCtx = ctx;
|
||||||
mNotificationManager = (NotificationManager) ctx.getSystemService(
|
mNotificationManager = (NotificationManager) mCtx.getSystemService(
|
||||||
Context.NOTIFICATION_SERVICE);
|
Context.NOTIFICATION_SERVICE);
|
||||||
|
assert mNotificationManager != null;
|
||||||
|
|
||||||
Thread.currentThread().setUncaughtExceptionHandler(
|
Thread.currentThread().setUncaughtExceptionHandler(
|
||||||
new CrashHandler(mNotificationManager));
|
new CrashHandler(mNotificationManager));
|
||||||
|
|
||||||
int icon = ICON_STARTING;
|
int icon = ICON_STARTING;
|
||||||
// won't be shown if replace() is called
|
// won't be shown if replace() is called
|
||||||
String text = ctx.getString(R.string.notification_status_starting);
|
String text = mCtx.getString(R.string.notification_status_starting);
|
||||||
|
|
||||||
mNotifyBuilder = new NotificationCompat.Builder(ctx)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
.setContentText(text)
|
mNotifyBuilder = new NotificationCompat.Builder(mCtx);
|
||||||
.setSmallIcon(icon)
|
} else {
|
||||||
.setColor(mCtx.getResources().getColor(R.color.primary_light))
|
mNotifyBuilder = new NotificationCompat.Builder(mCtx, NOTIFICATION_CHANNEL_ID);
|
||||||
.setOngoing(true)
|
}
|
||||||
.setOnlyAlertOnce(true);
|
|
||||||
|
|
||||||
Intent intent = new Intent(ctx, I2PActivity.class);
|
mNotifyBuilder.setContentText(text);
|
||||||
|
mNotifyBuilder.setSmallIcon(icon);
|
||||||
|
mNotifyBuilder.setColor(mCtx.getResources().getColor(R.color.primary_light));
|
||||||
|
mNotifyBuilder.setOngoing(true);
|
||||||
|
mNotifyBuilder.setPriority(NotificationManager.IMPORTANCE_LOW);
|
||||||
|
mNotifyBuilder.setCategory(Notification.CATEGORY_SERVICE);
|
||||||
|
|
||||||
|
Intent intent = new Intent(mCtx, I2PActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
PendingIntent pi = PendingIntent.getActivity(ctx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pi = PendingIntent.getActivity(mCtx, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
mNotifyBuilder.setContentIntent(pi);
|
mNotifyBuilder.setContentIntent(pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +89,12 @@ class StatusBar {
|
|||||||
public void update(String title, String text) {
|
public void update(String title, String text) {
|
||||||
mNotifyBuilder.setContentTitle(title)
|
mNotifyBuilder.setContentTitle(title)
|
||||||
.setContentText(text);
|
.setContentText(text);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
mNotificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_LOW);
|
||||||
|
mNotificationManager.createNotificationChannel(mNotificationChannel);
|
||||||
|
mNotificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||||
|
mNotifyBuilder.setChannelId(NOTIFICATION_CHANNEL_ID);
|
||||||
|
}
|
||||||
mNotif = mNotifyBuilder.build();
|
mNotif = mNotifyBuilder.build();
|
||||||
mNotificationManager.notify(ID, mNotif);
|
mNotificationManager.notify(ID, mNotif);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class PeersFragment extends I2PFragmentBase {
|
|||||||
wv.getSettings().setLoadsImagesAutomatically(true); // was false
|
wv.getSettings().setLoadsImagesAutomatically(true); // was false
|
||||||
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
|
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
|
||||||
wv.getSettings().setUseWideViewPort(true);
|
wv.getSettings().setUseWideViewPort(true);
|
||||||
_wvClient = new I2PWebViewClient();
|
_wvClient = new I2PWebViewClient(this);
|
||||||
wv.setWebViewClient(_wvClient);
|
wv.setWebViewClient(_wvClient);
|
||||||
wv.getSettings().setBuiltInZoomControls(true);
|
wv.getSettings().setBuiltInZoomControls(true);
|
||||||
return v;
|
return v;
|
||||||
|
@ -11,9 +11,10 @@ import android.view.ViewGroup;
|
|||||||
import com.androidplot.xy.BarFormatter;
|
import com.androidplot.xy.BarFormatter;
|
||||||
import com.androidplot.xy.BarRenderer;
|
import com.androidplot.xy.BarRenderer;
|
||||||
import com.androidplot.xy.BoundaryMode;
|
import com.androidplot.xy.BoundaryMode;
|
||||||
|
import com.androidplot.xy.StepMode;
|
||||||
|
import com.androidplot.xy.XYGraphWidget;
|
||||||
import com.androidplot.xy.XYPlot;
|
import com.androidplot.xy.XYPlot;
|
||||||
import com.androidplot.xy.XYSeries;
|
import com.androidplot.xy.XYSeries;
|
||||||
import com.androidplot.xy.XYStepMode;
|
|
||||||
|
|
||||||
import net.i2p.android.router.I2PFragmentBase;
|
import net.i2p.android.router.I2PFragmentBase;
|
||||||
import net.i2p.android.router.R;
|
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.addSeries(rateSeries, new BarFormatter(Color.argb(200, 0, 80, 0), Color.argb(200, 0, 80, 0)));
|
||||||
_ratePlot.calculateMinMaxVals();
|
_ratePlot.calculateMinMaxVals();
|
||||||
long maxX = _ratePlot.getCalculatedMaxX().longValue();
|
long maxX = _ratePlot.getBounds().getMaxX().longValue();
|
||||||
|
|
||||||
Util.d("Adding plot updater to listener");
|
Util.d("Adding plot updater to listener");
|
||||||
_listener.addObserver(_plotUpdater);
|
_listener.addObserver(_plotUpdater);
|
||||||
|
|
||||||
// Only one line, so hide the legend
|
// Only one line, so hide the legend
|
||||||
_ratePlot.getLegendWidget().setVisible(false);
|
_ratePlot.getLegend().setVisible(false);
|
||||||
|
|
||||||
BarRenderer renderer = (BarRenderer) _ratePlot.getRenderer(BarRenderer.class);
|
BarRenderer renderer = _ratePlot.getRenderer(BarRenderer.class);
|
||||||
renderer.setBarWidthStyle(BarRenderer.BarWidthStyle.VARIABLE_WIDTH);
|
renderer.setBarGroupWidth(BarRenderer.BarGroupWidthMode.FIXED_GAP, 0);
|
||||||
renderer.setBarGap(0);
|
|
||||||
|
|
||||||
_ratePlot.setDomainUpperBoundary(maxX, BoundaryMode.GROW);
|
_ratePlot.setDomainUpperBoundary(maxX, BoundaryMode.GROW);
|
||||||
_ratePlot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 15 * 60 * 1000);
|
_ratePlot.setDomainStep(StepMode.INCREMENT_BY_VAL, 15 * 60 * 1000);
|
||||||
_ratePlot.setTicksPerDomainLabel(4);
|
_ratePlot.setLinesPerDomainLabel(4);
|
||||||
|
|
||||||
_ratePlot.setRangeLowerBoundary(0, BoundaryMode.FIXED);
|
_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);
|
private DateFormat dateFormat = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -157,13 +157,13 @@ public class RateGraphFragment extends I2PFragmentBase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final int finalK = _k;
|
final int finalK = _k;
|
||||||
_ratePlot.setRangeValueFormat(new Format() {
|
_ratePlot.getGraph().getLineLabelStyle(XYGraphWidget.Edge.LEFT).setFormat(new Format() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer format(Object obj, @NonNull StringBuffer toAppendTo,
|
public StringBuffer format(Object obj, @NonNull StringBuffer toAppendTo,
|
||||||
@NonNull FieldPosition pos) {
|
@NonNull FieldPosition pos) {
|
||||||
double val = ((Number) obj).doubleValue();
|
double val = ((Number) obj).doubleValue();
|
||||||
double maxY = _ratePlot.getCalculatedMaxY().doubleValue();
|
double maxY = _ratePlot.getBounds().getMaxY().doubleValue();
|
||||||
|
|
||||||
if (val == 0 || maxY < finalK) {
|
if (val == 0 || maxY < finalK) {
|
||||||
return new DecimalFormat("0").format(val, toAppendTo, pos);
|
return new DecimalFormat("0").format(val, toAppendTo, pos);
|
||||||
@ -194,8 +194,8 @@ public class RateGraphFragment extends I2PFragmentBase {
|
|||||||
|
|
||||||
private void updatePlot() {
|
private void updatePlot() {
|
||||||
_ratePlot.calculateMinMaxVals();
|
_ratePlot.calculateMinMaxVals();
|
||||||
double maxY = _ratePlot.getCalculatedMaxY().doubleValue();
|
double maxY = _ratePlot.getBounds().getMaxY().doubleValue();
|
||||||
_ratePlot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, getRangeStep(maxY, _k));
|
_ratePlot.setRangeStep(StepMode.INCREMENT_BY_VAL, getRangeStep(maxY, _k));
|
||||||
|
|
||||||
_ratePlot.redraw();
|
_ratePlot.redraw();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ public class AppCache {
|
|||||||
private static AppCache _instance;
|
private static AppCache _instance;
|
||||||
private static File _cacheDir;
|
private static File _cacheDir;
|
||||||
private static long _totalSize;
|
private static long _totalSize;
|
||||||
private static ContentResolver _resolver;
|
|
||||||
/** the LRU cache */
|
/** the LRU cache */
|
||||||
private final Map<Integer, Object> _cache;
|
private final Map<Integer, Object> _cache;
|
||||||
|
|
||||||
@ -62,7 +61,6 @@ public class AppCache {
|
|||||||
_cacheDir = new File(ctx.getCacheDir(), DIR_NAME);
|
_cacheDir = new File(ctx.getCacheDir(), DIR_NAME);
|
||||||
_cacheDir.mkdir();
|
_cacheDir.mkdir();
|
||||||
Util.d("AppCache cache dir " + _cacheDir);
|
Util.d("AppCache cache dir " + _cacheDir);
|
||||||
_resolver = ctx.getContentResolver();
|
|
||||||
_cache = new LHM(MAX_FILES);
|
_cache = new LHM(MAX_FILES);
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
@ -72,9 +70,9 @@ public class AppCache {
|
|||||||
* addCacheFile() or removeCacheFile() after the data is written.
|
* addCacheFile() or removeCacheFile() after the data is written.
|
||||||
* @param key no fragment allowed
|
* @param key no fragment allowed
|
||||||
*/
|
*/
|
||||||
public OutputStream createCacheFile(Uri key) throws IOException {
|
public OutputStream createCacheFile(Context ctx, Uri key) throws IOException {
|
||||||
// remove any old file so the total stays correct
|
// remove any old file so the total stays correct
|
||||||
removeCacheFile(key);
|
removeCacheFile(ctx, key);
|
||||||
File f = toFile(key);
|
File f = toFile(key);
|
||||||
f.getParentFile().mkdirs();
|
f.getParentFile().mkdirs();
|
||||||
return new FileOutputStream(f);
|
return new FileOutputStream(f);
|
||||||
@ -88,7 +86,7 @@ public class AppCache {
|
|||||||
* @param key no fragment allowed
|
* @param key no fragment allowed
|
||||||
* @param setAsCurrentBase tell CacheProvider
|
* @param setAsCurrentBase tell CacheProvider
|
||||||
*/
|
*/
|
||||||
public Uri addCacheFile(Uri key, boolean setAsCurrentBase) {
|
public Uri addCacheFile(Context ctx, Uri key, boolean setAsCurrentBase) {
|
||||||
int hash = toHash(key);
|
int hash = toHash(key);
|
||||||
synchronized(_cache) {
|
synchronized(_cache) {
|
||||||
_cache.put(hash, DUMMY);
|
_cache.put(hash, DUMMY);
|
||||||
@ -96,19 +94,19 @@ public class AppCache {
|
|||||||
// file:/// uri
|
// file:/// uri
|
||||||
//return Uri.fromFile(toFile(hash)).toString();
|
//return Uri.fromFile(toFile(hash)).toString();
|
||||||
// content:// uri
|
// content:// uri
|
||||||
return insertContent(key, setAsCurrentBase);
|
return insertContent(ctx, key, setAsCurrentBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a previously written file from the cache index and disk.
|
* Remove a previously written file from the cache index and disk.
|
||||||
* @param key no fragment allowed
|
* @param key no fragment allowed
|
||||||
*/
|
*/
|
||||||
public void removeCacheFile(Uri key) {
|
public void removeCacheFile(Context ctx, Uri key) {
|
||||||
int hash = toHash(key);
|
int hash = toHash(key);
|
||||||
synchronized(_cache) {
|
synchronized(_cache) {
|
||||||
_cache.remove(hash);
|
_cache.remove(hash);
|
||||||
}
|
}
|
||||||
deleteContent(key);
|
deleteContent(ctx, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,7 +116,7 @@ public class AppCache {
|
|||||||
*
|
*
|
||||||
* @param key no fragment allowed
|
* @param key no fragment allowed
|
||||||
*/
|
*/
|
||||||
public Uri getCacheUri(Uri key) {
|
public Uri getCacheUri(Context ctx, Uri key) {
|
||||||
int hash = toHash(key);
|
int hash = toHash(key);
|
||||||
// poke the LRU
|
// poke the LRU
|
||||||
Object present;
|
Object present;
|
||||||
@ -126,7 +124,7 @@ public class AppCache {
|
|||||||
present = _cache.get(hash);
|
present = _cache.get(hash);
|
||||||
}
|
}
|
||||||
if (present != null)
|
if (present != null)
|
||||||
setAsCurrentBase(key);
|
setAsCurrentBase(ctx, key);
|
||||||
return CacheProvider.getContentUri(key);
|
return CacheProvider.getContentUri(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +240,7 @@ public class AppCache {
|
|||||||
/**
|
/**
|
||||||
* @return the uri inserted or null on failure
|
* @return the uri inserted or null on failure
|
||||||
*/
|
*/
|
||||||
private static Uri insertContent(Uri key, boolean setAsCurrentBase) {
|
private static Uri insertContent(Context ctx, Uri key, boolean setAsCurrentBase) {
|
||||||
String path = toFile(key).getAbsolutePath();
|
String path = toFile(key).getAbsolutePath();
|
||||||
ContentValues cv = new ContentValues();
|
ContentValues cv = new ContentValues();
|
||||||
cv.put(CacheProvider.DATA, path);
|
cv.put(CacheProvider.DATA, path);
|
||||||
@ -250,8 +248,9 @@ public class AppCache {
|
|||||||
cv.put(CacheProvider.CURRENT_BASE, Boolean.TRUE);
|
cv.put(CacheProvider.CURRENT_BASE, Boolean.TRUE);
|
||||||
Uri uri = CacheProvider.getContentUri(key);
|
Uri uri = CacheProvider.getContentUri(key);
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
_resolver.insert(uri, cv);
|
ContentResolver resolver = ctx.getContentResolver();
|
||||||
return uri;
|
resolver.insert(uri, cv);
|
||||||
|
return uri;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -259,19 +258,23 @@ public class AppCache {
|
|||||||
/**
|
/**
|
||||||
* Set key as current base. May be content or i2p key.
|
* Set key as current base. May be content or i2p key.
|
||||||
*/
|
*/
|
||||||
private static void setAsCurrentBase(Uri key) {
|
private static void setAsCurrentBase(Context ctx, Uri key) {
|
||||||
ContentValues cv = new ContentValues();
|
ContentValues cv = new ContentValues();
|
||||||
cv.put(CacheProvider.CURRENT_BASE, Boolean.TRUE);
|
cv.put(CacheProvider.CURRENT_BASE, Boolean.TRUE);
|
||||||
Uri uri = CacheProvider.getContentUri(key);
|
Uri uri = CacheProvider.getContentUri(key);
|
||||||
if (uri != null)
|
if (uri != null) {
|
||||||
_resolver.insert(uri, cv);
|
ContentResolver resolver = ctx.getContentResolver();
|
||||||
|
resolver.insert(uri, cv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ok for now but we will need to store key in the map and delete by integer */
|
/** ok for now but we will need to store key in the map and delete by integer */
|
||||||
private static void deleteContent(Uri key) {
|
private static void deleteContent(Context ctx, Uri key) {
|
||||||
Uri uri = CacheProvider.getContentUri(key);
|
Uri uri = CacheProvider.getContentUri(key);
|
||||||
if (uri != null)
|
if (uri != null) {
|
||||||
_resolver.delete(uri, null, null);
|
ContentResolver resolver = ctx.getContentResolver();
|
||||||
|
resolver.delete(uri, null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,17 @@ public class NamingServiceUtil {
|
|||||||
String kDest = res.getString(R.string.addressbook_add_wizard_k_destination);
|
String kDest = res.getString(R.string.addressbook_add_wizard_k_destination);
|
||||||
|
|
||||||
String hostName = data.getBundle(kHostName).getString(Page.SIMPLE_DATA_KEY);
|
String hostName = data.getBundle(kHostName).getString(Page.SIMPLE_DATA_KEY);
|
||||||
String host = toASCII(res, hostName); // Already validated, won't throw IAE
|
String host;
|
||||||
|
try {
|
||||||
|
// Already validated, won't throw IAE
|
||||||
|
// ^^^ NOT TRUE ticket #2489 ^^^
|
||||||
|
host = toASCII(res, hostName);
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
Toast.makeText(ctx,
|
||||||
|
iae.getMessage(),
|
||||||
|
Toast.LENGTH_LONG).show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String displayHost = host.equals(hostName) ? hostName :
|
String displayHost = host.equals(hostName) ? hostName :
|
||||||
hostName + " (" + host + ')';
|
hostName + " (" + host + ')';
|
||||||
|
|
||||||
|
@ -2,16 +2,20 @@ package net.i2p.android.router.util;
|
|||||||
|
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
|
|
||||||
|
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
public class Notifications {
|
public class Notifications {
|
||||||
private final Context mCtx;
|
private final Context mCtx;
|
||||||
private final NotificationManager mNotificationManager;
|
private final NotificationManager mNotificationManager;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static final int ICON = R.drawable.ic_stat_router_active;
|
public static final int ICON = R.drawable.ic_stat_router_active;
|
||||||
|
|
||||||
public Notifications(Context ctx) {
|
public Notifications(Context ctx) {
|
||||||
@ -25,13 +29,26 @@ public class Notifications {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void notify(String title, String text, Class<?> c) {
|
public void notify(String title, String text, Class<?> c) {
|
||||||
NotificationCompat.Builder b =
|
notify(title, text, "", c);
|
||||||
new NotificationCompat.Builder(mCtx)
|
}
|
||||||
.setContentTitle(title)
|
|
||||||
.setContentText(text)
|
public void notify(String title, String text, String channel, Class<?> c) {
|
||||||
.setSmallIcon(ICON)
|
NotificationCompat.Builder b;
|
||||||
.setColor(mCtx.getResources().getColor(R.color.primary_light))
|
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||||
.setAutoCancel(true);
|
b = new NotificationCompat.Builder(mCtx);
|
||||||
|
} else {
|
||||||
|
if (channel.equals("")){
|
||||||
|
b = new NotificationCompat.Builder(mCtx);
|
||||||
|
} else {
|
||||||
|
b = new NotificationCompat.Builder(mCtx, channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b.setContentTitle(title);
|
||||||
|
b.setContentText(text);
|
||||||
|
b.setSmallIcon(ICON);
|
||||||
|
b.setColor(mCtx.getResources().getColor(R.color.primary_light));
|
||||||
|
b.setAutoCancel(true);
|
||||||
|
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
Intent intent = new Intent(mCtx, c);
|
Intent intent = new Intent(mCtx, c);
|
||||||
|
@ -34,6 +34,7 @@ import java.util.Collection;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -185,9 +186,9 @@ public abstract class Util implements I2PConstants {
|
|||||||
toRemove.setProperty("routerconsole.lang", "");
|
toRemove.setProperty("routerconsole.lang", "");
|
||||||
toRemove.setProperty("routerconsole.country", "");
|
toRemove.setProperty("routerconsole.country", "");
|
||||||
} else {
|
} else {
|
||||||
routerProps.setProperty("routerconsole.lang", language[0].toLowerCase());
|
routerProps.setProperty("routerconsole.lang", language[0].toLowerCase(Locale.US));
|
||||||
if (language.length == 2)
|
if (language.length == 2)
|
||||||
routerProps.setProperty("routerconsole.country", language[1].toUpperCase());
|
routerProps.setProperty("routerconsole.country", language[1].toUpperCase(Locale.US));
|
||||||
else
|
else
|
||||||
toRemove.setProperty("routerconsole.country", "");
|
toRemove.setProperty("routerconsole.country", "");
|
||||||
}
|
}
|
||||||
@ -299,7 +300,15 @@ public abstract class Util implements I2PConstants {
|
|||||||
|
|
||||||
public static String getFileDir(Context context) {
|
public static String getFileDir(Context context) {
|
||||||
// This needs to be changed so that we can have an alternative place
|
// 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -437,10 +446,15 @@ public abstract class Util implements I2PConstants {
|
|||||||
case IPV4_UNKNOWN_IPV6_OK:
|
case IPV4_UNKNOWN_IPV6_OK:
|
||||||
case IPV4_DISABLED_IPV6_OK:
|
case IPV4_DISABLED_IPV6_OK:
|
||||||
case IPV4_SNAT_IPV6_OK:
|
case IPV4_SNAT_IPV6_OK:
|
||||||
RouterAddress ra = routerInfo.getTargetAddress("NTCP");
|
List<RouterAddress> ras = routerInfo.getTargetAddresses("NTCP", "NTCP2");
|
||||||
if (ra == null)
|
if (ras.isEmpty())
|
||||||
return new NetStatus(NetStatus.Level.INFO, toStatusString(ctx, status));
|
return new NetStatus(NetStatus.Level.INFO, toStatusString(ctx, status));
|
||||||
byte[] ip = ra.getIP();
|
byte[] ip = null;
|
||||||
|
for (RouterAddress ra : ras) {
|
||||||
|
ip = ra.getIP();
|
||||||
|
if (ip != null)
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (ip == null)
|
if (ip == null)
|
||||||
return new NetStatus(NetStatus.Level.ERROR, ctx.getString(R.string.net_status_error_unresolved_tcp));
|
return new NetStatus(NetStatus.Level.ERROR, ctx.getString(R.string.net_status_error_unresolved_tcp));
|
||||||
// TODO set IPv6 arg based on configuration?
|
// TODO set IPv6 arg based on configuration?
|
||||||
@ -454,7 +468,7 @@ public abstract class Util implements I2PConstants {
|
|||||||
|
|
||||||
case REJECT_UNSOLICITED:
|
case REJECT_UNSOLICITED:
|
||||||
case IPV4_DISABLED_IPV6_FIREWALLED:
|
case IPV4_DISABLED_IPV6_FIREWALLED:
|
||||||
if (routerInfo.getTargetAddress("NTCP") != null)
|
if (routerInfo.getTargetAddresses("NTCP", "NTCP2").isEmpty())
|
||||||
return new NetStatus(NetStatus.Level.WARN, ctx.getString(R.string.net_status_warn_firewalled_inbound_tcp));
|
return new NetStatus(NetStatus.Level.WARN, ctx.getString(R.string.net_status_warn_firewalled_inbound_tcp));
|
||||||
// fall through...
|
// fall through...
|
||||||
case IPV4_FIREWALLED_IPV6_OK:
|
case IPV4_FIREWALLED_IPV6_OK:
|
||||||
@ -475,7 +489,7 @@ public abstract class Util implements I2PConstants {
|
|||||||
case IPV4_UNKNOWN_IPV6_FIREWALLED:
|
case IPV4_UNKNOWN_IPV6_FIREWALLED:
|
||||||
case IPV4_DISABLED_IPV6_UNKNOWN:
|
case IPV4_DISABLED_IPV6_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
ra = routerInfo.getTargetAddress("SSU");
|
RouterAddress ra = routerInfo.getTargetAddress("SSU");
|
||||||
if (ra == null && rCtx.router().getUptime() > 5 * 60 * 1000) {
|
if (ra == null && rCtx.router().getUptime() > 5 * 60 * 1000) {
|
||||||
if (rCtx.commSystem().countActivePeers() <= 0)
|
if (rCtx.commSystem().countActivePeers() <= 0)
|
||||||
return new NetStatus(NetStatus.Level.ERROR, ctx.getString(R.string.net_status_error_no_active_peers));
|
return new NetStatus(NetStatus.Level.ERROR, ctx.getString(R.string.net_status_error_no_active_peers));
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package net.i2p.android.router.web;
|
package net.i2p.android.router.web;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.HttpAuthHandler;
|
import android.webkit.HttpAuthHandler;
|
||||||
@ -26,9 +28,11 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class I2PWebViewClient extends WebViewClient {
|
public class I2PWebViewClient extends WebViewClient {
|
||||||
|
|
||||||
|
private final Fragment _parentFrag;
|
||||||
private BGLoad _lastTask;
|
private BGLoad _lastTask;
|
||||||
/** save it here so we can dismiss it in onPageFinished() */
|
/** save it here so we can dismiss it in onPageFinished() */
|
||||||
private ProgressDialog _lastDialog;
|
private ProgressDialog _lastDialog;
|
||||||
@ -40,6 +44,11 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
private static final String ERROR_URL = "<p>Unable to load URL: ";
|
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>";
|
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
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
Util.d("Should override? " + url);
|
Util.d("Should override? " + url);
|
||||||
@ -68,7 +77,7 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
fail(view, "Bad URL " + url);
|
fail(view, "Bad URL " + url);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
s = s.toLowerCase();
|
s = s.toLowerCase(Locale.US);
|
||||||
if (!(s.equals("http") || s.equals("https") ||
|
if (!(s.equals("http") || s.equals("https") ||
|
||||||
s.equals(CONTENT))) {
|
s.equals(CONTENT))) {
|
||||||
Util.d("Not loading URL " + url);
|
Util.d("Not loading URL " + url);
|
||||||
@ -85,7 +94,7 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
h = h.toLowerCase();
|
h = h.toLowerCase(Locale.US);
|
||||||
if (h.endsWith(".i2p")) {
|
if (h.endsWith(".i2p")) {
|
||||||
if (!s.equals("http")) {
|
if (!s.equals("http")) {
|
||||||
fail(view, "Bad URL " + url);
|
fail(view, "Bad URL " + url);
|
||||||
@ -102,7 +111,7 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
///////// API 8
|
///////// API 8
|
||||||
// Otherwise hangs waiting for CSS
|
// Otherwise hangs waiting for CSS
|
||||||
view.getSettings().setBlockNetworkLoads(false);
|
view.getSettings().setBlockNetworkLoads(false);
|
||||||
_lastDialog = new ProgressDialog(view.getContext());
|
_lastDialog = new ProgressDialog(_parentFrag.getContext());
|
||||||
BGLoad task = new BackgroundEepLoad(view, h, _lastDialog);
|
BGLoad task = new BackgroundEepLoad(view, h, _lastDialog);
|
||||||
_lastTask = task;
|
_lastTask = task;
|
||||||
task.execute(url);
|
task.execute(url);
|
||||||
@ -203,7 +212,8 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
//reverse back to a i2p URI so we can delete it from the AppCache
|
//reverse back to a i2p URI so we can delete it from the AppCache
|
||||||
uri = CacheProvider.getI2PUri(uri);
|
uri = CacheProvider.getI2PUri(uri);
|
||||||
Util.d("clearing AppCache entry for current page " + uri);
|
Util.d("clearing AppCache entry for current page " + uri);
|
||||||
AppCache.getInstance(view.getContext()).removeCacheFile(uri);
|
Context ctx = view.getContext();
|
||||||
|
AppCache.getInstance(ctx).removeCacheFile(ctx, uri);
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
// this actually only deletes the row in the provider,
|
// this actually only deletes the row in the provider,
|
||||||
// not the actual file, but it will be overwritten in the reload.
|
// not the actual file, but it will be overwritten in the reload.
|
||||||
@ -215,10 +225,12 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
|
|
||||||
private abstract static class BGLoad extends AsyncTask<String, Integer, Integer> implements DialogInterface.OnCancelListener {
|
private abstract static class BGLoad extends AsyncTask<String, Integer, Integer> implements DialogInterface.OnCancelListener {
|
||||||
protected final WebView _view;
|
protected final WebView _view;
|
||||||
|
protected final Context _ctx;
|
||||||
protected final ProgressDialog _dialog;
|
protected final ProgressDialog _dialog;
|
||||||
|
|
||||||
public BGLoad(WebView view, ProgressDialog dialog) {
|
public BGLoad(WebView view, ProgressDialog dialog) {
|
||||||
_view = view;
|
_view = view;
|
||||||
|
_ctx = view.getContext();
|
||||||
if (dialog != null)
|
if (dialog != null)
|
||||||
dialog.setCancelable(true);
|
dialog.setCancelable(true);
|
||||||
_dialog = dialog;
|
_dialog = dialog;
|
||||||
@ -305,9 +317,10 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
protected Integer doInBackground(String... urls) {
|
protected Integer doInBackground(String... urls) {
|
||||||
final String url = urls[0];
|
final String url = urls[0];
|
||||||
Uri uri = Uri.parse(url);
|
Uri uri = Uri.parse(url);
|
||||||
File cacheFile = AppCache.getInstance(_view.getContext()).getCacheFile(uri);
|
final AppCache cache = AppCache.getInstance(_ctx);
|
||||||
|
File cacheFile = cache.getCacheFile(uri);
|
||||||
if (cacheFile.exists()) {
|
if (cacheFile.exists()) {
|
||||||
final Uri resUri = AppCache.getInstance(_view.getContext()).getCacheUri(uri);
|
final Uri resUri = cache.getCacheUri(_ctx, uri);
|
||||||
Util.d("Loading " + url + " from resource cache " + resUri);
|
Util.d("Loading " + url + " from resource cache " + resUri);
|
||||||
_view.post(new Runnable() {
|
_view.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -325,7 +338,7 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
//EepGetFetcher fetcher = new EepGetFetcher(url);
|
//EepGetFetcher fetcher = new EepGetFetcher(url);
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
try {
|
try {
|
||||||
out = AppCache.getInstance(_view.getContext()).createCacheFile(uri);
|
out = cache.createCacheFile(_ctx, uri);
|
||||||
// write error to stream
|
// write error to stream
|
||||||
EepGetFetcher fetcher = new EepGetFetcher(url, out, true);
|
EepGetFetcher fetcher = new EepGetFetcher(url, out, true);
|
||||||
fetcher.addStatusListener(this);
|
fetcher.addStatusListener(this);
|
||||||
@ -338,11 +351,11 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
if (success) {
|
if (success) {
|
||||||
// store in cache, get content URL, and load that way
|
// store in cache, get content URL, and load that way
|
||||||
// Set as current base
|
// Set as current base
|
||||||
final Uri content = AppCache.getInstance(_view.getContext()).addCacheFile(uri, true);
|
final Uri content = cache.addCacheFile(_ctx, uri, true);
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
Util.d("Stored cache in " + content);
|
Util.d("Stored cache in " + content);
|
||||||
} else {
|
} else {
|
||||||
AppCache.getInstance(_view.getContext()).removeCacheFile(uri);
|
cache.removeCacheFile(_ctx, uri);
|
||||||
Util.d("cache create error");
|
Util.d("cache create error");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -381,7 +394,7 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AppCache.getInstance(_view.getContext()).removeCacheFile(uri);
|
cache.removeCacheFile(_ctx, uri);
|
||||||
Util.d("loading error data URL: " + url);
|
Util.d("loading error data URL: " + url);
|
||||||
final String finalMsg = msg;
|
final String finalMsg = msg;
|
||||||
_view.post(new Runnable() {
|
_view.post(new Runnable() {
|
||||||
@ -403,30 +416,36 @@ public class I2PWebViewClient extends WebViewClient {
|
|||||||
protected void onProgressUpdate(Integer... progress) {
|
protected void onProgressUpdate(Integer... progress) {
|
||||||
if (isCancelled())
|
if (isCancelled())
|
||||||
return;
|
return;
|
||||||
int prog = progress[0];
|
try {
|
||||||
if (prog < 0) {
|
int prog = progress[0];
|
||||||
_dialog.setTitle("Contacting...");
|
if (prog < 0) {
|
||||||
_dialog.setMessage(_host);
|
_dialog.setTitle("Contacting...");
|
||||||
_dialog.setIndeterminate(true);
|
_dialog.setMessage(_host);
|
||||||
_dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
_dialog.setIndeterminate(true);
|
||||||
_dialog.setOnCancelListener(this);
|
_dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||||
_dialog.show();
|
_dialog.setOnCancelListener(this);
|
||||||
} else if (prog == 0 && _total > 0) {
|
_dialog.show();
|
||||||
_dialog.setTitle("Downloading...");
|
} else if (prog == 0 && _total > 0) {
|
||||||
_dialog.setMessage("...from " + _host);
|
_dialog.setTitle("Downloading...");
|
||||||
_dialog.setIndeterminate(false);
|
_dialog.setMessage("...from " + _host);
|
||||||
_dialog.setMax(_total);
|
_dialog.setIndeterminate(false);
|
||||||
_dialog.setProgress(0);
|
_dialog.setMax(_total);
|
||||||
} else if (_total > 0) {
|
_dialog.setProgress(0);
|
||||||
// so it isn't at 100% while loading images and CSS
|
} else if (_total > 0) {
|
||||||
_dialog.setProgress(Math.min(prog, _total * 99 / 100));
|
// so it isn't at 100% while loading images and CSS
|
||||||
} else if (prog > 0) {
|
_dialog.setProgress(Math.min(prog, _total * 99 / 100));
|
||||||
// ugly, need custom
|
} else if (prog > 0) {
|
||||||
_dialog.setTitle("Downloading...");
|
// ugly, need custom
|
||||||
_dialog.setMessage("...from " + _host + ": " + DataHelper.formatSize(prog) + 'B');
|
_dialog.setTitle("Downloading...");
|
||||||
//_dialog.setProgress(prog);
|
_dialog.setMessage("...from " + _host + ": " + DataHelper.formatSize(prog) + 'B');
|
||||||
} else {
|
//_dialog.setProgress(prog);
|
||||||
// nothing
|
} else {
|
||||||
|
// nothing
|
||||||
|
}
|
||||||
|
} catch (RuntimeException iae) {
|
||||||
|
// throws IAE - not attached to window manager - perhaps due to screen rotation?
|
||||||
|
// Also includes android.view.WindowManager$BadTokenException extends RuntimeException
|
||||||
|
Util.e("Error while updating I2PWebViewClient dialog", iae);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,24 +44,26 @@ public class WebFragment extends I2PFragmentBase {
|
|||||||
TextView tv = (TextView) v.findViewById(R.id.browser_status);
|
TextView tv = (TextView) v.findViewById(R.id.browser_status);
|
||||||
tv.setText(WARNING);
|
tv.setText(WARNING);
|
||||||
WebView wv = (WebView) v.findViewById(R.id.browser_webview);
|
WebView wv = (WebView) v.findViewById(R.id.browser_webview);
|
||||||
_wvClient = new I2PWebViewClient();
|
_wvClient = new I2PWebViewClient(this);
|
||||||
wv.setWebViewClient(_wvClient);
|
wv.setWebViewClient(_wvClient);
|
||||||
wv.getSettings().setBuiltInZoomControls(true);
|
wv.getSettings().setBuiltInZoomControls(true);
|
||||||
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
|
// http://stackoverflow.com/questions/2369310/webview-double-tap-zoom-not-working-on-a-motorola-droid-a855
|
||||||
wv.getSettings().setUseWideViewPort(true);
|
wv.getSettings().setUseWideViewPort(true);
|
||||||
_uriStr = getArguments().getString(HTML_URI);
|
if (getArguments() != null) {
|
||||||
if (_uriStr != null) {
|
_uriStr = getArguments().getString(HTML_URI);
|
||||||
Uri uri = Uri.parse(_uriStr);
|
if (_uriStr != null) {
|
||||||
//wv.getSettings().setLoadsImagesAutomatically(true);
|
Uri uri = Uri.parse(_uriStr);
|
||||||
//wv.loadUrl(uri.toString());
|
//wv.getSettings().setLoadsImagesAutomatically(true);
|
||||||
// go thru the client so .i2p will work too
|
//wv.loadUrl(uri.toString());
|
||||||
_wvClient.shouldOverrideUrlLoading(wv, uri.toString());
|
// go thru the client so .i2p will work too
|
||||||
} else {
|
_wvClient.shouldOverrideUrlLoading(wv, uri.toString());
|
||||||
wv.getSettings().setLoadsImagesAutomatically(false);
|
} else {
|
||||||
int id = getArguments().getInt(HTML_RESOURCE_ID, 0);
|
wv.getSettings().setLoadsImagesAutomatically(false);
|
||||||
// no default, so restart should keep previous view
|
int id = getArguments().getInt(HTML_RESOURCE_ID, 0);
|
||||||
if (id != 0)
|
// no default, so restart should keep previous view
|
||||||
loadResource(wv, id);
|
if (id != 0)
|
||||||
|
loadResource(wv, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import com.eowise.recyclerview.stickyheaders.StickyHeadersAdapter;
|
import com.eowise.recyclerview.stickyheaders.StickyHeadersAdapter;
|
||||||
|
|
||||||
import net.i2p.android.router.R;
|
import net.i2p.android.router.R;
|
||||||
@ -49,7 +51,7 @@ public class AlphanumericHeaderAdapter implements StickyHeadersAdapter<Alphanume
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ViewHolder headerViewHolder, int position) {
|
public void onBindViewHolder(ViewHolder headerViewHolder, int position) {
|
||||||
String sortString = mAdapter.getSortString(position).toUpperCase();
|
String sortString = mAdapter.getSortString(position).toUpperCase(Locale.getDefault());
|
||||||
if (sortString.isEmpty())
|
if (sortString.isEmpty())
|
||||||
headerViewHolder.itemView.setVisibility(View.GONE);
|
headerViewHolder.itemView.setVisibility(View.GONE);
|
||||||
else {
|
else {
|
||||||
@ -63,7 +65,7 @@ public class AlphanumericHeaderAdapter implements StickyHeadersAdapter<Alphanume
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getHeaderId(int position) {
|
public long getHeaderId(int position) {
|
||||||
String sortString = mAdapter.getSortString(position).toUpperCase();
|
String sortString = mAdapter.getSortString(position).toUpperCase(Locale.getDefault());
|
||||||
if (sortString.isEmpty())
|
if (sortString.isEmpty())
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
@ -3,19 +3,17 @@ package net.i2p.android.util;
|
|||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentPagerAdapter;
|
import android.support.v4.app.FragmentPagerAdapter;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class MemoryFragmentPagerAdapter extends FragmentPagerAdapter {
|
public abstract class MemoryFragmentPagerAdapter extends FragmentPagerAdapter {
|
||||||
private FragmentManager mFragmentManager;
|
private final FragmentManager mFragmentManager;
|
||||||
private Map<Integer, String> mFragmentTags;
|
private final SparseArray<String> mFragmentTags;
|
||||||
|
|
||||||
public MemoryFragmentPagerAdapter(FragmentManager fm) {
|
public MemoryFragmentPagerAdapter(FragmentManager fm) {
|
||||||
super(fm);
|
super(fm);
|
||||||
mFragmentManager = fm;
|
mFragmentManager = fm;
|
||||||
mFragmentTags = new HashMap<>();
|
mFragmentTags = new SparseArray<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,10 +30,10 @@ import java.util.List;
|
|||||||
* To create an actual wizard model, extend this class and implement {@link #onNewRootPageList()}.
|
* To create an actual wizard model, extend this class and implement {@link #onNewRootPageList()}.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractWizardModel implements ModelCallbacks {
|
public abstract class AbstractWizardModel implements ModelCallbacks {
|
||||||
protected Context mContext;
|
protected final Context mContext;
|
||||||
|
|
||||||
private List<ModelCallbacks> mListeners = new ArrayList<ModelCallbacks>();
|
private final List<ModelCallbacks> mListeners = new ArrayList<ModelCallbacks>();
|
||||||
private PageList mRootPageList;
|
private final PageList mRootPageList;
|
||||||
|
|
||||||
public AbstractWizardModel(Context context) {
|
public AbstractWizardModel(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
@ -67,7 +67,10 @@ public abstract class AbstractWizardModel implements ModelCallbacks {
|
|||||||
|
|
||||||
public void load(Bundle savedValues) {
|
public void load(Bundle savedValues) {
|
||||||
for (String key : savedValues.keySet()) {
|
for (String key : savedValues.keySet()) {
|
||||||
mRootPageList.findByKey(key).resetData(savedValues.getBundle(key));
|
// Expanded the code to hunt NPE - Ticket #2389
|
||||||
|
Page tmp = mRootPageList.findByKey(key);
|
||||||
|
Bundle tmpBundle = savedValues.getBundle(key);
|
||||||
|
tmp.resetData(tmpBundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ public class SingleTextFieldPage extends Page {
|
|||||||
protected String mDef = null;
|
protected String mDef = null;
|
||||||
protected String mDesc = "";
|
protected String mDesc = "";
|
||||||
protected boolean mNumeric = false;
|
protected boolean mNumeric = false;
|
||||||
|
private String mFeedback;
|
||||||
|
|
||||||
public SingleTextFieldPage(ModelCallbacks callbacks, String title) {
|
public SingleTextFieldPage(ModelCallbacks callbacks, String title) {
|
||||||
super(callbacks, title);
|
super(callbacks, title);
|
||||||
@ -81,14 +82,24 @@ public class SingleTextFieldPage extends Page {
|
|||||||
// Override these in subclasses to add content verification.
|
// Override these in subclasses to add content verification.
|
||||||
|
|
||||||
public boolean isValid() {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showFeedback() {
|
public boolean showFeedback() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFeedback() {
|
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
|
// Create the WizardModel before super.onCreate() in case a Fragment
|
||||||
// is created and tries to call e.g. onGetPage()
|
// is created and tries to call e.g. onGetPage()
|
||||||
mWizardModel = onCreateModel();
|
mWizardModel = onCreateModel();
|
||||||
if (savedInstanceState != null)
|
if (savedInstanceState != null) {
|
||||||
mWizardModel.load(savedInstanceState.getBundle("model"));
|
Bundle model = savedInstanceState.getBundle("model");
|
||||||
|
if (model != null) {
|
||||||
|
mWizardModel.load(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_wizard);
|
setContentView(R.layout.activity_wizard);
|
||||||
|
@ -190,6 +190,10 @@ public class I2PB64DestinationFragment extends Fragment {
|
|||||||
Util.e("Could not find B64 file", fnfe);
|
Util.e("Could not find B64 file", fnfe);
|
||||||
Toast.makeText(getActivity(), "Could not find B64 file.",
|
Toast.makeText(getActivity(), "Could not find B64 file.",
|
||||||
Toast.LENGTH_SHORT).show();
|
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 {
|
} finally {
|
||||||
if (br != null)
|
if (br != null)
|
||||||
try {
|
try {
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package net.i2p.router.client;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.ServerSocket;
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
import net.i2p.client.DomainSocketFactory;
|
||||||
|
import net.i2p.router.RouterContext;
|
||||||
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unix domain socket version of ClientListenerRunner.
|
||||||
|
*
|
||||||
|
* @author str4d
|
||||||
|
* @since 0.9.14
|
||||||
|
*/
|
||||||
|
public class DomainClientListenerRunner extends ClientListenerRunner {
|
||||||
|
private final DomainSocketFactory factory;
|
||||||
|
private final Log _log;
|
||||||
|
|
||||||
|
public DomainClientListenerRunner(RouterContext context, ClientManager manager) {
|
||||||
|
super(context, manager, -1);
|
||||||
|
factory = new DomainSocketFactory(_context);
|
||||||
|
_log = context.logManager().getLog(getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected ServerSocket getServerSocket() throws IOException {
|
||||||
|
return factory.createServerSocket(DomainSocketFactory.I2CP_SOCKET_ADDRESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopListening() {
|
||||||
|
_running = false;
|
||||||
|
// LocalServerSocket.close() fails silently if the socket is blocking in accept(), so we
|
||||||
|
// trick the socket by opening a new connection and then immediately closing it.
|
||||||
|
// http://stackoverflow.com/questions/8007982/java-serversocket-and-android-localserversocket
|
||||||
|
try {
|
||||||
|
_log.debug("Connecting to domain socket to trigger close");
|
||||||
|
Socket s = factory.createSocket(DomainSocketFactory.I2CP_SOCKET_ADDRESS);
|
||||||
|
s.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
_log.error("Failed to connect to domain socket to trigger close", e);
|
||||||
|
}
|
||||||
|
// runServer() will close the LocalServerSocket.
|
||||||
|
}
|
||||||
|
}
|
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 |