diff --git a/extras/pandroid_event_viewer/ChangeLog b/extras/pandroid_event_viewer/ChangeLog index 86e006fcfe..010c477b08 100644 --- a/extras/pandroid_event_viewer/ChangeLog +++ b/extras/pandroid_event_viewer/ChangeLog @@ -1,3 +1,17 @@ +2011-09-25 Miguel de Dios + + * src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java: added + empty file for to work in this in the monday. + + * 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/EventList.java: added the hook to + list event from notification. And fixed the search. + + * res/values/strings.xml, res/values-en/strings.xml, + res/values-es/strings.xml: added more strings values. + 2011-09-23 Miguel de Dios * src/pandroid_event_viewer/pandorafms/AlarmReceiver.java, @@ -23,7 +37,6 @@ * res/layout/main.xml: added a third button, the filter, to set the actual search as filter for the background event watcher. - 2011-09-22 Miguel de Dios * AndroidManifest.xml: added the lines for the service and broadcastreciver. diff --git a/extras/pandroid_event_viewer/res/values-en/strings.xml b/extras/pandroid_event_viewer/res/values-en/strings.xml index 181100ea3c..b1d4061158 100644 --- a/extras/pandroid_event_viewer/res/values-en/strings.xml +++ b/extras/pandroid_event_viewer/res/values-en/strings.xml @@ -59,4 +59,10 @@ There are %s events and some are in Normal state. There are %s events and some are in Warning state. There are %s events and some are in Critical state. + + Loading the %s events and all in Maintenance state. + Loading the %s events and some are in Informational state. + Loading the %s events and some are in Normal state. + Loading the %s events and some are in Warning state. + Loading the %s events and some are in Critical state. diff --git a/extras/pandroid_event_viewer/res/values-es/strings.xml b/extras/pandroid_event_viewer/res/values-es/strings.xml index d2f386ebab..af49b0d662 100644 --- a/extras/pandroid_event_viewer/res/values-es/strings.xml +++ b/extras/pandroid_event_viewer/res/values-es/strings.xml @@ -59,4 +59,10 @@ Hay %s eventos y algunos son Normales. Hay %s eventos y algunos son Aviso. Hay %s eventos y algunos son Criticos. + + Cargando los %s eventos y todos son de Mantenimiento. + Cargando los %s eventos y algunos son InformaciĆ³n. + Cargando los %s eventos y algunos son Normales. + Cargando los %s eventos y algunos son Aviso. + Cargando los %s eventos y algunos son Criticos. diff --git a/extras/pandroid_event_viewer/res/values/strings.xml b/extras/pandroid_event_viewer/res/values/strings.xml index d42d87a3ba..4a0f278cbc 100644 --- a/extras/pandroid_event_viewer/res/values/strings.xml +++ b/extras/pandroid_event_viewer/res/values/strings.xml @@ -64,4 +64,10 @@ There are %s events and some are in Normal state. There are %s events and some are in Warning state. There are %s events and some are in Critical state. + + Loading the %s events and all in Maintenance state. + Loading the %s events and some are in Informational state. + Loading the %s events and some are in Normal state. + Loading the %s events and some are in Warning state. + Loading the %s events and some are in Critical state. diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/AlarmReceiver.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/AlarmReceiver.java index 7c783448a7..4ee9174a65 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/AlarmReceiver.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/AlarmReceiver.java @@ -130,6 +130,7 @@ public class AlarmReceiver extends BroadcastReceiver { long filterTimestamp = preferences.getLong("filterTimestamp", now); SharedPreferences.Editor editorPreferences = preferences.edit(); editorPreferences.putLong("filterTimestamp", now); //Save for the next execution. + editorPreferences.putLong("previous_filterTimestamp", filterTimestamp); //Save and the previous for the list. editorPreferences.commit(); @@ -219,7 +220,10 @@ public class AlarmReceiver extends BroadcastReceiver { - Intent notificationIntent = new Intent(context, Options.class); + Intent notificationIntent = new Intent(context, PandroidEventviewerActivity.class); + notificationIntent.putExtra("count_events", this.count_events); + notificationIntent.putExtra("more_criticity", this.more_criticity); + PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); CharSequence title = context.getString(R.string.pandroid_event_viewer_str); diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java index 1e61a5e26b..a1033c5b34 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/EventList.java @@ -43,7 +43,6 @@ public class EventList extends ListActivity { public HashMap imgGroups; public HashMap imgSeverity; public HashMap imgType; - public String test; private BroadcastReceiver onBroadcast; @@ -71,8 +70,6 @@ public class EventList extends ListActivity { lv.setAdapter(la); - test = "666"; - onBroadcast = new BroadcastReceiver() { @Override @@ -128,13 +125,18 @@ public class EventList extends ListActivity { } public void toggleLoadingLayout() { - LinearLayout loadingLayout = (LinearLayout) findViewById(R.id.loading_layout); + LinearLayout layout; + + layout = (LinearLayout) findViewById(R.id.empty_list_layout); + layout.setVisibility(LinearLayout.GONE); + + layout = (LinearLayout) findViewById(R.id.loading_layout); if (this.object.loadInProgress) { - loadingLayout.setVisibility(LinearLayout.VISIBLE); + layout.setVisibility(LinearLayout.VISIBLE); } else { - loadingLayout.setVisibility(LinearLayout.GONE); + layout.setVisibility(LinearLayout.GONE); } } diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java index 170b3f3c74..b05d153234 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java @@ -226,12 +226,14 @@ public class Main extends Activity { DatePicker datePicker = (DatePicker)findViewById(R.id.date); TimePicker timePicker = (TimePicker)findViewById(R.id.time); int day = datePicker.getDayOfMonth(); - int month = datePicker.getMonth() + 1; + int month = datePicker.getMonth(); int year = datePicker.getYear(); int hour = timePicker.getCurrentHour(); int minute = timePicker.getCurrentMinute(); - Date date = new Date(year, month, day, minute, hour); - this.object.timestamp = date.getTime() / 1000; + Calendar c = Calendar.getInstance(); + 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(); @@ -253,9 +255,9 @@ public class Main extends Activity { } combo = (Spinner) findViewById(R.id.severity_combo); - this.object.severity = combo.getSelectedItemPosition(); - + this.object.severity = combo.getSelectedItemPosition() - 1; + this.object.getNewListEvents = true; this.object.executeBackgroundGetEvents(); TabActivity ta = (TabActivity) this.getParent(); diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java index cbe09aeaa5..aca1000bad 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java @@ -40,6 +40,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; import android.widget.TabHost; +import android.widget.Toast; public class PandroidEventviewerActivity extends TabActivity implements Serializable { //Data aplication @@ -107,8 +108,6 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ this.loadInProgress = true; } - executeBackgroundGetEvents(); - //Start the background service for the notifications this.core = new Core(); this.core.startServiceEventWatcher(getApplicationContext()); @@ -140,6 +139,63 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=45; tabHost.getTabWidget().getChildAt(1).getLayoutParams().height=45; + + } + + public void onResume() { + super.onResume(); + + Intent i = getIntent(); + long count_events = i.getLongExtra("count_events", 0); + int more_criticity = i.getIntExtra("more_criticity", -1); + + CharSequence text; + + Log.e("count_events", new Long(count_events).toString()); + + if (count_events > 0) { + switch (more_criticity) { + case 0: + text = getString(R.string.loading_events_criticity_0_str) + .replace("%s", new Long(count_events).toString()); + break; + case 1: + text = getString(R.string.loading_events_criticity_1_str) + .replace("%s", new Long(count_events).toString()); + break; + case 2: + text = getString(R.string.loading_events_criticity_2_str) + .replace("%s", new Long(count_events).toString()); + break; + case 3: + text = getString(R.string.loading_events_criticity_3_str) + .replace("%s", new Long(count_events).toString()); + break; + case 4: + text = getString(R.string.loading_events_criticity_4_str) + .replace("%s", new Long(count_events).toString()); + break; + default: + text = getString(R.string.loading_events_criticity_2_str) + .replace("%s", new Long(count_events).toString()); + break; + } + + + Toast toast = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT); + toast.show(); + + //Set the time when the watcher find the events. + SharedPreferences preferences = getSharedPreferences( + getString(R.string.const_string_preferences), + Activity.MODE_PRIVATE); + this.timestamp = preferences.getLong("previous_filterTimestamp", (new Date().getTime() / 1000)); + + + this.getTabHost().setCurrentTab(1); + } + + executeBackgroundGetEvents(); } public String serializeParams2Api() { @@ -165,6 +221,8 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ return_var += "|"; return_var += Long.toString(this.offset); //The offset of list events + Log.e("getEvents", return_var); + return return_var; } @@ -197,6 +255,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ return_api = Core.convertStreamToString(entityResponse.getContent()); return_api = return_api.replace("\n", ""); this.count_events = new Long(return_api).longValue(); + Log.e("count_events", return_api); if (this.count_events == 0) { return; @@ -332,7 +391,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ loadInProgress = false; getNewListEvents = false; - i.putExtra("load_more", 0); + i.putExtra("load_more", 0); } else { i.putExtra("load_more", 1); diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java new file mode 100644 index 0000000000..490042607b --- /dev/null +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java @@ -0,0 +1,12 @@ +package pandroid_event_viewer.pandorafms; + +import android.app.Activity; +import android.os.Bundle; + +public class PopupValidationEvent extends Activity { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } +}