Merge lp:~trb143/openlp/android-2 into lp:openlp/android

Proposed by Tim Bentley
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
Reviewer Review Type Date Requested Status
Johan Mynhardt Approve
Review via email: mp+157543@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

Userid and password are saveed in config but cannot be read in client.
Not sure why this is happning any clues Johan

Revision history for this message
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?

Revision history for this message
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.

review: Needs Fixing
Revision history for this message
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!

Revision history for this message
Johan Mynhardt (johanmynhardt) :
review: Approve
Revision history for this message
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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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 xmlns:android="http://schemas.android.com/apk/res/android"
6 android:installLocation="auto"
7 package="org.openlp.android"
8- android:versionCode="1"
9- android:versionName="1.0"
10+ android:versionCode="7"
11+ android:versionName="1.1"
12 >
13 <uses-sdk android:minSdkVersion="8"/>
14 <uses-permission android:name="android.permission.INTERNET"/>
15
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 <string name="portDefaultValue">4316</string>
21 <string name="ssl.port.default">4317</string>
22 <string name="displayTypeValue">@string/displayScreen</string>
23+ <string name="useridDefaultValue">openlp</string>
24+ <string name="passwordDefaultValue">password</string>
25
26 <!-- INTEGER -->
27 <integer name="socketTimeoutDefaultValue">3000</integer>
28
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 <string name="keySocketTimeout">socketTimeout</string>
34 <string name="keyHost">keyHost</string>
35 <string name="keyPort">keyPort</string>
36+ <string name="key.userid">key.userid</string>
37+ <string name="key.password">key.password</string>
38 <string name="keySharedPreferences">keySharedPreferences</string>
39 <string name="key.ssl.use">ssl.use</string>
40 <string name="key.profile.selected.title">key.profile.selected.title</string>
41
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 <string name="connection.profile.ssl.summary">Specify whether SSL should be used</string>
47 <string name="connection.available.configurations">List of available profiles</string>
48 <string name="connection.add.by.menu">Tap to add a new profile</string>
49+ <string name="connection.userid">Userid</string>
50+ <string name="connection.password">Password</string>
51+ <string name="httpreturn.unauthorised">Unauthorised Access, please enter valid userid and password</string>
52+ <string name="apiCallIntent.search">Unexpected invalid result during Search Call.</string>
53+ <string name="apiCallIntent.alert">Unexpected invalid result during Alert call.</string>
54+ <string name="apiCallIntent.navigation">Unexpected invalid result during Navigation.</string>
55+ <string name="apiCallIntent.list_data">Unexpected invalid result while setting list data.</string>
56+ <string name="apiCallIntent.poll">Unexpected invalid result during status Poll.</string>
57+ <string name="apiCallIntent.fetch">Unexpected invalid result while fetching items.</string>
58 </resources>
59
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 /******************************************************************************
65 * OpenLP - Open Source Lyrics Projection *
66 * --------------------------------------------------------------------------- *
67- * Copyright (c) 2011-2012 Raoul Snyman *
68- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
69+ * Copyright (c) 2011-2013 Raoul Snyman *
70+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
71 * Sjöbergsson *
72 * --------------------------------------------------------------------------- *
73 * This program is free software; you can redistribute it and/or modify it *
74
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 /******************************************************************************
80 * OpenLP - Open Source Lyrics Projection *
81 * --------------------------------------------------------------------------- *
82- * Copyright (c) 2011-2012 Raoul Snyman *
83- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
84+ * Copyright (c) 2011-2013 Raoul Snyman *
85+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
86 * Sjöbergsson *
87 * --------------------------------------------------------------------------- *
88 * This program is free software; you can redistribute it and/or modify it *
89
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 /******************************************************************************
95 * OpenLP - Open Source Lyrics Projection *
96 * --------------------------------------------------------------------------- *
97- * Copyright (c) 2011-2012 Raoul Snyman *
98- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
99+ * Copyright (c) 2011-2013 Raoul Snyman *
100+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
101 * Sjöbergsson *
102 * --------------------------------------------------------------------------- *
103 * This program is free software; you can redistribute it and/or modify it *
104
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 /******************************************************************************
110 * OpenLP - Open Source Lyrics Projection *
111 * --------------------------------------------------------------------------- *
112- * Copyright (c) 2011-2012 Raoul Snyman *
113- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
114+ * Copyright (c) 2011-2013 Raoul Snyman *
115+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
116 * Sjöbergsson *
117 * --------------------------------------------------------------------------- *
118 * This program is free software; you can redistribute it and/or modify it *
119
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 /******************************************************************************
125 * OpenLP - Open Source Lyrics Projection *
126 * --------------------------------------------------------------------------- *
127- * Copyright (c) 2011-2012 Raoul Snyman *
128- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
129+ * Copyright (c) 2011-2013 Raoul Snyman *
130+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
131 * Sjöbergsson *
132 * --------------------------------------------------------------------------- *
133 * This program is free software; you can redistribute it and/or modify it *
134
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 /******************************************************************************
140 * OpenLP - Open Source Lyrics Projection *
141 * --------------------------------------------------------------------------- *
142- * Copyright (c) 2011-2012 Raoul Snyman *
143- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
144+ * Copyright (c) 2011-2013 Raoul Snyman *
145+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
146 * Sjöbergsson *
147 * --------------------------------------------------------------------------- *
148 * This program is free software; you can redistribute it and/or modify it *
149
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 /******************************************************************************
155 * OpenLP - Open Source Lyrics Projection *
156 * --------------------------------------------------------------------------- *
157- * Copyright (c) 2011-2012 Raoul Snyman *
158- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
159+ * Copyright (c) 2011-2013 Raoul Snyman *
160+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
161 * Sjöbergsson *
162 * --------------------------------------------------------------------------- *
163 * This program is free software; you can redistribute it and/or modify it *
164
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 /******************************************************************************
170 * OpenLP - Open Source Lyrics Projection *
171 * --------------------------------------------------------------------------- *
172- * Copyright (c) 2011-2012 Raoul Snyman *
173- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
174+ * Copyright (c) 2011-2013 Raoul Snyman *
175+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
176 * Sjöbergsson *
177 * --------------------------------------------------------------------------- *
178 * This program is free software; you can redistribute it and/or modify it *
179@@ -39,9 +39,6 @@
180 import android.preference.PreferenceScreen;
181 import android.text.InputType;
182 import android.util.Log;
183-import android.view.Menu;
184-import android.view.MenuInflater;
185-import android.view.MenuItem;
186 import android.widget.Toast;
187 import org.openlp.android.R;
188
189@@ -51,7 +48,6 @@
190 private final String PREFERENCE_DISPLAY_SERVER = "displayServer";
191 private final String LOG_TAG = ConnectionPreferenceActivity.class.getName();
192
193-
194 private PreferenceScreen preferenceScreen = null;
195 private boolean resume = true;
196
197@@ -197,11 +193,24 @@
198 ? getString(R.string.hostDefaultValue) : hostValueObject.toString();
199 hostConfig.hostAddress.setText(hostValue);
200 hostConfig.hostAddress.setSummary(hostValue);
201+
202 Object portValueObject = preferences.get(hostConfig.hostPort.getKey());
203 String portValue = portValueObject == null
204 ? getString(R.string.portDefaultValue) : portValueObject.toString();
205 hostConfig.hostPort.setText(portValue);
206 hostConfig.hostPort.setSummary(portValue);
207+
208+ Object useridValueObject = preferences.get(hostConfig.userid.getKey());
209+ String useridValue = useridValueObject == null
210+ ? getString(R.string.useridDefaultValue) : useridValueObject.toString();
211+ hostConfig.userid.setText(useridValue);
212+ hostConfig.userid.setSummary(useridValue);
213+
214+ Object passwordValueObject = preferences.get(hostConfig.password.getKey());
215+ String passwordValue = passwordValueObject == null
216+ ? getString(R.string.passwordDefaultValue) : passwordValueObject.toString();
217+ hostConfig.password.setText(passwordValue);
218+ hostConfig.password.setSummary(passwordValue);
219 return hostConfig;
220 }
221
222@@ -234,6 +243,8 @@
223 preferenceCategory.addPreference(hostConfig.hostAddress);
224 preferenceCategory.addPreference(hostConfig.hostPort);
225 preferenceCategory.addPreference(hostConfig.useSsl);
226+ preferenceCategory.addPreference(hostConfig.userid);
227+ preferenceCategory.addPreference(hostConfig.password);
228 preferenceCategory.addPreference(hostConfig.remove);
229 preferenceCategory.addPreference(hostConfig.activate);
230 return true;
231@@ -261,6 +272,8 @@
232 final EditTextPreference hostAddress;
233 final EditTextPreference hostPort;
234 final CheckBoxPreference useSsl;
235+ final EditTextPreference userid;
236+ final EditTextPreference password;
237 final Preference remove;
238 final Preference activate;
239
240@@ -282,10 +295,9 @@
241 hostAddress.getEditText().setHint(R.string.urlHint);
242 hostAddress.setSummary(getString(R.string.urlHint));
243 hostAddress.setDialogTitle(getString(R.string.urlHint));
244- hostAddress.getEditText().setInputType(
245- InputType.TYPE_TEXT_VARIATION_URI);
246- hostAddress.setOnPreferenceChangeListener(
247- onPreferenceChangeListener);
248+ hostAddress.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI);
249+ hostAddress.setOnPreferenceChangeListener(onPreferenceChangeListener);
250+
251 hostPort = new EditTextPreference(ConnectionPreferenceActivity.this);
252 hostPort.setTitle(getString(R.string.port));
253 hostPort.setKey(KEY_PREFIX + id + ".port");
254@@ -299,8 +311,26 @@
255 useSsl.setTitle(getString(R.string.connection_profile_ssl_use));
256 useSsl.setSummary(getString(R.string.connection_profile_ssl_summary));
257 useSsl.setKey(KEY_PREFIX + id + ".usessl");
258- // Only till SSL is added to core
259- useSsl.setEnabled(false);
260+
261+ userid = new EditTextPreference(ConnectionPreferenceActivity.this);
262+ userid.setSummary(getString(R.string.connection_userid));
263+ userid.getEditText().setHint(getString(R.string.connection_userid));
264+ userid.setTitle(getString(R.string.connection_userid));
265+ userid.setKey(KEY_PREFIX + id + ".userid");
266+ userid.setDefaultValue(getString(R.string.useridDefaultValue));
267+ userid.setSummary(getString(R.string.useridDefaultValue));
268+ userid.setDialogTitle(getString(R.string.connection_userid));
269+ userid.setOnPreferenceChangeListener(onPreferenceChangeListener);
270+
271+ password = new EditTextPreference(ConnectionPreferenceActivity.this);
272+ password.setSummary(getString(R.string.connection_password));
273+ password.getEditText().setHint(getString(R.string.connection_password));
274+ password.setTitle(getString(R.string.connection_password));
275+ password.setKey(KEY_PREFIX + id + ".password");
276+ password.setDefaultValue(getString(R.string.passwordDefaultValue));
277+ password.setSummary(getString(R.string.passwordDefaultValue));
278+ password.setDialogTitle(getString(R.string.connection_password));
279+ password.setOnPreferenceChangeListener(onPreferenceChangeListener);
280
281 remove = new Preference(ConnectionPreferenceActivity.this);
282 remove.setTitle(getString(R.string.connection_profile_remove));
283@@ -314,6 +344,8 @@
284 editor.remove(hostPort.getKey());
285 editor.remove(title.getKey());
286 editor.remove(useSsl.getKey());
287+ editor.remove(userid.getKey());
288+ editor.remove(password.getKey());
289 editor.commit();
290 ConnectionPreferenceActivity.this.onBackPressed();
291 return false;
292@@ -336,6 +368,11 @@
293 editor.putString(getString(R.string.keyPort), port);
294 Boolean bUseSsl = preferences.getBoolean(useSsl.getKey(), false);
295 editor.putBoolean(getString(R.string.key_ssl_use), bUseSsl);
296+ String suserid = preferences.getString(userid.getKey(), getString(R.string.useridDefaultValue));
297+ editor.putString(getString(R.string.key_userid), suserid);
298+ String spassword = preferences.getString(password.getKey(),
299+ getString(R.string.passwordDefaultValue));
300+ editor.putString(getString(R.string.key_password), spassword);
301
302 editor.putString(
303 getString(R.string.key_profile_selected_title),
304
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 /******************************************************************************
310 * OpenLP - Open Source Lyrics Projection *
311 * --------------------------------------------------------------------------- *
312- * Copyright (c) 2011-2012 Raoul Snyman *
313- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
314+ * Copyright (c) 2011-2013 Raoul Snyman *
315+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
316 * Sjöbergsson *
317 * --------------------------------------------------------------------------- *
318 * This program is free software; you can redistribute it and/or modify it *
319
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 /******************************************************************************
325 * OpenLP - Open Source Lyrics Projection *
326 * --------------------------------------------------------------------------- *
327- * Copyright (c) 2011-2012 Raoul Snyman *
328- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
329+ * Copyright (c) 2011-2013 Raoul Snyman *
330+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
331 * Sjöbergsson *
332 * --------------------------------------------------------------------------- *
333 * This program is free software; you can redistribute it and/or modify it *
334
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+/******************************************************************************
340+ * OpenLP - Open Source Lyrics Projection *
341+ * --------------------------------------------------------------------------- *
342+ * Copyright (c) 2011-2013 Raoul Snyman *
343+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
344+ * Sjöbergsson *
345+ * --------------------------------------------------------------------------- *
346+ * This program is free software; you can redistribute it and/or modify it *
347+ * under the terms of the GNU General Public License as published by the Free *
348+ * Software Foundation; version 2 of the License. *
349+ * *
350+ * This program is distributed in the hope that it will be useful, but WITHOUT *
351+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
352+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
353+ * more details. *
354+ * *
355+ * You should have received a copy of the GNU General Public License along *
356+ * with this program; if not, write to the Free Software Foundation, Inc., 59 *
357+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA *
358+ *******************************************************************************/
359+package org.openlp.android.data;
360+
361+import android.content.Context;
362+import org.openlp.android.R;
363+
364+public class HttpReturn {
365+ private int return_code = 0;
366+ private String data = null;
367+ private Context context;
368+
369+ public HttpReturn(int return_code, String data, Context context) {
370+ this.return_code = return_code;
371+ this.data = data;
372+ this.context = context;
373+ }
374+
375+ public String getData() {
376+ return this.data;
377+ }
378+
379+ public boolean isError() {
380+ return return_code != 0;
381+ }
382+
383+ public String getErrorMessage(String message) {
384+ return return_code == 401 ? this.context.getString(R.string.httpreturn_unauthorised) : message;
385+ }
386+
387+ @Override
388+ public String toString() {
389+ return "HttpReturn{" + "data='" + data + '\'' + ", return code=" + return_code + '}';
390+ }
391+}
392
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 /******************************************************************************
398 * OpenLP - Open Source Lyrics Projection *
399 * --------------------------------------------------------------------------- *
400- * Copyright (c) 2011-2012 Raoul Snyman *
401- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
402+ * Copyright (c) 2011-2013 Raoul Snyman *
403+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
404 * Sjöbergsson *
405 * --------------------------------------------------------------------------- *
406 * This program is free software; you can redistribute it and/or modify it *
407
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 /******************************************************************************
413 * OpenLP - Open Source Lyrics Projection *
414 * --------------------------------------------------------------------------- *
415- * Copyright (c) 2011-2012 Raoul Snyman *
416- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
417+ * Copyright (c) 2011-2013 Raoul Snyman *
418+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
419 * Sjöbergsson *
420 * --------------------------------------------------------------------------- *
421 * This program is free software; you can redistribute it and/or modify it *
422
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 /******************************************************************************
428 * OpenLP - Open Source Lyrics Projection *
429 * --------------------------------------------------------------------------- *
430- * Copyright (c) 2011-2012 Raoul Snyman *
431- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
432+ * Copyright (c) 2011-2013 Raoul Snyman *
433+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
434 * Sjöbergsson *
435 * --------------------------------------------------------------------------- *
436 * This program is free software; you can redistribute it and/or modify it *
437@@ -23,9 +23,11 @@
438 import android.app.IntentService;
439 import android.content.Intent;
440 import android.util.Log;
441+import org.openlp.android.R;
442 import org.openlp.android.activity.Search;
443 import org.openlp.android.activity.SearchService;
444 import org.openlp.android.api.Api;
445+import org.openlp.android.data.HttpReturn;
446 import org.openlp.android.utility.JSONHandler;
447 import org.openlp.android.utility.OpenLPHttpClient;
448
449@@ -38,265 +40,247 @@
450 * from an OpenLP server.
451 */
452 public class ApiCallIntent extends IntentService implements SearchService {
453- public static final String API_CALL_RECEIVE =
454- ApiCallIntent.class.getName().concat(".Receive");
455-
456- public ApiCallIntent() {
457- super(ApiCallIntent.class.getName());
458- }
459-
460- /**
461- * apiPart is one of the strings set in {@link org.openlp.android.api.Api}
462- * apiCall is when the requested apiPart takes input
463- *
464- * @param intent The intent requesting data
465- */
466- @Override
467- protected void onHandleIntent(Intent intent) {
468- Log.v(LOG_TAG, "Executing WebCallIntent from: " + intent);
469- Intent apiCallReceiverIntent = null;
470-
471- try {
472- if (intent.hasExtra(Api.ALERT)) {
473- String alertData = JSONHandler.createRequestJSON("text",
474- intent.getStringExtra(Api.ALERT));
475- apiCallReceiverIntent = executeAlert(alertData);
476- }
477- else if (intent.hasExtra(Api.SERVICE_BASE)) {
478- apiCallReceiverIntent = executeNavigation(Api.SERVICE_BASE,
479- intent.getStringExtra(Api.SERVICE_BASE));
480- }
481- else if (intent.hasExtra(Api.LIVE_BASE)) {
482- apiCallReceiverIntent = executeNavigation(Api.LIVE_BASE,
483- intent.getStringExtra(Api.LIVE_BASE));
484- }
485- else if (intent.hasExtra(Api.DISPLAY_BASE)) {
486- apiCallReceiverIntent = executeNavigation(Api.DISPLAY_BASE,
487- intent.getStringExtra(Api.DISPLAY_BASE));
488- }
489- else if (intent.hasExtra(Api.POLL_STATUS)) {
490- apiCallReceiverIntent = executePoll();
491- }
492- else if (intent.hasExtra(Api.LIVE_TEXT)) {
493- apiCallReceiverIntent = executeItemFetch(Api.LIVE_TEXT);
494- }
495- else if (intent.hasExtra(Api.SERVICE_LIST)) {
496- apiCallReceiverIntent = executeItemFetch(Api.SERVICE_LIST);
497- }
498- else if (intent.hasExtra(Api.LIVE_SET)) {
499- apiCallReceiverIntent = executeSetData(Api.LIVE_SET,
500- intent.getIntExtra(Api.LIVE_SET, 0));
501- }
502- else if (intent.hasExtra(Api.SERVICE_SET)) {
503- apiCallReceiverIntent = executeSetData(Api.SERVICE_SET,
504- intent.getIntExtra(Api.SERVICE_SET, 0));
505- }
506-
507- if (apiCallReceiverIntent == null) {
508-
509- // match wildcard intent keys
510- for (String key : intent.getExtras().keySet()) {
511- if (key.matches("/api/\\w+\\W?\\w+/live\\?data=") ||
512- key.matches("/api/\\w+\\W?\\w+/add\\?data=")) {
513- apiCallReceiverIntent = getSearchPluginIntent(key,
514- intent.getStringExtra(key));
515- break;
516- }
517- }
518-
519- if (apiCallReceiverIntent == null) {
520- String nyiMessage =
521- "Not yet Implemented for calls with these extras: " +
522- intent.getExtras();
523- Log.w(LOG_TAG, nyiMessage);
524- apiCallReceiverIntent = new WebCallReceiverIntent(
525- new WebCallReceiverIntentError(nyiMessage));
526- }
527- }
528- }
529- catch (Exception e) {
530- Log.e(LOG_TAG, e.toString());
531- apiCallReceiverIntent = new WebCallReceiverIntent(
532- new WebCallReceiverIntentError(String
533- .format("%s: %s", e.getClass().getSimpleName(),
534- e.getMessage())));
535- Log.w(LOG_TAG,
536- "Sending Broadcast with error: " + apiCallReceiverIntent);
537- }
538- sendBroadcast(apiCallReceiverIntent);
539- }
540-
541- @Override
542- public Intent getSearchPluginIntent(String apiBase, String apiData)
543- throws JSONHandler.JSONHandlerException, IOException,
544- URISyntaxException {
545- Intent apiCallSearchReceiverIntent =
546- new WebCallReceiverIntent(apiBase, apiData);
547- apiCallSearchReceiverIntent
548- .setAction(Search.ACTION); //override default receiver action
549- String jsonRequest = JSONHandler.createRequestJSON("id", apiData);
550-
551- OpenLPHttpClient httpClient =
552- getApiConfiguredClient(apiBase, jsonRequest);
553- String result = httpClient.handleExecute();
554-
555- if (result == null) {
556- apiCallSearchReceiverIntent = new WebCallReceiverIntent(
557- new WebCallReceiverIntentError(
558- "Unexpected null result during searchPluginCall."));
559- apiCallSearchReceiverIntent.setAction(Search.ACTION);
560- }
561- else {
562- Log.d(LOG_TAG, "searchPluginCall result: " + result);
563- }
564-
565- return apiCallSearchReceiverIntent;
566- }
567-
568- private Intent executeAlert(String alertData)
569- throws IOException, URISyntaxException {
570- Intent apiCallReceiverIntent =
571- new WebCallReceiverIntent(Api.ALERT, alertData);
572- OpenLPHttpClient httpClient =
573- getApiConfiguredClient(Api.ALERT, alertData);
574-
575- String result = httpClient.handleExecute();
576- if (result == null) {
577- apiCallReceiverIntent = new WebCallReceiverIntent(
578- new WebCallReceiverIntentError(
579- "Unexpected null result during alert call."));
580- }
581- else {
582- Log.d(LOG_TAG, "Alert result: " + result);
583- }
584-
585- return apiCallReceiverIntent;
586- }
587-
588- private Intent executeNavigation(final String apiBase, final String apiData)
589- throws IOException, URISyntaxException {
590- Intent apiCallReceiverIntent =
591- new WebCallReceiverIntent(apiBase, apiData);
592- OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, apiData);
593-
594- String result = httpClient.handleExecute();
595- if (result == null) {
596- apiCallReceiverIntent = new WebCallReceiverIntent(
597- new WebCallReceiverIntentError(
598- "Unexpected null result during navigation."));
599- }
600- else {
601- Log.d(LOG_TAG, "Navigation result: " + result);
602- }
603-
604- return apiCallReceiverIntent;
605- }
606-
607- private Intent executeSetData(String apiBase, int position)
608- throws JSONHandler.JSONHandlerException, IOException,
609- URISyntaxException {
610- String request =
611- JSONHandler.createRequestJSON("id", Integer.toString(position));
612- Intent apiCallreceiverIntent =
613- new WebCallReceiverIntent(apiBase, request);
614- OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, request);
615-
616- String result = httpClient.handleExecute();
617- if (result == null) {
618- String message = String.format(
619- "Unexpected null result while setting list data. apiBase(%s), position(%s)",
620- apiBase, position);
621- Log.e(LOG_TAG, message);
622- apiCallreceiverIntent = new WebCallReceiverIntent(
623- new WebCallReceiverIntentError(
624- "Unexpected null result while setting list data."));
625- }
626- else {
627- Log.d(LOG_TAG, "setData result: " + result);
628- }
629-
630- return apiCallreceiverIntent;
631- }
632-
633- private Intent executePoll() throws IOException, URISyntaxException,
634- JSONHandler.JSONHandlerException {
635- Intent apiCallReceiverIntent =
636- new WebCallReceiverIntent(Api.POLL_STATUS, "");
637- OpenLPHttpClient httpClient = getApiConfiguredClient(Api.POLL_STATUS);
638-
639- String pollJson = httpClient.handleExecute();
640- if (pollJson == null) {
641- apiCallReceiverIntent = new WebCallReceiverIntent(
642- new WebCallReceiverIntentError(
643- "Unexpected null result during status poll."));
644- }
645- else {
646- Log.d(LOG_TAG, "Poll result: " + pollJson);
647- apiCallReceiverIntent.putExtra("pollJson", pollJson);
648- }
649- return apiCallReceiverIntent;
650- }
651-
652- private Intent executeItemFetch(final String apiBase)
653- throws IOException, URISyntaxException {
654- Intent apiCallReceiverIntent = new WebCallReceiverIntent(apiBase, "");
655- OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase);
656-
657- String itemsJson = httpClient.handleExecute();
658- if (itemsJson == null) {
659- apiCallReceiverIntent = new WebCallReceiverIntent(
660- new WebCallReceiverIntentError(
661- "Unexpected null result while fetching itmes."));
662- }
663- else {
664- Log.d(LOG_TAG, "Items JSON: " + itemsJson);
665- apiCallReceiverIntent.putExtra("itemsJson", itemsJson);
666- }
667- return apiCallReceiverIntent;
668- }
669-
670- private OpenLPHttpClient getApiConfiguredClient(String apiBase,
671- String partData) throws MalformedURLException, URISyntaxException {
672- OpenLPHttpClient httpClient =
673- new OpenLPHttpClient(getApplicationContext());
674- httpClient.setUrl(String.format("%s%s", apiBase, partData));
675- return httpClient;
676- }
677-
678- private OpenLPHttpClient getApiConfiguredClient(String apiBase)
679- throws MalformedURLException, URISyntaxException {
680- return getApiConfiguredClient(apiBase, "");
681- }
682-
683- private final String LOG_TAG = ApiCallIntent.class.getName();
684-
685- class WebCallReceiverIntent extends Intent {
686- WebCallReceiverIntent() {
687- setDefaults();
688- }
689-
690- WebCallReceiverIntent(WebCallReceiverIntentError error) {
691- setDefaults();
692- WebCallReceiverIntent.this.putExtra("error", error.message);
693- }
694-
695- WebCallReceiverIntent(String apiBase, String apiData) {
696- setDefaults();
697- WebCallReceiverIntent.this.putExtra("apiBase", apiBase);
698- WebCallReceiverIntent.this.putExtra("apiData", apiData);
699- }
700-
701- private void setDefaults() {
702- WebCallReceiverIntent.this.setAction(API_CALL_RECEIVE);
703- WebCallReceiverIntent.this.addCategory(Intent.CATEGORY_DEFAULT);
704- }
705- }
706-
707- class WebCallReceiverIntentError {
708- final String message;
709-
710- WebCallReceiverIntentError(String error) {
711- this.message = error;
712- }
713- }
714+ public static final String API_CALL_RECEIVE =
715+ ApiCallIntent.class.getName().concat(".Receive");
716+
717+ public ApiCallIntent() {
718+ super(ApiCallIntent.class.getName());
719+ }
720+
721+ /**
722+ * apiPart is one of the strings set in {@link org.openlp.android.api.Api}
723+ * apiCall is when the requested apiPart takes input
724+ *
725+ * @param intent The intent requesting data
726+ */
727+ @Override
728+ protected void onHandleIntent(Intent intent) {
729+ Log.v(LOG_TAG, "Executing WebCallIntent from: " + intent);
730+ Intent apiCallReceiverIntent = null;
731+
732+ try {
733+ if (intent.hasExtra(Api.ALERT)) {
734+ String alertData = JSONHandler.createRequestJSON("text",
735+ intent.getStringExtra(Api.ALERT));
736+ apiCallReceiverIntent = executeAlert(alertData);
737+ } else if (intent.hasExtra(Api.SERVICE_BASE)) {
738+ apiCallReceiverIntent = executeNavigation(Api.SERVICE_BASE,
739+ intent.getStringExtra(Api.SERVICE_BASE));
740+ } else if (intent.hasExtra(Api.LIVE_BASE)) {
741+ apiCallReceiverIntent = executeNavigation(Api.LIVE_BASE,
742+ intent.getStringExtra(Api.LIVE_BASE));
743+ } else if (intent.hasExtra(Api.DISPLAY_BASE)) {
744+ apiCallReceiverIntent = executeNavigation(Api.DISPLAY_BASE,
745+ intent.getStringExtra(Api.DISPLAY_BASE));
746+ } else if (intent.hasExtra(Api.POLL_STATUS)) {
747+ apiCallReceiverIntent = executePoll();
748+ } else if (intent.hasExtra(Api.LIVE_TEXT)) {
749+ apiCallReceiverIntent = executeItemFetch(Api.LIVE_TEXT);
750+ } else if (intent.hasExtra(Api.SERVICE_LIST)) {
751+ apiCallReceiverIntent = executeItemFetch(Api.SERVICE_LIST);
752+ } else if (intent.hasExtra(Api.LIVE_SET)) {
753+ apiCallReceiverIntent = executeSetData(Api.LIVE_SET,
754+ intent.getIntExtra(Api.LIVE_SET, 0));
755+ } else if (intent.hasExtra(Api.SERVICE_SET)) {
756+ apiCallReceiverIntent = executeSetData(Api.SERVICE_SET,
757+ intent.getIntExtra(Api.SERVICE_SET, 0));
758+ }
759+
760+ if (apiCallReceiverIntent == null) {
761+
762+ // match wildcard intent keys
763+ for (String key : intent.getExtras().keySet()) {
764+ if (key.matches("/api/\\w+\\W?\\w+/live\\?data=") ||
765+ key.matches("/api/\\w+\\W?\\w+/add\\?data=")) {
766+ apiCallReceiverIntent = getSearchPluginIntent(key,
767+ intent.getStringExtra(key));
768+ break;
769+ }
770+ }
771+
772+ if (apiCallReceiverIntent == null) {
773+ String nyiMessage =
774+ "Not yet Implemented for calls with these extras: " +
775+ intent.getExtras();
776+ Log.w(LOG_TAG, nyiMessage);
777+ apiCallReceiverIntent = new WebCallReceiverIntent(
778+ new WebCallReceiverIntentError(nyiMessage));
779+ }
780+ }
781+ } catch (Exception e) {
782+ Log.e(LOG_TAG, e.toString());
783+ apiCallReceiverIntent = new WebCallReceiverIntent(
784+ new WebCallReceiverIntentError(String
785+ .format("%s: %s", e.getClass().getSimpleName(),
786+ e.getMessage())));
787+ Log.w(LOG_TAG,
788+ "Sending Broadcast with error: " + apiCallReceiverIntent);
789+ }
790+ sendBroadcast(apiCallReceiverIntent);
791+ }
792+
793+ @Override
794+ public Intent getSearchPluginIntent(String apiBase, String apiData)
795+ throws JSONHandler.JSONHandlerException, IOException,
796+ URISyntaxException {
797+ Intent apiCallSearchReceiverIntent =
798+ new WebCallReceiverIntent(apiBase, apiData);
799+ apiCallSearchReceiverIntent
800+ .setAction(Search.ACTION); //override default receiver action
801+ String jsonRequest = JSONHandler.createRequestJSON("id", apiData);
802+
803+ OpenLPHttpClient httpClient =
804+ getApiConfiguredClient(apiBase, jsonRequest);
805+ HttpReturn result = httpClient.handleExecute();
806+
807+ if (result.isError()) {
808+ apiCallSearchReceiverIntent = new WebCallReceiverIntent(
809+ new WebCallReceiverIntentError(result.getErrorMessage(
810+ String.valueOf(R.string.apiCallIntent_search))));
811+ apiCallSearchReceiverIntent.setAction(Search.ACTION);
812+ } else {
813+ Log.d(LOG_TAG, "searchPluginCall result: " + result.getData());
814+ }
815+
816+ return apiCallSearchReceiverIntent;
817+ }
818+
819+ private Intent executeAlert(String alertData)
820+ throws IOException, URISyntaxException {
821+ Intent apiCallReceiverIntent =
822+ new WebCallReceiverIntent(Api.ALERT, alertData);
823+ OpenLPHttpClient httpClient =
824+ getApiConfiguredClient(Api.ALERT, alertData);
825+
826+ HttpReturn result = httpClient.handleExecute();
827+ if (result.isError()) {
828+ apiCallReceiverIntent = new WebCallReceiverIntent(
829+ new WebCallReceiverIntentError(result.getErrorMessage(
830+ String.valueOf(R.string.apiCallIntent_alert))));
831+ } else {
832+ Log.d(LOG_TAG, "Alert result: " + result.getData());
833+ }
834+
835+ return apiCallReceiverIntent;
836+ }
837+
838+ private Intent executeNavigation(final String apiBase, final String apiData)
839+ throws IOException, URISyntaxException {
840+ Intent apiCallReceiverIntent =
841+ new WebCallReceiverIntent(apiBase, apiData);
842+ OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, apiData);
843+
844+ HttpReturn result = httpClient.handleExecute();
845+ if (result.isError()) {
846+ apiCallReceiverIntent = new WebCallReceiverIntent(
847+ new WebCallReceiverIntentError(result.getErrorMessage(
848+ String.valueOf(R.string.apiCallIntent_navigation))));
849+ } else {
850+ Log.d(LOG_TAG, "Navigation result: " + result.getData());
851+ }
852+
853+ return apiCallReceiverIntent;
854+ }
855+
856+ private Intent executeSetData(String apiBase, int position)
857+ throws JSONHandler.JSONHandlerException, IOException,
858+ URISyntaxException {
859+ String request = JSONHandler.createRequestJSON("id", Integer.toString(position));
860+ Intent apiCallreceiverIntent = new WebCallReceiverIntent(apiBase, request);
861+ OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, request);
862+
863+ HttpReturn result = httpClient.handleExecute();
864+ if (result.isError()) {
865+ String message = String.format(
866+ "Unexpected null result while setting list data. apiBase(%s), position(%s)",
867+ apiBase, position);
868+ Log.e(LOG_TAG, message);
869+ apiCallreceiverIntent = new WebCallReceiverIntent(
870+ new WebCallReceiverIntentError(result.getErrorMessage(
871+ String.valueOf(R.string.apiCallIntent_list_data))));
872+ } else {
873+ Log.d(LOG_TAG, "setData result: " + result.getData());
874+ }
875+
876+ return apiCallreceiverIntent;
877+ }
878+
879+ private Intent executePoll() throws IOException, URISyntaxException,
880+ JSONHandler.JSONHandlerException {
881+ Intent apiCallReceiverIntent = new WebCallReceiverIntent(Api.POLL_STATUS, "");
882+ OpenLPHttpClient httpClient = getApiConfiguredClient(Api.POLL_STATUS);
883+
884+ HttpReturn pollJson = httpClient.handleExecute();
885+ if (pollJson.isError()) {
886+ apiCallReceiverIntent = new WebCallReceiverIntent(
887+ new WebCallReceiverIntentError(pollJson.getErrorMessage(
888+ String.valueOf(R.string.apiCallIntent_poll))));
889+ } else {
890+ Log.d(LOG_TAG, "Poll result: " + pollJson);
891+ apiCallReceiverIntent.putExtra("pollJson", pollJson.getData());
892+ }
893+ return apiCallReceiverIntent;
894+ }
895+
896+ private Intent executeItemFetch(final String apiBase)
897+ throws IOException, URISyntaxException {
898+ Intent apiCallReceiverIntent = new WebCallReceiverIntent(apiBase, "");
899+ OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase);
900+
901+ HttpReturn itemsJson = httpClient.handleExecute();
902+ if (itemsJson.isError()) {
903+ apiCallReceiverIntent = new WebCallReceiverIntent(
904+ new WebCallReceiverIntentError(
905+ itemsJson.getErrorMessage(String.valueOf(R.string.apiCallIntent_fetch))));
906+ } else {
907+ Log.d(LOG_TAG, "Items JSON: " + itemsJson);
908+ apiCallReceiverIntent.putExtra("itemsJson", itemsJson.getData());
909+ }
910+ return apiCallReceiverIntent;
911+ }
912+
913+ private OpenLPHttpClient getApiConfiguredClient(String apiBase,
914+ String partData) throws MalformedURLException, URISyntaxException {
915+ OpenLPHttpClient httpClient =
916+ new OpenLPHttpClient(getApplicationContext());
917+ httpClient.setUrl(String.format("%s%s", apiBase, partData));
918+ return httpClient;
919+ }
920+
921+ private OpenLPHttpClient getApiConfiguredClient(String apiBase)
922+ throws MalformedURLException, URISyntaxException {
923+ return getApiConfiguredClient(apiBase, "");
924+ }
925+
926+ private final String LOG_TAG = ApiCallIntent.class.getName();
927+
928+ class WebCallReceiverIntent extends Intent {
929+ WebCallReceiverIntent() {
930+ setDefaults();
931+ }
932+
933+ WebCallReceiverIntent(WebCallReceiverIntentError error) {
934+ setDefaults();
935+ WebCallReceiverIntent.this.putExtra("error", error.message);
936+ }
937+
938+ WebCallReceiverIntent(String apiBase, String apiData) {
939+ setDefaults();
940+ WebCallReceiverIntent.this.putExtra("apiBase", apiBase);
941+ WebCallReceiverIntent.this.putExtra("apiData", apiData);
942+ }
943+
944+ private void setDefaults() {
945+ WebCallReceiverIntent.this.setAction(API_CALL_RECEIVE);
946+ WebCallReceiverIntent.this.addCategory(Intent.CATEGORY_DEFAULT);
947+ }
948+ }
949+
950+ class WebCallReceiverIntentError {
951+ final String message;
952+
953+ WebCallReceiverIntentError(String error) {
954+ this.message = error;
955+ }
956+ }
957 }
958
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 /******************************************************************************
964 * OpenLP - Open Source Lyrics Projection *
965 * --------------------------------------------------------------------------- *
966- * Copyright (c) 2011-2012 Raoul Snyman *
967- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
968+ * Copyright (c) 2011-2013 Raoul Snyman *
969+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
970 * Sjöbergsson *
971 * --------------------------------------------------------------------------- *
972 * This program is free software; you can redistribute it and/or modify it *
973
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 /******************************************************************************
979 * OpenLP - Open Source Lyrics Projection *
980 * --------------------------------------------------------------------------- *
981- * Copyright (c) 2011-2012 Raoul Snyman *
982- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
983+ * Copyright (c) 2011-2013 Raoul Snyman *
984+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
985 * Sjöbergsson *
986 * --------------------------------------------------------------------------- *
987 * This program is free software; you can redistribute it and/or modify it *
988
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 /******************************************************************************
994 * OpenLP - Open Source Lyrics Projection *
995 * --------------------------------------------------------------------------- *
996- * Copyright (c) 2011-2012 Raoul Snyman *
997- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
998+ * Copyright (c) 2011-2013 Raoul Snyman *
999+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
1000 * Sjöbergsson *
1001 * --------------------------------------------------------------------------- *
1002 * This program is free software; you can redistribute it and/or modify it *
1003
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 /******************************************************************************
1009 * OpenLP - Open Source Lyrics Projection *
1010 * --------------------------------------------------------------------------- *
1011- * Copyright (c) 2011-2012 Raoul Snyman *
1012- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
1013+ * Copyright (c) 2011-2013 Raoul Snyman *
1014+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
1015 * Sjöbergsson *
1016 * --------------------------------------------------------------------------- *
1017 * This program is free software; you can redistribute it and/or modify it *
1018@@ -26,14 +26,17 @@
1019 import android.content.Intent;
1020 import android.content.IntentFilter;
1021 import android.content.SharedPreferences;
1022+import android.net.http.SslError;
1023 import android.support.v4.view.PagerAdapter;
1024 import android.support.v4.view.ViewPager;
1025 import android.util.Log;
1026 import android.view.LayoutInflater;
1027 import android.view.View;
1028 import android.view.ViewGroup;
1029+import android.webkit.SslErrorHandler;
1030 import android.webkit.WebSettings;
1031 import android.webkit.WebView;
1032+import android.webkit.WebViewClient;
1033 import android.widget.AdapterView;
1034 import android.widget.Button;
1035 import android.widget.EditText;
1036@@ -360,6 +363,15 @@
1037
1038 private WebView getWebViewFromView(View view) {
1039 WebView myWebView = (WebView) view.findViewById(R.id.stageview);
1040+ /*
1041+ * Handle SSL self signed certificates and refresh the screen if the certificate
1042+ * page appears.
1043+ */
1044+ myWebView.setWebViewClient(new WebViewClient() {
1045+ public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
1046+ handler.proceed() ;
1047+ }
1048+ } );
1049 WebSettings webSettings = myWebView.getSettings();
1050 webSettings.setJavaScriptEnabled(true);
1051 webSettings.setBuiltInZoomControls(true);
1052@@ -369,7 +381,6 @@
1053 myWebView.setScrollbarFadingEnabled(true);
1054
1055 myWebView.loadUrl(getUrlBase());
1056-
1057 return myWebView;
1058 }
1059
1060
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 /******************************************************************************
1066 * OpenLP - Open Source Lyrics Projection *
1067 * --------------------------------------------------------------------------- *
1068- * Copyright (c) 2011-2012 Raoul Snyman *
1069- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
1070+ * Copyright (c) 2011-2013 Raoul Snyman *
1071+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
1072 * Sjöbergsson *
1073 * --------------------------------------------------------------------------- *
1074 * This program is free software; you can redistribute it and/or modify it *
1075@@ -47,6 +47,9 @@
1076 import android.util.Log;
1077 import org.apache.http.HttpEntity;
1078 import org.apache.http.HttpResponse;
1079+import org.apache.http.auth.AuthScope;
1080+import org.apache.http.auth.Credentials;
1081+import org.apache.http.auth.UsernamePasswordCredentials;
1082 import org.apache.http.client.methods.HttpGet;
1083 import org.apache.http.conn.scheme.PlainSocketFactory;
1084 import org.apache.http.conn.scheme.Scheme;
1085@@ -57,11 +60,11 @@
1086 import org.apache.http.params.HttpConnectionParams;
1087 import org.apache.http.params.HttpParams;
1088 import org.openlp.android.R;
1089+import org.openlp.android.data.HttpReturn;
1090
1091 /**
1092 * Personalised HttpClient to be used throughout OpenLP with customisable
1093 * parameters.
1094- * todo: accomodate https
1095 */
1096 public class OpenLPHttpClient extends DefaultHttpClient {
1097
1098@@ -69,6 +72,7 @@
1099 private URL url;
1100 private final String urlBase;
1101 private SSLSocketFactory sslSocketFactory;
1102+ private Context context;
1103
1104 public OpenLPHttpClient(Context context) {
1105 SharedPreferences preferences = context.getSharedPreferences(
1106@@ -76,6 +80,8 @@
1107 Context.MODE_PRIVATE);
1108 HttpParams httpParams = new BasicHttpParams();
1109
1110+ this.context = context;
1111+
1112 Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false);
1113
1114 String port = preferences.getString(
1115@@ -83,7 +89,6 @@
1116 context.getString(R.string.portDefaultValue)
1117 );
1118
1119-
1120 SchemeRegistry schemeRegistry = getConnectionManager().getSchemeRegistry();
1121 if (!useSsl) {
1122 schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Integer.valueOf(port)));
1123@@ -107,7 +112,23 @@
1124
1125 }
1126
1127- urlBase = String.format("http%s://%s:%s",
1128+ String userid = preferences.getString(
1129+ context.getString(R.string.key_userid),
1130+ context.getString(R.string.useridDefaultValue)
1131+ );
1132+
1133+
1134+ String password = preferences.getString(
1135+ context.getString(R.string.key_password),
1136+ context.getString(R.string.passwordDefaultValue)
1137+ );
1138+
1139+ Log.d(LOG_TAG, "Credentials set to " + userid + " : " + password);
1140+
1141+ Credentials creds = new UsernamePasswordCredentials(userid, password);
1142+ getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds);
1143+
1144+ urlBase = String.format("http%s://%s:%s",
1145 useSsl ? "s" : "",
1146 preferences.getString(
1147 context.getString(R.string.keyHost),
1148@@ -158,9 +179,11 @@
1149 return super.execute(httpGet);
1150 }
1151
1152- public String handleExecute() throws IOException {
1153+ public HttpReturn handleExecute() throws IOException {
1154 HttpResponse response = this.execute();
1155
1156+ Log.d(LOG_TAG, "Http response code " + String.valueOf(response.getStatusLine().getStatusCode()));
1157+
1158 if (response.getStatusLine().getStatusCode() == 200) {
1159 BufferedReader bufferedReader;
1160 HttpEntity entity = response.getEntity();
1161@@ -175,10 +198,10 @@
1162 line = bufferedReader.readLine();
1163 }
1164 bufferedReader.close();
1165- return stringBuilder.toString();
1166+ return new HttpReturn(0, stringBuilder.toString(), this.context);
1167 }
1168 }
1169- return null;
1170+ return new HttpReturn(response.getStatusLine().getStatusCode() , null, this.context);
1171 }
1172
1173 public HttpEntity handleAndReturnEntity() throws IOException {
1174@@ -190,7 +213,8 @@
1175 return null;
1176 }
1177
1178- private void initSsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException, IOException, CertificateException {
1179+ private void initSsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException,
1180+ UnrecoverableKeyException, IOException, CertificateException {
1181 final SSLContext sslContext = SSLContext.getInstance("TLS");
1182 X509TrustManager trustManager = new X509TrustManager() {
1183 @Override
1184@@ -217,7 +241,8 @@
1185 }
1186
1187 @Override
1188- public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
1189+ public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException,
1190+ UnknownHostException {
1191 return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
1192 }
1193 };
1194
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 /******************************************************************************
1200 * OpenLP - Open Source Lyrics Projection *
1201 * --------------------------------------------------------------------------- *
1202- * Copyright (c) 2011-2012 Raoul Snyman *
1203- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
1204+ * Copyright (c) 2011-2013 Raoul Snyman *
1205+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
1206 * Sjöbergsson *
1207 * --------------------------------------------------------------------------- *
1208 * This program is free software; you can redistribute it and/or modify it *
1209
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 /******************************************************************************
1215 * OpenLP - Open Source Lyrics Projection *
1216 * --------------------------------------------------------------------------- *
1217- * Copyright (c) 2011-2012 Raoul Snyman *
1218- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
1219+ * Copyright (c) 2011-2013 Raoul Snyman *
1220+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
1221 * Sjöbergsson *
1222 * --------------------------------------------------------------------------- *
1223 * This program is free software; you can redistribute it and/or modify it *
1224
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 /******************************************************************************
1230 * OpenLP - Open Source Lyrics Projection *
1231 * --------------------------------------------------------------------------- *
1232- * Copyright (c) 2011-2012 Raoul Snyman *
1233- * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *
1234+ * Copyright (c) 2011-2013 Raoul Snyman *
1235+ * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
1236 * Sjöbergsson *
1237 * --------------------------------------------------------------------------- *
1238 * This program is free software; you can redistribute it and/or modify it *

Subscribers

People subscribed via source and target branches