2012-09-13 Santiago Munín <burning1@gmail.com>

* src/pandroid_event_viewer/pandorafms/EventList.java: Now, if an element is validated, his color changes to green.
	* src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java: Now it returns a result (validated or not) which will be processed for the activity which called it. 
	* res/values/colors.xml: Added colors to values instead of hardcoding them.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6973 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
santimunin 2012-09-13 17:28:04 +00:00
parent c97e3b6f97
commit 1fcb387ac7
4 changed files with 90 additions and 46 deletions

View File

@ -1,3 +1,8 @@
2012-09-13 Santiago Munín <burning1@gmail.com>
* src/pandroid_event_viewer/pandorafms/EventList.java: Now, if an element is validated, his color changes to green.
* src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java: Now it returns a result (validated or not) which will be processed for the activity which called it.
* res/values/colors.xml: Added colors to values instead of hardcoding them.
2012-09-13 Miguel de Dios <miguel.dedios@artica.es>
* res/drawable-ldpi/criticity_0.png,

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<resources>
<color name="Green">#BBFFA4</color>
<color name="Blue">#CDE2EA</color>
<color name="Grey">#E4E4E4</color>
<color name="Yellow">#F4FFBF</color>
<color name="Red">#FFC0B5</color>
</resources>

View File

@ -28,7 +28,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
@ -63,12 +62,14 @@ public class EventList extends ListActivity {
private static int DEFAULT_PRIORITY_CODE = 0;
private static String DEFAULT_SOURCE = "Pandora FMS Event";
private static final int CREATE_INCIDENT_DIALOG = 1;
private static final int VALIDATE_EVENT_ACTIVITY = 0;
private ListView lv;
private MyAdapter la;
private PandroidEventviewerActivity object;
private BroadcastReceiver onBroadcast;
private Dialog creatingIncidentDialog;
private Context context = this;
private View currentElement;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -232,8 +233,10 @@ public class EventList extends ListActivity {
context, "",
getString(R.string.creating_incident),
true);
String title = titleEditText.getText().toString();
String description = descriptionEditText.getText().toString();
String title = titleEditText.getText()
.toString();
String description = descriptionEditText
.getText().toString();
new SetNewIncidentAsyncTask().execute(title,
description, group);
} else {
@ -292,6 +295,25 @@ public class EventList extends ListActivity {
object.executeBackgroundGetEvents(true);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VALIDATE_EVENT_ACTIVITY) {
if (resultCode == RESULT_OK) {
String text;
if (data.getExtras().getBoolean("validated")) {
currentElement.setBackgroundColor(getResources().getColor(
R.color.Green));
text = getApplicationContext().getString(
R.string.successful_validate_event_str);
} else {
text = getApplicationContext().getString(
R.string.fail_validate_event_str);
}
Toast.makeText(getApplicationContext(), text,
Toast.LENGTH_SHORT).show();
}
}
}
/**
* Private adapter (event list).
*
@ -375,23 +397,29 @@ public class EventList extends ListActivity {
switch (item.criticity) {
case 0:// Blue
view.setBackgroundColor(Color.parseColor("#CDE2EA"));
case 0:
view.setBackgroundColor(getResources().getColor(
R.color.Blue));
break;
case 1:// Grey
view.setBackgroundColor(Color.parseColor("#E4E4E4"));
case 1:
view.setBackgroundColor(getResources().getColor(
R.color.Grey));
break;
case 2:// Green
view.setBackgroundColor(Color.parseColor("#BBFFA4"));
case 2:
view.setBackgroundColor(getResources().getColor(
R.color.Green));
break;
case 3:// Yellow
view.setBackgroundColor(Color.parseColor("#F4FFBF"));
case 3:
view.setBackgroundColor(getResources().getColor(
R.color.Yellow));
break;
case 4:// Red
view.setBackgroundColor(Color.parseColor("#FFC0B5"));
case 4:
view.setBackgroundColor(getResources()
.getColor(R.color.Red));
break;
default:// Grey
view.setBackgroundColor(Color.parseColor("#E4E4E4"));
default:
view.setBackgroundColor(getResources().getColor(
R.color.Grey));
break;
}
@ -457,8 +485,9 @@ public class EventList extends ListActivity {
}
if (item.user_comment.length() != 0) {
if (item.user_comment.length()> 200) {
item.user_comment = item.user_comment.substring(0, 197);
if (item.user_comment.length() > 200) {
item.user_comment = item.user_comment.substring(0,
197);
item.user_comment = item.user_comment.concat("...");
}
text = (TextView) viewEventExtended
@ -524,8 +553,9 @@ public class EventList extends ListActivity {
text.setText("");
text.setVisibility(TextView.VISIBLE);
} else if (item.status != 1) {
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate();
clickListener.id_event = item.id_event;
currentElement = view;
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate(
item.id_event);
button.setOnClickListener(clickListener);
text = (TextView) viewEventExtended
.findViewById(R.id.validate_event_label);
@ -643,13 +673,17 @@ public class EventList extends ListActivity {
*
*/
private class OnClickListenerButtonValidate implements OnClickListener {
public int id_event;
private int idEvent;
public OnClickListenerButtonValidate(int idEvent) {
this.idEvent = idEvent;
}
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(),
PopupValidationEvent.class);
i.putExtra("id_event", id_event);
startActivity(i);
i.putExtra("id_event", idEvent);
startActivityForResult(i, VALIDATE_EVENT_ACTIVITY);
}
}
}

View File

@ -26,7 +26,6 @@ import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;
/**
* Provides the functionality necessary to validate an event.
@ -73,14 +72,7 @@ public class PopupValidationEvent extends Activity {
}
/**
* Finish the activity
*/
private void destroyPopup() {
finish();
}
/**
* Sends a validation (async task)
* Sends a validation request (async task)
*
* @author Miguel de Dios Matías
*
@ -90,7 +82,6 @@ public class PopupValidationEvent extends Activity {
private boolean connectionProblem = false;
@Override
protected Boolean doInBackground(Void... params) {
int idEvent = Integer.valueOf(id_event);
try {
@ -100,26 +91,17 @@ public class PopupValidationEvent extends Activity {
connectionProblem = true;
return false;
}
}
@Override
protected void onPostExecute(Boolean result) {
String text;
if (connectionProblem) {
Core.showConnectionProblemToast(getApplicationContext(), true);
} else {
if (result) {
text = getApplicationContext().getString(
R.string.successful_validate_event_str);
} else {
text = getApplicationContext().getString(
R.string.fail_validate_event_str);
}
Toast toast = Toast.makeText(getApplicationContext(), text,
Toast.LENGTH_SHORT);
toast.show();
destroyPopup();
Intent resultIntent = new Intent();
resultIntent.putExtra("validated", result);
setResult(RESULT_OK, resultIntent);
finish();
}
}
}