2011-09-27 Miguel de Dios <miguel.dedios@artica.es>
* AndroidManifest.xml: change for avoid the crash when rotate mobile. * src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java, src/pandroid_event_viewer/pandorafms/AlarmReceiver.java, src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java, src/pandroid_event_viewer/pandorafms/Main.java, src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java, src/pandroid_event_viewer/pandorafms/Core.java, src/pandroid_event_viewer/pandorafms/EventList.java: wip and fixes, now it is the first version funcionality of Pandora Event Viewer....I hope. * res/values/arrays.xml, res/values/strings.xml, res/values-en/arrays.xml, res/values-en/strings.xml, res/values-es/arrays.xml, res/values-es/strings.xml: added more strings and array values. * res/layout/main.xml, res/layout/item_list_event_extended.xml, res/layout/popup_validation_event.xml: change and added layouts. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5015 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
00c6709e8a
commit
28cfe6ef86
|
@ -21,19 +21,49 @@
|
|||
<uses-sdk android:minSdkVersion="8" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<!--
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
|
||||
This is crazy, I want only block the screen rotation, but the android need
|
||||
two things.
|
||||
-->
|
||||
|
||||
<application android:icon="@drawable/pandorafms_logo"
|
||||
android:label="Pandroid Event viewer">
|
||||
<activity android:name=".PandroidEventviewerActivity"
|
||||
android:label="Pandroid Event viewer"
|
||||
android:theme="@android:style/Theme.NoTitleBar">
|
||||
<intent-filter>
|
||||
<activity
|
||||
android:name=".PandroidEventviewerActivity"
|
||||
android:label="Pandroid Event viewer"
|
||||
android:theme="@android:style/Theme.NoTitleBar"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".Main"></activity>
|
||||
<activity android:name=".EventList"></activity>
|
||||
<activity android:name=".Options" android:label="@string/option_title_str"></activity>
|
||||
<activity
|
||||
android:name=".Main"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".EventList"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".Options"
|
||||
android:label="@string/option_title_str"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".PopupValidationEvent"
|
||||
android:label="@string/validate_event_button_str"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
</activity>
|
||||
|
||||
<service android:name=".PandroidEventviewerService"></service>
|
||||
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
2011-09-27 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* AndroidManifest.xml: change for avoid the crash when rotate mobile.
|
||||
|
||||
* src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java,
|
||||
src/pandroid_event_viewer/pandorafms/AlarmReceiver.java,
|
||||
src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java,
|
||||
src/pandroid_event_viewer/pandorafms/Main.java,
|
||||
src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java,
|
||||
src/pandroid_event_viewer/pandorafms/Core.java,
|
||||
src/pandroid_event_viewer/pandorafms/EventList.java: wip and fixes, now it
|
||||
is the first version funcionality of Pandora Event Viewer....I hope.
|
||||
|
||||
* res/values/arrays.xml, res/values/strings.xml, res/values-en/arrays.xml,
|
||||
res/values-en/strings.xml, res/values-es/arrays.xml,
|
||||
res/values-es/strings.xml: added more strings and array values.
|
||||
|
||||
* res/layout/main.xml, res/layout/item_list_event_extended.xml,
|
||||
res/layout/popup_validation_event.xml: change and added layouts.
|
||||
|
||||
2011-09-25 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java: added
|
||||
|
|
|
@ -154,4 +154,14 @@
|
|||
android:text="- Empty -"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow
|
||||
android:gravity="right"
|
||||
>
|
||||
<Button
|
||||
android:id="@+id/validate_button_extended"
|
||||
android:text="@string/validate_event_button_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</TableRow>
|
||||
</TableLayout>
|
|
@ -80,7 +80,50 @@
|
|||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/status_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/status_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/event_search_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/event_search_text"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:editable="true"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/max_time_old_event_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/max_time_old_event_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
<!--
|
||||
<TextView
|
||||
android:text="@string/date_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -98,6 +141,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?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:orientation="vertical"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<EditText
|
||||
android:id="@+id/comment"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:inputType="textMultiLine"
|
||||
android:singleLine="false"
|
||||
android:lines="5"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/button_validate_event"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:text="@string/validate_event_button_str"
|
||||
/>
|
||||
<ProgressBar
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/send_progress"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
</LinearLayout>
|
|
@ -47,4 +47,34 @@
|
|||
<item>36 hours</item>
|
||||
<item>48 hours</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="event_status_values">
|
||||
<!-- You must subtract -1 -->
|
||||
<item>All event</item>
|
||||
<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>
|
||||
</resources>
|
|
@ -53,6 +53,7 @@
|
|||
<string name="please_set_preferences_str">Please set the preferences as the API URL, user and password for your Pandora FMS.</string>
|
||||
<string name="filter_update_succesful_str">Update filter sucessful.</string>
|
||||
<string name="filter_update_fail_str">Update filter is failed.</string>
|
||||
<string name="validate_event_button_str">Validate Event</string>
|
||||
|
||||
<string name="notification_criticity_0_str">There are %s events and all in Maintenance state.</string>
|
||||
<string name="notification_criticity_1_str">There are %s events and some are in Informational state.</string>
|
||||
|
@ -65,4 +66,11 @@
|
|||
<string name="loading_events_criticity_2_str">Loading the %s events and some are in Normal state.</string>
|
||||
<string name="loading_events_criticity_3_str">Loading the %s events and some are in Warning state.</string>
|
||||
<string name="loading_events_criticity_4_str">Loading the %s events and some are in Critical state.</string>
|
||||
|
||||
<string name="successful_validate_event_str">The event validation is successful.</string>
|
||||
<string name="fail_validate_event_str">The event validation is failed.</string>
|
||||
|
||||
<string name="status_label_str">Status</string>
|
||||
<string name="event_search_label_str">Event search</string>
|
||||
<string name="max_time_old_event_str">Max time old event</string>
|
||||
</resources>
|
||||
|
|
|
@ -47,4 +47,34 @@
|
|||
<item>36 horas</item>
|
||||
<item>48 horas</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="event_status_values">
|
||||
<!-- You must subtract -1 -->
|
||||
<item>Todo los eventos</item>
|
||||
<item>Solo los nuevos</item>
|
||||
<item>Solo los validados</item>
|
||||
<item>Solo los en proceso</item>
|
||||
<item>Solo los no validados</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Please change the code in the function convertMaxTimeOldEventValuesToTimestamp -->
|
||||
<string-array name="max_time_old_event_values">
|
||||
<item>30 minutos</item>
|
||||
<item>1 hora</item>
|
||||
<item>2 horas</item>
|
||||
<item>3 horas</item>
|
||||
<item>4 horas</item>
|
||||
<item>5 horas</item>
|
||||
<item>8 horas</item>
|
||||
<item>10 horas</item>
|
||||
<item>12 horas</item>
|
||||
<item>1 día</item>
|
||||
<item>2 días</item>
|
||||
<item>3 días</item>
|
||||
<item>4 días</item>
|
||||
<item>5 días</item>
|
||||
<item>1 semana</item>
|
||||
<item>2 semanas</item>
|
||||
<item>1 mes</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -47,6 +47,7 @@
|
|||
<string name="empty_label_str">Lista vacia de eventos</string>
|
||||
<string name="refresh_time_label_str">Refresco scanner eventos</string>
|
||||
<string name="set_as_filter_watcher_button_str">Hacerlo filtro para scanner eventos</string>
|
||||
<string name="validate_event_button_str">Validar Evento</string>
|
||||
|
||||
<string name="config_update_succesful_str">Configuración guardada correctamente.</string>
|
||||
<string name="config_update_fail_str">Configuración no ha podido guardarse..</string>
|
||||
|
@ -65,4 +66,11 @@
|
|||
<string name="loading_events_criticity_2_str">Cargando los %s eventos y algunos son Normales.</string>
|
||||
<string name="loading_events_criticity_3_str">Cargando los %s eventos y algunos son Aviso.</string>
|
||||
<string name="loading_events_criticity_4_str">Cargando los %s eventos y algunos son Criticos.</string>
|
||||
|
||||
<string name="successful_validate_event_str">Validación del evento correcta.</string>
|
||||
<string name="fail_validate_event_str">Validación del evento incorrecta.</string>
|
||||
|
||||
<string name="status_label_str">Estado</string>
|
||||
<string name="event_search_label_str">Buscar evento</string>
|
||||
<string name="max_time_old_event_str">Máx tiempo de antiguedad</string>
|
||||
</resources>
|
||||
|
|
|
@ -47,4 +47,34 @@
|
|||
<item>36 hours</item>
|
||||
<item>48 hours</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="event_status_values">
|
||||
<!-- You must subtract -1 -->
|
||||
<item>All event</item>
|
||||
<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>
|
||||
</resources>
|
|
@ -52,6 +52,7 @@
|
|||
<string name="empty_label_str">Empty list events</string>
|
||||
<string name="refresh_time_label_str">Refresh time watcher</string>
|
||||
<string name="set_as_filter_watcher_button_str">Set as filter for watcher</string>
|
||||
<string name="validate_event_button_str">Validate Event</string>
|
||||
|
||||
<string name="config_update_succesful_str">Update configuration successful.</string>
|
||||
<string name="config_update_fail_str">Update configuration is failed.</string>
|
||||
|
@ -70,4 +71,11 @@
|
|||
<string name="loading_events_criticity_2_str">Loading the %s events and some are in Normal state.</string>
|
||||
<string name="loading_events_criticity_3_str">Loading the %s events and some are in Warning state.</string>
|
||||
<string name="loading_events_criticity_4_str">Loading the %s events and some are in Critical state.</string>
|
||||
|
||||
<string name="successful_validate_event_str">The event validation is successful.</string>
|
||||
<string name="fail_validate_event_str">The event validation is failed.</string>
|
||||
|
||||
<string name="status_label_str">Status</string>
|
||||
<string name="event_search_label_str">Event search</string>
|
||||
<string name="max_time_old_event_str">Max time old event</string>
|
||||
</resources>
|
||||
|
|
|
@ -20,8 +20,6 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
public class AlarmReceiver extends BroadcastReceiver {
|
||||
|
@ -34,7 +32,6 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// TODO Auto-generated method stub
|
||||
Log.e("OnetimeAlarmReceiver", "onReceive");
|
||||
|
||||
checkNewEvents(context);
|
||||
|
@ -124,6 +121,9 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|||
String filterAgentName = preferences.getString("filterAgentName", "");
|
||||
int filterIDGroup = preferences.getInt("filterIDGroup", 0);
|
||||
int filterSeverity = preferences.getInt("filterSeverity", -1);
|
||||
int filterStatus = preferences.getInt("filterStatus", -1);
|
||||
String filterEventSearch = preferences.getString("filterEventSearch", "");
|
||||
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
long now = (c.getTimeInMillis() / 1000);
|
||||
|
@ -154,6 +154,10 @@ public class AlarmReceiver extends BroadcastReceiver {
|
|||
return_var += "|";
|
||||
return_var += ""; //The maximum timestamp
|
||||
return_var += "|";
|
||||
return_var += filterStatus; //The status
|
||||
return_var += "|";
|
||||
return_var += filterEventSearch; //The free search in the text event description.
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(0); //The pagination of list events
|
||||
return_var += "|";
|
||||
return_var += Long.toString(0); //The offset of list events
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.io.BufferedReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -92,4 +93,70 @@ public class Core implements Parcelable{
|
|||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public long convertMaxTimeOldEventValuesToTimestamp(long timestamp, int arrayKey) {
|
||||
long time = timestamp;
|
||||
long return_var = 0;
|
||||
|
||||
if (time == 0) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
time = c.getTimeInMillis() / 1000;
|
||||
}
|
||||
|
||||
switch (arrayKey) {
|
||||
case 0:
|
||||
return_var = time - 30 * 60;
|
||||
break;
|
||||
case 1:
|
||||
return_var = time - 60 * 60;
|
||||
break;
|
||||
case 2:
|
||||
return_var = time - 2 * (60 * 60);
|
||||
break;
|
||||
case 3:
|
||||
return_var = time - 3 * (60 * 60);
|
||||
break;
|
||||
case 4:
|
||||
return_var = time - 4 * (60 * 60);
|
||||
break;
|
||||
case 5:
|
||||
return_var = time - 5 * (60 * 60);
|
||||
break;
|
||||
case 6:
|
||||
return_var = time - 8 * (60 * 60);
|
||||
break;
|
||||
case 7:
|
||||
return_var = time - 10 * (60 * 60);
|
||||
break;
|
||||
case 8:
|
||||
return_var = time - 12 * (60 * 60);
|
||||
break;
|
||||
case 9:
|
||||
return_var = time - 24 * (60 * 60);
|
||||
break;
|
||||
case 10:
|
||||
return_var = time - 2 * (24 * 60 * 60);
|
||||
break;
|
||||
case 11:
|
||||
return_var = time - 3 * (24 * 60 * 60);
|
||||
break;
|
||||
case 12:
|
||||
return_var = time - 4 * (24 * 60 * 60);
|
||||
break;
|
||||
case 13:
|
||||
return_var = time - 5 * (24 * 60 * 60);
|
||||
break;
|
||||
case 14:
|
||||
return_var = time - 7 * (24 * 60 * 60);
|
||||
break;
|
||||
case 15:
|
||||
return_var = time - 2 * (7 * 24 * 60 * 60);
|
||||
break;
|
||||
case 16:
|
||||
return_var = time - 30 * (24 * 60 * 60);
|
||||
break;
|
||||
}
|
||||
|
||||
return return_var;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
|
@ -22,6 +23,7 @@ import android.view.Menu;
|
|||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
|
@ -30,7 +32,6 @@ import android.widget.LinearLayout;
|
|||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class EventList extends ListActivity {
|
||||
private ListView lv;
|
||||
|
@ -66,7 +67,7 @@ public class EventList extends ListActivity {
|
|||
|
||||
lv = (ListView)findViewById(android.R.id.list);
|
||||
|
||||
la = new MyAdapter(getBaseContext(), object);
|
||||
la = new MyAdapter(getBaseContext(), object, core);
|
||||
|
||||
lv.setAdapter(la);
|
||||
|
||||
|
@ -93,16 +94,30 @@ public class EventList extends ListActivity {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
||||
|
||||
this.toggleLoadingLayout();
|
||||
|
||||
Log.e("EventList", "onCreate");
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Log.e("EventList", "onResume");
|
||||
|
||||
|
||||
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
||||
|
||||
this.toggleLoadingLayout();
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
Log.e("EventList", "onConfigurationChanged");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
|
@ -248,14 +263,16 @@ public class EventList extends ListActivity {
|
|||
{
|
||||
private Context mContext;
|
||||
public PandroidEventviewerActivity object;
|
||||
public Core core;
|
||||
|
||||
public boolean showLoadingEvents;
|
||||
|
||||
public MyAdapter(Context c, PandroidEventviewerActivity object)
|
||||
public MyAdapter(Context c, PandroidEventviewerActivity object, Core core)
|
||||
{
|
||||
mContext = c;
|
||||
|
||||
this.object = object;
|
||||
this.core = core;
|
||||
|
||||
showLoadingEvents = false;
|
||||
}
|
||||
|
@ -408,6 +425,16 @@ public class EventList extends ListActivity {
|
|||
setImageType(viewEventExtended, item.criticity_image, R.id.img_severity);
|
||||
}
|
||||
|
||||
|
||||
final Button button;
|
||||
button = (Button)viewEventExtended.findViewById(R.id.validate_button_extended);
|
||||
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate();
|
||||
clickListener.id_event = item.id_event;
|
||||
//clickListener.object = this.object;
|
||||
clickListener.core = this.core;
|
||||
button.setOnClickListener(clickListener);
|
||||
|
||||
|
||||
LinearLayout itemLinearLayout = (LinearLayout)view.findViewById(R.id.item_linear_layout);
|
||||
itemLinearLayout.addView(viewEventExtended);
|
||||
}
|
||||
|
@ -416,6 +443,23 @@ public class EventList extends ListActivity {
|
|||
return view;
|
||||
}
|
||||
|
||||
public class OnClickListenerButtonValidate implements OnClickListener {
|
||||
public int id_event;
|
||||
//public PandroidEventviewerActivity object;
|
||||
public Core core;
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(getApplicationContext(), PopupValidationEvent.class);
|
||||
i.putExtra("id_event", id_event);
|
||||
//i.putExtra("object", this.object);
|
||||
i.putExtra("core", this.core);
|
||||
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -17,11 +15,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
|
|||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -33,11 +27,9 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TimePicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Main extends Activity {
|
||||
|
@ -91,6 +83,21 @@ public class Main extends Activity {
|
|||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
comboSeverity.setAdapter(adapter);
|
||||
|
||||
|
||||
Spinner combo;
|
||||
combo = (Spinner) findViewById(R.id.status_combo);
|
||||
adapter = ArrayAdapter.createFromResource(
|
||||
this, R.array.event_status_values, android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
combo.setAdapter(adapter);
|
||||
|
||||
combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
|
||||
adapter = ArrayAdapter.createFromResource(
|
||||
this, R.array.max_time_old_event_values, android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
combo.setAdapter(adapter);
|
||||
|
||||
|
||||
buttonReset.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -109,7 +116,6 @@ public class Main extends Activity {
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
save_filter_watcher();
|
||||
}
|
||||
});
|
||||
|
@ -223,6 +229,7 @@ public class Main extends Activity {
|
|||
this.object.loadInProgress = true;
|
||||
|
||||
//Get form data
|
||||
/*
|
||||
DatePicker datePicker = (DatePicker)findViewById(R.id.date);
|
||||
TimePicker timePicker = (TimePicker)findViewById(R.id.time);
|
||||
int day = datePicker.getDayOfMonth();
|
||||
|
@ -234,13 +241,20 @@ public class Main extends Activity {
|
|||
c.set(year, month, day, hour, minute);
|
||||
|
||||
this.object.timestamp = c.getTimeInMillis() / 1000;
|
||||
*/
|
||||
|
||||
EditText agentName = (EditText) findViewById(R.id.agent_name);
|
||||
String agentNameStr = agentName.getText().toString();
|
||||
|
||||
int timeKey = 0;
|
||||
Spinner combo = (Spinner)findViewById(R.id.max_time_old_event_combo);
|
||||
timeKey = combo.getSelectedItemPosition();
|
||||
|
||||
this.object.timestamp = this.core.convertMaxTimeOldEventValuesToTimestamp(0, timeKey);
|
||||
|
||||
EditText text = (EditText) findViewById(R.id.agent_name);
|
||||
this.object.agentNameStr = text.getText().toString();
|
||||
|
||||
this.object.id_group = 0;
|
||||
|
||||
Spinner combo;
|
||||
int sel;
|
||||
combo = (Spinner) findViewById(R.id.group_combo);
|
||||
String selectedGroup = combo.getSelectedItem().toString();
|
||||
|
@ -257,6 +271,12 @@ public class Main extends Activity {
|
|||
combo = (Spinner) findViewById(R.id.severity_combo);
|
||||
this.object.severity = combo.getSelectedItemPosition() - 1;
|
||||
|
||||
combo = (Spinner)findViewById(R.id.status_combo);
|
||||
this.object.status = combo.getSelectedItemPosition() - 1;
|
||||
|
||||
text = (EditText)findViewById(R.id.event_search_text);
|
||||
this.object.eventSearch = text.getText().toString();
|
||||
|
||||
this.object.getNewListEvents = true;
|
||||
this.object.executeBackgroundGetEvents();
|
||||
|
||||
|
@ -268,10 +288,12 @@ public class Main extends Activity {
|
|||
String filterAgentName = "";
|
||||
int filterIDGroup = 0;
|
||||
int filterSeverity = -1;
|
||||
int filterStatus = -1;
|
||||
String filterEventSearch = "";
|
||||
|
||||
|
||||
EditText agentName = (EditText) findViewById(R.id.agent_name);
|
||||
filterAgentName = agentName.getText().toString();
|
||||
EditText text = (EditText) findViewById(R.id.agent_name);
|
||||
filterAgentName = text.getText().toString();
|
||||
|
||||
Spinner combo;
|
||||
combo = (Spinner) findViewById(R.id.group_combo);
|
||||
|
@ -289,6 +311,12 @@ public class Main extends Activity {
|
|||
combo = (Spinner) findViewById(R.id.severity_combo);
|
||||
filterSeverity = combo.getSelectedItemPosition();
|
||||
|
||||
combo = (Spinner)findViewById(R.id.status_combo);
|
||||
filterStatus = combo.getSelectedItemPosition() - 1;
|
||||
|
||||
text = (EditText)findViewById(R.id.event_search_text);
|
||||
filterEventSearch = text.getText().toString();
|
||||
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
|
@ -298,6 +326,8 @@ public class Main extends Activity {
|
|||
editorPreferences.putString("filterAgentName", filterAgentName);
|
||||
editorPreferences.putInt("filterIDGroup", filterIDGroup);
|
||||
editorPreferences.putInt("filterSeverity", filterSeverity);
|
||||
editorPreferences.putInt("filterStatus", filterStatus);
|
||||
editorPreferences.putString("filterEventSearch", filterEventSearch);
|
||||
|
||||
if (editorPreferences.commit()) {
|
||||
this.core.stopServiceEventWatcher(getApplicationContext());
|
||||
|
@ -315,8 +345,8 @@ public class Main extends Activity {
|
|||
}
|
||||
|
||||
public void reset_form() {
|
||||
EditText agentEditText = (EditText)findViewById(R.id.agent_name);
|
||||
agentEditText.setText("");
|
||||
EditText text = (EditText)findViewById(R.id.agent_name);
|
||||
text.setText("");
|
||||
|
||||
Spinner combo = (Spinner) findViewById(R.id.group_combo);
|
||||
combo.setSelection(0);
|
||||
|
@ -324,6 +354,16 @@ public class Main extends Activity {
|
|||
combo = (Spinner) findViewById(R.id.severity_combo);
|
||||
combo.setSelection(0);
|
||||
|
||||
combo = (Spinner)findViewById(R.id.max_time_old_event_combo);
|
||||
combo.setSelection(0);
|
||||
|
||||
combo = (Spinner)findViewById(R.id.status_combo);
|
||||
combo.setSelection(0);
|
||||
|
||||
text = (EditText)findViewById(R.id.event_search_text);
|
||||
text.setText("");
|
||||
|
||||
/*
|
||||
Calendar c = Calendar.getInstance();
|
||||
DatePicker datePicker = (DatePicker)findViewById(R.id.date);
|
||||
datePicker.updateDate(c.get(Calendar.YEAR),
|
||||
|
@ -333,5 +373,6 @@ public class Main extends Activity {
|
|||
TimePicker timePicker = (TimePicker)findViewById(R.id.time);
|
||||
timePicker.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
|
||||
timePicker.setCurrentMinute(c.get(Calendar.MINUTE));
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,6 @@
|
|||
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
@ -31,11 +27,11 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import android.R.bool;
|
||||
import android.app.Activity;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
@ -63,6 +59,8 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
|
|||
public int severity;
|
||||
public int pagination;
|
||||
public long offset;
|
||||
public int status;
|
||||
public String eventSearch;
|
||||
|
||||
public Intent intent_service;
|
||||
|
||||
|
@ -88,6 +86,8 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
|
|||
this.offset = 0;
|
||||
this.agentNameStr = "";
|
||||
this.severity = -1;
|
||||
this.status = -1;
|
||||
this.eventSearch = "";
|
||||
|
||||
this.eventList = new ArrayList<EventListItem>();
|
||||
this.loadInProgress = false;
|
||||
|
@ -140,6 +140,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
|
|||
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=45;
|
||||
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height=45;
|
||||
|
||||
Log.e("PandroidEventviewerActivity", "onCreate");
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
|
@ -196,6 +197,14 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
|
|||
}
|
||||
|
||||
executeBackgroundGetEvents();
|
||||
|
||||
Log.e("PandroidEventviewerActivity", "onResume");
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
Log.e("PandroidEventviewerActivity", "onConfigurationChanged");
|
||||
}
|
||||
|
||||
public String serializeParams2Api() {
|
||||
|
@ -217,6 +226,10 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
|
|||
return_var += "|";
|
||||
return_var += ""; //The maximum timestamp
|
||||
return_var += "|";
|
||||
return_var += this.status; //The status
|
||||
return_var += "|";
|
||||
return_var += this.eventSearch; //The free search in the text event description.
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(this.pagination); //The pagination of list events
|
||||
return_var += "|";
|
||||
return_var += Long.toString(this.offset); //The offset of list events
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
|
|
|
@ -1,12 +1,161 @@
|
|||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class PopupValidationEvent extends Activity {
|
||||
public int id_event;
|
||||
public String comment;
|
||||
|
||||
public PandroidEventviewerActivity object;
|
||||
public Core core;
|
||||
|
||||
public String url;
|
||||
public String user;
|
||||
public String password;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent i = getIntent();
|
||||
this.id_event = i.getIntExtra("id_event", -1);
|
||||
//this.object = (PandroidEventviewerActivity)i.getSerializableExtra("object");
|
||||
this.core = (Core)i.getParcelableExtra("core");
|
||||
|
||||
setContentView(R.layout.popup_validation_event);
|
||||
|
||||
final Button button = (Button) findViewById(R.id.button_validate_event);
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
validateEvent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void validateEvent() {
|
||||
EditText textbox = (EditText) findViewById(R.id.comment);
|
||||
String comment = textbox.getText().toString();
|
||||
Button button = (Button) findViewById(R.id.button_validate_event);
|
||||
ProgressBar pb = (ProgressBar) findViewById(R.id.send_progress);
|
||||
|
||||
button.setVisibility(Button.GONE);
|
||||
pb.setVisibility(ProgressBar.VISIBLE);
|
||||
|
||||
this.comment = "Validate from Pandroid Eventviewer Mobile: " + comment;
|
||||
|
||||
new SendValidationAsyncTask().execute();
|
||||
}
|
||||
|
||||
public void destroyPopup() {
|
||||
finish();
|
||||
}
|
||||
|
||||
public boolean sendValidation() {
|
||||
boolean return_var = false;
|
||||
|
||||
if (this.url == null) {
|
||||
SharedPreferences preferences = getApplicationContext().getSharedPreferences(
|
||||
getApplicationContext().getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
this.url = preferences.getString("url", "");
|
||||
this.user = preferences.getString("user", "");
|
||||
this.password = preferences.getString("password", "");
|
||||
}
|
||||
try {
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
UrlEncodedFormEntity entity;
|
||||
HttpPost httpPost;
|
||||
List<NameValuePair> parameters;
|
||||
HttpResponse response;
|
||||
HttpEntity entityResponse;
|
||||
String return_api;
|
||||
|
||||
httpPost = new HttpPost(this.url);
|
||||
|
||||
//Set event validation.
|
||||
parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("user", this.user));
|
||||
parameters.add(new BasicNameValuePair("pass", this.password));
|
||||
parameters.add(new BasicNameValuePair("op", "set"));
|
||||
parameters.add(new BasicNameValuePair("op2", "validate_events"));
|
||||
parameters.add(new BasicNameValuePair("id", new Integer(this.id_event).toString()));
|
||||
parameters.add(new BasicNameValuePair("other", this.comment));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core.convertStreamToString(entityResponse.getContent());
|
||||
return_api = return_api.replace("\n", "");
|
||||
|
||||
if (return_api.startsWith("Correct validation")) {
|
||||
return_var = true;
|
||||
}
|
||||
|
||||
Log.e("sendValidation", return_api);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e("ERROR THE ", e.getMessage());
|
||||
}
|
||||
|
||||
return return_var;
|
||||
}
|
||||
|
||||
public class SendValidationAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
public ArrayList<String> lista;
|
||||
public boolean result;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
result = sendValidation();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void unused)
|
||||
{
|
||||
String text;
|
||||
|
||||
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();
|
||||
|
||||
if (result) {
|
||||
destroyPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue