From 8d965c519c4d1aea6ad3bdf4719f6652d4acb354 Mon Sep 17 00:00:00 2001 From: santimunin Date: Mon, 25 Jun 2012 15:40:26 +0000 Subject: [PATCH] 2012-06-25 Santiago Munin * src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java: Fixed a UI bug and refactorized the API call. * src/pandroid_event_viewer/pandorafms/API.java: Added create incident. * res/layout/main.xml: Little UI changes. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6702 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- extras/pandroid_event_viewer/ChangeLog | 11 +++++ .../pandroid_event_viewer/res/layout/main.xml | 22 ++++++--- .../pandroid_event_viewer/pandorafms/API.java | 18 +++++++ .../pandorafms/CreateIncidentActivity.java | 49 +++++++++---------- 4 files changed, 66 insertions(+), 34 deletions(-) diff --git a/extras/pandroid_event_viewer/ChangeLog b/extras/pandroid_event_viewer/ChangeLog index fcd7fa6882..7e0dad6a23 100644 --- a/extras/pandroid_event_viewer/ChangeLog +++ b/extras/pandroid_event_viewer/ChangeLog @@ -1,22 +1,33 @@ +2012-06-25 Santiago Munín + + * src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java: Fixed a UI bug and refactorized the API call. + * src/pandroid_event_viewer/pandorafms/API.java: Added create incident. + * res/layout/main.xml: Little UI changes. + 2012-06-24 Santiago Munín + * src/pandroid_event_viewer/pandorafms/Main.java: Removed getGroups function, now it calls API.getGroups(). 2012-06-24 Santiago Munín + * src/pandroid_event_viewer/pandorafms/Main.java: Added search profiles feature. * res/layout/main.xml: UI changes. Added search profiles feature. * res/values/strings.xml: Added new entries. 2012-06-23 Santiago Munín + * src/pandroid_event_viewer/pandorafms/Core.java: Fixed a bug in the isOnline() function. * src/pandroid_event_viewer/pandorafms/Options.java: Improved the connection checking functionality. * src/pandroid_event_viewer/pandorafms/API.java: Added getTags(). * src/pandroid_event_viewer/pandorafms/Main.java: Now the tags are getted by API.getTags(). 2012-06-21 Santiago Munín + * src/pandroid_event_viewer/pandorafms/Core.java: Added a new method which checks if a website is online. * src/pandroid_event_viewer/pandorafms/Options.java: Fixed a bug. The app didn't check if the url were online before checking the certificate. 2012-06-21 Santiago Munín + * src/pandroid_event_viewer/pandorafms/EventList.java: Restored to the previous version. * src/pandroid_event_viewer/pandorafms/Core.java: Added a line which checks if the connection is secure. * src/pandroid_event_viewer/pandorafms/Options.java: Made some changes in certificate checking. diff --git a/extras/pandroid_event_viewer/res/layout/main.xml b/extras/pandroid_event_viewer/res/layout/main.xml index 6bcb2d45c9..3b5e5086c0 100644 --- a/extras/pandroid_event_viewer/res/layout/main.xml +++ b/extras/pandroid_event_viewer/res/layout/main.xml @@ -26,7 +26,8 @@ + android:layout_height="wrap_content" + android:layout_marginTop="10dp" > + android:text="@string/profile_label_str" + android:textStyle="bold" /> - + android:contentDescription="@string/profile_delete" + android:src="@drawable/cross" /> + + diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/API.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/API.java index 894d2636ed..b5b57727f3 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/API.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/API.java @@ -138,4 +138,22 @@ public class API { } return array; } + + /** + * Creates new incident in console. + * @param context Application context + * @param incidentParameters Incident data + */ + public static void createNewIncident(Context context, + String[] incidentParameters) { + Log.i(TAG, "Sending new incident"); + List parameters = new ArrayList(); + parameters.add(new BasicNameValuePair("op", "set")); + parameters.add(new BasicNameValuePair("op2", "new_incident")); + parameters.add(new BasicNameValuePair("other_mode", + "url_encode_separator_|")); + parameters.add(new BasicNameValuePair("other", Core + .serializeParams2Api(incidentParameters))); + Core.httpGet(context, parameters); + } } \ No newline at end of file diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java index 7f897a4dfe..e00e0ff115 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java @@ -1,12 +1,7 @@ package pandroid_event_viewer.pandorafms; -import java.util.ArrayList; -import java.util.List; import java.util.Map.Entry; -import org.apache.http.NameValuePair; -import org.apache.http.message.BasicNameValuePair; - import android.app.Activity; import android.app.ProgressDialog; import android.os.AsyncTask; @@ -86,14 +81,11 @@ public class CreateIncidentActivity extends Activity { /** * Performs the create incident petition. + * + * @return true if it is created. */ - private void sendNewIncident() { + private boolean sendNewIncident() { Log.i(TAG, "Sending new incident"); - List parameters = new ArrayList(); - parameters.add(new BasicNameValuePair("op", "set")); - parameters.add(new BasicNameValuePair("op2", "new_incident")); - parameters.add(new BasicNameValuePair("other_mode", - "url_encode_separator_|")); String incidentParams[] = new String[6]; incidentParams[0] = title.getText().toString(); incidentParams[1] = description.getText().toString(); @@ -110,14 +102,10 @@ public class CreateIncidentActivity extends Activity { if (groupCode >= 0) { incidentParams[5] = String.valueOf(groupCode); } else { - Toast.makeText(getApplicationContext(), - R.string.create_incident_group_error, Toast.LENGTH_SHORT) - .show(); - finish(); + return false; } - parameters.add(new BasicNameValuePair("other", Core - .serializeParams2Api(incidentParams))); - Core.httpGet(getApplicationContext(), parameters); + API.createNewIncident(getApplicationContext(), incidentParams); + return true; } /** @@ -126,20 +114,27 @@ public class CreateIncidentActivity extends Activity { * @author Santiago Munín González * */ - private class SetNewIncidentAsyncTask extends AsyncTask { + private class SetNewIncidentAsyncTask extends + AsyncTask { @Override - protected Void doInBackground(Void... params) { - sendNewIncident(); - return null; + protected Boolean doInBackground(Void... params) { + return sendNewIncident(); } @Override - protected void onPostExecute(Void result) { - Toast.makeText(getApplicationContext(), R.string.incident_created, - Toast.LENGTH_SHORT).show(); - dialog.dismiss(); - finish(); + protected void onPostExecute(Boolean result) { + if (result) { + Toast.makeText(getApplicationContext(), + R.string.incident_created, Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + finish(); + } else { + Toast.makeText(getApplicationContext(), + R.string.create_incident_group_error, + Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + } } } } \ No newline at end of file