mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-27 07:44:35 +02:00
2012-06-01 Santiago Munin <burnin1@gmail.com>
* AndroidManifest.xml: Added IncidenList (new activity) * src/pandroid_event_viewer/pandorafms/IncidentListItem.java: Added, value object of incidents. * src/pandroid_event_viewer/pandorafms/IncidentList.java: New activity. It will show all incidents. * src/pandroid_event_viewer/pandorafms/Options.java: Little refactoring. * src/pandroid_event_viewer/pandorafms/EventList.java: Deprecated function removed. * res/layout/item_list_incident_layout.xml: Layout of IncidentList items. * res/values/strings.xml: Added new entries. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6405 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
04cb80614d
commit
48d36c778c
@ -79,7 +79,7 @@
|
|||||||
android:label="@string/pandroid_event_viewer_str"
|
android:label="@string/pandroid_event_viewer_str"
|
||||||
android:theme="@android:style/Theme.Dialog" >
|
android:theme="@android:style/Theme.Dialog" >
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".IncidentList"/>
|
||||||
<service android:name=".PandroidEventviewerService" >
|
<service android:name=".PandroidEventviewerService" >
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2012-06-01 Santiago Munín <burnin1@gmail.com>
|
||||||
|
* AndroidManifest.xml: Added IncidenList (new activity)
|
||||||
|
* src/pandroid_event_viewer/pandorafms/IncidentListItem.java: Added, value object of incidents.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/IncidentList.java: New activity. It will show all incidents.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Options.java: Little refactoring.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/EventList.java: Deprecated function removed.
|
||||||
|
* res/layout/item_list_incident_layout.xml: Layout of IncidentList items.
|
||||||
|
* res/values/strings.xml: Added new entries.
|
||||||
|
|
||||||
|
|
||||||
2012-06-01 Santiago Munín <burnin1@gmail.com>
|
2012-06-01 Santiago Munín <burnin1@gmail.com>
|
||||||
* Little changes on the whole app: Fixed some Lint errors.
|
* Little changes on the whole app: Fixed some Lint errors.
|
||||||
|
|
||||||
|
@ -0,0 +1,110 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/item_linear_layout"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/content_incident_item"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/incident_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/incident_name"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/incident_agent"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:textSize="10sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/incident_last_update_timestamp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:textSize="10sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_load_more_incidents"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/load_more_events_button_str"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/loading_more_incidents"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="gone" >
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
style="?android:attr/progressBarStyleSmall"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingRight="10dip" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/loading_label_str"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/incident_extra_info"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:background="#FFFFFF"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/description" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/incident_description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/description" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/incident_close_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/incident_close_button" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -105,4 +105,6 @@
|
|||||||
<string name="artica_copyright">Copyright (©) 2011 Artica</string>
|
<string name="artica_copyright">Copyright (©) 2011 Artica</string>
|
||||||
<string name="dont_show_again">Don\'t show again</string>
|
<string name="dont_show_again">Don\'t show again</string>
|
||||||
<string name="pandorafms_logo_description">PandoraFMS\'s logo</string>
|
<string name="pandorafms_logo_description">PandoraFMS\'s logo</string>
|
||||||
|
<string name="description">Description</string>
|
||||||
|
<string name="incident_close_button">Close incident</string>
|
||||||
</resources>
|
</resources>
|
@ -200,32 +200,6 @@ public class EventList extends ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the group image on event list.
|
|
||||||
*
|
|
||||||
* @param view
|
|
||||||
* Parent view.
|
|
||||||
* @param group_icon
|
|
||||||
* Group icon.
|
|
||||||
* @param id
|
|
||||||
* Group's ImageView id.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* private void setImageGroup(View view, String group_icon, int id) {
|
|
||||||
* ImageView imgview = (ImageView) view.findViewById(id); Bitmap img;
|
|
||||||
*
|
|
||||||
* SharedPreferences preferences = getApplicationContext()
|
|
||||||
* .getSharedPreferences( getApplicationContext().getString(
|
|
||||||
* R.string.const_string_preferences), Activity.MODE_PRIVATE);
|
|
||||||
*
|
|
||||||
* String url = preferences.getString("url", "");
|
|
||||||
*
|
|
||||||
* img = Core.downloadImage(url + "/images/groups_small/" + group_icon +
|
|
||||||
* ".png");
|
|
||||||
*
|
|
||||||
* if (img != null) { imgview.setImageBitmap(img); } }
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String getImageGroupUrl(String group_icon) {
|
private String getImageGroupUrl(String group_icon) {
|
||||||
SharedPreferences preferences = getApplicationContext()
|
SharedPreferences preferences = getApplicationContext()
|
||||||
.getSharedPreferences(
|
.getSharedPreferences(
|
||||||
|
@ -0,0 +1,271 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import android.app.ListActivity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity where incidents are displayed.
|
||||||
|
*
|
||||||
|
* @author Santiago Munín González
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class IncidentList extends ListActivity {
|
||||||
|
private ListView lv;
|
||||||
|
private MyIncidentListAdapter la;
|
||||||
|
private boolean loadInProgress;
|
||||||
|
private static String TAG = "IncidentList";
|
||||||
|
private List<IncidentListItem> incidents = new ArrayList<IncidentListItem>();
|
||||||
|
private int newIncidents;
|
||||||
|
private int offset, pagination;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.list_view_layout);
|
||||||
|
offset = 0;
|
||||||
|
pagination = 0;
|
||||||
|
la = new MyIncidentListAdapter(getBaseContext());
|
||||||
|
this.toggleLoadingLayout();
|
||||||
|
lv = (ListView) findViewById(android.R.id.list);
|
||||||
|
lv.setAdapter(la);
|
||||||
|
// TODO broadcast receiver went here
|
||||||
|
this.toggleLoadingLayout();
|
||||||
|
loadIncidents();
|
||||||
|
this.toggleLoadingLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows loading information.
|
||||||
|
*/
|
||||||
|
private void toggleLoadingLayout() {
|
||||||
|
LinearLayout layout;
|
||||||
|
|
||||||
|
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||||
|
layout.setVisibility(LinearLayout.GONE);
|
||||||
|
|
||||||
|
layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||||
|
|
||||||
|
if (loadInProgress) {
|
||||||
|
layout.setVisibility(LinearLayout.VISIBLE);
|
||||||
|
} else {
|
||||||
|
layout.setVisibility(LinearLayout.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Loads incidents.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void loadIncidents() {
|
||||||
|
la.showLoadingEvents = true;
|
||||||
|
new GetIncidentsTask().execute((Void)null);
|
||||||
|
}
|
||||||
|
private class GetIncidentsTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
List<IncidentListItem> list = new ArrayList<IncidentListItem>();
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
incidents = new ArrayList<IncidentListItem>();
|
||||||
|
//TODO just a tests
|
||||||
|
IncidentListItem i = new IncidentListItem();
|
||||||
|
i.title = "Test";
|
||||||
|
i.description = "asdadsadads";
|
||||||
|
i.timestamp = "ASDD";
|
||||||
|
i.statusImage = "http://www.limpiatumundo.com/imagenes/circle_blue.png";
|
||||||
|
list.add(i);
|
||||||
|
i = new IncidentListItem();
|
||||||
|
i.title = "Test2";
|
||||||
|
list.add(i);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
|
incidents.clear();
|
||||||
|
incidents.addAll(list);
|
||||||
|
la.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Private adapter (incident list).
|
||||||
|
*
|
||||||
|
* @author Santiago Munín González
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class MyIncidentListAdapter extends BaseAdapter {
|
||||||
|
private Context mContext;
|
||||||
|
public boolean showLoadingEvents;
|
||||||
|
|
||||||
|
public MyIncidentListAdapter(Context c) {
|
||||||
|
super();
|
||||||
|
mContext = c;
|
||||||
|
showLoadingEvents = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
// TODO +1?
|
||||||
|
return incidents.size()+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View view;
|
||||||
|
|
||||||
|
LayoutInflater inflater = (LayoutInflater) mContext
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
view = inflater.inflate(R.layout.item_list_incident_layout, null);
|
||||||
|
view.setOnClickListener(new OnIncidentClickListener(position));
|
||||||
|
// If the end of the list.
|
||||||
|
if (incidents.size() == position) {
|
||||||
|
// Show button to get more events
|
||||||
|
if ((!loadInProgress) && (newIncidents != 0)) {
|
||||||
|
if (showLoadingEvents) {
|
||||||
|
LinearLayout layout = (LinearLayout) view
|
||||||
|
.findViewById(R.id.loading_more_incidents);
|
||||||
|
layout.setVisibility(LinearLayout.VISIBLE);
|
||||||
|
|
||||||
|
RelativeLayout layout2 = (RelativeLayout) view
|
||||||
|
.findViewById(R.id.content_incident_item);
|
||||||
|
layout2.setVisibility(RelativeLayout.VISIBLE);
|
||||||
|
|
||||||
|
Button button = (Button) view
|
||||||
|
.findViewById(R.id.button_load_more_incidents);
|
||||||
|
button.setVisibility(Button.GONE);
|
||||||
|
} else {
|
||||||
|
Button button = (Button) view
|
||||||
|
.findViewById(R.id.button_load_more_incidents);
|
||||||
|
|
||||||
|
/* if (incidents.size() == 0) {
|
||||||
|
button.setVisibility(Button.GONE);
|
||||||
|
} else if (incidents.size() >= newIncidents) {
|
||||||
|
button.setVisibility(Button.GONE);
|
||||||
|
} else {
|
||||||
|
button.setVisibility(Button.VISIBLE);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
offset += pagination;
|
||||||
|
loadIncidents();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*RelativeLayout content_event_item = (RelativeLayout) view
|
||||||
|
.findViewById(R.id.content_event_item);
|
||||||
|
content_event_item.setVisibility(RelativeLayout.GONE);*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
IncidentListItem item = incidents.get(position);
|
||||||
|
|
||||||
|
TextView tv = (TextView) view.findViewById(R.id.incident_name);
|
||||||
|
tv.setText(item.title);
|
||||||
|
Core.setTextViewLeftImage(tv, item.statusImage);
|
||||||
|
|
||||||
|
tv = (TextView) view.findViewById(R.id.incident_agent);
|
||||||
|
tv.setText(item.nameAgent);
|
||||||
|
Core.setTextViewLeftImage(tv, item.priorityImage);
|
||||||
|
|
||||||
|
tv = (TextView) view
|
||||||
|
.findViewById(R.id.incident_last_update_timestamp);
|
||||||
|
tv.setText(item.timestamp);
|
||||||
|
|
||||||
|
// Show extended info
|
||||||
|
if (item.opened) {
|
||||||
|
((LinearLayout) view.findViewById(R.id.incident_extra_info)).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
TextView text = (TextView) view.findViewById(R.id.incident_description);
|
||||||
|
text.setText(item.description);
|
||||||
|
|
||||||
|
view.setOnClickListener(new OnIncidentClickListener(position));
|
||||||
|
|
||||||
|
Button button;
|
||||||
|
button = (Button) findViewById(R.id.incident_close_button);
|
||||||
|
// TODO if status == closed then
|
||||||
|
// button.setVisibility(Visibility.GONE);
|
||||||
|
// else
|
||||||
|
/* button.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// TODO close event
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
|
||||||
|
} else {
|
||||||
|
((LinearLayout) view.findViewById(R.id.incident_extra_info)).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom click listener (show more information).
|
||||||
|
*
|
||||||
|
* @author Santiago Munín González
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class OnIncidentClickListener implements OnClickListener {
|
||||||
|
private int mPosition;
|
||||||
|
|
||||||
|
OnIncidentClickListener(int position) {
|
||||||
|
mPosition = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View arg0) {
|
||||||
|
IncidentListItem item = incidents.get(mPosition);
|
||||||
|
item.opened = !item.opened;
|
||||||
|
incidents.set(mPosition, item);
|
||||||
|
la.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an incident.
|
||||||
|
*
|
||||||
|
* @author Santiago Munín González
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class IncidentListItem {
|
||||||
|
public int id;
|
||||||
|
public int idAgent;
|
||||||
|
public String nameAgent;
|
||||||
|
public String title;
|
||||||
|
public String description;
|
||||||
|
public int priority;
|
||||||
|
public String priorityImage;
|
||||||
|
public int idGroup;
|
||||||
|
public String nameGroup;
|
||||||
|
public List<String> notes;
|
||||||
|
public int status;
|
||||||
|
public String statusImage;
|
||||||
|
public String timestamp;
|
||||||
|
public boolean opened = false;
|
||||||
|
//TODO attachments too?
|
||||||
|
}
|
@ -92,8 +92,8 @@ public class Options extends Activity {
|
|||||||
combo.setAdapter(adapter);
|
combo.setAdapter(adapter);
|
||||||
combo.setSelection(refreshTimeKey);
|
combo.setSelection(refreshTimeKey);
|
||||||
|
|
||||||
final Button buttonSearch = (Button) findViewById(R.id.update_options);
|
final Button button = (Button) findViewById(R.id.update_options);
|
||||||
buttonSearch.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
save_options();
|
save_options();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user