From fbb0318785077426738846ff0506510d567916b2 Mon Sep 17 00:00:00 2001 From: santimunin Date: Mon, 11 Jun 2012 14:46:18 +0000 Subject: [PATCH] 2012-06-11 Santiago Munin * src/pandroid_event_viewer/pandorafms/Options.java, src/pandroid_event_viewer/pandorafms/Main.java, res/layout/main.xml, res/layout/options.xml: Changed advanced filter from Options to Filter. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6486 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- extras/pandroid_event_viewer/ChangeLog | 11 ++- .../pandroid_event_viewer/res/layout/main.xml | 22 +++++- .../res/layout/options.xml | 22 ------ .../pandorafms/Main.java | 71 ++++++++++++++----- .../pandorafms/Options.java | 36 ++-------- 5 files changed, 83 insertions(+), 79 deletions(-) diff --git a/extras/pandroid_event_viewer/ChangeLog b/extras/pandroid_event_viewer/ChangeLog index e6cb619536..3872d9ea5c 100644 --- a/extras/pandroid_event_viewer/ChangeLog +++ b/extras/pandroid_event_viewer/ChangeLog @@ -1,10 +1,9 @@ -2012-06-06 Santiago Munín +2012-06-11 Santiago Munín - * src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java: All api operations are now asynchronous. - * res/layout/create_incident.xml: Progress circle next to groups spinner. - * res/values/strings.xml: New entries. - * res/menu/options_menu_list_events.xml, res/menu/options_menu.xml: New incident icon. - * res/drawable-ldpi/incident.png: Added new icon + * src/pandroid_event_viewer/pandorafms/Options.java, + src/pandroid_event_viewer/pandorafms/Main.java, + res/layout/main.xml, + res/layout/options.xml: Changed advanced filter from Options to Filter. 2012-06-06 Santiago Munín diff --git a/extras/pandroid_event_viewer/res/layout/main.xml b/extras/pandroid_event_viewer/res/layout/main.xml index 04ccf91008..58cc99682b 100644 --- a/extras/pandroid_event_viewer/res/layout/main.xml +++ b/extras/pandroid_event_viewer/res/layout/main.xml @@ -91,10 +91,30 @@ android:id="@+id/loading_tag" android:layout_width="wrap_content" android:layout_height="wrap_content" /> - + + + + + + + - - - - - - - diff --git a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java index bdf76e54eb..a819653ad7 100644 --- a/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java +++ b/extras/pandroid_event_viewer/src/pandroid_event_viewer/pandorafms/Main.java @@ -35,6 +35,7 @@ import android.app.Activity; import android.app.TabActivity; import android.content.Intent; import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; import android.os.AsyncTask; import android.os.Bundle; import android.util.Log; @@ -44,6 +45,9 @@ import android.view.MenuItem; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -103,7 +107,7 @@ public class Main extends Activity { new GetTagsAsyncTask().execute(); } - SharedPreferences preferences = getSharedPreferences( + final SharedPreferences preferences = getSharedPreferences( this.getString(R.string.const_string_preferences), Activity.MODE_PRIVATE); @@ -153,6 +157,36 @@ public class Main extends Activity { save_filter_watcher(); } }); + LinearLayout advancedOptions = (LinearLayout) findViewById(R.id.show_hide_layout); + // Show advanced options? + if (preferences.getBoolean("show_advanced", false)) { + advancedOptions.setVisibility(View.VISIBLE); + } else { + advancedOptions.setVisibility(View.INVISIBLE); + setAdvancedOptionsDefaults(); + clearAdvancedOptions(); + } + CheckBox cb = (CheckBox) findViewById(R.id.checkBox_advanced_options); + cb.setChecked(preferences.getBoolean("show_advanced", false)); + cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + LinearLayout advancedOptions = (LinearLayout) findViewById(R.id.show_hide_layout); + Editor preferencesEditor = preferences.edit(); + if (isChecked) { + advancedOptions.setVisibility(View.VISIBLE); + preferencesEditor.putBoolean("show_advanced", true); + } else { + advancedOptions.setVisibility(View.INVISIBLE); + preferencesEditor.putBoolean("show_advanced", false); + setAdvancedOptionsDefaults(); + clearAdvancedOptions(); + } + preferencesEditor.commit(); + } + }); if (this.object.show_popup_info) { this.object.show_popup_info = false; @@ -161,23 +195,6 @@ public class Main extends Activity { } } - @Override - protected void onResume() { - super.onResume(); - SharedPreferences preferences = getSharedPreferences( - this.getString(R.string.const_string_preferences), - Activity.MODE_PRIVATE); - // Show advanced options? - if (preferences.getBoolean("show_advanced", false)) { - ((LinearLayout) findViewById(R.id.show_hide_layout)) - .setVisibility(View.VISIBLE); - } else { - ((LinearLayout) findViewById(R.id.show_hide_layout)) - .setVisibility(View.INVISIBLE); - clearAdvancedOptions(); - } - } - public void onRestart() { super.onRestart(); SharedPreferences preferences = getSharedPreferences( @@ -552,4 +569,22 @@ public class Main extends Activity { text.setText(""); } + /** + * Puts advanced options to default values. + */ + private void setAdvancedOptionsDefaults() { + SharedPreferences preferences = getSharedPreferences( + this.getString(R.string.const_string_preferences), + Activity.MODE_PRIVATE); + SharedPreferences.Editor editorPreferences = preferences.edit(); + + editorPreferences.putString("filterAgentName", ""); + editorPreferences.putInt("filterIDGroup", 0); + editorPreferences.putInt("filterSeverity", -1); + editorPreferences.putString("filterEventSearch", ""); + editorPreferences.putInt("filterLastTime", 6); + // There were changes + editorPreferences.putBoolean("filterChanges", true); + editorPreferences.commit(); + } } \ No newline at end of file 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 685da150b1..a6792de8d8 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 @@ -81,9 +81,6 @@ public class Options extends Activity { text = (EditText) findViewById(R.id.password); text.setText(password); - ((CheckBox) findViewById(R.id.checkBox_advanced_options)) - .setChecked(preferences.getBoolean("show_advanced", false)); - Spinner combo = (Spinner) findViewById(R.id.refresh_combo); ArrayAdapter adapter = ArrayAdapter.createFromResource( this, R.array.refresh_combo, @@ -163,12 +160,11 @@ public class Options extends Activity { * Saves all options */ private void save_options() { - boolean advancedFilterOff = false; SharedPreferences preferences = getSharedPreferences( this.getString(R.string.const_string_preferences), Activity.MODE_PRIVATE); SharedPreferences.Editor editorPreferences = preferences.edit(); - + // Connection settings EditText text = (EditText) findViewById(R.id.url); String url = text.getText().toString(); @@ -177,7 +173,8 @@ public class Options extends Activity { } editorPreferences.putString("url", url); - //MainActivity uses this to know if it has to check tags and groups again + // MainActivity uses this to know if it has to check tags and groups + // again editorPreferences.putBoolean("url_changed", true); text = (EditText) findViewById(R.id.user); editorPreferences.putString("user", text.getText().toString()); @@ -188,13 +185,8 @@ public class Options extends Activity { editorPreferences.putInt("refreshTimeKey", combo.getSelectedItemPosition()); - CheckBox cb = (CheckBox) findViewById(R.id.checkBox_advanced_options); - editorPreferences.putBoolean("show_advanced", cb.isChecked()); - if (!cb.isChecked()) { - advancedFilterOff = true; - } // Notification settings - cb = (CheckBox) findViewById(R.id.vibration_on); + CheckBox cb = (CheckBox) findViewById(R.id.vibration_on); editorPreferences.putBoolean("vibration", cb.isChecked()); cb = (CheckBox) findViewById(R.id.led_flash_on); editorPreferences.putBoolean("led", cb.isChecked()); @@ -214,8 +206,6 @@ public class Options extends Activity { Toast.LENGTH_LONG); toast.show(); } - if (advancedFilterOff) - setAdvancedOptionsDefaults(); } /** @@ -260,24 +250,6 @@ public class Options extends Activity { button.setText(getString(R.string.silence)); } } - /** - * Puts advanced options to default values. - */ - private void setAdvancedOptionsDefaults() { - SharedPreferences preferences = getSharedPreferences( - this.getString(R.string.const_string_preferences), - Activity.MODE_PRIVATE); - SharedPreferences.Editor editorPreferences = preferences.edit(); - - editorPreferences.putString("filterAgentName", ""); - editorPreferences.putInt("filterIDGroup", 0); - editorPreferences.putInt("filterSeverity", -1); - editorPreferences.putString("filterEventSearch", ""); - editorPreferences.putInt("filterLastTime", 6); - // There were changes - editorPreferences.putBoolean("filterChanges", true); - editorPreferences.commit(); - } /** * Checks if connection parameters are ok.