openlp-android team mailing list archive
-
openlp-android team
-
Mailing list archive
-
Message #00070
[Merge] lp:~trb143/openlp/android_03 into lp:openlp/android
Tim Bentley has proposed merging lp:~trb143/openlp/android_03 into lp:openlp/android.
Requested reviews:
OpenLP Android Developers (openlp-android)
For more details, see:
https://code.launchpad.net/~trb143/openlp/android_03/+merge/87021
Updates and new blanking code
--
https://code.launchpad.net/~trb143/openlp/android_03/+merge/87021
Your team OpenLP Android Developers is requested to review the proposed merge of lp:~trb143/openlp/android_03 into lp:openlp/android.
=== modified file '.classpath'
--- .classpath 2011-05-03 22:11:35 +0000
+++ .classpath 2011-12-28 15:45:29 +0000
@@ -3,5 +3,5 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="output" path="bin/classes"/>
</classpath>
=== modified file 'AndroidManifest.xml'
--- AndroidManifest.xml 2011-06-13 19:33:25 +0000
+++ AndroidManifest.xml 2011-12-28 15:45:29 +0000
@@ -4,9 +4,9 @@
android:installLocation="auto"
package="org.openlp.android"
android:versionCode="1"
- android:versionName="0.1"
+ android:versionName="0.3"
>
- <uses-sdk android:minSdkVersion="7"/>
+ <uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
=== modified file 'OpenLP.apk'
Binary files OpenLP.apk 2011-06-13 19:33:25 +0000 and OpenLP.apk 2011-12-28 15:45:29 +0000 differ
=== removed file 'default.properties'
--- default.properties 2011-06-13 19:33:25 +0000
+++ default.properties 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-8
=== modified file 'res/layout/misc.xml'
--- res/layout/misc.xml 2011-05-08 11:41:49 +0000
+++ res/layout/misc.xml 2011-12-28 15:45:29 +0000
@@ -8,8 +8,8 @@
android:id="@+id/toggleDisplayButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
- android:textOn="@string/toggleBlankOn"
- android:textOff="@string/toggleBlankOff"/>
+ android:textOn="@string/displayBlankOn"
+ android:textOff="@string/displayBlankOff"/>
<TextView
android:text="@string/alert"
android:layout_width="wrap_content"
=== modified file 'res/values-en/defaultValues.xml'
--- res/values-en/defaultValues.xml 2011-05-07 20:01:46 +0000
+++ res/values-en/defaultValues.xml 2011-12-28 15:45:29 +0000
@@ -2,6 +2,7 @@
<!-- STRING -->
<string name="hostDefaultValue">192.168.1.1</string>
<string name="portDefaultValue">4316</string>
+ <string name="displayTypeValue">Blank</string>
<!-- INTEGER -->
<integer name="socketTimeoutDefaultValue">3000</integer>
=== modified file 'res/values-en/keyStrings.xml'
--- res/values-en/keyStrings.xml 2011-05-07 20:30:34 +0000
+++ res/values-en/keyStrings.xml 2011-12-28 15:45:29 +0000
@@ -1,6 +1,7 @@
<resources>
<string name="keyEnableCustomTimeout">enableCustomTimeout</string>
<string name="keyConnectionTimeout">connectionTimeout</string>
+ <string name="keyDisplayBlankType">blankType</string>
<string name="keySocketTimeout">socketTimeout</string>
<string name="keyHost">keyHost</string>
<string name="keyPort">keyPort</string>
=== modified file 'res/values-en/strings.xml'
--- res/values-en/strings.xml 2011-05-27 19:46:14 +0000
+++ res/values-en/strings.xml 2011-12-28 15:45:29 +0000
@@ -25,11 +25,15 @@
<string name="urlHint">Hostname or IP</string>
<string name="port">Port</string>
<string name="enableCustomTimeouts">Enable Custom Timeouts</string>
+ <string name="displayType">Display Blank Type</string>
+ <string name="displayBlankType">Display Blank Type</string>
+ <string name="displayBlankSummary">Select the required blank type</string>
<string name="customTimeoutsSummary">Check to modify timeout settings</string>
<string name="customTimeout">Custom Timeout</string>
<string name="socketTimeout">Socket Timeout</string>
<string name="socketTimeoutSummary">Select a value (milliseconds)</string>
<string name="connectionTimeout">Connection Timeout</string>
+ <string name="connectionTimedout">Connection timed out</string>
<string name="connectionTimeoutSummary">Select a value (milliseconds)</string>
<string name="save">Save</string>
<string name="unable">Unable to load page -</string>
@@ -37,10 +41,11 @@
<string name="jsonfail">JSON failed</string>
<string name="loading">Connecting...</string>
<string name="searching">Searching...</string>
- <string name="toggleBlankOn">Display Blanked</string>
- <string name="toggleBlankOff">Display Unblanked</string>
+ <string name="toggleBlankOn">Blank to </string>
+ <string name="toggleBlankOff">Show Display</string>
<string name="loadingServiceItems">Loading Service Items...</string>
<string name="loadingSlideItems">Loading Slide Items...</string>
+ <string name="loadingStatusInfo">Loading Status Info...</string>
<string name="searchHint">Search OpenLP</string>
<string name="searchResults">Search Results</string>
<string name="showingResults">Showing Results for \'%s\'</string>
=== modified file 'res/values/defaultValues.xml'
--- res/values/defaultValues.xml 2011-05-07 20:01:46 +0000
+++ res/values/defaultValues.xml 2011-12-28 15:45:29 +0000
@@ -2,6 +2,7 @@
<!-- STRING -->
<string name="hostDefaultValue">192.168.1.1</string>
<string name="portDefaultValue">4316</string>
+ <string name="displayTypeValue">Blank</string>
<!-- INTEGER -->
<integer name="socketTimeoutDefaultValue">3000</integer>
=== modified file 'res/values/keyStrings.xml'
--- res/values/keyStrings.xml 2011-05-07 20:01:46 +0000
+++ res/values/keyStrings.xml 2011-12-28 15:45:29 +0000
@@ -1,6 +1,7 @@
<resources>
<string name="keyEnableCustomTimeout">enableCustomTimeout</string>
<string name="keyConnectionTimeout">connectionTimeout</string>
+ <string name="keyDisplayBlankType">blankType</string>
<string name="keySocketTimeout">socketTimeout</string>
<string name="keyHost">keyHost</string>
<string name="keyPort">keyPort</string>
=== added file 'res/values/misc.xml'
--- res/values/misc.xml 1970-01-01 00:00:00 +0000
+++ res/values/misc.xml 2011-12-28 15:45:29 +0000
@@ -0,0 +1,12 @@
+<resources>
+ <string-array name="displayTypeValueEntries">
+ <item>Blank</item>
+ <item>Theme</item>
+ <item>Display</item>
+ </string-array>
+ <string-array name="displayTypeValues">
+ <item>Blank</item>
+ <item>Theme</item>
+ <item>Display</item>
+ </string-array>
+</resources>
\ No newline at end of file
=== modified file 'res/values/strings.xml'
--- res/values/strings.xml 2011-05-24 19:17:02 +0000
+++ res/values/strings.xml 2011-12-28 15:45:29 +0000
@@ -25,11 +25,20 @@
<string name="urlHint">Hostname or IP</string>
<string name="port">Port</string>
<string name="enableCustomTimeouts">Enable Custom Timeouts</string>
+ <string name="displayType">Display Blank Type</string>
+ <string name="displayBlankType">Display Blank Type</string>
+ <string name="displayBlankSummary">Select the required blank type</string>
+ <string name="displayBlank">Blank</string>
+ <string name="displayTheme">Theme</string>
+ <string name="displayDesktop">Desktop</string>
+ <string name="displayBlankOn">Reset display from</string>
+ <string name="displayBlankOff">Blank display to</string>
<string name="customTimeoutsSummary">Check to modify timeout settings</string>
<string name="customTimeout">Custom Timeout</string>
<string name="socketTimeout">Socket Timeout</string>
<string name="socketTimeoutSummary">Select a value (milliseconds)</string>
<string name="connectionTimeout">Connection Timeout</string>
+ <string name="connectionTimedout">Connection timed out</string>
<string name="connectionTimeoutSummary">Select a value (milliseconds)</string>
<string name="save">Save</string>
<string name="unable">Unable to load page -</string>
@@ -37,10 +46,9 @@
<string name="jsonfail">JSON failed</string>
<string name="loading">Connecting...</string>
<string name="searching">Searching...</string>
- <string name="toggleBlankOn">Display Blanked</string>
- <string name="toggleBlankOff">Display Unblanked</string>
<string name="loadingServiceItems">Loading Service Items...</string>
<string name="loadingSlideItems">Loading Slide Items...</string>
+ <string name="loadingStatusInfo">Loading Status Info...</string>
<string name="searchHint">Search OpenLP</string>
<string name="searchResults">Search Results</string>
<string name="showingResults">Showing Results for \'%s\'</string>
=== modified file 'res/xml/preferences.xml'
--- res/xml/preferences.xml 2011-05-08 11:41:49 +0000
+++ res/xml/preferences.xml 2011-12-28 15:45:29 +0000
@@ -2,6 +2,16 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
+ android:title="@string/displayType">
+ <ListPreference
+ android:title="@string/displayBlankType"
+ android:key="@string/keyDisplayBlankType"
+ android:summary="@string/displayBlankSummary"
+ android:entries="@array/displayTypeValueEntries"
+ android:entryValues="@array/displayTypeValues"
+ android:defaultValue="@string/displayTypeValue"/>
+ </PreferenceCategory>
+ <PreferenceCategory
android:title="@string/preferenceCategoryTitleServer">
<EditTextPreference
android:title="@string/url"
=== modified file 'src/org/openlp/android/OpenLP.java'
--- src/org/openlp/android/OpenLP.java 2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/OpenLP.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -68,8 +68,5 @@
.setContent(new Intent(this, Misc.class)));
}
-
private final String LOG_TAG = OpenLP.class.getName();
-
-
}
\ No newline at end of file
=== modified file 'src/org/openlp/android/activity/Misc.java'
--- src/org/openlp/android/activity/Misc.java 2011-06-13 19:33:25 +0000
+++ src/org/openlp/android/activity/Misc.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -22,9 +22,13 @@
*******************************************************************************/
package org.openlp.android.activity;
+import java.util.Arrays;
import android.app.Activity;
+import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
@@ -35,14 +39,26 @@
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
import org.openlp.android.R;
import org.openlp.android.api.Api;
+import org.openlp.android.data.Poll;
import org.openlp.android.utility.JSONHandler;
+import org.openlp.android.utility.OpenLPHttpClient;
import org.openlp.android.utility.WebCallAsyncTask;
+
public class Misc extends Activity implements Api {
private final Context context = this;
-
+ Misc misc = this;
+ SharedPreferences prefs;
+ String displayType;
+
+ /*
+ * Process the Alert button
+ */
public Button.OnClickListener mSend = new Button.OnClickListener() {
@Override
public void onClick(View v) {
@@ -66,9 +82,15 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
Log.i(LOG_TAG, "onCreate");
setContentView(R.layout.misc);
-
+
+ prefs = getApplicationContext().getSharedPreferences(getApplicationContext().getString(R.string.keySharedPreferences), Context.MODE_PRIVATE);
+ Log.d(LOG_TAG, prefs.getAll().toString());
+ displayType = prefs.getString(getApplicationContext().getString(R.string.keyDisplayBlankType), getApplicationContext().getString(R.string.displayTypeValue));
+ Log.d(LOG_TAG, "Pref Display Type = " + displayType);
+
final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleDisplayButton);
toggleButton.setOnClickListener(new View.OnClickListener() {
@@ -79,7 +101,19 @@
new WebCallAsyncTask(context).execute(DISPLAY_SHOW);
}
else {
- new WebCallAsyncTask(context).execute(DISPLAY_HIDE);
+ Log.d(LOG_TAG, "onCLick Display Type = " + displayType);
+ if (displayType.equals("Blank")){
+ Log.d(LOG_TAG, "Blank called");
+ new WebCallAsyncTask(context).execute(DISPLAY_HIDE_BLANK);
+ }
+ else if (displayType.equals("Theme")){
+ Log.d(LOG_TAG, "Theme called");
+ new WebCallAsyncTask(context).execute(DISPLAY_HIDE_THEME);
+ }
+ else {
+ Log.d(LOG_TAG, "Desktop called");
+ new WebCallAsyncTask(context).execute(DISPLAY_HIDE_DESKTOP);
+ }
}
}
catch (Exception e) {
@@ -96,8 +130,123 @@
protected void onResume() {
super.onResume();
Log.d(LOG_TAG, "Resume");
- }
-
+ new PollStatusTask(this).execute(POLL_STATUS);
+ }
+
+ /**
+ * Asynchronous task to Poll the status data.
+ */
+ class PollStatusTask extends AsyncTask<String, Void, Poll> {
+ Misc miscActivity;
+ ProgressDialog progressDialog;
+ String error;
+
+ PollStatusTask(Misc miscActivity) {
+ this.miscActivity = miscActivity;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ progressDialog = ProgressDialog.show(Misc.this, getString(R.string.loading),
+ getString(R.string.loadingStatusInfo));
+ }
+
+ @Override
+ protected Poll doInBackground(String... strings) {
+ OpenLPHttpClient httpClient = new OpenLPHttpClient(getApplicationContext());
+ HttpResponse response = null;
+ String returnString = "";
+
+ Log.d(LOG_TAG, "Processing:" + Arrays.asList(strings));
+ try {
+ httpClient.setUrl(strings[0]);
+ if (httpClient.getUrl().getHost().trim().length() <= 0) {
+ startActivity(new Intent(miscActivity, Preferences.class));
+ }
+ else {
+ response = httpClient.execute();
+ }
+
+ if (response != null && response.getStatusLine().getStatusCode() == 200) {
+ HttpEntity entity = response.getEntity();
+
+ if (entity != null) {
+ Poll poll = JSONHandler.parsePollResponseJSON(entity);
+ Log.i(LOG_TAG, String.format("Service Items: %s", poll));
+ return poll;
+ }
+ }
+ else {
+ returnString = String.format("%s %s", getString(R.string.unable), response);
+ }
+ }
+ catch (Exception e) {
+ try {
+ throw new FetchItemsException(e);
+ }
+ catch (FetchItemsException e1) {
+ returnString = String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage());
+ }
+ }
+
+ if (returnString.trim().length() > 0) {
+ error = returnString;
+ Log.e(LOG_TAG, returnString);
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Poll poll) {
+ super.onPostExecute(poll);
+ final ToggleButton toggleButton = (ToggleButton) findViewById(R.id.toggleDisplayButton);
+ if (poll == null){
+ toggleButton.setEnabled(false);
+ }
+ else {
+ displayType = prefs.getString(getApplicationContext().getString(R.string.keyDisplayBlankType), getApplicationContext().getString(R.string.displayTypeValue));
+ Log.d(LOG_TAG, "onPostExecute Display Type = " + displayType + " " + poll.isDisplayHidden());
+ if (displayType.equals("Blank")){
+ Log.d(LOG_TAG, "Blank called");
+ toggleButton.setTextOn(context.getString(R.string.displayBlankOn) + " "+ context.getString(R.string.displayBlank));
+ toggleButton.setTextOff(context.getString(R.string.displayBlankOff) + " "+ context.getString(R.string.displayBlank));
+ }
+ else if (displayType.equals("Theme")){
+ Log.d(LOG_TAG, "Theme called");
+ toggleButton.setTextOn(context.getString(R.string.displayBlankOn) + " "+ context.getString(R.string.displayTheme));
+ toggleButton.setTextOff(context.getString(R.string.displayBlankOff) + " "+ context.getString(R.string.displayTheme));
+ }
+ else {
+ Log.d(LOG_TAG, "Desktop called");
+ toggleButton.setTextOn(context.getString(R.string.displayBlankOn) + " "+ context.getString(R.string.displayDesktop));
+ toggleButton.setTextOff(context.getString(R.string.displayBlankOff) + " "+ context.getString(R.string.displayDesktop));
+ }
+ toggleButton.setEnabled(true);
+ toggleButton.setChecked(false);
+ if (poll.isDisplayHidden()){
+ toggleButton.setChecked(true);
+ }
+ }
+ progressDialog.dismiss();
+ if (error != null && error.trim().length() > 0) {
+ Toast.makeText(context, error, Toast.LENGTH_LONG).show();
+ }
+ }
+
+ class FetchItemsException extends Exception {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1527836134529641630L;
+
+ FetchItemsException(Throwable throwable) {
+ super(throwable);
+ }
+ }
+ }
+
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
@@ -119,6 +268,5 @@
return super.onOptionsItemSelected(item);
}
}
-
private final String LOG_TAG = Misc.class.getName();
}
=== modified file 'src/org/openlp/android/activity/Preferences.java'
--- src/org/openlp/android/activity/Preferences.java 2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/activity/Preferences.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
=== modified file 'src/org/openlp/android/activity/SearchableActivity.java'
--- src/org/openlp/android/activity/SearchableActivity.java 2011-09-15 19:37:55 +0000
+++ src/org/openlp/android/activity/SearchableActivity.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -51,7 +51,6 @@
import java.util.Map;
public class SearchableActivity extends Activity implements Api {
- private final String LOG_TAG = this.getClass().getSimpleName();
private Activity context;
private ExpandableListView listView;
private final int DIALOG_ITEM_OPTIONS = 0;
@@ -149,7 +148,7 @@
List<String> groups = new ArrayList<String>();
List<List<Map<String, JSONArray>>> children = new ArrayList<List<Map<String, JSONArray>>>();
- AsyncTask call = new WebCallReturningAsyncTask(context).execute(SEARCHABLE_PLUGINS);
+ AsyncTask <String, Void, String> call = new WebCallReturningAsyncTask(context).execute(SEARCHABLE_PLUGINS);
try {
JSONArray array = new JSONObject(call.get().toString()).getJSONObject("results").getJSONArray("items");
@@ -160,7 +159,7 @@
JSONArray resultArray = null;
- AsyncTask pluginResults = new WebCallReturningAsyncTask(context,
+ AsyncTask <String, Void, String> pluginResults = new WebCallReturningAsyncTask(context,
String.format(SEARCH_PLUGIN_FORMATTED, pluginString))
.execute(JSONHandler.createRequestJSON("text", query));
@@ -223,4 +222,5 @@
this.children = children;
}
}
+ private final String LOG_TAG = this.getClass().getSimpleName();
}
=== modified file 'src/org/openlp/android/activity/Service.java'
--- src/org/openlp/android/activity/Service.java 2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/activity/Service.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -53,7 +53,6 @@
* Activity for managing service objects.
*/
public class Service extends Activity implements Api {
- private final String LOG_TAG = Service.class.getName();
private final Activity context = this;
private ListView listView;
@@ -96,18 +95,18 @@
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
- String alert;
+ String service;
try {
- alert = JSONHandler.createRequestJSON("id", Integer.toString(i));
- new WebCallAsyncTask(context, SERVICE_SET).execute(alert);
- alert = null;
+ service = JSONHandler.createRequestJSON("id", Integer.toString(i));
+ new WebCallAsyncTask(context, SERVICE_SET).execute(service);
+ service = null;
}
catch (JSONHandler.JSONHandlerException e) {
- alert = String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage());
+ service = String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage());
}
- if (alert != null) {
- Toast.makeText(getApplicationContext(), alert, Toast.LENGTH_LONG).show();
+ if (service != null) {
+ Toast.makeText(getApplicationContext(), service, Toast.LENGTH_LONG).show();
}
}
});
@@ -220,9 +219,15 @@
}
class FetchItemsException extends Exception {
- FetchItemsException(Throwable throwable) {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1527836134529641630L;
+
+ FetchItemsException(Throwable throwable) {
super(throwable);
}
}
}
+ private final String LOG_TAG = Service.class.getName();
}
\ No newline at end of file
=== modified file 'src/org/openlp/android/activity/Slide.java'
--- src/org/openlp/android/activity/Slide.java 2011-06-13 19:33:25 +0000
+++ src/org/openlp/android/activity/Slide.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -50,7 +50,6 @@
public class Slide extends Activity implements Api {
private final Activity context = this;
- private final String LOG_TAG = Slide.class.getName();
private ListView slideList;
public void onCreate(Bundle savedInstanceState) {
@@ -192,7 +191,8 @@
throw new FetchItemsException(ex);
}
catch (FetchItemsException e) {
- returnString = String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage());
+ Log.d(LOG_TAG, String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()));
+ returnString = String.format("%s", getString(R.string.connectionTimedout));
}
}
@@ -218,9 +218,15 @@
}
class FetchItemsException extends Exception {
- FetchItemsException(Throwable throwable) {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5643837655316198262L;
+
+ FetchItemsException(Throwable throwable) {
super(throwable);
}
}
}
+ private final String LOG_TAG = Slide.class.getName();
}
=== modified file 'src/org/openlp/android/api/Api.java'
--- src/org/openlp/android/api/Api.java 2011-06-07 20:39:33 +0000
+++ src/org/openlp/android/api/Api.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -102,8 +102,11 @@
public final String SERVICE_LIST = "/api/service/list";
public final String SERVICE_SET = "/api/service/set?data=";
- public final String DISPLAY_HIDE = "/api/display/hide";
+ public final String DISPLAY_HIDE_BLANK = "/api/display/blank";
+ public final String DISPLAY_HIDE_THEME = "/api/display/theme";
+ public final String DISPLAY_HIDE_DESKTOP = "/api/display/desktop";
public final String DISPLAY_SHOW = "/api/display/show";
+ public final String POLL_STATUS = "/api/poll";
public final String ALERT = "/api/alert?data=";
=== added file 'src/org/openlp/android/data/Poll.java'
--- src/org/openlp/android/data/Poll.java 1970-01-01 00:00:00 +0000
+++ src/org/openlp/android/data/Poll.java 2011-12-28 15:45:29 +0000
@@ -0,0 +1,101 @@
+/******************************************************************************
+ * OpenLP - Open Source Lyrics Projection *
+ * --------------------------------------------------------------------------- *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
+ * Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
+ * Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
+ * Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
+ * --------------------------------------------------------------------------- *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU General Public License as published by the Free *
+ * Software Foundation; version 2 of the License. *
+ * *
+ * This program is distributed in the hope that it will be useful, but WITHOUT *
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
+ * more details. *
+ * *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., 59 *
+ * Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ *******************************************************************************/
+
+package org.openlp.android.data;
+
+
+public class Poll {
+
+ private int slide;
+ private String item;
+ private boolean twelveHourDisplay = false;;
+ private boolean blankedDisplayed = false;;
+ private boolean themeDisplayed = false;;
+ private boolean desktopDisplayed = false;
+ private boolean displayHidden = false;
+
+ public int getSlide() {
+ return slide;
+ }
+
+ public void setSlide(int slide) {
+ this.slide = slide;
+ }
+
+ public String getItem() {
+ return item;
+ }
+
+ public void setItem(String item) {
+ this.item = item;
+ }
+
+ public boolean isTwelveHourDisplay() {
+ return twelveHourDisplay;
+ }
+
+ public void setTwelveHourDisplay(boolean twelveHourDisplay) {
+ this.twelveHourDisplay = twelveHourDisplay;
+ }
+
+ public boolean isBlankedDisplayed() {
+ return blankedDisplayed;
+ }
+
+ public void setBlankedDisplayed(boolean blankedDisplayed) {
+ this.blankedDisplayed = blankedDisplayed;
+ if (blankedDisplayed){
+ this.displayHidden = true;
+ }
+ }
+
+ public boolean isThemeDisplayed() {
+ return themeDisplayed;
+ }
+
+ public void setThemeDisplayed(boolean themeDisplayed) {
+ this.themeDisplayed = themeDisplayed;
+ if (themeDisplayed){
+ this.displayHidden = true;
+ }
+ }
+
+ public boolean isDesktopDisplayed() {
+ return desktopDisplayed;
+ }
+
+ public void setDesktopDisplayed(boolean desktopDisplayed) {
+ this.desktopDisplayed = desktopDisplayed;
+ if (desktopDisplayed){
+ this.displayHidden = true;
+ }
+ }
+
+ public boolean isDisplayHidden() {
+ return displayHidden;
+ }
+
+ public void setDisplayHidden(boolean displayHidden) {
+ this.displayHidden = displayHidden;
+ }
+}
=== modified file 'src/org/openlp/android/data/Slide.java'
--- src/org/openlp/android/data/Slide.java 2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/data/Slide.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
=== modified file 'src/org/openlp/android/utility/GroupExpandableListAdapter.java'
--- src/org/openlp/android/utility/GroupExpandableListAdapter.java 2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/utility/GroupExpandableListAdapter.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
=== modified file 'src/org/openlp/android/utility/JSONHandler.java'
--- src/org/openlp/android/utility/JSONHandler.java 2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/utility/JSONHandler.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -28,6 +28,7 @@
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONStringer;
+import org.openlp.android.data.Poll;
import org.openlp.android.data.Slide;
import java.io.IOException;
@@ -38,7 +39,6 @@
import java.util.List;
public class JSONHandler {
- private static String LOG_TAG = JSONHandler.class.getName();
public static String createRequestJSON(String key, String value) throws JSONHandlerException {
try {
@@ -120,12 +120,45 @@
catch (JSONException e) {
throw new JSONHandlerException(e);
}
-
- }
-
+ }
+
+ public static Poll parsePollResponseJSON(HttpEntity entity) throws JSONHandlerException {
+ try {
+ InputStream inputStream = entity.getContent();
+ String result = StringHelper.convertStreamToString(inputStream);
+ Log.i(LOG_TAG, result);
+
+ JSONObject jObject = new JSONObject(result);
+ JSONObject results = jObject.getJSONObject("results");
+ //JSONArray items = results.getJSONArray("slides");
+ Poll poll = new Poll();
+ poll.setSlide(results.getInt("slide"));
+ poll.setItem(results.getString("item"));
+ poll.setTwelveHourDisplay(results.getBoolean("twelve"));
+ poll.setBlankedDisplayed(results.getBoolean("blank"));
+ poll.setThemeDisplayed(results.getBoolean("theme"));
+ poll.setDesktopDisplayed(results.getBoolean("display"));
+ Log.d(LOG_TAG, poll.toString());
+ inputStream.close();
+ return poll;
+ }
+ catch (IOException e) {
+ throw new JSONHandlerException(e);
+ }
+ catch (JSONException e) {
+ throw new JSONHandlerException(e);
+ }
+ }
+
public static class JSONHandlerException extends Exception {
- public JSONHandlerException(Throwable throwable) {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6772307308404816615L;
+
+ public JSONHandlerException(Throwable throwable) {
super(throwable);
}
}
+ private static String LOG_TAG = JSONHandler.class.getName();
}
=== modified file 'src/org/openlp/android/utility/OpenLPHttpClient.java'
--- src/org/openlp/android/utility/OpenLPHttpClient.java 2011-05-07 20:01:46 +0000
+++ src/org/openlp/android/utility/OpenLPHttpClient.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -46,7 +46,6 @@
private HttpGet httpGet;
private URL url;
private final String urlBase;
- private final String LOG_TAG = OpenLPHttpClient.class.getName();
public OpenLPHttpClient(Context context) {
SharedPreferences preferences = context.getSharedPreferences(context
@@ -91,5 +90,5 @@
public HttpResponse execute() throws IOException {
return super.execute(httpGet);
}
-
+ private final String LOG_TAG = OpenLPHttpClient.class.getName();
}
=== modified file 'src/org/openlp/android/utility/SlideAdapter.java'
--- src/org/openlp/android/utility/SlideAdapter.java 2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/utility/SlideAdapter.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
=== modified file 'src/org/openlp/android/utility/StringHelper.java'
--- src/org/openlp/android/utility/StringHelper.java 2011-05-05 19:30:01 +0000
+++ src/org/openlp/android/utility/StringHelper.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
=== modified file 'src/org/openlp/android/utility/WebCallAsyncTask.java'
--- src/org/openlp/android/utility/WebCallAsyncTask.java 2011-05-24 19:17:02 +0000
+++ src/org/openlp/android/utility/WebCallAsyncTask.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -33,7 +33,6 @@
* Call URL's using this task, which provides visual feedback.
*/
public class WebCallAsyncTask extends AsyncTask<String, Void, Void> {
- private final String LOG_TAG = WebCallAsyncTask.class.getName();
private Context context;
private ProgressDialog progressDialog;
private String error;
@@ -85,4 +84,5 @@
Toast.makeText(context, error, Toast.LENGTH_LONG).show();
}
}
+ private final String LOG_TAG = WebCallAsyncTask.class.getName();
}
=== modified file 'src/org/openlp/android/utility/WebCallReturningAsyncTask.java'
--- src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2011-06-07 20:39:33 +0000
+++ src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2011-12-28 15:45:29 +0000
@@ -1,8 +1,8 @@
/******************************************************************************
* OpenLP - Open Source Lyrics Projection *
* --------------------------------------------------------------------------- *
- * Copyright (c) 2008-2011 Raoul Snyman *
- * Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael *
+ * Copyright (c) 2008-2012 Raoul Snyman *
+ * Portions copyright (c) 2008-2012 Tim Bentley, Jonathan Corwin, Michael *
* Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, *
* Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, *
* Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund *
@@ -35,7 +35,6 @@
import java.io.InputStreamReader;
public class WebCallReturningAsyncTask extends AsyncTask<String, Void, String> {
- private final String LOG_TAG = this.getClass().getName();
private Activity context;
private String apiPart;
@@ -105,4 +104,5 @@
protected void onPostExecute(String s) {
super.onPostExecute(s);
}
+ private final String LOG_TAG = this.getClass().getName();
}
Follow ups