mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 15:54:29 +02:00
2011-09-15 Miguel de Dios <miguel.dedios@artica.es>
* res/layout/*: added new layout and some changes in other layout. * res/values/strings.xml, res/values-en/strings.xml, res/values-es/strings.xml: added more strings. * src/pandroid_event_viewer/pandorafms/*: some changes to show opened item when make click in event list. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4955 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f8b3bba7aa
commit
ffc38018b3
@ -1,3 +1,13 @@
|
|||||||
|
2011-09-15 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* res/layout/*: added new layout and some changes in other layout.
|
||||||
|
|
||||||
|
* res/values/strings.xml, res/values-en/strings.xml,
|
||||||
|
res/values-es/strings.xml: added more strings.
|
||||||
|
|
||||||
|
* src/pandroid_event_viewer/pandorafms/*: some changes to show opened item
|
||||||
|
when make click in event list.
|
||||||
|
|
||||||
2011-09-13 Miguel de Dios <miguel.dedios@artica.es>
|
2011-09-13 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* *.*: added first version of Pandroid Event Viewer.
|
* *.*: added first version of Pandroid Event Viewer.
|
@ -0,0 +1,157 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<TableLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:background="#FFFFFF"
|
||||||
|
>
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="@string/severity_label_str"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<ImageView
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:id="@+id/img_severity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/severity_text"
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text=""
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="@string/type_label_str"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<ImageView
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:id="@+id/img_type"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/type_text"
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text=""
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow
|
||||||
|
android:id="@+id/row_agent"
|
||||||
|
android:visibility="gone"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="@string/agent_label_str"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/agent_text"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text=""
|
||||||
|
/>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="@string/group_label_str"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
<ImageView
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:id="@+id/img_group"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:id="@+id/group_text"
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="@string/all_str"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
</TableRow>
|
||||||
|
<!--<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="Count"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="1"
|
||||||
|
/>
|
||||||
|
</TableRow>-->
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="@string/comments_label_str"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/comments_text"
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="- Empty -"
|
||||||
|
/>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="@string/tags_label_str"
|
||||||
|
android:paddingRight="5dip"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tags_text"
|
||||||
|
android:textColor="#000"
|
||||||
|
android:text="- Empty -"
|
||||||
|
/>
|
||||||
|
</TableRow>
|
||||||
|
</TableLayout>
|
@ -16,9 +16,10 @@
|
|||||||
-->
|
-->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
|
android:id="@+id/item_linear_layout"
|
||||||
>
|
>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
@ -60,12 +61,12 @@
|
|||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
<ImageButton
|
<!--<ImageButton
|
||||||
android:id="@+id/icon_config"
|
android:id="@+id/icon_config"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/config"
|
android:src="@drawable/config"
|
||||||
android:layout_weight="0"
|
android:layout_weight="0"
|
||||||
android:layout_alignParentRight="@layout/item_list_event_layout"
|
android:layout_alignParentRight="@layout/item_list_event_layout"
|
||||||
/>
|
/>-->
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -20,4 +20,16 @@
|
|||||||
|
|
||||||
<string name="main_text">main text (value english)</string>
|
<string name="main_text">main text (value english)</string>
|
||||||
<string name="list_text">list (value english)</string>
|
<string name="list_text">list (value english)</string>
|
||||||
|
|
||||||
|
<string name="system_str">System</string>
|
||||||
|
|
||||||
|
<string name="empty_str">- Empty -</string>
|
||||||
|
<string name="all_str">All</string>
|
||||||
|
|
||||||
|
<string name="tags_label_str">Tags</string>
|
||||||
|
<string name="comments_label_str">Comments</string>
|
||||||
|
<string name="group_label_str">Group</string>
|
||||||
|
<string name="agent_label_str">Agent name</string>
|
||||||
|
<string name="type_label_str">Type</string>
|
||||||
|
<string name="severity_label_str">Severity</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -20,4 +20,16 @@
|
|||||||
|
|
||||||
<string name="main_text">main text (value spanish)</string>
|
<string name="main_text">main text (value spanish)</string>
|
||||||
<string name="list_text">list (value spanish)</string>
|
<string name="list_text">list (value spanish)</string>
|
||||||
|
|
||||||
|
<string name="system_str">Sistema</string>
|
||||||
|
|
||||||
|
<string name="empty_str">- Vacio -</string>
|
||||||
|
<string name="all_str">Todo</string>
|
||||||
|
|
||||||
|
<string name="tags_label_str">Etiquetas</string>
|
||||||
|
<string name="comments_label_str">Comentarios</string>
|
||||||
|
<string name="group_label_str">Grupos</string>
|
||||||
|
<string name="agent_label_str">Nombre del agente</string>
|
||||||
|
<string name="type_label_str">Tipo</string>
|
||||||
|
<string name="severity_label_str">Severidad</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -20,4 +20,16 @@
|
|||||||
|
|
||||||
<string name="main_text">main text (value)</string>
|
<string name="main_text">main text (value)</string>
|
||||||
<string name="list_text">list (value)</string>
|
<string name="list_text">list (value)</string>
|
||||||
|
|
||||||
|
<string name="system_str">System</string>
|
||||||
|
|
||||||
|
<string name="empty_str">- Empty -</string>
|
||||||
|
<string name="all_str">All</string>
|
||||||
|
|
||||||
|
<string name="tags_label_str">Tags</string>
|
||||||
|
<string name="comments_label_str">Comments</string>
|
||||||
|
<string name="group_label_str">Group</string>
|
||||||
|
<string name="agent_label_str">Agent name</string>
|
||||||
|
<string name="type_label_str">Type</string>
|
||||||
|
<string name="severity_label_str">Severity</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,51 +1,231 @@
|
|||||||
package pandroid_event_viewer.pandorafms;
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.ListActivity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.opengl.Visibility;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.SimpleCursorAdapter;
|
||||||
|
import android.widget.TableRow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class EventList extends Activity {
|
public class EventList extends ListActivity {
|
||||||
private ListView lv1;
|
private ListView lv;
|
||||||
private MyAdapter la1;
|
private MyAdapter la;
|
||||||
|
public PandroidEventviewerActivity object;
|
||||||
|
public HashMap<Integer, Boolean> openedItem;
|
||||||
|
public HashMap<String, Bitmap> imgGroups;
|
||||||
|
public HashMap<String, Bitmap> imgSeverity;
|
||||||
|
public HashMap<String, Bitmap> imgType;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
this.openedItem = new HashMap<Integer, Boolean>();
|
||||||
|
this.imgGroups = new HashMap<String, Bitmap>();
|
||||||
|
this.imgSeverity = new HashMap<String, Bitmap>();
|
||||||
|
this.imgType = new HashMap<String, Bitmap>();
|
||||||
|
|
||||||
|
Intent i = getIntent();
|
||||||
|
this.object = (PandroidEventviewerActivity)i.getSerializableExtra("object");
|
||||||
|
|
||||||
setContentView(R.layout.list_view_layout);
|
setContentView(R.layout.list_view_layout);
|
||||||
|
|
||||||
//enganchamos el view con el layout de lista de main.xml
|
lv = (ListView)findViewById(android.R.id.list);
|
||||||
lv1 = (ListView)findViewById(android.R.id.list);
|
|
||||||
|
|
||||||
la1 = new MyAdapter(getBaseContext());
|
la = new MyAdapter(getBaseContext(), object);
|
||||||
|
|
||||||
lv1.setAdapter(la1);
|
lv.setAdapter(la);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Bitmap downloadFile(String fileUrl) {Log.e("downloadFile", fileUrl);
|
||||||
|
URL myFileUrl =null;
|
||||||
|
try {
|
||||||
|
myFileUrl= new URL(fileUrl);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
|
||||||
|
conn.setDoInput(true);
|
||||||
|
conn.connect();
|
||||||
|
InputStream is = conn.getInputStream();
|
||||||
|
|
||||||
|
return BitmapFactory.decodeStream(is);
|
||||||
|
//imView.setImageBitmap(bmImg);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageGroup(View view, String group_icon, int id) {
|
||||||
|
ImageView imgview = (ImageView)view.findViewById(id);
|
||||||
|
Bitmap img;
|
||||||
|
|
||||||
|
if (this.imgGroups.containsKey(group_icon)) {
|
||||||
|
img = this.imgGroups.get(group_icon);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
img = this.downloadFile(
|
||||||
|
"http://192.168.70.112/pandora_console/images/groups_small/" + group_icon + ".png");
|
||||||
|
|
||||||
|
if (img != null) {
|
||||||
|
this.imgGroups.put(group_icon, img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img != null) {
|
||||||
|
imgview.setImageBitmap(img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageType(View view, String url, int id) {
|
||||||
|
ImageView imgview = (ImageView)view.findViewById(id);
|
||||||
|
Bitmap img = null;
|
||||||
|
|
||||||
|
if (this.imgType.containsKey(url)) {
|
||||||
|
img = this.imgType.get(url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
img = this.downloadFile(url);
|
||||||
|
|
||||||
|
if (img != null) {
|
||||||
|
this.imgType.put(url, img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img != null) {
|
||||||
|
imgview.setImageBitmap(img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageSeverity(View view, String url, int id) {
|
||||||
|
ImageView imgview = (ImageView)view.findViewById(id);
|
||||||
|
Bitmap img = null;
|
||||||
|
|
||||||
|
if (this.imgSeverity.containsKey(url)) {
|
||||||
|
img = this.imgSeverity.get(url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
img = this.downloadFile(url);
|
||||||
|
|
||||||
|
if (img != null) {
|
||||||
|
this.imgSeverity.put(url, img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img != null) {
|
||||||
|
imgview.setImageBitmap(img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onListItemClick(ListView l, View v, int position, long id)
|
||||||
|
{
|
||||||
|
super.onListItemClick(l, v, position, id);
|
||||||
|
|
||||||
|
Boolean opened = new Boolean(false);
|
||||||
|
if (this.openedItem.containsKey(new Integer(position))) {
|
||||||
|
opened = this.openedItem.get(new Integer(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
LinearLayout itemLinearLayout = (LinearLayout)l.findViewById(R.id.item_linear_layout);
|
||||||
|
|
||||||
|
if (!opened.booleanValue()) {
|
||||||
|
EventListItem item = this.object.eventList.get(position);
|
||||||
|
View view;
|
||||||
|
|
||||||
|
LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
view = inflater.inflate(R.layout.item_list_event_extended, null);
|
||||||
|
|
||||||
|
TextView text;
|
||||||
|
if (item.tags.length() != 0) {
|
||||||
|
text = (TextView)view.findViewById(R.id.tags_text);
|
||||||
|
text.setText(item.tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.user_comment.length() != 0) {
|
||||||
|
text = (TextView)view.findViewById(R.id.comments_text);
|
||||||
|
text.setText(item.user_comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.group_name.length() != 0) {
|
||||||
|
text = (TextView)view.findViewById(R.id.group_text);
|
||||||
|
text.setText(item.group_name);
|
||||||
|
this.setImageGroup(view, item.group_icon, R.id.img_group);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//ALL
|
||||||
|
this.setImageGroup(view, "world", R.id.img_group);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.agent_name.length() != 0) {
|
||||||
|
View row = view.findViewById(R.id.row_agent);
|
||||||
|
row.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
text = (TextView)view.findViewById(R.id.type_text);
|
||||||
|
text.setText(item.description_event);
|
||||||
|
|
||||||
|
this.setImageType(view, item.description_image, R.id.img_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.criticity_name.length() != 0) {
|
||||||
|
text = (TextView)view.findViewById(R.id.severity_text);
|
||||||
|
text.setText(item.criticity_name);
|
||||||
|
|
||||||
|
this.setImageType(view, item.criticity_image, R.id.img_severity);
|
||||||
|
}
|
||||||
|
Log.e("item", item.criticity_name);
|
||||||
|
|
||||||
|
itemLinearLayout.addView(view);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
itemLinearLayout.removeViewAt(1);
|
||||||
|
}
|
||||||
|
opened = new Boolean(!opened.booleanValue());
|
||||||
|
this.openedItem.put(new Integer(position), opened);
|
||||||
|
}
|
||||||
|
|
||||||
public class MyAdapter extends BaseAdapter
|
public class MyAdapter extends BaseAdapter
|
||||||
{
|
{
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
public PandroidEventviewerActivity object;
|
||||||
|
|
||||||
public MyAdapter(Context c)
|
public MyAdapter(Context c, PandroidEventviewerActivity object)
|
||||||
{
|
{
|
||||||
mContext = c;
|
mContext = c;
|
||||||
|
|
||||||
|
this.object = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
//A FUEGO ¿¿PORQUE?? Porque rellenamos con 4 datos falsos
|
return this.object.eventList.size();
|
||||||
return 40;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -64,6 +244,8 @@ public class EventList extends Activity {
|
|||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View view;
|
View view;
|
||||||
|
|
||||||
|
EventListItem item = this.object.eventList.get(position);
|
||||||
|
|
||||||
//OPTIMIZACIÓN PARA NO CREAR convertView
|
//OPTIMIZACIÓN PARA NO CREAR convertView
|
||||||
if (convertView == null)
|
if (convertView == null)
|
||||||
{
|
{
|
||||||
@ -75,36 +257,42 @@ public class EventList extends Activity {
|
|||||||
view = convertView;
|
view = convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
Random rand = new Random();
|
switch (item.criticity) {
|
||||||
rand.setSeed(System.currentTimeMillis());
|
|
||||||
|
|
||||||
int status = rand.nextInt(5);
|
case 0://Blue
|
||||||
switch (status) {
|
|
||||||
case 0://Green
|
|
||||||
view.setBackgroundColor(Color.parseColor("#BBFFA4"));
|
|
||||||
break;
|
|
||||||
case 1://Red
|
|
||||||
view.setBackgroundColor(Color.parseColor("#FFC0B5"));
|
|
||||||
break;
|
|
||||||
case 2://Yellow
|
|
||||||
view.setBackgroundColor(Color.parseColor("#F4FFBF"));
|
|
||||||
break;
|
|
||||||
case 3://Blue
|
|
||||||
view.setBackgroundColor(Color.parseColor("#CDE2EA"));
|
view.setBackgroundColor(Color.parseColor("#CDE2EA"));
|
||||||
break;
|
break;
|
||||||
case 4://Grey
|
case 1://Grey
|
||||||
|
view.setBackgroundColor(Color.parseColor("#E4E4E4"));
|
||||||
|
break;
|
||||||
|
case 2://Green
|
||||||
|
view.setBackgroundColor(Color.parseColor("#BBFFA4"));
|
||||||
|
break;
|
||||||
|
case 3://Yellow
|
||||||
|
view.setBackgroundColor(Color.parseColor("#F4FFBF"));
|
||||||
|
break;
|
||||||
|
case 4://Red
|
||||||
|
view.setBackgroundColor(Color.parseColor("#FFC0B5"));
|
||||||
|
break;
|
||||||
|
default://Grey
|
||||||
view.setBackgroundColor(Color.parseColor("#E4E4E4"));
|
view.setBackgroundColor(Color.parseColor("#E4E4E4"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextView titulo = (TextView)view.findViewById(R.id.agent_name);
|
TextView titulo = (TextView)view.findViewById(R.id.agent_name);
|
||||||
titulo.setText("Agent " + position);
|
|
||||||
|
if (item.event_type.equals("system")) {
|
||||||
|
titulo.setText(R.string.system_str);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
titulo.setText(item.agent_name);
|
||||||
|
}
|
||||||
|
|
||||||
TextView descripcion = (TextView)view.findViewById(R.id.event_name);
|
TextView descripcion = (TextView)view.findViewById(R.id.event_name);
|
||||||
descripcion.setText("Module Host Alive (0.00) is going to CRITICAL");
|
descripcion.setText(item.event);
|
||||||
|
|
||||||
TextView timestamp = (TextView)view.findViewById(R.id.timestamp);
|
TextView timestamp = (TextView)view.findViewById(R.id.timestamp);
|
||||||
timestamp.setText("13:12:11");
|
timestamp.setText(item.timestamp);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,25 @@
|
|||||||
package pandroid_event_viewer.pandorafms;
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
public class EventListItem {
|
public class EventListItem {
|
||||||
|
public int id_event;
|
||||||
|
public int id_agent;
|
||||||
|
public String id_user;
|
||||||
|
public int id_group;
|
||||||
|
public int status;
|
||||||
|
public String timestamp;
|
||||||
|
public String event;
|
||||||
|
public int utimestamp;
|
||||||
|
public String event_type;
|
||||||
|
public int id_agentmodule;
|
||||||
|
public int id_alert_am;
|
||||||
|
public int criticity;
|
||||||
|
public String user_comment;
|
||||||
|
public String tags;
|
||||||
|
public String agent_name;
|
||||||
|
public String group_name;
|
||||||
|
public String group_icon;
|
||||||
|
public String description_event;
|
||||||
|
public String description_image;
|
||||||
|
public String criticity_name;
|
||||||
|
public String criticity_image;
|
||||||
}
|
}
|
||||||
|
@ -18,35 +18,16 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.Socket;
|
import java.io.Serializable;
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.security.KeyManagementException;
|
|
||||||
import java.security.KeyStore;
|
|
||||||
import java.security.KeyStoreException;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.UnrecoverableKeyException;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.TrustManager;
|
|
||||||
import javax.net.ssl.X509TrustManager;
|
|
||||||
|
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.conn.scheme.Scheme;
|
|
||||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
|
||||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
|
||||||
import org.apache.http.conn.ssl.X509HostnameVerifier;
|
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
import org.apache.http.impl.conn.SingleClientConnManager;
|
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
@ -55,7 +36,7 @@ import android.os.Bundle;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
|
|
||||||
public class PandroidEventviewerActivity extends TabActivity {
|
public class PandroidEventviewerActivity extends TabActivity implements Serializable {
|
||||||
public ArrayList<EventListItem> eventList;
|
public ArrayList<EventListItem> eventList;
|
||||||
|
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
@ -63,26 +44,35 @@ public class PandroidEventviewerActivity extends TabActivity {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
this.eventList = new ArrayList<EventListItem>();
|
||||||
|
|
||||||
final TabHost tabHost = getTabHost();
|
final TabHost tabHost = getTabHost();
|
||||||
|
|
||||||
|
|
||||||
test();
|
test();
|
||||||
|
|
||||||
|
|
||||||
|
Intent i_main = new Intent(this, Main.class);
|
||||||
|
|
||||||
tabHost.addTab
|
tabHost.addTab
|
||||||
(
|
(
|
||||||
tabHost.newTabSpec(getResources().getString(R.string.item_tab_main_text))
|
tabHost.newTabSpec(getResources().getString(R.string.item_tab_main_text))
|
||||||
.setIndicator(getResources().getString(R.string.item_tab_main_text),
|
.setIndicator(getResources().getString(R.string.item_tab_main_text),
|
||||||
this.getResources().getDrawable(R.drawable.house)
|
this.getResources().getDrawable(R.drawable.house)
|
||||||
)
|
)
|
||||||
.setContent(new Intent(this, Main.class))
|
.setContent(i_main)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Intent i_event_list = new Intent(this, EventList.class);
|
||||||
|
i_event_list.putExtra("object", this);
|
||||||
|
|
||||||
tabHost.addTab
|
tabHost.addTab
|
||||||
(
|
(
|
||||||
tabHost.newTabSpec(getResources().getString(R.string.item_tab_event_list_text))
|
tabHost.newTabSpec(getResources().getString(R.string.item_tab_event_list_text))
|
||||||
.setIndicator(getResources().getString(R.string.item_tab_event_list_text),
|
.setIndicator(getResources().getString(R.string.item_tab_event_list_text),
|
||||||
this.getResources().getDrawable(R.drawable.lightning_go)
|
this.getResources().getDrawable(R.drawable.lightning_go)
|
||||||
)
|
)
|
||||||
.setContent(new Intent(this, EventList.class))
|
.setContent(i_event_list)
|
||||||
);
|
);
|
||||||
|
|
||||||
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=45;
|
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=45;
|
||||||
@ -90,11 +80,10 @@ public class PandroidEventviewerActivity extends TabActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void test() {
|
public void test() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HttpPost httpPost = new HttpPost(
|
HttpPost httpPost = new HttpPost(
|
||||||
"http://192.168.70.112/pandora_console/include/api.php");
|
"http://192.168.70.112/pandora_console/include/api.php");
|
||||||
|
|
||||||
@ -105,7 +94,7 @@ public class PandroidEventviewerActivity extends TabActivity {
|
|||||||
parameters.add(new BasicNameValuePair("op2", "events"));
|
parameters.add(new BasicNameValuePair("op2", "events"));
|
||||||
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
|
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
|
||||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||||
parameters.add(new BasicNameValuePair("other", ";||||||1315015715||10|1"));
|
parameters.add(new BasicNameValuePair("other", ";||||||1315015715||20|1"));
|
||||||
|
|
||||||
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters);
|
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters);
|
||||||
|
|
||||||
@ -114,11 +103,81 @@ public class PandroidEventviewerActivity extends TabActivity {
|
|||||||
HttpResponse response = httpClient.execute(httpPost);
|
HttpResponse response = httpClient.execute(httpPost);
|
||||||
HttpEntity entityResponse = response.getEntity();
|
HttpEntity entityResponse = response.getEntity();
|
||||||
|
|
||||||
String str = convertStreamToString(entityResponse.getContent());
|
String return_api = convertStreamToString(entityResponse.getContent());
|
||||||
Log.e("test2", str);
|
|
||||||
|
String[] lines = return_api.split("\n");
|
||||||
|
|
||||||
|
for (int i= 0; i < lines.length; i++) {
|
||||||
|
String[] items = lines[i].split(";", 21);
|
||||||
|
|
||||||
|
EventListItem event = new EventListItem();
|
||||||
|
if (items[0].length() == 0) {
|
||||||
|
event.id_event = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.id_event = Integer.parseInt(items[0]);
|
||||||
|
}
|
||||||
|
if (items[1].length() == 0) {
|
||||||
|
event.id_agent = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.id_agent = Integer.parseInt(items[1]);
|
||||||
|
}
|
||||||
|
event.id_user = items[2];
|
||||||
|
if (items[3].length() == 0) {
|
||||||
|
event.id_group = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.id_group = Integer.parseInt(items[3]);
|
||||||
|
}
|
||||||
|
if (items[4].length() == 0) {
|
||||||
|
event.status = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.status = Integer.parseInt(items[4]);
|
||||||
|
}
|
||||||
|
event.timestamp = items[5];
|
||||||
|
event.event = items[6];
|
||||||
|
if (items[7].length() == 0) {
|
||||||
|
event.utimestamp = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.utimestamp = Integer.parseInt(items[7]);
|
||||||
|
}
|
||||||
|
event.event_type = items[8];
|
||||||
|
if (items[9].length() == 0) {
|
||||||
|
event.id_agentmodule = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.id_agentmodule = Integer.parseInt(items[9]);
|
||||||
|
}
|
||||||
|
if (items[10].length() == 0) {
|
||||||
|
event.id_alert_am = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.id_alert_am = Integer.parseInt(items[10]);
|
||||||
|
}
|
||||||
|
if (items[11].length() == 0) {
|
||||||
|
event.criticity = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.criticity = Integer.parseInt(items[11]);
|
||||||
|
}
|
||||||
|
event.user_comment = items[12];
|
||||||
|
event.tags = items[13];
|
||||||
|
event.agent_name = items[14];
|
||||||
|
event.group_name = items[15];
|
||||||
|
event.group_icon = items[16];
|
||||||
|
event.description_event = items[17];
|
||||||
|
event.description_image = items[18];
|
||||||
|
event.criticity_name = items[19];
|
||||||
|
event.criticity_image = items[20];
|
||||||
|
|
||||||
|
this.eventList.add(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Log.e("test2", e.getMessage());
|
Log.e("ERROR THE ", e.getMessage());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user