From 0032039a22e8c55c8400c75dcbfb48d8ae42f398 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 9 Dec 2013 13:36:38 +0000 Subject: [PATCH] 2013-12-09 Miguel de Dios * src/pandroid_event_viewer/pandorafms/EventList.java: fixed the incident dialog when two times. * src/pandroid_event_viewer/pandorafms/Options.java: updated the api password for the pandora_demo in firefly. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9194 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- extras/pandroid_event_viewer/ChangeLog | 8 +++ .../pandorafms/EventList.java | 52 +++++++++++++++---- .../pandorafms/Options.java | 3 +- 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/extras/pandroid_event_viewer/ChangeLog b/extras/pandroid_event_viewer/ChangeLog index f7a54238ab..d140e64306 100644 --- a/extras/pandroid_event_viewer/ChangeLog +++ b/extras/pandroid_event_viewer/ChangeLog @@ -1,3 +1,11 @@ +2013-12-09 Miguel de Dios + + * src/pandroid_event_viewer/pandorafms/EventList.java: fixed the + incident dialog when two times. + + * src/pandroid_event_viewer/pandorafms/Options.java: updated the + api password for the pandora_demo in firefly. + 2013-12-09 Miguel de Dios * src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java, diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java index eabeaa150e..a8f3d312d5 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java @@ -19,8 +19,11 @@ package pandroid_event_viewer.pandorafms; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Map.Entry; import java.util.Date; +import java.util.Map.Entry; + +import org.json.JSONArray; +import org.json.JSONObject; import android.app.Activity; import android.app.Dialog; @@ -28,6 +31,9 @@ import android.app.ListActivity; import android.app.TabActivity; import android.content.BroadcastReceiver; import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnCancelListener; +import android.content.DialogInterface.OnDismissListener; import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; @@ -54,9 +60,6 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; -import org.json.JSONArray; -import org.json.JSONObject; - /** * Activity where events are displayed. * @@ -223,12 +226,13 @@ public class EventList extends ListActivity { return true; } - + @Override protected Dialog onCreateDialog(int id, Bundle args) { switch (id) { case CREATE_INCIDENT_DIALOG: final String group; + creatingIncidentDialog = new Dialog(this); creatingIncidentDialog.setContentView(R.layout.create_incident); creatingIncidentDialog.setTitle(getString(R.string.create_incident)); @@ -236,6 +240,12 @@ public class EventList extends ListActivity { .findViewById(R.id.incident_title); final EditText descriptionEditText = (EditText) creatingIncidentDialog .findViewById(R.id.incident_description); + + Log.e("onCreateDialog", + "Group: " + args.getString("group") + + "Title: " + args.getString("title") + + "Description: " + args.getString("description")); + String temp = args.getString("title"); if (temp != null) { @@ -253,6 +263,7 @@ public class EventList extends ListActivity { else { group = ""; } + creatingIncidentDialog.findViewById(R.id.incident_create_button) .setOnClickListener(new OnClickListener() { @@ -266,6 +277,8 @@ public class EventList extends ListActivity { .getText().toString(); new SetNewIncidentAsyncTask().execute(title, description, group); + + removeDialog(CREATE_INCIDENT_DIALOG); } else { Toast.makeText(getApplicationContext(), @@ -274,6 +287,21 @@ public class EventList extends ListActivity { } } }); + + + creatingIncidentDialog.setOnDismissListener( + new OnDismissListener() { + + @Override + public void onDismiss(DialogInterface dialog) { + removeDialog(CREATE_INCIDENT_DIALOG); + } + } + ); + + + + return creatingIncidentDialog; } return null; @@ -568,7 +596,8 @@ public class EventList extends ListActivity { comments = comments + mJsonObject.getString("action") + " by " + mJsonObject.getString("id_user") + "\n"; comments = comments + "\"" + mJsonObject.getString("comment") + "\"" + "\n\n"; } - } catch (Exception e) { + } + catch (Exception e) { // If comment is not stored as JSON (old format), clean it and show it as stored item.user_comment = item.user_comment.replaceAll("^-- ", "\n"); item.user_comment = item.user_comment.replaceAll(" --$", "\n"); @@ -633,7 +662,7 @@ public class EventList extends ListActivity { button = (Button) viewEventExtended .findViewById(R.id.validate_button_extended); if (item.status == -1) { - // For unknow events + // For unknown events button.setVisibility(Button.GONE); text = (TextView) viewEventExtended .findViewById(R.id.validate_event_label); @@ -642,8 +671,8 @@ public class EventList extends ListActivity { } else if (item.status != 1) { currentElement = view; - OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate( - item.id_event); + OnClickListenerButtonValidate clickListener = + new OnClickListenerButtonValidate(item.id_event); button.setOnClickListener(clickListener); text = (TextView) viewEventExtended .findViewById(R.id.validate_event_label); @@ -657,8 +686,11 @@ public class EventList extends ListActivity { b.putString("group", item.group_name); b.putString("title", item.event); b.putString("description", ""); + showDialog(CREATE_INCIDENT_DIALOG, b); - Log.e("TEST", "TEST"); + Log.e("CREATE_INCIDENT", + "Group: " + item.group_name + + "Title: " + item.event); } }); } diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java index e1f5c3ebc3..c6b5af944b 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java @@ -75,6 +75,7 @@ public class Options extends Activity { SharedPreferences preferences = getSharedPreferences( this.getString(R.string.const_string_preferences), Activity.MODE_PRIVATE); + // Connection EditText text = (EditText) findViewById(R.id.url); text.setText(preferences.getString("url", @@ -84,7 +85,7 @@ public class Options extends Activity { text = (EditText) findViewById(R.id.password); text.setText(preferences.getString("password", "demo")); text = (EditText) findViewById(R.id.api_password); - text.setText(preferences.getString("api_password", "m1gu3l")); + text.setText(preferences.getString("api_password", "1234")); text = (EditText) findViewById(R.id.timeout_connections); text.setText(Integer.toString(preferences.getInt("timeout_connections", 10)));