2012-06-06 Santiago Munin <burnin1@gmail.com>
* AndroidManifest.xml: Added CreateIncidentActivity (new activity). * src/pandroid_event_viewer/pandorafms/Core.java: Added some getAgents and getGroups * res/values/strings.xml: Added new entries * res/values/arrays.xml: Added new entries * res/menu/options_menu_list_events.xml, res/menu/options_menu.xml: Added "Incidents" entry * res/layout/create_incident.xml: CreateIncidentActivity's layout. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6428 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
|
@ -79,7 +79,9 @@
|
|||
android:label="@string/pandroid_event_viewer_str"
|
||||
android:theme="@android:style/Theme.Dialog" >
|
||||
</activity>
|
||||
<activity android:name=".IncidentList"/>
|
||||
<!--
|
||||
<activity android:name=".IncidentList"/> -->
|
||||
<activity android:name=".CreateIncidentActivity"/>
|
||||
<service android:name=".PandroidEventviewerService" >
|
||||
</service>
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2012-06-06 Santiago Munín <burnin1@gmail.com>
|
||||
* AndroidManifest.xml: Added CreateIncidentActivity (new activity).
|
||||
* src/pandroid_event_viewer/pandorafms/Core.java: Added some getAgents and getGroups
|
||||
* res/values/strings.xml: Added new entries
|
||||
* res/values/arrays.xml: Added new entries
|
||||
* res/menu/options_menu_list_events.xml, res/menu/options_menu.xml: Added "Incidents" entry
|
||||
* res/layout/create_incident.xml: CreateIncidentActivity's layout.
|
||||
|
||||
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.
|
||||
|
@ -7,7 +15,6 @@
|
|||
* 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>
|
||||
* Little changes on the whole app: Fixed some Lint errors.
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# cache for current jar dependecy. DO NOT EDIT.
|
||||
# format is <lastModified> <length> <SHA-1> <path>
|
||||
# Encoding is UTF-8
|
After Width: | Height: | Size: 801 B |
After Width: | Height: | Size: 686 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 764 B |
After Width: | Height: | Size: 914 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1023 B |
After Width: | Height: | Size: 585 B |
After Width: | Height: | Size: 320 B |
|
@ -0,0 +1,14 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-8
|
|
@ -0,0 +1,157 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TableLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_weight="9"
|
||||
android:orientation="vertical"
|
||||
android:stretchColumns="1" >
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp" >
|
||||
|
||||
<TextView
|
||||
style="@android:style/TextAppearance.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="@string/title" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/incident_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp" >
|
||||
|
||||
<TextView
|
||||
style="@android:style/TextAppearance.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="@string/description" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/incident_description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp" >
|
||||
|
||||
<TextView
|
||||
style="@android:style/TextAppearance.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="@string/source" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/incident_source"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/incident_source" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp" >
|
||||
|
||||
<TextView
|
||||
style="@android:style/TextAppearance.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="@string/priority" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/incident_priority"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:entries="@array/incident_priority" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp" >
|
||||
|
||||
<TextView
|
||||
style="@android:style/TextAppearance.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="@string/status_label_str" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/incident_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:entries="@array/incident_status"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginTop="5dp" >
|
||||
|
||||
<TextView
|
||||
style="@android:style/TextAppearance.Medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="5dp"
|
||||
android:text="@string/group_label_str" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/incident_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/incident_create_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:text="@string/create" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -25,4 +25,8 @@
|
|||
android:title="@string/about_label_str"
|
||||
android:icon="@drawable/about"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/incidents_button_menu_options"
|
||||
android:title="@string/incidents_label_str"
|
||||
/>
|
||||
</menu>
|
|
@ -30,4 +30,8 @@
|
|||
android:title="@string/about_label_str"
|
||||
android:icon="@drawable/about"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/incidents_button_menu_options"
|
||||
android:title="@string/incidents_label_str"
|
||||
/>
|
||||
</menu>
|
||||
|
|
|
@ -15,18 +15,20 @@
|
|||
// GNU General Public License for more details.
|
||||
-->
|
||||
<resources>
|
||||
<string-array name="severity_array_values">
|
||||
<!-- You must subtract -1 -->
|
||||
|
||||
<string-array name="severity_array_values">
|
||||
|
||||
<!-- You must subtract -1 -->
|
||||
<item>All</item>
|
||||
<item>Maintenance</item>
|
||||
<item>Informational</item>
|
||||
<item>Normal</item>
|
||||
<item>Warning</item>
|
||||
<item>Critical</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Please change the code in the function convertRefreshTimeKeyToTime -->
|
||||
<string-array name="refresh_combo">
|
||||
</string-array>
|
||||
|
||||
<!-- Please change the code in the function convertRefreshTimeKeyToTime -->
|
||||
<string-array name="refresh_combo">
|
||||
<item>30 seconds</item>
|
||||
<item>1 minute</item>
|
||||
<item>5 minutes</item>
|
||||
|
@ -46,37 +48,65 @@
|
|||
<item>24 hours</item>
|
||||
<item>36 hours</item>
|
||||
<item>48 hours</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="event_status_values">
|
||||
<!-- You must subtract -1 -->
|
||||
<!--<item>All event</item>//The next version re-add please -->
|
||||
|
||||
<!-- You must subtract 0 -->
|
||||
<item>Only new</item>
|
||||
<item>Only validated</item>
|
||||
<item>Only in process</item>
|
||||
<item>Only not validated</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Please change the code in the function convertMaxTimeOldEventValuesToTimestamp -->
|
||||
<string-array name="max_time_old_event_values">
|
||||
<item>30 minutes</item>
|
||||
<item>1 hour</item>
|
||||
<item>2 hours</item>
|
||||
<item>3 hours</item>
|
||||
<item>4 hours</item>
|
||||
<item>5 hours</item>
|
||||
<item>8 hours</item>
|
||||
<item>10 hours</item>
|
||||
<item>12 hours</item>
|
||||
<item>1 day</item>
|
||||
<item>2 days</item>
|
||||
<item>3 days</item>
|
||||
<item>4 days</item>
|
||||
<item>5 days</item>
|
||||
<item>1 week</item>
|
||||
<item>2 weeks</item>
|
||||
<item>1 month</item>
|
||||
</string-array>
|
||||
</string-array>
|
||||
<string-array name="event_status_values">
|
||||
|
||||
<!-- You must subtract -1 -->
|
||||
<!-- <item>All event</item>//The next version re-add please -->
|
||||
|
||||
|
||||
<!-- You must subtract 0 -->
|
||||
<item>Only new</item>
|
||||
<item>Only validated</item>
|
||||
<item>Only in process</item>
|
||||
<item>Only not validated</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Please change the code in the function convertMaxTimeOldEventValuesToTimestamp -->
|
||||
<string-array name="max_time_old_event_values">
|
||||
<item>30 minutes</item>
|
||||
<item>1 hour</item>
|
||||
<item>2 hours</item>
|
||||
<item>3 hours</item>
|
||||
<item>4 hours</item>
|
||||
<item>5 hours</item>
|
||||
<item>8 hours</item>
|
||||
<item>10 hours</item>
|
||||
<item>12 hours</item>
|
||||
<item>1 day</item>
|
||||
<item>2 days</item>
|
||||
<item>3 days</item>
|
||||
<item>4 days</item>
|
||||
<item>5 days</item>
|
||||
<item>1 week</item>
|
||||
<item>2 weeks</item>
|
||||
<item>1 month</item>
|
||||
</string-array>
|
||||
<string-array name="incident_priority">
|
||||
<item>Informative</item>
|
||||
<item>Low</item>
|
||||
<item>Medium</item>
|
||||
<item>Serious</item>
|
||||
<item>Very serious</item>
|
||||
<item>Maintenance</item>
|
||||
</string-array>
|
||||
<string-array name="incident_source">
|
||||
<item>Application data</item>
|
||||
<item>Database event</item>
|
||||
<item>Firewall records</item>
|
||||
<item>Logfiles</item>
|
||||
<item>Operating System event</item>
|
||||
<item>Other data source</item>
|
||||
<item>Pandora FMS event</item>
|
||||
<item>Unknown resource</item>
|
||||
<item>User report</item>
|
||||
</string-array>
|
||||
<string-array name="incident_status">
|
||||
<item>Active incidents</item>
|
||||
<item>Active incidents, with comments</item>
|
||||
<item>Rejected incidents</item>
|
||||
<item>Expired incidents</item>
|
||||
<item>Closed incidents</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
|
@ -107,4 +107,9 @@
|
|||
<string name="pandorafms_logo_description">PandoraFMS\'s logo</string>
|
||||
<string name="description">Description</string>
|
||||
<string name="incident_close_button">Close incident</string>
|
||||
<string name="incidents_label_str">Incidents</string>
|
||||
<string name="title">Title</string>
|
||||
<string name="priority">Priority</string>
|
||||
<string name="create">Create</string>
|
||||
<string name="source">Source</string>
|
||||
</resources>
|
|
@ -266,9 +266,9 @@ public class Core {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Converts params to string.
|
||||
* @param params
|
||||
* @return
|
||||
* @return All params in a single string.
|
||||
*/
|
||||
public static String serializeParams2Api(String[] params) {
|
||||
String return_var = params[0];
|
||||
|
@ -276,7 +276,6 @@ public class Core {
|
|||
for (int i = 1; i < params.length; i++) {
|
||||
return_var += "|" + params[i];
|
||||
}
|
||||
|
||||
Log.i(TAG + " serializeParams2Api", return_var);
|
||||
return return_var;
|
||||
}
|
||||
|
@ -391,11 +390,72 @@ public class Core {
|
|||
* TextView.
|
||||
* @param image
|
||||
* Image.
|
||||
* @param size Image size
|
||||
* @param size
|
||||
* Image size
|
||||
*/
|
||||
public static void setTextViewLeftImage(TextView view, Drawable image,
|
||||
int size) {
|
||||
image.setBounds(0, 0, size, size);
|
||||
view.setCompoundDrawables(image, null, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups through an api call.
|
||||
*
|
||||
* @param context
|
||||
* Application context.
|
||||
* @return Map containing id -> group.
|
||||
*/
|
||||
public static Map<Integer, String> getGroups(Context context) {
|
||||
Map<Integer, String> result = new HashMap<Integer, String>();
|
||||
try {
|
||||
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("op", "get"));
|
||||
parameters.add(new BasicNameValuePair("op2", "groups"));
|
||||
parameters.add(new BasicNameValuePair("other_mode",
|
||||
"url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other", ";"));
|
||||
|
||||
String return_api = Core.httpGet(context, parameters);
|
||||
String[] lines = return_api.split("\n");
|
||||
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String[] groups = lines[i].split(";", 21);
|
||||
|
||||
result.put(Integer.valueOf(groups[0]), groups[1]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG + ": getting groups", e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agents through an api call.
|
||||
*
|
||||
* @param context
|
||||
* @return Map containing id -> agent.
|
||||
*/
|
||||
public static Map<Integer, String> getAgents(Context context) {
|
||||
Map<Integer, String> result = new HashMap<Integer, String>();
|
||||
try {
|
||||
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("op", "get"));
|
||||
parameters.add(new BasicNameValuePair("op2", "all_agents"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
|
||||
String return_api = Core.httpGet(context, parameters);
|
||||
String[] lines = return_api.split("\n");
|
||||
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String[] agents = lines[i].split(";");
|
||||
|
||||
result.put(Integer.valueOf(agents[0]), agents[1]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG + ": getting groups", e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
|
||||
/**
|
||||
* Allows user to create an incident.
|
||||
*
|
||||
* @author Santiago Munín González
|
||||
*
|
||||
*/
|
||||
public class CreateIncidentActivity extends Activity {
|
||||
private static String TAG = "CreateIncidentActivity";
|
||||
EditText title, description;
|
||||
Spinner source, priority, group, status;
|
||||
int priority_code, status_code;
|
||||
Map<Integer, String> groups;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.create_incident);
|
||||
setViews();
|
||||
}
|
||||
|
||||
private void setViews() {
|
||||
title = (EditText) findViewById(R.id.incident_title);
|
||||
title.setText("");
|
||||
description = (EditText) findViewById(R.id.incident_description);
|
||||
description.setText("");
|
||||
priority = (Spinner) findViewById(R.id.incident_priority);
|
||||
priority.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1,
|
||||
int arg2, long arg3) {
|
||||
priority_code = arg0.getSelectedItemPosition();
|
||||
if (priority_code == 5) {
|
||||
priority_code = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
}
|
||||
});
|
||||
group = (Spinner) findViewById(R.id.incident_group);
|
||||
source = (Spinner) findViewById(R.id.incident_source);
|
||||
status = (Spinner) findViewById(R.id.incident_status);
|
||||
status.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1,
|
||||
int arg2, long arg3) {
|
||||
status_code = arg0.getSelectedItemPosition();
|
||||
if (status_code == 4) {
|
||||
status_code = 13;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
}
|
||||
});
|
||||
new GetGroupsAsyncTask().execute((Void) null);
|
||||
|
||||
((Button) findViewById(R.id.incident_create_button))
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
sendNewIncident();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the create incident petition.
|
||||
*/
|
||||
private void sendNewIncident() {
|
||||
Log.i(TAG, "Sending new incident");
|
||||
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("op", "set"));
|
||||
parameters.add(new BasicNameValuePair("op2", "new_incident"));
|
||||
/*
|
||||
*
|
||||
* op=set&op2=new_incident&other=titulo|descripcion%20texto|Logfiles|2|10
|
||||
* |12&other_mode=url_encode_separator_|
|
||||
*/
|
||||
parameters.add(new BasicNameValuePair("other_mode",
|
||||
"url_encode_separator_|"));
|
||||
String incidentParams[] = new String[6];
|
||||
incidentParams[0] = title.getText().toString();
|
||||
incidentParams[1] = description.getText().toString();
|
||||
incidentParams[2] = String.valueOf(source.getSelectedItem().toString());
|
||||
incidentParams[3] = String.valueOf(priority_code);
|
||||
incidentParams[4] = String.valueOf(status_code);
|
||||
incidentParams[5] = String.valueOf(groups.get(group
|
||||
.getSelectedItemPosition()));
|
||||
parameters.add(new BasicNameValuePair("other", Core
|
||||
.serializeParams2Api(incidentParams)));
|
||||
Core.httpGet(getApplicationContext(), parameters);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Async task which get groups.
|
||||
*
|
||||
* @author Santiago Munín González
|
||||
*
|
||||
*/
|
||||
private class GetGroupsAsyncTask extends
|
||||
AsyncTask<Void, Void, Map<Integer, String>> {
|
||||
|
||||
@Override
|
||||
protected Map<Integer, String> doInBackground(Void... params) {
|
||||
return Core.getGroups(getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Map<Integer, String> result) {
|
||||
groups = result;
|
||||
List<String> list = new LinkedList<String>();
|
||||
for (Entry<Integer, String> entry : result.entrySet()) {
|
||||
list.add(entry.getValue());
|
||||
}
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
|
||||
getApplicationContext(),
|
||||
android.R.layout.simple_spinner_item, list);
|
||||
group.setAdapter(spinnerArrayAdapter);
|
||||
group.setSelection(0);
|
||||
/*
|
||||
* ProgressBar loadingGroup = (ProgressBar)
|
||||
* findViewById(R.id.loading_group);
|
||||
*
|
||||
* loadingGroup.setVisibility(ProgressBar.GONE);
|
||||
* combo.setVisibility(Spinner.VISIBLE);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* private class GetAgentsAsyncTask extends AsyncTask<Void, Void,
|
||||
* Map<Integer, String>> {
|
||||
*
|
||||
* @Override protected Map<Integer, String> doInBackground(Void... params) {
|
||||
* return Core.getAgents(getApplicationContext()); }
|
||||
*
|
||||
* @Override protected void onPostExecute(Map<Integer, String> result) {
|
||||
* agents = result; List<String> list = new LinkedList<String>(); for
|
||||
* (Entry<Integer, String> entry : result.entrySet()) {
|
||||
* list.add(entry.getValue()); } ArrayAdapter<String> spinnerArrayAdapter =
|
||||
* new ArrayAdapter<String>( getApplicationContext(),
|
||||
* android.R.layout.simple_spinner_item, list);
|
||||
* agent.setAdapter(spinnerArrayAdapter); agent.setSelection(0); /*
|
||||
* ProgressBar loadingGroup = (ProgressBar)
|
||||
* findViewById(R.id.loading_group);
|
||||
*
|
||||
* loadingGroup.setVisibility(ProgressBar.GONE);
|
||||
* combo.setVisibility(Spinner.VISIBLE);
|
||||
*/
|
||||
// }
|
||||
// }
|
||||
}
|
|
@ -177,6 +177,9 @@ public class EventList extends ListActivity {
|
|||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case R.id.incidents_button_menu_options:
|
||||
startActivity(new Intent(this, CreateIncidentActivity.class));
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -18,17 +18,15 @@ 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.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -139,7 +137,7 @@ public class IncidentList extends ListActivity {
|
|||
@Override
|
||||
public int getCount() {
|
||||
// TODO +1?
|
||||
return incidents.size()+1;
|
||||
return incidents.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -210,7 +210,8 @@ public class Main extends Activity {
|
|||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other", ";"));
|
||||
|
||||
String return_api = Core.httpGet(getApplicationContext(), parameters);
|
||||
String return_api = Core.httpGet(getApplicationContext(),
|
||||
parameters);
|
||||
String[] lines = return_api.split("\n");
|
||||
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
|
@ -369,8 +370,11 @@ public class Main extends Activity {
|
|||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
|
||||
case R.id.incidents_button_menu_options:
|
||||
startActivity(new Intent(this, CreateIncidentActivity.class));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|