← Back to team overview

openlp-android team mailing list archive

[Merge] lp:~johanmynhardt/openlp/android into lp:openlp/android

 

Johan Mynhardt has proposed merging lp:~johanmynhardt/openlp/android into lp:openlp/android.

Requested reviews:
  Tim Bentley (trb143)

For more details, see:
https://code.launchpad.net/~johanmynhardt/openlp/android/+merge/75620

Search fixed and working for all activities (Search from any activity)
Ability to move app to external memory.
-- 
https://code.launchpad.net/~johanmynhardt/openlp/android/+merge/75620
Your team OpenLP Android Developers is subscribed to branch lp:openlp/android.
=== modified file '.bzrignore'
--- .bzrignore	2011-05-05 19:30:01 +0000
+++ .bzrignore	2011-09-15 19:48:32 +0000
@@ -7,3 +7,6 @@
 Openlp-android-working.iml
 .classpath
 .settings
+Openlp-android-buildfilefix.iml
+build.xml
+local.properties

=== modified file 'AndroidManifest.xml'
--- AndroidManifest.xml	2011-05-27 19:46:14 +0000
+++ AndroidManifest.xml	2011-09-15 19:48:32 +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-15 19:48:32 +0000 differ
=== added file 'build.properties'
--- build.properties	1970-01-01 00:00:00 +0000
+++ build.properties	2011-09-15 19:48:32 +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.
+

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

=== added directory 'libs'
=== 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-15 19:48:32 +0000
@@ -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/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-15 19:48:32 +0000
@@ -23,15 +23,20 @@
 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.android.api.Api;
@@ -46,8 +51,12 @@
 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 +72,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 +88,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 +155,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);
 
+                    JSONArray resultArray = null;
+
                     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);
+                    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/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-15 19:48:32 +0000
@@ -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);
         }

=== 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-15 19:48:32 +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-15 19:48:32 +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/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-15 19:48:32 +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;