2011-09-28 Miguel de Dios <miguel.dedios@artica.es>

* src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java,
	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/Options.java,
	src/pandroid_event_viewer/pandorafms/EventList.java: wip and fixes.
	
	* res/values/strings.xml, res/values-en/strings.xml,
	res/values-es/strings.xml: added more strings and array values. 
	
	* res/menu/options_menu_list_events.xml: added custom menu for event list.

	* res/drawable-ldpi/refresh.png: icon for the refresh.
	
	* res/layout/main.xml, res/layout/options.xml: modify the layer.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5021 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2011-09-28 17:23:19 +00:00
parent e051933292
commit a54cb57c32
14 changed files with 269 additions and 197 deletions

View File

@ -1,3 +1,22 @@
2011-09-28 Miguel de Dios <miguel.dedios@artica.es>
* src/pandroid_event_viewer/pandorafms/PopupValidationEvent.java,
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/Options.java,
src/pandroid_event_viewer/pandorafms/EventList.java: wip and fixes.
* res/values/strings.xml, res/values-en/strings.xml,
res/values-es/strings.xml: added more strings and array values.
* res/menu/options_menu_list_events.xml: added custom menu for event list.
* res/drawable-ldpi/refresh.png: icon for the refresh.
* res/layout/main.xml, res/layout/options.xml: modify the layer.
2011-09-27 Miguel de Dios <miguel.dedios@artica.es>
* AndroidManifest.xml: change for avoid the crash when rotate mobile.

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

View File

@ -14,160 +14,164 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableLayout
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_height="wrap_content"
>
<TableRow>
<TextView
android:text="@string/agent_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<EditText
android:id="@+id/agent_name"
android:layout_height="wrap_content"
android:singleLine="true"
android:editable="true"
android:layout_width="0dp"
android:layout_weight="1"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/group_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<Spinner
android:id="@+id/group_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
/>
<ProgressBar
android:id="@+id/loading_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/severity_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<Spinner
android:id="@+id/severity_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/status_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<Spinner
android:id="@+id/status_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/event_search_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<EditText
android:id="@+id/event_search_text"
android:layout_height="wrap_content"
android:singleLine="true"
android:editable="true"
android:layout_width="0dp"
android:layout_weight="1"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/max_time_old_event_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<Spinner
android:id="@+id/max_time_old_event_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
</TableLayout>
<!--
<TextView
android:text="@string/date_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<TimePicker
android:textSize="10sp"
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<DatePicker
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:text="@string/reset_button_str"
android:id="@+id/button_reset"
<TextView
android:text="@string/agent_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:text="@string/search_button_str"
android:id="@+id/button_send"
<EditText
android:id="@+id/agent_name"
android:layout_height="wrap_content"
android:singleLine="true"
android:editable="true"
android:layout_width="fill_parent"
/>
<TextView
android:text="@string/event_search_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<EditText
android:id="@+id/event_search_text"
android:layout_height="wrap_content"
android:singleLine="true"
android:editable="true"
android:layout_width="fill_parent"
/>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableRow>
<TextView
android:text="@string/group_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
android:layout_weight="1"
/>
<Spinner
android:id="@+id/group_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
/>
<ProgressBar
android:id="@+id/loading_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/severity_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
android:layout_weight="1"
/>
<Spinner
android:id="@+id/severity_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
<TableRow>
<TextView
android:text="@string/status_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
android:layout_weight="1"
/>
<Spinner
android:id="@+id/status_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
</TableLayout>
<!--
<TextView
android:text="@string/date_label_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<TimePicker
android:textSize="10sp"
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<DatePicker
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
-->
<TextView
android:text="@string/max_time_old_event_str"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dip"
/>
<Spinner
android:id="@+id/max_time_old_event_combo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
/>
<LinearLayout
android:layout_marginTop="10px"
android:layout_marginBottom="10px"
android:layout_height="2px"
android:layout_width="fill_parent"
android:background="#ffffff"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:text="@string/reset_button_str"
android:id="@+id/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<Button
android:text="@string/search_button_str"
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<Button
android:text="@string/set_as_filter_watcher_button_str"
android:id="@+id/button_set_as_filter_watcher"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<Button
android:text="@string/set_as_filter_watcher_button_str"
android:id="@+id/button_set_as_filter_watcher"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -20,12 +20,16 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableRow>
<TextView
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:textColor="#ffffff"
android:text="@string/url_label_str"
android:layout_width="wrap_content"
@ -37,11 +41,8 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:editable="true"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_width="fill_parent"
/>
</TableRow>
<TableRow>
<TextView
android:textColor="#ffffff"
android:text="@string/user_label_str"
@ -54,11 +55,8 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:editable="true"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_width="fill_parent"
/>
</TableRow>
<TableRow>
<TextView
android:textColor="#ffffff"
android:text="@string/password_label_str"
@ -71,12 +69,9 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:editable="true"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_width="fill_parent"
android:inputType="textPassword"
/>
</TableRow>
<TableRow>
<TextView
android:textColor="#ffffff"
android:text="@string/refresh_time_label_str"
@ -89,13 +84,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
</TableLayout>
<Button
android:id="@+id/update_options"
android:text="@string/update_button_str"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/update_options"
android:text="@string/update_button_str"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/options_button_menu_options"
android:title="@string/options_label_str"
android:icon="@drawable/config"
/>
<item
android:id="@+id/refresh_button_menu_options"
android:title="@string/refresh_label_str"
android:icon="@drawable/refresh"
/>
</menu>

View File

@ -43,6 +43,7 @@
<string name="password_label_str">Password</string>
<string name="update_button_str">Update</string>
<string name="option_title_str">Options</string>
<string name="refresh_label_str">Refresh</string>
<string name="load_more_events_button_str">Load more events</string>
<string name="empty_label_str">Empty list events</string>
<string name="refresh_time_label_str">Refresh time watcher</string>

View File

@ -34,10 +34,11 @@
<string name="severity_label_str">Severidad</string>
<string name="date_label_str">Fecha</string>
<string name="number_events_label_str">Número de eventos</string>
<string name="reset_button_str">Reserteo</string>
<string name="reset_button_str">Reseteo</string>
<string name="search_button_str">Buscar</string>
<string name="loading_label_str">Cargando</string>
<string name="options_label_str">Opciones</string>
<string name="refresh_label_str">Refrescar</string>
<string name="url_label_str">URL</string>
<string name="user_label_str">Usuario</string>
<string name="password_label_str">Contraseña</string>

View File

@ -43,6 +43,7 @@
<string name="search_button_str">Search</string>
<string name="loading_label_str">Loading</string>
<string name="options_label_str">Options</string>
<string name="refresh_label_str">Refresh</string>
<string name="url_label_str">URL</string>
<string name="user_label_str">User</string>
<string name="password_label_str">Password</string>

View File

@ -47,6 +47,11 @@ public class AlarmReceiver extends BroadcastReceiver {
this.user = preferences.getString("user", "");
this.password = preferences.getString("password", "");
if ((user.length() == 0) && (password.length() == 0)
&& (url.length() == 0)) {
return;
}
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
UrlEncodedFormEntity entity;
@ -56,7 +61,7 @@ public class AlarmReceiver extends BroadcastReceiver {
HttpEntity entityResponse;
String return_api;
httpPost = new HttpPost(this.url);
httpPost = new HttpPost(this.url + "/include/api.php");
String parametersAPI = serializeParams2Api(context);
@ -121,7 +126,7 @@ public class AlarmReceiver extends BroadcastReceiver {
String filterAgentName = preferences.getString("filterAgentName", "");
int filterIDGroup = preferences.getInt("filterIDGroup", 0);
int filterSeverity = preferences.getInt("filterSeverity", -1);
int filterStatus = preferences.getInt("filterStatus", -1);
int filterStatus = preferences.getInt("filterStatus", 4);
String filterEventSearch = preferences.getString("filterEventSearch", "");

View File

@ -7,11 +7,13 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
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.BitmapFactory;
@ -32,6 +34,7 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
public class EventList extends ListActivity {
private ListView lv;
@ -78,6 +81,7 @@ public class EventList extends ListActivity {
Log.e("onReceive", "onReceive");
int load_more = intent.getIntExtra("load_more", 0);
Log.e("load_more", "" + load_more);
if (load_more == 1) {
la.showLoadingEvents = false;
@ -121,7 +125,7 @@ public class EventList extends ListActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
inflater.inflate(R.menu.options_menu_list_events, menu);
return true;
}
@Override
@ -134,6 +138,13 @@ public class EventList extends ListActivity {
startActivity(i);
break;
case R.id.refresh_button_menu_options:
Log.e("onOptionsItemSelected","refresh_button_menu_options");
this.object.loadInProgress = true;
this.object.getNewListEvents = true;
this.toggleLoadingLayout();
this.object.executeBackgroundGetEvents();
break;
}
return true;
@ -187,8 +198,14 @@ public class EventList extends ListActivity {
img = this.imgGroups.get(group_icon);
}
else {
SharedPreferences preferences = getApplicationContext().getSharedPreferences(
getApplicationContext().getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
String url = preferences.getString("url", "");
img = this.downloadFile(
"http://192.168.70.112/pandora_console/images/groups_small/" + group_icon + ".png");
url + "/images/groups_small/" + group_icon + ".png");
if (img != null) {
this.imgGroups.put(group_icon, img);

View File

@ -90,12 +90,14 @@ public class Main extends Activity {
this, R.array.event_status_values, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
combo.setAdapter(adapter);
combo.setSelection(4);
combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
adapter = ArrayAdapter.createFromResource(
this, R.array.max_time_old_event_values, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
combo.setAdapter(adapter);
combo.setSelection(4);
buttonReset.setOnClickListener(new View.OnClickListener() {
@ -127,11 +129,11 @@ public class Main extends Activity {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(this.object.url);
HttpPost httpPost = new HttpPost(this.object.url + "/include/api.php");
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("user", this.object.user));
parameters.add(new BasicNameValuePair("pass", this.object.password));
parameters.add(new BasicNameValuePair("pass", this.object.password));Log.e("getGroups", this.object.password);
parameters.add(new BasicNameValuePair("op", "get"));
parameters.add(new BasicNameValuePair("op2", "groups"));
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
@ -355,10 +357,10 @@ public class Main extends Activity {
combo.setSelection(0);
combo = (Spinner)findViewById(R.id.max_time_old_event_combo);
combo.setSelection(0);
combo.setSelection(4);
combo = (Spinner)findViewById(R.id.status_combo);
combo.setSelection(0);
combo.setSelection(4);
text = (EditText)findViewById(R.id.event_search_text);
text.setText("");

View File

@ -34,7 +34,7 @@ public class Options extends Activity {
this.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
url = preferences.getString("url", "");
url = preferences.getString("url", "http://farscape.artica.es/pandora_console");
user = preferences.getString("user", "");
password = preferences.getString("password", "");
refreshTimeKey = preferences.getInt("refreshTimeKey", 3);
@ -81,8 +81,11 @@ public class Options extends Activity {
int duration = Toast.LENGTH_SHORT;
if (editorPreferences.commit()) {
this.core.stopServiceEventWatcher(getApplicationContext());
this.core.startServiceEventWatcher(getApplicationContext());
if (this.core != null) {
Log.e("Options", "reset service");
this.core.stopServiceEventWatcher(getApplicationContext());
this.core.startServiceEventWatcher(getApplicationContext());
}
Toast toast = Toast.makeText(context, this.getString(R.string.config_update_succesful_str), duration);
toast.show();

View File

@ -16,6 +16,7 @@ package pandroid_event_viewer.pandorafms;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -71,7 +72,6 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences preferences = getSharedPreferences(
this.getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
@ -80,14 +80,14 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
this.user = preferences.getString("user", "");
this.password = preferences.getString("password", "");
//this.timestamp = 1315015715;
this.timestamp = new Date().getTime() / 1000;
Calendar c = Calendar.getInstance();
this.timestamp = (c.getTimeInMillis() / 1000) - (4 * 60 * 60);
this.pagination = 20;
this.offset = 0;
this.agentNameStr = "";
this.severity = -1;
this.status = -1;
this.eventSearch = "";
this.agentNameStr = preferences.getString("filterAgentName", "");
this.severity = preferences.getInt("filterSeverity", -1);
this.status = preferences.getInt("filterStatus", 4);
this.eventSearch = preferences.getString("filterEventSearch", "");
this.eventList = new ArrayList<EventListItem>();
this.loadInProgress = false;
@ -108,8 +108,9 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
this.loadInProgress = true;
}
//Start the background service for the notifications
this.core = new Core();
//Start the background service for the notifications
this.core.startServiceEventWatcher(getApplicationContext());
Intent i_main = new Intent(this, Main.class);
@ -119,8 +120,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
tabHost.addTab
(
tabHost.newTabSpec(getResources().getString(R.string.item_tab_main_text))
.setIndicator(getResources().getString(R.string.item_tab_main_text),
this.getResources().getDrawable(R.drawable.house)
.setIndicator(getResources().getString(R.string.item_tab_main_text)
)
.setContent(i_main)
);
@ -131,8 +131,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
tabHost.addTab
(
tabHost.newTabSpec(getResources().getString(R.string.item_tab_event_list_text))
.setIndicator(getResources().getString(R.string.item_tab_event_list_text),
this.getResources().getDrawable(R.drawable.lightning_go)
.setIndicator(getResources().getString(R.string.item_tab_event_list_text)
)
.setContent(i_event_list)
);
@ -191,17 +190,15 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
getString(R.string.const_string_preferences),
Activity.MODE_PRIVATE);
this.timestamp = preferences.getLong("previous_filterTimestamp", (new Date().getTime() / 1000));
}
this.getTabHost().setCurrentTab(1);
}
this.getTabHost().setCurrentTab(1);
executeBackgroundGetEvents();
Log.e("PandroidEventviewerActivity", "onResume");
}
public void onConfigurationChanged(Configuration newConfig) {
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Log.e("PandroidEventviewerActivity", "onConfigurationChanged");
@ -250,7 +247,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
HttpEntity entityResponse;
String return_api;
httpPost = new HttpPost(this.url);
httpPost = new HttpPost(this.url + "/include/api.php");
//Get total count.
parameters = new ArrayList<NameValuePair>();

View File

@ -97,7 +97,7 @@ public class PopupValidationEvent extends Activity {
HttpEntity entityResponse;
String return_api;
httpPost = new HttpPost(this.url);
httpPost = new HttpPost(this.url + "/include/api.php");
//Set event validation.
parameters = new ArrayList<NameValuePair>();