├── .gitignore
├── COPYING.txt
├── README.md
├── RetroShareAndroidIntegration
├── .gitignore
├── AndroidManifest.xml
├── ic_launcher-web.png
├── proguard-project.txt
├── project.properties
├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-ldpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── drawable
│ │ ├── bubble_colorizable.9.png
│ │ ├── chat_bubble.png
│ │ ├── files.png
│ │ ├── groupevent.png
│ │ ├── ic_contact_color.png
│ │ ├── ic_contact_picture.png
│ │ ├── irc_protocol.png
│ │ ├── retrosharelogo2.png
│ │ ├── retrosharelogo2_gray.png
│ │ ├── rstray0.png
│ │ ├── rstray0_err2.png
│ │ ├── rstray3.png
│ │ └── search.png
│ ├── layout
│ │ ├── activity_account.xml
│ │ ├── activity_add_download.xml
│ │ ├── activity_add_server.xml
│ │ ├── activity_addfriend.xml
│ │ ├── activity_chalobby_lobby_item.xml
│ │ ├── activity_chatlobbychat.xml
│ │ ├── activity_files_file_item.xml
│ │ ├── activity_listsearches.xml
│ │ ├── activity_login_dialog.xml
│ │ ├── activity_main.xml
│ │ ├── activity_peerdetails.xml
│ │ ├── activity_peers.xml
│ │ ├── activity_peers_person_item.xml
│ │ ├── activity_server_chooser.xml
│ │ ├── activity_show_qrcode.xml
│ │ ├── activity_tester.xml
│ │ ├── chat_message_item.xml
│ │ ├── conversation_fragment.xml
│ │ ├── conversation_info_fragment_layout.xml
│ │ ├── factivity_conversation.xml
│ │ ├── factivity_lobbieslist.xml
│ │ ├── lobbies_list_fragment.xml
│ │ ├── lobby_list_item.xml
│ │ └── participants_list_item.xml
│ ├── menu
│ │ ├── activity_main.xml
│ │ └── lobbies_list_context_menu.xml
│ ├── raw
│ │ └── bdboot.txt
│ ├── values-de
│ │ └── strings.xml
│ ├── values
│ │ └── strings.xml
│ └── xml
│ │ ├── account_preferences.xml
│ │ ├── authenticator.xml
│ │ └── sync_contacts.xml
├── src
│ └── org
│ │ └── retroshare
│ │ └── android
│ │ ├── AddDownloadActivity.java
│ │ ├── AddFriendMethodChooserActivity.java
│ │ ├── AddServerActivity.java
│ │ ├── ConnectingToServiceFragmentDialog.java
│ │ ├── ContactMethodChooserActivity.java
│ │ ├── ConversationFragment.java
│ │ ├── ConversationFragmentActivity.java
│ │ ├── ConversationInfoDialogFragment.java
│ │ ├── FilesActivity.java
│ │ ├── HandlerThreadInterface.java
│ │ ├── ListSearchesActivity.java
│ │ ├── LobbiesListFragment.java
│ │ ├── LobbiesListFragmentActivity.java
│ │ ├── MainActivity.java
│ │ ├── PeerDetailsActivity.java
│ │ ├── PeersActivity.java
│ │ ├── ProxiedActivityBase.java
│ │ ├── ProxiedFragmentActivityBase.java
│ │ ├── ProxiedFragmentBase.java
│ │ ├── ProxiedInterface.java
│ │ ├── ProxiedServiceBase.java
│ │ ├── RSA-CircleN-icon.svg
│ │ ├── RetroShareAndroidProxy.java
│ │ ├── RsClientInterface.java
│ │ ├── RsConversationService.java
│ │ ├── RsCtrlService.java
│ │ ├── RsFilesService.java
│ │ ├── RsMessageHandler.java
│ │ ├── RsPeersService.java
│ │ ├── RsSearchService.java
│ │ ├── RsServerData.java
│ │ ├── RsServiceClientFragmentBase.java
│ │ ├── RsServiceInterface.java
│ │ ├── ServerChooserActivity.java
│ │ ├── ShowQrCodeActivity.java
│ │ ├── ShowSearchResultsActivity.java
│ │ ├── authenticator
│ │ ├── AccountActivity.java
│ │ ├── AccountAuthenticator.java
│ │ ├── AccountPreferenceActivity.java
│ │ └── AuthenticationService.java
│ │ ├── sync
│ │ └── ContactsSyncAdapterService.java
│ │ ├── tests
│ │ ├── HtmlBase64ImageGetterTestActivity.java
│ │ └── TestActivity.java
│ │ └── utils
│ │ ├── ColorHash.java
│ │ ├── HtmlBase64ImageGetter.java
│ │ ├── Util.java
│ │ └── WeakHashSet.java
└── todo.txt
├── doc
├── architecture.dia
├── architecture.dia~
└── architecture.png
├── lib
└── rsctrl
│ ├── readme.txt
│ └── rsctrl
│ ├── chat
│ └── Chat.java
│ ├── core
│ └── Core.java
│ ├── files
│ └── Files.java
│ ├── gxs
│ └── Gxs.java
│ ├── msgs
│ └── Msgs.java
│ ├── peers
│ └── Peers.java
│ ├── search
│ └── Search.java
│ ├── stream
│ └── Stream.java
│ └── system
│ └── System.java
└── readme-update.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | #tmp
2 | *.tmp
3 | *.bak
4 | *.swp
5 | *~.nib
6 |
7 | # built application files
8 | *.apk
9 | *.ap_
10 |
11 | # files for the dex VM
12 | *.dex
13 |
14 | # Java class files
15 | *.class
16 |
17 | # Intellij project files
18 | *.iml
19 | *.ipr
20 | *.iws
21 | .idea
22 |
23 | # Locally stored "Eclipse launch configurations"
24 | *.launch
25 |
26 | RetroShareAndroidIntegration/.classpath
27 | RetroShareAndroidIntegration/.settings
28 | RetroShareAndroidIntegration/gen
29 | RetroShareAndroidIntegration/libs
30 | out
31 | lib
32 | RetroShareAndroidIntegration/.externalToolBuilders
33 | RetroShareAndroidIntegration/.settings
34 | RetroShareAndroidIntegration/.project
35 | RetroShareAndroidIntegration/.cproject
36 | RetroShareAndroidIntegration/.buildpath
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Very Old RetroShare Client for Android #
2 |
3 | This project is deprecated, kept only as an hystorical archive, it uses very old
4 | RetroShare API which had hand written wrappers based on protobuf and was
5 | accessible via an SSH connection directly into retroshare-nogui process.
6 |
7 | That API was cumbersome to write, maintain and use and therefore was deprecated
8 | and then removed from RetroShare a long time ago.
9 |
10 | As of today RetroShare-service runs directly on Android and exposes a programmer
11 | friendly API, and many different Android apps use that API. Please refer to that
12 | API and to Android documentation shipped toghether within RetroShare main source
13 | code repository.
14 |
15 |
16 | ## How to run from source ##
17 | you need:
18 |
19 | - Android Studio (http://developer.android.com/sdk/installing/studio.html)
20 | - git (http://git-scm.com/)
21 | - ant (http://ant.apache.org/)
22 | - The other tools ( JVM, unzip, wget ) are usually already installed on almost all android developer computers.
23 |
24 | Clone RetroShare Android Client source running:
25 |
26 | # git clone https://github.com/G10h4ck/RetroShare-Android-Client.git
27 |
28 | Prepare library dependency:
29 |
30 | ## If you miss some command install it ;)
31 | # cd RetroShare-Android-Client/lib
32 | # wget http://lag.net/jaramiko/download/jaramiko-151.zip
33 | # unzip jaramiko-151.zip
34 | # cd jaramiko-151
35 | # ant jar
36 |
37 | Create Android Studio Project:
38 |
39 | From Android Studio main window:
40 | File -> Import Project -> select RetroShare-Android-Client/RetroShareAndroidIntegration
41 | File -> Import Module -> select RetroShare-Android-Client/lib/rsctrl/rsctrl
42 | File -> Project Structure -> Libraries -> + -> Java -> select RetroShare-Android-Client/lib/jaramiko-151/jaramiko.jar ( Doing this you will probably asked what modules of your project depends on that library, select the one created importing RetroShare-Android-Client/RetroShareAndroidIntegration )
43 | File -> Project Structure -> Libraries -> + -> From Maven... -> put com.google.protobuf in the search box -> press search -> select version 2.4.1 -> set Download to RetroShare-Android-Client/lib -> press OK
44 | File -> Project Structure -> Libraries -> + -> From Maven... -> put com.google.zxing in the search box -> press search -> select version core:2.0 -> set Download to RetroShare-Android-Client/lib -> press OK
45 | File -> Project Structure -> Libraries -> + -> From Maven... -> put org.apache.commons.lang in the search box -> press search -> select a version >= 2.6.0 -> set Download to RetroShare-Android-Client/lib -> press OK
46 | Now you should be ready to contribute to the project editing the source and tunning it for testing on your emulator
47 |
48 | ## What is RetroShare? ##
49 |
50 | [RetroShare](https://retroshare.cc/) is a secure friend-2-friend social network.
51 |
52 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | .metadata
3 | obj
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
50 |
51 |
54 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
92 |
93 |
97 |
98 |
99 |
100 |
103 |
104 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/ic_launcher-web.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-17
15 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/bubble_colorizable.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/bubble_colorizable.9.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/chat_bubble.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/chat_bubble.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/files.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/files.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/groupevent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/groupevent.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/ic_contact_color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/ic_contact_color.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/ic_contact_picture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/ic_contact_picture.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/irc_protocol.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/irc_protocol.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/retrosharelogo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/retrosharelogo2.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/retrosharelogo2_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/retrosharelogo2_gray.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/rstray0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/rstray0.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/rstray0_err2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/rstray0_err2.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/rstray3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/rstray3.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/drawable/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/RetroShareAndroidIntegration/res/drawable/search.png
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_account.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
17 |
18 |
24 |
25 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_add_download.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
13 |
14 |
15 |
16 |
22 |
23 |
24 |
29 |
30 |
31 |
32 |
38 |
39 |
44 |
45 |
46 |
52 |
53 |
59 |
60 |
63 |
64 |
65 |
66 |
67 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_add_server.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
18 |
19 |
20 |
26 |
27 |
28 |
29 |
36 |
37 |
38 |
39 |
40 |
47 |
48 |
49 |
50 |
51 |
58 |
59 |
67 |
68 |
74 |
75 |
81 |
82 |
85 |
86 |
87 |
93 |
94 |
99 |
100 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_addfriend.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
25 |
26 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_chalobby_lobby_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
19 |
20 |
24 |
25 |
26 |
33 |
34 |
35 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_chatlobbychat.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
26 |
27 |
30 |
31 |
36 |
37 |
38 |
39 |
40 |
41 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_files_file_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
14 |
15 |
18 |
19 |
20 |
25 |
26 |
27 |
33 |
34 |
35 |
36 |
39 |
40 |
41 |
46 |
47 |
48 |
54 |
55 |
56 |
57 |
60 |
61 |
62 |
67 |
68 |
69 |
70 |
76 |
77 |
78 |
79 |
80 |
85 |
86 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_listsearches.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
11 |
12 |
16 |
17 |
22 |
23 |
24 |
25 |
26 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_login_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
12 |
13 |
14 |
20 |
21 |
25 |
26 |
30 |
31 |
37 |
43 |
49 |
50 |
51 |
52 |
56 |
57 |
62 |
63 |
64 |
69 |
70 |
75 |
76 |
77 |
83 |
84 |
85 |
86 |
90 |
91 |
92 |
96 |
97 |
102 |
103 |
104 |
111 |
112 |
113 |
114 |
119 |
120 |
121 |
126 |
127 |
132 |
133 |
134 |
140 |
141 |
142 |
143 |
147 |
148 |
149 |
154 |
155 |
160 |
161 |
162 |
168 |
169 |
170 |
171 |
177 |
178 |
184 |
185 |
186 |
187 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_peerdetails.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
18 |
19 |
23 |
24 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
47 |
48 |
53 |
54 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_peers.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
18 |
19 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_peers_person_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
22 |
23 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_server_chooser.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_show_qrcode.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/activity_tester.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
13 |
18 |
23 |
28 |
29 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/chat_message_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
20 |
21 |
29 |
30 |
35 |
36 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/conversation_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
15 |
16 |
22 |
23 |
24 |
29 |
30 |
39 |
40 |
49 |
50 |
58 |
59 |
65 |
73 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/conversation_info_fragment_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
15 |
16 |
20 |
21 |
27 |
28 |
29 |
34 |
39 |
40 |
45 |
46 |
47 |
52 |
57 |
58 |
63 |
64 |
65 |
70 |
75 |
76 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/factivity_conversation.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/factivity_lobbieslist.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/lobbies_list_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/lobby_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
13 |
14 |
21 |
22 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/layout/participants_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
14 |
15 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/menu/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/menu/lobbies_list_context_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/values-de/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | RetroShare Remote
4 | Hello world!
5 | Settings
6 | RetroShare Remote
7 | Verbinden
8 |
9 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RetroShare
3 | Yet Another Not Implemented Yet
4 | Settings
5 | Terminate
6 | Do you really want to terminate RetroShare Android?
7 | RetroShare
8 | Connect
9 | Disconnect
10 | Edit
11 | Save
12 | Title:
13 | Delete
14 | Leave lobby
15 | Join lobby
16 | Show details
17 | send chat
18 | insert message here
19 | peers
20 | chat
21 | chat lobbies
22 | Add Friends
23 | Add as Friend
24 | From Known Peers
25 | Show QR Code
26 | hostname
27 | port
28 | user
29 | Reset Password
30 | Reset Server SSH hostkey
31 | server key not available
32 | password
33 | error
34 | Unknown Error
35 | could not get ip for this hostname
36 | could not contact server. maybe you are not connected to a network.
37 | host refused connection: ip or port wrong or server not running
38 | the servers public is not the same as last time
39 | ssh authentification failed: wrong user or password
40 | error while sending
41 | error while receiving
42 | Remove from Friends
43 | (TODO) system status
44 | connection error
45 | connected
46 | not connected
47 | New message
48 | new private message
49 | new lobby message
50 | Public
51 | Private
52 | from
53 | Topic:
54 | Privacy:
55 | Participants:
56 | bandwidth up/down
57 | network status
58 | files
59 |
60 | - continue
61 | - wait
62 | - pause
63 | - restart
64 | - check
65 | - cancel
66 | - show link as qrcode
67 |
68 | filename:
69 | size:
70 | hash:
71 | download
72 | rate:
73 | search
74 | select server/account
75 | " show password"
76 | save password
77 | new server..
78 | add
79 | enter ssh password
80 | arbitrary name
81 | ssh username
82 | ssh port
83 | new retroshare-nogui server
84 | Are you sure?
85 | Do you really want to delete this server?
86 |
87 |
88 |
89 | org.retroshare.android
90 | RetroShare Account
91 | Chose between available RetroShare account to enable sync
92 | Account Local Name
93 | No Account Selected
94 | You should select an account to register or create another RetroShare account if no one is available before adding it for sync
95 | Server Settings
96 |
97 |
98 |
99 | retroshare
100 |
101 |
102 |
103 | Add Server
104 | Server saved
105 | Server deleted
106 | Please fill in all fields.
107 | Login
108 | Connecting to
109 | Connecting to Service
110 |
111 |
112 |
113 | retroshare
114 | person
115 | hash
116 | name
117 |
118 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/xml/account_preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/xml/authenticator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/res/xml/sync_contacts.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/AddDownloadActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import org.retroshare.android.RsCtrlService.RsMessage;
24 |
25 | import com.google.protobuf.InvalidProtocolBufferException;
26 |
27 | import rsctrl.core.Core;
28 | import rsctrl.core.Core.File;
29 | import rsctrl.core.Core.Status.StatusCode;
30 | import rsctrl.files.Files.RequestControlDownload.Action;
31 | import rsctrl.files.Files.ResponseControlDownload;
32 | import android.net.Uri;
33 | import android.os.Bundle;
34 | import android.view.View;
35 | import android.widget.Button;
36 | import android.widget.TextView;
37 |
38 | public class AddDownloadActivity extends ProxiedActivityBase
39 | {
40 | private static final String TAG="AddDownloadActivity";
41 |
42 | TextView textViewName;
43 | TextView textViewSize;
44 | TextView textViewHash;
45 | TextView textViewResult;
46 |
47 | Button buttonDownload;
48 |
49 | Core.File mFile=null;
50 |
51 | @Override
52 | public void onCreate(Bundle savedInstanceState) {
53 | super.onCreate(savedInstanceState);
54 | setContentView(R.layout.activity_add_download);
55 |
56 | textViewName=(TextView)findViewById(R.id.textViewFileName_DownloadActivity);
57 | textViewSize=(TextView)findViewById(R.id.textViewFileSize_DownloadActivity);
58 | textViewHash=(TextView)findViewById(R.id.textViewFileHash_DownloadActivity);
59 | textViewResult=(TextView)findViewById(R.id.textViewResult_DownloadActivity);
60 |
61 | buttonDownload=(Button)findViewById(R.id.buttonDownload_DownloadActivity);
62 |
63 | buttonDownload.setVisibility(View.GONE);
64 |
65 | if(getIntent().hasExtra("File")){
66 | try{
67 | mFile = File.parseFrom(getIntent().getByteArrayExtra("File"));
68 | }catch (InvalidProtocolBufferException e) { e.printStackTrace(); }
69 | }else{
70 | Uri uri = getIntent().getData();
71 | mFile=File.newBuilder()
72 | .setName(uri.getQueryParameter("name"))
73 | .setHash(uri.getQueryParameter("hash"))
74 | .setSize(Long.parseLong(uri.getQueryParameter("size")))
75 | .build();
76 | }
77 | }
78 |
79 | @Override
80 | protected void onServiceConnected()
81 | {
82 | if(mFile!=null){
83 | textViewName.setText(mFile.getName());
84 | textViewSize.setText(Long.toString(mFile.getSize()));
85 | textViewHash.setText(mFile.getHash());
86 | }
87 | if(getConnectedServer().isOnline()){
88 | buttonDownload.setVisibility(View.VISIBLE);
89 | textViewResult.setVisibility(View.GONE);
90 | }else{
91 | buttonDownload.setVisibility(View.GONE);
92 | textViewResult.setVisibility(View.VISIBLE);
93 | textViewResult.setText("you have to be connected to download a file");
94 | }
95 | }
96 |
97 |
98 | public void onButtonDownloadClick(View v)
99 | {
100 | buttonDownload.setVisibility(View.GONE);
101 | textViewResult.setVisibility(View.VISIBLE);
102 | textViewResult.setText("processing...");
103 | if(mFile!=null){
104 | getConnectedServer().mRsFilesService.sendRequestControlDownload(mFile, Action.ACTION_START,new RsMessageHandler(){
105 |
106 | @Override
107 | protected void rsHandleMsg(RsMessage msg) {
108 | try {
109 | ResponseControlDownload resp=ResponseControlDownload.parseFrom(msg.body);
110 | //textViewResult.setText(resp.getStatus().toString());
111 | if(resp.getStatus().getCode().equals(StatusCode.SUCCESS)){
112 | textViewResult.setText("ok");
113 | }else{
114 | textViewResult.setText("nok");
115 | }
116 | } catch (InvalidProtocolBufferException e) { e.printStackTrace(); }
117 | }
118 |
119 | });
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/AddFriendMethodChooserActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.content.Intent;
24 | import android.os.Bundle;
25 | import android.view.View;
26 |
27 | import rsctrl.core.Core;
28 |
29 |
30 | public class AddFriendMethodChooserActivity extends ProxiedActivityBase
31 | {
32 | @Override
33 | public void onCreateBeforeConnectionInit(Bundle savedInstanceState)
34 | {
35 | setContentView(R.layout.activity_addfriend);
36 | }
37 |
38 | public void onFromKnownPeersButtonPressed(View v)
39 | {
40 | Intent i = new Intent();
41 | i.putExtra(PeersActivity.SHOW_ALL_PEER_EXTRA, true);
42 | startActivity(PeersActivity.class, i);
43 | }
44 |
45 | public void onShowQrCodeButtonPressed(View v)
46 | {
47 | if(isBound())
48 | {
49 | Core.Person p = getConnectedServer().mRsPeersService.getOwnPerson();
50 | Intent i = new Intent();
51 | i.putExtra(ShowQrCodeActivity.PGP_ID_EXTRA, p.getGpgId());
52 | i.putExtra(ShowQrCodeActivity.NAME_EXTRA, p.getName());
53 | startActivity(ShowQrCodeActivity.class, i);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/AddServerActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.app.AlertDialog;
24 | import android.app.Dialog;
25 | import android.content.DialogInterface;
26 | import android.os.Bundle;
27 | import android.view.View;
28 | import android.widget.CheckBox;
29 | import android.widget.EditText;
30 | import android.widget.Toast;
31 |
32 | import org.retroshare.android.utils.Util;
33 |
34 | public class AddServerActivity extends ProxiedActivityBase
35 | {
36 | public final static String EDIT_SERVER_EXTRA = "editServer";
37 | boolean editServer = false;
38 |
39 | @Override
40 | public void onCreateBeforeConnectionInit(Bundle savedInstanceState)
41 | {
42 | setContentView(R.layout.activity_add_server);
43 |
44 | editServer = getIntent().getBooleanExtra(EDIT_SERVER_EXTRA, false);
45 |
46 | View deleteBtn = findViewById(R.id.deleteServerButton);
47 | if(editServer)
48 | {
49 | deleteBtn.setVisibility(View.VISIBLE);
50 | findViewById(R.id.editTextSshKey).setVisibility(View.VISIBLE);
51 | findViewById(R.id.resetPasswordCheckBox).setVisibility(View.VISIBLE);
52 | findViewById(R.id.resetSshServerKeyCheckBox).setVisibility(View.VISIBLE);
53 | findViewById(R.id.editTextName).setEnabled(false);
54 | }
55 | else
56 | {
57 | findViewById(R.id.resetPasswordCheckBox).setVisibility(View.GONE);
58 | findViewById(R.id.editTextSshKey).setVisibility(View.GONE);
59 | findViewById(R.id.resetSshServerKeyCheckBox).setVisibility(View.GONE);
60 | deleteBtn.setVisibility(View.GONE);
61 | }
62 | }
63 |
64 | protected void onServiceConnected()
65 | {
66 | if(isBound() && editServer)
67 | {
68 | EditText editTextName = (EditText) findViewById(R.id.editTextName);
69 | EditText editTextHostname = (EditText) findViewById(R.id.editTextHostname);
70 | EditText editTextPort = (EditText) findViewById(R.id.editTextPort);
71 | EditText editTextUser = (EditText) findViewById(R.id.editTextUser);
72 | EditText editTextSshKey = (EditText) findViewById(R.id.editTextSshKey);
73 |
74 | RsServerData sd = rsProxy.getSavedServers().get(serverName);
75 | editTextName.setText(sd.name);
76 | editTextHostname.setText(sd.hostname);
77 | editTextPort.setText(String.valueOf(sd.port));
78 | editTextUser.setText(sd.user);
79 | try { editTextSshKey.setText(sd.getHostkeyFingerprint()); } catch (Exception e) {}
80 | }
81 | }
82 |
83 | public void onSaveButtonPressed(View v)
84 | {
85 | if(isBound())
86 | {
87 | EditText editTextName = (EditText) findViewById(R.id.editTextName);
88 | EditText editTextHostname = (EditText) findViewById(R.id.editTextHostname);
89 | EditText editTextPort = (EditText) findViewById(R.id.editTextPort);
90 | EditText editTextUser = (EditText) findViewById(R.id.editTextUser);
91 | CheckBox resetPwdChkb = (CheckBox) findViewById(R.id.resetPasswordCheckBox);
92 | CheckBox resetSshSrvKey = (CheckBox) findViewById(R.id.resetSshServerKeyCheckBox);
93 |
94 | if(!Util.hasContent(editTextPort) || !Util.hasContent(editTextName) || !Util.hasContent(editTextHostname) || !Util.hasContent(editTextUser))
95 | {
96 | Toast.makeText(getApplicationContext(), getText(R.string.missing_input), Toast.LENGTH_LONG).show();
97 | return;
98 | }
99 |
100 | RsServerData sd;
101 | if(editServer) sd = rsProxy.getSavedServers().get(serverName);
102 | else sd = new RsServerData();
103 |
104 | sd.name = editTextName.getText().toString();
105 | sd.hostname = editTextHostname.getText().toString();
106 |
107 | if(Util.hasContent(editTextPort)) sd.port = Integer.parseInt(editTextPort.getText().toString());
108 |
109 | sd.user = editTextUser.getText().toString();
110 |
111 | if(resetPwdChkb.isChecked())
112 | {
113 | sd.password = null;
114 | sd.savePassword = false;
115 | }
116 |
117 | if(resetSshSrvKey.isChecked()) sd.hostkey = null;
118 |
119 | rsProxy.delServer(sd.name);
120 | rsProxy.addServer(sd);
121 | Toast.makeText(getApplicationContext(), getText(R.string.server_saved), Toast.LENGTH_SHORT).show();
122 | startActivity(MainActivity.class);
123 | }
124 | }
125 |
126 | public void onDeleteButtonPressed(View v) { showDialog(DIALOG_DELETE_SERVER); }
127 |
128 | private static final int DIALOG_DELETE_SERVER = 0;
129 | @Override
130 | protected Dialog onCreateDialog(int id)
131 | {
132 | switch (id)
133 | {
134 | case DIALOG_DELETE_SERVER:
135 | {
136 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
137 | builder.setTitle(R.string.are_you_sure)
138 | .setMessage(R.string.do_you_want_delete_server)
139 | .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { _deleteServer(); } })
140 | .setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) {} });
141 | return builder.create();
142 | }
143 | }
144 |
145 | return null;
146 | }
147 |
148 | private final void _deleteServer()
149 | {
150 | if(isBound())
151 | {
152 | rsProxy.delServer(serverName);
153 | Toast.makeText(getApplicationContext(), getText(R.string.server_deleted), Toast.LENGTH_SHORT).show();
154 | startActivity(MainActivity.class);
155 | }
156 | }
157 | }
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ConnectingToServiceFragmentDialog.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.app.Dialog;
24 | import android.app.ProgressDialog;
25 | import android.os.Bundle;
26 | import android.support.v4.app.DialogFragment;
27 |
28 | public class ConnectingToServiceFragmentDialog extends DialogFragment
29 | {
30 | @Override public Dialog onCreateDialog(final Bundle savedInstanceState)
31 | {
32 | final ProgressDialog dialog = new ProgressDialog(getActivity());
33 | dialog.setMessage(getString(R.string.connecting_to_rsproxy));
34 | dialog.setIndeterminate(true);
35 | dialog.setCancelable(false);
36 | return dialog;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ContactMethodChooserActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.app.Activity;
24 | import android.content.Intent;
25 | import android.net.Uri;
26 | import android.os.Bundle;
27 | import android.util.Log;
28 |
29 | import org.retroshare.android.RsConversationService.PgpChatId;
30 |
31 |
32 | public class ContactMethodChooserActivity extends Activity
33 | {
34 | public String TAG() { return "ContactMethodChooserActivity"; }
35 |
36 | private String serverName;
37 | private String pgpId;
38 |
39 |
40 | @Override
41 | public void onCreate(Bundle savedInstanceState)
42 | {
43 | super.onCreate(savedInstanceState);
44 |
45 | Log.d(TAG(), "onCreate(Bundle savedInstanceState)");
46 |
47 | Uri uri = getIntent().getData();
48 | if ( uri != null )
49 | {
50 | String sp[] = uri.getPath().split("/");
51 |
52 | serverName = sp[1];
53 | pgpId = sp[2];
54 |
55 | Intent i = new Intent(this, ConversationFragmentActivity.class);
56 | i.putExtra(ConversationFragmentActivity.SERVER_NAME_EXTRA_KEY, serverName);
57 | i.putExtra(ConversationFragmentActivity.CONVERSATION_ID_EXTRA_KEY, PgpChatId.Factory.getPgpChatId(pgpId));
58 | // Log.d(TAG(), "Launching ConversationFragmentActivity with SERVER_NAME_EXTRA=" + serverName + ", for pgpid=" + pgpId );
59 | startActivity(i);
60 |
61 | // Finishing right after launching the new activity no problem because we set nohistory in the manifest (http://developer.android.com/guide/topics/manifest/activity-element.html#nohist)
62 | finish();
63 | }
64 | else finish(); // How did we get here without data?
65 | }
66 | }
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ConversationFragmentActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.content.Intent;
24 | import android.os.Bundle;
25 | import android.support.v4.app.Fragment;
26 | import android.support.v4.app.FragmentManager;
27 | import android.support.v4.app.FragmentTransaction;
28 |
29 | import org.retroshare.android.RsConversationService.ConversationId;
30 |
31 |
32 | public class ConversationFragmentActivity extends ProxiedFragmentActivityBase
33 | {
34 | public static final String CONVERSATION_ID_EXTRA_KEY = ConversationFragment.CONVERSATION_ID_EXTRA_KEY;
35 |
36 | @Override public void onCreate(Bundle savedInstanceState)
37 | {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.factivity_conversation);
40 |
41 | onNewIntent(getIntent());
42 | }
43 |
44 | private ConversationId lastConversationId;
45 | @Override protected void onNewIntent(Intent intent)
46 | {
47 | super.onNewIntent(intent);
48 |
49 | final ConversationId conversationId;
50 | if(intent.hasExtra(CONVERSATION_ID_EXTRA_KEY)) conversationId = intent.getParcelableExtra(CONVERSATION_ID_EXTRA_KEY);
51 | else throw new RuntimeException(TAG() + " need firing intent contains valid value for " + CONVERSATION_ID_EXTRA_KEY);
52 |
53 | if(!conversationId.equals(lastConversationId))
54 | {
55 | lastConversationId = conversationId;
56 |
57 | Bundle fragmentArgs = new Bundle(1);
58 | fragmentArgs.putString(ConversationFragment.SERVER_NAME_EXTRA_KEY, serverName);
59 | fragmentArgs.putParcelable(ConversationFragment.CONVERSATION_ID_EXTRA_KEY, conversationId);
60 |
61 | ConversationFragment conversationFragment = new ConversationFragment();
62 | conversationFragment.setArguments(fragmentArgs);
63 |
64 | FragmentManager fragmentManager = getSupportFragmentManager();
65 | FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
66 | fragmentTransaction.replace(R.id.conversationFragmentContainer, conversationFragment);
67 | fragmentTransaction.commit();
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ConversationInfoDialogFragment.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.content.Context;
24 | import android.os.Bundle;
25 | import android.support.v4.app.DialogFragment;
26 | import android.view.LayoutInflater;
27 | import android.view.View;
28 | import android.view.ViewGroup;
29 | import android.widget.ArrayAdapter;
30 | import android.widget.ListView;
31 | import android.widget.TextView;
32 |
33 | public class ConversationInfoDialogFragment extends DialogFragment
34 | {
35 | public static final String CONVERSATION_INFO_EXTRA = "org.retroshare.android.ConversationInfoDialogFragment.CONVERSATION_INFO_EXTRA";
36 |
37 | private final Context mContext;
38 | public ConversationInfoDialogFragment(Context context) { mContext = context; }
39 |
40 | @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
41 | {
42 | super.onCreateView(inflater, container, savedInstanceState);
43 |
44 | getDialog().setTitle("Conversation Details");
45 |
46 | RsConversationService.ConversationInfo conversationInfo = getArguments().getParcelable(CONVERSATION_INFO_EXTRA);
47 |
48 | View a = inflater.inflate(R.layout.conversation_info_fragment_layout, container);
49 |
50 | TextView privacyTextView = (TextView)a.findViewById(R.id.conversation_info_privacy);
51 | if(conversationInfo.isPrivate()) privacyTextView.setText(R.string._private);
52 | else privacyTextView.setText(R.string._public);
53 |
54 | if(conversationInfo.hasTitle())
55 | {
56 | a.findViewById(R.id.conversation_info_title_layout).setVisibility(View.VISIBLE);
57 | ((TextView) a.findViewById(R.id.conversation_info_title)).setText(conversationInfo.getTitle());
58 | }
59 | else a.findViewById(R.id.conversation_info_title_layout).setVisibility(View.GONE);
60 |
61 | if(conversationInfo.hasTopic())
62 | {
63 | a.findViewById(R.id.conversation_info_topic_layout).setVisibility(View.VISIBLE);
64 | ((TextView) a.findViewById(R.id.conversation_info_topic)).setText(conversationInfo.getTopic());
65 | }
66 | else a.findViewById(R.id.conversation_info_topic_layout).setVisibility(View.GONE);
67 |
68 | if(conversationInfo.getParticipantsCount() > 0)
69 | {
70 | a.findViewById(R.id.conversation_info_participants_layout).setVisibility(View.VISIBLE);
71 | ArrayAdapter adapter = new ArrayAdapter(mContext, R.layout.participants_list_item, R.id.participant_name_text_view);
72 | ((ListView) a.findViewById(R.id.conversation_info_participants)).setAdapter(adapter);
73 | for(CharSequence nick : conversationInfo.getParticipantsNick()) adapter.add(nick);
74 | }
75 | else a.findViewById(R.id.conversation_info_participants_layout).setVisibility(View.GONE);
76 |
77 | return a;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/HandlerThreadInterface.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 |
24 | public interface HandlerThreadInterface
25 | {
26 | /**
27 | * Posts a Runnable Object to the UI Thread and calls r.run() in UI Thread
28 | * @param r Runnable to run in UI Thread
29 | */
30 | public void postToHandlerThread(Runnable r);
31 | }
32 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ListSearchesActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import java.util.ArrayList;
24 | import java.util.HashMap;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | import org.retroshare.android.RsSearchService.SearchResponseHandler;
29 |
30 | import android.content.Context;
31 | import android.content.Intent;
32 | import android.database.DataSetObserver;
33 | import android.os.Bundle;
34 | import android.util.Log;
35 | import android.view.KeyEvent;
36 | import android.view.LayoutInflater;
37 | import android.view.View;
38 | import android.view.ViewGroup;
39 | import android.view.View.OnKeyListener;
40 | import android.widget.AdapterView;
41 | import android.widget.EditText;
42 | import android.widget.ListAdapter;
43 | import android.widget.ListView;
44 | import android.widget.TextView;
45 | import android.widget.AdapterView.OnItemClickListener;
46 | import android.widget.AdapterView.OnItemLongClickListener;
47 |
48 | public class ListSearchesActivity extends ProxiedActivityBase
49 | {
50 |
51 | private static final String TAG="ListSearchesActivity";
52 |
53 | private EditText editText;
54 | private ListView listView;
55 |
56 | private SearchListAdapterListener adapter;
57 |
58 | @Override
59 | public void onCreate(Bundle savedInstanceState) {
60 | super.onCreate(savedInstanceState);
61 |
62 | setContentView(R.layout.activity_listsearches);
63 |
64 | editText=(EditText) findViewById(R.id.searchEditText_ListSearchesActivity);
65 | listView=(ListView) findViewById(R.id.searchListView_ListSearchesActivity);
66 |
67 | editText.setOnKeyListener(new KeyListener());
68 |
69 | adapter=new SearchListAdapterListener(this);
70 | listView.setAdapter(adapter);
71 | listView.setOnItemClickListener(adapter);
72 | listView.setOnItemLongClickListener(adapter);
73 | }
74 |
75 | private class KeyListener implements OnKeyListener
76 | {
77 | @Override
78 | public boolean onKey(View v, int keyCode, KeyEvent event) {
79 |
80 | if((event.getAction()==KeyEvent.ACTION_DOWN)&(event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
81 | {
82 | Log.v(TAG,"KeyListener.onKey() event.getKeyCode() == KeyEvent.KEYCODE_ENTER");
83 | getConnectedServer().mRsSearchService.sendRequestBasicSearch(editText.getText().toString(), new ResponseHandler());
84 | return true;
85 | }
86 | else return false;
87 | }
88 |
89 | }
90 |
91 | // needed, because we know dont know the serach id before we received the result
92 | private class ResponseHandler implements SearchResponseHandler
93 | {
94 | @Override
95 | public void onSearchResponseReceived(int id)
96 | {
97 | Intent i=new Intent(ListSearchesActivity.this,ShowSearchResultsActivity.class);
98 | i.putExtra("SearchId", id);
99 | Log.v(TAG, "ResponseHandler: starting ShowSearchResultsActivity with Id "+Integer.toString(id));
100 | startActivity(i);
101 | }
102 |
103 | }
104 |
105 | @Override
106 | protected void onServiceConnected() { adapter.setData(getConnectedServer().mRsSearchService.getSearches()); }
107 |
108 | @Override
109 | public void onResume()
110 | {
111 | super.onResume();
112 | if(isBound()) adapter.setData(getConnectedServer().mRsSearchService.getSearches());
113 | }
114 |
115 | private class SearchListAdapterListener implements ListAdapter, OnItemClickListener, OnItemLongClickListener
116 | {
117 |
118 | private Map searchIdFromIndex=new HashMap();
119 | private List list=new ArrayList();
120 |
121 | private List observerList=new ArrayList();
122 |
123 | private LayoutInflater mInflater;
124 |
125 | public SearchListAdapterListener(Context context) {
126 | mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
127 | }
128 |
129 | public void setData(Map s){
130 | searchIdFromIndex.clear();
131 | list.clear();
132 | int i=0;
133 | for(Map.Entry e:s.entrySet()){
134 | list.add(e.getValue());
135 | searchIdFromIndex.put(i, e.getKey());
136 | }
137 | for(DataSetObserver obs:observerList){
138 | obs.onChanged();
139 | }
140 | }
141 |
142 | @Override
143 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
144 | Intent i=new Intent(ListSearchesActivity.this,ShowSearchResultsActivity.class);
145 | i.putExtra("SearchId", searchIdFromIndex.get(position));
146 | startActivity(i);
147 | }
148 |
149 | @Override
150 | public boolean onItemLongClick(AdapterView> arg0, View arg1, int position, long id) {
151 | /*Location loc=locationList.get(position);
152 | Person p=mapLocationToPerson.get(loc);
153 | Intent i=new Intent(PeersActivity.this,PeerDetailsActivity.class);
154 | i.putExtra("GpgId", p.getGpgId());
155 | i.putExtra("SslId", loc.getSslId());
156 | startActivity(i);*/
157 | return true;
158 | }
159 |
160 | @Override
161 | public int getCount() {
162 | return list.size();
163 | }
164 |
165 | @Override
166 | public Object getItem(int position) {
167 | return list.get(position);
168 | }
169 |
170 | @Override public long getItemId(int position) { return 0; }
171 |
172 | @Override
173 | public int getItemViewType(int position) {
174 | return 0;
175 | }
176 |
177 | @Override
178 | public View getView(int position, View convertView, ViewGroup parent) {
179 | TextView tv=new TextView(parent.getContext());
180 | tv.setText(list.get(position));
181 | return tv;
182 | }
183 |
184 | @Override
185 | public int getViewTypeCount() {
186 | return 1;
187 | }
188 |
189 | @Override
190 | public boolean hasStableIds() { return false; }
191 |
192 | @Override
193 | public boolean isEmpty() {
194 | return list.isEmpty();
195 | }
196 |
197 | @Override
198 | public void registerDataSetObserver(DataSetObserver observer) {
199 | observerList.add(observer);
200 | }
201 |
202 | @Override
203 | public void unregisterDataSetObserver(DataSetObserver observer) {
204 | observerList.remove(observer);
205 | }
206 |
207 | @Override public boolean areAllItemsEnabled() {return true;}
208 | @Override public boolean isEnabled(int position) {return true;}
209 |
210 | }
211 | }
212 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/LobbiesListFragmentActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.content.Intent;
24 | import android.os.Bundle;
25 | import android.support.v4.app.FragmentManager;
26 | import android.support.v4.app.FragmentTransaction;
27 |
28 |
29 | public class LobbiesListFragmentActivity extends ProxiedFragmentActivityBase
30 | {
31 | @Override public void onCreate(Bundle savedInstanceState)
32 | {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.factivity_lobbieslist);
35 |
36 | onNewIntent(getIntent());
37 | }
38 |
39 | @Override protected void onNewIntent(Intent intent)
40 | {
41 | super.onNewIntent(intent);
42 |
43 | Bundle fragmentArgs = new Bundle(1);
44 | fragmentArgs.putString(LobbiesListFragment.SERVER_NAME_EXTRA_KEY, serverName);
45 |
46 | LobbiesListFragment lobbiesListFragment = new LobbiesListFragment();
47 | lobbiesListFragment.setArguments(fragmentArgs);
48 |
49 | FragmentManager fragmentManager = getSupportFragmentManager();
50 | FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
51 | fragmentTransaction.replace(R.id.lobbyListFragmentContainer, lobbiesListFragment);
52 | fragmentTransaction.commit();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/PeerDetailsActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.content.Intent;
24 | import android.net.Uri;
25 | import android.os.Bundle;
26 | import android.view.View;
27 | import android.widget.Button;
28 | import android.widget.TextView;
29 |
30 | import rsctrl.core.Core.Person;
31 | import rsctrl.peers.Peers;
32 |
33 |
34 | public class PeerDetailsActivity extends ProxiedActivityBase implements RsPeersService.PeersServiceListener
35 | {
36 | public String TAG() { return "PeerDetailsActivity"; }
37 |
38 | public final static String PGP_ID_EXTRA = "pgpId";
39 | private String pgpId;
40 | private String name;
41 | private boolean fromExtIntent = false;
42 |
43 | @Override
44 | public void onCreateBeforeConnectionInit(Bundle savedInstanceState)
45 | {
46 | if (serverName == null)
47 | {
48 | fromExtIntent = true;
49 | Intent i = new Intent(this, ServerChooserActivity.class);
50 | startActivityForResult(i, 0);
51 | }
52 |
53 | setContentView(R.layout.activity_peerdetails);
54 |
55 | Intent i = getIntent();
56 | if(fromExtIntent)
57 | {
58 | Uri uri = i.getData();
59 | pgpId = uri.getQueryParameter(getString(R.string.hash_uri_query_param));
60 | name = uri.getQueryParameter(getString(R.string.name_uri_query_param));
61 | }
62 | else pgpId = i.getStringExtra(PGP_ID_EXTRA);
63 | }
64 |
65 | @Override
66 | public void onActivityResult(int requestCode, int resultCode, Intent data)
67 | {
68 | if (resultCode == RESULT_OK)
69 | {
70 | serverName = data.getStringExtra(SERVER_NAME_EXTRA);
71 | updateViews();
72 | }
73 | }
74 |
75 | @Override
76 | public void onServiceConnected() { updateViews(); }
77 |
78 | public void onToggleFriendshipButtonPressed(View v)
79 | {
80 | if(isBound())
81 | {
82 | RsPeersService prs = getConnectedServer().mRsPeersService;
83 |
84 | Person p;
85 | if(fromExtIntent) p = Person.newBuilder().setGpgId(pgpId).setName(name).setRelation(Person.Relationship.UNKNOWN).build();
86 | else p = prs.getPersonByPgpId(pgpId);
87 |
88 | boolean makeFriend = ! ( p.getRelation() == Person.Relationship.FRIEND );
89 | prs.requestSetFriend(p, makeFriend);
90 |
91 | prs.requestPersonsUpdate(Peers.RequestPeers.SetOption.ALL, Peers.RequestPeers.InfoOption.ALLINFO);
92 |
93 | finish();
94 | }
95 | }
96 |
97 | private void updateViews()
98 | {
99 | if (serverName == null) return;
100 |
101 | Person.Relationship r;
102 |
103 | if(fromExtIntent)
104 | {
105 | r = Person.Relationship.UNKNOWN;
106 | }
107 | else
108 | {
109 | Person p = getConnectedServer().mRsPeersService.getPersonByPgpId(pgpId);
110 | name = p.getName();
111 | r = p.getRelation();
112 | }
113 |
114 | TextView nameTextView = (TextView) findViewById(R.id.peerNameTextView);
115 | TextView pgpIdTextView = (TextView) findViewById(R.id.pgpIdTextView);
116 | Button toggleFriendshipButton = (Button) findViewById(R.id.buttonToggleFriendship);
117 |
118 | nameTextView.setText(name);
119 | pgpIdTextView.setText(pgpId);
120 |
121 | if ( r.equals(Person.Relationship.YOURSELF) ) toggleFriendshipButton.setVisibility(View.GONE);
122 | else if ( r.equals(Person.Relationship.FRIEND) ) toggleFriendshipButton.setText(R.string.block_friend);
123 | else toggleFriendshipButton.setText(R.string.add_as_friend);
124 | }
125 |
126 | @Override
127 | public void update()
128 | {
129 | updateViews();
130 | }
131 |
132 | public void onShowPeerQrCodeButtonPressed(View v)
133 | {
134 | RsPeersService prs = getConnectedServer().mRsPeersService;
135 |
136 | Person p;
137 | if(fromExtIntent) p = Person.newBuilder().setGpgId(pgpId).setName(name).setRelation(Person.Relationship.UNKNOWN).build();
138 | else p = prs.getPersonByPgpId(pgpId);
139 |
140 | Intent i = new Intent();
141 | i.putExtra(ShowQrCodeActivity.PGP_ID_EXTRA, p.getGpgId());
142 | i.putExtra(ShowQrCodeActivity.NAME_EXTRA, p.getName());
143 | startActivity(ShowQrCodeActivity.class, i);
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ProxiedActivityBase.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.app.Activity;
24 | import android.content.ComponentName;
25 | import android.content.Intent;
26 | import android.content.ServiceConnection;
27 | import android.os.Bundle;
28 | import android.os.IBinder;
29 | import android.util.Log;
30 | import android.view.View;
31 | import android.widget.ProgressBar;
32 |
33 |
34 | /**
35 | * @author G10h4ck
36 | * This class is aimed to be inherited by Activityes that needs to communicate with RsService
37 | * provide out of the box almost all needed stuff to communicate with RsService
38 | * so each activity doesn't need to handle all this common stuff
39 | */
40 | public abstract class ProxiedActivityBase extends Activity implements ServiceConnection
41 | {
42 | public String TAG() { return "ProxiedActivityBase"; }
43 |
44 | protected RetroShareAndroidProxy rsProxy;
45 | protected ProgressBar rsProxyConnectionProgressBar;
46 |
47 | private boolean mBound = false;
48 | public boolean isBound(){return mBound;}
49 | protected void setBound(boolean v) { mBound = v; }
50 |
51 | public static final String SERVER_NAME_EXTRA = "org.retroshare.android.intent_extra_keys.serverName";
52 | protected String serverName;
53 |
54 | private boolean isInForeground = false;
55 | public boolean isForeground() { return isInForeground; }
56 |
57 | /**
58 | * This method should be overridden by child classes that want to do something between Activity.onCreate and connection initialization it is guaranteed to be executed before onServiceConnected
59 | * It is suggested for inflating your activity layout, so you are sure that your widget are in the right place when onServiceConnected() is called
60 | */
61 | protected void onCreateBeforeConnectionInit(Bundle savedInstanceState)
62 | {}
63 |
64 | /**
65 | * This method should be overridden by child classes that want to do something when connection to RetroShareAndroidProxy is available.
66 | */
67 | protected void onServiceConnected()
68 | {}
69 |
70 | /**
71 | * Get Actual server
72 | * @return The actual server if bound, null otherwise
73 | */
74 | public RsCtrlService getConnectedServer()
75 | {
76 | if(isBound()) return rsProxy.activateServer(serverName);
77 | throw new RuntimeException(TAG() + " getConnectedServer() called before binding");
78 | }
79 |
80 | @Override
81 | public void onServiceConnected(ComponentName className, IBinder service)
82 | {
83 | // Log.d(TAG(), "onServiceConnected(ComponentName className, IBinder service)");
84 |
85 | RetroShareAndroidProxy.RsProxyBinder binder = (RetroShareAndroidProxy.RsProxyBinder) service;
86 | rsProxy = binder.getService();
87 | setBound(true);
88 | if(rsProxy.mUiThreadHandler == null) rsProxy.mUiThreadHandler = new RetroShareAndroidProxy.HandlerThread();
89 | onServiceConnected();
90 | rsProxyConnectionProgressBar.setVisibility(View.GONE);
91 | }
92 |
93 | @Override
94 | public void onServiceDisconnected(ComponentName arg0)
95 | {
96 | // Log.d(TAG(), "onServiceDisconnected(" + arg0.toShortString() + ")" );
97 | setBound(false);
98 | }
99 |
100 | @Override
101 | public void onCreate(Bundle savedInstanceState)
102 | {
103 | super.onCreate(savedInstanceState);
104 |
105 | rsProxyConnectionProgressBar = new ProgressBar(this);
106 | rsProxyConnectionProgressBar.setIndeterminate(true);
107 | rsProxyConnectionProgressBar.setVisibility(View.VISIBLE);
108 |
109 | serverName = getIntent().getStringExtra(SERVER_NAME_EXTRA);
110 | onCreateBeforeConnectionInit(savedInstanceState);
111 | _bindRsService();
112 | }
113 |
114 | @Override
115 | public void onDestroy()
116 | {
117 | _unBindRsService();
118 | super.onDestroy();
119 | }
120 |
121 | protected void _bindRsService()
122 | {
123 | // Log.d(TAG(), "_bindRsService()");
124 |
125 | if(isBound()) return;
126 |
127 | Intent intent = new Intent(this, RetroShareAndroidProxy.class);
128 | getApplicationContext().startService(intent);
129 | getApplicationContext().bindService(intent, this, 0);
130 | }
131 |
132 | protected void _unBindRsService()
133 | {
134 | // Log.d(TAG(), "_unBindRsService()");
135 |
136 | if(isBound())
137 | {
138 | getApplicationContext().unbindService(this);
139 | setBound(false);
140 | }
141 | }
142 |
143 | /**
144 | * This method launch an activity putting the server name as intent extra data transparently
145 | * @param cls The activity to launch like MainActivity.class
146 | */
147 | public void startActivity(Class> cls) { startActivity(cls, new Intent()); };
148 |
149 | /**
150 | * This method launch an activity adding the server name in the already forged intent extra data transparently
151 | * @param cls The activity to launch like MainActivity.class
152 | */
153 | public void startActivity(Class> cls, Intent i)
154 | {
155 | i.setClass(this, cls);
156 | startActivity(i);
157 | }
158 |
159 | /**
160 | * @{inheritDoc}
161 | */
162 | @Override
163 | public void startActivity(Intent i)
164 | {
165 | i.putExtra(SERVER_NAME_EXTRA, serverName);
166 | super.startActivity(i);
167 | }
168 |
169 | @Override
170 | public void onPause()
171 | {
172 | super.onPause();
173 | isInForeground = false;
174 | }
175 |
176 | @Override
177 | public void onResume()
178 | {
179 | super.onResume();
180 | isInForeground = true;
181 | }
182 | }
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ProxiedFragmentActivityBase.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.content.ComponentName;
24 | import android.content.Intent;
25 | import android.content.ServiceConnection;
26 | import android.os.Bundle;
27 | import android.os.IBinder;
28 | import android.support.v4.app.Fragment;
29 | import android.support.v4.app.FragmentActivity;
30 | import android.util.Log;
31 |
32 | import org.retroshare.android.utils.WeakHashSet;
33 |
34 | import java.util.Collection;
35 |
36 |
37 | /**
38 | * This class is aimed to be inherited by FragmentActivityes that needs to communicate with RsService
39 | * provide out of the box almost all needed stuff to communicate with RsService
40 | * so each activity doesn't need to handle all this common stuff
41 | */
42 | public abstract class ProxiedFragmentActivityBase extends FragmentActivity implements ServiceConnection, ProxiedInterface, RsClientInterface
43 | {
44 | public String TAG() { return "ProxiedFragmentActivityBase"; }
45 |
46 | /**
47 | * Activity Life Cicle stuff
48 | */
49 |
50 | /**
51 | * This method should be overridden by child classes that want to do something between Activity.onCreate and connection initialization it is guaranteed to be executed before onServiceConnected
52 | * It is suggested for inflating your activity layout, so you are sure that your widget are in the right place when onServiceConnected() is called
53 | */
54 | protected void onCreateBeforeConnectionInit(Bundle savedInstanceState) {}
55 | @Override public void onCreate(Bundle savedInstanceState)
56 | {
57 | super.onCreate(savedInstanceState);
58 |
59 | onNewIntent(getIntent());
60 | onCreateBeforeConnectionInit(savedInstanceState);
61 | _bindRsService();
62 | }
63 | @Override public void onDestroy()
64 | {
65 | _unBindRsService();
66 | super.onDestroy();
67 | }
68 | @Override public void onPause()
69 | {
70 | super.onPause();
71 | isInForeground = false;
72 | }
73 | @Override public void onResume()
74 | {
75 | super.onResume();
76 | isInForeground = true;
77 | if(!isBound()) showConnectingToServiceFragmentDialog();
78 | }
79 | private boolean isInForeground = false;
80 | public boolean isForeground() { return isInForeground; }
81 |
82 | /**
83 | * "Connecting to Service" dialog stuff
84 | */
85 | protected static final String CONNECTING_TO_SERVIE_FRAGMENT_DIALOG_TAG = "org.retroshare.android.ConnectingToServiceFragmentDialog";
86 | protected void showConnectingToServiceFragmentDialog()
87 | {
88 | ConnectingToServiceFragmentDialog cfd = new ConnectingToServiceFragmentDialog();
89 | cfd.show(getSupportFragmentManager(), CONNECTING_TO_SERVIE_FRAGMENT_DIALOG_TAG);
90 | }
91 | protected void hideConnectingToServiceFragmentDialog()
92 | {
93 | ConnectingToServiceFragmentDialog cfd = (ConnectingToServiceFragmentDialog) getSupportFragmentManager().findFragmentByTag(CONNECTING_TO_SERVIE_FRAGMENT_DIALOG_TAG);
94 | if( cfd == null) Log.e(TAG(), "hideConnectingToServiceFragmentDialog() called before showConnectingToServiceFragmentDialog() ?");
95 | else cfd.dismiss();
96 | }
97 |
98 | /**
99 | * Commodity startActivity
100 | */
101 |
102 | /**
103 | * This method launch an activity putting the server name as intent extra data transparently
104 | * @param cls The activity to launch like MainActivity.class
105 | */
106 | public void startActivity(Class> cls) { startActivity(cls, new Intent()); };
107 | /**
108 | * This method launch an activity adding the server name in the already forged intent extra data transparently
109 | * @param cls The activity to launch like MainActivity.class
110 | */
111 | public void startActivity(Class> cls, Intent i)
112 | {
113 | i.setClass(this, cls);
114 | startActivity(i);
115 | }
116 | /**
117 | * @{inheritDoc}
118 | */
119 | @Override public void startActivity(Intent i)
120 | {
121 | i.putExtra(SERVER_NAME_EXTRA_KEY, serverName);
122 | super.startActivity(i);
123 | }
124 |
125 | /**
126 | * Service Connection stuff
127 | */
128 | private RetroShareAndroidProxy rsProxy;
129 | public RetroShareAndroidProxy getRsProxy() { return rsProxy; } /** Implements ProxiedInterface */
130 | private boolean mBound = false;
131 | protected void setBound(boolean v) { mBound = v; }
132 | public boolean isBound() { return mBound; } /** Implements ProxiedInterface */
133 | public void onServiceConnected(ComponentName className, IBinder service) /** Implements ServiceConnection */
134 | {
135 | RetroShareAndroidProxy.RsProxyBinder binder = (RetroShareAndroidProxy.RsProxyBinder) service;
136 | rsProxy = binder.getService();
137 | setBound(true);
138 | if(rsProxy.mUiThreadHandler == null) rsProxy.mUiThreadHandler = new RetroShareAndroidProxy.HandlerThread();
139 | if(isForeground()) hideConnectingToServiceFragmentDialog();
140 | }
141 | public void onServiceDisconnected(ComponentName arg0) /** Implements ServiceConnection */ { setBound(false); }
142 | protected void _bindRsService()
143 | {
144 | if(!isBound())
145 | {
146 | Intent intent = new Intent(this, RetroShareAndroidProxy.class);
147 | getApplicationContext().startService(intent);
148 | getApplicationContext().bindService(intent, this, 0);
149 | }
150 | }
151 | protected void _unBindRsService()
152 | {
153 | if(isBound())
154 | {
155 | getApplicationContext().unbindService(this);
156 | setBound(false);
157 | }
158 | }
159 |
160 |
161 | /**
162 | * RsClientInterface stuff
163 | */
164 | protected String serverName;
165 | @Override protected void onNewIntent(Intent i)
166 | {
167 | super.onNewIntent(i);
168 | if(i.hasExtra(SERVER_NAME_EXTRA_KEY)) serverName = i.getStringExtra(SERVER_NAME_EXTRA_KEY);
169 | }
170 | public RsCtrlService getConnectedServer() /** Implements RsClientInterface */
171 | {
172 | if(isBound()) return rsProxy.activateServer(serverName);
173 | throw new RuntimeException(TAG() + " getConnectedServer() called before binding");
174 | }
175 |
176 | }
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ProxiedFragmentBase.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.app.Activity;
24 | import android.content.ComponentName;
25 | import android.content.Intent;
26 | import android.content.ServiceConnection;
27 | import android.os.IBinder;
28 | import android.support.v4.app.Fragment;
29 | import android.util.Log;
30 |
31 |
32 | /**
33 | * This class is aimed to be inherited by Fragments that needs to communicate with RsService
34 | * provide out of the box almost all needed stuff to communicate with RsService
35 | * so each fragment doesn't need to handle all this common stuff
36 | */
37 | public abstract class ProxiedFragmentBase extends Fragment implements ServiceConnection, ProxiedInterface
38 | {
39 | public String TAG() { return "ProxiedFragmentBase"; }
40 |
41 |
42 | /**
43 | * Life Cicle stuff
44 | */
45 |
46 | private boolean notPaused = false;
47 |
48 | /**
49 | * @return true if it is visible to the user, false otherwise
50 | */
51 | public boolean isUserVisible() { return notPaused; }
52 |
53 | @Override public void onPause()
54 | {
55 | notPaused = false;
56 | super.onPause();
57 | }
58 | @Override public void onResume()
59 | {
60 | super.onResume();
61 | notPaused = true;
62 | }
63 |
64 |
65 |
66 | /**
67 | * Service Connection stuff
68 | */
69 | private RetroShareAndroidProxy rsProxy;
70 | public RetroShareAndroidProxy getRsProxy() { return rsProxy; } /** Implements ProxiedInterface */
71 | private boolean mBound = false;
72 | protected void setBound(boolean v) { mBound = v; }
73 | public boolean isBound() { return mBound; } /** Implements ProxiedInterface */
74 | public void onServiceConnected(ComponentName className, IBinder service) /** Implements ServiceConnection */
75 | {
76 | RetroShareAndroidProxy.RsProxyBinder binder = (RetroShareAndroidProxy.RsProxyBinder) service;
77 | rsProxy = binder.getService();
78 | setBound(true);
79 | if(rsProxy.mUiThreadHandler == null) rsProxy.mUiThreadHandler = new RetroShareAndroidProxy.HandlerThread();
80 | }
81 | public void onServiceDisconnected(ComponentName className) /** Implements ServiceConnection */
82 | {
83 | setBound(false);
84 | }
85 | @Override public void onAttach(Activity a)
86 | {
87 | super.onAttach(a);
88 | if(!isBound())
89 | {
90 | Intent intent = new Intent(getActivity(), RetroShareAndroidProxy.class);
91 | a.getApplicationContext().startService(intent);
92 | a.getApplicationContext().bindService(intent, this, 0);
93 | }
94 | }
95 | @Override public void onDetach()
96 | {
97 | if(isBound())
98 | {
99 | getActivity().getApplicationContext().unbindService(this);
100 | setBound(false);
101 | }
102 | super.onDetach();
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ProxiedInterface.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | /**
24 | * This interface should be implemented by Proxied Components
25 | */
26 | public interface ProxiedInterface
27 | {
28 | /**
29 | * @return True if the proxy is bound to the backend false otherwise
30 | */
31 | public boolean isBound();
32 |
33 | /**
34 | * @return RetroShare backend proxy
35 | */
36 | public RetroShareAndroidProxy getRsProxy();
37 | }
38 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ProxiedServiceBase.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.app.Service;
24 | import android.content.ComponentName;
25 | import android.content.Context;
26 | import android.content.Intent;
27 | import android.content.ServiceConnection;
28 | import android.os.IBinder;
29 | import android.util.Log;
30 |
31 | /**
32 | * This class is aimed to be inherited by Services that needs to communicate with RsService
33 | * provide out of the box almost all needed stuff to communicate with RsService
34 | * so each service doesn't need to handle all this common stuff
35 | */
36 | public abstract class ProxiedServiceBase extends Service implements ServiceConnection
37 | {
38 | private static final String TAG="ProxiedServiceBase";
39 |
40 | protected RetroShareAndroidProxy rsProxy;
41 | protected boolean mBound = false;
42 |
43 | @Override
44 | public void onServiceConnected(ComponentName className, IBinder service)
45 | {
46 | RetroShareAndroidProxy.RsProxyBinder binder = (RetroShareAndroidProxy.RsProxyBinder) service;
47 | rsProxy = binder.getService();
48 | mBound = true;
49 | Log.v(TAG, "onServiceConnected");
50 | }
51 |
52 | @Override
53 | public void onServiceDisconnected(ComponentName arg0)
54 | {
55 | mBound = false;
56 | Log.v(TAG, "onServiceDisconnected");
57 | }
58 |
59 | private void _bindRsService()
60 | {
61 | Intent intent = new Intent(this, RetroShareAndroidProxy.class);
62 | getApplicationContext().bindService(intent, this, Context.BIND_AUTO_CREATE);
63 | }
64 | private void _unBindRsService() { getApplicationContext().unbindService(this); }
65 |
66 | /**
67 | * This method should be overridden by child classes that want to do something between Services.onCreate and connection initialization it is guaranteed to be executed before onServiceConnected
68 | */
69 | protected void onCreateBeforeConnectionInit()
70 | {}
71 |
72 | @Override
73 | public void onCreate()
74 | {
75 | super.onCreate();
76 | onCreateBeforeConnectionInit();
77 | _bindRsService();
78 | }
79 |
80 | @Override
81 | public void onDestroy()
82 | {
83 | _unBindRsService();
84 | super.onDestroy();
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RSA-CircleN-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RsClientInterface.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | /**
24 | * This interface should be implemented by components that needs to interact with rscore
25 | */
26 | public interface RsClientInterface //TODO: find a better name for this interface
27 | {
28 | public static final String SERVER_NAME_EXTRA_KEY = "org.retroshare.android.intent_extra_keys.serverName";
29 | /**
30 | * @returns The actual server if bound
31 | * @throws RuntimeException if is not bound
32 | */
33 | public RsCtrlService getConnectedServer();
34 | }
35 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RsFilesService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import java.util.ArrayList;
24 | import java.util.HashSet;
25 | import java.util.List;
26 | import java.util.Set;
27 |
28 | import rsctrl.core.Core;
29 | import rsctrl.core.Core.File;
30 | import rsctrl.core.Core.Status.StatusCode;
31 | import rsctrl.files.Files;
32 | import rsctrl.files.Files.RequestControlDownload;
33 | import rsctrl.files.Files.RequestControlDownload.Action;
34 | import rsctrl.files.Files.RequestTransferList;
35 | import rsctrl.files.Files.ResponseTransferList;
36 |
37 | import org.retroshare.android.RsCtrlService.RsMessage;
38 |
39 | import com.google.protobuf.InvalidProtocolBufferException;
40 |
41 | public class RsFilesService implements RsServiceInterface
42 | {
43 | RsCtrlService mRsCtrlService;
44 | HandlerThreadInterface mUiThreadHandler;
45 |
46 | RsFilesService(RsCtrlService s, HandlerThreadInterface u)
47 | {
48 | mRsCtrlService = s;
49 | mUiThreadHandler = u;
50 | }
51 |
52 | public static interface FilesServiceListener
53 | {
54 | public void update();
55 | }
56 |
57 | private SetmListeners = new HashSet();
58 | public void registerListener(FilesServiceListener l) { mListeners.add(l); }
59 | public void unregisterListener(FilesServiceListener l) { mListeners.remove(l); }
60 | private void _notifyListeners() { if(mUiThreadHandler != null) mUiThreadHandler.postToHandlerThread(new Runnable() {
61 | public void run() {
62 | for (FilesServiceListener l : mListeners) l.update();
63 | }
64 | }); }
65 |
66 | List transfersUp = new ArrayList();
67 | public List getTransfersUp() { return transfersUp; }
68 |
69 | List transfersDown = new ArrayList();
70 | public List getTransfersDown() { return transfersDown; }
71 |
72 | public void updateTransfers(Files.Direction d)
73 | {
74 | RequestTransferList.Builder reqb = RequestTransferList.newBuilder();
75 | reqb.setDirection(d);
76 | RsMessage msg=new RsMessage();
77 | msg.msgId = (Core.ExtensionId.CORE_VALUE<<24)|(Core.PackageId.FILES_VALUE<<8)|Files.RequestMsgIds.MsgId_RequestTransferList_VALUE;
78 | msg.body=reqb.build().toByteArray();
79 | mRsCtrlService.sendMsg(msg,new ResponseTransferListHandler(d));
80 | }
81 |
82 | private class ResponseTransferListHandler extends RsMessageHandler
83 | {
84 | Files.Direction mDirection;
85 |
86 | ResponseTransferListHandler(Files.Direction d)
87 | {
88 | super();
89 | mDirection = d;
90 | }
91 |
92 | @Override
93 | protected void rsHandleMsg(RsMessage msg)
94 | {
95 | try
96 | {
97 | ResponseTransferList resp=ResponseTransferList.parseFrom(msg.body);
98 | if(resp.getStatus().getCode().equals(StatusCode.SUCCESS))
99 | {
100 | List files=ResponseTransferList.parseFrom(msg.body).getTransfersList();
101 | if(mDirection.equals(Files.Direction.DIRECTION_UPLOAD)) transfersUp=files;
102 | else transfersDown = files;
103 | _notifyListeners();
104 | }
105 | }
106 | catch (InvalidProtocolBufferException e) { e.printStackTrace(); }
107 | }
108 | }
109 |
110 | @Override
111 | public void handleMessage(RsMessage m) {}
112 |
113 | public void sendRequestControlDownload(File file, Action action,RsMessageHandler handler)
114 | {
115 | RsMessage msg = new RsMessage();
116 | msg.msgId = (Core.ExtensionId.CORE_VALUE<<24)|(Core.PackageId.FILES_VALUE<<8)|Files.RequestMsgIds.MsgId_RequestControlDownload_VALUE;
117 | msg.body = RequestControlDownload.newBuilder().setFile(file).setAction(action).build().toByteArray();
118 | mRsCtrlService.sendMsg(msg,handler);
119 | }
120 | public void sendRequestControlDownload(File file, Action action) { sendRequestControlDownload(file, action, null); }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RsMessageHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 |
24 | import android.os.Handler;
25 |
26 | import org.retroshare.android.RsCtrlService.RsMessage;
27 |
28 | /**
29 | * This is an abstract class used as base for received messages handlers
30 | */
31 | public abstract class RsMessageHandler extends Handler implements Runnable
32 | {
33 |
34 | /**
35 | * Should be implemented in child class, it is a callback called by run() when a message to handle is received
36 | * @param msg The message to handle
37 | */
38 | protected void rsHandleMsg(RsMessage msg) {}
39 |
40 | /**
41 | * Contain the message to handle
42 | */
43 | private RsMessage mMsg;
44 |
45 | /**
46 | * Set the message to handle
47 | * @param m message to set
48 | */
49 | public void setMsg(RsMessage m) { mMsg = m; }
50 |
51 | /**
52 | * {@inheritDoc}
53 | */
54 | @Override
55 | public void run() { rsHandleMsg(mMsg); }
56 | }
57 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RsPeersService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.os.Looper;
24 |
25 | import java.util.ArrayList;
26 | import java.util.Collection;
27 | import java.util.HashMap;
28 | import java.util.HashSet;
29 | import java.util.List;
30 | import java.util.Map;
31 | import java.util.Set;
32 |
33 | import rsctrl.core.Core;
34 | import rsctrl.core.Core.Location;
35 | import rsctrl.core.Core.Person;
36 | import rsctrl.peers.Peers;
37 | import rsctrl.peers.Peers.RequestPeers;
38 | import rsctrl.peers.Peers.ResponsePeerList;
39 |
40 | import org.retroshare.android.RsCtrlService.RsMessage;
41 |
42 | import com.google.protobuf.InvalidProtocolBufferException;
43 |
44 | public class RsPeersService implements RsServiceInterface
45 | {
46 | private static final String TAG() { return "RsPeersService"; }
47 |
48 | RsCtrlService mRsCtrlService;
49 | HandlerThreadInterface mUiThreadHandler;
50 |
51 | OwnIdReceivedHandler mOwnIdReceivedHandler;
52 | Thread mOwnIdReceivedHandlerThread;
53 |
54 | RsPeersService(RsCtrlService s, HandlerThreadInterface u)
55 | {
56 | mRsCtrlService = s;
57 | mUiThreadHandler = u;
58 |
59 | // TODO Port/generalize this indipendent from ui message handling system to other Rs*Sevice too
60 | mOwnIdReceivedHandlerThread = new Thread(new Runnable() { @Override public void run() { Looper.prepare(); mOwnIdReceivedHandler = new OwnIdReceivedHandler(); Looper.loop(); } });
61 | mOwnIdReceivedHandlerThread.start();
62 | }
63 |
64 | private class OwnIdReceivedHandler extends RsMessageHandler { @Override protected void rsHandleMsg(RsMessage msg) { try { ownPerson = ResponsePeerList.parseFrom(msg.body).getPeersList().get(0); } catch (InvalidProtocolBufferException e) { e.printStackTrace(); } } }
65 | public static interface PeersServiceListener { public void update(); }
66 |
67 | private Set mListeners = new HashSet();
68 | public void registerListener(PeersServiceListener l) { mListeners.add(l); }
69 | public void unregisterListener(PeersServiceListener l) { mListeners.remove(l); }
70 | private void _notifyListeners() { if(mUiThreadHandler != null) { mUiThreadHandler.postToHandlerThread(new Runnable() {
71 | @Override
72 | public void run() {
73 | for (PeersServiceListener l : mListeners) {
74 | l.update();
75 | }
76 | ;
77 | }
78 | }); } }
79 |
80 | // TODO check if we can take more advantage of the fact we have peers in a map in PeersService clients
81 | private Map mPersons = new HashMap(); //
82 | public Person getPersonByPgpId(String pgpId) { return mPersons.get(pgpId); }
83 | public List getPersonsByRelationship(Collection relationships)
84 | {
85 | List ret = new ArrayList();
86 | for (Person p : mPersons.values()) if(relationships.contains(p.getRelation())) ret.add(p);
87 | return ret;
88 | }
89 | public Collection getPersonsByRelationship(Person.Relationship relationship)
90 | {
91 | Collection ret = new ArrayList();
92 | for (Person p : mPersons.values()) if(relationship.equals(p.getRelation())) ret.add(p);
93 | return ret;
94 | }
95 | public Collection getPersons() { return mPersons.values(); }
96 | public Person getPersonBySslId(String sslId)
97 | {
98 | for( Person p : getPersons() ) for( Location l : p.getLocationsList() ) if ( l.getSslId().equals(sslId) ) return p;
99 | throw new RuntimeException("There is no Person with a location matching sslId " + sslId);
100 | }
101 | private Person ownPerson;
102 | public Person getOwnPerson()
103 | {
104 | if(ownPerson == null)
105 | {
106 | for (Person p : mPersons.values())
107 | {
108 | if(p.getRelation() == Person.Relationship.YOURSELF)
109 | {
110 | ownPerson = p;
111 | break;
112 | }
113 | }
114 | }
115 | return ownPerson;
116 | }
117 |
118 | public void requestPersonsUpdate(RequestPeers.SetOption option, RequestPeers.InfoOption info)
119 | {
120 | RequestPeers.Builder reqb = RequestPeers.newBuilder();
121 | reqb.setSet(option);
122 | reqb.setInfo(info);
123 | RequestPeers req = reqb.build();
124 | byte[] b;
125 | b = req.toByteArray();
126 | RsMessage msg = new RsMessage();
127 | msg.msgId = RsCtrlService.constructMsgId(Core.ExtensionId.CORE_VALUE, Core.PackageId.PEERS_VALUE, Peers.RequestMsgIds.MsgId_RequestPeers_VALUE, false);
128 | msg.body = b;
129 | mRsCtrlService.sendMsg(msg);
130 | }
131 |
132 | public void requestSetFriend(Person p, boolean makeFriend)
133 | {
134 | int messageIg = RsCtrlService.constructMsgId(Core.ExtensionId.CORE_VALUE, Core.PackageId.PEERS_VALUE, Peers.RequestMsgIds.MsgId_RequestAddPeer_VALUE, false);
135 |
136 | Peers.RequestAddPeer.Builder messageBody = Peers.RequestAddPeer.newBuilder();
137 | messageBody.setPgpId(p.getGpgId());
138 | if(makeFriend) messageBody.setCmd(Peers.RequestAddPeer.AddCmd.ADD);
139 | else messageBody.setCmd( Peers.RequestAddPeer.AddCmd.REMOVE);
140 |
141 | RsMessage reqMsg = new RsMessage( messageIg, messageBody.build().toByteArray() );
142 |
143 | mRsCtrlService.sendMsg(reqMsg);
144 | }
145 |
146 | @Override
147 | public void handleMessage(RsMessage msg)
148 | {
149 | if( msg.msgId == ( RsCtrlService.RESPONSE | (Core.PackageId.PEERS_VALUE << 8) | Peers.ResponseMsgIds.MsgId_ResponsePeerList_VALUE ) )
150 | {
151 | try
152 | {
153 | for (Person p : ResponsePeerList.parseFrom(msg.body).getPeersList()) mPersons.put(p.getGpgId(), p);
154 | _notifyListeners();
155 | }
156 | catch (InvalidProtocolBufferException e) { e.printStackTrace(); }
157 | }
158 | }
159 | }
160 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RsSearchService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import java.util.ArrayList;
24 | import java.util.HashMap;
25 | import java.util.HashSet;
26 | import java.util.List;
27 | import java.util.Map;
28 | import java.util.Set;
29 |
30 | import rsctrl.core.Core;
31 | import rsctrl.search.Search;
32 | import rsctrl.search.Search.RequestBasicSearch;
33 | import rsctrl.search.Search.RequestSearchResults;
34 | import rsctrl.search.Search.ResponseSearchIds;
35 | import rsctrl.search.Search.ResponseSearchResults;
36 | import rsctrl.search.Search.SearchHit;
37 | import rsctrl.search.Search.SearchSet;
38 |
39 | import android.annotation.SuppressLint;
40 |
41 | import org.retroshare.android.RsCtrlService.RsMessage;
42 |
43 | import com.google.protobuf.InvalidProtocolBufferException;
44 |
45 | public class RsSearchService implements RsServiceInterface
46 | {
47 |
48 | RsCtrlService mRsCtrlService;
49 | HandlerThreadInterface mUiThreadHandler;
50 |
51 | RsSearchService(RsCtrlService s, HandlerThreadInterface u)
52 | {
53 | mRsCtrlService = s;
54 | mUiThreadHandler = u;
55 | }
56 |
57 | public static interface SearchServiceListener{ public void update(); }
58 |
59 | private SetmListeners=new HashSet();
60 | public void registerListener(SearchServiceListener l) { mListeners.add(l); }
61 | public void unregisterListener(SearchServiceListener l) { mListeners.remove(l); }
62 | private void _notifyListeners() { if(mUiThreadHandler != null) mUiThreadHandler.postToHandlerThread(new Runnable() {
63 | @Override
64 | public void run() {
65 | for (SearchServiceListener l : mListeners) {
66 | l.update();
67 | }
68 | ;
69 | }
70 | }); }
71 |
72 | @Override
73 | public void handleMessage(RsMessage m) {}
74 |
75 |
76 | public interface SearchResponseHandler { public void onSearchResponseReceived(int id); }
77 |
78 | // stores search terms
79 | @SuppressLint("UseSparseArrays")
80 | Map searchTermsList=new HashMap();
81 |
82 | public Map getSearches(){ return searchTermsList; }
83 |
84 | public void sendRequestBasicSearch(String term, SearchResponseHandler handler)
85 | {
86 | RsMessage msg=new RsMessage();
87 | msg.msgId = (Core.ExtensionId.CORE_VALUE<<24)|(Core.PackageId.SEARCH_VALUE<<8)|Search.RequestMsgIds.MsgId_RequestBasicSearch_VALUE;
88 | msg.body = RequestBasicSearch.newBuilder().addTerms(term).build().toByteArray();
89 | mRsCtrlService.sendMsg(msg, new RequestBasicSearchHandler(term,handler));
90 | }
91 |
92 | private class RequestBasicSearchHandler extends RsMessageHandler
93 | {
94 | SearchResponseHandler handler;
95 | String term;
96 | RequestBasicSearchHandler(String t, SearchResponseHandler h)
97 | {
98 | super();
99 | term=t;
100 | handler=h;
101 | }
102 |
103 | @Override
104 | protected void rsHandleMsg(RsMessage msg)
105 | {
106 | try
107 | {
108 | ResponseSearchIds resp=ResponseSearchIds.parseFrom(msg.body);
109 | searchTermsList.put(resp.getSearchId(0), term);
110 | handler.onSearchResponseReceived(resp.getSearchId(0));
111 | _notifyListeners();
112 | } catch (InvalidProtocolBufferException e) { e.printStackTrace(); }
113 | }
114 | }
115 |
116 | /*
117 | * RequestListSearches is useless, because we dont save the terms
118 | * maybe useful, to delete searches with unknown terms
119 | *
120 | private class RequestListSearchesHandler extends RsMessageHandler{
121 |
122 | @Override
123 | protected void rsHandleMsg(RsMessage msg) {
124 | try {
125 | ResponseSearchIds resp=ResponseSearchIds.parseFrom(msg.body);
126 |
127 | } catch (InvalidProtocolBufferException e) {
128 | e.printStackTrace();
129 | }
130 | }
131 |
132 | }
133 | */
134 |
135 | public void updateSearchResults(int id)
136 | {
137 | RsMessage msg=new RsMessage();
138 | msg.msgId = RsCtrlService.constructMsgId(Core.ExtensionId.CORE_VALUE, Core.PackageId.SEARCH_VALUE, Search.RequestMsgIds.MsgId_RequestSearchResults_VALUE, false);
139 | msg.body = RequestSearchResults.newBuilder()/*.addSearchIds(id)*/.build().toByteArray();
140 | mRsCtrlService.sendMsg(msg,new RequestSearchResultsHandler(id));
141 | }
142 |
143 | public List getSearchResults(int id)
144 | {
145 | if(searchHitsMap.get(id) != null)
146 | {
147 | /*if(searchHitsMap.get(id).size()>100){
148 | return searchHitsMap.get(id).subList(0, 100);
149 | }else{
150 | return searchHitsMap.get(id);
151 | }*/
152 | return searchHitsMap.get(id);
153 | }
154 | else
155 | {
156 | return new ArrayList();
157 | }
158 | }
159 |
160 | @SuppressLint("UseSparseArrays")
161 | private Map> searchHitsMap=new HashMap>();
162 |
163 | private class RequestSearchResultsHandler extends RsMessageHandler
164 | {
165 | int id;
166 | RequestSearchResultsHandler(int i)
167 | {
168 | super();
169 | id = i;
170 | }
171 |
172 | @Override
173 | protected void rsHandleMsg(RsMessage msg)
174 | {
175 | try
176 | {
177 | System.out.println("RequestSearchResultsHandler: parsing...");
178 | ResponseSearchResults resp=ResponseSearchResults.parseFrom(msg.body);
179 | System.out.println("RequestSearchResultsHandler: parsed msg, updating searchhitsmap...");
180 | //searchHitsMap.put(resp.getSearchesList().get(0).getSearchId(), resp.getSearchesList().get(0).getHitsList());
181 |
182 | for(SearchSet ss:resp.getSearchesList())
183 | {
184 | Map searchHitsByHash=new HashMap();
185 | for(SearchHit sh:ss.getHitsList())
186 | {
187 | searchHitsByHash.put(sh.getFile().getHash(), sh);
188 | if(searchHitsByHash.size() > 100) break;
189 | }
190 | searchHitsMap.put(ss.getSearchId(), new ArrayList(searchHitsByHash.values()));
191 | }
192 |
193 | System.out.println("RequestSearchResultsHandler: completed");
194 |
195 | _notifyListeners();
196 | } catch (InvalidProtocolBufferException e) { e.printStackTrace(); }
197 | }
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RsServerData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import java.io.IOException;
24 | import java.io.NotActiveException;
25 | import java.io.ObjectInputStream;
26 | import java.io.ObjectOutputStream;
27 | import java.io.Serializable;
28 |
29 | import net.lag.jaramiko.PKey;
30 | import net.lag.jaramiko.SSHException;
31 |
32 | // TODO: test serialization and clone()
33 | // http://java.sun.com/developer/technicalArticles/Programming/serialization/
34 | public class RsServerData implements Serializable, Cloneable
35 | {
36 | private static final boolean DEBUG = false;
37 | private static final long serialVersionUID = 0;
38 |
39 | // name to identify this server
40 | public String name;
41 |
42 | public String user;
43 | public transient String password;
44 | public boolean savePassword = false;
45 | public String hostname;
46 | public String dhtKey;
47 | public int port;
48 | public transient PKey hostkey;
49 |
50 | @Override
51 | public String toString()
52 | {
53 | //if(hostkey!=null){
54 | try{
55 | return "Servername:"+name+" \""+user+":"+password+"@"+hostname+":"+Integer.toString(port)+" key="+hostkey+"\"";
56 | } catch(NullPointerException e){
57 | //System.err.println("NullPointerException in RsServerData.toString()");
58 | return "Servername:"+name+" \""+user+":"+password+"@"+hostname+":"+Integer.toString(port)+" key=Error in RsServerData.toString() \"";
59 | }/*
60 | }else{
61 | return "\""+user+":"+password+"@"+hostname+":"+Integer.toString(port)+" key=RsServerData::toString: hostkey=null\"";
62 | }*/
63 | }
64 |
65 | public String getHostkeyFingerprint()
66 | {
67 | if(hostkey == null) return null;
68 |
69 | String s = hostkey.getSSHName()+" "+Integer.toString(hostkey.getBits())+" ";
70 |
71 | // TODO isn't this the same as Util.byteArrayToHexString(byte[] b) ?
72 | boolean firstbyte = true;
73 | for(byte b : hostkey.getFingerprint())
74 | {
75 | if( firstbyte == true ) firstbyte = false;
76 | else s += ":";
77 | byte[] a = new byte[2];
78 | int c = (b>>4) & 0x0f;
79 | a[0] = (byte) ((c<10)?(c+'0'):(c-10+'a'));
80 | c = b & 0x0f;
81 | a[1] = (byte) ((c<10)?(c+'0'):(c-10+'a'));
82 | s += new String(a);
83 | }
84 |
85 | return s;
86 | }
87 |
88 | private void writeObject(ObjectOutputStream out)
89 | {
90 | if(DEBUG) System.err.println("RsServerData::writeObject: "+this);
91 |
92 | try
93 | {
94 | out.defaultWriteObject();
95 | if(hostkey != null)
96 | {
97 | out.writeBoolean(true);
98 | out.writeObject(hostkey.toByteArray());
99 | }
100 | else out.writeBoolean(false);
101 |
102 | if(savePassword)
103 | {
104 | out.writeBoolean(true);
105 | out.writeObject(password);
106 | }
107 | else out.writeBoolean(false);
108 |
109 |
110 | }
111 | catch (IOException e) { e.printStackTrace(); }
112 | }
113 |
114 | private void readObject(ObjectInputStream in) throws NotActiveException, IOException, ClassNotFoundException
115 | {
116 | if(DEBUG) System.err.println("RsServerData::readObject begin: ");
117 |
118 | in.defaultReadObject();
119 | if(in.readBoolean())
120 | {
121 | if(DEBUG) System.err.println("RsServerData::readObject: PKey!=null");
122 |
123 | byte[] b=(byte[]) in.readObject();
124 | hostkey = PKey.createFromData(b);
125 | }
126 | else
127 | {
128 | if(DEBUG) System.err.println("RsServerData::readObject: PKey==null");
129 | hostkey=null;
130 | }
131 |
132 | if(in.readBoolean()) password = (String) in.readObject();
133 | else password = null;
134 |
135 | if(DEBUG) System.err.println("RsServerData::readObject end: "+this);
136 | }
137 |
138 | protected RsServerData clone()
139 | {
140 | RsServerData d = new RsServerData();
141 | d.name = name;
142 | d.user = user;
143 | d.password = password;
144 | d.savePassword = savePassword;
145 | d.hostname = hostname;
146 | d.dhtKey = dhtKey;
147 | d.port = port;
148 | if(hostkey != null) { try { d.hostkey = PKey.createFromData(hostkey.toByteArray()); } catch (SSHException e) { e.printStackTrace(); } }
149 | else{ d.hostkey = null; }
150 | return d;
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RsServiceClientFragmentBase.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.app.Activity;
24 | import android.content.ComponentName;
25 | import android.os.IBinder;
26 |
27 | /**
28 | * This class is aimed to be inherited by Fragments that needs to communicate with RsCore
29 | * provide out of the box almost all needed stuff to communicate with RsCore
30 | * so each fragment doesn't need to handle all this common stuff
31 | */
32 | public class RsServiceClientFragmentBase extends ProxiedFragmentBase implements RsClientInterface
33 | {
34 | public String TAG() { return "RsServiceClientFragmentBase"; }
35 |
36 | /**
37 | * RsClientInterface stuff
38 | */
39 |
40 | @Override public void onAttach(Activity a)
41 | {
42 | super.onAttach(a);
43 | if(getArguments() != null && getArguments().containsKey(SERVER_NAME_EXTRA_KEY)) serverName = getArguments().getString(SERVER_NAME_EXTRA_KEY);
44 | else throw new RuntimeException(TAG() + " requires arguments contain value for key " + SERVER_NAME_EXTRA_KEY);
45 | }
46 | protected String serverName;
47 | public RsCtrlService getConnectedServer() { return getRsProxy().activateServer(serverName); }
48 |
49 |
50 | /**
51 | * Rs*ServiceListener stuff
52 | */
53 |
54 | @Override public void onPause()
55 | {
56 | if(isBound()) unregisterRsServicesListeners();
57 | super.onPause();
58 | }
59 | @Override public void onResume()
60 | {
61 | super.onResume();
62 | if(isBound()) registerRsServicesListeners();
63 | }
64 | @Override public void onServiceConnected(ComponentName className, IBinder service)
65 | {
66 | super.onServiceConnected(className, service);
67 | registerRsServicesListeners();
68 | }
69 | // @Override public void onServiceDisconnected(ComponentName className)
70 | // {
71 | // unregisterRsServicesListeners();
72 | // super.onServiceDisconnected(className);
73 | // }
74 |
75 | /**
76 | * Fragment that need to register Rs*Listener should do it inside this method
77 | */
78 | public void registerRsServicesListeners() {}
79 | /**
80 | * Fragment that need to unregister Rs*Listener should do it inside this method
81 | */
82 | public void unregisterRsServicesListeners() {}
83 | }
84 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/RsServiceInterface.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import org.retroshare.android.RsCtrlService.RsMessage;
24 |
25 |
26 | public interface RsServiceInterface
27 | {
28 | public void handleMessage(RsMessage m);
29 | }
30 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ServerChooserActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.os.Bundle;
24 | import android.util.Log;
25 | import android.view.View;
26 | import android.widget.AdapterView;
27 | import android.widget.ArrayAdapter;
28 | import android.widget.Spinner;
29 |
30 | import java.util.ArrayList;
31 | import java.util.HashSet;
32 | import java.util.List;
33 | import java.util.Set;
34 |
35 | /**
36 | * Created by G10h4ck on 7/16/13.
37 | */
38 | public class ServerChooserActivity extends ProxiedActivityBase implements AdapterView.OnItemSelectedListener
39 | {
40 | @Override
41 | protected void onCreateBeforeConnectionInit(Bundle savedInstanceState)
42 | {
43 | setContentView(R.layout.activity_server_chooser);
44 | }
45 |
46 | @Override
47 | protected void onServiceConnected()
48 | {
49 | Set rsAvailableServers = rsProxy.getActivableWithoutUiServers();
50 |
51 | if (rsAvailableServers.size() < 1) startActivity(MainActivity.class);
52 | else
53 | {
54 | List rsSelectableServers = new ArrayList(rsAvailableServers);
55 | serverName = rsSelectableServers.get(0);
56 |
57 | ArrayAdapter spinnerAdapter = new ArrayAdapter(ServerChooserActivity.this, android.R.layout.simple_spinner_item, rsSelectableServers);
58 | Spinner serverSpinner = (Spinner) findViewById(R.id.serverSpinner);
59 | serverSpinner.setAdapter(spinnerAdapter);
60 | }
61 | }
62 |
63 | public void onOkButtonPressed(View v)
64 | {
65 | setResult(RESULT_OK, getIntent().putExtra(SERVER_NAME_EXTRA, serverName));
66 | finish();
67 | }
68 |
69 | @Override public void onItemSelected(AdapterView> adapterView, View view, int i, long l) { serverName = ((Spinner) adapterView).getSelectedItem().toString(); }
70 | @Override public void onNothingSelected(AdapterView> adapterView) {}
71 | }
72 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ShowQrCodeActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import android.app.Activity;
24 | import android.content.Intent;
25 | import android.graphics.Bitmap;
26 | import android.net.Uri;
27 | import android.os.Bundle;
28 | import android.util.Log;
29 | import android.widget.ImageView;
30 | import android.widget.TextView;
31 |
32 | import org.retroshare.android.utils.Util;
33 |
34 |
35 | public class ShowQrCodeActivity extends Activity
36 | {
37 | public String TAG() { return "ShowQrCodeActivity"; }
38 |
39 | public static final String PGP_ID_EXTRA = "pgpId";
40 | public static final String NAME_EXTRA = "name";
41 |
42 | @Override
43 | public void onCreate(Bundle savedInstanceState)
44 | {
45 | super.onCreate(savedInstanceState);
46 |
47 | Intent i = getIntent();
48 | if(i.hasExtra(PGP_ID_EXTRA) && i.hasExtra(NAME_EXTRA))
49 | {
50 | setContentView(R.layout.activity_show_qrcode);
51 |
52 | String name = i.getStringExtra(NAME_EXTRA);
53 | String pgpId = i.getStringExtra(PGP_ID_EXTRA);
54 |
55 | ((TextView) findViewById(R.id.textViewTitleQrCode)).setText(name + " (" + pgpId + ")");
56 |
57 | try
58 | {
59 | // using format like retroshare://person?name=Just%20Relay%20It&hash=AA3BFD5CEEE7EC17
60 | Uri.Builder uriBuilder = new Uri.Builder();
61 | String data = uriBuilder
62 | .scheme(getString(R.string.retroshare_uri_scheme))
63 | .authority(getString(R.string.person_uri_authority))
64 | .appendQueryParameter(getString(R.string.name_uri_query_param), name)
65 | .appendQueryParameter(getString(R.string.hash_uri_query_param), pgpId)
66 | .build()
67 | .toString();
68 |
69 | Bitmap bm = Util.encodeQrCode(data);
70 |
71 | ImageView mImageView = (ImageView) findViewById(R.id.imageViewQrCode);
72 | mImageView.setImageBitmap(bm);
73 | }
74 | catch (Exception e) {}
75 |
76 | }
77 | else Log.wtf(TAG(), "onCreate() how we get here without data required data in the intent?");
78 | }
79 | }
80 |
81 | // mode BYTE version 22
82 | //private String data="retroshare://certificate?sslid=4bab7a4eb473263295f4d726ecfdd7ff&gpgid=8931AA29&gpgbase64=xsBNBFBRzEMBCACuNNXThmv7XkDXse0aMXF5GOSJx+xsOZpDoqhbDsWjeK6Ar+JrxomX4dh2LQuIORpRBfeRA3/yBF6mBVK3BLwQX3P3RzkRpUq6pGwj1HmD4F3Nr8uuNJvJL9wBcK5Hye7HWSIbDfvjQ1/+c0LHfgiW0wdajhRZPtQEmCDkncTJ3RNQjmL7J0NLbybxC8WSrDWwLlO9mOpIq2oRwl1wQnjwU9wivGWBH0epaCgzEcwygY0WVq5a+Xcfxb63jgW1ZHm0kbrYyPNOzaVFhmWmInmb4FxO6NUl8f8YpzakIg3vohskzJeYJCQWjapx6tQQr06YXOf4lseDSxtSVL4Q8lvjABEBAAHNJWRldnggKEdlbmVyYXRlZCBieSBSZXRyb1NoYXJlKSA8ZGV2eD7CwF8EEwECABMFAlBRzEMJECPWaviJMaopAhkBAABVjQgAqC+JJP1NVgnuY42SQv71GLcBGxgD18gbfP73vLQzIEI85tk3tPQ5hpI/xl5Pp0pMpHDXxRrcTXXeCo75DCG+sm5ArokNIt7zr/9ge/pePvDO0HvHMMJbyGxTagnC6lEu+m9SRSSboT2gSmxTU+Yr3fsr2XPTd0fJk5WzIHt1lvcxFrIuPGlDvTj0B6P96Trhn4PdfPDSx3C6sRkxuA9vvv9Gk9jTkEe5CyLyCmPeJOGXTsOxBu0rI3T+e2z73VEywgyIEqUa+CTmZaAWxc0GuOPhT4bTpdtAFI1r4cCKjAej0UAoMiGXS3O1qV2cW9EoqjbeyVSHzONBahrZUDDUIQ==&gpgchecksum=f+Ib&location=devxhome&name=devx&locipp=192.168.1.102:39382;&extipp=109.192.144.39:39382;";
83 | //
84 | //private String data="Hallo echo was geht";
85 | //
86 | // mode ALPHANUMERIC version 18
87 | //private String data="RETROSHARE://C/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
88 | //
89 | // mode ALPHANUMERIC
90 | //private String data="RETROSHARE://C/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
91 | //private String data="HALLO264876";
92 | //
93 | //lnge eines schlssels:
94 | //
95 | //neues format: 894 zeichen
96 | //
97 | //base 64 decodiert:
98 | //649 bytes
99 | //
100 | //macht 944 alfanumerische zeichen fr den qrcode
101 | //
102 | //http://en.wikipedia.org/wiki/QR_code#Encoding
103 | //
104 | //rs cert url: 993 zeichen (bytes)
105 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/ShowSearchResultsActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | import org.retroshare.android.RsSearchService.SearchServiceListener;
27 |
28 | import rsctrl.search.Search.SearchHit;
29 |
30 | import android.content.Context;
31 | import android.content.Intent;
32 | import android.database.DataSetObserver;
33 | import android.os.Bundle;
34 | import android.os.Handler;
35 | import android.os.SystemClock;
36 | import android.util.Log;
37 | import android.view.LayoutInflater;
38 | import android.view.View;
39 | import android.view.ViewGroup;
40 | import android.widget.AdapterView;
41 | import android.widget.ListAdapter;
42 | import android.widget.ListView;
43 | import android.widget.TextView;
44 | import android.widget.AdapterView.OnItemClickListener;
45 | import android.widget.AdapterView.OnItemLongClickListener;
46 |
47 | public class ShowSearchResultsActivity extends ProxiedActivityBase
48 | {
49 | private static final String TAG="ShowSearchResultsActivity";
50 |
51 | private static final int UPDATE_INTERVAL =1500;
52 |
53 | private ListView listView;
54 |
55 | private SearchResultAdapterListener adapter;
56 |
57 | Handler mHandler;
58 |
59 | int mId;
60 |
61 | @Override
62 | public void onCreate(Bundle savedInstanceState)
63 | {
64 | super.onCreate(savedInstanceState);
65 |
66 | mId=getIntent().getIntExtra("SearchId", 0);
67 |
68 | listView=new ListView(this);
69 |
70 | adapter=new SearchResultAdapterListener(this);
71 |
72 | listView.setAdapter(adapter);
73 | listView.setOnItemClickListener(adapter);
74 | listView.setOnItemLongClickListener(adapter);
75 |
76 | setContentView(listView);
77 |
78 | mHandler=new Handler();
79 |
80 | //mHandler.postAtTime(new updateRunnable(), SystemClock.uptimeMillis()+UPDATE_INTERVAL);
81 | }
82 |
83 | @Override
84 | protected void onServiceConnected()
85 | {
86 | RsCtrlService server = getConnectedServer();
87 | server.mRsSearchService.registerListener(adapter);
88 |
89 | // TODO remove this
90 | server.mRsSearchService.updateSearchResults(mId);
91 | }
92 |
93 | boolean isInForeground = false;
94 |
95 | @Override
96 | public void onResume()
97 | {
98 | super.onResume();
99 | isInForeground = true;
100 | }
101 |
102 | @Override
103 | public void onPause()
104 | {
105 | super.onPause();
106 | isInForeground = false;
107 | }
108 |
109 | @Override
110 | public void onDestroy()
111 | {
112 | getConnectedServer().mRsSearchService.unregisterListener(adapter);
113 | super.onDestroy();
114 | }
115 |
116 | private class updateRunnable implements Runnable
117 | {
118 | @Override
119 | public void run()
120 | {
121 | RsCtrlService server = getConnectedServer();
122 | if( isInForeground && isBound() && server.isOnline()) server.mRsSearchService.updateSearchResults(mId);
123 | mHandler.postAtTime(new updateRunnable(), SystemClock.uptimeMillis()+ UPDATE_INTERVAL);
124 | }
125 | }
126 |
127 | private class SearchResultAdapterListener implements ListAdapter, OnItemClickListener, OnItemLongClickListener, SearchServiceListener{
128 |
129 | private List list=new ArrayList();
130 |
131 | private List observerList=new ArrayList();
132 |
133 | private LayoutInflater mInflater;
134 |
135 | public SearchResultAdapterListener(Context context) { mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); }
136 |
137 | public void setData(List l)
138 | {
139 | list.clear();
140 | list = l;
141 | for(DataSetObserver obs:observerList) obs.onChanged();
142 | }
143 |
144 | @Override
145 | public void onItemClick(AdapterView> parent, View view, int position, long id)
146 | {
147 | Intent i=new Intent(ShowSearchResultsActivity.this,AddDownloadActivity.class);
148 | i.putExtra("File", list.get(position).getFile().toByteArray());
149 | startActivity(i);
150 | }
151 |
152 | @Override
153 | public boolean onItemLongClick(AdapterView> arg0, View arg1, int position, long id)
154 | {
155 | /*Location loc=locationList.get(position);
156 | Person p=mapLocationToPerson.get(loc);
157 | Intent i=new Intent(PeersActivity.this,PeerDetailsActivity.class);
158 | i.putExtra("GpgId", p.getGpgId());
159 | i.putExtra("SslId", loc.getSslId());
160 | startActivity(i);*/
161 | return true;
162 | }
163 |
164 | @Override
165 | public View getView(int position, View convertView, ViewGroup parent)
166 | {
167 | TextView tv = new TextView(parent.getContext());
168 | SearchHit sh = list.get(position);
169 | tv.setText(sh.getFile().getName()+" ("+Integer.toString(sh.getNoHits())+") "+Long.toString(sh.getFile().getSize()));
170 | return tv;
171 | }
172 |
173 | @Override
174 | public void update()
175 | {
176 | RsCtrlService server = getConnectedServer();
177 | Log.v(TAG, "update: "+Integer.toString( server.mRsSearchService.getSearchResults(mId).size())+" items");
178 | setData(server.mRsSearchService.getSearchResults(mId));
179 | }
180 |
181 | @Override public int getCount() { return list.size(); }
182 | @Override public Object getItem(int position) { return list.get(position); }
183 | @Override public long getItemId(int position) { return 0; }
184 | @Override public int getItemViewType(int position) { return 0; }
185 | @Override public int getViewTypeCount() { return 1; }
186 | @Override public boolean hasStableIds() { return false; }
187 | @Override public boolean isEmpty() { return list.isEmpty(); }
188 | @Override public void registerDataSetObserver(DataSetObserver observer) { observerList.add(observer); }
189 | @Override public void unregisterDataSetObserver(DataSetObserver observer) { observerList.remove(observer); }
190 | @Override public boolean areAllItemsEnabled() {return true;}
191 | @Override public boolean isEnabled(int position) {return true;}
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/authenticator/AccountActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.authenticator;
22 |
23 | import java.util.ArrayList;
24 |
25 | import org.retroshare.android.AddServerActivity;
26 | import org.retroshare.android.ProxiedActivityBase;
27 | import org.retroshare.android.R;
28 |
29 | import android.accounts.Account;
30 | import android.accounts.AccountAuthenticatorResponse;
31 | import android.accounts.AccountManager;
32 | import android.app.AlertDialog;
33 | import android.content.DialogInterface;
34 | import android.content.Intent;
35 | import android.os.Bundle;
36 | import android.util.Log;
37 | import android.view.View;
38 | import android.widget.ArrayAdapter;
39 | import android.widget.Spinner;
40 |
41 |
42 | public class AccountActivity extends ProxiedActivityBase
43 | {
44 | private static final String TAG = "AccountActivity";
45 |
46 | AccountAuthenticatorResponse response;
47 |
48 | @Override
49 | protected void onCreateBeforeConnectionInit(Bundle savedInstanceState)
50 | {
51 | Log.d(TAG, "onCreateBeforeConnectionInit(Bundle savedInstanceState)");
52 |
53 | response = getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
54 |
55 | setContentView(R.layout.activity_account);
56 | }
57 |
58 | @Override
59 | protected void onServiceConnected()
60 | {
61 | Log.d(TAG, "onServiceConnected()");
62 | // Get RetroShare servers
63 | ArrayList rsAvailableServers = new ArrayList();
64 | rsAvailableServers.addAll(rsProxy.getSavedServers().keySet());
65 | if(rsAvailableServers.size() < 1) return;
66 |
67 | // Remove servers already associated with an android account
68 | for(Account account : (AccountManager.get(this)).getAccountsByType(getString(R.string.ACCOUNT_TYPE))) rsAvailableServers.remove(account.name);
69 | if(rsAvailableServers.size() < 1) return;
70 |
71 | // Put available servers inside the Spinner
72 | ArrayAdapter spinnerAdapter = new ArrayAdapter(AccountActivity.this, android.R.layout.simple_spinner_item, rsAvailableServers);
73 | Spinner accountSpinner = (Spinner) this.findViewById(R.id.available_account_spinner);
74 | accountSpinner.setAdapter(spinnerAdapter);
75 | }
76 |
77 | public void saveAccount(View v)
78 | {
79 | Log.d(TAG, "saveAccount(View v)");
80 |
81 | final Spinner accountSpinner = (Spinner) findViewById(R.id.available_account_spinner);
82 | Object selectedItem = accountSpinner.getSelectedItem();
83 | if(selectedItem != null)
84 | {
85 | String accountName = selectedItem.toString();
86 |
87 | String mAccountType = getString(R.string.ACCOUNT_TYPE);
88 | Account account = new Account(accountName, mAccountType);
89 | AccountManager am = AccountManager.get(this);
90 |
91 | Bundle result = new Bundle();
92 | result.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccountType);
93 | result.putString(AccountManager.KEY_ACCOUNT_NAME, accountName );
94 |
95 | boolean accountCreated = am.addAccountExplicitly(account, null, result);
96 |
97 | if(accountCreated)
98 | {
99 | // Now we tell our caller, could be the Android Account Manager or even our own application that the process was successful
100 | final Intent intent = new Intent();
101 | intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, accountName);
102 | intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, mAccountType);
103 |
104 | setResult(RESULT_OK, intent);
105 |
106 | response.onResult(result);
107 | }
108 |
109 | finish();
110 | }
111 | else
112 | {
113 | new AlertDialog.Builder(this)
114 | .setTitle(R.string.authenticator_activity_accounts_not_selected_title)
115 | .setMessage(R.string.authenticator_activity_accounts_not_selected_message)
116 | .setPositiveButton
117 | (
118 | android.R.string.yes,
119 | new DialogInterface.OnClickListener() {
120 | public void onClick(DialogInterface dialog, int which)
121 | {
122 | if (accountSpinner.getCount() < 1)
123 | {
124 | Intent intent = new Intent(AccountActivity.this, AddServerActivity.class);
125 | startActivity(intent);
126 | }
127 | }
128 | }
129 | )
130 | .setNegativeButton
131 | (android.R.string.no,
132 | new DialogInterface.OnClickListener()
133 | {
134 | public void onClick(DialogInterface dialog, int which) {
135 | AccountActivity.this.finish();
136 | }
137 | }
138 | )
139 | .show();
140 | }
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/authenticator/AccountAuthenticator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.authenticator;
22 |
23 | import android.accounts.AbstractAccountAuthenticator;
24 | import android.accounts.Account;
25 | import android.accounts.AccountAuthenticatorResponse;
26 | import android.accounts.AccountManager;
27 | import android.accounts.NetworkErrorException;
28 | import android.content.Context;
29 | import android.content.Intent;
30 | import android.os.Bundle;
31 |
32 |
33 | public class AccountAuthenticator extends AbstractAccountAuthenticator
34 | {
35 | private final Context mContext;
36 |
37 | public AccountAuthenticator(Context context)
38 | {
39 | super(context);
40 | mContext = context;
41 | }
42 |
43 | /**
44 | * {@inheritDoc}
45 | */
46 | @Override
47 | public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)
48 | {
49 | final Intent intent = new Intent(mContext, AccountActivity.class);
50 | //intent.putExtra(AccountManager.PARAM_AUTHTOKEN_TYPE, authTokenType);
51 | intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
52 | final Bundle bundle = new Bundle();
53 | bundle.putParcelable(AccountManager.KEY_INTENT, intent);
54 | return bundle;
55 | }
56 |
57 | @Override
58 | public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) throws NetworkErrorException { return null; }
59 |
60 | @Override
61 | public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) { return null; }
62 |
63 | @Override
64 | public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException { return null; }
65 |
66 | @Override
67 | public String getAuthTokenLabel(String authTokenType) { return null; }
68 |
69 | @Override
70 | public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) throws NetworkErrorException { return null; }
71 |
72 | @Override
73 | public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException { return null; }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/authenticator/AccountPreferenceActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.authenticator;
22 |
23 | import android.preference.PreferenceActivity;
24 |
25 | /**
26 | * This empty activity is needed by Android Account Manager tho show RetroShare accounts and to edit option such as to enable/disable sync
27 | */
28 | public class AccountPreferenceActivity extends PreferenceActivity {}
29 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/authenticator/AuthenticationService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.authenticator;
22 |
23 | import android.app.Service;
24 | import android.content.Intent;
25 | import android.os.IBinder;
26 | import android.util.Log;
27 |
28 | /**
29 | * Service to handle Account authentication. It instantiates the authenticator
30 | * and returns its IBinder.
31 | */
32 | public class AuthenticationService extends Service
33 | {
34 | private static final String TAG = "AuthenticationService";
35 | private AccountAuthenticator mAuthenticator;
36 |
37 | @Override
38 | public void onCreate()
39 | {
40 | Log.v(TAG, "Authentication Service started.");
41 | mAuthenticator = new AccountAuthenticator(this);
42 | }
43 |
44 | @Override
45 | public void onDestroy()
46 | {
47 | Log.v(TAG, "Authentication Service stopped.");
48 | }
49 |
50 | @Override
51 | public IBinder onBind(Intent intent)
52 | {
53 | Log.v(TAG, "getBinder()... returning the AccountAuthenticator binder for intent " + intent);
54 | return mAuthenticator.getIBinder();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/tests/HtmlBase64ImageGetterTestActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.tests;
22 |
23 | import android.app.Activity;
24 | import android.os.Bundle;
25 | import android.widget.ImageView;
26 |
27 | import org.retroshare.android.utils.HtmlBase64ImageGetter;
28 |
29 | public class HtmlBase64ImageGetterTestActivity extends Activity
30 | {
31 | @Override
32 | public void onCreate(Bundle b)
33 | {
34 | super.onCreate(b);
35 |
36 | String base64Src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACzklEQVRIibVWS08TURQ+dzqFKZROpg+balsKpE1jiUSQh0gwggsTYhpZqgtjMHFjTFTcuNOd8hPc4MLEBcaFEIORhYaoSSVIRYkgEKChQCktbaXv62JKAXs7w4z128y55/F9d86dMzOABTG59BTjbLFoMh2d9j0XZgDhcOj34tz6SH6ZziQy2WR+ObUymEzHhBkQxhgE4fU9Uyl1vzZe+8MTO6kgAFSUHTGxp6zaTlrB1Bl6hMtFBIKx2bGZe4Hod2LUxDZ3OR9XMWaZAqthz4i3L5WJCdQzSu3FhkFdpbNYAlUsEIn73ny7mcrEWmvu1ujPFyY0227XGi7EU8ER7414akuywPjcw0Q6DAD6qnoNYy1M0KtdrKoaAGIJ/+f5J8V4yC3ais2+8PQAiJz/3jYRfbXtfUWZgRAiFswHRg/PDgBZnF7cfEfWJnoD0enDs+dKIuSSvRYtBEZ9oU82XbeZO+MPe+KpkCQBlVJrZBsXAm99oY82XZeZ6zggsBz8MOy9DgAIUb2NL8fnHvnDXyQJmLn2Bkvf8NQuyckhQ1U95Fu0FpnkDYyz69uTkqjzWNveRxL5ytuEMxB9eRwGeZKic1Aq/C8BDBkBgRK0CARahHFGHicCRaGzlC1CiODMCVCIIF4SkO6AuBOp2OXICejVrnxIrz4uj9Ogri8kofmLVXu2yzmwsjVerTtnYpvlCVi0nd3OgeUcScsBAQBwGN0Oo5u3EcjoEgIAu9Ft3yXhQX6KBL6xxaBTk0toore1tl9BlYd25qMJ/2b0B+/UMGau0g4Aq2FPMh3hnce40zTFaCvsTbZbRCqR35afa6/GZvp5+4T5WnvdAwAYmujdiHh55+XWMQ1jEWAQGTTRw8A4K5wgZ5IlPQCyBKSMvYhAuZLbs2n2LwMhqpzW/JOAhetwGC9RiDaxTa6jV3hnS80djcpKK1RttfeZfTsg4g/+D5MwF/zpFwAAAABJRU5ErkJggg==";
37 | HtmlBase64ImageGetter gt = new HtmlBase64ImageGetter(getResources());
38 |
39 | ImageView iv = new ImageView(this);
40 | iv.setImageDrawable(gt.getDrawable(base64Src));
41 |
42 | setContentView(iv);
43 | }
44 | }
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/tests/TestActivity.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.tests;
22 |
23 | import android.app.Activity;
24 | import android.content.Intent;
25 | import android.net.Uri;
26 | import android.os.Bundle;
27 | import android.view.View;
28 |
29 | import org.retroshare.android.ConversationFragmentActivity;
30 | import org.retroshare.android.LobbiesListFragmentActivity;
31 | import org.retroshare.android.R;
32 | import org.retroshare.android.RsConversationService;
33 |
34 |
35 | public class TestActivity extends Activity
36 | {
37 | public static final String SERVER_NAME_TEST_VALUE = "testServer";
38 |
39 | @Override
40 | public void onCreate(Bundle savedInstanceState)
41 | {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_tester);
44 | }
45 |
46 | public void onButtonTestQrReadPressed(View v)
47 | {
48 | Intent i = new Intent();
49 | i.setAction(Intent.ACTION_VIEW);
50 | i.addCategory(Intent.CATEGORY_DEFAULT);
51 | i.addCategory(Intent.CATEGORY_BROWSABLE);
52 |
53 | Uri uri = new Uri.Builder()
54 | .scheme(getString(R.string.retroshare_uri_scheme))
55 | .authority(getString(R.string.person_uri_authority))
56 | .appendQueryParameter(getString(R.string.name_uri_query_param), "Just Relay It")
57 | .appendQueryParameter(getString(R.string.hash_uri_query_param), "AA3BFD5CEEE7EC17")
58 | .build();
59 |
60 | i.setData(uri);
61 |
62 | startActivity(i);
63 | }
64 |
65 | public void onButtonTestFragmentChatActivityPressed(View v)
66 | {
67 | Intent i = new Intent(this, ConversationFragmentActivity.class);
68 | i.putExtra(ConversationFragmentActivity.SERVER_NAME_EXTRA_KEY, SERVER_NAME_TEST_VALUE);
69 | i.putExtra(ConversationFragmentActivity.CONVERSATION_ID_EXTRA_KEY, RsConversationService.PgpChatId.Factory.getPgpChatId("F444EB20C713A5C0"));
70 | startActivity(i);
71 | }
72 |
73 | public void onButtonTestHtmlBase64ImageGetterPressed(View v)
74 | {
75 | Intent i = new Intent(this, HtmlBase64ImageGetterTestActivity.class);
76 | startActivity(i);
77 | }
78 |
79 | public void onButtonTestLobbyChatPressed(View v)
80 | {
81 | Intent i = new Intent(this, LobbiesListFragmentActivity.class);
82 | i.putExtra(LobbiesListFragmentActivity.SERVER_NAME_EXTRA_KEY, SERVER_NAME_TEST_VALUE);
83 | startActivity(i);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/utils/ColorHash.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.utils;
22 |
23 | public class ColorHash
24 | {
25 | public static final int getObjectColor(Object o) { return getNumberColor(o.hashCode()); }
26 | public static final int getNumberColor(int o) { return (0xFF000000 | ColorArray[Math.abs(o % ColorArray.length)]); }
27 |
28 | // Colors taken from http://developer.android.com/design/style/color.html
29 | public static final int[] ColorArray = new int[]
30 | {
31 | 0xE2F4FB, 0xC5EAF8, 0xA8DFF4, 0x8AD5F0, 0x6DCAEC, 0x50C0E9, 0x33B5E5, 0x2CB1E1, 0x24ADDE, 0x1DA9DA, 0x16A5D7, 0x0FA1D3, 0x079DD0, 0x0099CC, // Blue Gradations
32 | 0xF5EAFA, 0xE5CAF2, 0xDDBCEE, 0xD6ADEB, 0xCF9FE7, 0xCB97E5, 0xC58BE2, 0xC182E0, 0xBA75DC, 0xB368D9, 0xAC59D6, 0xA750D3, 0xA041D0, 0xF5F5F5, // Violet Gradations
33 | 0xF0F8DB, 0xE2F0B6, 0xD3E992, 0xC5E26D, 0xB6DB49, 0xA8D324, 0x99CC00, 0x92C500, 0x8ABD00, 0x83B600, 0x7CAF00, 0x75A800, 0x6DA000, 0x669900, // Green Gradations
34 | 0xFFF6DF, 0xFFECC0, 0xFFE3A0, 0xFFD980, 0xFFD060, 0xFFC641, 0xFFBD21, 0xFFB61C, 0xFFAE18, 0xFFA713, 0xFFA00E, 0xFF9909, 0xFF9105, 0xFD8903, // Yellow Gradations
35 | 0xFFE4E4, 0xFFCACA, 0xFFAFAF, 0xFF9494, 0xFF7979, 0xFF5F5F, 0xFF4444, 0xF83A3A, 0xF03131, 0xE92727, 0xE21D1D, 0xDB1313, 0xD30A0A, 0xCC0000 // Red Gradations
36 | };
37 | }
38 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/utils/HtmlBase64ImageGetter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.utils;
22 |
23 | import android.content.res.Resources;
24 | import android.graphics.drawable.BitmapDrawable;
25 | import android.graphics.drawable.Drawable;
26 | import android.text.Html;
27 |
28 | /**
29 | * @author G10h4ck
30 | */
31 | public class HtmlBase64ImageGetter implements Html.ImageGetter
32 | {
33 | public String TAG() { return "HtmlBase64ImageGetter"; }
34 |
35 | Resources resources;
36 |
37 | public HtmlBase64ImageGetter(Resources res) { resources = res; }
38 |
39 | @Override
40 | public Drawable getDrawable(String src) //format of accepted src: "data:image/png;base64,iVBORw0KGgoAAA........."
41 | {
42 | BitmapDrawable bd = null;
43 |
44 | if( src.split(":",2)[0].startsWith("data") )
45 | {
46 | bd = new BitmapDrawable(resources, Util.decodeBase64(src.split(",", 2)[1]));
47 | bd.setBounds(0, 0, bd.getIntrinsicWidth(), bd.getIntrinsicHeight());
48 | }
49 |
50 | return bd;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/utils/Util.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.utils;
22 |
23 | import android.content.ContentResolver;
24 | import android.content.Context;
25 | import android.graphics.Bitmap;
26 | import android.graphics.BitmapFactory;
27 | import android.graphics.Color;
28 | import android.net.Uri;
29 | import android.util.Base64;
30 | import android.util.Log;
31 | import android.widget.EditText;
32 | import android.widget.Toast;
33 |
34 |
35 | import com.google.zxing.WriterException;
36 | import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
37 | import com.google.zxing.qrcode.encoder.ByteMatrix;
38 | import com.google.zxing.qrcode.encoder.Encoder;
39 | import com.google.zxing.qrcode.encoder.QRCode;
40 |
41 | import java.io.ByteArrayOutputStream;
42 | import java.io.FileNotFoundException;
43 |
44 | public class Util
45 | {
46 | public static final String URI_REG_EXP = "([a-z]+[0-9a-z\\.\\-\\+]*:\\/\\/)(\\S)+"; // Probably too permissive, but I never saw a false positive in many tests
47 |
48 | public static String TAG() { return "Util"; }
49 |
50 | public static String byteArrayToHexString(byte[] b)
51 | {
52 | StringBuffer sb = new StringBuffer(b.length * 2);
53 | for (int i = 0; i < b.length; i++)
54 | {
55 | int v = b[i] & 0xff;
56 | if (v < 16) sb.append('0');
57 | sb.append(Integer.toHexString(v));
58 | }
59 | return sb.toString().toUpperCase();
60 | }
61 |
62 | public static boolean hasContent(EditText et) { return (et.getText().toString().trim().length() > 0); }
63 |
64 | private static Long dCounter = 0L;
65 | public static void uDebug(Context c, String tag, String msg)
66 | {
67 | Log.d(tag, msg + " " );
68 | Toast.makeText(c, tag + " " + msg + " ", Toast.LENGTH_LONG).show();
69 |
70 | ++dCounter;
71 | }
72 |
73 |
74 | public static Bitmap encodeQrCode(String contents) throws WriterException
75 | {
76 | QRCode qrCode = new QRCode();
77 | Encoder.encode(contents, ErrorCorrectionLevel.L, qrCode);
78 |
79 | System.out.println("encoded qrCode: "+qrCode);
80 |
81 | ByteMatrix result = qrCode.getMatrix();
82 | int codewidth = result.getWidth();
83 | int codeheight = result.getHeight();
84 | // +2 for quiet zone
85 | int imagewidth = result.getWidth() + 2;
86 | int imageheight = result.getHeight() + 2;
87 | int[] pixels = new int[imagewidth * imageheight];
88 |
89 | // init pixels with white:
90 | for (int i = 0; i < pixels.length; i++) pixels[i] = Color.WHITE;
91 |
92 | // set black pixels
93 | // use 1pixel quiet zone, this is enough for most readers, see
94 | // http://qrworld.wordpress.com/2011/08/09/the-quiet-zone/
95 | for (int y = 0; y < codeheight; y++)
96 | {
97 | // +1 line horizontal for quiet zone
98 | int offset = (y+1) * imagewidth;
99 | for (int x = 0; x < codewidth; x++)
100 | {
101 | if( result.get(x, y) == 1 )
102 | {
103 | // +1 pixel vertical for quiet zone
104 | pixels[offset + x +1] = Color.BLACK;
105 | }
106 | }
107 | }
108 |
109 | Bitmap bitmap = Bitmap.createBitmap(imagewidth, imageheight, Bitmap.Config.ARGB_8888);
110 | bitmap.setPixels(pixels, 0, imagewidth, 0, 0, imagewidth, imageheight);
111 | bitmap = Bitmap.createScaledBitmap(bitmap, imagewidth*6, imageheight*6, false);
112 |
113 | return bitmap;
114 | }
115 |
116 | public static String getCertFromUri(Uri uri)
117 | {
118 | if( uri.getScheme().equals("retroshare") && uri.getHost().equals("certificate") )
119 | {
120 | String cert="-----BEGIN PGP PUBLIC KEY BLOCK-----\n";
121 | cert+=uri.getQueryParameter("gpgbase64");
122 | cert+="\n=";
123 | cert+=uri.getQueryParameter("gpgchecksum");
124 | cert+="\n-----END PGP PUBLIC KEY BLOCK-----\n";
125 | cert+="--SSLID--"+uri.getQueryParameter("sslid")+";--LOCATION--"+uri.getQueryParameter("location")+";\n";
126 | // Note: at locipp and extipp, the ';' is included in the query string
127 | cert+="--LOCAL--"+uri.getQueryParameter("locipp")+"--EXT--"+uri.getQueryParameter("extipp");
128 | return cert;
129 | }
130 | else
131 | {
132 | Log.e( TAG(), "getCertFromUri( "+ uri.toString() +" ): wrong scheme or host");
133 | return null;
134 | }
135 | }
136 |
137 | public static String encodeTobase64(Bitmap image, Bitmap.CompressFormat format, int quality)
138 | {
139 | if(image == null) throw new NullPointerException("encodeTobase64 called with null argument");
140 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
141 | image.compress(format, quality, baos);
142 | return Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);
143 | }
144 | public static Bitmap decodeBase64(String input)
145 | {
146 | byte[] decodedByte = Base64.decode(input, 0);
147 | return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
148 | }
149 | public static Bitmap loadFittingBitmap(ContentResolver contentResolver, Uri uri, int maxDimension) throws FileNotFoundException
150 | {
151 | BitmapFactory.Options options = new BitmapFactory.Options();
152 | options.inJustDecodeBounds = true;
153 | BitmapFactory.decodeStream(contentResolver.openInputStream(uri), null, options);
154 | int h = options.outHeight;
155 | int w = options.outWidth;
156 | if( h > maxDimension || w > maxDimension)
157 | {
158 | if( h > w ) options.inSampleSize = Math.round((float) h / (float) maxDimension);
159 | else options.inSampleSize = Math.round((float) w / (float) maxDimension);
160 | }
161 | options.inJustDecodeBounds = false;
162 | return BitmapFactory.decodeStream(contentResolver.openInputStream(uri), null, options);
163 | }
164 |
165 | public static int opposeColor(int colorToInvert)
166 | {
167 | int RGBMAX = 255;
168 | float[] hsv = new float[3];
169 | float H;
170 | Color.RGBToHSV( Color.red(colorToInvert), RGBMAX - Color.green( colorToInvert), Color.blue(colorToInvert), hsv );
171 | H = (float) (hsv[0] + 0.5);
172 | if (H > 1) H -= 1;
173 | return Color.HSVToColor(hsv);
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/src/org/retroshare/android/utils/WeakHashSet.java:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | *
4 | * Copyright (c) 2013 Gioacchino Mazzurco .
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | *
19 | */
20 |
21 | package org.retroshare.android.utils;
22 |
23 | import java.util.Collection;
24 | import java.util.Iterator;
25 | import java.util.Map;
26 | import java.util.Set;
27 | import java.util.WeakHashMap;
28 |
29 | /**
30 | * A weak HashSet. An element stored in the WeakHashSet might be
31 | * garbage collected, if there is no strong reference to this element.
32 | */
33 | public class WeakHashSet implements Set
34 | {
35 | private final Map repository = new WeakHashMap();
36 |
37 | @Override public int size() { return repository.size(); }
38 | @Override public Object[] toArray() { return repository.values().toArray(); }
39 | @Override public T1[] toArray(T1[] t1s) { return repository.values().toArray(t1s); }
40 | @Override public Iterator iterator() { return repository.values().iterator(); }
41 | @Override public boolean contains(Object o) { return repository.containsValue(o); }
42 | @Override public boolean containsAll(Collection> objects) { return repository.values().containsAll(objects); }
43 | @Override public boolean isEmpty() { return repository.isEmpty(); }
44 | @Override public boolean add(T e)
45 | {
46 | boolean ret = !repository.containsValue(e);
47 | if(ret) repository.put(new Integer(e.hashCode()), e);
48 | return ret;
49 | }
50 | @Override public boolean addAll(Collection extends T> ts)
51 | {
52 | boolean ret = false;
53 | for ( T e : ts )
54 | {
55 | boolean missing = ! repository.containsValue(e);
56 | if(missing)
57 | {
58 | ret = true;
59 | repository.put(Integer.valueOf(e.hashCode()), e);
60 | }
61 | }
62 | return ret;
63 | }
64 | @Override public void clear() { repository.clear(); }
65 | @Override public boolean remove(Object o)
66 | {
67 | boolean ret = repository.containsValue(o);
68 | if(ret) repository.remove(o);
69 | return ret;
70 | }
71 | @Override public boolean removeAll(Collection> objects)
72 | {
73 | boolean ret = false;
74 | for ( Object e : objects )
75 | {
76 | boolean present = repository.containsValue(e);
77 | if(present)
78 | {
79 | ret = true;
80 | repository.remove(e);
81 | }
82 | }
83 | return ret;
84 | }
85 | @Override public boolean retainAll(Collection> objects) { return repository.values().retainAll(objects); }
86 | }
87 |
--------------------------------------------------------------------------------
/RetroShareAndroidIntegration/todo.txt:
--------------------------------------------------------------------------------
1 | Future: use fragments to make ui for tablets (bigger screen)
2 |
3 | add errorhandling:
4 | add check if port is a number
5 | mServerData.port=Integer.parseInt(editTextPort.getText().toString());
6 |
7 | github markdown
8 | https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#wiki-images
9 |
10 | eclipse c++:
11 | http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/
12 |
13 | std::cerr from c++ to logcat:
14 | create a local.prop on your workstation, then adb push local.prop /data
15 | local.prop:
16 | log.redirect-stdio = true
17 |
18 |
19 | ndk-stack:
20 | D:\Java_Dev\android-ndk-r8b>ndk-stack -sym D:\Java_Dev\RetroShareRemote\RetroSha
21 | reRemote\obj\local\armeabi -dump
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/doc/architecture.dia:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/doc/architecture.dia
--------------------------------------------------------------------------------
/doc/architecture.dia~:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/doc/architecture.dia~
--------------------------------------------------------------------------------
/doc/architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/G10h4ck/RetroShare-Android-Client/e4ccb9bd823ad86148eae5e27b899aafe3a3d397/doc/architecture.png
--------------------------------------------------------------------------------
/lib/rsctrl/readme.txt:
--------------------------------------------------------------------------------
1 | this folder contains code generated by the protocol buffer compiler
2 | you can get the definitions from the retroshare repo
--------------------------------------------------------------------------------
/readme-update.txt:
--------------------------------------------------------------------------------
1 | http://stackoverflow.com/questions/11697572/protobuf-java-code-has-build-errors
2 |
3 |
4 |
5 |
6 | Ok, the so-called Java tutorial for protobufs doesn't actually mention how to get the protobuf library into your project. It implies that all the code is in your single generated .java file, which would actually be pretty nice, but that isn't case.
7 |
8 | Look at the source and you will see references to com.google.protobuf, which you can find in the java/src/main/java directory in the protobuf source. Copy that into your project however, and it will have build errors.
9 |
10 | The solution is in the README.txt file. Yeah, maybe I should have read it, but shouldn't all the information you need to get started be in the getting started tutorial? Anyway, do this:
11 | # From the protobuf directory.
12 | cd java
13 | protoc --java_out=src/main/java -I../src ../src/google/protobuf/descriptor.proto
14 |
15 | And then copy the java files into your project.
--------------------------------------------------------------------------------