Repository: incubator-taverna-mobile
Updated Branches:
  refs/heads/master 66577e326 -> a4d52e7b7


http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/build/intermediates/symbols/debug/R.txt
----------------------------------------------------------------------
diff --git a/app/build/intermediates/symbols/debug/R.txt 
b/app/build/intermediates/symbols/debug/R.txt
index 74b3650..88f0cb9 100644
--- a/app/build/intermediates/symbols/debug/R.txt
+++ b/app/build/intermediates/symbols/debug/R.txt
@@ -393,16 +393,16 @@ int id action_menu_presenter 0x7f0b0003
 int id action_mode_bar 0x7f0b002e
 int id action_mode_bar_stub 0x7f0b002d
 int id action_mode_close_button 0x7f0b0020
-int id action_search 0x7f0b0076
-int id action_settings 0x7f0b0077
+int id action_search 0x7f0b0078
+int id action_settings 0x7f0b0079
 int id activity_chooser_view_content 0x7f0b0021
 int id always 0x7f0b0016
 int id author 0x7f0b0048
 int id author_profile_image 0x7f0b004a
 int id beginning 0x7f0b0013
-int id button_download_workflow 0x7f0b0073
-int id button_mark_workflow 0x7f0b0074
-int id button_view_workflow 0x7f0b0072
+int id button_download_workflow 0x7f0b0075
+int id button_mark_workflow 0x7f0b0076
+int id button_view_workflow 0x7f0b0074
 int id checkbox 0x7f0b0029
 int id collapseActionView 0x7f0b0017
 int id container 0x7f0b0042
@@ -432,6 +432,7 @@ int id imageView 0x7f0b0044
 int id imageView2 0x7f0b0045
 int id imageView3 0x7f0b005d
 int id imageView4 0x7f0b005e
+int id layoutinfo 0x7f0b006f
 int id linearlayout_workflow_info 0x7f0b0049
 int id listMode 0x7f0b0009
 int id list_item 0x7f0b0025
@@ -452,7 +453,7 @@ int id pager_title_strip 0x7f0b0041
 int id progress_circular 0x7f0b0005
 int id progress_horizontal 0x7f0b0006
 int id radio 0x7f0b002b
-int id recycler_list 0x7f0b0075
+int id recycler_list 0x7f0b0077
 int id run_wk 0x7f0b0065
 int id scrollView 0x7f0b0063
 int id search_badge 0x7f0b0035
@@ -469,7 +470,7 @@ int id shortcut 0x7f0b002a
 int id showCustom 0x7f0b000f
 int id showHome 0x7f0b0010
 int id showTitle 0x7f0b0011
-int id show_more 0x7f0b0070
+int id show_more 0x7f0b006e
 int id split_action_bar 0x7f0b0007
 int id submit_area 0x7f0b003c
 int id tabMode 0x7f0b000b
@@ -492,10 +493,11 @@ int id withText 0x7f0b001a
 int id wkf_author 0x7f0b0062
 int id wkll 0x7f0b006b
 int id workflow_author 0x7f0b006c
-int id workflow_datecreated 0x7f0b006d
-int id workflow_dateupdated 0x7f0b006e
-int id workflow_image 0x7f0b0071
-int id workflow_title 0x7f0b006f
+int id workflow_brief_description 0x7f0b0072
+int id workflow_datecreated 0x7f0b0070
+int id workflow_dateupdated 0x7f0b0071
+int id workflow_image 0x7f0b0073
+int id workflow_title 0x7f0b006d
 int id workflowpolicyTextView 0x7f0b0068
 int id wrap_content 0x7f0b001d
 int integer abc_config_activityDefaultDur 0x7f0c0000
@@ -581,39 +583,46 @@ int string app_name 0x7f0d0013
 int string brand 0x7f0d0014
 int string completebrand 0x7f0d0015
 int string created 0x7f0d0016
-int string detail_title_section1 0x7f0d0017
-int string detail_title_section2 0x7f0d0018
-int string detail_title_section3 0x7f0d0019
-int string detail_title_section4 0x7f0d001a
-int string favorite_empty 0x7f0d001b
-int string hello_blank_fragment 0x7f0d001c
-int string hello_world 0x7f0d001d
-int string loginbutton 0x7f0d001e
-int string loginpassword 0x7f0d001f
-int string loginusername 0x7f0d0020
-int string marked 0x7f0d0021
-int string menu_search 0x7f0d0022
-int string modified 0x7f0d0023
-int string navigation_drawer_close 0x7f0d0024
-int string navigation_drawer_open 0x7f0d0025
-int string play_workflow 0x7f0d0026
-int string search_hint 0x7f0d0027
-int string title_about 0x7f0d0028
-int string title_activity_dashboard_main 0x7f0d0029
-int string title_activity_flash_screen 0x7f0d002a
-int string title_activity_workflow_detail 0x7f0d002b
-int string title_exit 0x7f0d002c
-int string title_explore 0x7f0d002d
-int string title_favorite 0x7f0d002e
-int string title_openworkflow 0x7f0d002f
-int string title_usage 0x7f0d0030
-int string wktitle 0x7f0d0031
-int string workflow_authorhint 0x7f0d0032
-int string workflow_component 0x7f0d0033
-int string workflow_download 0x7f0d0034
-int string workflow_empty 0x7f0d0035
-int string workflow_mark 0x7f0d0036
-int string workflow_read 0x7f0d0037
+int string description 0x7f0d0017
+int string detail_title_section1 0x7f0d0018
+int string detail_title_section2 0x7f0d0019
+int string detail_title_section3 0x7f0d001a
+int string detail_title_section4 0x7f0d001b
+int string downloadcomplete 0x7f0d001c
+int string downloadduplicate 0x7f0d001d
+int string downloaderror 0x7f0d001e
+int string downloadfailed 0x7f0d001f
+int string downloadprogress 0x7f0d0020
+int string favorite_empty 0x7f0d0021
+int string hello_blank_fragment 0x7f0d0022
+int string hello_world 0x7f0d0023
+int string loginbutton 0x7f0d0024
+int string loginpassword 0x7f0d0025
+int string loginusername 0x7f0d0026
+int string marked 0x7f0d0027
+int string menu_search 0x7f0d0028
+int string modified 0x7f0d0029
+int string navigation_drawer_close 0x7f0d002a
+int string navigation_drawer_open 0x7f0d002b
+int string play_workflow 0x7f0d002c
+int string search_hint 0x7f0d002d
+int string seemore 0x7f0d002e
+int string title_about 0x7f0d002f
+int string title_activity_dashboard_main 0x7f0d0030
+int string title_activity_flash_screen 0x7f0d0031
+int string title_activity_workflow_detail 0x7f0d0032
+int string title_exit 0x7f0d0033
+int string title_explore 0x7f0d0034
+int string title_favorite 0x7f0d0035
+int string title_openworkflow 0x7f0d0036
+int string title_usage 0x7f0d0037
+int string wktitle 0x7f0d0038
+int string workflow_authorhint 0x7f0d0039
+int string workflow_component 0x7f0d003a
+int string workflow_download 0x7f0d003b
+int string workflow_empty 0x7f0d003c
+int string workflow_mark 0x7f0d003d
+int string workflow_read 0x7f0d003e
 int style Animation_AppCompat_DropDownUp 0x7f0e0000
 int style AppTheme 0x7f0e0001
 int style Base_Animation_AppCompat_DropDownUp 0x7f0e0002

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/build/outputs/apk/app-debug-unaligned.apk
----------------------------------------------------------------------
diff --git a/app/build/outputs/apk/app-debug-unaligned.apk 
b/app/build/outputs/apk/app-debug-unaligned.apk
index fc526c3..b4a7ead 100644
Binary files a/app/build/outputs/apk/app-debug-unaligned.apk and 
b/app/build/outputs/apk/app-debug-unaligned.apk differ

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/build/outputs/apk/app-debug.apk
----------------------------------------------------------------------
diff --git a/app/build/outputs/apk/app-debug.apk 
b/app/build/outputs/apk/app-debug.apk
index 2b8f4d6..cd7d840 100644
Binary files a/app/build/outputs/apk/app-debug.apk and 
b/app/build/outputs/apk/app-debug.apk differ

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/build/outputs/logs/manifest-merger-debug-report.txt
----------------------------------------------------------------------
diff --git a/app/build/outputs/logs/manifest-merger-debug-report.txt 
b/app/build/outputs/logs/manifest-merger-debug-report.txt
index f84fda2..127f9ec 100644
--- a/app/build/outputs/logs/manifest-merger-debug-report.txt
+++ b/app/build/outputs/logs/manifest-merger-debug-report.txt
@@ -90,6 +90,20 @@ ADDED from AndroidManifest.xml:60:13
                ADDED from AndroidManifest.xml:62:17
        android:name
                ADDED from AndroidManifest.xml:61:17
+receiver#org.apache.taverna.mobile.broadcastreceivers.WorkflowDownloadReceiver
+ADDED from AndroidManifest.xml:65:9
+       android:enabled
+               ADDED from AndroidManifest.xml:67:13
+       android:exported
+               ADDED from AndroidManifest.xml:68:13
+       android:name
+               ADDED from AndroidManifest.xml:66:13
+intent-filter#android.intent.action.DOWNLOAD_COMPLETE
+ADDED from AndroidManifest.xml:69:13
+action#android.intent.action.DOWNLOAD_COMPLETE
+ADDED from AndroidManifest.xml:70:17
+       android:name
+               ADDED from AndroidManifest.xml:70:25
 uses-sdk
 INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
 MERGED from com.android.support:appcompat-v7:22.0.0:20:5

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d97a064..7a8d8ba 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -61,6 +61,15 @@ limitations under the License.
                 android:name="android.support.PARENT_ACTIVITY"
                 
android:value="org.apache.taverna.mobile.activities.DashboardMainActivity" />
         </activity>
+
+        <receiver
+            android:name=".broadcastreceivers.WorkflowDownloadReceiver"
+            android:enabled="true"
+            android:exported="false" >
+            <intent-filter >
+                <action 
android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
+            </intent-filter>
+        </receiver>
     </application>
 
 </manifest>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/activities/DashboardMainActivity.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/activities/DashboardMainActivity.java
 
b/app/src/main/java/org/apache/taverna/mobile/activities/DashboardMainActivity.java
index 2fb7e1d..fd38391 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/activities/DashboardMainActivity.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/activities/DashboardMainActivity.java
@@ -28,13 +28,16 @@ package org.apache.taverna.mobile.activities;
 import android.app.SearchManager;
 import android.content.Context;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.Environment;
+import android.preference.PreferenceManager;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentPagerAdapter;
 import android.support.v4.app.FragmentTransaction;
+import android.support.v4.os.EnvironmentCompat;
 import android.support.v4.view.ViewPager;
 import android.support.v4.widget.DrawerLayout;
 import android.support.v7.app.ActionBar;
@@ -43,6 +46,7 @@ import android.support.v7.widget.SearchView;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
+import android.view.Window;
 import android.widget.Toast;
 
 import org.apache.taverna.mobile.R;
@@ -67,14 +71,16 @@ public class DashboardMainActivity extends ActionBarActivity
 
     static final int NUM_ITEMS = 2;
     private final int SELECT_WORKFLOW = 10;
-    public final String APP_DIRECTORY_NAME = "TavernaMobile";
+    public static final String APP_DIRECTORY_NAME = "TavernaMobile";
 
     MyAdapter mAdapter;
     ViewPager mPager;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
+        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
         super.onCreate(savedInstanceState);
+
         setContentView(R.layout.activity_dashboard_main);
 
         mNavigationDrawerFragment = (NavigationDrawerFragment)
@@ -99,6 +105,8 @@ public class DashboardMainActivity extends ActionBarActivity
             Toast.makeText(this,"Query = "+query, Toast.LENGTH_SHORT).show();
         }
         setUpWorkflowDirectory(this);
+        if (savedInstanceState == null)
+            getSupportFragmentManager().beginTransaction().add(R.id.container, 
WorkflowItemFragment.newInstance("","")).commit();
     }
 
     @Override
@@ -119,8 +127,10 @@ public class DashboardMainActivity extends 
ActionBarActivity
                 break;
             case 2: //open workflow
                 Intent workflowSelectIntent = new 
Intent(Intent.ACTION_GET_CONTENT)
-                        .setType("text/t2flow")
-                        
.setData(Uri.parse(Environment.getExternalStorageDirectory()+File.separator+APP_DIRECTORY_NAME));
+                        
.setDataAndTypeAndNormalize(Uri.parse(String.format("%s%s%s",
+                                        
Environment.getExternalStorageDirectory(),
+                                        File.separator, APP_DIRECTORY_NAME)),
+                                "application/vnd.taverna.t2flow+xml");
 
                 Intent loadWorkflowIntent = 
Intent.createChooser(workflowSelectIntent,
                         "Choose Workflow (.t2flow)");
@@ -185,15 +195,32 @@ public class DashboardMainActivity extends 
ActionBarActivity
     }
 
     private void setUpWorkflowDirectory(Context context){
-        File workflowDirectory = new 
File(Environment.getExternalStorageDirectory()+File.separator+APP_DIRECTORY_NAME);
-        if(!workflowDirectory.exists()){
-            boolean state = workflowDirectory.mkdirs();
-            if(state){
-                Toast.makeText(context, "Storage Ready", 
Toast.LENGTH_SHORT).show();
-            }else{
-                Toast.makeText(context, "Storage Error. Directory not 
created", Toast.LENGTH_SHORT).show();
-            }
+
+        SharedPreferences sp = 
PreferenceManager.getDefaultSharedPreferences(context);
+        
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+            File workflowDirectory = new 
File(Environment.getExternalStorageDirectory()+File.separator+APP_DIRECTORY_NAME);
+            if (!workflowDirectory.exists()) {
+                boolean state = workflowDirectory.mkdirs();
+                if (state) {
+                    Toast.makeText(context, "Storage Ready", 
Toast.LENGTH_SHORT).show();
+                    sp.edit().putString(APP_DIRECTORY_NAME, 
Environment.getExternalStorageDirectory() + File.separator + 
APP_DIRECTORY_NAME).commit();
+                } else { //directory can't be created either because of 
restricted access or lack of an external storage media.
+                    //we assume the lack of secondary storage so we have to 
switch to internal storage
+                    //   File dir = new 
File(Environment.getExternalStoragePublicDirectory(Environment.))
+                    Toast.makeText(context, "Storage Error. Directory not 
created", Toast.LENGTH_SHORT).show();
+                }
 //            workflowDirectory.list();
+            } /*else {
+                File mainDir = new 
File(Environment.getExternalStorageDirectory() + File.separator + 
APP_DIRECTORY_NAME);
+                if (mainDir.mkdirs())
+                    sp.edit().putString(APP_DIRECTORY_NAME, 
mainDir.getAbsolutePath()).commit();
+                else
+                    Toast.makeText(context, "Workflow home not created. 
Permission issues", Toast.LENGTH_SHORT).show();
+            }*/
+        }else{//use internal memory to save the data
+            File home = context.getDir("Workflows", Context.MODE_PRIVATE);
+            sp.edit().putString(APP_DIRECTORY_NAME, 
home.getAbsolutePath()).commit();
+//            Toast.makeText(context, "Home dir: "+home.getAbsolutePath(), 
Toast.LENGTH_LONG).show();
         }
     }
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java 
b/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java
index 0833a18..4c924a8 100644
--- a/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java
+++ b/app/src/main/java/org/apache/taverna/mobile/adapters/WorkflowAdapter.java
@@ -27,27 +27,36 @@ package org.apache.taverna.mobile.adapters;
 import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
+import android.net.Uri;
+import android.preference.PreferenceManager;
 import android.support.v7.widget.RecyclerView;
+import android.text.Html;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.BaseAdapter;
 import android.widget.Button;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.activities.DashboardMainActivity;
 import org.apache.taverna.mobile.activities.WorkflowDetailActivity;
-import org.apache.taverna.mobile.utils.Workflow;
+import org.apache.taverna.mobile.tavernamobile.Workflow;
+import org.apache.taverna.mobile.utils.WorkflowDownloadManager;
+
+import java.io.File;
+import java.util.List;
 
 /**
  * Created by root on 6/8/15.
  */
 public class WorkflowAdapter extends 
RecyclerView.Adapter<WorkflowAdapter.ViewHolder> implements 
View.OnClickListener{
     private Context context;
-    private Workflow[] workflow;
+    private List<Workflow> workflow;
     private WorkflowAdapter.ViewHolder mViewHolder;
-    public WorkflowAdapter(Context c, Workflow[] wk) {
+
+    public WorkflowAdapter(Context c, List<Workflow> wk) {
         context = c;
         workflow = wk;
     }
@@ -65,15 +74,53 @@ public class WorkflowAdapter extends 
RecyclerView.Adapter<WorkflowAdapter.ViewHo
      * @param i position of data in the dataset to use.
      */
     @Override
-    public void onBindViewHolder(ViewHolder viewHolder, int i) {
-        viewHolder.author_name.setText(workflow[i].getWorkflow_author());
+    public void onBindViewHolder(final ViewHolder viewHolder, int i) {
+        final int j = i; //position of workflow item that has workflow data
+        final Context c = this.context;
+        viewHolder.author_name.setText(workflow.get(i).getWorkflow_author());
+        viewHolder.wk_title.setText(workflow.get(i).getWorkflow_title());
+        
viewHolder.wk_modified.append(workflow.get(i).getWorkflow_datemodified());
+        
viewHolder.wk_created.append(workflow.get(i).getWorkflow_datecreated());
+        viewHolder.wk_description.setText( 
workflow.get(i).getWorkflow_description());
         
//viewHolder.author_profile.setImageBitmap(workflow[i].getWorkflow_author_bitmap());
+        Intent it = new Intent();
         viewHolder.btn_view_workflow.setOnClickListener(this);
+        viewHolder.btn_download_workflow.setOnClickListener(new 
View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                String wkflow_url = workflow.get(j).getWorkflow_remote_url();
+                try {
+
+                    String workflow_name = 
Uri.parse(wkflow_url).getLastPathSegment();
+                    WorkflowDownloadManager dm = new 
WorkflowDownloadManager(c);
+                    dm.downloadWorkflow(new File(PreferenceManager
+                            .getDefaultSharedPreferences(c)
+                            
.getString(DashboardMainActivity.APP_DIRECTORY_NAME, 
"/")+File.separator+workflow_name), wkflow_url);
+                } catch(NullPointerException np){
+                    np.printStackTrace();
+                }catch (IllegalArgumentException ill){
+                    ill.printStackTrace();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        viewHolder.btn_mark_workflow.setOnClickListener(this);
+        
viewHolder.wk_showmore.setText(Html.fromHtml(context.getResources().getString(R.string.seemore)));
+        viewHolder.wk_showmore.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                if (viewHolder.infolayout.getVisibility() == View.GONE)
+                    viewHolder.infolayout.setVisibility(View.VISIBLE);
+                else
+                    viewHolder.infolayout.setVisibility(View.GONE);
+            }
+        });
     }
 
     @Override
     public long getItemId(int i) {
-        return workflow[i].getid();
+        return workflow.get(i).getId();
     }
 
     @Override
@@ -85,6 +132,10 @@ public class WorkflowAdapter extends 
RecyclerView.Adapter<WorkflowAdapter.ViewHo
         return size;
     }
 
+    public Workflow getItem(int position){
+        return workflow.get(position);
+    }
+
     @Override
     public void onClick(View view) {
         switch(view.getId()){
@@ -92,18 +143,35 @@ public class WorkflowAdapter extends 
RecyclerView.Adapter<WorkflowAdapter.ViewHo
                 context.startActivity(new Intent(context, 
WorkflowDetailActivity.class));
                 ((Activity) 
context).overridePendingTransition(android.R.anim.slide_in_left, 
android.R.anim.fade_out);
                 break;
+            case R.id.button_mark_workflow:
+                break;
+
         }
     }
 
     public static class ViewHolder extends RecyclerView.ViewHolder {
         public final ImageView author_profile;
-        public final TextView author_name;
+        public final TextView author_name, 
wk_title,wk_showmore,wk_created,wk_modified,wk_description;
         public final Button btn_view_workflow;
+        public final Button btn_download_workflow;
+        public final Button btn_mark_workflow;
+        public final LinearLayout infolayout;
 
         public ViewHolder(View v) {
             super(v);
+            infolayout = (LinearLayout) v.findViewById(R.id.layoutinfo);
+            //cache text fields
             author_profile = (ImageView) 
v.findViewById(R.id.author_profile_image);
             author_name = (TextView) v.findViewById(R.id.workflow_author);
+            wk_title = (TextView) v.findViewById(R.id.workflow_title);
+            wk_showmore = (TextView) v.findViewById(R.id.show_more);
+            wk_created = (TextView) v.findViewById(R.id.workflow_datecreated);
+            wk_modified = (TextView) v.findViewById(R.id.workflow_dateupdated);
+            wk_description = (TextView) 
v.findViewById(R.id.workflow_brief_description);
+
+            //cache buttons
+            btn_download_workflow = (Button) 
v.findViewById(R.id.button_download_workflow);
+            btn_mark_workflow = (Button) 
v.findViewById(R.id.button_mark_workflow);
             btn_view_workflow = (Button) 
v.findViewById(R.id.button_view_workflow);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/broadcastreceivers/WorkflowDownloadReceiver.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/broadcastreceivers/WorkflowDownloadReceiver.java
 
b/app/src/main/java/org/apache/taverna/mobile/broadcastreceivers/WorkflowDownloadReceiver.java
new file mode 100644
index 0000000..8bc2468
--- /dev/null
+++ 
b/app/src/main/java/org/apache/taverna/mobile/broadcastreceivers/WorkflowDownloadReceiver.java
@@ -0,0 +1,63 @@
+package org.apache.taverna.mobile.broadcastreceivers;
+/**
+ * Apache Taverna Mobile
+ * Copyright 2015 The Apache Software Foundation
+
+ * This product includes software developed at
+ * The Apache Software Foundation (http://www.apache.org/).
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import android.app.DownloadManager;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+
+import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.utils.WorkflowDownloadManager;
+
+public class WorkflowDownloadReceiver extends BroadcastReceiver {
+    public WorkflowDownloadReceiver() {
+    }
+
+    @Override
+    public void onReceive(Context context, Intent intent) {
+
+        long receivedID = 
intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1L);
+        DownloadManager mgr = (DownloadManager) 
context.getSystemService(Context.DOWNLOAD_SERVICE);
+        WorkflowDownloadManager wdm = new WorkflowDownloadManager(context, 
mgr);
+
+        DownloadManager.Query query = new DownloadManager.Query(); //ask for 
information about the download queue
+        query.setFilterById(receivedID);
+        Cursor cur = mgr.query(query);
+        int index = cur.getColumnIndex(DownloadManager.COLUMN_STATUS);
+        String workflow = 
cur.getString(cur.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME));
+
+        if(cur.moveToFirst()) {
+            if(cur.getInt(index) == DownloadManager.STATUS_SUCCESSFUL){
+                
wdm.sendNotification(workflow+context.getResources().getString(R.string.downloadcomplete));
+            }else{
+                
wdm.sendNotification(context.getResources().getString(R.string.downloadfailed));
+            }
+        }else{
+            
wdm.sendNotification(context.getResources().getString(R.string.downloadfailed));
+        }
+        cur.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
 
b/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
index 781e6d1..7270e55 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/fragments/WorkflowItemFragment.java
@@ -27,19 +27,29 @@ package org.apache.taverna.mobile.fragments;
 import android.app.Activity;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.Loader;
 import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
 import android.widget.AdapterView;
-import android.widget.ListAdapter;
 import android.widget.TextView;
 
 import org.apache.taverna.mobile.R;
 import org.apache.taverna.mobile.activities.DashboardMainActivity;
 import org.apache.taverna.mobile.adapters.WorkflowAdapter;
-import org.apache.taverna.mobile.utils.Workflow;
+import org.apache.taverna.mobile.tavernamobile.Workflow;
+import org.apache.taverna.mobile.utils.WorkflowLoader;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * A fragment representing a list of Items.
@@ -50,12 +60,13 @@ import org.apache.taverna.mobile.utils.Workflow;
  * Activities containing this fragment MUST implement the {@link 
org.apache.taverna.mobile.fragments.WorkflowItemFragment.OnWorkflowSelectedListener}
  * interface.
  */
-public class WorkflowItemFragment extends Fragment implements 
AdapterView.OnItemClickListener {
+public class WorkflowItemFragment extends Fragment implements 
AdapterView.OnItemClickListener,android.app.LoaderManager.LoaderCallbacks<List<Workflow>>
 {
 
     // TODO: Rename parameter arguments, choose names that match
     // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
     private static final String ARG_PARAM1 = "param1";
     private static final String ARG_PARAM2 = "param2";
+    private Animation in;
 
     // TODO: Rename and change types of parameters
     private String mParam1;
@@ -95,28 +106,36 @@ public class WorkflowItemFragment extends Fragment 
implements AdapterView.OnItem
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        setHasOptionsMenu(true);
 
         if (getArguments() != null) {
             mParam1 = getArguments().getString(ARG_PARAM1);
             mParam2 = getArguments().getString(ARG_PARAM2);
         }
-
-        workflowAdapter = new WorkflowAdapter(getActivity(), new 
Workflow[]{new Workflow(getActivity(), null),
-                new Workflow(getActivity(), null),
-                new Workflow(getActivity(), null)});
+        in = 
AnimationUtils.loadAnimation(getActivity(),android.R.anim.slide_in_left);
+       List<Workflow> mlist = new ArrayList<Workflow>();
+   /*
+        mlist.add(new Workflow(getActivity(), null));
+        mlist.add(new Workflow(getActivity(), null));
+        mlist.add(new Workflow(getActivity(), null)); */
+        workflowAdapter = new WorkflowAdapter(getActivity(), mlist );
     }
 
     @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-                             Bundle savedInstanceState) {
+    public View onCreateView(LayoutInflater inflater, ViewGroup 
container,Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.fragment_item, container, false);
 
         // Set the adapter
         mListView = (RecyclerView) view.findViewById(android.R.id.list);
         mListView.setHasFixedSize(true);
         mListView.setLayoutManager(new LinearLayoutManager(getActivity()));
-        mListView.setAdapter(workflowAdapter);
-
+         if(workflowAdapter.getItemCount() == 0){
+            setEmptyText("No Workflows available");
+            mListView.swapAdapter(null, false);
+        }else {
+            mListView.setAdapter(workflowAdapter);
+             mListView.setAnimation(in);
+        }
         return view;
     }
 
@@ -126,11 +145,61 @@ public class WorkflowItemFragment extends Fragment 
implements AdapterView.OnItem
         try {
             mListener = (OnWorkflowSelectedListener) activity;
             ((DashboardMainActivity) activity).onSectionAttached(1);
+            getActivity().getLoaderManager().initLoader(0,null,this);
         } catch (ClassCastException e) {
             throw new ClassCastException(activity.toString()
                     + " must implement OnFragmentInteractionListener");
         }
     }
+    /**
+     * Initialize the contents of the Activity's standard options menu.  You
+     * should place your menu items in to <var>menu</var>.  For this method
+     * to be called, you must have first called {@link #setHasOptionsMenu}.  
See
+     * {@link android.app.Activity#onCreateOptionsMenu(android.view.Menu) 
Activity.onCreateOptionsMenu}
+     * for more information.
+     *
+     * @param menu     The options menu in which you place your items.
+     * @param inflater
+     * @see #setHasOptionsMenu
+     * @see #onPrepareOptionsMenu
+     * @see #onOptionsItemSelected
+     */
+    @Override
+    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        super.onCreateOptionsMenu(menu, inflater);
+        //menu.clear();
+        if(menu.size() == 1) {
+            // inflater.inflate(R.menu.dashboard_main,menu);
+            MenuItem mit = menu.add("Refresh");
+            mit.setIcon(android.R.drawable.stat_notify_sync);
+            mit.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+        }
+    }
+
+    /**
+     * This hook is called whenever an item in your options menu is selected.
+     * The default implementation simply returns false to have the normal
+     * processing happen (calling the item's Runnable or sending a message to
+     * its Handler as appropriate).  You can use this method for any items
+     * for which you would like to do processing without those other
+     * facilities.
+     * <p/>
+     * <p>Derived classes should call through to the base class for it to
+     * perform the default menu handling.
+     *
+     * @param item The menu item that was selected.
+     * @return boolean Return false to allow normal menu processing to
+     * proceed, true to consume it here.
+     * @see #onCreateOptionsMenu
+     */
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        if(item.getTitle().equals("Refresh")){
+            getActivity().getLoaderManager().restartLoader(0, null, this);
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
 
     @Override
     public void onDetach() {
@@ -138,7 +207,6 @@ public class WorkflowItemFragment extends Fragment 
implements AdapterView.OnItem
         mListener = null;
     }
 
-
     @Override
     public void onItemClick(AdapterView<?> parent, View view, int position, 
long id) {
         if (null != mListener) {
@@ -161,6 +229,38 @@ public class WorkflowItemFragment extends Fragment 
implements AdapterView.OnItem
     }
 
     /**
+     * Instantiate and return a new Loader for the given ID.
+     *
+     * @param id   The ID whose loader is to be created.
+     * @param args Any arguments supplied by the caller.
+     * @return Return a new Loader instance that is ready to start loading.
+     */
+    @Override
+    public android.content.Loader<List<Workflow>> onCreateLoader(int id, 
Bundle args) {
+        getActivity().setProgressBarIndeterminateVisibility(true);
+        return new WorkflowLoader(getActivity());
+    }
+
+    @Override
+    public void onLoadFinished(android.content.Loader<List<Workflow>> loader, 
List<Workflow> workflows) {
+        getActivity().setProgressBarIndeterminateVisibility(false);
+        loader.stopLoading();
+        workflowAdapter = new WorkflowAdapter(getActivity(), workflows);
+        if(workflows.size() > 0)
+            mListView.swapAdapter(workflowAdapter, true);
+        else {
+//            mListView.setVisibility(View.GONE);
+//            setEmptyText("No views available");
+        }
+    }
+
+    @Override
+    public void onLoaderReset(android.content.Loader<List<Workflow>> 
listLoader) {
+        listLoader.reset();
+        mListView.swapAdapter(null, false);
+    }
+
+    /**
      * This interface must be implemented by activities that contain this
      * fragment to allow an interaction in this fragment to be communicated
      * to the activity and potentially other fragments contained in that

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
 
b/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
index c7e8a24..4179988 100644
--- 
a/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
+++ 
b/app/src/main/java/org/apache/taverna/mobile/fragments/workflowdetails/WorkflowdetailFragment.java
@@ -24,23 +24,37 @@ package org.apache.taverna.mobile.fragments.workflowdetails;
  * under the License.
  */
 
+import android.app.DownloadManager;
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
 import android.os.Bundle;
+import android.os.Environment;
+import android.preference.PreferenceManager;
 import android.support.v4.app.Fragment;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.Button;
 
 import org.apache.taverna.mobile.R;
+import org.apache.taverna.mobile.activities.DashboardMainActivity;
+import org.apache.taverna.mobile.utils.WorkflowDownloadManager;
+
+import java.io.File;
+import java.util.prefs.PreferenceChangeEvent;
 
 /**
  * Created by Larry Akah on 6/9/15.
  */
-public class WorkflowdetailFragment extends Fragment {
+public class WorkflowdetailFragment extends Fragment implements 
View.OnClickListener{
     /**
      * The fragment argument representing the section number for this
      * fragment.
      */
     private static final String ARG_SECTION_NUMBER = "section_number";
+    private DownloadManager downloadManager;
+    private boolean isDownloading = false;
 
     /**
      * Returns a new instance of this fragment for the given section
@@ -61,6 +75,34 @@ public class WorkflowdetailFragment extends Fragment {
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState) {
         View rootView = inflater.inflate(R.layout.fragment_workflow_detail, 
container, false);
+        Button download = (Button) rootView.findViewById(R.id.download_wk);
+        download.setOnClickListener(this);
+        downloadManager = (DownloadManager) 
getActivity().getSystemService(Context.DOWNLOAD_SERVICE);
+
         return rootView;
     }
+
+    @Override
+    public void onClick(View view) {
+        switch(view.getId()){
+            case R.id.run_wk:
+                //TODO implement functionality to issue a run request to the 
Taverna PLAYER to run the current workflow
+                break;
+            case R.id.download_wk:
+                // start the android Download manager to start downloading a 
remote workflow file
+                WorkflowDownloadManager dmgr = new 
WorkflowDownloadManager(getActivity(), downloadManager);
+                try {
+                    dmgr.downloadWorkflow(new 
File(PreferenceManager.getDefaultSharedPreferences(getActivity()).getString(
+                                    DashboardMainActivity.APP_DIRECTORY_NAME, 
"/")),
+                            "http://www.iceteck.com/volley.jar";);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+                break;
+            case R.id.mark_wk:
+                //TODO mark a workflow as important and launch task to store 
the entry into the local database
+                break;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Runs.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Runs.java 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Runs.java
new file mode 100644
index 0000000..2a62b2a
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Runs.java
@@ -0,0 +1,8 @@
+package org.apache.taverna.mobile.tavernamobile;
+
+/**
+ * Created by Larry Akah on 6/13/15.
+ * Workflow runs for a given workflow
+ */
+public class Runs {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/tavernamobile/TavernaPlayerAPI.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/tavernamobile/TavernaPlayerAPI.java
 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/TavernaPlayerAPI.java
new file mode 100644
index 0000000..e4f353d
--- /dev/null
+++ 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/TavernaPlayerAPI.java
@@ -0,0 +1,12 @@
+package org.apache.taverna.mobile.tavernamobile;
+
+/**
+ * Created by root on 6/13/15.
+ */
+public class TavernaPlayerAPI {
+    public static final String PLAYER_URL = "http://heater.cs.man.ac.uk:3000/";;
+    public static final String SERVER_URL = 
"http://heater.cs.man.ac.uk:8090/taverna-2.5.4/";;
+
+    public TavernaPlayerAPI() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java
new file mode 100644
index 0000000..f6f2282
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/Workflow.java
@@ -0,0 +1,137 @@
+package org.apache.taverna.mobile.tavernamobile;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+
+import org.apache.taverna.mobile.R;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by root on 6/8/15.
+ */
+public class Workflow {
+    private Context context;
+    private String workflow_author;
+    private String workflow_title;
+    private String workflow_description;
+    private String workflow_datecreated, workflow_datemodified;
+    private Bitmap workflow_author_bitmap;
+    private WorkflowComponent workflowComponent;
+    private String workflow_remote_url;
+    private List<Runs> workflow_runs;
+    private int workflow_input;
+    private long id;
+
+    public static enum workflow_input_type{ TYPE_INT, TYPE_STRING, 
TYPE_OBJECT};
+
+    public Workflow(Context ctx, String title, String author, String 
description, long id, String status){
+        this.context = ctx;
+        this.workflow_author = author;
+        this.workflow_author_bitmap = 
BitmapFactory.decodeResource(this.context.getResources(), 
R.drawable.ic_userprofile);
+        this.workflow_description =description;
+        this.workflow_title =title;
+        this.workflow_input=1;
+        this.id = id;
+        this.workflow_remote_url = "http://org.man.uc.taverna/workflows";;
+        this.workflow_runs = new ArrayList<Runs>();
+        
this.setWorkflow_datecreated(SimpleDateFormat.getDateTimeInstance().format(new 
Date()));
+        
this.setWorkflow_datemodified(SimpleDateFormat.getDateTimeInstance().format(new 
Date()));
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getWorkflow_datecreated() {
+        return this.workflow_datecreated;
+    }
+
+    public String getWorkflow_remote_url() {
+        return this.workflow_remote_url;
+    }
+
+    public void setWorkflow_remote_url(String workflow_remote_url) {
+        this.workflow_remote_url = workflow_remote_url;
+    }
+
+    public void setWorkflow_datecreated(String workflow_datecreated) {
+        this.workflow_datecreated = workflow_datecreated;
+    }
+
+    public String getWorkflow_datemodified() {
+        return this.workflow_datemodified;
+    }
+
+    public void setWorkflow_datemodified(String workflow_datemodified) {
+        this.workflow_datemodified = workflow_datemodified;
+    }
+
+    public List<Runs> getWorkflow_runs() {
+        return this.workflow_runs;
+    }
+
+    public void setWorkflow_runs(List<Runs> workflow_runs) {
+        this.workflow_runs = workflow_runs;
+    }
+
+    public int getWorkflow_input() {
+        return this.workflow_input;
+    }
+
+    public void setWorkflow_input(int workflow_input) {
+        this.workflow_input = workflow_input;
+    }
+
+    public workflow_input_type getInputType(){
+        return workflow_input_type.TYPE_INT;
+    }
+
+    public String getWorkflow_author() {
+        return this.workflow_author;
+    }
+
+    public String getWorkflow_description() {
+        return this.workflow_description;
+    }
+
+    public String getWorkflow_title() {
+        return this.workflow_title;
+    }
+
+    public Bitmap getWorkflow_author_bitmap() {
+        return this.workflow_author_bitmap;
+    }
+
+    public WorkflowComponent getWorkflowComponent() {
+        return this.workflowComponent;
+    }
+
+    public void setWorkflow_author(String workflow_author) {
+        this.workflow_author = workflow_author;
+    }
+
+    public void setWorkflow_title(String workflow_title) {
+        this.workflow_title = workflow_title;
+    }
+
+    public void setWorkflow_description(String workflow_description) {
+        this.workflow_description = workflow_description;
+    }
+
+    public void setWorkflow_author_bitmap(Bitmap workflow_author_bitmap) {
+        this.workflow_author_bitmap = workflow_author_bitmap;
+    }
+
+    public void setWorkflowComponent(WorkflowComponent workflowComponent) {
+        this.workflowComponent = workflowComponent;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
new file mode 100644
index 0000000..71f30ae
--- /dev/null
+++ 
b/app/src/main/java/org/apache/taverna/mobile/tavernamobile/WorkflowComponent.java
@@ -0,0 +1,33 @@
+package org.apache.taverna.mobile.tavernamobile;
+/**
+ * Apache Taverna Mobile
+ * Copyright 2015 The Apache Software Foundation
+
+ * This product includes software developed at
+ * The Apache Software Foundation (http://www.apache.org/).
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Created by root on 6/8/15.
+ */
+public class WorkflowComponent {
+
+    public WorkflowComponent() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/utils/DB_Utility.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/DB_Utility.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/DB_Utility.java
new file mode 100644
index 0000000..2ed6b19
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/DB_Utility.java
@@ -0,0 +1,45 @@
+package org.apache.taverna.mobile.utils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+
+/**
+ * This class contains all utility functions used by our database for basic 
functionality not directly related to the core
+ * functionality of it but that aids a core functionality to carryout its 
function efficiently.
+ * This class is designed to be a singleton class
+ * @author Larry Akah
+ *
+ */
+public class DB_Utility {
+
+       /**
+        * Returns a new JSONArray of new key values to be stored ommitting the 
identified entry to be removed
+        * @param keys
+        * @param removeid
+        * @return
+        * @throws org.json.JSONException
+        */
+       public static JSONArray removeKey(JSONArray keys, String removeid) 
throws JSONException{
+               ArrayList<String> mkeys = new ArrayList<String>();
+               if(keys!=null){
+               for(int i=0; i<keys.length(); i++){
+                       mkeys.add(keys.getString(i));
+                       }
+               mkeys.remove(removeid);
+               JSONArray nkeyArray = new JSONArray();
+               for(String newkey: mkeys){
+                       nkeyArray.put(newkey);
+               }
+               return nkeyArray; //returns the new keys to save under the db;
+               
+               }
+               else{
+                       return keys; //returns a null value indicating nothin 
to remove due to no keys available
+               }
+               
+       }
+       
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/utils/Workflow.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/Workflow.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/Workflow.java
deleted file mode 100644
index c61eb18..0000000
--- a/app/src/main/java/org/apache/taverna/mobile/utils/Workflow.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.apache.taverna.mobile.utils;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.support.v4.graphics.BitmapCompat;
-import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
-
-import org.apache.taverna.mobile.R;
-
-/**
- * Created by root on 6/8/15.
- */
-public class Workflow {
-    private Context context;
-    private String workflow_author;
-    private String workflow_title;
-    private String workflow_description;
-    private Bitmap workflow_author_bitmap;
-    private WorkflowComponent workflowComponent;
-    private int workflow_input;
-    private long id;
-
-    public long getid() {
-        return id;
-    }
-
-    public long getId() {
-        return id;
-    }
-
-    public void setId(long id) {
-        this.id = id;
-    }
-
-    public static enum workflow_input_type{ TYPE_INT, TYPE_STRING, 
TYPE_OBJECT};
-
-    public Workflow(Context ctx, WorkflowComponent component){
-        this.context = ctx;
-        this.workflowComponent = component;
-        this.workflow_author = "Larry Akah";
-        this.workflow_author_bitmap = 
BitmapFactory.decodeResource(this.context.getResources(), 
R.drawable.ic_userprofile);
-        this.workflow_description =" Prokaryotic behaviour in carnivorous 
plants";
-        this.workflow_title ="Carnivorous synthesis";
-        this.workflow_input=1;
-
-    }
-
-    public int getWorkflow_input() {
-        return this.workflow_input;
-    }
-
-    public void setWorkflow_input(int workflow_input) {
-        this.workflow_input = workflow_input;
-    }
-
-    public workflow_input_type getInputType(){
-        return workflow_input_type.TYPE_INT;
-    }
-
-    public String getWorkflow_author() {
-        return this.workflow_author;
-    }
-
-    public String getWorkflow_description() {
-        return this.workflow_description;
-    }
-
-    public String getWorkflow_title() {
-        return this.workflow_title;
-    }
-
-    public Bitmap getWorkflow_author_bitmap() {
-        return this.workflow_author_bitmap;
-    }
-
-    public WorkflowComponent getWorkflowComponent() {
-        return this.workflowComponent;
-    }
-
-    public void setWorkflow_author(String workflow_author) {
-        this.workflow_author = workflow_author;
-    }
-
-    public void setWorkflow_title(String workflow_title) {
-        this.workflow_title = workflow_title;
-    }
-
-    public void setWorkflow_description(String workflow_description) {
-        this.workflow_description = workflow_description;
-    }
-
-    public void setWorkflow_author_bitmap(Bitmap workflow_author_bitmap) {
-        this.workflow_author_bitmap = workflow_author_bitmap;
-    }
-
-    public void setWorkflowComponent(WorkflowComponent workflowComponent) {
-        this.workflowComponent = workflowComponent;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowComponent.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowComponent.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowComponent.java
deleted file mode 100644
index 2da760d..0000000
--- a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowComponent.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.taverna.mobile.utils;
-
-/**
- * Created by root on 6/8/15.
- */
-public class WorkflowComponent {
-
-    public WorkflowComponent() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
 
b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
new file mode 100644
index 0000000..1f244fb
--- /dev/null
+++ 
b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowDownloadManager.java
@@ -0,0 +1,115 @@
+package org.apache.taverna.mobile.utils;
+/**
+ * Apache Taverna Mobile
+ * Copyright 2015 The Apache Software Foundation
+
+ * This product includes software developed at
+ * The Apache Software Foundation (http://www.apache.org/).
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import android.app.DownloadManager;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.database.Cursor;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.support.v4.app.NotificationCompat;
+
+import org.apache.taverna.mobile.R;
+
+import java.io.File;
+
+/**
+ * Created by root on 6/11/15.
+ */
+public class WorkflowDownloadManager {
+    private DownloadManager downloadManager;
+    private Context context;
+    private boolean isDownloading;
+
+    public WorkflowDownloadManager(Context ctx, DownloadManager 
downloadManager) {
+        this.context = ctx;
+        this.downloadManager = downloadManager;
+        this.isDownloading = false;
+    }
+
+    public WorkflowDownloadManager(Context context) {
+        this.context = context;
+        this.downloadManager = (DownloadManager) 
context.getSystemService(Context.DOWNLOAD_SERVICE);
+        this.isDownloading = false;
+    }
+
+    /**
+     * Download the given workflow
+     * @param destination The destination file in which to save the downloaded 
file
+     */
+    public void downloadWorkflow(File destination, String sourceurl) throws 
Exception{
+
+        DownloadManager.Query query = new DownloadManager.Query();
+        query.setFilterByStatus(DownloadManager.STATUS_PAUSED|
+                DownloadManager.STATUS_PENDING|
+                DownloadManager.STATUS_RUNNING|
+                DownloadManager.STATUS_SUCCESSFUL);
+        Cursor cur = this.downloadManager.query(query);
+        int col = cur.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME);
+
+        for(cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
+            this.isDownloading = this.isDownloading || (destination.getName() 
== cur.getString(col));
+        }
+        cur.close();
+        if (!this.isDownloading) {
+            Uri source = Uri.parse(sourceurl);
+            //extract the file name from the source url and append it to the 
workflow storage directory to be used to download the file into.
+            Uri destinationurl = 
Uri.withAppendedPath(Uri.fromFile(destination), 
Uri.parse(sourceurl).getLastPathSegment());
+
+            DownloadManager.Request request = new 
DownloadManager.Request(source);
+            request.setTitle("Workflow");
+            request.setDescription("Downloading workflow");
+            request.setDestinationUri(destinationurl);
+            
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED
 |
+                    DownloadManager.Request.VISIBILITY_VISIBLE);
+            request.allowScanningByMediaScanner();
+
+            long id = downloadManager.enqueue(request);
+            if(id == DownloadManager.STATUS_RUNNING ){
+                //send notification to user about running download
+                
sendNotification(this.context.getResources().getString(R.string.downloadprogress));
+            }else{
+                
sendNotification(this.context.getResources().getString(R.string.downloaderror));
+            }
+        }else{
+            
sendNotification(this.context.getResources().getString(R.string.downloadduplicate));
+        }
+    }
+
+    public void sendNotification(String message){
+        NotificationCompat.Builder notificationBuilder = new 
NotificationCompat.Builder(this.context);
+        notificationBuilder.setContentText(message)
+                .setContentTitle("Workflow Download")
+                .setSmallIcon(R.mipmap.ic_launcher)
+                .setAutoCancel(true)
+                .setVisibility(Notification.VISIBILITY_PUBLIC)
+                .setWhen(0)
+                
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
+        Notification nf  = notificationBuilder.build();
+        NotificationManager notificationManager = (NotificationManager) 
context.getSystemService(Context.NOTIFICATION_SERVICE);
+        notificationManager.notify(1, nf);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoader.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoader.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoader.java
new file mode 100644
index 0000000..9c97485
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowLoader.java
@@ -0,0 +1,138 @@
+package org.apache.taverna.mobile.utils;
+/**
+ * Apache Taverna Mobile
+ * Copyright 2015 The Apache Software Foundation
+
+ * This product includes software developed at
+ * The Apache Software Foundation (http://www.apache.org/).
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import android.content.AsyncTaskLoader;
+import android.content.Context;
+
+import org.apache.taverna.mobile.adapters.WorkflowAdapter;
+import org.apache.taverna.mobile.tavernamobile.TavernaPlayerAPI;
+import org.apache.taverna.mobile.tavernamobile.Workflow;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Larry Akah on 6/13/15.
+ */
+public class WorkflowLoader extends AsyncTaskLoader<List<Workflow>> {
+
+    private Context ctx;
+    private List<Workflow> userWorkflows;
+
+    public WorkflowLoader(Context context) {
+        super(context);
+        ctx = context;
+    }
+
+    @Override
+    public List<Workflow> loadInBackground() {
+         userWorkflows = new ArrayList<Workflow>();
+        //start a network request to fetch user's workflows
+        try {
+            URL workflowurl = new URL(TavernaPlayerAPI.PLAYER_URL+"workflows");
+            HttpURLConnection connection = (HttpURLConnection) 
workflowurl.openConnection();
+            connection.setDoInput(true);
+            connection.setDoOutput(true);
+            connection.setUseCaches(false);
+            connection.setRequestProperty("Accept","application/json");
+            connection.setRequestMethod("GET");
+            connection.connect(); //send request
+
+//            DataInputStream dis = new 
DataInputStream(connection.getInputStream());
+            InputStream dis = connection.getInputStream();
+            BufferedReader br = new BufferedReader(new InputStreamReader(dis));
+            StringBuffer sb = new StringBuffer();
+            String jsonData = "";
+            while((jsonData = br.readLine()) != null){
+                sb.append(jsonData);
+            }
+            dis.close();
+            br.close();
+            JSONArray jsonWorkflow = new JSONArray(sb.toString());
+            for(int i=0; i<jsonWorkflow.length();i++){
+                JSONObject js = jsonWorkflow.getJSONObject(i);
+                String author = js.getString("author");
+                String title = js.getString("title");
+                String description = js.getString("description");
+                long id = js.getLong("id");
+                userWorkflows.add(new 
Workflow(ctx,title,author,description,id,""));
+            }
+
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+
+        return userWorkflows;
+    }
+
+    @Override
+    public void onCanceled(List<Workflow> data) {
+        super.onCanceled(data);
+    }
+
+    @Override
+    public boolean isStarted() {
+        return super.isStarted();
+    }
+
+    @Override
+    protected void onStartLoading() {
+        //if there is data available, deliver it at once
+        if(userWorkflows != null)
+            deliverResult(userWorkflows);
+        else{
+            forceLoad();
+        }
+    }
+
+    @Override
+    public void deliverResult(List<Workflow> data) {
+        if(isStarted()){
+            super.deliverResult(data);
+        }
+    }
+
+    @Override
+    protected void onStopLoading() {
+        cancelLoad();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowRunHelper.java
----------------------------------------------------------------------
diff --git 
a/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowRunHelper.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowRunHelper.java
new file mode 100644
index 0000000..f450bca
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/WorkflowRunHelper.java
@@ -0,0 +1,30 @@
+package org.apache.taverna.mobile.utils;
+/**
+ * Apache Taverna Mobile
+ * Copyright 2015 The Apache Software Foundation
+
+ * This product includes software developed at
+ * The Apache Software Foundation (http://www.apache.org/).
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Created by root on 6/11/15.
+ */
+public class WorkflowRunHelper {
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/java/org/apache/taverna/mobile/utils/Workflow_DB.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/taverna/mobile/utils/Workflow_DB.java 
b/app/src/main/java/org/apache/taverna/mobile/utils/Workflow_DB.java
new file mode 100644
index 0000000..a82f214
--- /dev/null
+++ b/app/src/main/java/org/apache/taverna/mobile/utils/Workflow_DB.java
@@ -0,0 +1,266 @@
+package org.apache.taverna.mobile.utils;
+/**
+ * Apache Taverna Mobile
+ * Copyright 2015 The Apache Software Foundation
+
+ * This product includes software developed at
+ * The Apache Software Foundation (http://www.apache.org/).
+
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+/**
+ * @author Larry Akah
+ * @version 1.0.0
+ * This class is developed as a means to simplify the code base of the initial 
json_db implementation.
+ * It aims at using fully the java JSON API available to implement the CRUD 
functionality of the json_db library.
+ * This class is much more scalable and light-weight than the first 
implementation
+ */
+public class Workflow_DB {
+       
+       private String ENTITY_KEY;
+       private Context context;
+       private SharedPreferences msharedpreference;
+       private ArrayList<String> ITEM_IDS;
+       private final String LIBTAG = getClass().getName();
+       private JSONObject DBJSON;
+       private JSONObject dataobj; //hold all entries for a given ENTITY_KEY
+       
+       /**
+        * Constructor initializes a basic data store environment
+        * @param ctx a reference to the application's context or sand box
+        * @param entityKey The main data store key for each entity space/schema
+        */
+       public Workflow_DB(Context ctx, String entityKey){
+               context = ctx;
+               ENTITY_KEY = entityKey;
+               DBJSON = new JSONObject();
+               ITEM_IDS = new ArrayList<String>();
+               dataobj = DBJSON;
+       }
+       
+       /**
+        * Inserts an entity set('row') into the data store
+        * @param items values for each 'column' in the entity
+        * @return the same instance for chaining multiple calls to this method.
+        * @throws org.json.JSONException
+        */
+       public Workflow_DB put(ArrayList<Object> items) throws JSONException{
+
+               String item_id = this.generateRandomId();
+               ITEM_IDS.add(item_id);
+               JSONArray jarray = new JSONArray();
+               for(Object item: items){
+                       jarray.put(item);
+               }
+               dataobj.put(item_id, jarray);
+               Log.d(LIBTAG, ""+dataobj.toString(2));
+               return this;
+       }
+       
+       /**
+        * Returns all entity entries from the data store. Each item of an 
entity is accompanied with the key or unique id of the items.
+        * @author Larry Akah
+        * @throws org.json.JSONException for errors during construction of a 
JSON data string.
+        * @throws NullPointerException for any null accessed variable
+        */
+       public List<ArrayList<Object>> get() throws JSONException , 
NullPointerException{
+                               msharedpreference = 
PreferenceManager.getDefaultSharedPreferences(context);
+                               //read key and get existing data
+                               List<ArrayList<Object>> results = new 
ArrayList<ArrayList<Object>>();
+                               JSONObject mainJson = new 
JSONObject(msharedpreference.getString(ENTITY_KEY, ENTITY_KEY+":{}"));
+                               
+                               Log.i(ENTITY_KEY, mainJson.toString(2));
+                               
+                               JSONArray keysJson = 
mainJson.getJSONArray("ids"); //retrieve a json array of ids for every entity 
entry
+                               Log.i(ENTITY_KEY, keysJson.toString(2));
+                               
+                               if(null != keysJson)
+                                       for(int i=0; i<keysJson.length(); i++){
+                                               //for each key, get the 
associated data
+                                               try {
+                                                       JSONArray resultArray = 
mainJson.getJSONArray(keysJson.getString(i));
+                                                       ArrayList<Object> mlist 
= new ArrayList<Object>();
+                                                       if(null != resultArray)
+                                                               for(int j=0; 
j<resultArray.length(); j++){
+                                                                       
mlist.add(resultArray.getString(j));
+                                                                       
+                                                               }
+                                                       
mlist.add(keysJson.getString(i)); // adds the entry key as last value of the 
data returned
+                                                       results.add(mlist);
+                                               } catch (Exception e) {
+                                                       e.printStackTrace();
+                                                       continue;
+                                               }
+                                       }
+                               return results;
+       }
+       
+       /**
+        * updates a single item entry of an entity
+        * @param itemId provides the id of the item to be updated
+        * @param newItem the new set of data to be used to update the entry 
+        * @return boolean indicating whether the item was successfully updated 
or not. True means item was updated, false means otherwise.
+        */
+       public boolean update(String itemId, ArrayList<Object> newItem){
+               boolean operationSucceeded = false;
+               
+               JSONArray jarray = new JSONArray();
+               for(Object item: newItem){
+                       jarray.put(item);
+               }
+               try {
+                       dataobj.put(itemId, jarray); //replace the current 
entry at the given ID.
+                       Log.d(LIBTAG, ""+dataobj.toString(2));
+                       operationSucceeded = true;
+               } catch (JSONException e) {
+                       e.printStackTrace();
+                       operationSucceeded = false;
+               }finally{
+                       return operationSucceeded;
+               }
+       }
+       
+       /**
+        * Updates all the items of a given entity
+        * @return the number of items successfully updated.
+        */
+       public int updateAll(List<ArrayList<String>> items){
+               return 0;
+       }
+       
+       /**
+        * Gets an entry of an entity from the data store
+        * @author Larry Akah
+        * @param id The id of the item('row') in question to return
+        * @throws org.json.JSONException for errors during construction of a 
JSON data string.
+        * @throws NullPointerException for any null accessed variable
+        */
+       public ArrayList<Object> get(String id) throws JSONException , 
NullPointerException{
+                               msharedpreference = 
PreferenceManager.getDefaultSharedPreferences(context);
+                               //read key and get existing data
+                               ArrayList<Object> results = new 
ArrayList<Object>();
+                               JSONObject mainJson = new 
JSONObject(msharedpreference.getString(ENTITY_KEY, ENTITY_KEY+":{}"));
+                               
+                               Log.i(ENTITY_KEY, mainJson.toString(2));
+                               
+                               JSONArray keysJson = 
mainJson.getJSONArray("ids"); //retrieve a json array of ids for every entity 
entry
+                               Log.i(ENTITY_KEY, keysJson.toString(2));
+                               
+                               if(null != keysJson)
+                                       for(int i=0; i<keysJson.length(); i++){
+                                               //for each key, get the 
associated data
+                                               try {
+                                                       JSONArray resultArray = 
mainJson.getJSONArray(keysJson.getString(i));
+                                                       if(null != resultArray)
+                                                               for(int j=0; 
j<resultArray.length(); j++){
+                                                                       
results.add(resultArray.getString(j));
+                                                               }
+                                               } catch (Exception e) {
+                                                       e.printStackTrace();
+                                                       continue;
+                                               }
+                                       }
+                               return results;
+       }
+       
+       /**
+        * Persists all data by making the data permanent in the preference 
file on the fileSystem
+        * Save all id's in a different preference
+        * @author Larry Akah
+        * @return true or false indicating whether the save was successful or 
not
+        */
+       public boolean save(){          
+               msharedpreference = 
PreferenceManager.getDefaultSharedPreferences(context);
+               boolean saved = false;
+               if(dataobj != null)
+                       try {
+                               saved = saveid(ITEM_IDS);
+                               if(saved)
+                                       
msharedpreference.edit().putString(ENTITY_KEY, dataobj.toString()).apply();
+                                       return saved;
+                       } catch (JSONException e) {
+                               e.printStackTrace();
+                               return false;
+                       }
+               else
+                       return false;
+       }
+       
+       /**
+        * save the ids of all entity entries
+        * @author Larry Akah
+        * @param ids A list of auto-generated ids that point to each set of 
entity data in the data store
+        * @throws org.json.JSONException
+        */
+       private boolean saveid(ArrayList<String> ids) throws JSONException{
+               JSONArray jarray = new JSONArray();
+               for(Object item: ids){
+                       jarray.put(item);
+               }
+               dataobj.put("ids", jarray);
+               
+               return jarray.length() == ids.size()? true:false;
+       }
+       
+       /**
+        * Removes an item from an entity entry
+        * @author Larry Akah
+        * @throws org.json.JSONException
+        */
+       public Workflow_DB delete(String itemID) throws JSONException{
+               SharedPreferences sp = 
PreferenceManager.getDefaultSharedPreferences(context);
+               JSONObject dbjson = new JSONObject(sp.getString(ENTITY_KEY, 
ENTITY_KEY+":{}"));
+               
+               JSONArray currentkeys = dbjson.getJSONArray("ids");
+               JSONArray newKeys = DB_Utility.removeKey(currentkeys, itemID);
+
+               dbjson.put("ids", newKeys);
+               sp.edit().putString(ENTITY_KEY, dbjson.toString()).apply();
+               
+               return this;
+       }
+       /**
+        * Removes all items from an entity
+        * @author Larry Akah
+        */
+       public int bulkDelete(String entity_key){
+               
+               return 0;
+       }
+       
+       /**
+        * Generates a random hexadecimal string to be used as ids for 
identifying each entry of an entity item. Proven to be collision resistant 
enough accross API KEYS
+        * @author Larry Akah
+        */
+       private String generateRandomId(){
+               return UUID.randomUUID().toString();
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/res/layout/fragment_item_list.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/layout/fragment_item_list.xml 
b/app/src/main/res/layout/fragment_item_list.xml
index d6050f1..8bc7719 100644
--- a/app/src/main/res/layout/fragment_item_list.xml
+++ b/app/src/main/res/layout/fragment_item_list.xml
@@ -31,7 +31,8 @@ limitations under the License.
 
     </android.support.v7.widget.RecyclerView>
 
-    <TextView android:id="@android:id/empty"
+    <TextView
+        android:id="@android:id/empty"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:gravity="center"

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/res/layout/workflow_item_layout.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/layout/workflow_item_layout.xml 
b/app/src/main/res/layout/workflow_item_layout.xml
index 0f01d93..aca2422 100644
--- a/app/src/main/res/layout/workflow_item_layout.xml
+++ b/app/src/main/res/layout/workflow_item_layout.xml
@@ -45,13 +45,18 @@ limitations under the License.
                 android:layout_height="wrap_content"
                 android:elevation="5dp"
                 android:src="@mipmap/icuserprofiles"
-                android:background="@drawable/round_shape"/>
+                android:background="@drawable/round_shape"
+                android:contentDescription="@string/workflow_authorhint" />
 
         <LinearLayout
                 android:id="@+id/linearlayout_workflow_info"
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:orientation="vertical">
+                android:orientation="vertical"
+            android:showDividers="middle|beginning"
+            android:divider="@color/background_material_dark"
+            android:dividerPadding="2dp"
+            android:layout_marginLeft="2dp">
                 <TextView
                     android:id="@+id/workflow_author"
                     android:layout_width="match_parent"
@@ -62,42 +67,59 @@ limitations under the License.
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="Large Text"
-                android:id="@+id/workflow_datecreated" />
+                android:id="@+id/workflow_title"
+                android:hint="@string/wktitle" />
 
             <TextView
-                android:layout_width="wrap_content"
+                android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="Large Text"
-                android:id="@+id/workflow_dateupdated"
-                android:layout_gravity="center_vertical" />
+                android:text="@string/abc_activity_chooser_view_see_all"
+                android:id="@+id/show_more"
+                android:typeface="serif"
+                android:background="@color/material_deep_teal_200" />
+        </LinearLayout>
+    </LinearLayout>
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            android:visibility="gone"
+            android:id="@+id/layoutinfo"
+            android:showDividers="middle|beginning"
+            android:dividerPadding="1dp">
 
             <TextView
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="Large Text"
-                android:id="@+id/workflow_title" />
+                android:text="@string/created"
+                android:id="@+id/workflow_datecreated"
+                android:gravity="center" />
 
             <TextView
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:textAppearance="?android:attr/textAppearanceLarge"
-                android:text="See more"
-                android:id="@+id/show_more"
-                android:typeface="serif"
-                android:background="@color/material_deep_teal_200" />
-
+                android:text="@string/modified"
+                android:id="@+id/workflow_dateupdated"
+                android:layout_gravity="center_vertical"
+                android:gravity="center" />
+            <TextView
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:textAppearance="?android:attr/textAppearanceLarge"
+                android:minLines="2"
+                android:id="@+id/workflow_brief_description"
+                android:layout_gravity="center_vertical"
+                android:hint="@string/description" />
         </LinearLayout>
-
-    </LinearLayout>
         <ImageView
             android:id="@+id/workflow_image"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:src="@drawable/tavernalogo"
-            android:background="@color/highlighted_text_material_light"/>
+            android:contentDescription="@string/workflow_component" />
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content">

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/app/src/main/res/values/strings.xml
----------------------------------------------------------------------
diff --git a/app/src/main/res/values/strings.xml 
b/app/src/main/res/values/strings.xml
index 911aa38..3cf57d4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -61,6 +61,7 @@ limitations under the License.
     <string name="marked">Marked On</string>
     <string name="created">Workflow Created On:</string>
     <string name="modified">Modified On:</string>
+    <string name="description">Workflow Description</string>
     <string name="title_activity_workflow_detail">Workflow Detail</string>
 
 
@@ -69,5 +70,12 @@ limitations under the License.
     <string name="detail_title_section3">Licence | Policy</string>
     <string name="detail_title_section4"> About </string>
     <string name="play_workflow">Run</string>
+    
+    <string name="downloadfailed">Download Failed. Please try again</string>
+    <string name="downloadprogress">Workflow download in progress</string>
+    <string name="downloaderror">Unable to start Download. Check your internet 
connectivity</string>
+    <string name="downloadduplicate">Already Downloading</string>
+    <string name="downloadcomplete">  download complete</string>
+    <string name="seemore"> See more &amp;raquo</string>
 
 </resources>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/7e5b3591/build/intermediates/model_data.bin
----------------------------------------------------------------------
diff --git a/build/intermediates/model_data.bin 
b/build/intermediates/model_data.bin
index 2ce9e58..fcd55ef 100644
Binary files a/build/intermediates/model_data.bin and 
b/build/intermediates/model_data.bin differ

Reply via email to