openlp-android team mailing list archive
-
openlp-android team
-
Mailing list archive
-
Message #00089
[Merge] lp:~trb143/openlp/android_04 into lp:openlp/android
Tim Bentley has proposed merging lp:~trb143/openlp/android_04 into lp:openlp/android.
Requested reviews:
John Cegalis (jseagull1)
OpenLP Android Developers (openlp-android)
For more details, see:
https://code.launchpad.net/~trb143/openlp/android_04/+merge/91705
Big Change.
Reformatted all code.
- Added long press to select song and them move the slide
- Ability to select font for display size
- Made tabs smaller
- Split misc and alert tabs
- Added stage view tabs.
--
https://code.launchpad.net/~trb143/openlp/android_04/+merge/91705
Your team OpenLP Android Developers is requested to review the proposed merge of lp:~trb143/openlp/android_04 into lp:openlp/android.
=== modified file 'AndroidManifest.xml'
--- AndroidManifest.xml 2011-12-11 10:12:40 +0000
+++ AndroidManifest.xml 2012-02-06 19:37:54 +0000
@@ -3,8 +3,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:installLocation="auto"
package="org.openlp.android"
- android:versionCode="1"
- android:versionName="0.3"
+ android:versionCode="3"
+ android:versionName="0.4"
>
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.INTERNET"/>
@@ -35,6 +35,8 @@
<activity android:name=".activity.Preferences" android:label="@string/preferences"/>
<activity android:name=".activity.Slide"/>
<activity android:name=".activity.Service"/>
+ <activity android:name=".activity.Alert"/>
+ <activity android:name=".activity.StageView"/>
<meta-data
android:name="android.app.default_searchable"
android:value=".activity.SearchableActivity"/>
=== modified file 'OpenLP.apk'
Binary files OpenLP.apk 2012-01-15 08:36:46 +0000 and OpenLP.apk 2012-02-06 19:37:54 +0000 differ
=== added file 'project.properties'
--- project.properties 1970-01-01 00:00:00 +0000
+++ project.properties 2012-02-06 19:37:54 +0000
@@ -0,0 +1,11 @@
+# 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,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
=== added file 'res/layout/alert.xml'
--- res/layout/alert.xml 1970-01-01 00:00:00 +0000
+++ res/layout/alert.xml 2012-02-06 19:37:54 +0000
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+ <TextView
+ android:text="@string/alert"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+ <EditText
+ android:id="@+id/alert"
+ android:layout_height="wrap_content"
+ android:text=""
+ android:inputType="textShortMessage"
+ android:layout_width="fill_parent"
+ android:hint="@string/alertHint"/>
+ <Button android:text="@string/send"
+ android:id="@+id/send"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"/>
+</LinearLayout>
=== modified file 'res/layout/main.xml'
--- res/layout/main.xml 2011-05-17 21:49:44 +0000
+++ res/layout/main.xml 2012-02-06 19:37:54 +0000
@@ -7,11 +7,16 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:padding="5dp">
+ android:padding="0dp">
+
<TabWidget
- android:id="@android:id/tabs"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
+ android:id="@android:id/tabs"
+ android:layout_width="fill_parent"
+ android:layout_height="45dp"
+ android:textColor="#000000"
+ android:textSize="18dp"
+ android:textStyle="bold"/>
+
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
=== modified file 'res/layout/misc.xml'
--- res/layout/misc.xml 2011-12-24 15:06:31 +0000
+++ res/layout/misc.xml 2012-02-06 19:37:54 +0000
@@ -10,20 +10,5 @@
android:layout_height="wrap_content"
android:textOn="@string/displayBlankOn"
android:textOff="@string/displayBlankOff"/>
- <TextView
- android:text="@string/alert"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
- <EditText
- android:id="@+id/alert"
- android:layout_height="wrap_content"
- android:text=""
- android:inputType="textShortMessage"
- android:layout_width="fill_parent"
- android:hint="@string/alertHint"/>
- <Button android:text="@string/send"
- android:id="@+id/send"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"/>
</LinearLayout>
=== modified file 'res/layout/service.xml'
--- res/layout/service.xml 2011-05-17 21:49:44 +0000
+++ res/layout/service.xml 2012-02-06 19:37:54 +0000
@@ -14,7 +14,7 @@
android:layout_gravity="top"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:id="@+id/list"
+ android:id="@+id/serviceList"
android:layout_width="fill_parent"/>
<LinearLayout
android:baselineAligned="false"
=== added file 'res/layout/stageview.xml'
--- res/layout/stageview.xml 1970-01-01 00:00:00 +0000
+++ res/layout/stageview.xml 2012-02-06 19:37:54 +0000
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:baselineAligned="false"
+ android:orientation="vertical" >
+ <WebView
+ android:id="@+id/stageview"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+</LinearLayout>
\ No newline at end of file
=== modified file 'res/values/colors.xml'
--- res/values/colors.xml 2011-05-20 19:41:14 +0000
+++ res/values/colors.xml 2012-02-06 19:37:54 +0000
@@ -1,4 +1,4 @@
<resources>
<color name="lightGreen">#ff66ff33</color>
- <color name="white">#ffffffff</color>
+ <color name="white">#ffffff00</color>
</resources>
\ No newline at end of file
=== modified file 'res/values/defaultValues.xml'
--- res/values/defaultValues.xml 2011-12-31 09:22:22 +0000
+++ res/values/defaultValues.xml 2012-02-06 19:37:54 +0000
@@ -7,4 +7,5 @@
<!-- INTEGER -->
<integer name="socketTimeoutDefaultValue">3000</integer>
<integer name="connectionTimeoutDefaultValue">3000</integer>
+ <integer name="textSizeDefaultValue">14</integer>
</resources>
\ No newline at end of file
=== modified file 'res/values/keyStrings.xml'
--- res/values/keyStrings.xml 2011-12-16 15:37:31 +0000
+++ res/values/keyStrings.xml 2012-02-06 19:37:54 +0000
@@ -1,7 +1,8 @@
<resources>
<string name="keyEnableCustomTimeout">enableCustomTimeout</string>
<string name="keyConnectionTimeout">connectionTimeout</string>
- <string name="keyDisplayBlankType">blankType</string>
+ <string name="keyDisplayBlankType">blankType</string>
+ <string name="keyTextSize">textSize</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 2012-02-06 19:37:54 +0000
@@ -0,0 +1,12 @@
+<resources>
+ <string-array name="displayTypeValueEntries">
+ <item>@string/displayScreen</item>
+ <item>@string/displayTheme</item>
+ <item>@string/displayDesktop</item>
+ </string-array>
+ <string-array name="displayTypeValues">
+ <item>@string/displayScreen</item>
+ <item>@string/displayTheme</item>
+ <item>@string/displayDesktop</item>
+ </string-array>
+</resources>
\ No newline at end of file
=== removed file 'res/values/misc.xml'
--- res/values/misc.xml 2011-12-31 09:22:22 +0000
+++ res/values/misc.xml 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
-<resources>
- <string-array name="displayTypeValueEntries">
- <item>@string/displayScreen</item>
- <item>@string/displayTheme</item>
- <item>@string/displayDesktop</item>
- </string-array>
- <string-array name="displayTypeValues">
- <item>@string/displayScreen</item>
- <item>@string/displayTheme</item>
- <item>@string/displayDesktop</item>
- </string-array>
-</resources>
\ No newline at end of file
=== modified file 'res/values/strings.xml'
--- res/values/strings.xml 2011-12-31 09:22:22 +0000
+++ res/values/strings.xml 2012-02-06 19:37:54 +0000
@@ -25,6 +25,8 @@
<string name="urlHint">Hostname or IP</string>
<string name="port">Port</string>
<string name="enableCustomTimeouts">Enable Custom Timeouts</string>
+ <string name="textSizeType">Text Size Type</string>
+ <string name="textSizeSummary">Change the Service text size</string>
<string name="displayType">Display Blank Type</string>
<string name="displayBlankType">Display Blank Type</string>
<string name="displayBlankSummary">Select the required blank type</string>
@@ -42,10 +44,11 @@
<string name="connectionTimeoutSummary">Select a value (milliseconds)</string>
<string name="save">Save</string>
<string name="unable">Unable to load page -</string>
- <string name="fail">Connection failed</string>
- <string name="jsonfail">JSON failed</string>
+ <string name="connectionFailed">Connection failed</string>
+ <string name="jsonfail">Message format error </string>
<string name="loading">Connecting...</string>
<string name="searching">Searching...</string>
+ <string name="loadingFailed">Error - Load Failed</string>
<string name="loadingServiceItems">Loading Service Items...</string>
<string name="loadingSlideItems">Loading Slide Items...</string>
<string name="loadingStatusInfo">Loading Status Info...</string>
=== added file 'res/values/textSize.xml'
--- res/values/textSize.xml 1970-01-01 00:00:00 +0000
+++ res/values/textSize.xml 2012-02-06 19:37:54 +0000
@@ -0,0 +1,22 @@
+<resources>
+ <string-array name="textSizeValueEntries">
+ <item>6</item>
+ <item>8</item>
+ <item>10</item>
+ <item>12</item>
+ <item>14</item>
+ <item>16</item>
+ <item>18</item>
+ <item>20</item>
+ </string-array>
+ <string-array name="textSizeValues">
+ <item>6</item>
+ <item>8</item>
+ <item>10</item>
+ <item>12</item>
+ <item>14</item>
+ <item>16</item>
+ <item>18</item>
+ <item>20</item>
+ </string-array>
+</resources>
\ No newline at end of file
=== modified file 'res/xml/preferences.xml'
--- res/xml/preferences.xml 2011-12-16 15:37:31 +0000
+++ res/xml/preferences.xml 2012-02-06 19:37:54 +0000
@@ -2,6 +2,16 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
+ android:title="@string/textSizeType">
+ <ListPreference
+ android:title="@string/textSizeType"
+ android:key="@string/keyTextSize"
+ android:summary="@string/textSizeSummary"
+ android:entries="@array/textSizeValueEntries"
+ android:entryValues="@array/textSizeValues"
+ android:defaultValue="@integer/textSizeDefaultValue"/>
+ </PreferenceCategory>
+ <PreferenceCategory
android:title="@string/displayType">
<ListPreference
android:title="@string/displayBlankType"
=== modified file 'src/org/openlp/android/OpenLP.java'
--- src/org/openlp/android/OpenLP.java 2011-12-24 15:06:31 +0000
+++ src/org/openlp/android/OpenLP.java 2012-02-06 19:37:54 +0000
@@ -27,46 +27,66 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
+import android.view.Window;
import android.widget.TabHost;
+
+import org.openlp.android.activity.Alert;
import org.openlp.android.activity.Misc;
import org.openlp.android.activity.Preferences;
import org.openlp.android.activity.Service;
import org.openlp.android.activity.Slide;
+import org.openlp.android.activity.StageView;
/**
* OpenLP-Android initialisation point.
*/
public class OpenLP extends TabActivity {
- /**
- * Called when the activity is first created.
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- if (getSharedPreferences(getString(R.string.keySharedPreferences), Context.MODE_PRIVATE)
- .getString(getString(R.string.keyHost), "NONE").equals("NONE")
- || getSharedPreferences(getString(R.string.keySharedPreferences), Context.MODE_PRIVATE).getString(getString(R.string.keyHost), null).equals(null)
- ) {
- Log.d(LOG_TAG, "URL preference not set. Starting preference activity...");
- Intent preferenceIntent = new Intent(this, Preferences.class);
- startActivity(preferenceIntent);
- }
- TabHost tabHost = getTabHost();
-
- tabHost.addTab(tabHost.newTabSpec("albums")
- .setIndicator("Service")
- .setContent(new Intent(this, Service.class)));
-
- tabHost.addTab(tabHost.newTabSpec("artists")
- .setIndicator("Slide")
- .setContent(new Intent(this, Slide.class)));
-
- tabHost.addTab(tabHost.newTabSpec("albums")
- .setIndicator("Misc")
- .setContent(new Intent(this, Misc.class)));
-
- }
- private final String LOG_TAG = OpenLP.class.getName();
+ final int tabHeight = 45;
+ /**
+ * Called when the activity is first created.
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(R.layout.main);
+
+ if (getSharedPreferences(getString(R.string.keySharedPreferences),
+ Context.MODE_PRIVATE).getString(getString(R.string.keyHost),
+ "NONE").equals("NONE")
+ || getSharedPreferences(
+ getString(R.string.keySharedPreferences),
+ Context.MODE_PRIVATE).getString(
+ getString(R.string.keyHost), null).equals(null)) {
+ Log.d(LOG_TAG,
+ "URL preference not set. Starting preference activity...");
+ Intent preferenceIntent = new Intent(this, Preferences.class);
+ startActivity(preferenceIntent);
+ }
+ TabHost tabHost = getTabHost();
+
+ tabHost.addTab(tabHost.newTabSpec("service").setIndicator("Service")
+ .setContent(new Intent(this, Service.class)));
+
+ tabHost.addTab(tabHost.newTabSpec("slide").setIndicator("Slide")
+ .setContent(new Intent(this, Slide.class)));
+
+ tabHost.addTab(tabHost.newTabSpec("display").setIndicator("Display")
+ .setContent(new Intent(this, Misc.class)));
+
+ tabHost.addTab(tabHost.newTabSpec("alerts").setIndicator("Alerts")
+ .setContent(new Intent(this, Alert.class)));
+
+ tabHost.addTab(tabHost.newTabSpec("stage").setIndicator("Stage")
+ .setContent(new Intent(this, StageView.class)));
+ /*
+ * Set the overall tab height for all tabs
+ */
+ for(int i=0; i<tabHost.getTabWidget().getTabCount(); i++){
+ tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = tabHeight;
+ }
+
+ }
+
+ private final String LOG_TAG = OpenLP.class.getName();
}
\ No newline at end of file
=== added file 'src/org/openlp/android/activity/Alert.java'
--- src/org/openlp/android/activity/Alert.java 1970-01-01 00:00:00 +0000
+++ src/org/openlp/android/activity/Alert.java 2012-02-06 19:37:54 +0000
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * OpenLP - Open Source Lyrics Projection *
+ * --------------------------------------------------------------------------- *
+ * Copyright (c) 2008-2011 Raoul Snyman *
+ * Portions copyright (c) 2008-2011 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.activity;
+
+import org.openlp.android.R;
+import org.openlp.android.api.Api;
+import org.openlp.android.utility.JSONHandler;
+import org.openlp.android.utility.WebCallAsyncTask;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+public class Alert extends Activity implements Api {
+ private final Context context = this;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Log.i(LOG_TAG, "onCreate");
+ setContentView(R.layout.alert);
+
+ findViewById(R.id.send).setOnClickListener(mSend);
+ }
+
+ public Button.OnClickListener mSend = new Button.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ EditText edittext = (EditText) findViewById(R.id.alert);
+ String alert;
+ try {
+ if (edittext.getText().toString().trim().length() > 0) {
+ alert = JSONHandler.createRequestJSON("text", edittext
+ .getText().toString());
+ new WebCallAsyncTask(context, ALERT).execute(alert);
+ }
+ else {
+ Toast.makeText(getBaseContext(),
+ getString(R.string.alertTextNull),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ catch (JSONHandler.JSONHandlerException e) {
+ Toast.makeText(context,R.string.jsonfail,
+ Toast.LENGTH_LONG).show();
+ Log.e(LOG_TAG, e.toString());
+ }
+ }
+ };
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Log.d(LOG_TAG, "Resume");
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.preferences:
+ startActivity(new Intent(this, Preferences.class));
+ return true;
+ case R.id.menuSearch:
+ onSearchRequested();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ private final String LOG_TAG = Alert.class.getName();
+}
=== modified file 'src/org/openlp/android/activity/Misc.java'
--- src/org/openlp/android/activity/Misc.java 2012-01-15 11:35:44 +0000
+++ src/org/openlp/android/activity/Misc.java 2012-02-06 19:37:54 +0000
@@ -35,8 +35,6 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
@@ -49,161 +47,145 @@
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) {
- EditText edittext = (EditText) findViewById(R.id.alert);
- String alert;
- try {
- if (edittext.getText().toString().trim().length() > 0) {
- alert = JSONHandler.createRequestJSON("text", edittext.getText().toString());
- new WebCallAsyncTask(context, ALERT).execute(alert);
- }
- else {
- Toast.makeText(getBaseContext(), getString(R.string.alertTextNull), Toast.LENGTH_SHORT).show();
- }
- }
- catch (JSONHandler.JSONHandlerException e) {
- Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT).show();
- }
- }
- };
-
- @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() {
- @Override
- public void onClick(View view) {
- try {
- if (!toggleButton.isChecked()) {
- new WebCallAsyncTask(context).execute(DISPLAY_SHOW);
- }
- else {
- Log.d(LOG_TAG, "onCLick Display Type = " + displayType);
- if (displayType.equals(getString(R.string.displayScreen))){
- Log.d(LOG_TAG, "Blank matched");
- new WebCallAsyncTask(context).execute(DISPLAY_HIDE_SCREEN);
- }
- else if (displayType.equals(getString(R.string.displayTheme))){
- Log.d(LOG_TAG, "Theme matched");
- new WebCallAsyncTask(context).execute(DISPLAY_HIDE_THEME);
- }
- else {
- Log.d(LOG_TAG, "Desktop matched");
- new WebCallAsyncTask(context).execute(DISPLAY_HIDE_DESKTOP);
- }
- }
- }
- catch (Exception e) {
- Toast.makeText(context, String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()),
- Toast.LENGTH_SHORT).show();
- }
+ private final Context context = this;
+ Misc misc = this;
+ SharedPreferences prefs;
+ String displayType;
+
+ @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() {
+ @Override
+ public void onClick(View view) {
+ try {
+ if (!toggleButton.isChecked()) {
+ new WebCallAsyncTask(context).execute(DISPLAY_SHOW);
+ }
+ else {
+ Log.d(LOG_TAG, "onCLick Display Type = " + displayType);
+ if (displayType
+ .equals(getString(R.string.displayScreen))) {
+ Log.d(LOG_TAG, "Blank matched");
+ new WebCallAsyncTask(context)
+ .execute(DISPLAY_HIDE_SCREEN);
+ }
+ else if (displayType
+ .equals(getString(R.string.displayTheme))) {
+ Log.d(LOG_TAG, "Theme matched");
+ new WebCallAsyncTask(context)
+ .execute(DISPLAY_HIDE_THEME);
+ }
+ else {
+ Log.d(LOG_TAG, "Desktop matched");
+ new WebCallAsyncTask(context)
+ .execute(DISPLAY_HIDE_DESKTOP);
+ }
+ }
+ }
+ catch (Exception e) {
+ Toast.makeText(context,R.string.loadingFailed,
+ Toast.LENGTH_LONG).show();
+ Log.e(LOG_TAG, e.toString());
+ }
try {
Thread.sleep(500);
}
catch (InterruptedException e) {
e.printStackTrace();
- }
- PollStatusTask poll = new PollStatusTask(misc);
- poll.execute(POLL_STATUS);
- }
- });
-
- findViewById(R.id.send).setOnClickListener(mSend);
- }
-
- @Override
- 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;
- }
-
+ }
+ PollStatusTask poll = new PollStatusTask(misc);
+ poll.execute(POLL_STATUS);
+ }
+ });
+ }
+
+ @Override
+ 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;
+ error = "";
+
+ 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 {
+ error = String.format("%s %s",
+ getString(R.string.unable), response);
+ }
+ }
+ catch (Exception e) {
+ error = String.format("%s: %s", e.getClass()
+ .getSimpleName(), e.getMessage());
+ }
+ return null;
+ }
+
@Override
protected void onPostExecute(Poll poll) {
super.onPostExecute(poll);
@@ -268,44 +250,36 @@
}
}
progressDialog.dismiss();
+
if (error != null && error.trim().length() > 0) {
+ Toast.makeText(context,R.string.connectionFailed,
+ Toast.LENGTH_LONG).show();
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();
- inflater.inflate(R.menu.menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle item selection
- switch (item.getItemId()) {
- case R.id.preferences:
- startActivity(new Intent(this, Preferences.class));
- return true;
- case R.id.menuSearch:
- onSearchRequested();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
- private final String LOG_TAG = Misc.class.getName();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.preferences:
+ startActivity(new Intent(this, Preferences.class));
+ return true;
+ case R.id.menuSearch:
+ onSearchRequested();
+ return true;
+ default:
+ 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-12-24 15:06:31 +0000
+++ src/org/openlp/android/activity/Preferences.java 2012-02-06 19:37:54 +0000
@@ -28,18 +28,18 @@
import org.openlp.android.R;
/**
- * Credits:
- * http://www.kaloer.com/android-preferences
+ * Credits: http://www.kaloer.com/android-preferences
* http://androidpartaker.wordpress.com/2010/07/11/android-preferences/
*/
public class Preferences extends PreferenceActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Log.d(LOG_TAG, "Launching preferences");
- getPreferenceManager().setSharedPreferencesName(getString(R.string.keySharedPreferences));
- addPreferencesFromResource(R.xml.preferences);
- }
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Log.d(LOG_TAG, "Launching preferences");
+ getPreferenceManager().setSharedPreferencesName(
+ getString(R.string.keySharedPreferences));
+ addPreferencesFromResource(R.xml.preferences);
+ }
- private final String LOG_TAG = Preferences.class.getName();
+ private final String LOG_TAG = Preferences.class.getName();
}
=== modified file 'src/org/openlp/android/activity/SearchableActivity.java'
--- src/org/openlp/android/activity/SearchableActivity.java 2011-12-24 15:06:31 +0000
+++ src/org/openlp/android/activity/SearchableActivity.java 2012-02-06 19:37:54 +0000
@@ -51,176 +51,203 @@
import java.util.Map;
public class SearchableActivity extends Activity implements Api {
- private Activity context;
- private ExpandableListView listView;
- private final int DIALOG_ITEM_OPTIONS = 0;
- private Object dialogKey;
- private JSONArray dialogValue;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.search);
- context = this;
- listView = (ExpandableListView) findViewById(R.id.list);
-
- listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
- @SuppressWarnings({"unchecked"})
- @Override
- public boolean onChildClick(ExpandableListView expandableListView, View view, int parent,
- int childPosition, long l) {
- Map<String, JSONArray> child = (Map<String, JSONArray>) listView.getExpandableListAdapter()
- .getChild(parent, childPosition);
- dialogKey = null;
- dialogValue = null;
- dialogKey = listView.getExpandableListAdapter().getGroup(parent);
- dialogValue = child.get(dialogKey.toString());
- showDialog(DIALOG_ITEM_OPTIONS);
- return false;
- }
- });
-
- Intent intent = getIntent();
- if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
- String query = intent.getStringExtra(SearchManager.QUERY);
- doSearch(query);
- }
- }
-
- @Override
- protected Dialog onCreateDialog(int id) {
- switch (id) {
- case DIALOG_ITEM_OPTIONS:
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
- dialogBuilder.setTitle("Item Options:");
- dialogBuilder.setNegativeButton("Send Live", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- try {
- new WebCallAsyncTask(context, String.format(SEARCH_PLUGIN_LIVE, dialogKey))
- .execute(JSONHandler.createRequestJSON("id", dialogValue.get(0).toString()));
- }
- catch (Exception e) {
- Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
- }
- }
- });
- dialogBuilder.setPositiveButton("Add to Service", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- try {
- new WebCallAsyncTask(context, String.format(SEARCH_PLUGIN_ADD, dialogKey))
- .execute(JSONHandler.createRequestJSON("id", dialogValue.get(0).toString()));
- }
- catch (Exception e) {
- Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
- }
- dialogInterface.cancel();
- }
- });
- return dialogBuilder.create();
- default:
- return null;
- }
- }
-
- @Override
- protected void onPrepareDialog(int id, Dialog dialog) {
- try {
- dialog.setTitle(dialogValue.get(1).toString());
- }
- catch (JSONException e) {
- e.printStackTrace();
- }
- }
-
- public void doSearch(String search) {
- new SearchAsync().execute(search);
- }
-
- class SearchAsync extends AsyncTask<String, Void, SearchResults> {
- ProgressDialog progressDialog;
- String query;
-
- @Override
- protected SearchResults doInBackground(String... strings) {
- query = strings[0];
- List<String> groups = new ArrayList<String>();
- List<List<Map<String, JSONArray>>> children = new ArrayList<List<Map<String, JSONArray>>>();
-
- AsyncTask <String, Void, String> call = new WebCallReturningAsyncTask(context).execute(SEARCHABLE_PLUGINS);
-
- try {
- JSONArray array = new JSONObject(call.get().toString()).getJSONObject("results").getJSONArray("items");
-
- for (int i = 0; i < array.length(); i++) {
- String pluginString = ((JSONArray) array.get(i)).get(0).toString();
- groups.add(pluginString);
-
- JSONArray resultArray = null;
-
- AsyncTask <String, Void, String> pluginResults = new WebCallReturningAsyncTask(context,
- String.format(SEARCH_PLUGIN_FORMATTED, pluginString))
- .execute(JSONHandler.createRequestJSON("text", query));
-
- List<Map<String, JSONArray>> list = new ArrayList<Map<String, JSONArray>>();
- if (pluginResults.get() != null && pluginResults.get().toString().trim().length() > 0) {
- resultArray = new JSONObject(pluginResults.get().toString()).getJSONObject("results")
- .getJSONArray("items");
- for (int j = 0; j < resultArray.length(); j++) {
- Map<String, JSONArray> item = new HashMap<String, JSONArray>();
- item.put(pluginString, (JSONArray) resultArray.get(j));
- list.add(item);
- }
- }
- children.add(list);
- }
- }
- catch (Exception e) {
- Log.e(LOG_TAG, e.toString());
- Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
- }
-
- SearchResults results = new SearchResults();
- results.setGroups(groups);
- results.setChildren(children);
- return results;
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- progressDialog = ProgressDialog.show(context, null, getString(R.string.searching));
- }
-
- @Override
- protected void onPostExecute(SearchResults results) {
- super.onPostExecute(results);
- listView.setAdapter(new GroupExpandableListAdapter(context, results.getGroups(), results.getChildren()));
- progressDialog.dismiss();
- Toast.makeText(context, String.format(getString(R.string.showingResults), query), Toast.LENGTH_SHORT).show();
- }
- }
-
- class SearchResults {
- List<String> groups;
- List<List<Map<String, JSONArray>>> children;
-
- public List<String> getGroups() {
- return groups;
- }
-
- public void setGroups(List<String> groups) {
- this.groups = groups;
- }
-
- public List<List<Map<String, JSONArray>>> getChildren() {
- return children;
- }
-
- public void setChildren(List<List<Map<String, JSONArray>>> children) {
- this.children = children;
- }
- }
- private final String LOG_TAG = this.getClass().getSimpleName();
+ private Activity context;
+ private ExpandableListView listView;
+ private final int DIALOG_ITEM_OPTIONS = 0;
+ private Object dialogKey;
+ private JSONArray dialogValue;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.search);
+ context = this;
+ listView = (ExpandableListView) findViewById(R.id.list);
+
+ listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
+ @SuppressWarnings({ "unchecked" })
+ @Override
+ public boolean onChildClick(ExpandableListView expandableListView,
+ View view, int parent, int childPosition, long l) {
+ Map<String, JSONArray> child = (Map<String, JSONArray>) listView
+ .getExpandableListAdapter().getChild(parent,
+ childPosition);
+ dialogKey = null;
+ dialogValue = null;
+ dialogKey = listView.getExpandableListAdapter()
+ .getGroup(parent);
+ dialogValue = child.get(dialogKey.toString());
+ showDialog(DIALOG_ITEM_OPTIONS);
+ return false;
+ }
+ });
+
+ Intent intent = getIntent();
+ if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
+ String query = intent.getStringExtra(SearchManager.QUERY);
+ doSearch(query);
+ }
+ }
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ switch (id) {
+ case DIALOG_ITEM_OPTIONS:
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
+ dialogBuilder.setTitle("Item Options:");
+ dialogBuilder.setNegativeButton("Send Live",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface,
+ int i) {
+ try {
+ new WebCallAsyncTask(context, String.format(
+ SEARCH_PLUGIN_LIVE, dialogKey))
+ .execute(JSONHandler.createRequestJSON(
+ "id", dialogValue.get(0)
+ .toString()));
+ }
+ catch (Exception e) {
+ Toast.makeText(context, e.getMessage(),
+ Toast.LENGTH_LONG).show();
+ }
+ }
+ });
+ dialogBuilder.setPositiveButton("Add to Service",
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface,
+ int i) {
+ try {
+ new WebCallAsyncTask(context, String.format(
+ SEARCH_PLUGIN_ADD, dialogKey))
+ .execute(JSONHandler.createRequestJSON(
+ "id", dialogValue.get(0)
+ .toString()));
+ }
+ catch (Exception e) {
+ Toast.makeText(context, e.getMessage(),
+ Toast.LENGTH_LONG).show();
+ }
+ dialogInterface.cancel();
+ }
+ });
+ return dialogBuilder.create();
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ protected void onPrepareDialog(int id, Dialog dialog) {
+ try {
+ dialog.setTitle(dialogValue.get(1).toString());
+ }
+ catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void doSearch(String search) {
+ new SearchAsync().execute(search);
+ }
+
+ class SearchAsync extends AsyncTask<String, Void, SearchResults> {
+ ProgressDialog progressDialog;
+ String query;
+
+ @Override
+ protected SearchResults doInBackground(String... strings) {
+ query = strings[0];
+ List<String> groups = new ArrayList<String>();
+ List<List<Map<String, JSONArray>>> children = new ArrayList<List<Map<String, JSONArray>>>();
+
+ AsyncTask<String, Void, String> call = new WebCallReturningAsyncTask(
+ context).execute(SEARCHABLE_PLUGINS);
+
+ try {
+ JSONArray array = new JSONObject(call.get().toString())
+ .getJSONObject("results").getJSONArray("items");
+
+ for (int i = 0; i < array.length(); i++) {
+ String pluginString = ((JSONArray) array.get(i)).get(0)
+ .toString();
+ groups.add(pluginString);
+
+ JSONArray resultArray = null;
+
+ AsyncTask<String, Void, String> pluginResults = new WebCallReturningAsyncTask(
+ context, String.format(SEARCH_PLUGIN_FORMATTED,
+ pluginString)).execute(JSONHandler
+ .createRequestJSON("text", query));
+
+ List<Map<String, JSONArray>> list = new ArrayList<Map<String, JSONArray>>();
+ if (pluginResults.get() != null
+ && pluginResults.get().toString().trim().length() > 0) {
+ resultArray = new JSONObject(pluginResults.get()
+ .toString()).getJSONObject("results")
+ .getJSONArray("items");
+ for (int j = 0; j < resultArray.length(); j++) {
+ Map<String, JSONArray> item = new HashMap<String, JSONArray>();
+ item.put(pluginString,
+ (JSONArray) resultArray.get(j));
+ list.add(item);
+ }
+ }
+ children.add(list);
+ }
+ }
+ catch (Exception e) {
+ Log.e(LOG_TAG, e.toString());
+ Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG)
+ .show();
+ }
+
+ SearchResults results = new SearchResults();
+ results.setGroups(groups);
+ results.setChildren(children);
+ return results;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ progressDialog = ProgressDialog.show(context, null,
+ getString(R.string.searching));
+ }
+
+ @Override
+ protected void onPostExecute(SearchResults results) {
+ super.onPostExecute(results);
+ listView.setAdapter(new GroupExpandableListAdapter(context, results
+ .getGroups(), results.getChildren()));
+ progressDialog.dismiss();
+ Toast.makeText(context,
+ String.format(getString(R.string.showingResults), query),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+
+ class SearchResults {
+ List<String> groups;
+ List<List<Map<String, JSONArray>>> children;
+
+ public List<String> getGroups() {
+ return groups;
+ }
+
+ public void setGroups(List<String> groups) {
+ this.groups = groups;
+ }
+
+ public List<List<Map<String, JSONArray>>> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<List<Map<String, JSONArray>>> children) {
+ 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-12-24 15:06:31 +0000
+++ src/org/openlp/android/activity/Service.java 2012-02-06 19:37:54 +0000
@@ -40,7 +40,8 @@
import org.apache.http.HttpResponse;
import org.openlp.android.R;
import org.openlp.android.api.Api;
-import org.openlp.android.data.Slide;
+import org.openlp.android.activity.Slide;
+import org.openlp.android.data.SlideItem;
import org.openlp.android.utility.JSONHandler;
import org.openlp.android.utility.OpenLPHttpClient;
import org.openlp.android.utility.SlideAdapter;
@@ -53,181 +54,197 @@
* Activity for managing service objects.
*/
public class Service extends Activity implements Api {
- private final Activity context = this;
-
- private ListView listView;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Log.i(LOG_TAG, "onCreate");
-
- setContentView(R.layout.service);
- listView = (ListView) findViewById(R.id.list);
- findViewById(R.id.prev).setOnClickListener(new Button.OnClickListener() {
- @Override
- public void onClick(View v) {
- try {
- new WebCallAsyncTask(context).execute(SERVICE_PREVIOUS);
- }
- catch (Exception e) {
- Toast.makeText(getApplicationContext(),
- String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()),
- Toast.LENGTH_SHORT).show();
- }
- }
- });
-
- findViewById(R.id.next).setOnClickListener(new Button.OnClickListener() {
- @Override
- public void onClick(View v) {
- try {
- new WebCallAsyncTask(context).execute(SERVICE_NEXT);
- }
- catch (Exception e) {
- Toast.makeText(getApplicationContext(),
- String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()),
- Toast.LENGTH_SHORT).show();
- }
- }
- });
-
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
- String service;
- try {
- service = JSONHandler.createRequestJSON("id", Integer.toString(i));
- new WebCallAsyncTask(context, SERVICE_SET).execute(service);
- service = null;
- }
- catch (JSONHandler.JSONHandlerException e) {
- service = String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage());
- }
-
- if (service != null) {
- Toast.makeText(getApplicationContext(), service, Toast.LENGTH_LONG).show();
- }
- }
- });
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- Log.d(LOG_TAG, "Resume");
-
- new FetchServiceItemsTask(this).execute(SERVICE_LIST);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.preferences:
- startActivity(new Intent(this, Preferences.class));
- return true;
- case R.id.menuSearch:
- onSearchRequested();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- /**
- * Asynchronous task to fetch the service items.
- */
- class FetchServiceItemsTask extends AsyncTask<String, Void, Slide[]> {
- Service serviceActivity;
- ProgressDialog progressDialog;
- String error;
-
- FetchServiceItemsTask(Service serviceActivity) {
- this.serviceActivity = serviceActivity;
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- progressDialog = ProgressDialog.show(Service.this, getString(R.string.loading),
- getString(R.string.loadingServiceItems));
- }
-
- @Override
- protected Slide[] 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(serviceActivity, Preferences.class));
- }
- else {
- response = httpClient.execute();
- }
-
- if (response != null && response.getStatusLine().getStatusCode() == 200) {
- HttpEntity entity = response.getEntity();
-
- if (entity != null) {
- List<Slide> serviceItemList = JSONHandler.parseServiceItemResponseJSON(entity);
- Log.i(LOG_TAG, String.format("Service Items: %s", serviceItemList));
- return serviceItemList.toArray(new Slide[]{});
- }
- }
- 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(Slide[] slides) {
- super.onPostExecute(slides);
- if (slides == null) {
- slides = new Slide[]{};
- }
- listView.setAdapter(new SlideAdapter(context, Arrays.asList(slides), false));
- 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);
- }
- }
- }
- private final String LOG_TAG = Service.class.getName();
+ private final Activity context = this;
+
+ private ListView listView;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Log.i(LOG_TAG, "onCreate");
+
+ setContentView(R.layout.service);
+ listView = (ListView) findViewById(R.id.serviceList);
+ findViewById(R.id.prev).setOnClickListener(
+ new Button.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ try {
+ new WebCallAsyncTask(context)
+ .execute(SERVICE_PREVIOUS);
+ }
+ catch (Exception e) {
+ Toast.makeText(
+ getApplicationContext(),
+ String.format("%s: %s", e.getClass()
+ .getSimpleName(), e.getMessage()),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ findViewById(R.id.next).setOnClickListener(
+ new Button.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ try {
+ new WebCallAsyncTask(context).execute(SERVICE_NEXT);
+ }
+ catch (Exception e) {
+ Toast.makeText(
+ getApplicationContext(),
+ String.format("%s: %s", e.getClass()
+ .getSimpleName(), e.getMessage()),
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view,
+ int i, long l) {
+ try {
+ String service = JSONHandler.createRequestJSON("id",
+ Integer.toString(i));
+ new WebCallAsyncTask(context, SERVICE_SET).execute(service);
+ }
+ catch (JSONHandler.JSONHandlerException e) {
+ Toast.makeText(getApplicationContext(),
+ String.format("%s: %s", e.getClass()
+ .getSimpleName(), e.getMessage()),
+ Toast.LENGTH_LONG).show();
+ }
+ }
+ });
+
+ listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> adapterView, View view,
+ int i, long l) {
+ try {
+ String service = JSONHandler.createRequestJSON("id",
+ Integer.toString(i));
+ new WebCallAsyncTask(context, SERVICE_SET).execute(service);
+ }
+ catch (JSONHandler.JSONHandlerException e) {
+ Toast.makeText(getApplicationContext(),
+ String.format("%s: %s", e.getClass()
+ .getSimpleName(), e.getMessage()),
+ Toast.LENGTH_LONG).show();
+ }
+ startActivity(new Intent(context, Slide.class));
+ return true;
+ }
+ });
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Log.d(LOG_TAG, "Resume");
+ new FetchServiceItemsTask(this).execute(SERVICE_LIST);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.preferences:
+ startActivity(new Intent(this, Preferences.class));
+ return true;
+ case R.id.menuSearch:
+ onSearchRequested();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ /**
+ * Asynchronous task to fetch the service items.
+ */
+ class FetchServiceItemsTask extends AsyncTask<String, Void, SlideItem[]> {
+ Service serviceActivity;
+ ProgressDialog progressDialog;
+ String error;
+
+ FetchServiceItemsTask(Service serviceActivity) {
+ this.serviceActivity = serviceActivity;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ progressDialog = ProgressDialog.show(Service.this,
+ getString(R.string.loading),
+ getString(R.string.loadingServiceItems));
+ }
+
+ @Override
+ protected SlideItem[] doInBackground(String... strings) {
+ OpenLPHttpClient httpClient = new OpenLPHttpClient(
+ getApplicationContext());
+ HttpResponse response = null;
+ error = "";
+
+ Log.d(LOG_TAG, "Processing:" + Arrays.asList(strings));
+ try {
+ httpClient.setUrl(strings[0]);
+ if (httpClient.getUrl().getHost().trim().length() <= 0) {
+ startActivity(new Intent(serviceActivity, Preferences.class));
+ }
+ else {
+ response = httpClient.execute();
+ }
+
+ if (response != null
+ && response.getStatusLine().getStatusCode() == 200) {
+ HttpEntity entity = response.getEntity();
+
+ if (entity != null) {
+ List<SlideItem> serviceItemList = JSONHandler
+ .parseServiceItemResponseJSON(entity);
+ Log.i(LOG_TAG, String.format("Service Items: %s",
+ serviceItemList));
+ return serviceItemList.toArray(new SlideItem[] {});
+ }
+ }
+ else {
+ error = String.format("%s %s",
+ getString(R.string.unable), response);
+ }
+ }
+ catch (Exception e) {
+ error = String.format("%s: %s", e.getClass()
+ .getSimpleName(), e.getMessage());
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(SlideItem[] slides) {
+ super.onPostExecute(slides);
+ if (slides == null) {
+ slides = new SlideItem[] {};
+ }
+ listView.setAdapter(new SlideAdapter(context,
+ Arrays.asList(slides), false));
+ progressDialog.dismiss();
+
+ if (error != null && error.trim().length() > 0) {
+ Toast.makeText(context,R.string.loadingFailed,
+ Toast.LENGTH_LONG).show();
+ Log.e(LOG_TAG, error);
+ }
+ }
+ }
+
+ 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-12-24 15:06:31 +0000
+++ src/org/openlp/android/activity/Slide.java 2012-02-06 19:37:54 +0000
@@ -49,184 +49,183 @@
import java.util.List;
public class Slide extends Activity implements Api {
- private final Activity context = this;
- private ListView slideList;
-
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Log.d(LOG_TAG, "onCreate");
- setContentView(R.layout.slide);
-
- slideList = (ListView) findViewById(R.id.list);
-
- findViewById(R.id.prev).setOnClickListener(new Button.OnClickListener() {
- public void onClick(View v) {
- try {
- new WebCallAsyncTask(context).execute(LIVE_PREVIOUS);
- }
- catch (Exception e) {
- Toast.makeText(getApplicationContext(),
- String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()),
- Toast.LENGTH_SHORT).show();
- Log.e(LOG_TAG, e.toString(), e);
- }
- }
- });
-
- findViewById(R.id.next).setOnClickListener(new Button.OnClickListener() {
- public void onClick(View v) {
- try {
- new WebCallAsyncTask(context).execute(LIVE_NEXT);
- }
- catch (Exception e) {
- Toast.makeText(getApplicationContext(),
- String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()),
- Toast.LENGTH_SHORT).show();
- Log.e(LOG_TAG, e.toString(), e);
- }
- }
- });
-
- slideList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
- String alert;
- try {
- alert = JSONHandler.createRequestJSON("id", Integer.toString(i));
- new WebCallAsyncTask(context, LIVE_SET).execute(alert);
- alert = null;
- }
- catch (Exception e) {
- try {
- throw new JSONHandler.JSONHandlerException(e);
- }
- catch (JSONHandler.JSONHandlerException e1) {
- alert = String.format("%s: %s", e1.getClass().getSimpleName(), e1.getMessage());
- }
- }
-
- if (alert != null) {
- Toast.makeText(getApplicationContext(), alert, Toast.LENGTH_LONG).show();
- }
- }
- });
-
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- Log.d(LOG_TAG, "Resume");
-
- new FetchSlideItemsTask(this).execute(LIVE_TEXT);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.preferences:
- startActivity(new Intent(this, Preferences.class));
- return true;
- case R.id.menuSearch:
- onSearchRequested();
- return true;
- default:
- return super.onOptionsItemSelected(item);
- }
- }
-
- class FetchSlideItemsTask extends AsyncTask<String, Void, org.openlp.android.data.Slide[]> {
- Slide slideActivity;
- ProgressDialog progressDialog;
- String error;
-
- FetchSlideItemsTask(Slide slideActivity) {
- this.slideActivity = slideActivity;
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- progressDialog = ProgressDialog.show(Slide.this, getString(R.string.loading), getString(R.string.loadingSlideItems));
- }
-
- @Override
- protected org.openlp.android.data.Slide[] 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(slideActivity, Preferences.class));
- }
- else {
- response = httpClient.execute();
- }
-
- if (response != null && response.getStatusLine().getStatusCode() == 200) {
- HttpEntity entity = response.getEntity();
-
- if (entity != null) {
- List<org.openlp.android.data.Slide> slideItemList = JSONHandler.parseSlideItemResponseJSON(entity);
- Log.d(LOG_TAG, String.format("slides: %s", slideItemList));
- return slideItemList.toArray(new org.openlp.android.data.Slide[]{});
- }
- }
- else {
- returnString = String.format("%s %s", getString(R.string.unable), response);
- }
- }
- catch (Exception ex) {
- try {
- throw new FetchItemsException(ex);
- }
- catch (FetchItemsException e) {
- Log.d(LOG_TAG, String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage()));
- returnString = String.format("%s", getString(R.string.connectionTimedout));
- }
- }
-
- if (returnString.trim().length() > 0) {
- error = returnString;
- Log.e(LOG_TAG, returnString);
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(org.openlp.android.data.Slide[] slides) {
- super.onPostExecute(slides);
- if (slides == null) {
- slides = new org.openlp.android.data.Slide[]{};
- }
- slideList.setAdapter(new SlideAdapter(context, Arrays.asList(slides)));
- 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 = 5643837655316198262L;
-
- FetchItemsException(Throwable throwable) {
- super(throwable);
- }
- }
- }
- private final String LOG_TAG = Slide.class.getName();
+ private final Activity context = this;
+ private ListView slideList;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Log.d(LOG_TAG, "onCreate");
+ setContentView(R.layout.slide);
+
+ slideList = (ListView) findViewById(R.id.list);
+
+ findViewById(R.id.prev).setOnClickListener(
+ new Button.OnClickListener() {
+ public void onClick(View v) {
+ try {
+ new WebCallAsyncTask(context)
+ .execute(LIVE_PREVIOUS);
+ }
+ catch (Exception e) {
+ Toast.makeText(
+ getApplicationContext(),
+ String.format("%s: %s", e.getClass()
+ .getSimpleName(), e.getMessage()),
+ Toast.LENGTH_SHORT).show();
+ Log.e(LOG_TAG, e.toString(), e);
+ }
+ }
+ });
+
+ findViewById(R.id.next).setOnClickListener(
+ new Button.OnClickListener() {
+ public void onClick(View v) {
+ try {
+ new WebCallAsyncTask(context).execute(LIVE_NEXT);
+ }
+ catch (Exception e) {
+ Toast.makeText(context,R.string.loadingFailed,
+ Toast.LENGTH_LONG).show();
+ Log.e(LOG_TAG, String.format("%s: %s", e.getClass()
+ .getSimpleName(), e.getMessage()), e);
+ }
+ }
+ });
+
+ slideList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view,
+ int i, long l) {
+ try {
+ String alert = JSONHandler.createRequestJSON("id",
+ Integer.toString(i));
+ new WebCallAsyncTask(context, LIVE_SET).execute(alert);
+ }
+ catch (Exception e) {
+ try {
+ throw new JSONHandler.JSONHandlerException(e);
+ }
+ catch (JSONHandler.JSONHandlerException e1) {
+ Toast.makeText(getApplicationContext(),
+ String.format("%s: %s", e1.getClass()
+ .getSimpleName(), e1.getMessage()),
+ Toast.LENGTH_LONG).show();
+ }
+ }
+ }
+ });
+
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Log.d(LOG_TAG, "Resume");
+
+ new FetchSlideItemsTask(this).execute(LIVE_TEXT);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.preferences:
+ startActivity(new Intent(this, Preferences.class));
+ return true;
+ case R.id.menuSearch:
+ onSearchRequested();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ class FetchSlideItemsTask extends
+ AsyncTask<String, Void, org.openlp.android.data.SlideItem[]> {
+ Slide slideActivity;
+ ProgressDialog progressDialog;
+ String error;
+
+ FetchSlideItemsTask(Slide slideActivity) {
+ this.slideActivity = slideActivity;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ progressDialog = ProgressDialog.show(Slide.this,
+ getString(R.string.loading),
+ getString(R.string.loadingSlideItems));
+ }
+
+ @Override
+ protected org.openlp.android.data.SlideItem[] doInBackground(
+ String... strings) {
+ OpenLPHttpClient httpClient = new OpenLPHttpClient(
+ getApplicationContext());
+ HttpResponse response = null;
+ error = "";
+
+ Log.d(LOG_TAG, "Processing:" + Arrays.asList(strings));
+ try {
+ httpClient.setUrl(strings[0]);
+ if (httpClient.getUrl().getHost().trim().length() <= 0) {
+ startActivity(new Intent(slideActivity, Preferences.class));
+ }
+ else {
+ response = httpClient.execute();
+ }
+
+ if (response != null
+ && response.getStatusLine().getStatusCode() == 200) {
+ HttpEntity entity = response.getEntity();
+
+ if (entity != null) {
+ List<org.openlp.android.data.SlideItem> slideItemList = JSONHandler
+ .parseSlideItemResponseJSON(entity);
+ Log.d(LOG_TAG,
+ String.format("slides: %s", slideItemList));
+ return slideItemList
+ .toArray(new org.openlp.android.data.SlideItem[] {});
+ }
+ }
+ else {
+ error = String.format("%s %s",
+ getString(R.string.unable), response);
+ }
+ }
+ catch (Exception ex) {
+ Log.d(LOG_TAG, String.format("%s: %s", ex.getClass()
+ .getSimpleName(), ex.getMessage()));
+ error = String.format("%s",
+ getString(R.string.connectionTimedout));
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(org.openlp.android.data.SlideItem[] slides) {
+ super.onPostExecute(slides);
+ if (slides == null) {
+ slides = new org.openlp.android.data.SlideItem[] {};
+ }
+ slideList.setAdapter(new SlideAdapter(context, Arrays
+ .asList(slides)));
+ progressDialog.dismiss();
+
+ if (error != null && error.trim().length() > 0) {
+ Toast.makeText(context,R.string.loadingFailed,
+ Toast.LENGTH_LONG).show();
+ Log.e(LOG_TAG, error);
+ }
+ }
+ }
+
+ private final String LOG_TAG = Slide.class.getName();
}
=== added file 'src/org/openlp/android/activity/StageView.java'
--- src/org/openlp/android/activity/StageView.java 1970-01-01 00:00:00 +0000
+++ src/org/openlp/android/activity/StageView.java 2012-02-06 19:37:54 +0000
@@ -0,0 +1,100 @@
+/******************************************************************************
+ * 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.activity;
+
+import org.openlp.android.R;
+import org.openlp.android.api.Api;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+
+
+public class StageView extends Activity implements Api {
+ private final Context context = this;
+
+ SharedPreferences preferences;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Log.d(LOG_TAG, "onCreate");
+ setContentView(R.layout.stageview);
+ preferences = getApplicationContext().getSharedPreferences(
+ getApplicationContext()
+ .getString(R.string.keySharedPreferences),
+ Context.MODE_PRIVATE);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ Log.d(LOG_TAG, "Resume");
+ WebView myWebView = (WebView) findViewById(R.id.stageview);
+ WebSettings webSettings = myWebView.getSettings();
+ webSettings.setJavaScriptEnabled(true);
+ webSettings.setBuiltInZoomControls(true);
+ webSettings.setLoadWithOverviewMode(true);
+ webSettings.setUseWideViewPort(true);
+ myWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
+ myWebView.setScrollbarFadingEnabled(true);
+ String urlBase = String.format("http://%s:%s/stage", preferences.getString(
+ context.getString(R.string.keyHost),
+ context.getString(R.string.hostDefaultValue)), preferences
+ .getString(context.getString(R.string.keyPort),
+ context.getString(R.string.portDefaultValue)));
+ Log.d(LOG_TAG, urlBase);
+ myWebView.loadUrl(urlBase);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ // Handle item selection
+ switch (item.getItemId()) {
+ case R.id.preferences:
+ startActivity(new Intent(this, Preferences.class));
+ return true;
+ case R.id.menuSearch:
+ onSearchRequested();
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+
+ private final String LOG_TAG = StageView.class.getName();
+}
=== modified file 'src/org/openlp/android/api/Api.java'
--- src/org/openlp/android/api/Api.java 2011-12-31 09:22:22 +0000
+++ src/org/openlp/android/api/Api.java 2012-02-06 19:37:54 +0000
@@ -25,66 +25,67 @@
/**
* <h1>Routes:</h1>
* <p/>
+ *
* <pre>
* ``/``
* Go to the web interface.
- *
+ *
* ``/files/{filename}``
- *
+ *
* ``/api/poll``
* {"results": {"type": "controller"}}
* Or, if there were no results, False::
* {"results": False}
- *
+ *
* ``/api/display/{hide|show}``
* Blank or unblank the screen.
- *
+ *
* ``/api/alert``
* {"request": {"text": "<your alert text>"}}
* ``/api/controller/{live|preview}/{action}``
* ``next``
* Load the next slide.
- *
+ *
* ``previous``
* Load the previous slide.
- *
+ *
* ``set``
* Set a specific slide. Requires an id return in a JSON-encoded dict like
* this::
- *
+ *
* {"request": {"id": 1}}
- *
+ *
* ``first``
* Load the first slide.
- *
+ *
* ``last``
* Load the last slide.
- *
+ *
* ``text``
* Fetches the text of the current song. The output is a JSON-encoded
* dict which looks like this::
- *
+ *
* {"result": {"slides": ["...", "..."]}}
- *
+ *
* ``/api/service/{action}``
* Perform ``{action}`` on the service manager (e.g. go live). Data is
* passed as a json-encoded ``data`` parameter. Valid actions are:
- *
+ *
* ``next``
* Load the next item in the service.
- *
+ *
* ``previous``
- *
+ *
* ``set``
* Set a specific item in the service. Requires an id returned in a
* JSON-encoded dict like this::
- *
+ *
* {"request": {"id": 1}}
- *
+ *
* ``list``
* Request a list of items in the service. Returns a list of items in the
* current service in a JSON-encoded dict like this::
- *
+ *
* {"results": {"items": [{...}, {...}]}}
* """
* </pre>
@@ -92,30 +93,30 @@
public interface Api {
- public final String LIVE_NEXT = "/api/controller/live/next";
- public final String LIVE_PREVIOUS = "/api/controller/live/previous";
- public final String LIVE_TEXT = "/api/controller/live/text";
- public final String LIVE_SET = "/api/controller/live/set?data=";
-
- public final String SERVICE_NEXT = "/api/service/next";
- public final String SERVICE_PREVIOUS = "/api/service/previous";
- public final String SERVICE_LIST = "/api/service/list";
- public final String SERVICE_SET = "/api/service/set?data=";
-
- public final String DISPLAY_HIDE_SCREEN = "/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=";
-
- public final String SEARCHABLE_PLUGINS = "/api/plugin/search";
- /**
- * This is a special string that uses the String.format() method.
- * See {@link String#format(String, Object...)}
- */
- public final String SEARCH_PLUGIN_FORMATTED = "/api/%s/search?data=";
- public final String SEARCH_PLUGIN_LIVE = "/api/%s/live?data=";
- public final String SEARCH_PLUGIN_ADD = "/api/%s/add?data=";
+ public final String LIVE_NEXT = "/api/controller/live/next";
+ public final String LIVE_PREVIOUS = "/api/controller/live/previous";
+ public final String LIVE_TEXT = "/api/controller/live/text";
+ public final String LIVE_SET = "/api/controller/live/set?data=";
+
+ public final String SERVICE_NEXT = "/api/service/next";
+ public final String SERVICE_PREVIOUS = "/api/service/previous";
+ public final String SERVICE_LIST = "/api/service/list";
+ public final String SERVICE_SET = "/api/service/set?data=";
+
+ public final String DISPLAY_HIDE_SCREEN = "/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=";
+
+ public final String SEARCHABLE_PLUGINS = "/api/plugin/search";
+ /**
+ * This is a special string that uses the String.format() method. See
+ * {@link String#format(String, Object...)}
+ */
+ public final String SEARCH_PLUGIN_FORMATTED = "/api/%s/search?data=";
+ public final String SEARCH_PLUGIN_LIVE = "/api/%s/live?data=";
+ public final String SEARCH_PLUGIN_ADD = "/api/%s/add?data=";
}
=== modified file 'src/org/openlp/android/data/Poll.java'
--- src/org/openlp/android/data/Poll.java 2011-12-24 15:06:31 +0000
+++ src/org/openlp/android/data/Poll.java 2012-02-06 19:37:54 +0000
@@ -23,9 +23,8 @@
package org.openlp.android.data;
-
public class Poll {
-
+
private int slide;
private String item;
private boolean twelveHourDisplay = false;;
@@ -64,7 +63,7 @@
public void setBlankedDisplayed(boolean blankedDisplayed) {
this.blankedDisplayed = blankedDisplayed;
- if (blankedDisplayed){
+ if (blankedDisplayed) {
this.displayHidden = true;
}
}
@@ -75,9 +74,9 @@
public void setThemeDisplayed(boolean themeDisplayed) {
this.themeDisplayed = themeDisplayed;
- if (themeDisplayed){
+ if (themeDisplayed) {
this.displayHidden = true;
- }
+ }
}
public boolean isDesktopDisplayed() {
@@ -86,9 +85,9 @@
public void setDesktopDisplayed(boolean desktopDisplayed) {
this.desktopDisplayed = desktopDisplayed;
- if (desktopDisplayed){
+ if (desktopDisplayed) {
this.displayHidden = true;
- }
+ }
}
public boolean isDisplayHidden() {
=== renamed file 'src/org/openlp/android/data/Slide.java' => 'src/org/openlp/android/data/SlideItem.java'
--- src/org/openlp/android/data/Slide.java 2011-12-24 15:06:31 +0000
+++ src/org/openlp/android/data/SlideItem.java 2012-02-06 19:37:54 +0000
@@ -22,51 +22,47 @@
*******************************************************************************/
package org.openlp.android.data;
-public class Slide {
- private String text;
- private boolean selected;
- private String tag;
- private String html;
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public boolean isSelected() {
- return selected;
- }
-
- public void setSelected(boolean selected) {
- this.selected = selected;
- }
-
- public String getTag() {
- return tag;
- }
-
- public void setTag(String tag) {
- this.tag = tag;
- }
-
- public String getHtml() {
- return html;
- }
-
- public void setHtml(String html) {
- this.html = html;
- }
-
- @Override
- public String toString() {
- return "SlidePOJO{" +
- "text='" + text + '\'' +
- ", selected=" + selected +
- ", tag='" + tag + '\'' +
- ", html='" + html + '\'' +
- '}';
- }
+public class SlideItem {
+ private String text;
+ private boolean selected;
+ private String tag;
+ private String html;
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public boolean isSelected() {
+ return selected;
+ }
+
+ public void setSelected(boolean selected) {
+ this.selected = selected;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ public String getHtml() {
+ return html;
+ }
+
+ public void setHtml(String html) {
+ this.html = html;
+ }
+
+ @Override
+ public String toString() {
+ return "SlidePOJO{" + "text='" + text + '\'' + ", selected=" + selected
+ + ", tag='" + tag + '\'' + ", html='" + html + '\'' + '}';
+ }
}
=== modified file 'src/org/openlp/android/service/PingService.java'
--- src/org/openlp/android/service/PingService.java 2011-06-07 20:39:33 +0000
+++ src/org/openlp/android/service/PingService.java 2012-02-06 19:37:54 +0000
@@ -1,16 +1,38 @@
+/******************************************************************************
+ * 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.service;
import android.os.Bundle;
import org.openlp.android.activity.Service;
public class PingService extends Service {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
- @Override
- protected void onResume() {
- super.onResume();
- }
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
}
=== modified file 'src/org/openlp/android/utility/GroupExpandableListAdapter.java'
--- src/org/openlp/android/utility/GroupExpandableListAdapter.java 2011-12-24 15:06:31 +0000
+++ src/org/openlp/android/utility/GroupExpandableListAdapter.java 2012-02-06 19:37:54 +0000
@@ -36,89 +36,92 @@
import java.util.Map;
public class GroupExpandableListAdapter extends BaseExpandableListAdapter {
- List<String> groups;
- List<List<Map<String, JSONArray>>> children;
- LayoutInflater inflater;
- Activity context;
-
- public GroupExpandableListAdapter(Activity context, List<String> groups,
- List<List<Map<String, JSONArray>>> children) {
- this.context = context;
- this.groups = groups;
- this.children = children;
- inflater = context.getLayoutInflater();
- }
-
- @Override
- public int getGroupCount() {
- return groups.size();
- }
-
- @Override
- public int getChildrenCount(int position) {
- return children.get(position).size();
- }
-
- @Override
- public Object getGroup(int position) {
- return groups.get(position);
- }
-
- @Override
- public Object getChild(int rootPosition, int childPosition) {
- return children.get(rootPosition).get(childPosition);
- }
-
- @Override
- public long getGroupId(int position) {
- return groups.indexOf(groups.get(position));
- }
-
- @Override
- public long getChildId(int i, int i1) {
- List<Map<String, JSONArray>> child = children.get(i);
- return child.indexOf(child.get(i1));
- }
-
- @Override
- public boolean hasStableIds() {
- return false;
- }
-
- @Override
- public View getGroupView(int position, boolean b, View view, ViewGroup viewGroup) {
- if (view == null) {
- view = inflater.inflate(R.layout.group_parent, null);
- view.setClickable(false);
- }
- TextView textView = (TextView) view.findViewById(R.id.groupParentText);
- TextView numberView = (TextView) view.findViewById(R.id.parentChildCount);
- numberView.setText(String.format("%s", children.get(position).size()));
- textView.setText(groups.get(position));
- return view;
- }
-
- @Override
- public View getChildView(int groupPosition, int childPosition, boolean b, View view, ViewGroup viewGroup) {
- if (view == null) {
- view = inflater.inflate(R.layout.group_child, null);
- view.setClickable(false);
- }
- TextView childView = (TextView) view.findViewById(R.id.groupChildText);
- List<Map<String, JSONArray>> childItem = children.get(groupPosition);
- Map<String, JSONArray> mapItem = childItem.get(childPosition);
- JSONArray jsonItem = mapItem.get(groups.get(groupPosition));
- try {
- childView.setText(String.format("%s", jsonItem.get(1)));
- }
- catch (JSONException e) {
- e.printStackTrace();
- }
- return view;
- }
-
- @Override
- public boolean isChildSelectable(int i, int i1) {
- return true;
- }
+ List<String> groups;
+ List<List<Map<String, JSONArray>>> children;
+ LayoutInflater inflater;
+ Activity context;
+
+ public GroupExpandableListAdapter(Activity context, List<String> groups,
+ List<List<Map<String, JSONArray>>> children) {
+ this.context = context;
+ this.groups = groups;
+ this.children = children;
+ inflater = context.getLayoutInflater();
+ }
+
+ @Override
+ public int getGroupCount() {
+ return groups.size();
+ }
+
+ @Override
+ public int getChildrenCount(int position) {
+ return children.get(position).size();
+ }
+
+ @Override
+ public Object getGroup(int position) {
+ return groups.get(position);
+ }
+
+ @Override
+ public Object getChild(int rootPosition, int childPosition) {
+ return children.get(rootPosition).get(childPosition);
+ }
+
+ @Override
+ public long getGroupId(int position) {
+ return groups.indexOf(groups.get(position));
+ }
+
+ @Override
+ public long getChildId(int i, int i1) {
+ List<Map<String, JSONArray>> child = children.get(i);
+ return child.indexOf(child.get(i1));
+ }
+
+ @Override
+ public boolean hasStableIds() {
+ return false;
+ }
+
+ @Override
+ public View getGroupView(int position, boolean b, View view,
+ ViewGroup viewGroup) {
+ if (view == null) {
+ view = inflater.inflate(R.layout.group_parent, null);
+ view.setClickable(false);
+ }
+ TextView textView = (TextView) view.findViewById(R.id.groupParentText);
+ TextView numberView = (TextView) view
+ .findViewById(R.id.parentChildCount);
+ numberView.setText(String.format("%s", children.get(position).size()));
+ textView.setText(groups.get(position));
+ return view;
+ }
+
+ @Override
+ public View getChildView(int groupPosition, int childPosition, boolean b,
+ View view, ViewGroup viewGroup) {
+ if (view == null) {
+ view = inflater.inflate(R.layout.group_child, null);
+ view.setClickable(false);
+ }
+ TextView childView = (TextView) view.findViewById(R.id.groupChildText);
+ List<Map<String, JSONArray>> childItem = children.get(groupPosition);
+ Map<String, JSONArray> mapItem = childItem.get(childPosition);
+ JSONArray jsonItem = mapItem.get(groups.get(groupPosition));
+ try {
+ childView.setText(String.format("%s", jsonItem.get(1)));
+ }
+ catch (JSONException e) {
+ e.printStackTrace();
+ }
+ return view;
+ }
+
+ @Override
+ public boolean isChildSelectable(int i, int i1) {
+ return true;
+ }
}
=== modified file 'src/org/openlp/android/utility/JSONHandler.java'
--- src/org/openlp/android/utility/JSONHandler.java 2011-12-24 15:06:31 +0000
+++ src/org/openlp/android/utility/JSONHandler.java 2012-02-06 19:37:54 +0000
@@ -29,7 +29,7 @@
import org.json.JSONObject;
import org.json.JSONStringer;
import org.openlp.android.data.Poll;
-import org.openlp.android.data.Slide;
+import org.openlp.android.data.SlideItem;
import java.io.IOException;
import java.io.InputStream;
@@ -40,125 +40,131 @@
public class JSONHandler {
- public static String createRequestJSON(String key, String value) throws JSONHandlerException {
- try {
- String responseJSON;
- JSONObject jo = new JSONObject();
- jo.put(key, value);
- responseJSON = new JSONStringer().object().key("request").value(jo).endObject().toString();
- responseJSON = URLEncoder.encode(responseJSON, "UTF-8");
- return responseJSON;
- }
- catch (JSONException e) {
- throw new JSONHandlerException(e);
- }
- catch (UnsupportedEncodingException e) {
- throw new JSONHandlerException(e);
- }
- }
-
- public static List<Slide> parseServiceItemResponseJSON(HttpEntity entity) throws JSONHandlerException {
- try {
- List<Slide> serviceItemList = new ArrayList<Slide>();
- 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("items");
-
- for (int i = 0; i < items.length(); i++) {
- JSONObject item = items.getJSONObject(i);
- Slide slide = new Slide();
- slide.setTag("");
- slide.setText(item.getString("title"));
- slide.setSelected(item.getBoolean("selected"));
- slide.setHtml("");
- serviceItemList.add(slide);
- }
-
- inputStream.close();
- return serviceItemList;
- }
- catch (IOException e) {
- throw new JSONHandlerException(e);
- }
- catch (JSONException e) {
- throw new JSONHandlerException(e);
- }
-
- }
-
- public static List<Slide> parseSlideItemResponseJSON(HttpEntity entity) throws JSONHandlerException {
- try {
- List<Slide> serviceItemList = new ArrayList<Slide>();
- 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");
-
- for (int i = 0; i < items.length(); i++) {
- JSONObject item = items.getJSONObject(i);
- Slide slide = new Slide();
- slide.setText(item.getString("text"));
- slide.setTag(item.getString("tag"));
- slide.setSelected(item.getBoolean("selected"));
- slide.setHtml(item.getString("html"));
- serviceItemList.add(slide);
- }
-
- inputStream.close();
- return serviceItemList;
- }
- catch (IOException e) {
- throw new JSONHandlerException(e);
- }
- 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 static String createRequestJSON(String key, String value)
+ throws JSONHandlerException {
+ try {
+ String responseJSON;
+ JSONObject jo = new JSONObject();
+ jo.put(key, value);
+ responseJSON = new JSONStringer().object().key("request").value(jo)
+ .endObject().toString();
+ responseJSON = URLEncoder.encode(responseJSON, "UTF-8");
+ return responseJSON;
+ }
+ catch (JSONException e) {
+ throw new JSONHandlerException(e);
+ }
+ catch (UnsupportedEncodingException e) {
+ throw new JSONHandlerException(e);
+ }
+ }
+
+ public static List<SlideItem> parseServiceItemResponseJSON(HttpEntity entity)
+ throws JSONHandlerException {
+ try {
+ List<SlideItem> serviceItemList = new ArrayList<SlideItem>();
+ 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("items");
+
+ for (int i = 0; i < items.length(); i++) {
+ JSONObject item = items.getJSONObject(i);
+ SlideItem slide = new SlideItem();
+ slide.setTag("");
+ slide.setText(item.getString("title"));
+ slide.setSelected(item.getBoolean("selected"));
+ slide.setHtml("");
+ serviceItemList.add(slide);
+ }
+
+ inputStream.close();
+ return serviceItemList;
+ }
+ catch (IOException e) {
+ throw new JSONHandlerException(e);
+ }
+ catch (JSONException e) {
+ throw new JSONHandlerException(e);
+ }
+
+ }
+
+ public static List<SlideItem> parseSlideItemResponseJSON(HttpEntity entity)
+ throws JSONHandlerException {
+ try {
+ List<SlideItem> serviceItemList = new ArrayList<SlideItem>();
+ 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");
+
+ for (int i = 0; i < items.length(); i++) {
+ JSONObject item = items.getJSONObject(i);
+ SlideItem slide = new SlideItem();
+ slide.setText(item.getString("text"));
+ slide.setTag(item.getString("tag"));
+ slide.setSelected(item.getBoolean("selected"));
+ slide.setHtml(item.getString("html"));
+ serviceItemList.add(slide);
+ }
+
+ inputStream.close();
+ return serviceItemList;
+ }
+ catch (IOException e) {
+ throw new JSONHandlerException(e);
+ }
+ 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 {
+ /**
*
*/
private static final long serialVersionUID = -6772307308404816615L;
public JSONHandlerException(Throwable throwable) {
- super(throwable);
- }
- }
- private static String LOG_TAG = JSONHandler.class.getName();
+ 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-12-24 15:06:31 +0000
+++ src/org/openlp/android/utility/OpenLPHttpClient.java 2012-02-06 19:37:54 +0000
@@ -39,56 +39,71 @@
import java.net.URL;
/**
- * Personalised HttpClient to be used throughout OpenLP with customisable parameters.
+ * Personalised HttpClient to be used throughout OpenLP with customisable
+ * parameters.
*/
public class OpenLPHttpClient extends DefaultHttpClient {
- private HttpGet httpGet;
- private URL url;
- private final String urlBase;
-
- public OpenLPHttpClient(Context context) {
- SharedPreferences preferences = context.getSharedPreferences(context
- .getString(R.string.keySharedPreferences), Context.MODE_PRIVATE);
-
- Log.d(LOG_TAG, preferences.getAll().toString());
- HttpParams httpParams = new BasicHttpParams();
-
- urlBase = String.format("http://%s:%s",
- preferences.getString(context.getString(R.string.keyHost), context.getString(R.string.hostDefaultValue)),
- preferences.getString(context.getString(R.string.keyPort), context.getString(R.string.portDefaultValue)));
-
- int connectionTimeout = context.getResources().getInteger(R.integer.connectionTimeoutDefaultValue);
- int socketTimeout = context.getResources().getInteger(R.integer.socketTimeoutDefaultValue);
-
- if (preferences.getBoolean(context.getString(R.string.keyEnableCustomTimeout), false)) {
- Log.d(LOG_TAG, String.format("Retrieving values for %s and %s...", context
- .getString(R.string.keyConnectionTimeout), context.getString(R.string.keySocketTimeout)));
- connectionTimeout = Integer.parseInt(preferences.getString(context.getString(R.string.keyConnectionTimeout),
- String.valueOf(context.getResources().getInteger(R.integer.connectionTimeoutDefaultValue))));
- socketTimeout = Integer.parseInt(preferences.getString(context.getString(R.string.keySocketTimeout),
- String.valueOf(context.getResources().getInteger(R.integer.socketTimeoutDefaultValue))));
- }
- HttpConnectionParams.setConnectionTimeout(httpParams, connectionTimeout);
- HttpConnectionParams.setSoTimeout(httpParams, socketTimeout);
-
- setParams(httpParams);
-
- httpGet = new HttpGet();
- }
-
- public URL getUrl() {
- return url;
- }
-
- public void setUrl(String apiPart) throws URISyntaxException, MalformedURLException {
- url = new URL(urlBase.concat(apiPart));
- Log.d(LOG_TAG, "URL set to: " + url);
- httpGet.setURI(getUrl().toURI());
- }
-
- public HttpResponse execute() throws IOException {
- return super.execute(httpGet);
- }
- private final String LOG_TAG = OpenLPHttpClient.class.getName();
+ private HttpGet httpGet;
+ private URL url;
+ private final String urlBase;
+
+ public OpenLPHttpClient(Context context) {
+ SharedPreferences preferences = context.getSharedPreferences(
+ context.getString(R.string.keySharedPreferences),
+ Context.MODE_PRIVATE);
+
+ Log.d(LOG_TAG, preferences.getAll().toString());
+ HttpParams httpParams = new BasicHttpParams();
+
+ urlBase = String.format("http://%s:%s", preferences.getString(
+ context.getString(R.string.keyHost),
+ context.getString(R.string.hostDefaultValue)), preferences
+ .getString(context.getString(R.string.keyPort),
+ context.getString(R.string.portDefaultValue)));
+
+ int connectionTimeout = context.getResources().getInteger(
+ R.integer.connectionTimeoutDefaultValue);
+ int socketTimeout = context.getResources().getInteger(
+ R.integer.socketTimeoutDefaultValue);
+
+ if (preferences.getBoolean(
+ context.getString(R.string.keyEnableCustomTimeout), false)) {
+ Log.d(LOG_TAG, String.format("Retrieving values for %s and %s...",
+ context.getString(R.string.keyConnectionTimeout),
+ context.getString(R.string.keySocketTimeout)));
+ connectionTimeout = Integer.parseInt(preferences.getString(
+ context.getString(R.string.keyConnectionTimeout),
+ String.valueOf(context.getResources().getInteger(
+ R.integer.connectionTimeoutDefaultValue))));
+ socketTimeout = Integer.parseInt(preferences.getString(
+ context.getString(R.string.keySocketTimeout),
+ String.valueOf(context.getResources().getInteger(
+ R.integer.socketTimeoutDefaultValue))));
+ }
+ HttpConnectionParams
+ .setConnectionTimeout(httpParams, connectionTimeout);
+ HttpConnectionParams.setSoTimeout(httpParams, socketTimeout);
+
+ setParams(httpParams);
+
+ httpGet = new HttpGet();
+ }
+
+ public URL getUrl() {
+ return url;
+ }
+
+ public void setUrl(String apiPart) throws URISyntaxException,
+ MalformedURLException {
+ url = new URL(urlBase.concat(apiPart));
+ Log.d(LOG_TAG, "URL set to: " + url);
+ httpGet.setURI(getUrl().toURI());
+ }
+
+ 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-12-24 15:06:31 +0000
+++ src/org/openlp/android/utility/SlideAdapter.java 2012-02-06 19:37:54 +0000
@@ -22,82 +22,113 @@
*******************************************************************************/
package org.openlp.android.utility;
+import java.util.List;
+
+import org.openlp.android.R;
+import org.openlp.android.data.SlideItem;
+
import android.app.Activity;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
-import org.openlp.android.R;
-import org.openlp.android.data.Slide;
-
-import java.util.List;
public class SlideAdapter extends BaseAdapter {
- List<Slide> items;
- Activity context;
- LayoutInflater inflater;
- boolean useTagDisplay = true;
-
- public SlideAdapter(Activity context, List<Slide> items) {
- this.context = context;
- this.items = items;
- inflater = context.getLayoutInflater();
- }
-
- public SlideAdapter(Activity context, List<Slide> items, boolean useTagDisplay) {
- this.context = context;
- this.items = items;
- this.useTagDisplay = useTagDisplay;
- inflater = context.getLayoutInflater();
- }
-
- @Override
- public int getCount() {
- return items.size();
- }
-
- @Override
- public Object getItem(int i) {
- return items.get(i);
- }
-
- @Override
- public long getItemId(int i) {
- return items.indexOf(items.get(i));
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- ViewHolder holder;
- View view = convertView;
-
- Slide item = items.get(position);
-
- if (view == null) {
- view = inflater.inflate(R.layout.slide_list_item, null);
- holder = new ViewHolder();
-
- holder.rowMarker = (TextView) view.findViewById(R.id.rowItemMarker);
- holder.rowItem = (TextView) view.findViewById(R.id.rowItemText);
-
- view.setTag(holder);
- }
- else {
- holder = (ViewHolder) view.getTag();
- }
-
- holder.rowMarker.setText(item.getTag());
- holder.rowItem.setText(item.getText());
-
- if (useTagDisplay) {
- holder.rowMarker.setMinWidth(40);
- }
- return view;
- }
-
- static class ViewHolder {
- TextView rowMarker;
- TextView rowItem;
- }
+ List<SlideItem> items;
+ Activity context;
+ LayoutInflater inflater;
+ boolean useTagDisplay = true;
+ private int[] colors = new int[] { 0x74717000, 0x00000000 };
+ SharedPreferences prefs;
+
+ public SlideAdapter(Activity context, List<SlideItem> items) {
+ this.context = context;
+ this.items = items;
+ inflater = context.getLayoutInflater();
+
+ prefs = context.getSharedPreferences(
+ context.getString(R.string.keySharedPreferences),
+ Context.MODE_PRIVATE);
+
+
+ Log.d(LOG_TAG, "xx2 " + prefs.getAll().toString());
+ }
+
+ public SlideAdapter(Activity context, List<SlideItem> items,
+ boolean useTagDisplay) {
+ this.context = context;
+ this.items = items;
+ this.useTagDisplay = useTagDisplay;
+ inflater = context.getLayoutInflater();
+
+ prefs = context.getSharedPreferences(
+ context.getString(R.string.keySharedPreferences),
+ Context.MODE_PRIVATE);
+ }
+
+ @Override
+ public int getCount() {
+ return items.size();
+ }
+
+ @Override
+ public Object getItem(int i) {
+ return items.get(i);
+ }
+
+ @Override
+ public long getItemId(int i) {
+ return items.indexOf(items.get(i));
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder holder;
+ View view = convertView;
+
+ SlideItem item = items.get(position);
+
+ if (view == null) {
+ view = inflater.inflate(R.layout.slide_list_item, null);
+ holder = new ViewHolder();
+
+ holder.rowMarker = (TextView) view.findViewById(R.id.rowItemMarker);
+ holder.rowItem = (TextView) view.findViewById(R.id.rowItemText);
+
+ view.setTag(holder);
+ }
+ else {
+ holder = (ViewHolder) view.getTag();
+ }
+
+ Log.d(LOG_TAG," " + context.getString(R.string.keyTextSize));
+
+ int size = Integer.parseInt(prefs.getString(
+ context.getString(R.string.keyTextSize),
+ String.valueOf(context.getResources().getInteger(
+ R.integer.textSizeDefaultValue))));
+
+ holder.rowMarker.setText(item.getTag());
+ holder.rowItem.setText(item.getText());
+ holder.rowItem.setTextSize(size);
+
+ if (useTagDisplay) {
+ holder.rowMarker.setMinWidth(40);
+ }
+
+ int colorPos = position % colors.length;
+ view.setBackgroundColor(colors[colorPos]);
+
+ return view;
+ }
+
+ static class ViewHolder {
+ TextView rowMarker;
+ TextView rowItem;
+ }
+ private final String LOG_TAG = SlideAdapter.class.getName();
}
=== modified file 'src/org/openlp/android/utility/StringHelper.java'
--- src/org/openlp/android/utility/StringHelper.java 2011-12-24 15:06:31 +0000
+++ src/org/openlp/android/utility/StringHelper.java 2012-02-06 19:37:54 +0000
@@ -31,35 +31,34 @@
* String helper utility to do common string processing.
*/
public class StringHelper {
- public synchronized static String convertStreamToString(InputStream is) {
- /*
- To convert the InputStream to String we use the
- BufferedReader.readLine() method. We iterate until the BufferedReader
- return null which means there's no more data to read. Each line will
- appended to a StringBuilder and returned as String.
- */
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- StringBuilder sb = new StringBuilder();
-
- String line = null;
- try {
- while ((line = reader.readLine()) != null) {
- sb.append(line + "\n");
- }
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- finally {
- try {
- is.close();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
- return sb.toString();
- }
+ public synchronized static String convertStreamToString(InputStream is) {
+ /*
+ * To convert the InputStream to String we use the
+ * BufferedReader.readLine() method. We iterate until the BufferedReader
+ * return null which means there's no more data to read. Each line will
+ * appended to a StringBuilder and returned as String.
+ */
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ StringBuilder sb = new StringBuilder();
+
+ String line = null;
+ try {
+ while ((line = reader.readLine()) != null) {
+ sb.append(line + "\n");
+ }
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ is.close();
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return sb.toString();
+ }
}
=== modified file 'src/org/openlp/android/utility/WebCallAsyncTask.java'
--- src/org/openlp/android/utility/WebCallAsyncTask.java 2011-12-24 15:06:31 +0000
+++ src/org/openlp/android/utility/WebCallAsyncTask.java 2012-02-06 19:37:54 +0000
@@ -33,56 +33,60 @@
* Call URL's using this task, which provides visual feedback.
*/
public class WebCallAsyncTask extends AsyncTask<String, Void, Void> {
- private Context context;
- private ProgressDialog progressDialog;
- private String error;
- private String apiPart;
-
- public WebCallAsyncTask(Context context) {
- this.context = context;
- }
-
- public WebCallAsyncTask(Context context, String apiPart) {
- this.context = context;
- this.apiPart = apiPart;
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- progressDialog = ProgressDialog.show(context, "", context.getString(R.string.loading));
- }
-
- @Override
- protected Void doInBackground(String... apiCall) {
- OpenLPHttpClient httpClient = new OpenLPHttpClient(context);
- try {
- if (apiPart == null) {
- httpClient.setUrl(apiCall[0]);
- }
- else {
- httpClient.setUrl(String.format("%s%s", apiPart, apiCall[0]));
- }
-
- Log.d(LOG_TAG, "Executing request: " + httpClient.getUrl().toString());
- if (httpClient.getUrl().getHost() != null) {
- httpClient.execute();
- }
- }
- catch (Exception e) {
- Log.e(LOG_TAG, e.toString());
- error = String.format("%s: %s", e.getClass().getSimpleName(), e.getMessage());
- }
- return null;
- }
-
- @Override
- protected void onPostExecute(Void aVoid) {
- super.onPostExecute(aVoid);
- progressDialog.dismiss();
- if (error != null && error.trim().length() > 0) {
- Toast.makeText(context, error, Toast.LENGTH_LONG).show();
- }
- }
- private final String LOG_TAG = WebCallAsyncTask.class.getName();
+ private Context context;
+ private ProgressDialog progressDialog;
+ private String error;
+ private String apiPart;
+
+ public WebCallAsyncTask(Context context) {
+ this.context = context;
+ }
+
+ public WebCallAsyncTask(Context context, String apiPart) {
+ this.context = context;
+ this.apiPart = apiPart;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ progressDialog = ProgressDialog.show(context, "",
+ context.getString(R.string.loading));
+ }
+
+ @Override
+ protected Void doInBackground(String... apiCall) {
+ OpenLPHttpClient httpClient = new OpenLPHttpClient(context);
+ try {
+ if (apiPart == null) {
+ httpClient.setUrl(apiCall[0]);
+ }
+ else {
+ httpClient.setUrl(String.format("%s%s", apiPart, apiCall[0]));
+ }
+
+ Log.d(LOG_TAG, "Executing request: "
+ + httpClient.getUrl().toString());
+ if (httpClient.getUrl().getHost() != null) {
+ httpClient.execute();
+ }
+ }
+ catch (Exception e) {
+ Log.e(LOG_TAG, e.toString());
+ error = String.format("%s: %s", e.getClass().getSimpleName(),
+ e.getMessage());
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(Void aVoid) {
+ super.onPostExecute(aVoid);
+ progressDialog.dismiss();
+ if (error != null && error.trim().length() > 0) {
+ 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-12-24 15:06:31 +0000
+++ src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2012-02-06 19:37:54 +0000
@@ -35,74 +35,77 @@
import java.io.InputStreamReader;
public class WebCallReturningAsyncTask extends AsyncTask<String, Void, String> {
- private Activity context;
- private String apiPart;
-
-
- public WebCallReturningAsyncTask(Activity context) {
- this.context = context;
- }
-
- public WebCallReturningAsyncTask(Activity context, String apiPart) {
- this.context = context;
- this.apiPart = apiPart;
- }
-
-
- @Override
- protected String doInBackground(String... apiCall) {
- OpenLPHttpClient httpClient = new OpenLPHttpClient(context);
- HttpResponse response = null;
-
- try {
- if (apiPart == null) {
- httpClient.setUrl(apiCall[0]);
- }
- else {
- httpClient.setUrl(String.format("%s%s", apiPart, apiCall[0]));
- }
-
- if (httpClient.getUrl().getHost().trim().length() <= 0) {
- context.startActivity(new Intent(context, Preferences.class));
- }
- else {
- response = httpClient.execute();
- }
-
- if (response != null && response.getStatusLine().getStatusCode() == 200) {
- HttpEntity entity = response.getEntity();
-
- if (entity != null) {
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent()));
- StringBuilder stringBuilder = new StringBuilder();
-
- String line = bufferedReader.readLine();
- while (line != null) {
- stringBuilder.append(line);
- line = bufferedReader.readLine();
- }
-
- Log.i(LOG_TAG, String.format("entity: %s", stringBuilder.toString()));
- bufferedReader.close();
- return stringBuilder.toString();
- }
- }
- }
- catch (Exception e) {
- Log.e(LOG_TAG, e.toString());
- Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
- }
- return null;
- }
-
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- }
-
- @Override
- protected void onPostExecute(String s) {
- super.onPostExecute(s);
- }
- private final String LOG_TAG = this.getClass().getName();
+ private Activity context;
+ private String apiPart;
+
+ public WebCallReturningAsyncTask(Activity context) {
+ this.context = context;
+ }
+
+ public WebCallReturningAsyncTask(Activity context, String apiPart) {
+ this.context = context;
+ this.apiPart = apiPart;
+ }
+
+ @Override
+ protected String doInBackground(String... apiCall) {
+ OpenLPHttpClient httpClient = new OpenLPHttpClient(context);
+ HttpResponse response = null;
+
+ try {
+ if (apiPart == null) {
+ httpClient.setUrl(apiCall[0]);
+ }
+ else {
+ httpClient.setUrl(String.format("%s%s", apiPart, apiCall[0]));
+ }
+
+ if (httpClient.getUrl().getHost().trim().length() <= 0) {
+ context.startActivity(new Intent(context, Preferences.class));
+ }
+ else {
+ response = httpClient.execute();
+ }
+
+ if (response != null
+ && response.getStatusLine().getStatusCode() == 200) {
+ HttpEntity entity = response.getEntity();
+
+ if (entity != null) {
+ BufferedReader bufferedReader = new BufferedReader(
+ new InputStreamReader(entity.getContent()));
+ StringBuilder stringBuilder = new StringBuilder();
+
+ String line = bufferedReader.readLine();
+ while (line != null) {
+ stringBuilder.append(line);
+ line = bufferedReader.readLine();
+ }
+
+ Log.i(LOG_TAG,
+ String.format("entity: %s",
+ stringBuilder.toString()));
+ bufferedReader.close();
+ return stringBuilder.toString();
+ }
+ }
+ }
+ catch (Exception e) {
+ Log.e(LOG_TAG, e.toString());
+ Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ }
+
+ @Override
+ protected void onPostExecute(String s) {
+ super.onPostExecute(s);
+ }
+
+ private final String LOG_TAG = this.getClass().getName();
}
Follow ups