2012-07-06 Santiago Munin <burning1@gmail.com>

* 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.


git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6744 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
santimunin 2012-07-06 08:02:31 +00:00
parent c5ea8e4da3
commit 41bd6a881c
6 changed files with 35 additions and 36 deletions

View File

@ -1,3 +1,10 @@
2012-07-06 Santiago Munín <burning1@gmail.com>
* 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 <burning1@gmail.com> 2012-07-05 Santiago Munín <burning1@gmail.com>
* 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/OnBootLoader.java: New BroadcastReceiver which starts the search new events service after the phone boot.
* src/pandroid_event_viewer/pandorafms/Core.java: Little changes. * src/pandroid_event_viewer/pandorafms/Core.java: Little changes.

View File

@ -118,7 +118,7 @@
<Spinner <Spinner
android:id="@+id/refresh_combo" android:id="@+id/refresh_combo"
android:layout_width="wrap_content" android:layout_width="150dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="left" /> android:gravity="left" />
</LinearLayout> </LinearLayout>

View File

@ -90,7 +90,6 @@ public class API {
parameters.add(new BasicNameValuePair("op2", "test")); parameters.add(new BasicNameValuePair("op2", "test"));
String return_api; String return_api;
return_api = Core.httpGet(context, parameters); return_api = Core.httpGet(context, parameters);
// TODO wait version
if (return_api.contains("OK")) { if (return_api.contains("OK")) {
String[] lines = return_api.split(","); String[] lines = return_api.split(",");
if (lines.length == 3) { if (lines.length == 3) {

View File

@ -115,22 +115,30 @@ public class Core {
* Application context. * Application context.
*/ */
public static void setFetchFrequency(Context ctx) { public static void setFetchFrequency(Context ctx) {
Log.i(TAG, "Setting events fetching frequency"); SharedPreferences preferences = ctx.getSharedPreferences(
// Stops the service (if it's running) ctx.getString(R.string.const_string_preferences),
ctx.stopService(new Intent(ctx, PandroidEventviewerService.class)); Activity.MODE_PRIVATE);
// Sets the launch frequency if (preferences.getBoolean("configured", false)) {
AlarmManager alarmM = (AlarmManager) ctx Log.i(TAG, "Setting events fetching frequency");
.getSystemService(Context.ALARM_SERVICE); // 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, PendingIntent pandroidService = PendingIntent.getService(ctx, 0,
new Intent(ctx, PandroidEventviewerService.class), 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, alarmM.setRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(), sleepTimeAlarm, pandroidService); 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.add(new BasicNameValuePair("apipass", apiPassword));
} }
parameters.addAll(additionalParameters); parameters.addAll(additionalParameters);
Log.i(TAG, "sent: "+url); Log.i(TAG, "sent: " + url);
if (url.toLowerCase().contains("https")) { if (url.toLowerCase().contains("https")) {
// Secure connection // Secure connection
return Core.httpsGet(url, parameters); return Core.httpsGet(url, parameters);
@ -349,7 +357,7 @@ public class Core {
entityResponse = response.getEntity(); entityResponse = response.getEntity();
return_api = Core return_api = Core
.convertStreamToString(entityResponse.getContent()); .convertStreamToString(entityResponse.getContent());
Log.i(TAG, "received: "+ return_api); Log.i(TAG, "received: " + return_api);
return return_api; return return_api;
} }
} }

View File

@ -18,15 +18,12 @@ package pandroid_event_viewer.pandorafms;
import java.util.ArrayList; import java.util.ArrayList;
import android.app.Activity;
import android.app.ListActivity; import android.app.ListActivity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html; 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() SharedPreferences preferences = getApplicationContext()
.getSharedPreferences( .getSharedPreferences(
getApplicationContext().getString( getApplicationContext().getString(
@ -209,7 +206,7 @@ public class EventList extends ListActivity {
String url = preferences.getString("url", ""); String url = preferences.getString("url", "");
return url + "/images/groups_small/" + group_icon + ".png"; return url + "/images/groups_small/" + group_icon + ".png";
} }+/
/** /**
* Sets an image to the left of group's TextView. * Sets an image to the left of group's TextView.
@ -221,7 +218,7 @@ public class EventList extends ListActivity {
* @param id * @param id
* Group's TextView 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); TextView tview = (TextView) view.findViewById(id);
Bitmap img = null; Bitmap img = null;
@ -238,7 +235,7 @@ public class EventList extends ListActivity {
if (img != null) { if (img != null) {
Core.setTextViewLeftImage(tview, img); Core.setTextViewLeftImage(tview, img);
} }
} }*/
@Override @Override
protected void onListItemClick(ListView l, View v, int position, long id) { protected void onListItemClick(ListView l, View v, int position, long id) {
@ -391,11 +388,6 @@ public class EventList extends ListActivity {
.getSeverityImage(getApplicationContext(), .getSeverityImage(getApplicationContext(),
item.criticity), 16); 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) { if (item.status == 1) {
Core.setTextViewLeftImage(timestamp, getResources() Core.setTextViewLeftImage(timestamp, getResources()
.getDrawable(R.drawable.tick), 24); .getDrawable(R.drawable.tick), 24);
@ -445,13 +437,6 @@ public class EventList extends ListActivity {
text = (TextView) viewEventExtended text = (TextView) viewEventExtended
.findViewById(R.id.group_text); .findViewById(R.id.group_text);
text.setText(item.group_name); 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) { if (item.agent_name.length() != 0) {
@ -517,7 +502,6 @@ public class EventList extends ListActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// TODO
Intent intent = new Intent( Intent intent = new Intent(
getBaseContext(), getBaseContext(),
CreateIncidentActivity.class); CreateIncidentActivity.class);

View File

@ -214,6 +214,7 @@ public class Options extends Activity {
editorPreferences.putBoolean("vibration", cb.isChecked()); editorPreferences.putBoolean("vibration", cb.isChecked());
cb = (CheckBox) findViewById(R.id.led_flash_on); cb = (CheckBox) findViewById(R.id.led_flash_on);
editorPreferences.putBoolean("led", cb.isChecked()); editorPreferences.putBoolean("led", cb.isChecked());
editorPreferences.putBoolean("configured", true);
Context context = this.getApplicationContext(); Context context = this.getApplicationContext();