2012-07-30 Santiago Munín <burning1@gmail.com>
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java, src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java: Changed time measurement in the background check events. * res/layout/create_incident.xml: Fixed a edittext's bad behavior (bad stretching). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6829 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
7ec8ce0f85
commit
27c81e2ba1
|
@ -1,3 +1,8 @@
|
||||||
|
2012-07-30 Santiago Munín <burning1@gmail.com>
|
||||||
|
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java,
|
||||||
|
src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java: Changed time measurement in the background check events.
|
||||||
|
* res/layout/create_incident.xml: Fixed a edittext's bad behavior (bad stretching).
|
||||||
|
|
||||||
2012-07-14 Santiago Munín <burning1@gmail.com>
|
2012-07-14 Santiago Munín <burning1@gmail.com>
|
||||||
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java: Now uses the new getEvents() method in API class.
|
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerService.java: Now uses the new getEvents() method in API class.
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:layout_weight="9"
|
android:layout_weight="8"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:stretchColumns="1" >
|
android:stretchColumns="1" >
|
||||||
|
|
||||||
|
@ -24,14 +24,14 @@
|
||||||
style="@android:style/TextAppearance.Medium"
|
style="@android:style/TextAppearance.Medium"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:text="@string/title" />
|
android:text="@string/title" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/incident_title"
|
android:id="@+id/incident_title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
@ -45,105 +45,16 @@
|
||||||
style="@android:style/TextAppearance.Medium"
|
style="@android:style/TextAppearance.Medium"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:text="@string/description" />
|
android:text="@string/description" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/incident_description"
|
android:id="@+id/incident_description"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
</TableRow>
|
</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:layout_height="wrap_content"
|
|
||||||
android:entries="@array/incident_status" />
|
|
||||||
</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" />
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/loading_group"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
</TableRow>
|
|
||||||
-->
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -232,8 +232,8 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
||||||
SharedPreferences preferences = getSharedPreferences(
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
getString(R.string.const_string_preferences),
|
getString(R.string.const_string_preferences),
|
||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
long timestamp_notification = preferences.getLong("filterTimestamp",
|
long timestamp_notification = preferences.getLong(
|
||||||
(new Date().getTime() / 1000));
|
"new_events_last_timestamp", (new Date().getTime() / 1000));
|
||||||
Log.i(TAG + " process_notification_timestamp", ""
|
Log.i(TAG + " process_notification_timestamp", ""
|
||||||
+ timestamp_notification);
|
+ timestamp_notification);
|
||||||
this.timestamp = timestamp_notification;
|
this.timestamp = timestamp_notification;
|
||||||
|
@ -252,11 +252,9 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
long now = (c.getTimeInMillis() / 1000);
|
long now = (c.getTimeInMillis() / 1000);
|
||||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||||
// Save for the next execution
|
|
||||||
editorPreferences.putLong("filterTimestamp", now);
|
editorPreferences.putLong("new_events_last_timestamp",
|
||||||
// Save the previous for the list.
|
now);
|
||||||
editorPreferences.putLong("previous_filterTimestamp",
|
|
||||||
timestamp_notification);
|
|
||||||
if (editorPreferences.commit()) {
|
if (editorPreferences.commit()) {
|
||||||
Log.i(TAG + " (filter options)",
|
Log.i(TAG + " (filter options)",
|
||||||
"Configuration changes commited (timestamp)");
|
"Configuration changes commited (timestamp)");
|
||||||
|
|
|
@ -18,6 +18,7 @@ package pandroid_event_viewer.pandorafms;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.IntentService;
|
import android.app.IntentService;
|
||||||
|
@ -78,10 +79,22 @@ public class PandroidEventviewerService extends IntentService {
|
||||||
SharedPreferences preferences = context.getSharedPreferences(
|
SharedPreferences preferences = context.getSharedPreferences(
|
||||||
context.getString(R.string.const_string_preferences),
|
context.getString(R.string.const_string_preferences),
|
||||||
Activity.MODE_PRIVATE);
|
Activity.MODE_PRIVATE);
|
||||||
Calendar c = Calendar.getInstance();
|
|
||||||
long now = (c.getTimeInMillis() / 1000);
|
long new_events_filterTimestamp = preferences.getLong(
|
||||||
long old_previous_filterTimestamp = preferences.getLong(
|
"new_events_last_timestamp", 0);
|
||||||
"previous_filterTimestamp", now);
|
Editor editor;
|
||||||
|
// Sets a default time
|
||||||
|
if (new_events_filterTimestamp == 0) {
|
||||||
|
editor = preferences.edit();
|
||||||
|
new_events_filterTimestamp = Calendar.getInstance()
|
||||||
|
.getTimeInMillis() / 1000;
|
||||||
|
editor.putLong("new_events_last_timestamp",
|
||||||
|
new_events_filterTimestamp);
|
||||||
|
editor.commit();
|
||||||
|
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Retrieve events since: "
|
||||||
|
+ new Date(new_events_filterTimestamp * 1000).toString());
|
||||||
String filterAgentName = preferences.getString("filterAgentName", "");
|
String filterAgentName = preferences.getString("filterAgentName", "");
|
||||||
|
|
||||||
int idGroup = preferences.getInt("filterIDGroup", 0);
|
int idGroup = preferences.getInt("filterIDGroup", 0);
|
||||||
|
@ -90,13 +103,9 @@ public class PandroidEventviewerService extends IntentService {
|
||||||
String filterEventSearch = preferences.getString("filterEventSearch",
|
String filterEventSearch = preferences.getString("filterEventSearch",
|
||||||
"");
|
"");
|
||||||
String filterTag = preferences.getString("filterTag", "");
|
String filterTag = preferences.getString("filterTag", "");
|
||||||
|
|
||||||
c = Calendar.getInstance();
|
|
||||||
now = (c.getTimeInMillis() / 1000);
|
|
||||||
long filterTimestamp = preferences.getLong("filterTimestamp", now);
|
|
||||||
String return_api = API.getEvents(this, filterAgentName, idGroup,
|
String return_api = API.getEvents(this, filterAgentName, idGroup,
|
||||||
filterSeverity, filterStatus, filterEventSearch, filterTag,
|
filterSeverity, filterStatus, filterEventSearch, filterTag,
|
||||||
filterTimestamp, 20, 0, true, false);
|
new_events_filterTimestamp, 20, 0, true, false);
|
||||||
return_api = return_api.replace("\n", "");
|
return_api = return_api.replace("\n", "");
|
||||||
try {
|
try {
|
||||||
this.count_events = Long.valueOf(return_api);
|
this.count_events = Long.valueOf(return_api);
|
||||||
|
@ -110,7 +119,7 @@ public class PandroidEventviewerService extends IntentService {
|
||||||
Log.i(TAG, "There are new events");
|
Log.i(TAG, "There are new events");
|
||||||
return_api = API.getEvents(this, filterAgentName, idGroup,
|
return_api = API.getEvents(this, filterAgentName, idGroup,
|
||||||
filterSeverity, filterStatus, filterEventSearch, filterTag,
|
filterSeverity, filterStatus, filterEventSearch, filterTag,
|
||||||
filterTimestamp, 20, 0, false, true);
|
new_events_filterTimestamp, 20, 0, false, true);
|
||||||
return_api = return_api.replace("\n", "");
|
return_api = return_api.replace("\n", "");
|
||||||
try {
|
try {
|
||||||
this.more_criticity = Integer.valueOf(return_api).intValue();
|
this.more_criticity = Integer.valueOf(return_api).intValue();
|
||||||
|
@ -122,19 +131,13 @@ public class PandroidEventviewerService extends IntentService {
|
||||||
// Don't repeat the same notification
|
// Don't repeat the same notification
|
||||||
if (lastCountEvents != count_events) {
|
if (lastCountEvents != count_events) {
|
||||||
notificationEvent(context);
|
notificationEvent(context);
|
||||||
Editor editor = preferences.edit();
|
editor = preferences.edit();
|
||||||
editor.putLong("last_count_events", count_events);
|
editor.putLong("last_count_events", count_events);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.more_criticity = -1;
|
this.more_criticity = -1;
|
||||||
|
|
||||||
// Restore timestamp
|
|
||||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
|
||||||
editorPreferences.putLong("previous_filterTimestamp",
|
|
||||||
old_previous_filterTimestamp);
|
|
||||||
editorPreferences.commit();
|
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Check finished at "
|
Log.d(TAG, "Check finished at "
|
||||||
+ Calendar.getInstance().getTime().toGMTString());
|
+ Calendar.getInstance().getTime().toGMTString());
|
||||||
|
|
Loading…
Reference in New Issue