diff --git a/extras/pandroid_event_viewer/ChangeLog b/extras/pandroid_event_viewer/ChangeLog index e4dbbb2114..df2e8debac 100644 --- a/extras/pandroid_event_viewer/ChangeLog +++ b/extras/pandroid_event_viewer/ChangeLog @@ -1,3 +1,10 @@ +2012-07-06 Santiago Munín + * src/pandroid_event_viewer/pandorafms/Core.java: Service will only start if options were configured. + * src/pandroid_event_viewer/pandorafms/API.java: Removed a //TODO comment. + * src/pandroid_event_viewer/pandorafms/Options.java: A "configured" value is saved in preferences as true if options were configured. + * src/pandroid_event_viewer/pandorafms/EventList.java: Removed group images. + * res/layout/options.xml: Little UI changes. + 2012-07-05 Santiago Munín * src/pandroid_event_viewer/pandorafms/OnBootLoader.java: New BroadcastReceiver which starts the search new events service after the phone boot. * src/pandroid_event_viewer/pandorafms/Core.java: Little changes. diff --git a/extras/pandroid_event_viewer/res/layout/options.xml b/extras/pandroid_event_viewer/res/layout/options.xml index 11540fcc4f..36a0cc04ca 100644 --- a/extras/pandroid_event_viewer/res/layout/options.xml +++ b/extras/pandroid_event_viewer/res/layout/options.xml @@ -118,7 +118,7 @@ diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/API.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/API.java index 5eae38b4dc..d99e044114 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/API.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/API.java @@ -90,7 +90,6 @@ public class API { parameters.add(new BasicNameValuePair("op2", "test")); String return_api; return_api = Core.httpGet(context, parameters); - // TODO wait version if (return_api.contains("OK")) { String[] lines = return_api.split(","); if (lines.length == 3) { diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java index 64f43a7c1a..021c91514a 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Core.java @@ -115,22 +115,30 @@ public class Core { * Application context. */ public static void setFetchFrequency(Context ctx) { - Log.i(TAG, "Setting events fetching frequency"); - // Stops the service (if it's running) - ctx.stopService(new Intent(ctx, PandroidEventviewerService.class)); - // Sets the launch frequency - AlarmManager alarmM = (AlarmManager) ctx - .getSystemService(Context.ALARM_SERVICE); + SharedPreferences preferences = ctx.getSharedPreferences( + ctx.getString(R.string.const_string_preferences), + Activity.MODE_PRIVATE); + if (preferences.getBoolean("configured", false)) { + Log.i(TAG, "Setting events fetching frequency"); + // Stops the service (if it's running) + ctx.stopService(new Intent(ctx, PandroidEventviewerService.class)); + // Sets the launch frequency + AlarmManager alarmM = (AlarmManager) ctx + .getSystemService(Context.ALARM_SERVICE); - PendingIntent pandroidService = PendingIntent.getService(ctx, 0, - new Intent(ctx, PandroidEventviewerService.class), 0); + PendingIntent pandroidService = PendingIntent.getService(ctx, 0, + new Intent(ctx, PandroidEventviewerService.class), 0); - int sleepTimeAlarm = convertRefreshTimeKeyToTime(ctx); + int sleepTimeAlarm = convertRefreshTimeKeyToTime(ctx); - Log.i(TAG, "sleepTimeAlarm = " + sleepTimeAlarm); + Log.i(TAG, "sleepTimeAlarm = " + sleepTimeAlarm); - alarmM.setRepeating(AlarmManager.RTC_WAKEUP, - System.currentTimeMillis(), sleepTimeAlarm, pandroidService); + alarmM.setRepeating(AlarmManager.RTC_WAKEUP, + System.currentTimeMillis(), sleepTimeAlarm, pandroidService); + } else { + Log.i(TAG, + "Service wasn't started because the options aren't configured yet"); + } } /** @@ -331,7 +339,7 @@ public class Core { parameters.add(new BasicNameValuePair("apipass", apiPassword)); } parameters.addAll(additionalParameters); - Log.i(TAG, "sent: "+url); + Log.i(TAG, "sent: " + url); if (url.toLowerCase().contains("https")) { // Secure connection return Core.httpsGet(url, parameters); @@ -349,7 +357,7 @@ public class Core { entityResponse = response.getEntity(); return_api = Core .convertStreamToString(entityResponse.getContent()); - Log.i(TAG, "received: "+ return_api); + Log.i(TAG, "received: " + return_api); return return_api; } } 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 2fd1f5d681..87765d3a3f 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 @@ -18,15 +18,12 @@ package pandroid_event_viewer.pandorafms; import java.util.ArrayList; -import android.app.Activity; import android.app.ListActivity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.SharedPreferences; import android.content.res.Configuration; -import android.graphics.Bitmap; import android.graphics.Color; import android.os.Bundle; import android.text.Html; @@ -200,7 +197,7 @@ public class EventList extends ListActivity { } } - private String getImageGroupUrl(String group_icon) { + /*private String getImageGroupUrl(String group_icon) { SharedPreferences preferences = getApplicationContext() .getSharedPreferences( getApplicationContext().getString( @@ -209,7 +206,7 @@ public class EventList extends ListActivity { String url = preferences.getString("url", ""); return url + "/images/groups_small/" + group_icon + ".png"; - } + }+/ /** * Sets an image to the left of group's TextView. @@ -221,7 +218,7 @@ public class EventList extends ListActivity { * @param id * Group's TextView id; */ - private void setTextViewGroupImage(View view, String group_icon, int id) { + /*private void setTextViewGroupImage(View view, String group_icon, int id) { TextView tview = (TextView) view.findViewById(id); Bitmap img = null; @@ -238,7 +235,7 @@ public class EventList extends ListActivity { if (img != null) { Core.setTextViewLeftImage(tview, img); } - } + }*/ @Override protected void onListItemClick(ListView l, View v, int position, long id) { @@ -391,11 +388,6 @@ public class EventList extends ListActivity { .getSeverityImage(getApplicationContext(), item.criticity), 16); - if (item.group_icon.length() != 0) - Core.setTextViewLeftImage( - (TextView) view.findViewById(R.id.agent_name), - getImageGroupUrl(item.group_icon)); - if (item.status == 1) { Core.setTextViewLeftImage(timestamp, getResources() .getDrawable(R.drawable.tick), 24); @@ -445,13 +437,6 @@ public class EventList extends ListActivity { text = (TextView) viewEventExtended .findViewById(R.id.group_text); text.setText(item.group_name); - if (item.group_icon.length() != 0) - setTextViewGroupImage(viewEventExtended, - item.group_icon, R.id.group_text); - } else { - // ALL - setTextViewGroupImage(viewEventExtended, "world", - R.id.group_text); } if (item.agent_name.length() != 0) { @@ -517,7 +502,6 @@ public class EventList extends ListActivity { @Override public void onClick(View v) { - // TODO Intent intent = new Intent( getBaseContext(), CreateIncidentActivity.class); diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java index 9ed6d9c2a1..82a2750c3c 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Options.java @@ -214,6 +214,7 @@ public class Options extends Activity { editorPreferences.putBoolean("vibration", cb.isChecked()); cb = (CheckBox) findViewById(R.id.led_flash_on); editorPreferences.putBoolean("led", cb.isChecked()); + editorPreferences.putBoolean("configured", true); Context context = this.getApplicationContext();