← Back to team overview

openlp-android team mailing list archive

[Merge] lp:~trb143/openlp/android-fixes into lp:openlp/android

 

Tim Bentley has proposed merging lp:~trb143/openlp/android-fixes into lp:openlp/android.

Requested reviews:
  OpenLP Android Developers (openlp-android)

For more details, see:
https://code.launchpad.net/~trb143/openlp/android-fixes/+merge/74906
-- 
https://code.launchpad.net/~trb143/openlp/android-fixes/+merge/74906
Your team OpenLP Android Developers is requested to review the proposed merge of lp:~trb143/openlp/android-fixes into lp:openlp/android.
=== modified file 'AndroidManifest.xml'
--- AndroidManifest.xml	2011-05-27 19:46:14 +0000
+++ AndroidManifest.xml	2011-09-11 11:57:25 +0000
@@ -1,9 +1,11 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest
         xmlns:android="http://schemas.android.com/apk/res/android";
+		android:installLocation="auto"
         package="org.openlp.android"
         android:versionCode="1"
-        android:versionName="0.1">
+        android:versionName="0.1"
+        >
     <uses-sdk android:minSdkVersion="7"/>
     <uses-permission android:name="android.permission.INTERNET"/>
 

=== modified file 'OpenLP.apk'
Binary files OpenLP.apk	2011-05-27 19:46:14 +0000 and OpenLP.apk	2011-09-11 11:57:25 +0000 differ
=== added file 'build.properties'
--- build.properties	1970-01-01 00:00:00 +0000
+++ build.properties	2011-09-11 11:57:25 +0000
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+#  'source.dir' for the location of your java source folder and
+#  'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+#  'key.store' for the location of your keystore and
+#  'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+

=== added file 'build.xml'
--- build.xml	1970-01-01 00:00:00 +0000
+++ build.xml	2011-09-11 11:57:25 +0000
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="OpenLP" default="help">
+
+<!-- The local.properties file is created and updated by the 'android'
+     tool.
+     It contains the path to the SDK. It should *NOT* be checked into
+     Version Control Systems. -->
+    <property file="local.properties" />
+
+    <!-- The build.properties file can be created by you and is never touched
+         by the 'android' tool. This is the place to change some of the
+         default property values used by the Ant rules.
+         Here are some properties you may want to change/update:
+
+         source.dir
+             The name of the source directory. Default is 'src'.
+         out.dir
+             The name of the output directory. Default is 'bin'.
+
+         Properties related to the SDK location or the project target should
+         be updated using the 'android' tool with the 'update' action.
+
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems.
+
+         -->
+    <property file="build.properties" />
+
+    <!-- The default.properties file is created and updated by the 'android'
+         tool, as well as ADT.
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems. -->
+    <property file="default.properties" />
+
+
+    <!-- Required pre-setup import -->
+    <import file="${sdk.dir}/tools/ant/pre_setup.xml" />
+
+
+<!-- extension targets. Uncomment the ones where you want to do custom work
+     in between standard targets -->
+<!--
+    <target name="-pre-build">
+    </target>
+    <target name="-pre-compile">
+    </target>
+
+    [This is typically used for code obfuscation.
+     Compiled code location: ${out.classes.absolute.dir}
+     If this is not done in place, override ${out.dex.input.absolute.dir}]
+    <target name="-post-compile">
+    </target>
+-->
+
+    <!-- Execute the Android Setup task that will setup some properties
+         specific to the target, and import the build rules files.
+
+         The rules file is imported from
+            <SDK>/tools/ant/
+         Depending on the project type it can be either:
+         - main_rules.xml
+         - lib_rules.xml
+         - test_rules.xml
+
+         To customize existing targets, there are two options:
+         - Customize only one target:
+             - copy/paste the target into this file, *before* the
+               <setup> task.
+             - customize it to your needs.
+         - Customize the whole script.
+             - copy/paste the content of the rules files (minus the top node)
+               into this file, *after* the <setup> task
+             - disable the import of the rules by changing the setup task
+               below to <setup import="false" />.
+             - customize to your needs.
+    -->
+    <setup />
+
+</project>

=== modified file 'default.properties'
--- default.properties	2011-05-02 21:10:36 +0000
+++ default.properties	2011-09-11 11:57:25 +0000
@@ -8,4 +8,4 @@
 # project structure.
 
 # Project target.
-target=android-7
+target=android-8

=== added directory 'libs'
=== added file 'local.properties'
--- local.properties	1970-01-01 00:00:00 +0000
+++ local.properties	2011-09-11 11:57:25 +0000
@@ -0,0 +1,10 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked in Version Control Systems,
+# as it contains information specific to your local configuration.
+
+# location of the SDK. This is only used by Ant
+# For customization when using a Version Control System, please read the
+# header note.
+sdk.dir=/home/johan/android-sdk

=== modified file 'src/org/openlp/android/OpenLP.java'
--- src/org/openlp/android/OpenLP.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/OpenLP.java	2011-09-11 11:57:25 +0000
@@ -28,6 +28,8 @@
 import android.os.Bundle;
 import android.util.Log;
 import android.widget.TabHost;
+import org.openlp.R;
+
 import org.openlp.android.activity.Misc;
 import org.openlp.android.activity.Preferences;
 import org.openlp.android.activity.Service;

=== modified file 'src/org/openlp/android/activity/Misc.java'
--- src/org/openlp/android/activity/Misc.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/activity/Misc.java	2011-09-11 11:57:25 +0000
@@ -35,7 +35,7 @@
 import android.widget.EditText;
 import android.widget.Toast;
 import android.widget.ToggleButton;
-import org.openlp.android.R;
+import org.openlp.R;
 import org.openlp.android.api.Api;
 import org.openlp.android.utility.JSONHandler;
 import org.openlp.android.utility.WebCallAsyncTask;
@@ -112,6 +112,9 @@
             case R.id.preferences:
                 startActivity(new Intent(this, Preferences.class));
                 return true;
+            case R.id.menuSearch:
+                onSearchRequested();
+                return true;
             default:
                 return super.onOptionsItemSelected(item);
         }

=== modified file 'src/org/openlp/android/activity/Preferences.java'
--- src/org/openlp/android/activity/Preferences.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/activity/Preferences.java	2011-09-11 11:57:25 +0000
@@ -25,7 +25,7 @@
 import android.os.Bundle;
 import android.preference.PreferenceActivity;
 import android.util.Log;
-import org.openlp.android.R;
+import org.openlp.R;
 
 /**
  * Credits:

=== modified file 'src/org/openlp/android/activity/SearchableActivity.java'
--- src/org/openlp/android/activity/SearchableActivity.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/activity/SearchableActivity.java	2011-09-11 11:57:25 +0000
@@ -23,31 +23,39 @@
 package org.openlp.android.activity;
 
 import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
 import android.app.ProgressDialog;
 import android.app.SearchManager;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.os.AsyncTask;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.View;
 import android.widget.ExpandableListView;
 import android.widget.Toast;
 import org.json.JSONArray;
+import org.json.JSONException;
 import org.json.JSONObject;
-import org.openlp.android.R;
+import org.openlp.R;
 import org.openlp.android.api.Api;
 import org.openlp.android.utility.GroupExpandableListAdapter;
 import org.openlp.android.utility.JSONHandler;
 import org.openlp.android.utility.WebCallAsyncTask;
 import org.openlp.android.utility.WebCallReturningAsyncTask;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 public class SearchableActivity extends Activity implements Api {
+    private final String LOG_TAG = this.getClass().getSimpleName();
     private Activity context;
     private ExpandableListView listView;
+    private final int DIALOG_ITEM_OPTIONS = 0;
+    private Object dialogKey;
+    private JSONArray dialogValue;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -63,16 +71,11 @@
                                         int childPosition, long l) {
                 Map<String, JSONArray> child = (Map<String, JSONArray>) listView.getExpandableListAdapter()
                         .getChild(parent, childPosition);
-                Object key = listView.getExpandableListAdapter().getGroup(parent);
-                JSONArray value = child.get(key.toString());
-
-                try {
-                    new WebCallAsyncTask(context, String.format(SEARCH_PLUGIN_LIVE, key))
-                            .execute(JSONHandler.createRequestJSON("id", value.get(0).toString()));
-                }
-                catch (Exception e) {
-                    Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
-                }
+                dialogKey = null;
+                dialogValue = null;
+                dialogKey = listView.getExpandableListAdapter().getGroup(parent);
+                dialogValue = child.get(dialogKey.toString());
+                showDialog(DIALOG_ITEM_OPTIONS);
                 return false;
             }
         });
@@ -84,6 +87,53 @@
         }
     }
 
+    @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);
     }
@@ -104,25 +154,30 @@
                 JSONArray array = new JSONObject(call.get().toString()).getJSONObject("results").getJSONArray("items");
 
                 for (int i = 0; i < array.length(); i++) {
-                    String pluginString = array.get(i).toString();
+                    String pluginString = ((JSONArray)array.get(i)).get(0).toString();
                     groups.add(pluginString);
 
-                    AsyncTask pluginResults = new WebCallReturningAsyncTask(context,
-                            String.format(SEARCH_PLUGIN_FORMATTED, pluginString))
-                            .execute(JSONHandler.createRequestJSON("text", query));
-
-                    JSONArray resultArray = new JSONObject(pluginResults.get().toString()).getJSONObject("results")
-                            .getJSONArray("items");
-                    List<Map<String, JSONArray>> list = new ArrayList<Map<String, JSONArray>>();
-                    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);
-                    }
+					JSONArray resultArray = null;
+
+						AsyncTask 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();
             }
 

=== modified file 'src/org/openlp/android/activity/Service.java'
--- src/org/openlp/android/activity/Service.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/activity/Service.java	2011-09-11 11:57:25 +0000
@@ -38,7 +38,7 @@
 import android.widget.Toast;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
-import org.openlp.android.R;
+import org.openlp.R;
 import org.openlp.android.api.Api;
 import org.openlp.android.data.Slide;
 import org.openlp.android.utility.JSONHandler;
@@ -220,7 +220,12 @@
         }
 
         class FetchItemsException extends Exception {
-            FetchItemsException(Throwable throwable) {
+            /**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
+			FetchItemsException(Throwable throwable) {
                 super(throwable);
             }
         }

=== modified file 'src/org/openlp/android/activity/Slide.java'
--- src/org/openlp/android/activity/Slide.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/activity/Slide.java	2011-09-11 11:57:25 +0000
@@ -38,7 +38,7 @@
 import android.widget.Toast;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
-import org.openlp.android.R;
+import org.openlp.R;
 import org.openlp.android.api.Api;
 import org.openlp.android.utility.JSONHandler;
 import org.openlp.android.utility.OpenLPHttpClient;
@@ -135,6 +135,9 @@
             case R.id.preferences:
                 startActivity(new Intent(this, Preferences.class));
                 return true;
+            case R.id.menuSearch:
+                onSearchRequested();
+                return true;
             default:
                 return super.onOptionsItemSelected(item);
         }
@@ -215,7 +218,12 @@
         }
 
         class FetchItemsException extends Exception {
-            FetchItemsException(Throwable throwable) {
+            /**
+			 * 
+			 */
+			private static final long serialVersionUID = 1L;
+
+			FetchItemsException(Throwable throwable) {
                 super(throwable);
             }
         }

=== modified file 'src/org/openlp/android/api/Api.java'
--- src/org/openlp/android/api/Api.java	2011-05-23 20:59:21 +0000
+++ src/org/openlp/android/api/Api.java	2011-09-11 11:57:25 +0000
@@ -114,4 +114,5 @@
      */
     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=";
 }

=== added directory 'src/org/openlp/android/service'
=== added file 'src/org/openlp/android/service/PingService.java'
--- src/org/openlp/android/service/PingService.java	1970-01-01 00:00:00 +0000
+++ src/org/openlp/android/service/PingService.java	2011-09-11 11:57:25 +0000
@@ -0,0 +1,16 @@
+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
+    protected void onResume() {
+        super.onResume();
+    }
+}

=== modified file 'src/org/openlp/android/utility/GroupExpandableListAdapter.java'
--- src/org/openlp/android/utility/GroupExpandableListAdapter.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/utility/GroupExpandableListAdapter.java	2011-09-11 11:57:25 +0000
@@ -30,7 +30,7 @@
 import android.widget.TextView;
 import org.json.JSONArray;
 import org.json.JSONException;
-import org.openlp.android.R;
+import org.openlp.R;
 
 import java.util.List;
 import java.util.Map;

=== modified file 'src/org/openlp/android/utility/JSONHandler.java'
--- src/org/openlp/android/utility/JSONHandler.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/utility/JSONHandler.java	2011-09-11 11:57:25 +0000
@@ -124,7 +124,12 @@
     }
 
     public static class JSONHandlerException extends Exception {
-        public JSONHandlerException(Throwable throwable) {
+        /**
+		 * 
+		 */
+		private static final long serialVersionUID = 1L;
+
+		public JSONHandlerException(Throwable throwable) {
             super(throwable);
         }
     }

=== modified file 'src/org/openlp/android/utility/OpenLPHttpClient.java'
--- src/org/openlp/android/utility/OpenLPHttpClient.java	2011-05-07 20:01:46 +0000
+++ src/org/openlp/android/utility/OpenLPHttpClient.java	2011-09-11 11:57:25 +0000
@@ -31,7 +31,7 @@
 import org.apache.http.params.BasicHttpParams;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
-import org.openlp.android.R;
+import org.openlp.R;
 
 import java.io.IOException;
 import java.net.MalformedURLException;

=== modified file 'src/org/openlp/android/utility/SlideAdapter.java'
--- src/org/openlp/android/utility/SlideAdapter.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/utility/SlideAdapter.java	2011-09-11 11:57:25 +0000
@@ -28,7 +28,7 @@
 import android.view.ViewGroup;
 import android.widget.BaseAdapter;
 import android.widget.TextView;
-import org.openlp.android.R;
+import org.openlp.R;
 import org.openlp.android.data.Slide;
 
 import java.util.List;

=== modified file 'src/org/openlp/android/utility/WebCallAsyncTask.java'
--- src/org/openlp/android/utility/WebCallAsyncTask.java	2011-05-24 19:17:02 +0000
+++ src/org/openlp/android/utility/WebCallAsyncTask.java	2011-09-11 11:57:25 +0000
@@ -27,7 +27,7 @@
 import android.os.AsyncTask;
 import android.util.Log;
 import android.widget.Toast;
-import org.openlp.android.R;
+import org.openlp.R;
 
 /**
  * Call URL's using this task, which provides visual feedback.

=== modified file 'src/org/openlp/android/utility/WebCallReturningAsyncTask.java'
--- src/org/openlp/android/utility/WebCallReturningAsyncTask.java	2011-05-27 19:46:14 +0000
+++ src/org/openlp/android/utility/WebCallReturningAsyncTask.java	2011-09-11 11:57:25 +0000
@@ -90,6 +90,7 @@
             }
         }
         catch (Exception e) {
+            Log.e(LOG_TAG, e.toString());
             Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
         }
         return null;