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:
parent
c97e3b6f97
commit
1fcb387ac7
|
@ -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>
|
2012-09-13 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* res/drawable-ldpi/criticity_0.png,
|
* res/drawable-ldpi/criticity_0.png,
|
||||||
|
|
|
@ -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>
|
|
@ -28,7 +28,6 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
@ -63,12 +62,14 @@ public class EventList extends ListActivity {
|
||||||
private static int DEFAULT_PRIORITY_CODE = 0;
|
private static int DEFAULT_PRIORITY_CODE = 0;
|
||||||
private static String DEFAULT_SOURCE = "Pandora FMS Event";
|
private static String DEFAULT_SOURCE = "Pandora FMS Event";
|
||||||
private static final int CREATE_INCIDENT_DIALOG = 1;
|
private static final int CREATE_INCIDENT_DIALOG = 1;
|
||||||
|
private static final int VALIDATE_EVENT_ACTIVITY = 0;
|
||||||
private ListView lv;
|
private ListView lv;
|
||||||
private MyAdapter la;
|
private MyAdapter la;
|
||||||
private PandroidEventviewerActivity object;
|
private PandroidEventviewerActivity object;
|
||||||
private BroadcastReceiver onBroadcast;
|
private BroadcastReceiver onBroadcast;
|
||||||
private Dialog creatingIncidentDialog;
|
private Dialog creatingIncidentDialog;
|
||||||
private Context context = this;
|
private Context context = this;
|
||||||
|
private View currentElement;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -232,8 +233,10 @@ public class EventList extends ListActivity {
|
||||||
context, "",
|
context, "",
|
||||||
getString(R.string.creating_incident),
|
getString(R.string.creating_incident),
|
||||||
true);
|
true);
|
||||||
String title = titleEditText.getText().toString();
|
String title = titleEditText.getText()
|
||||||
String description = descriptionEditText.getText().toString();
|
.toString();
|
||||||
|
String description = descriptionEditText
|
||||||
|
.getText().toString();
|
||||||
new SetNewIncidentAsyncTask().execute(title,
|
new SetNewIncidentAsyncTask().execute(title,
|
||||||
description, group);
|
description, group);
|
||||||
} else {
|
} else {
|
||||||
|
@ -292,6 +295,25 @@ public class EventList extends ListActivity {
|
||||||
object.executeBackgroundGetEvents(true);
|
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).
|
* Private adapter (event list).
|
||||||
*
|
*
|
||||||
|
@ -375,23 +397,29 @@ public class EventList extends ListActivity {
|
||||||
|
|
||||||
switch (item.criticity) {
|
switch (item.criticity) {
|
||||||
|
|
||||||
case 0:// Blue
|
case 0:
|
||||||
view.setBackgroundColor(Color.parseColor("#CDE2EA"));
|
view.setBackgroundColor(getResources().getColor(
|
||||||
|
R.color.Blue));
|
||||||
break;
|
break;
|
||||||
case 1:// Grey
|
case 1:
|
||||||
view.setBackgroundColor(Color.parseColor("#E4E4E4"));
|
view.setBackgroundColor(getResources().getColor(
|
||||||
|
R.color.Grey));
|
||||||
break;
|
break;
|
||||||
case 2:// Green
|
case 2:
|
||||||
view.setBackgroundColor(Color.parseColor("#BBFFA4"));
|
view.setBackgroundColor(getResources().getColor(
|
||||||
|
R.color.Green));
|
||||||
break;
|
break;
|
||||||
case 3:// Yellow
|
case 3:
|
||||||
view.setBackgroundColor(Color.parseColor("#F4FFBF"));
|
view.setBackgroundColor(getResources().getColor(
|
||||||
|
R.color.Yellow));
|
||||||
break;
|
break;
|
||||||
case 4:// Red
|
case 4:
|
||||||
view.setBackgroundColor(Color.parseColor("#FFC0B5"));
|
view.setBackgroundColor(getResources()
|
||||||
|
.getColor(R.color.Red));
|
||||||
break;
|
break;
|
||||||
default:// Grey
|
default:
|
||||||
view.setBackgroundColor(Color.parseColor("#E4E4E4"));
|
view.setBackgroundColor(getResources().getColor(
|
||||||
|
R.color.Grey));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,8 +485,9 @@ public class EventList extends ListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.user_comment.length() != 0) {
|
if (item.user_comment.length() != 0) {
|
||||||
if (item.user_comment.length()> 200) {
|
if (item.user_comment.length() > 200) {
|
||||||
item.user_comment = item.user_comment.substring(0, 197);
|
item.user_comment = item.user_comment.substring(0,
|
||||||
|
197);
|
||||||
item.user_comment = item.user_comment.concat("...");
|
item.user_comment = item.user_comment.concat("...");
|
||||||
}
|
}
|
||||||
text = (TextView) viewEventExtended
|
text = (TextView) viewEventExtended
|
||||||
|
@ -524,8 +553,9 @@ public class EventList extends ListActivity {
|
||||||
text.setText("");
|
text.setText("");
|
||||||
text.setVisibility(TextView.VISIBLE);
|
text.setVisibility(TextView.VISIBLE);
|
||||||
} else if (item.status != 1) {
|
} else if (item.status != 1) {
|
||||||
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate();
|
currentElement = view;
|
||||||
clickListener.id_event = item.id_event;
|
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate(
|
||||||
|
item.id_event);
|
||||||
button.setOnClickListener(clickListener);
|
button.setOnClickListener(clickListener);
|
||||||
text = (TextView) viewEventExtended
|
text = (TextView) viewEventExtended
|
||||||
.findViewById(R.id.validate_event_label);
|
.findViewById(R.id.validate_event_label);
|
||||||
|
@ -643,13 +673,17 @@ public class EventList extends ListActivity {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private class OnClickListenerButtonValidate implements OnClickListener {
|
private class OnClickListenerButtonValidate implements OnClickListener {
|
||||||
public int id_event;
|
private int idEvent;
|
||||||
|
|
||||||
|
public OnClickListenerButtonValidate(int idEvent) {
|
||||||
|
this.idEvent = idEvent;
|
||||||
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent i = new Intent(getApplicationContext(),
|
Intent i = new Intent(getApplicationContext(),
|
||||||
PopupValidationEvent.class);
|
PopupValidationEvent.class);
|
||||||
i.putExtra("id_event", id_event);
|
i.putExtra("id_event", idEvent);
|
||||||
startActivity(i);
|
startActivityForResult(i, VALIDATE_EVENT_ACTIVITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the functionality necessary to validate an event.
|
* Provides the functionality necessary to validate an event.
|
||||||
|
@ -73,14 +72,7 @@ public class PopupValidationEvent extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finish the activity
|
* Sends a validation request (async task)
|
||||||
*/
|
|
||||||
private void destroyPopup() {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a validation (async task)
|
|
||||||
*
|
*
|
||||||
* @author Miguel de Dios Matías
|
* @author Miguel de Dios Matías
|
||||||
*
|
*
|
||||||
|
@ -90,7 +82,6 @@ public class PopupValidationEvent extends Activity {
|
||||||
|
|
||||||
private boolean connectionProblem = false;
|
private boolean connectionProblem = false;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Boolean doInBackground(Void... params) {
|
protected Boolean doInBackground(Void... params) {
|
||||||
int idEvent = Integer.valueOf(id_event);
|
int idEvent = Integer.valueOf(id_event);
|
||||||
try {
|
try {
|
||||||
|
@ -100,26 +91,17 @@ public class PopupValidationEvent extends Activity {
|
||||||
connectionProblem = true;
|
connectionProblem = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
String text;
|
|
||||||
if (connectionProblem) {
|
if (connectionProblem) {
|
||||||
Core.showConnectionProblemToast(getApplicationContext(), true);
|
Core.showConnectionProblemToast(getApplicationContext(), true);
|
||||||
} else {
|
} else {
|
||||||
if (result) {
|
Intent resultIntent = new Intent();
|
||||||
text = getApplicationContext().getString(
|
resultIntent.putExtra("validated", result);
|
||||||
R.string.successful_validate_event_str);
|
setResult(RESULT_OK, resultIntent);
|
||||||
} else {
|
finish();
|
||||||
text = getApplicationContext().getString(
|
|
||||||
R.string.fail_validate_event_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast toast = Toast.makeText(getApplicationContext(), text,
|
|
||||||
Toast.LENGTH_SHORT);
|
|
||||||
toast.show();
|
|
||||||
destroyPopup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue