2012-06-11 Santiago Munin <burning1@gmail.com>
* res/values/arrays.xml: Removed some entries. * res/values/strings.xml: Added one entry. * res/layout/create_incident.xml: Removed form fields. * res/layout/item_list_event_extended.xml: Added a button to create an incident from the event. * src/pandroid_event_viewer/pandorafms/EventList.java: Added crate incident button logic. * src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java: Removed fields logic. * src/pandroid_event_viewer/pandorafms/Main.java, src/pandroid_event_viewer/pandorafms/EventList.java, res/menu/options_menu.xml, res/menu/options_menu_list_events.xml: Removed create incident (menu entry) git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6494 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b86459d841
commit
3c6cc729f4
|
@ -1,3 +1,16 @@
|
|||
2012-06-11 Santiago Munín <burning1@gmail.com>
|
||||
|
||||
* res/values/arrays.xml: Removed some entries.
|
||||
* res/values/strings.xml: Added one entry.
|
||||
* res/layout/create_incident.xml: Removed form fields.
|
||||
* res/layout/item_list_event_extended.xml: Added a button to create an incident from the event.
|
||||
* src/pandroid_event_viewer/pandorafms/EventList.java: Added crate incident button logic.
|
||||
* src/pandroid_event_viewer/pandorafms/CreateIncidentActivity.java: Removed fields logic.
|
||||
* src/pandroid_event_viewer/pandorafms/Main.java,
|
||||
src/pandroid_event_viewer/pandorafms/EventList.java,
|
||||
res/menu/options_menu.xml,
|
||||
res/menu/options_menu_list_events.xml: Removed create incident (menu entry)
|
||||
|
||||
2012-06-11 Santiago Munín <burning1@gmail.com>
|
||||
|
||||
* src/pandroid_event_viewer/pandorafms/Main.java,
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:inputType="text" />
|
||||
</TableRow>
|
||||
|
||||
<!--
|
||||
<TableRow
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -143,6 +143,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
-->
|
||||
</TableLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -131,7 +131,9 @@
|
|||
android:textColor="#000" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:gravity="right" >
|
||||
<TableRow
|
||||
android:layout_marginTop="4dp"
|
||||
android:gravity="right" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/validate_button_extended"
|
||||
|
@ -145,6 +147,12 @@
|
|||
android:textColor="#000"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/create_incident_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/create_incident" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
|
@ -14,20 +14,15 @@
|
|||
// 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/about_button_menu_options"
|
||||
android:title="@string/about_label_str"
|
||||
android:icon="@drawable/about"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/incidents_button_menu_options"
|
||||
android:icon="@drawable/incident"
|
||||
android:title="@string/incidents_label_str"/>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/options_button_menu_options"
|
||||
android:icon="@drawable/config"
|
||||
android:title="@string/options_label_str"/>
|
||||
<item
|
||||
android:id="@+id/about_button_menu_options"
|
||||
android:icon="@drawable/about"
|
||||
android:title="@string/about_label_str"/>
|
||||
|
||||
</menu>
|
|
@ -28,9 +28,5 @@
|
|||
android:id="@+id/about_button_menu_options"
|
||||
android:icon="@drawable/about"
|
||||
android:title="@string/about_label_str"/>
|
||||
<item
|
||||
android:id="@+id/incidents_button_menu_options"
|
||||
android:icon="@drawable/incident"
|
||||
android:title="@string/incidents_label_str"/>
|
||||
|
||||
</menu>
|
|
@ -82,6 +82,7 @@
|
|||
<item>2 weeks</item>
|
||||
<item>1 month</item>
|
||||
</string-array>
|
||||
<!--
|
||||
<string-array name="incident_priority">
|
||||
<item>Informative</item>
|
||||
<item>Low</item>
|
||||
|
@ -108,5 +109,6 @@
|
|||
<item>Expired incidents</item>
|
||||
<item>Closed incidents</item>
|
||||
</string-array>
|
||||
-->
|
||||
|
||||
</resources>
|
|
@ -115,5 +115,7 @@
|
|||
<string name="incident_created">Incident created</string>
|
||||
<string name="title_empty">Sorry, you must provide a title</string>
|
||||
<string name="creating_incident">Creating new incident…</string>
|
||||
<string name="create_incident">Create incident</string>
|
||||
<string name="create_incident_group_error">There was an error creating the incident: unrecognized event group. Please, contact administrator.</string>
|
||||
|
||||
</resources>
|
|
@ -1,9 +1,7 @@
|
|||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.http.NameValuePair;
|
||||
|
@ -16,13 +14,8 @@ import android.os.Bundle;
|
|||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemSelectedListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
|
@ -33,16 +26,22 @@ import android.widget.Toast;
|
|||
*/
|
||||
public class CreateIncidentActivity extends Activity {
|
||||
private static String TAG = "CreateIncidentActivity";
|
||||
EditText title, description;
|
||||
Spinner source, priority, group, status;
|
||||
int priority_code, status_code;
|
||||
Map<Integer, String> groups;
|
||||
ProgressBar groupLoadingStatus;
|
||||
ProgressDialog dialog;
|
||||
private static int DEFAULT_STATUS_CODE = 0;
|
||||
private static int DEFAULT_PRIORITY_CODE = 0;
|
||||
private static String DEFAULT_SOURCE = "Pandora FMS Event";
|
||||
private EditText title, description;
|
||||
private ProgressDialog dialog;
|
||||
private String eventTitle, eventDescription, eventGroup;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
eventTitle = extras.getString("title");
|
||||
eventDescription = extras.getString("description");
|
||||
eventGroup = extras.getString("group");
|
||||
}
|
||||
setContentView(R.layout.create_incident);
|
||||
initializeViews();
|
||||
resetViews();
|
||||
|
@ -54,41 +53,7 @@ public class CreateIncidentActivity extends Activity {
|
|||
private void initializeViews() {
|
||||
title = (EditText) findViewById(R.id.incident_title);
|
||||
description = (EditText) findViewById(R.id.incident_description);
|
||||
priority = (Spinner) findViewById(R.id.incident_priority);
|
||||
group = (Spinner) findViewById(R.id.incident_group);
|
||||
source = (Spinner) findViewById(R.id.incident_source);
|
||||
status = (Spinner) findViewById(R.id.incident_status);
|
||||
groupLoadingStatus = (ProgressBar) findViewById(R.id.loading_group);
|
||||
priority.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1,
|
||||
int arg2, long arg3) {
|
||||
priority_code = arg0.getSelectedItemPosition();
|
||||
if (priority_code == 5) {
|
||||
priority_code = 10;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
}
|
||||
});
|
||||
status.setOnItemSelectedListener(new OnItemSelectedListener() {
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1,
|
||||
int arg2, long arg3) {
|
||||
status_code = arg0.getSelectedItemPosition();
|
||||
if (status_code == 4) {
|
||||
status_code = 13;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0) {
|
||||
}
|
||||
});
|
||||
((Button) findViewById(R.id.incident_create_button))
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
|
||||
|
@ -115,13 +80,8 @@ public class CreateIncidentActivity extends Activity {
|
|||
*/
|
||||
private void resetViews() {
|
||||
|
||||
title.setText("");
|
||||
description.setText("");
|
||||
source.setSelection(0);
|
||||
priority.setSelection(0);
|
||||
group.setSelection(0);
|
||||
status.setSelection(0);
|
||||
new GetGroupsAsyncTask().execute((Void) null);
|
||||
title.setText(eventTitle);
|
||||
description.setText(eventDescription);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,45 +97,27 @@ public class CreateIncidentActivity extends Activity {
|
|||
String incidentParams[] = new String[6];
|
||||
incidentParams[0] = title.getText().toString();
|
||||
incidentParams[1] = description.getText().toString();
|
||||
incidentParams[2] = String.valueOf(source.getSelectedItem().toString());
|
||||
incidentParams[3] = String.valueOf(priority_code);
|
||||
incidentParams[4] = String.valueOf(status_code);
|
||||
incidentParams[5] = String.valueOf(groups.get(group
|
||||
.getSelectedItemPosition()));
|
||||
incidentParams[2] = String.valueOf(DEFAULT_SOURCE);
|
||||
incidentParams[3] = String.valueOf(DEFAULT_PRIORITY_CODE);
|
||||
incidentParams[4] = String.valueOf(DEFAULT_STATUS_CODE);
|
||||
int groupCode = -1;
|
||||
for (Entry<Integer, String> entry : Core.getGroups(
|
||||
getApplicationContext()).entrySet()) {
|
||||
if (entry.getValue().equals(eventGroup)) {
|
||||
groupCode = entry.getKey();
|
||||
}
|
||||
}
|
||||
if (groupCode >= 0) {
|
||||
incidentParams[5] = String.valueOf(groupCode);
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(),
|
||||
R.string.create_incident_group_error, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
finish();
|
||||
}
|
||||
parameters.add(new BasicNameValuePair("other", Core
|
||||
.serializeParams2Api(incidentParams)));
|
||||
Core.httpGet(getApplicationContext(), parameters);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Async task which get groups.
|
||||
*
|
||||
* @author Santiago Munín González
|
||||
*
|
||||
*/
|
||||
private class GetGroupsAsyncTask extends
|
||||
AsyncTask<Void, Void, Map<Integer, String>> {
|
||||
|
||||
@Override
|
||||
protected Map<Integer, String> doInBackground(Void... params) {
|
||||
return Core.getGroups(getApplicationContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Map<Integer, String> result) {
|
||||
groups = result;
|
||||
List<String> list = new LinkedList<String>();
|
||||
for (Entry<Integer, String> entry : result.entrySet()) {
|
||||
list.add(entry.getValue());
|
||||
}
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
|
||||
getApplicationContext(),
|
||||
android.R.layout.simple_spinner_item, list);
|
||||
group.setAdapter(spinnerArrayAdapter);
|
||||
group.setSelection(0);
|
||||
groupLoadingStatus.setVisibility(ProgressBar.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -200,4 +142,4 @@ public class CreateIncidentActivity extends Activity {
|
|||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -177,9 +177,6 @@ public class EventList extends ListActivity {
|
|||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case R.id.incidents_button_menu_options:
|
||||
startActivity(new Intent(this, CreateIncidentActivity.class));
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -349,7 +346,7 @@ public class EventList extends ListActivity {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
EventListItem item = this.object.eventList.get(position);
|
||||
final EventListItem item = this.object.eventList.get(position);
|
||||
|
||||
switch (item.criticity) {
|
||||
|
||||
|
@ -514,10 +511,27 @@ public class EventList extends ListActivity {
|
|||
OnClickListenerButtonValidate clickListener = new OnClickListenerButtonValidate();
|
||||
clickListener.id_event = item.id_event;
|
||||
button.setOnClickListener(clickListener);
|
||||
|
||||
text = (TextView) viewEventExtended
|
||||
.findViewById(R.id.validate_event_label);
|
||||
text.setVisibility(TextView.GONE);
|
||||
((Button) viewEventExtended
|
||||
.findViewById(R.id.create_incident_button))
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO
|
||||
Intent intent = new Intent(
|
||||
getBaseContext(),
|
||||
CreateIncidentActivity.class);
|
||||
intent.putExtra("group",
|
||||
item.group_name);
|
||||
intent.putExtra("title", item.event);
|
||||
intent.putExtra("description",
|
||||
item.description_event);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
button.setVisibility(Button.GONE);
|
||||
text = (TextView) viewEventExtended
|
||||
|
|
|
@ -387,10 +387,6 @@ public class Main extends Activity {
|
|||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
|
||||
case R.id.incidents_button_menu_options:
|
||||
startActivity(new Intent(this, CreateIncidentActivity.class));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue