Merge lp:~trb143/openlp/android-2 into lp:openlp/android
- android-2
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 49 |
Proposed branch: | lp:~trb143/openlp/android-2 |
Merge into: | lp:openlp/android |
Diff against target: |
1238 lines (+447/-324) 26 files modified
AndroidManifest.xml (+2/-2) res/values/defaultValues.xml (+2/-0) res/values/keyStrings.xml (+2/-0) res/values/strings.xml (+9/-0) src/org/openlp/android/OpenLP.java (+2/-2) src/org/openlp/android/activity/DefaultActivity.java (+2/-2) src/org/openlp/android/activity/OpenLPNavigate.java (+2/-2) src/org/openlp/android/activity/PagerActivity.java (+2/-2) src/org/openlp/android/activity/Search.java (+2/-2) src/org/openlp/android/activity/SearchService.java (+2/-2) src/org/openlp/android/activity/SearchableActivity.java (+2/-2) src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java (+49/-12) src/org/openlp/android/activity/preference/Preferences.java (+2/-2) src/org/openlp/android/api/Api.java (+2/-2) src/org/openlp/android/data/HttpReturn.java (+53/-0) src/org/openlp/android/data/Poll.java (+2/-2) src/org/openlp/android/data/SlideItem.java (+2/-2) src/org/openlp/android/service/ApiCallIntent.java (+247/-263) src/org/openlp/android/service/PingIntent.java (+2/-2) src/org/openlp/android/utility/GroupExpandableListAdapter.java (+2/-2) src/org/openlp/android/utility/JSONHandler.java (+2/-2) src/org/openlp/android/utility/OpenLPController.java (+14/-3) src/org/openlp/android/utility/OpenLPHttpClient.java (+35/-10) src/org/openlp/android/utility/SlideAdapter.java (+2/-2) src/org/openlp/android/utility/StringHelper.java (+2/-2) src/org/openlp/android/utility/WebCallReturningAsyncTask.java (+2/-2) |
To merge this branch: | bzr merge lp:~trb143/openlp/android-2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Johan Mynhardt | Approve | ||
Review via email: mp+157543@code.launchpad.net |
Commit message
Description of the change
Fix up the SSL code to work with CherryPy
Add Userid and Password to config and HTTPCLient
Fix up error handling to work better
Move display strings to translatables.
Tim Bentley (trb143) wrote : | # |
Johan Mynhardt (johanmynhardt) wrote : | # |
Ok, got my stuff up and running.
@trb143: it appears to be working for me:
* if I activate user Authentication and set the username and password to something different (matching between remote and openlp) it works.
* if I set the wrong credentials on the remote, it does not authenticate correctly.
I'm not sure I understood your question 100%. Did I maybe troubleshoot the wrong scenario?
Johan Mynhardt (johanmynhardt) wrote : | # |
Looks good to me! Although it appears that in several places the indents have been replaced with spaces. I'm not 100% sure of the convention, but most places I looked, it seems that the indents are achieved by means of tabs.
Tim Bentley (trb143) wrote : | # |
No you were right.
I changed the userid and forgot to press "Activate" to enable it.
Retested and works fine.
The code layout has always been an issue as we use different editors. I use plain intelij now and it looks fine!
Johan Mynhardt (johanmynhardt) : | # |
Raoul Snyman (raoul-snyman) wrote : | # |
My guess is that somewhere tabs are used and somewhere spaces are used. Can you try to decide which you want to use, and then set the entire code base to use those?
Preview Diff
1 | === modified file 'AndroidManifest.xml' | |||
2 | --- AndroidManifest.xml 2013-03-12 19:45:46 +0000 | |||
3 | +++ AndroidManifest.xml 2013-04-07 12:27:25 +0000 | |||
4 | @@ -3,8 +3,8 @@ | |||
5 | 3 | xmlns:android="http://schemas.android.com/apk/res/android" | 3 | xmlns:android="http://schemas.android.com/apk/res/android" |
6 | 4 | android:installLocation="auto" | 4 | android:installLocation="auto" |
7 | 5 | package="org.openlp.android" | 5 | package="org.openlp.android" |
10 | 6 | android:versionCode="1" | 6 | android:versionCode="7" |
11 | 7 | android:versionName="1.0" | 7 | android:versionName="1.1" |
12 | 8 | > | 8 | > |
13 | 9 | <uses-sdk android:minSdkVersion="8"/> | 9 | <uses-sdk android:minSdkVersion="8"/> |
14 | 10 | <uses-permission android:name="android.permission.INTERNET"/> | 10 | <uses-permission android:name="android.permission.INTERNET"/> |
15 | 11 | 11 | ||
16 | === modified file 'res/values/defaultValues.xml' | |||
17 | --- res/values/defaultValues.xml 2012-05-23 21:37:47 +0000 | |||
18 | +++ res/values/defaultValues.xml 2013-04-07 12:27:25 +0000 | |||
19 | @@ -4,6 +4,8 @@ | |||
20 | 4 | <string name="portDefaultValue">4316</string> | 4 | <string name="portDefaultValue">4316</string> |
21 | 5 | <string name="ssl.port.default">4317</string> | 5 | <string name="ssl.port.default">4317</string> |
22 | 6 | <string name="displayTypeValue">@string/displayScreen</string> | 6 | <string name="displayTypeValue">@string/displayScreen</string> |
23 | 7 | <string name="useridDefaultValue">openlp</string> | ||
24 | 8 | <string name="passwordDefaultValue">password</string> | ||
25 | 7 | 9 | ||
26 | 8 | <!-- INTEGER --> | 10 | <!-- INTEGER --> |
27 | 9 | <integer name="socketTimeoutDefaultValue">3000</integer> | 11 | <integer name="socketTimeoutDefaultValue">3000</integer> |
28 | 10 | 12 | ||
29 | === modified file 'res/values/keyStrings.xml' | |||
30 | --- res/values/keyStrings.xml 2012-05-27 21:42:19 +0000 | |||
31 | +++ res/values/keyStrings.xml 2013-04-07 12:27:25 +0000 | |||
32 | @@ -7,6 +7,8 @@ | |||
33 | 7 | <string name="keySocketTimeout">socketTimeout</string> | 7 | <string name="keySocketTimeout">socketTimeout</string> |
34 | 8 | <string name="keyHost">keyHost</string> | 8 | <string name="keyHost">keyHost</string> |
35 | 9 | <string name="keyPort">keyPort</string> | 9 | <string name="keyPort">keyPort</string> |
36 | 10 | <string name="key.userid">key.userid</string> | ||
37 | 11 | <string name="key.password">key.password</string> | ||
38 | 10 | <string name="keySharedPreferences">keySharedPreferences</string> | 12 | <string name="keySharedPreferences">keySharedPreferences</string> |
39 | 11 | <string name="key.ssl.use">ssl.use</string> | 13 | <string name="key.ssl.use">ssl.use</string> |
40 | 12 | <string name="key.profile.selected.title">key.profile.selected.title</string> | 14 | <string name="key.profile.selected.title">key.profile.selected.title</string> |
41 | 13 | 15 | ||
42 | === modified file 'res/values/strings.xml' | |||
43 | --- res/values/strings.xml 2012-06-02 14:43:23 +0000 | |||
44 | +++ res/values/strings.xml 2013-04-07 12:27:25 +0000 | |||
45 | @@ -89,4 +89,13 @@ | |||
46 | 89 | <string name="connection.profile.ssl.summary">Specify whether SSL should be used</string> | 89 | <string name="connection.profile.ssl.summary">Specify whether SSL should be used</string> |
47 | 90 | <string name="connection.available.configurations">List of available profiles</string> | 90 | <string name="connection.available.configurations">List of available profiles</string> |
48 | 91 | <string name="connection.add.by.menu">Tap to add a new profile</string> | 91 | <string name="connection.add.by.menu">Tap to add a new profile</string> |
49 | 92 | <string name="connection.userid">Userid</string> | ||
50 | 93 | <string name="connection.password">Password</string> | ||
51 | 94 | <string name="httpreturn.unauthorised">Unauthorised Access, please enter valid userid and password</string> | ||
52 | 95 | <string name="apiCallIntent.search">Unexpected invalid result during Search Call.</string> | ||
53 | 96 | <string name="apiCallIntent.alert">Unexpected invalid result during Alert call.</string> | ||
54 | 97 | <string name="apiCallIntent.navigation">Unexpected invalid result during Navigation.</string> | ||
55 | 98 | <string name="apiCallIntent.list_data">Unexpected invalid result while setting list data.</string> | ||
56 | 99 | <string name="apiCallIntent.poll">Unexpected invalid result during status Poll.</string> | ||
57 | 100 | <string name="apiCallIntent.fetch">Unexpected invalid result while fetching items.</string> | ||
58 | 92 | </resources> | 101 | </resources> |
59 | 93 | 102 | ||
60 | === modified file 'src/org/openlp/android/OpenLP.java' | |||
61 | --- src/org/openlp/android/OpenLP.java 2012-05-24 21:06:55 +0000 | |||
62 | +++ src/org/openlp/android/OpenLP.java 2013-04-07 12:27:25 +0000 | |||
63 | @@ -1,8 +1,8 @@ | |||
64 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
65 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
66 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
69 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
70 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
71 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
72 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
73 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
74 | 9 | 9 | ||
75 | === modified file 'src/org/openlp/android/activity/DefaultActivity.java' | |||
76 | --- src/org/openlp/android/activity/DefaultActivity.java 2012-05-24 21:06:55 +0000 | |||
77 | +++ src/org/openlp/android/activity/DefaultActivity.java 2013-04-07 12:27:25 +0000 | |||
78 | @@ -1,8 +1,8 @@ | |||
79 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
80 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
81 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
84 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
85 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
86 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
87 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
88 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
89 | 9 | 9 | ||
90 | === modified file 'src/org/openlp/android/activity/OpenLPNavigate.java' | |||
91 | --- src/org/openlp/android/activity/OpenLPNavigate.java 2012-05-01 18:49:58 +0000 | |||
92 | +++ src/org/openlp/android/activity/OpenLPNavigate.java 2013-04-07 12:27:25 +0000 | |||
93 | @@ -1,8 +1,8 @@ | |||
94 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
95 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
96 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
99 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
100 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
101 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
102 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
103 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
104 | 9 | 9 | ||
105 | === modified file 'src/org/openlp/android/activity/PagerActivity.java' | |||
106 | --- src/org/openlp/android/activity/PagerActivity.java 2012-05-01 20:43:27 +0000 | |||
107 | +++ src/org/openlp/android/activity/PagerActivity.java 2013-04-07 12:27:25 +0000 | |||
108 | @@ -1,8 +1,8 @@ | |||
109 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
110 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
111 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
114 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
115 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
116 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
117 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
118 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
119 | 9 | 9 | ||
120 | === modified file 'src/org/openlp/android/activity/Search.java' | |||
121 | --- src/org/openlp/android/activity/Search.java 2012-05-05 14:12:12 +0000 | |||
122 | +++ src/org/openlp/android/activity/Search.java 2013-04-07 12:27:25 +0000 | |||
123 | @@ -1,8 +1,8 @@ | |||
124 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
125 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
126 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
129 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
130 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
131 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
132 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
133 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
134 | 9 | 9 | ||
135 | === modified file 'src/org/openlp/android/activity/SearchService.java' | |||
136 | --- src/org/openlp/android/activity/SearchService.java 2012-05-05 14:12:12 +0000 | |||
137 | +++ src/org/openlp/android/activity/SearchService.java 2013-04-07 12:27:25 +0000 | |||
138 | @@ -1,8 +1,8 @@ | |||
139 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
140 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
141 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
144 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
145 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
146 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
147 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
148 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
149 | 9 | 9 | ||
150 | === modified file 'src/org/openlp/android/activity/SearchableActivity.java' | |||
151 | --- src/org/openlp/android/activity/SearchableActivity.java 2012-05-05 17:34:31 +0000 | |||
152 | +++ src/org/openlp/android/activity/SearchableActivity.java 2013-04-07 12:27:25 +0000 | |||
153 | @@ -1,8 +1,8 @@ | |||
154 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
155 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
156 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
159 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
160 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
161 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
162 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
163 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
164 | 9 | 9 | ||
165 | === modified file 'src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java' | |||
166 | --- src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java 2012-07-02 05:09:23 +0000 | |||
167 | +++ src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java 2013-04-07 12:27:25 +0000 | |||
168 | @@ -1,8 +1,8 @@ | |||
169 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
170 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
171 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
174 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
175 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
176 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
177 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
178 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
179 | @@ -39,9 +39,6 @@ | |||
180 | 39 | import android.preference.PreferenceScreen; | 39 | import android.preference.PreferenceScreen; |
181 | 40 | import android.text.InputType; | 40 | import android.text.InputType; |
182 | 41 | import android.util.Log; | 41 | import android.util.Log; |
183 | 42 | import android.view.Menu; | ||
184 | 43 | import android.view.MenuInflater; | ||
185 | 44 | import android.view.MenuItem; | ||
186 | 45 | import android.widget.Toast; | 42 | import android.widget.Toast; |
187 | 46 | import org.openlp.android.R; | 43 | import org.openlp.android.R; |
188 | 47 | 44 | ||
189 | @@ -51,7 +48,6 @@ | |||
190 | 51 | private final String PREFERENCE_DISPLAY_SERVER = "displayServer"; | 48 | private final String PREFERENCE_DISPLAY_SERVER = "displayServer"; |
191 | 52 | private final String LOG_TAG = ConnectionPreferenceActivity.class.getName(); | 49 | private final String LOG_TAG = ConnectionPreferenceActivity.class.getName(); |
192 | 53 | 50 | ||
193 | 54 | |||
194 | 55 | private PreferenceScreen preferenceScreen = null; | 51 | private PreferenceScreen preferenceScreen = null; |
195 | 56 | private boolean resume = true; | 52 | private boolean resume = true; |
196 | 57 | 53 | ||
197 | @@ -197,11 +193,24 @@ | |||
198 | 197 | ? getString(R.string.hostDefaultValue) : hostValueObject.toString(); | 193 | ? getString(R.string.hostDefaultValue) : hostValueObject.toString(); |
199 | 198 | hostConfig.hostAddress.setText(hostValue); | 194 | hostConfig.hostAddress.setText(hostValue); |
200 | 199 | hostConfig.hostAddress.setSummary(hostValue); | 195 | hostConfig.hostAddress.setSummary(hostValue); |
201 | 196 | |||
202 | 200 | Object portValueObject = preferences.get(hostConfig.hostPort.getKey()); | 197 | Object portValueObject = preferences.get(hostConfig.hostPort.getKey()); |
203 | 201 | String portValue = portValueObject == null | 198 | String portValue = portValueObject == null |
204 | 202 | ? getString(R.string.portDefaultValue) : portValueObject.toString(); | 199 | ? getString(R.string.portDefaultValue) : portValueObject.toString(); |
205 | 203 | hostConfig.hostPort.setText(portValue); | 200 | hostConfig.hostPort.setText(portValue); |
206 | 204 | hostConfig.hostPort.setSummary(portValue); | 201 | hostConfig.hostPort.setSummary(portValue); |
207 | 202 | |||
208 | 203 | Object useridValueObject = preferences.get(hostConfig.userid.getKey()); | ||
209 | 204 | String useridValue = useridValueObject == null | ||
210 | 205 | ? getString(R.string.useridDefaultValue) : useridValueObject.toString(); | ||
211 | 206 | hostConfig.userid.setText(useridValue); | ||
212 | 207 | hostConfig.userid.setSummary(useridValue); | ||
213 | 208 | |||
214 | 209 | Object passwordValueObject = preferences.get(hostConfig.password.getKey()); | ||
215 | 210 | String passwordValue = passwordValueObject == null | ||
216 | 211 | ? getString(R.string.passwordDefaultValue) : passwordValueObject.toString(); | ||
217 | 212 | hostConfig.password.setText(passwordValue); | ||
218 | 213 | hostConfig.password.setSummary(passwordValue); | ||
219 | 205 | return hostConfig; | 214 | return hostConfig; |
220 | 206 | } | 215 | } |
221 | 207 | 216 | ||
222 | @@ -234,6 +243,8 @@ | |||
223 | 234 | preferenceCategory.addPreference(hostConfig.hostAddress); | 243 | preferenceCategory.addPreference(hostConfig.hostAddress); |
224 | 235 | preferenceCategory.addPreference(hostConfig.hostPort); | 244 | preferenceCategory.addPreference(hostConfig.hostPort); |
225 | 236 | preferenceCategory.addPreference(hostConfig.useSsl); | 245 | preferenceCategory.addPreference(hostConfig.useSsl); |
226 | 246 | preferenceCategory.addPreference(hostConfig.userid); | ||
227 | 247 | preferenceCategory.addPreference(hostConfig.password); | ||
228 | 237 | preferenceCategory.addPreference(hostConfig.remove); | 248 | preferenceCategory.addPreference(hostConfig.remove); |
229 | 238 | preferenceCategory.addPreference(hostConfig.activate); | 249 | preferenceCategory.addPreference(hostConfig.activate); |
230 | 239 | return true; | 250 | return true; |
231 | @@ -261,6 +272,8 @@ | |||
232 | 261 | final EditTextPreference hostAddress; | 272 | final EditTextPreference hostAddress; |
233 | 262 | final EditTextPreference hostPort; | 273 | final EditTextPreference hostPort; |
234 | 263 | final CheckBoxPreference useSsl; | 274 | final CheckBoxPreference useSsl; |
235 | 275 | final EditTextPreference userid; | ||
236 | 276 | final EditTextPreference password; | ||
237 | 264 | final Preference remove; | 277 | final Preference remove; |
238 | 265 | final Preference activate; | 278 | final Preference activate; |
239 | 266 | 279 | ||
240 | @@ -282,10 +295,9 @@ | |||
241 | 282 | hostAddress.getEditText().setHint(R.string.urlHint); | 295 | hostAddress.getEditText().setHint(R.string.urlHint); |
242 | 283 | hostAddress.setSummary(getString(R.string.urlHint)); | 296 | hostAddress.setSummary(getString(R.string.urlHint)); |
243 | 284 | hostAddress.setDialogTitle(getString(R.string.urlHint)); | 297 | hostAddress.setDialogTitle(getString(R.string.urlHint)); |
248 | 285 | hostAddress.getEditText().setInputType( | 298 | hostAddress.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI); |
249 | 286 | InputType.TYPE_TEXT_VARIATION_URI); | 299 | hostAddress.setOnPreferenceChangeListener(onPreferenceChangeListener); |
250 | 287 | hostAddress.setOnPreferenceChangeListener( | 300 | |
247 | 288 | onPreferenceChangeListener); | ||
251 | 289 | hostPort = new EditTextPreference(ConnectionPreferenceActivity.this); | 301 | hostPort = new EditTextPreference(ConnectionPreferenceActivity.this); |
252 | 290 | hostPort.setTitle(getString(R.string.port)); | 302 | hostPort.setTitle(getString(R.string.port)); |
253 | 291 | hostPort.setKey(KEY_PREFIX + id + ".port"); | 303 | hostPort.setKey(KEY_PREFIX + id + ".port"); |
254 | @@ -299,8 +311,26 @@ | |||
255 | 299 | useSsl.setTitle(getString(R.string.connection_profile_ssl_use)); | 311 | useSsl.setTitle(getString(R.string.connection_profile_ssl_use)); |
256 | 300 | useSsl.setSummary(getString(R.string.connection_profile_ssl_summary)); | 312 | useSsl.setSummary(getString(R.string.connection_profile_ssl_summary)); |
257 | 301 | useSsl.setKey(KEY_PREFIX + id + ".usessl"); | 313 | useSsl.setKey(KEY_PREFIX + id + ".usessl"); |
260 | 302 | // Only till SSL is added to core | 314 | |
261 | 303 | useSsl.setEnabled(false); | 315 | userid = new EditTextPreference(ConnectionPreferenceActivity.this); |
262 | 316 | userid.setSummary(getString(R.string.connection_userid)); | ||
263 | 317 | userid.getEditText().setHint(getString(R.string.connection_userid)); | ||
264 | 318 | userid.setTitle(getString(R.string.connection_userid)); | ||
265 | 319 | userid.setKey(KEY_PREFIX + id + ".userid"); | ||
266 | 320 | userid.setDefaultValue(getString(R.string.useridDefaultValue)); | ||
267 | 321 | userid.setSummary(getString(R.string.useridDefaultValue)); | ||
268 | 322 | userid.setDialogTitle(getString(R.string.connection_userid)); | ||
269 | 323 | userid.setOnPreferenceChangeListener(onPreferenceChangeListener); | ||
270 | 324 | |||
271 | 325 | password = new EditTextPreference(ConnectionPreferenceActivity.this); | ||
272 | 326 | password.setSummary(getString(R.string.connection_password)); | ||
273 | 327 | password.getEditText().setHint(getString(R.string.connection_password)); | ||
274 | 328 | password.setTitle(getString(R.string.connection_password)); | ||
275 | 329 | password.setKey(KEY_PREFIX + id + ".password"); | ||
276 | 330 | password.setDefaultValue(getString(R.string.passwordDefaultValue)); | ||
277 | 331 | password.setSummary(getString(R.string.passwordDefaultValue)); | ||
278 | 332 | password.setDialogTitle(getString(R.string.connection_password)); | ||
279 | 333 | password.setOnPreferenceChangeListener(onPreferenceChangeListener); | ||
280 | 304 | 334 | ||
281 | 305 | remove = new Preference(ConnectionPreferenceActivity.this); | 335 | remove = new Preference(ConnectionPreferenceActivity.this); |
282 | 306 | remove.setTitle(getString(R.string.connection_profile_remove)); | 336 | remove.setTitle(getString(R.string.connection_profile_remove)); |
283 | @@ -314,6 +344,8 @@ | |||
284 | 314 | editor.remove(hostPort.getKey()); | 344 | editor.remove(hostPort.getKey()); |
285 | 315 | editor.remove(title.getKey()); | 345 | editor.remove(title.getKey()); |
286 | 316 | editor.remove(useSsl.getKey()); | 346 | editor.remove(useSsl.getKey()); |
287 | 347 | editor.remove(userid.getKey()); | ||
288 | 348 | editor.remove(password.getKey()); | ||
289 | 317 | editor.commit(); | 349 | editor.commit(); |
290 | 318 | ConnectionPreferenceActivity.this.onBackPressed(); | 350 | ConnectionPreferenceActivity.this.onBackPressed(); |
291 | 319 | return false; | 351 | return false; |
292 | @@ -336,6 +368,11 @@ | |||
293 | 336 | editor.putString(getString(R.string.keyPort), port); | 368 | editor.putString(getString(R.string.keyPort), port); |
294 | 337 | Boolean bUseSsl = preferences.getBoolean(useSsl.getKey(), false); | 369 | Boolean bUseSsl = preferences.getBoolean(useSsl.getKey(), false); |
295 | 338 | editor.putBoolean(getString(R.string.key_ssl_use), bUseSsl); | 370 | editor.putBoolean(getString(R.string.key_ssl_use), bUseSsl); |
296 | 371 | String suserid = preferences.getString(userid.getKey(), getString(R.string.useridDefaultValue)); | ||
297 | 372 | editor.putString(getString(R.string.key_userid), suserid); | ||
298 | 373 | String spassword = preferences.getString(password.getKey(), | ||
299 | 374 | getString(R.string.passwordDefaultValue)); | ||
300 | 375 | editor.putString(getString(R.string.key_password), spassword); | ||
301 | 339 | 376 | ||
302 | 340 | editor.putString( | 377 | editor.putString( |
303 | 341 | getString(R.string.key_profile_selected_title), | 378 | getString(R.string.key_profile_selected_title), |
304 | 342 | 379 | ||
305 | === modified file 'src/org/openlp/android/activity/preference/Preferences.java' | |||
306 | --- src/org/openlp/android/activity/preference/Preferences.java 2012-05-31 20:07:41 +0000 | |||
307 | +++ src/org/openlp/android/activity/preference/Preferences.java 2013-04-07 12:27:25 +0000 | |||
308 | @@ -1,8 +1,8 @@ | |||
309 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
310 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
311 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
314 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
315 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
316 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
317 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
318 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
319 | 9 | 9 | ||
320 | === modified file 'src/org/openlp/android/api/Api.java' | |||
321 | --- src/org/openlp/android/api/Api.java 2012-05-01 18:49:58 +0000 | |||
322 | +++ src/org/openlp/android/api/Api.java 2013-04-07 12:27:25 +0000 | |||
323 | @@ -1,8 +1,8 @@ | |||
324 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
325 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
326 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
329 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
330 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
331 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
332 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
333 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
334 | 9 | 9 | ||
335 | === added file 'src/org/openlp/android/data/HttpReturn.java' | |||
336 | --- src/org/openlp/android/data/HttpReturn.java 1970-01-01 00:00:00 +0000 | |||
337 | +++ src/org/openlp/android/data/HttpReturn.java 2013-04-07 12:27:25 +0000 | |||
338 | @@ -0,0 +1,53 @@ | |||
339 | 1 | /****************************************************************************** | ||
340 | 2 | * OpenLP - Open Source Lyrics Projection * | ||
341 | 3 | * --------------------------------------------------------------------------- * | ||
342 | 4 | * Copyright (c) 2011-2013 Raoul Snyman * | ||
343 | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * | ||
344 | 6 | * Sjöbergsson * | ||
345 | 7 | * --------------------------------------------------------------------------- * | ||
346 | 8 | * This program is free software; you can redistribute it and/or modify it * | ||
347 | 9 | * under the terms of the GNU General Public License as published by the Free * | ||
348 | 10 | * Software Foundation; version 2 of the License. * | ||
349 | 11 | * * | ||
350 | 12 | * This program is distributed in the hope that it will be useful, but WITHOUT * | ||
351 | 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * | ||
352 | 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * | ||
353 | 15 | * more details. * | ||
354 | 16 | * * | ||
355 | 17 | * You should have received a copy of the GNU General Public License along * | ||
356 | 18 | * with this program; if not, write to the Free Software Foundation, Inc., 59 * | ||
357 | 19 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA * | ||
358 | 20 | *******************************************************************************/ | ||
359 | 21 | package org.openlp.android.data; | ||
360 | 22 | |||
361 | 23 | import android.content.Context; | ||
362 | 24 | import org.openlp.android.R; | ||
363 | 25 | |||
364 | 26 | public class HttpReturn { | ||
365 | 27 | private int return_code = 0; | ||
366 | 28 | private String data = null; | ||
367 | 29 | private Context context; | ||
368 | 30 | |||
369 | 31 | public HttpReturn(int return_code, String data, Context context) { | ||
370 | 32 | this.return_code = return_code; | ||
371 | 33 | this.data = data; | ||
372 | 34 | this.context = context; | ||
373 | 35 | } | ||
374 | 36 | |||
375 | 37 | public String getData() { | ||
376 | 38 | return this.data; | ||
377 | 39 | } | ||
378 | 40 | |||
379 | 41 | public boolean isError() { | ||
380 | 42 | return return_code != 0; | ||
381 | 43 | } | ||
382 | 44 | |||
383 | 45 | public String getErrorMessage(String message) { | ||
384 | 46 | return return_code == 401 ? this.context.getString(R.string.httpreturn_unauthorised) : message; | ||
385 | 47 | } | ||
386 | 48 | |||
387 | 49 | @Override | ||
388 | 50 | public String toString() { | ||
389 | 51 | return "HttpReturn{" + "data='" + data + '\'' + ", return code=" + return_code + '}'; | ||
390 | 52 | } | ||
391 | 53 | } | ||
392 | 0 | 54 | ||
393 | === modified file 'src/org/openlp/android/data/Poll.java' | |||
394 | --- src/org/openlp/android/data/Poll.java 2012-05-05 17:29:57 +0000 | |||
395 | +++ src/org/openlp/android/data/Poll.java 2013-04-07 12:27:25 +0000 | |||
396 | @@ -1,8 +1,8 @@ | |||
397 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
398 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
399 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
402 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
403 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
404 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
405 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
406 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
407 | 9 | 9 | ||
408 | === modified file 'src/org/openlp/android/data/SlideItem.java' | |||
409 | --- src/org/openlp/android/data/SlideItem.java 2012-03-04 17:20:44 +0000 | |||
410 | +++ src/org/openlp/android/data/SlideItem.java 2013-04-07 12:27:25 +0000 | |||
411 | @@ -1,8 +1,8 @@ | |||
412 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
413 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
414 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
417 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
418 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
419 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
420 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
421 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
422 | 9 | 9 | ||
423 | === modified file 'src/org/openlp/android/service/ApiCallIntent.java' | |||
424 | --- src/org/openlp/android/service/ApiCallIntent.java 2012-05-12 19:40:12 +0000 | |||
425 | +++ src/org/openlp/android/service/ApiCallIntent.java 2013-04-07 12:27:25 +0000 | |||
426 | @@ -1,8 +1,8 @@ | |||
427 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
428 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
429 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
432 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
433 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
434 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
435 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
436 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
437 | @@ -23,9 +23,11 @@ | |||
438 | 23 | import android.app.IntentService; | 23 | import android.app.IntentService; |
439 | 24 | import android.content.Intent; | 24 | import android.content.Intent; |
440 | 25 | import android.util.Log; | 25 | import android.util.Log; |
441 | 26 | import org.openlp.android.R; | ||
442 | 26 | import org.openlp.android.activity.Search; | 27 | import org.openlp.android.activity.Search; |
443 | 27 | import org.openlp.android.activity.SearchService; | 28 | import org.openlp.android.activity.SearchService; |
444 | 28 | import org.openlp.android.api.Api; | 29 | import org.openlp.android.api.Api; |
445 | 30 | import org.openlp.android.data.HttpReturn; | ||
446 | 29 | import org.openlp.android.utility.JSONHandler; | 31 | import org.openlp.android.utility.JSONHandler; |
447 | 30 | import org.openlp.android.utility.OpenLPHttpClient; | 32 | import org.openlp.android.utility.OpenLPHttpClient; |
448 | 31 | 33 | ||
449 | @@ -38,265 +40,247 @@ | |||
450 | 38 | * from an OpenLP server. | 40 | * from an OpenLP server. |
451 | 39 | */ | 41 | */ |
452 | 40 | public class ApiCallIntent extends IntentService implements SearchService { | 42 | public class ApiCallIntent extends IntentService implements SearchService { |
714 | 41 | public static final String API_CALL_RECEIVE = | 43 | public static final String API_CALL_RECEIVE = |
715 | 42 | ApiCallIntent.class.getName().concat(".Receive"); | 44 | ApiCallIntent.class.getName().concat(".Receive"); |
716 | 43 | 45 | ||
717 | 44 | public ApiCallIntent() { | 46 | public ApiCallIntent() { |
718 | 45 | super(ApiCallIntent.class.getName()); | 47 | super(ApiCallIntent.class.getName()); |
719 | 46 | } | 48 | } |
720 | 47 | 49 | ||
721 | 48 | /** | 50 | /** |
722 | 49 | * apiPart is one of the strings set in {@link org.openlp.android.api.Api} | 51 | * apiPart is one of the strings set in {@link org.openlp.android.api.Api} |
723 | 50 | * apiCall is when the requested apiPart takes input | 52 | * apiCall is when the requested apiPart takes input |
724 | 51 | * | 53 | * |
725 | 52 | * @param intent The intent requesting data | 54 | * @param intent The intent requesting data |
726 | 53 | */ | 55 | */ |
727 | 54 | @Override | 56 | @Override |
728 | 55 | protected void onHandleIntent(Intent intent) { | 57 | protected void onHandleIntent(Intent intent) { |
729 | 56 | Log.v(LOG_TAG, "Executing WebCallIntent from: " + intent); | 58 | Log.v(LOG_TAG, "Executing WebCallIntent from: " + intent); |
730 | 57 | Intent apiCallReceiverIntent = null; | 59 | Intent apiCallReceiverIntent = null; |
731 | 58 | 60 | ||
732 | 59 | try { | 61 | try { |
733 | 60 | if (intent.hasExtra(Api.ALERT)) { | 62 | if (intent.hasExtra(Api.ALERT)) { |
734 | 61 | String alertData = JSONHandler.createRequestJSON("text", | 63 | String alertData = JSONHandler.createRequestJSON("text", |
735 | 62 | intent.getStringExtra(Api.ALERT)); | 64 | intent.getStringExtra(Api.ALERT)); |
736 | 63 | apiCallReceiverIntent = executeAlert(alertData); | 65 | apiCallReceiverIntent = executeAlert(alertData); |
737 | 64 | } | 66 | } else if (intent.hasExtra(Api.SERVICE_BASE)) { |
738 | 65 | else if (intent.hasExtra(Api.SERVICE_BASE)) { | 67 | apiCallReceiverIntent = executeNavigation(Api.SERVICE_BASE, |
739 | 66 | apiCallReceiverIntent = executeNavigation(Api.SERVICE_BASE, | 68 | intent.getStringExtra(Api.SERVICE_BASE)); |
740 | 67 | intent.getStringExtra(Api.SERVICE_BASE)); | 69 | } else if (intent.hasExtra(Api.LIVE_BASE)) { |
741 | 68 | } | 70 | apiCallReceiverIntent = executeNavigation(Api.LIVE_BASE, |
742 | 69 | else if (intent.hasExtra(Api.LIVE_BASE)) { | 71 | intent.getStringExtra(Api.LIVE_BASE)); |
743 | 70 | apiCallReceiverIntent = executeNavigation(Api.LIVE_BASE, | 72 | } else if (intent.hasExtra(Api.DISPLAY_BASE)) { |
744 | 71 | intent.getStringExtra(Api.LIVE_BASE)); | 73 | apiCallReceiverIntent = executeNavigation(Api.DISPLAY_BASE, |
745 | 72 | } | 74 | intent.getStringExtra(Api.DISPLAY_BASE)); |
746 | 73 | else if (intent.hasExtra(Api.DISPLAY_BASE)) { | 75 | } else if (intent.hasExtra(Api.POLL_STATUS)) { |
747 | 74 | apiCallReceiverIntent = executeNavigation(Api.DISPLAY_BASE, | 76 | apiCallReceiverIntent = executePoll(); |
748 | 75 | intent.getStringExtra(Api.DISPLAY_BASE)); | 77 | } else if (intent.hasExtra(Api.LIVE_TEXT)) { |
749 | 76 | } | 78 | apiCallReceiverIntent = executeItemFetch(Api.LIVE_TEXT); |
750 | 77 | else if (intent.hasExtra(Api.POLL_STATUS)) { | 79 | } else if (intent.hasExtra(Api.SERVICE_LIST)) { |
751 | 78 | apiCallReceiverIntent = executePoll(); | 80 | apiCallReceiverIntent = executeItemFetch(Api.SERVICE_LIST); |
752 | 79 | } | 81 | } else if (intent.hasExtra(Api.LIVE_SET)) { |
753 | 80 | else if (intent.hasExtra(Api.LIVE_TEXT)) { | 82 | apiCallReceiverIntent = executeSetData(Api.LIVE_SET, |
754 | 81 | apiCallReceiverIntent = executeItemFetch(Api.LIVE_TEXT); | 83 | intent.getIntExtra(Api.LIVE_SET, 0)); |
755 | 82 | } | 84 | } else if (intent.hasExtra(Api.SERVICE_SET)) { |
756 | 83 | else if (intent.hasExtra(Api.SERVICE_LIST)) { | 85 | apiCallReceiverIntent = executeSetData(Api.SERVICE_SET, |
757 | 84 | apiCallReceiverIntent = executeItemFetch(Api.SERVICE_LIST); | 86 | intent.getIntExtra(Api.SERVICE_SET, 0)); |
758 | 85 | } | 87 | } |
759 | 86 | else if (intent.hasExtra(Api.LIVE_SET)) { | 88 | |
760 | 87 | apiCallReceiverIntent = executeSetData(Api.LIVE_SET, | 89 | if (apiCallReceiverIntent == null) { |
761 | 88 | intent.getIntExtra(Api.LIVE_SET, 0)); | 90 | |
762 | 89 | } | 91 | // match wildcard intent keys |
763 | 90 | else if (intent.hasExtra(Api.SERVICE_SET)) { | 92 | for (String key : intent.getExtras().keySet()) { |
764 | 91 | apiCallReceiverIntent = executeSetData(Api.SERVICE_SET, | 93 | if (key.matches("/api/\\w+\\W?\\w+/live\\?data=") || |
765 | 92 | intent.getIntExtra(Api.SERVICE_SET, 0)); | 94 | key.matches("/api/\\w+\\W?\\w+/add\\?data=")) { |
766 | 93 | } | 95 | apiCallReceiverIntent = getSearchPluginIntent(key, |
767 | 94 | 96 | intent.getStringExtra(key)); | |
768 | 95 | if (apiCallReceiverIntent == null) { | 97 | break; |
769 | 96 | 98 | } | |
770 | 97 | // match wildcard intent keys | 99 | } |
771 | 98 | for (String key : intent.getExtras().keySet()) { | 100 | |
772 | 99 | if (key.matches("/api/\\w+\\W?\\w+/live\\?data=") || | 101 | if (apiCallReceiverIntent == null) { |
773 | 100 | key.matches("/api/\\w+\\W?\\w+/add\\?data=")) { | 102 | String nyiMessage = |
774 | 101 | apiCallReceiverIntent = getSearchPluginIntent(key, | 103 | "Not yet Implemented for calls with these extras: " + |
775 | 102 | intent.getStringExtra(key)); | 104 | intent.getExtras(); |
776 | 103 | break; | 105 | Log.w(LOG_TAG, nyiMessage); |
777 | 104 | } | 106 | apiCallReceiverIntent = new WebCallReceiverIntent( |
778 | 105 | } | 107 | new WebCallReceiverIntentError(nyiMessage)); |
779 | 106 | 108 | } | |
780 | 107 | if (apiCallReceiverIntent == null) { | 109 | } |
781 | 108 | String nyiMessage = | 110 | } catch (Exception e) { |
782 | 109 | "Not yet Implemented for calls with these extras: " + | 111 | Log.e(LOG_TAG, e.toString()); |
783 | 110 | intent.getExtras(); | 112 | apiCallReceiverIntent = new WebCallReceiverIntent( |
784 | 111 | Log.w(LOG_TAG, nyiMessage); | 113 | new WebCallReceiverIntentError(String |
785 | 112 | apiCallReceiverIntent = new WebCallReceiverIntent( | 114 | .format("%s: %s", e.getClass().getSimpleName(), |
786 | 113 | new WebCallReceiverIntentError(nyiMessage)); | 115 | e.getMessage()))); |
787 | 114 | } | 116 | Log.w(LOG_TAG, |
788 | 115 | } | 117 | "Sending Broadcast with error: " + apiCallReceiverIntent); |
789 | 116 | } | 118 | } |
790 | 117 | catch (Exception e) { | 119 | sendBroadcast(apiCallReceiverIntent); |
791 | 118 | Log.e(LOG_TAG, e.toString()); | 120 | } |
792 | 119 | apiCallReceiverIntent = new WebCallReceiverIntent( | 121 | |
793 | 120 | new WebCallReceiverIntentError(String | 122 | @Override |
794 | 121 | .format("%s: %s", e.getClass().getSimpleName(), | 123 | public Intent getSearchPluginIntent(String apiBase, String apiData) |
795 | 122 | e.getMessage()))); | 124 | throws JSONHandler.JSONHandlerException, IOException, |
796 | 123 | Log.w(LOG_TAG, | 125 | URISyntaxException { |
797 | 124 | "Sending Broadcast with error: " + apiCallReceiverIntent); | 126 | Intent apiCallSearchReceiverIntent = |
798 | 125 | } | 127 | new WebCallReceiverIntent(apiBase, apiData); |
799 | 126 | sendBroadcast(apiCallReceiverIntent); | 128 | apiCallSearchReceiverIntent |
800 | 127 | } | 129 | .setAction(Search.ACTION); //override default receiver action |
801 | 128 | 130 | String jsonRequest = JSONHandler.createRequestJSON("id", apiData); | |
802 | 129 | @Override | 131 | |
803 | 130 | public Intent getSearchPluginIntent(String apiBase, String apiData) | 132 | OpenLPHttpClient httpClient = |
804 | 131 | throws JSONHandler.JSONHandlerException, IOException, | 133 | getApiConfiguredClient(apiBase, jsonRequest); |
805 | 132 | URISyntaxException { | 134 | HttpReturn result = httpClient.handleExecute(); |
806 | 133 | Intent apiCallSearchReceiverIntent = | 135 | |
807 | 134 | new WebCallReceiverIntent(apiBase, apiData); | 136 | if (result.isError()) { |
808 | 135 | apiCallSearchReceiverIntent | 137 | apiCallSearchReceiverIntent = new WebCallReceiverIntent( |
809 | 136 | .setAction(Search.ACTION); //override default receiver action | 138 | new WebCallReceiverIntentError(result.getErrorMessage( |
810 | 137 | String jsonRequest = JSONHandler.createRequestJSON("id", apiData); | 139 | String.valueOf(R.string.apiCallIntent_search)))); |
811 | 138 | 140 | apiCallSearchReceiverIntent.setAction(Search.ACTION); | |
812 | 139 | OpenLPHttpClient httpClient = | 141 | } else { |
813 | 140 | getApiConfiguredClient(apiBase, jsonRequest); | 142 | Log.d(LOG_TAG, "searchPluginCall result: " + result.getData()); |
814 | 141 | String result = httpClient.handleExecute(); | 143 | } |
815 | 142 | 144 | ||
816 | 143 | if (result == null) { | 145 | return apiCallSearchReceiverIntent; |
817 | 144 | apiCallSearchReceiverIntent = new WebCallReceiverIntent( | 146 | } |
818 | 145 | new WebCallReceiverIntentError( | 147 | |
819 | 146 | "Unexpected null result during searchPluginCall.")); | 148 | private Intent executeAlert(String alertData) |
820 | 147 | apiCallSearchReceiverIntent.setAction(Search.ACTION); | 149 | throws IOException, URISyntaxException { |
821 | 148 | } | 150 | Intent apiCallReceiverIntent = |
822 | 149 | else { | 151 | new WebCallReceiverIntent(Api.ALERT, alertData); |
823 | 150 | Log.d(LOG_TAG, "searchPluginCall result: " + result); | 152 | OpenLPHttpClient httpClient = |
824 | 151 | } | 153 | getApiConfiguredClient(Api.ALERT, alertData); |
825 | 152 | 154 | ||
826 | 153 | return apiCallSearchReceiverIntent; | 155 | HttpReturn result = httpClient.handleExecute(); |
827 | 154 | } | 156 | if (result.isError()) { |
828 | 155 | 157 | apiCallReceiverIntent = new WebCallReceiverIntent( | |
829 | 156 | private Intent executeAlert(String alertData) | 158 | new WebCallReceiverIntentError(result.getErrorMessage( |
830 | 157 | throws IOException, URISyntaxException { | 159 | String.valueOf(R.string.apiCallIntent_alert)))); |
831 | 158 | Intent apiCallReceiverIntent = | 160 | } else { |
832 | 159 | new WebCallReceiverIntent(Api.ALERT, alertData); | 161 | Log.d(LOG_TAG, "Alert result: " + result.getData()); |
833 | 160 | OpenLPHttpClient httpClient = | 162 | } |
834 | 161 | getApiConfiguredClient(Api.ALERT, alertData); | 163 | |
835 | 162 | 164 | return apiCallReceiverIntent; | |
836 | 163 | String result = httpClient.handleExecute(); | 165 | } |
837 | 164 | if (result == null) { | 166 | |
838 | 165 | apiCallReceiverIntent = new WebCallReceiverIntent( | 167 | private Intent executeNavigation(final String apiBase, final String apiData) |
839 | 166 | new WebCallReceiverIntentError( | 168 | throws IOException, URISyntaxException { |
840 | 167 | "Unexpected null result during alert call.")); | 169 | Intent apiCallReceiverIntent = |
841 | 168 | } | 170 | new WebCallReceiverIntent(apiBase, apiData); |
842 | 169 | else { | 171 | OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, apiData); |
843 | 170 | Log.d(LOG_TAG, "Alert result: " + result); | 172 | |
844 | 171 | } | 173 | HttpReturn result = httpClient.handleExecute(); |
845 | 172 | 174 | if (result.isError()) { | |
846 | 173 | return apiCallReceiverIntent; | 175 | apiCallReceiverIntent = new WebCallReceiverIntent( |
847 | 174 | } | 176 | new WebCallReceiverIntentError(result.getErrorMessage( |
848 | 175 | 177 | String.valueOf(R.string.apiCallIntent_navigation)))); | |
849 | 176 | private Intent executeNavigation(final String apiBase, final String apiData) | 178 | } else { |
850 | 177 | throws IOException, URISyntaxException { | 179 | Log.d(LOG_TAG, "Navigation result: " + result.getData()); |
851 | 178 | Intent apiCallReceiverIntent = | 180 | } |
852 | 179 | new WebCallReceiverIntent(apiBase, apiData); | 181 | |
853 | 180 | OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, apiData); | 182 | return apiCallReceiverIntent; |
854 | 181 | 183 | } | |
855 | 182 | String result = httpClient.handleExecute(); | 184 | |
856 | 183 | if (result == null) { | 185 | private Intent executeSetData(String apiBase, int position) |
857 | 184 | apiCallReceiverIntent = new WebCallReceiverIntent( | 186 | throws JSONHandler.JSONHandlerException, IOException, |
858 | 185 | new WebCallReceiverIntentError( | 187 | URISyntaxException { |
859 | 186 | "Unexpected null result during navigation.")); | 188 | String request = JSONHandler.createRequestJSON("id", Integer.toString(position)); |
860 | 187 | } | 189 | Intent apiCallreceiverIntent = new WebCallReceiverIntent(apiBase, request); |
861 | 188 | else { | 190 | OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, request); |
862 | 189 | Log.d(LOG_TAG, "Navigation result: " + result); | 191 | |
863 | 190 | } | 192 | HttpReturn result = httpClient.handleExecute(); |
864 | 191 | 193 | if (result.isError()) { | |
865 | 192 | return apiCallReceiverIntent; | 194 | String message = String.format( |
866 | 193 | } | 195 | "Unexpected null result while setting list data. apiBase(%s), position(%s)", |
867 | 194 | 196 | apiBase, position); | |
868 | 195 | private Intent executeSetData(String apiBase, int position) | 197 | Log.e(LOG_TAG, message); |
869 | 196 | throws JSONHandler.JSONHandlerException, IOException, | 198 | apiCallreceiverIntent = new WebCallReceiverIntent( |
870 | 197 | URISyntaxException { | 199 | new WebCallReceiverIntentError(result.getErrorMessage( |
871 | 198 | String request = | 200 | String.valueOf(R.string.apiCallIntent_list_data)))); |
872 | 199 | JSONHandler.createRequestJSON("id", Integer.toString(position)); | 201 | } else { |
873 | 200 | Intent apiCallreceiverIntent = | 202 | Log.d(LOG_TAG, "setData result: " + result.getData()); |
874 | 201 | new WebCallReceiverIntent(apiBase, request); | 203 | } |
875 | 202 | OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, request); | 204 | |
876 | 203 | 205 | return apiCallreceiverIntent; | |
877 | 204 | String result = httpClient.handleExecute(); | 206 | } |
878 | 205 | if (result == null) { | 207 | |
879 | 206 | String message = String.format( | 208 | private Intent executePoll() throws IOException, URISyntaxException, |
880 | 207 | "Unexpected null result while setting list data. apiBase(%s), position(%s)", | 209 | JSONHandler.JSONHandlerException { |
881 | 208 | apiBase, position); | 210 | Intent apiCallReceiverIntent = new WebCallReceiverIntent(Api.POLL_STATUS, ""); |
882 | 209 | Log.e(LOG_TAG, message); | 211 | OpenLPHttpClient httpClient = getApiConfiguredClient(Api.POLL_STATUS); |
883 | 210 | apiCallreceiverIntent = new WebCallReceiverIntent( | 212 | |
884 | 211 | new WebCallReceiverIntentError( | 213 | HttpReturn pollJson = httpClient.handleExecute(); |
885 | 212 | "Unexpected null result while setting list data.")); | 214 | if (pollJson.isError()) { |
886 | 213 | } | 215 | apiCallReceiverIntent = new WebCallReceiverIntent( |
887 | 214 | else { | 216 | new WebCallReceiverIntentError(pollJson.getErrorMessage( |
888 | 215 | Log.d(LOG_TAG, "setData result: " + result); | 217 | String.valueOf(R.string.apiCallIntent_poll)))); |
889 | 216 | } | 218 | } else { |
890 | 217 | 219 | Log.d(LOG_TAG, "Poll result: " + pollJson); | |
891 | 218 | return apiCallreceiverIntent; | 220 | apiCallReceiverIntent.putExtra("pollJson", pollJson.getData()); |
892 | 219 | } | 221 | } |
893 | 220 | 222 | return apiCallReceiverIntent; | |
894 | 221 | private Intent executePoll() throws IOException, URISyntaxException, | 223 | } |
895 | 222 | JSONHandler.JSONHandlerException { | 224 | |
896 | 223 | Intent apiCallReceiverIntent = | 225 | private Intent executeItemFetch(final String apiBase) |
897 | 224 | new WebCallReceiverIntent(Api.POLL_STATUS, ""); | 226 | throws IOException, URISyntaxException { |
898 | 225 | OpenLPHttpClient httpClient = getApiConfiguredClient(Api.POLL_STATUS); | 227 | Intent apiCallReceiverIntent = new WebCallReceiverIntent(apiBase, ""); |
899 | 226 | 228 | OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase); | |
900 | 227 | String pollJson = httpClient.handleExecute(); | 229 | |
901 | 228 | if (pollJson == null) { | 230 | HttpReturn itemsJson = httpClient.handleExecute(); |
902 | 229 | apiCallReceiverIntent = new WebCallReceiverIntent( | 231 | if (itemsJson.isError()) { |
903 | 230 | new WebCallReceiverIntentError( | 232 | apiCallReceiverIntent = new WebCallReceiverIntent( |
904 | 231 | "Unexpected null result during status poll.")); | 233 | new WebCallReceiverIntentError( |
905 | 232 | } | 234 | itemsJson.getErrorMessage(String.valueOf(R.string.apiCallIntent_fetch)))); |
906 | 233 | else { | 235 | } else { |
907 | 234 | Log.d(LOG_TAG, "Poll result: " + pollJson); | 236 | Log.d(LOG_TAG, "Items JSON: " + itemsJson); |
908 | 235 | apiCallReceiverIntent.putExtra("pollJson", pollJson); | 237 | apiCallReceiverIntent.putExtra("itemsJson", itemsJson.getData()); |
909 | 236 | } | 238 | } |
910 | 237 | return apiCallReceiverIntent; | 239 | return apiCallReceiverIntent; |
911 | 238 | } | 240 | } |
912 | 239 | 241 | ||
913 | 240 | private Intent executeItemFetch(final String apiBase) | 242 | private OpenLPHttpClient getApiConfiguredClient(String apiBase, |
914 | 241 | throws IOException, URISyntaxException { | 243 | String partData) throws MalformedURLException, URISyntaxException { |
915 | 242 | Intent apiCallReceiverIntent = new WebCallReceiverIntent(apiBase, ""); | 244 | OpenLPHttpClient httpClient = |
916 | 243 | OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase); | 245 | new OpenLPHttpClient(getApplicationContext()); |
917 | 244 | 246 | httpClient.setUrl(String.format("%s%s", apiBase, partData)); | |
918 | 245 | String itemsJson = httpClient.handleExecute(); | 247 | return httpClient; |
919 | 246 | if (itemsJson == null) { | 248 | } |
920 | 247 | apiCallReceiverIntent = new WebCallReceiverIntent( | 249 | |
921 | 248 | new WebCallReceiverIntentError( | 250 | private OpenLPHttpClient getApiConfiguredClient(String apiBase) |
922 | 249 | "Unexpected null result while fetching itmes.")); | 251 | throws MalformedURLException, URISyntaxException { |
923 | 250 | } | 252 | return getApiConfiguredClient(apiBase, ""); |
924 | 251 | else { | 253 | } |
925 | 252 | Log.d(LOG_TAG, "Items JSON: " + itemsJson); | 254 | |
926 | 253 | apiCallReceiverIntent.putExtra("itemsJson", itemsJson); | 255 | private final String LOG_TAG = ApiCallIntent.class.getName(); |
927 | 254 | } | 256 | |
928 | 255 | return apiCallReceiverIntent; | 257 | class WebCallReceiverIntent extends Intent { |
929 | 256 | } | 258 | WebCallReceiverIntent() { |
930 | 257 | 259 | setDefaults(); | |
931 | 258 | private OpenLPHttpClient getApiConfiguredClient(String apiBase, | 260 | } |
932 | 259 | String partData) throws MalformedURLException, URISyntaxException { | 261 | |
933 | 260 | OpenLPHttpClient httpClient = | 262 | WebCallReceiverIntent(WebCallReceiverIntentError error) { |
934 | 261 | new OpenLPHttpClient(getApplicationContext()); | 263 | setDefaults(); |
935 | 262 | httpClient.setUrl(String.format("%s%s", apiBase, partData)); | 264 | WebCallReceiverIntent.this.putExtra("error", error.message); |
936 | 263 | return httpClient; | 265 | } |
937 | 264 | } | 266 | |
938 | 265 | 267 | WebCallReceiverIntent(String apiBase, String apiData) { | |
939 | 266 | private OpenLPHttpClient getApiConfiguredClient(String apiBase) | 268 | setDefaults(); |
940 | 267 | throws MalformedURLException, URISyntaxException { | 269 | WebCallReceiverIntent.this.putExtra("apiBase", apiBase); |
941 | 268 | return getApiConfiguredClient(apiBase, ""); | 270 | WebCallReceiverIntent.this.putExtra("apiData", apiData); |
942 | 269 | } | 271 | } |
943 | 270 | 272 | ||
944 | 271 | private final String LOG_TAG = ApiCallIntent.class.getName(); | 273 | private void setDefaults() { |
945 | 272 | 274 | WebCallReceiverIntent.this.setAction(API_CALL_RECEIVE); | |
946 | 273 | class WebCallReceiverIntent extends Intent { | 275 | WebCallReceiverIntent.this.addCategory(Intent.CATEGORY_DEFAULT); |
947 | 274 | WebCallReceiverIntent() { | 276 | } |
948 | 275 | setDefaults(); | 277 | } |
949 | 276 | } | 278 | |
950 | 277 | 279 | class WebCallReceiverIntentError { | |
951 | 278 | WebCallReceiverIntent(WebCallReceiverIntentError error) { | 280 | final String message; |
952 | 279 | setDefaults(); | 281 | |
953 | 280 | WebCallReceiverIntent.this.putExtra("error", error.message); | 282 | WebCallReceiverIntentError(String error) { |
954 | 281 | } | 283 | this.message = error; |
955 | 282 | 284 | } | |
956 | 283 | WebCallReceiverIntent(String apiBase, String apiData) { | 285 | } |
696 | 284 | setDefaults(); | ||
697 | 285 | WebCallReceiverIntent.this.putExtra("apiBase", apiBase); | ||
698 | 286 | WebCallReceiverIntent.this.putExtra("apiData", apiData); | ||
699 | 287 | } | ||
700 | 288 | |||
701 | 289 | private void setDefaults() { | ||
702 | 290 | WebCallReceiverIntent.this.setAction(API_CALL_RECEIVE); | ||
703 | 291 | WebCallReceiverIntent.this.addCategory(Intent.CATEGORY_DEFAULT); | ||
704 | 292 | } | ||
705 | 293 | } | ||
706 | 294 | |||
707 | 295 | class WebCallReceiverIntentError { | ||
708 | 296 | final String message; | ||
709 | 297 | |||
710 | 298 | WebCallReceiverIntentError(String error) { | ||
711 | 299 | this.message = error; | ||
712 | 300 | } | ||
713 | 301 | } | ||
957 | 302 | } | 286 | } |
958 | 303 | 287 | ||
959 | === modified file 'src/org/openlp/android/service/PingIntent.java' | |||
960 | --- src/org/openlp/android/service/PingIntent.java 2012-05-06 15:53:56 +0000 | |||
961 | +++ src/org/openlp/android/service/PingIntent.java 2013-04-07 12:27:25 +0000 | |||
962 | @@ -1,8 +1,8 @@ | |||
963 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
964 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
965 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
968 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
969 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
970 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
971 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
972 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
973 | 9 | 9 | ||
974 | === modified file 'src/org/openlp/android/utility/GroupExpandableListAdapter.java' | |||
975 | --- src/org/openlp/android/utility/GroupExpandableListAdapter.java 2012-03-04 17:20:44 +0000 | |||
976 | +++ src/org/openlp/android/utility/GroupExpandableListAdapter.java 2013-04-07 12:27:25 +0000 | |||
977 | @@ -1,8 +1,8 @@ | |||
978 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
979 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
980 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
983 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
984 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
985 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
986 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
987 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
988 | 9 | 9 | ||
989 | === modified file 'src/org/openlp/android/utility/JSONHandler.java' | |||
990 | --- src/org/openlp/android/utility/JSONHandler.java 2012-05-05 17:34:31 +0000 | |||
991 | +++ src/org/openlp/android/utility/JSONHandler.java 2013-04-07 12:27:25 +0000 | |||
992 | @@ -1,8 +1,8 @@ | |||
993 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
994 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
995 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
998 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
999 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
1000 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
1001 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
1002 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
1003 | 9 | 9 | ||
1004 | === modified file 'src/org/openlp/android/utility/OpenLPController.java' | |||
1005 | --- src/org/openlp/android/utility/OpenLPController.java 2012-07-31 17:13:08 +0000 | |||
1006 | +++ src/org/openlp/android/utility/OpenLPController.java 2013-04-07 12:27:25 +0000 | |||
1007 | @@ -1,8 +1,8 @@ | |||
1008 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
1009 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
1010 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
1013 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
1014 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
1015 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
1016 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
1017 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
1018 | @@ -26,14 +26,17 @@ | |||
1019 | 26 | import android.content.Intent; | 26 | import android.content.Intent; |
1020 | 27 | import android.content.IntentFilter; | 27 | import android.content.IntentFilter; |
1021 | 28 | import android.content.SharedPreferences; | 28 | import android.content.SharedPreferences; |
1022 | 29 | import android.net.http.SslError; | ||
1023 | 29 | import android.support.v4.view.PagerAdapter; | 30 | import android.support.v4.view.PagerAdapter; |
1024 | 30 | import android.support.v4.view.ViewPager; | 31 | import android.support.v4.view.ViewPager; |
1025 | 31 | import android.util.Log; | 32 | import android.util.Log; |
1026 | 32 | import android.view.LayoutInflater; | 33 | import android.view.LayoutInflater; |
1027 | 33 | import android.view.View; | 34 | import android.view.View; |
1028 | 34 | import android.view.ViewGroup; | 35 | import android.view.ViewGroup; |
1029 | 36 | import android.webkit.SslErrorHandler; | ||
1030 | 35 | import android.webkit.WebSettings; | 37 | import android.webkit.WebSettings; |
1031 | 36 | import android.webkit.WebView; | 38 | import android.webkit.WebView; |
1032 | 39 | import android.webkit.WebViewClient; | ||
1033 | 37 | import android.widget.AdapterView; | 40 | import android.widget.AdapterView; |
1034 | 38 | import android.widget.Button; | 41 | import android.widget.Button; |
1035 | 39 | import android.widget.EditText; | 42 | import android.widget.EditText; |
1036 | @@ -360,6 +363,15 @@ | |||
1037 | 360 | 363 | ||
1038 | 361 | private WebView getWebViewFromView(View view) { | 364 | private WebView getWebViewFromView(View view) { |
1039 | 362 | WebView myWebView = (WebView) view.findViewById(R.id.stageview); | 365 | WebView myWebView = (WebView) view.findViewById(R.id.stageview); |
1040 | 366 | /* | ||
1041 | 367 | * Handle SSL self signed certificates and refresh the screen if the certificate | ||
1042 | 368 | * page appears. | ||
1043 | 369 | */ | ||
1044 | 370 | myWebView.setWebViewClient(new WebViewClient() { | ||
1045 | 371 | public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) { | ||
1046 | 372 | handler.proceed() ; | ||
1047 | 373 | } | ||
1048 | 374 | } ); | ||
1049 | 363 | WebSettings webSettings = myWebView.getSettings(); | 375 | WebSettings webSettings = myWebView.getSettings(); |
1050 | 364 | webSettings.setJavaScriptEnabled(true); | 376 | webSettings.setJavaScriptEnabled(true); |
1051 | 365 | webSettings.setBuiltInZoomControls(true); | 377 | webSettings.setBuiltInZoomControls(true); |
1052 | @@ -369,7 +381,6 @@ | |||
1053 | 369 | myWebView.setScrollbarFadingEnabled(true); | 381 | myWebView.setScrollbarFadingEnabled(true); |
1054 | 370 | 382 | ||
1055 | 371 | myWebView.loadUrl(getUrlBase()); | 383 | myWebView.loadUrl(getUrlBase()); |
1056 | 372 | |||
1057 | 373 | return myWebView; | 384 | return myWebView; |
1058 | 374 | } | 385 | } |
1059 | 375 | 386 | ||
1060 | 376 | 387 | ||
1061 | === modified file 'src/org/openlp/android/utility/OpenLPHttpClient.java' | |||
1062 | --- src/org/openlp/android/utility/OpenLPHttpClient.java 2012-05-23 21:37:47 +0000 | |||
1063 | +++ src/org/openlp/android/utility/OpenLPHttpClient.java 2013-04-07 12:27:25 +0000 | |||
1064 | @@ -1,8 +1,8 @@ | |||
1065 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
1066 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
1067 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
1070 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
1071 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
1072 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
1073 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
1074 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
1075 | @@ -47,6 +47,9 @@ | |||
1076 | 47 | import android.util.Log; | 47 | import android.util.Log; |
1077 | 48 | import org.apache.http.HttpEntity; | 48 | import org.apache.http.HttpEntity; |
1078 | 49 | import org.apache.http.HttpResponse; | 49 | import org.apache.http.HttpResponse; |
1079 | 50 | import org.apache.http.auth.AuthScope; | ||
1080 | 51 | import org.apache.http.auth.Credentials; | ||
1081 | 52 | import org.apache.http.auth.UsernamePasswordCredentials; | ||
1082 | 50 | import org.apache.http.client.methods.HttpGet; | 53 | import org.apache.http.client.methods.HttpGet; |
1083 | 51 | import org.apache.http.conn.scheme.PlainSocketFactory; | 54 | import org.apache.http.conn.scheme.PlainSocketFactory; |
1084 | 52 | import org.apache.http.conn.scheme.Scheme; | 55 | import org.apache.http.conn.scheme.Scheme; |
1085 | @@ -57,11 +60,11 @@ | |||
1086 | 57 | import org.apache.http.params.HttpConnectionParams; | 60 | import org.apache.http.params.HttpConnectionParams; |
1087 | 58 | import org.apache.http.params.HttpParams; | 61 | import org.apache.http.params.HttpParams; |
1088 | 59 | import org.openlp.android.R; | 62 | import org.openlp.android.R; |
1089 | 63 | import org.openlp.android.data.HttpReturn; | ||
1090 | 60 | 64 | ||
1091 | 61 | /** | 65 | /** |
1092 | 62 | * Personalised HttpClient to be used throughout OpenLP with customisable | 66 | * Personalised HttpClient to be used throughout OpenLP with customisable |
1093 | 63 | * parameters. | 67 | * parameters. |
1094 | 64 | * todo: accomodate https | ||
1095 | 65 | */ | 68 | */ |
1096 | 66 | public class OpenLPHttpClient extends DefaultHttpClient { | 69 | public class OpenLPHttpClient extends DefaultHttpClient { |
1097 | 67 | 70 | ||
1098 | @@ -69,6 +72,7 @@ | |||
1099 | 69 | private URL url; | 72 | private URL url; |
1100 | 70 | private final String urlBase; | 73 | private final String urlBase; |
1101 | 71 | private SSLSocketFactory sslSocketFactory; | 74 | private SSLSocketFactory sslSocketFactory; |
1102 | 75 | private Context context; | ||
1103 | 72 | 76 | ||
1104 | 73 | public OpenLPHttpClient(Context context) { | 77 | public OpenLPHttpClient(Context context) { |
1105 | 74 | SharedPreferences preferences = context.getSharedPreferences( | 78 | SharedPreferences preferences = context.getSharedPreferences( |
1106 | @@ -76,6 +80,8 @@ | |||
1107 | 76 | Context.MODE_PRIVATE); | 80 | Context.MODE_PRIVATE); |
1108 | 77 | HttpParams httpParams = new BasicHttpParams(); | 81 | HttpParams httpParams = new BasicHttpParams(); |
1109 | 78 | 82 | ||
1110 | 83 | this.context = context; | ||
1111 | 84 | |||
1112 | 79 | Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false); | 85 | Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false); |
1113 | 80 | 86 | ||
1114 | 81 | String port = preferences.getString( | 87 | String port = preferences.getString( |
1115 | @@ -83,7 +89,6 @@ | |||
1116 | 83 | context.getString(R.string.portDefaultValue) | 89 | context.getString(R.string.portDefaultValue) |
1117 | 84 | ); | 90 | ); |
1118 | 85 | 91 | ||
1119 | 86 | |||
1120 | 87 | SchemeRegistry schemeRegistry = getConnectionManager().getSchemeRegistry(); | 92 | SchemeRegistry schemeRegistry = getConnectionManager().getSchemeRegistry(); |
1121 | 88 | if (!useSsl) { | 93 | if (!useSsl) { |
1122 | 89 | schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Integer.valueOf(port))); | 94 | schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Integer.valueOf(port))); |
1123 | @@ -107,7 +112,23 @@ | |||
1124 | 107 | 112 | ||
1125 | 108 | } | 113 | } |
1126 | 109 | 114 | ||
1128 | 110 | urlBase = String.format("http%s://%s:%s", | 115 | String userid = preferences.getString( |
1129 | 116 | context.getString(R.string.key_userid), | ||
1130 | 117 | context.getString(R.string.useridDefaultValue) | ||
1131 | 118 | ); | ||
1132 | 119 | |||
1133 | 120 | |||
1134 | 121 | String password = preferences.getString( | ||
1135 | 122 | context.getString(R.string.key_password), | ||
1136 | 123 | context.getString(R.string.passwordDefaultValue) | ||
1137 | 124 | ); | ||
1138 | 125 | |||
1139 | 126 | Log.d(LOG_TAG, "Credentials set to " + userid + " : " + password); | ||
1140 | 127 | |||
1141 | 128 | Credentials creds = new UsernamePasswordCredentials(userid, password); | ||
1142 | 129 | getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds); | ||
1143 | 130 | |||
1144 | 131 | urlBase = String.format("http%s://%s:%s", | ||
1145 | 111 | useSsl ? "s" : "", | 132 | useSsl ? "s" : "", |
1146 | 112 | preferences.getString( | 133 | preferences.getString( |
1147 | 113 | context.getString(R.string.keyHost), | 134 | context.getString(R.string.keyHost), |
1148 | @@ -158,9 +179,11 @@ | |||
1149 | 158 | return super.execute(httpGet); | 179 | return super.execute(httpGet); |
1150 | 159 | } | 180 | } |
1151 | 160 | 181 | ||
1153 | 161 | public String handleExecute() throws IOException { | 182 | public HttpReturn handleExecute() throws IOException { |
1154 | 162 | HttpResponse response = this.execute(); | 183 | HttpResponse response = this.execute(); |
1155 | 163 | 184 | ||
1156 | 185 | Log.d(LOG_TAG, "Http response code " + String.valueOf(response.getStatusLine().getStatusCode())); | ||
1157 | 186 | |||
1158 | 164 | if (response.getStatusLine().getStatusCode() == 200) { | 187 | if (response.getStatusLine().getStatusCode() == 200) { |
1159 | 165 | BufferedReader bufferedReader; | 188 | BufferedReader bufferedReader; |
1160 | 166 | HttpEntity entity = response.getEntity(); | 189 | HttpEntity entity = response.getEntity(); |
1161 | @@ -175,10 +198,10 @@ | |||
1162 | 175 | line = bufferedReader.readLine(); | 198 | line = bufferedReader.readLine(); |
1163 | 176 | } | 199 | } |
1164 | 177 | bufferedReader.close(); | 200 | bufferedReader.close(); |
1166 | 178 | return stringBuilder.toString(); | 201 | return new HttpReturn(0, stringBuilder.toString(), this.context); |
1167 | 179 | } | 202 | } |
1168 | 180 | } | 203 | } |
1170 | 181 | return null; | 204 | return new HttpReturn(response.getStatusLine().getStatusCode() , null, this.context); |
1171 | 182 | } | 205 | } |
1172 | 183 | 206 | ||
1173 | 184 | public HttpEntity handleAndReturnEntity() throws IOException { | 207 | public HttpEntity handleAndReturnEntity() throws IOException { |
1174 | @@ -190,7 +213,8 @@ | |||
1175 | 190 | return null; | 213 | return null; |
1176 | 191 | } | 214 | } |
1177 | 192 | 215 | ||
1179 | 193 | private void initSsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException, IOException, CertificateException { | 216 | private void initSsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, |
1180 | 217 | UnrecoverableKeyException, IOException, CertificateException { | ||
1181 | 194 | final SSLContext sslContext = SSLContext.getInstance("TLS"); | 218 | final SSLContext sslContext = SSLContext.getInstance("TLS"); |
1182 | 195 | X509TrustManager trustManager = new X509TrustManager() { | 219 | X509TrustManager trustManager = new X509TrustManager() { |
1183 | 196 | @Override | 220 | @Override |
1184 | @@ -217,7 +241,8 @@ | |||
1185 | 217 | } | 241 | } |
1186 | 218 | 242 | ||
1187 | 219 | @Override | 243 | @Override |
1189 | 220 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException { | 244 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, |
1190 | 245 | UnknownHostException { | ||
1191 | 221 | return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); | 246 | return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); |
1192 | 222 | } | 247 | } |
1193 | 223 | }; | 248 | }; |
1194 | 224 | 249 | ||
1195 | === modified file 'src/org/openlp/android/utility/SlideAdapter.java' | |||
1196 | --- src/org/openlp/android/utility/SlideAdapter.java 2012-05-05 17:34:31 +0000 | |||
1197 | +++ src/org/openlp/android/utility/SlideAdapter.java 2013-04-07 12:27:25 +0000 | |||
1198 | @@ -1,8 +1,8 @@ | |||
1199 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
1200 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
1201 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
1204 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
1205 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
1206 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
1207 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
1208 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
1209 | 9 | 9 | ||
1210 | === modified file 'src/org/openlp/android/utility/StringHelper.java' | |||
1211 | --- src/org/openlp/android/utility/StringHelper.java 2012-03-04 10:56:34 +0000 | |||
1212 | +++ src/org/openlp/android/utility/StringHelper.java 2013-04-07 12:27:25 +0000 | |||
1213 | @@ -1,8 +1,8 @@ | |||
1214 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
1215 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
1216 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
1219 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
1220 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
1221 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
1222 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
1223 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
1224 | 9 | 9 | ||
1225 | === modified file 'src/org/openlp/android/utility/WebCallReturningAsyncTask.java' | |||
1226 | --- src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2012-05-24 21:06:55 +0000 | |||
1227 | +++ src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2013-04-07 12:27:25 +0000 | |||
1228 | @@ -1,8 +1,8 @@ | |||
1229 | 1 | /****************************************************************************** | 1 | /****************************************************************************** |
1230 | 2 | * OpenLP - Open Source Lyrics Projection * | 2 | * OpenLP - Open Source Lyrics Projection * |
1231 | 3 | * --------------------------------------------------------------------------- * | 3 | * --------------------------------------------------------------------------- * |
1234 | 4 | * Copyright (c) 2011-2012 Raoul Snyman * | 4 | * Copyright (c) 2011-2013 Raoul Snyman * |
1235 | 5 | * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel * | 5 | * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel * |
1236 | 6 | * Sjöbergsson * | 6 | * Sjöbergsson * |
1237 | 7 | * --------------------------------------------------------------------------- * | 7 | * --------------------------------------------------------------------------- * |
1238 | 8 | * This program is free software; you can redistribute it and/or modify it * | 8 | * This program is free software; you can redistribute it and/or modify it * |
Userid and password are saveed in config but cannot be read in client.
Not sure why this is happning any clues Johan