2011-09-19 Miguel de Dios <miguel.dedios@artica.es>
* AndroidManifest.xml: added Options activity. * src/pandroid_event_viewer/pandorafms/Options.java, res/layout/options.xml: added ctivity Options to edit application preferences. * src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java, src/pandroid_event_viewer/pandorafms/Main.java: added to hook for the options activity. * src/pandroid_event_viewer/pandorafms/EventList.java * res/values/strings.xml, res/values-en/strings.xml, res/values-es/strings.xml: added some strings const. * res/menu/options_menu.xml: the sublayout for the option key. *res/layout/list_view_layout.xml: started to show dinamic load items. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4971 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c62316f848
commit
befb0c04ae
|
@ -33,5 +33,6 @@
|
|||
</activity>
|
||||
<activity android:name=".Main"></activity>
|
||||
<activity android:name=".EventList"></activity>
|
||||
<activity android:name=".Options" android:label="@string/option_title_str"></activity>
|
||||
</application>
|
||||
</manifest>
|
|
@ -1,3 +1,23 @@
|
|||
2011-09-19 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* AndroidManifest.xml: added Options activity.
|
||||
|
||||
* src/pandroid_event_viewer/pandorafms/Options.java, res/layout/options.xml:
|
||||
added ctivity Options to edit application preferences.
|
||||
|
||||
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java,
|
||||
src/pandroid_event_viewer/pandorafms/Main.java: added to hook for the
|
||||
options activity.
|
||||
|
||||
* src/pandroid_event_viewer/pandorafms/EventList.java
|
||||
|
||||
* res/values/strings.xml, res/values-en/strings.xml,
|
||||
res/values-es/strings.xml: added some strings const.
|
||||
|
||||
* res/menu/options_menu.xml: the sublayout for the option key.
|
||||
|
||||
*res/layout/list_view_layout.xml: started to show dinamic load items.
|
||||
|
||||
2011-09-16 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java:
|
||||
|
|
|
@ -14,11 +14,32 @@
|
|||
// 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"
|
||||
>
|
||||
<LinearLayout
|
||||
android:id="@+id/loading_layout"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<ProgressBar
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:paddingRight="10dip"
|
||||
/>
|
||||
<TextView
|
||||
android:textColor="#ffffff"
|
||||
android:text="@string/loading_label_str"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<ListView
|
||||
android:id="@id/android:list"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?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.
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:textColor="#ffffff"
|
||||
android:text="@string/url_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/url"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:editable="true"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:textColor="#ffffff"
|
||||
android:text="@string/user_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/user"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:editable="true"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:textColor="#ffffff"
|
||||
android:text="@string/password_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:editable="true"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:inputType="textPassword"
|
||||
/>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
<Button
|
||||
android:id="@+id/update_options"
|
||||
android:text="@string/update_button_str"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,23 @@
|
|||
<?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"
|
||||
/>
|
||||
</menu>
|
|
@ -36,4 +36,14 @@
|
|||
<string name="number_events_label_str">Number Events</string>
|
||||
<string name="reset_button_str">Reset</string>
|
||||
<string name="search_button_str">Search</string>
|
||||
<string name="loading_label_str">Loading</string>
|
||||
<string name="options_label_str">Options</string>
|
||||
<string name="url_label_str">URL</string>
|
||||
<string name="user_label_str">User</string>
|
||||
<string name="password_label_str">Password</string>
|
||||
<string name="update_button_str">Update</string>
|
||||
<string name="option_title_str">Options</string>
|
||||
|
||||
<string name="config_update_succesful_str">Update configuration successful.</string>
|
||||
<string name="config_update_fail_str">Update configuration is failed.</string>
|
||||
</resources>
|
||||
|
|
|
@ -36,4 +36,14 @@
|
|||
<string name="number_events_label_str">Número de eventos</string>
|
||||
<string name="reset_button_str">Reserteo</string>
|
||||
<string name="search_button_str">Buscar</string>
|
||||
<string name="loading_label_str">Cargando</string>
|
||||
<string name="options_label_str">Opciones</string>
|
||||
<string name="url_label_str">URL</string>
|
||||
<string name="user_label_str">Usuario</string>
|
||||
<string name="password_label_str">Contraseña</string>
|
||||
<string name="update_button_str">Actualizar</string>
|
||||
<string name="option_title_str">Opciones</string>
|
||||
|
||||
<string name="config_update_succesful_str">Configuración guardada correctamente.</string>
|
||||
<string name="config_update_fail_str">Configuración no ha podido guardarse..</string>
|
||||
</resources>
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
// GNU General Public License for more details.
|
||||
-->
|
||||
<resources>
|
||||
<!-- CONST -->
|
||||
<string name="const_string_preferences">PANDROID_EVENT_VIEWER_PREFERENCES</string>
|
||||
|
||||
<string name="item_tab_main_text">Main</string>
|
||||
<string name="item_tab_event_list_text">Event list</string>
|
||||
|
||||
|
@ -36,4 +39,14 @@
|
|||
<string name="number_events_label_str">Number Events</string>
|
||||
<string name="reset_button_str">Reset</string>
|
||||
<string name="search_button_str">Search</string>
|
||||
<string name="loading_label_str">Loading</string>
|
||||
<string name="options_label_str">Options</string>
|
||||
<string name="url_label_str">URL</string>
|
||||
<string name="user_label_str">User</string>
|
||||
<string name="password_label_str">Password</string>
|
||||
<string name="update_button_str">Update</string>
|
||||
<string name="option_title_str">Options</string>
|
||||
|
||||
<string name="config_update_succesful_str">Update configuration successful.</string>
|
||||
<string name="config_update_fail_str">Update configuration is failed.</string>
|
||||
</resources>
|
||||
|
|
|
@ -10,23 +10,22 @@ import java.util.HashMap;
|
|||
import android.app.ListActivity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
import android.opengl.Visibility;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleCursorAdapter;
|
||||
import android.widget.TableRow;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class EventList extends ListActivity {
|
||||
private ListView lv;
|
||||
|
@ -52,6 +51,8 @@ public class EventList extends ListActivity {
|
|||
|
||||
setContentView(R.layout.list_view_layout);
|
||||
|
||||
this.toggleLoadingLayout();
|
||||
|
||||
lv = (ListView)findViewById(android.R.id.list);
|
||||
|
||||
la = new MyAdapter(getBaseContext(), object);
|
||||
|
@ -59,6 +60,30 @@ public class EventList extends ListActivity {
|
|||
lv.setAdapter(la);
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.toggleLoadingLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.options_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void toggleLoadingLayout() {
|
||||
LinearLayout loadingLayout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||
|
||||
if (this.object.loadInProgress) {
|
||||
loadingLayout.setVisibility(LinearLayout.VISIBLE);
|
||||
}
|
||||
else {
|
||||
loadingLayout.setVisibility(LinearLayout.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public Bitmap downloadFile(String fileUrl) {Log.e("downloadFile", fileUrl);
|
||||
URL myFileUrl =null;
|
||||
try {
|
||||
|
|
|
@ -14,9 +14,15 @@ import org.apache.http.impl.client.DefaultHttpClient;
|
|||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Region.Op;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
|
@ -28,12 +34,23 @@ import android.widget.TimePicker;
|
|||
public class Main extends Activity {
|
||||
public PandroidEventviewerActivity object;
|
||||
public HashMap<Integer, String> pandoraGroups;
|
||||
public String url;
|
||||
public String user;
|
||||
public String password;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
this.url = preferences.getString("url", "");
|
||||
this.user = preferences.getString("user", "");
|
||||
this.password = preferences.getString("password", "");
|
||||
|
||||
Intent i = getIntent();
|
||||
this.object = (PandroidEventviewerActivity)i.getSerializableExtra("object");
|
||||
|
||||
|
@ -68,8 +85,32 @@ public class Main extends Activity {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.options_menu, menu);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.options_button_menu_options:
|
||||
Intent i = new Intent(this, Options.class);
|
||||
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void search_form() {
|
||||
//Clean the EventList
|
||||
this.object.eventList = new ArrayList<EventListItem>();
|
||||
this.object.loadInProgress = true;
|
||||
|
||||
TabActivity ta = (TabActivity) this.getParent();
|
||||
ta.getTabHost().setCurrentTab(1);
|
||||
}
|
||||
|
||||
public void reset_form() {
|
||||
|
@ -98,12 +139,11 @@ public class Main extends Activity {
|
|||
try {
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
|
||||
HttpPost httpPost = new HttpPost(
|
||||
"http://192.168.70.112/pandora_console/include/api.php");
|
||||
HttpPost httpPost = new HttpPost(this.url);
|
||||
|
||||
List<NameValuePair> parameters = new ArrayList<NameValuePair>(2);
|
||||
parameters.add(new BasicNameValuePair("user", "admin"));
|
||||
parameters.add(new BasicNameValuePair("pass", "pandora"));
|
||||
parameters.add(new BasicNameValuePair("user", this.user));
|
||||
parameters.add(new BasicNameValuePair("pass", this.password));
|
||||
parameters.add(new BasicNameValuePair("op", "get"));
|
||||
parameters.add(new BasicNameValuePair("op2", "groups"));
|
||||
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Options extends Activity {
|
||||
public String url;
|
||||
public String user;
|
||||
public String password;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.options);
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
url = preferences.getString("url", "");
|
||||
user = preferences.getString("user", "");
|
||||
password = preferences.getString("password", "");
|
||||
|
||||
EditText text = (EditText) findViewById(R.id.url);
|
||||
text.setText(url);
|
||||
text = (EditText) findViewById(R.id.user);
|
||||
text.setText(user);
|
||||
|
||||
final Button buttonSearch = (Button) findViewById(R.id.update_options);
|
||||
buttonSearch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
save_options();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void save_options() {
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||
|
||||
EditText text = (EditText) findViewById(R.id.url);
|
||||
|
||||
editorPreferences.putString("url", text.getText().toString());
|
||||
text = (EditText) findViewById(R.id.user);
|
||||
editorPreferences.putString("user", text.getText().toString());
|
||||
text = (EditText) findViewById(R.id.password);
|
||||
editorPreferences.putString("password", text.getText().toString());
|
||||
|
||||
Context context = this.getApplicationContext();
|
||||
int duration = Toast.LENGTH_SHORT;
|
||||
|
||||
if (editorPreferences.commit()) {
|
||||
Toast toast = Toast.makeText(context, this.getString(R.string.config_update_succesful_str), duration);
|
||||
toast.show();
|
||||
}
|
||||
else {
|
||||
Toast toast = Toast.makeText(context, this.getString(R.string.config_update_fail_str), duration);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import android.R.bool;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
@ -38,6 +39,7 @@ import android.widget.TabHost;
|
|||
|
||||
public class PandroidEventviewerActivity extends TabActivity implements Serializable {
|
||||
public ArrayList<EventListItem> eventList;
|
||||
public boolean loadInProgress;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
|
@ -45,6 +47,7 @@ public class PandroidEventviewerActivity extends TabActivity implements Serializ
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
this.eventList = new ArrayList<EventListItem>();
|
||||
this.loadInProgress = false;
|
||||
|
||||
final TabHost tabHost = getTabHost();
|
||||
|
||||
|
|
Loading…
Reference in New Issue