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 f625d98873
commit 991d05736f
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>
* 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.

View File

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

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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();