mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
2012-05-31 Santiago Munín <burnin1@gmail.com>
* src/pandroid_event_viewer/pandorafms/Main.java: Added tag retrieving. * res/layout/main.xml: Added tags' spinner. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6392 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
6e9ce11f3e
commit
7d8cae5db3
@ -1,3 +1,7 @@
|
|||||||
|
2012-05-31 Santiago Munín <burnin1@gmail.com>
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Main.java: Added tag retrieving.
|
||||||
|
* res/layout/main.xml: Added tags' spinner.
|
||||||
|
|
||||||
2012-05-30 Santiago Munín <burnin1@gmail.com>
|
2012-05-30 Santiago Munín <burnin1@gmail.com>
|
||||||
|
|
||||||
* src/pandroid_event_viewer/pandorafms/EventList.java: Removed unused methods and added two that will set images to the left of some textviews.
|
* src/pandroid_event_viewer/pandorafms/EventList.java: Removed unused methods and added two that will set images to the left of some textviews.
|
||||||
|
@ -82,11 +82,16 @@
|
|||||||
android:paddingRight="5dip"
|
android:paddingRight="5dip"
|
||||||
android:text="@string/tag_label_str" />
|
android:text="@string/tag_label_str" />
|
||||||
|
|
||||||
<EditText
|
<Spinner
|
||||||
android:id="@+id/tag"
|
android:id="@+id/tag"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:inputType="text"
|
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/loading_tag"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ public class Main extends Activity {
|
|||||||
buttonbuttonSetAsFilterWatcher.setEnabled(false);
|
buttonbuttonSetAsFilterWatcher.setEnabled(false);
|
||||||
|
|
||||||
new GetGroupsAsyncTask().execute();
|
new GetGroupsAsyncTask().execute();
|
||||||
|
new GetTagsAsyncTask().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences preferences = getSharedPreferences(
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
@ -283,6 +284,90 @@ public class Main extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get tags through an api call.
|
||||||
|
*
|
||||||
|
* @return A list of groups.
|
||||||
|
*/
|
||||||
|
private List<String> getTags() {
|
||||||
|
ArrayList<String> array = new ArrayList<String>();
|
||||||
|
|
||||||
|
SharedPreferences preferences = getSharedPreferences(
|
||||||
|
this.getString(R.string.const_string_preferences),
|
||||||
|
Activity.MODE_PRIVATE);
|
||||||
|
|
||||||
|
String url = preferences.getString("url", "");
|
||||||
|
String user = preferences.getString("user", "");
|
||||||
|
String password = preferences.getString("password", "");
|
||||||
|
|
||||||
|
try {
|
||||||
|
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||||
|
|
||||||
|
HttpPost httpPost = new HttpPost(url + "/include/api.php");
|
||||||
|
|
||||||
|
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
|
||||||
|
parameters.add(new BasicNameValuePair("user", user));
|
||||||
|
parameters.add(new BasicNameValuePair("pass", password));
|
||||||
|
parameters.add(new BasicNameValuePair("op", "get"));
|
||||||
|
parameters.add(new BasicNameValuePair("op2", "tags"));
|
||||||
|
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||||
|
|
||||||
|
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters);
|
||||||
|
|
||||||
|
httpPost.setEntity(entity);
|
||||||
|
|
||||||
|
HttpResponse response = httpClient.execute(httpPost);
|
||||||
|
HttpEntity entityResponse = response.getEntity();
|
||||||
|
|
||||||
|
String return_api = Core.convertStreamToString(entityResponse
|
||||||
|
.getContent());
|
||||||
|
|
||||||
|
String[] lines = return_api.split("\n");
|
||||||
|
array.add("");
|
||||||
|
for (int i = 0; i < lines.length; i++) {
|
||||||
|
String[] tags = lines[i].split(";", 2);
|
||||||
|
array.add(tags[1]);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Log.e(TAG + ": getting tags", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Async task which get tags.
|
||||||
|
*
|
||||||
|
* @author Santiago Munín González
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class GetTagsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||||
|
private List<String> list;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
// TODO here
|
||||||
|
list = getTags();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void unused) {
|
||||||
|
Spinner combo = (Spinner) findViewById(R.id.tag);
|
||||||
|
|
||||||
|
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
|
||||||
|
getApplicationContext(),
|
||||||
|
android.R.layout.simple_spinner_item, list);
|
||||||
|
combo.setAdapter(spinnerArrayAdapter);
|
||||||
|
combo.setSelection(0);
|
||||||
|
|
||||||
|
ProgressBar loadingGroup = (ProgressBar) findViewById(R.id.loading_tag);
|
||||||
|
|
||||||
|
loadingGroup.setVisibility(ProgressBar.GONE);
|
||||||
|
combo.setVisibility(Spinner.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// For options
|
// For options
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
@ -350,11 +435,13 @@ public class Main extends Activity {
|
|||||||
combo = (Spinner) findViewById(R.id.status_combo);
|
combo = (Spinner) findViewById(R.id.status_combo);
|
||||||
this.object.status = combo.getSelectedItemPosition() - 0;
|
this.object.status = combo.getSelectedItemPosition() - 0;
|
||||||
|
|
||||||
text = (EditText) findViewById(R.id.tag);
|
|
||||||
this.object.eventTag = text.getText().toString();
|
|
||||||
text = (EditText) findViewById(R.id.event_search_text);
|
text = (EditText) findViewById(R.id.event_search_text);
|
||||||
this.object.eventSearch = text.getText().toString();
|
this.object.eventSearch = text.getText().toString();
|
||||||
|
|
||||||
|
combo = (Spinner) findViewById(R.id.tag);
|
||||||
|
if (combo.getSelectedItem() != null) {
|
||||||
|
this.object.eventTag = combo.getSelectedItem().toString();
|
||||||
|
}
|
||||||
this.object.getNewListEvents = true;
|
this.object.getNewListEvents = true;
|
||||||
this.object.executeBackgroundGetEvents();
|
this.object.executeBackgroundGetEvents();
|
||||||
|
|
||||||
@ -402,8 +489,8 @@ public class Main extends Activity {
|
|||||||
combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
|
combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
|
||||||
filterLastTime = combo.getSelectedItemPosition();
|
filterLastTime = combo.getSelectedItemPosition();
|
||||||
|
|
||||||
text = (EditText) findViewById(R.id.tag);
|
combo = (Spinner) findViewById(R.id.tag);
|
||||||
filterTag = text.getText().toString();
|
filterTag = combo.getSelectedItem().toString();
|
||||||
|
|
||||||
text = (EditText) findViewById(R.id.event_search_text);
|
text = (EditText) findViewById(R.id.event_search_text);
|
||||||
filterEventSearch = text.getText().toString();
|
filterEventSearch = text.getText().toString();
|
||||||
@ -444,10 +531,10 @@ public class Main extends Activity {
|
|||||||
combo.setSelection(0);
|
combo.setSelection(0);
|
||||||
combo = (Spinner) findViewById(R.id.status_combo);
|
combo = (Spinner) findViewById(R.id.status_combo);
|
||||||
combo.setSelection(3);
|
combo.setSelection(3);
|
||||||
EditText text = (EditText) findViewById(R.id.tag);
|
combo = (Spinner) findViewById(R.id.tag);
|
||||||
text.setText("");
|
combo.setSelection(0);
|
||||||
|
|
||||||
text = (EditText) findViewById(R.id.agent_name);
|
EditText text = (EditText) findViewById(R.id.agent_name);
|
||||||
text.setText("");
|
text.setText("");
|
||||||
|
|
||||||
combo = (Spinner) findViewById(R.id.severity_combo);
|
combo = (Spinner) findViewById(R.id.severity_combo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user