Repository: incubator-taverna-mobile Updated Branches: refs/heads/master 5fc1a69c9 -> 04f429483
Filter and validate workflows when seelcting from storage to run on server Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/commit/10e5e427 Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/tree/10e5e427 Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/diff/10e5e427 Branch: refs/heads/master Commit: 10e5e4275c69df3d06d7712943c1f96ebf7e41d2 Parents: d540f9e Author: larrytech7 <larrya...@gmail.com> Authored: Sat Jul 18 12:08:50 2015 +0100 Committer: larrytech7 <larrya...@gmail.com> Committed: Sat Jul 18 12:08:50 2015 +0100 ---------------------------------------------------------------------- .../activities/DashboardMainActivity.java | 29 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-taverna-mobile/blob/10e5e427/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 2afab50..de8f542 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 @@ -45,6 +45,7 @@ import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.webkit.MimeTypeMap; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; @@ -125,7 +126,7 @@ public class DashboardMainActivity extends ActionBarActivity "application/vnd.taverna.t2flow+xml"); Intent loadWorkflowIntent = Intent.createChooser(workflowSelectIntent, - "Choose Workflow (.t2flow)"); + "Choose Workflow (t2flow or xml)"); startActivityForResult(loadWorkflowIntent, SELECT_WORKFLOW); break; @@ -161,12 +162,33 @@ public class DashboardMainActivity extends ActionBarActivity if(resultCode == RESULT_OK){ if(requestCode == SELECT_WORKFLOW){ String workflowPath = data.getData().getPath(); - Toast.makeText(getBaseContext(), "Path: "+workflowPath, Toast.LENGTH_LONG).show(); - new WorkflowOpen(this).execute(workflowPath); + // Toast.makeText(getBaseContext(), "Path: "+workflowPath, Toast.LENGTH_LONG).show(); + String type = getMimeType(data.getData().getPath()); + if (type == "text/xml" || type == "application/vnd.taverna.t2flow+xml"){ + + new WorkflowOpen(this).execute(workflowPath); + }else { + Toast.makeText(getBaseContext(), "Invalid worklow. Please try again", Toast.LENGTH_LONG).show(); + + } } } } + /** + * Return the mimetype of the file selected to be run as a workflow + * @param url the path to the seleted file + * @return the mimetype of the file selected + */ + private String getMimeType(String url) { + String type = null; + String extension = MimeTypeMap.getFileExtensionFromUrl(url); + if (extension != null) { + type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + } + return type; + } + public void onSectionAttached(int number) { switch (number) { case 1: @@ -231,6 +253,7 @@ public class DashboardMainActivity extends ActionBarActivity // Toast.makeText(context, "Home dir: "+home.getAbsolutePath(), Toast.LENGTH_LONG).show(); } } + @Override public boolean onCreateOptionsMenu(Menu menu) { if (!mNavigationDrawerFragment.isDrawerOpen()) {