mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
2012-06-21 Santiago Munin <burning1@gmail.com>
* src/pandroid_event_viewer/pandorafms/EventList.java: Restored to the previous version. * src/pandroid_event_viewer/pandorafms/Core.java: Added a line which checks if the connection is secure. * src/pandroid_event_viewer/pandorafms/Options.java: Made some changes in certificate checking. * src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java: Now, if there are any problem parsing data received from server. * res/layout/list_view_layout.xml: Restored to the previous version. * res/layout/item_list_event_layout.xml: Restored to the previous version. * res/values/strings.xml: Added new entries. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6665 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f16cf3cd5a
commit
6f73b31102
@ -1,3 +1,12 @@
|
|||||||
|
2012-06-21 Santiago Munín <burning1@gmail.com>
|
||||||
|
* src/pandroid_event_viewer/pandorafms/EventList.java: Restored to the previous version.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Core.java: Added a line which checks if the connection is secure.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/Options.java: Made some changes in certificate checking.
|
||||||
|
* src/pandroid_event_viewer/pandorafms/PandroidEventviewerActivity.java: Now, if there are any problem parsing data received from server.
|
||||||
|
* res/layout/list_view_layout.xml: Restored to the previous version.
|
||||||
|
* res/layout/item_list_event_layout.xml: Restored to the previous version.
|
||||||
|
* res/values/strings.xml: Added new entries.
|
||||||
|
|
||||||
2012-06-20 Santiago Munín <burning1@gmail.com>
|
2012-06-20 Santiago Munín <burning1@gmail.com>
|
||||||
|
|
||||||
* src/pandroid_event_viewer/pandorafms/API.java: New class, it will provide all API calls.
|
* src/pandroid_event_viewer/pandorafms/API.java: New class, it will provide all API calls.
|
||||||
|
@ -62,12 +62,12 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<!-- <Button
|
<Button
|
||||||
android:id="@+id/button_load_more_events"
|
android:id="@+id/button_load_more_events"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/load_more_events_button_str"
|
android:text="@string/load_more_events_button_str"
|
||||||
android:visibility="gone" /> -->
|
android:visibility="gone" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/loading_more_events"
|
android:id="@+id/loading_more_events"
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
>
|
>
|
||||||
<!-- <LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/loading_layout"
|
android:id="@+id/loading_layout"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@ -39,7 +39,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
/>
|
/>
|
||||||
</LinearLayout> -->
|
</LinearLayout>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/empty_list_layout"
|
android:id="@+id/empty_list_layout"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -120,4 +120,5 @@
|
|||||||
<string name="url_not_valid">Incorrect url. Please, insert a valid url</string>
|
<string name="url_not_valid">Incorrect url. Please, insert a valid url</string>
|
||||||
<string name="certificate_not_valid">This server has a certificate not signed by a CA, do you trust it?</string>
|
<string name="certificate_not_valid">This server has a certificate not signed by a CA, do you trust it?</string>
|
||||||
<string name="options_not_saved">Options not saved.</string>
|
<string name="options_not_saved">Options not saved.</string>
|
||||||
|
<string name="notification_error_parsing">There was an error retrieving data from server.</string>
|
||||||
</resources>
|
</resources>
|
@ -321,7 +321,7 @@ public class Core {
|
|||||||
parameters.add(new BasicNameValuePair("user", user));
|
parameters.add(new BasicNameValuePair("user", user));
|
||||||
parameters.add(new BasicNameValuePair("pass", password));
|
parameters.add(new BasicNameValuePair("pass", password));
|
||||||
parameters.addAll(additionalParameters);
|
parameters.addAll(additionalParameters);
|
||||||
if (url.contains("https")) {
|
if (url.toLowerCase().contains("https")) {
|
||||||
// Secure connection
|
// Secure connection
|
||||||
return Core.httpsGet(url, parameters);
|
return Core.httpsGet(url, parameters);
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ public class Core {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
myFileUrl = new URL(fileUrl);
|
myFileUrl = new URL(fileUrl);
|
||||||
if (fileUrl.contains("https")) {
|
if (fileUrl.toLowerCase().contains("https")) {
|
||||||
HttpsURLConnection con = (HttpsURLConnection) new URL(fileUrl)
|
HttpsURLConnection con = (HttpsURLConnection) new URL(fileUrl)
|
||||||
.openConnection();
|
.openConnection();
|
||||||
con.setHostnameVerifier(new HostnameVerifier() {
|
con.setHostnameVerifier(new HostnameVerifier() {
|
||||||
|
@ -31,7 +31,6 @@ import android.graphics.Color;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@ -39,12 +38,11 @@ import android.view.MenuItem;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AbsListView;
|
|
||||||
import android.widget.AbsListView.OnScrollListener;
|
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +55,6 @@ public class EventList extends ListActivity {
|
|||||||
private ListView lv;
|
private ListView lv;
|
||||||
private MyAdapter la;
|
private MyAdapter la;
|
||||||
private PandroidEventviewerActivity object;
|
private PandroidEventviewerActivity object;
|
||||||
private boolean moreEvents;
|
|
||||||
|
|
||||||
private BroadcastReceiver onBroadcast;
|
private BroadcastReceiver onBroadcast;
|
||||||
|
|
||||||
@ -71,40 +68,13 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
setContentView(R.layout.list_view_layout);
|
setContentView(R.layout.list_view_layout);
|
||||||
|
|
||||||
//this.toggleLoadingLayout();
|
this.toggleLoadingLayout();
|
||||||
moreEvents = true;
|
|
||||||
lv = (ListView) findViewById(android.R.id.list);
|
lv = (ListView) findViewById(android.R.id.list);
|
||||||
|
|
||||||
la = new MyAdapter(getBaseContext(), object);
|
la = new MyAdapter(getBaseContext(), object);
|
||||||
this.object.adapter = la;
|
|
||||||
lv.setAdapter(la);
|
lv.setAdapter(la);
|
||||||
lv.setOnScrollListener(new OnScrollListener() {
|
|
||||||
private int priorFirst = -1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScroll(final AbsListView view, final int first,
|
|
||||||
final int visible, final int total) {
|
|
||||||
// detect if last item is visible
|
|
||||||
if (visible < total && (first + visible == total)) {
|
|
||||||
// see if we have more results
|
|
||||||
if (first != priorFirst) {
|
|
||||||
priorFirst = first;
|
|
||||||
Log.d("EventList", "Loading smthing");
|
|
||||||
if (((long) object.eventList.size()) < object.count_events) {
|
|
||||||
loadMoreEvents();
|
|
||||||
// moreEvents = true;
|
|
||||||
} /*
|
|
||||||
* else { Log.d("eventList", "moreEvents FALSE");
|
|
||||||
* moreEvents = false; }
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
onBroadcast = new BroadcastReceiver() {
|
onBroadcast = new BroadcastReceiver() {
|
||||||
|
|
||||||
@ -112,26 +82,37 @@ public class EventList extends ListActivity {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
int load_more = intent.getIntExtra("load_more", 0);
|
int load_more = intent.getIntExtra("load_more", 0);
|
||||||
|
|
||||||
|
Button button = (Button) findViewById(R.id.button_load_more_events);
|
||||||
|
|
||||||
|
if (object.eventList.size() == 0) {
|
||||||
|
button.setVisibility(Button.GONE);
|
||||||
|
} else if (((long) object.eventList.size()) >= object.count_events) {
|
||||||
|
button.setVisibility(Button.GONE);
|
||||||
|
} else {
|
||||||
|
button.setVisibility(Button.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
if (load_more == 1) {
|
if (load_more == 1) {
|
||||||
/* LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||||
layout.setVisibility(LinearLayout.GONE);*/
|
layout.setVisibility(LinearLayout.GONE);
|
||||||
la.showLoadingEvents = false;
|
la.showLoadingEvents = false;
|
||||||
} else {
|
} else {
|
||||||
/*LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
LinearLayout layout = (LinearLayout) findViewById(R.id.loading_layout);
|
||||||
layout.setVisibility(LinearLayout.GONE);*/
|
layout.setVisibility(LinearLayout.GONE);
|
||||||
|
|
||||||
if (((int) object.count_events) == 0) {
|
if (((int) object.count_events) == 0) {
|
||||||
LinearLayout layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||||
layout.setVisibility(LinearLayout.VISIBLE);
|
layout.setVisibility(LinearLayout.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
la.notifyDataSetChanged();
|
la.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
||||||
|
|
||||||
//this.toggleLoadingLayout();
|
this.toggleLoadingLayout();
|
||||||
|
|
||||||
if (this.object.show_popup_info) {
|
if (this.object.show_popup_info) {
|
||||||
this.object.show_popup_info = false;
|
this.object.show_popup_info = false;
|
||||||
@ -145,7 +126,7 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
if (this.object.showOptionsFirstTime) {
|
if (this.object.showOptionsFirstTime) {
|
||||||
this.object.loadInProgress = true;
|
this.object.loadInProgress = true;
|
||||||
// toggleLoadingLayout();
|
toggleLoadingLayout();
|
||||||
|
|
||||||
this.object.showOptionsFirstTime = false;
|
this.object.showOptionsFirstTime = false;
|
||||||
this.object.executeBackgroundGetEvents();
|
this.object.executeBackgroundGetEvents();
|
||||||
@ -157,7 +138,7 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
registerReceiver(onBroadcast, new IntentFilter("eventlist.java"));
|
||||||
|
|
||||||
//this.toggleLoadingLayout();
|
this.toggleLoadingLayout();
|
||||||
|
|
||||||
if (!this.object.loadInProgress) {
|
if (!this.object.loadInProgress) {
|
||||||
if (((int) object.count_events) == 0) {
|
if (((int) object.count_events) == 0) {
|
||||||
@ -189,7 +170,7 @@ public class EventList extends ListActivity {
|
|||||||
this.object.loadInProgress = true;
|
this.object.loadInProgress = true;
|
||||||
this.object.getNewListEvents = true;
|
this.object.getNewListEvents = true;
|
||||||
this.object.eventList = new ArrayList<EventListItem>();
|
this.object.eventList = new ArrayList<EventListItem>();
|
||||||
// this.toggleLoadingLayout();
|
this.toggleLoadingLayout();
|
||||||
this.object.executeBackgroundGetEvents();
|
this.object.executeBackgroundGetEvents();
|
||||||
break;
|
break;
|
||||||
case R.id.about_button_menu_options:
|
case R.id.about_button_menu_options:
|
||||||
@ -204,7 +185,7 @@ public class EventList extends ListActivity {
|
|||||||
/**
|
/**
|
||||||
* Shows loading information.
|
* Shows loading information.
|
||||||
*/
|
*/
|
||||||
/*private void toggleLoadingLayout() {
|
private void toggleLoadingLayout() {
|
||||||
LinearLayout layout;
|
LinearLayout layout;
|
||||||
|
|
||||||
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
layout = (LinearLayout) findViewById(R.id.empty_list_layout);
|
||||||
@ -217,7 +198,7 @@ public class EventList extends ListActivity {
|
|||||||
} else {
|
} else {
|
||||||
layout.setVisibility(LinearLayout.GONE);
|
layout.setVisibility(LinearLayout.GONE);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
private String getImageGroupUrl(String group_icon) {
|
private String getImageGroupUrl(String group_icon) {
|
||||||
SharedPreferences preferences = getApplicationContext()
|
SharedPreferences preferences = getApplicationContext()
|
||||||
@ -263,12 +244,7 @@ public class EventList extends ListActivity {
|
|||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
super.onListItemClick(l, v, position, id);
|
super.onListItemClick(l, v, position, id);
|
||||||
|
|
||||||
EventListItem item;
|
EventListItem item = this.object.eventList.get(position);
|
||||||
try {
|
|
||||||
item = this.object.eventList.get(position);
|
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
item.opened = !item.opened;
|
item.opened = !item.opened;
|
||||||
this.object.eventList.set(position, item);
|
this.object.eventList.set(position, item);
|
||||||
@ -282,7 +258,8 @@ public class EventList extends ListActivity {
|
|||||||
*/
|
*/
|
||||||
private void loadMoreEvents() {
|
private void loadMoreEvents() {
|
||||||
la.showLoadingEvents = true;
|
la.showLoadingEvents = true;
|
||||||
object.offset += object.pagination;
|
la.notifyDataSetChanged();
|
||||||
|
|
||||||
object.executeBackgroundGetEvents();
|
object.executeBackgroundGetEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,83 +304,49 @@ public class EventList extends ListActivity {
|
|||||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
view = inflater.inflate(R.layout.item_list_event_layout, null);
|
view = inflater.inflate(R.layout.item_list_event_layout, null);
|
||||||
|
|
||||||
LinearLayout layout = (LinearLayout) view
|
|
||||||
.findViewById(R.id.loading_more_events);
|
|
||||||
// layout.setVisibility(LinearLayout.GONE);*/
|
|
||||||
// If the end of the list.
|
// If the end of the list.
|
||||||
if (this.object.eventList.size() == position) {
|
if (this.object.eventList.size() == position) {
|
||||||
if (object.newEvents) {
|
|
||||||
Log.d("loading", "true");
|
|
||||||
layout.setVisibility(LinearLayout.VISIBLE);
|
|
||||||
if (convertView != null) {
|
|
||||||
convertView.setClickable(false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.d("loading", "false");
|
|
||||||
layout.setVisibility(LinearLayout.GONE);
|
|
||||||
if (convertView != null) {
|
|
||||||
convertView.setClickable(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.notifyDataSetChanged();
|
|
||||||
// if (showLoadingEvents) {
|
|
||||||
/*
|
|
||||||
* layout = (LinearLayout) view
|
|
||||||
* .findViewById(R.id.loading_more_events);
|
|
||||||
* layout.setVisibility(LinearLayout.VISIBLE);
|
|
||||||
*/
|
|
||||||
// }// else {
|
|
||||||
/*
|
|
||||||
* LinearLayout layout = (LinearLayout) view
|
|
||||||
* .findViewById(R.id.loading_more_events);
|
|
||||||
* layout.setVisibility(LinearLayout.GONE);
|
|
||||||
*/
|
|
||||||
// }
|
|
||||||
// Show button to get more events
|
// Show button to get more events
|
||||||
if ((!object.loadInProgress) && (object.count_events != 0)) {
|
if ((!object.loadInProgress) && (object.count_events != 0)) {
|
||||||
|
if (showLoadingEvents) {
|
||||||
|
LinearLayout layout = (LinearLayout) view
|
||||||
|
.findViewById(R.id.loading_more_events);
|
||||||
|
layout.setVisibility(LinearLayout.VISIBLE);
|
||||||
|
|
||||||
|
RelativeLayout layout2 = (RelativeLayout) view
|
||||||
|
.findViewById(R.id.content_event_item);
|
||||||
|
layout2.setVisibility(RelativeLayout.GONE);
|
||||||
|
|
||||||
|
Button button = (Button) view
|
||||||
|
.findViewById(R.id.button_load_more_events);
|
||||||
|
button.setVisibility(Button.GONE);
|
||||||
|
} else {
|
||||||
|
Button button = (Button) view
|
||||||
|
.findViewById(R.id.button_load_more_events);
|
||||||
|
|
||||||
|
if (object.eventList.size() == 0) {
|
||||||
|
button.setVisibility(Button.GONE);
|
||||||
|
} else if (((long) object.eventList.size()) >= object.count_events) {
|
||||||
|
button.setVisibility(Button.GONE);
|
||||||
|
} else {
|
||||||
|
button.setVisibility(Button.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
object.offset += object.pagination;
|
||||||
|
loadMoreEvents();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
RelativeLayout content_event_item = (RelativeLayout) view
|
||||||
|
.findViewById(R.id.content_event_item);
|
||||||
|
content_event_item.setVisibility(RelativeLayout.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Log.d("error", "crash2"); LinearLayout layout =
|
|
||||||
* (LinearLayout) view .findViewById(R.id.loading_more_events);
|
|
||||||
* layout.setVisibility(LinearLayout.VISIBLE);
|
|
||||||
*
|
|
||||||
* RelativeLayout layout2 = (RelativeLayout) view
|
|
||||||
* .findViewById(R.id.content_event_item);
|
|
||||||
* layout2.setVisibility(RelativeLayout.GONE);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Button button = (Button) view
|
|
||||||
* .findViewById(R.id.button_load_more_events);
|
|
||||||
* button.setVisibility(Button.GONE);
|
|
||||||
*/
|
|
||||||
// } else {
|
|
||||||
/*
|
|
||||||
* Log.d("error", "crash1"); LinearLayout layout =
|
|
||||||
* (LinearLayout) view .findViewById(R.id.loading_more_events);
|
|
||||||
* layout.setVisibility(LinearLayout.GONE);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* RelativeLayout content_event_item = (RelativeLayout) view
|
|
||||||
* .findViewById(R.id.content_event_item);
|
|
||||||
* content_event_item.setVisibility(RelativeLayout.GONE);
|
|
||||||
*/
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
final EventListItem item = this.object.eventList.get(position);
|
||||||
* LinearLayout layout = (LinearLayout) view
|
|
||||||
* .findViewById(R.id.loading_more_events);
|
|
||||||
* layout.setVisibility(LinearLayout.GONE);
|
|
||||||
*/
|
|
||||||
final EventListItem item;
|
|
||||||
try {
|
|
||||||
item = this.object.eventList.get(position);
|
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (item.criticity) {
|
switch (item.criticity) {
|
||||||
|
|
||||||
@ -577,6 +520,7 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
// TODO
|
||||||
Intent intent = new Intent(
|
Intent intent = new Intent(
|
||||||
getBaseContext(),
|
getBaseContext(),
|
||||||
CreateIncidentActivity.class);
|
CreateIncidentActivity.class);
|
||||||
@ -600,7 +544,7 @@ public class EventList extends ListActivity {
|
|||||||
itemLinearLayout.addView(viewEventExtended);
|
itemLinearLayout.addView(viewEventExtended);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.notifyDataSetChanged();
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,12 +619,7 @@ public class EventList extends ListActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View arg0) {
|
public void onClick(View arg0) {
|
||||||
EventListItem item;
|
EventListItem item = this.object.eventList.get(mPosition);
|
||||||
try {
|
|
||||||
item = this.object.eventList.get(mPosition);
|
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
item.opened = !item.opened;
|
item.opened = !item.opened;
|
||||||
this.object.eventList.set(mPosition, item);
|
this.object.eventList.set(mPosition, item);
|
||||||
la.notifyDataSetChanged();
|
la.notifyDataSetChanged();
|
||||||
|
@ -21,6 +21,7 @@ import java.net.URL;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -56,13 +57,15 @@ public class Options extends Activity {
|
|||||||
private String password;
|
private String password;
|
||||||
private int refreshTimeKey;
|
private int refreshTimeKey;
|
||||||
private TextView connectionStatus;
|
private TextView connectionStatus;
|
||||||
|
private ProgressDialog retrievingCertificate;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
private PandroidEventviewerActivity object;
|
private PandroidEventviewerActivity object;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
this.context = this;
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
|
|
||||||
setContentView(R.layout.options);
|
setContentView(R.layout.options);
|
||||||
@ -168,34 +171,10 @@ public class Options extends Activity {
|
|||||||
String url = ((EditText) findViewById(R.id.url)).getText().toString();
|
String url = ((EditText) findViewById(R.id.url)).getText().toString();
|
||||||
if (url.contains("https")) {
|
if (url.contains("https")) {
|
||||||
try {
|
try {
|
||||||
if (!Core.isValidCertificate(new URL(url))) {
|
retrievingCertificate = ProgressDialog.show(this, "",
|
||||||
// Displays confirmation dialog
|
"Loading...", true);
|
||||||
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
new CheckCertificateAsyncTask()
|
||||||
@Override
|
.execute(new URL[] { new URL(url) });
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
switch (which) {
|
|
||||||
case DialogInterface.BUTTON_NEGATIVE:
|
|
||||||
Toast.makeText(getApplicationContext(),
|
|
||||||
R.string.options_not_saved,
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
case DialogInterface.BUTTON_POSITIVE:
|
|
||||||
writeChanges();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
||||||
builder.setMessage(
|
|
||||||
getString(R.string.certificate_not_valid))
|
|
||||||
.setPositiveButton(getString(android.R.string.yes),
|
|
||||||
dialogClickListener)
|
|
||||||
.setNegativeButton(getString(android.R.string.no),
|
|
||||||
dialogClickListener).show();
|
|
||||||
} else {
|
|
||||||
writeChanges();
|
|
||||||
}
|
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.url_not_valid,
|
Toast.makeText(getApplicationContext(), R.string.url_not_valid,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
@ -333,4 +312,45 @@ public class Options extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class CheckCertificateAsyncTask extends
|
||||||
|
AsyncTask<URL, Void, Boolean> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean doInBackground(URL... arg0) {
|
||||||
|
return Core.isValidCertificate(arg0[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Boolean result) {
|
||||||
|
retrievingCertificate.dismiss();
|
||||||
|
if (!result) {
|
||||||
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case DialogInterface.BUTTON_NEGATIVE:
|
||||||
|
Toast.makeText(getApplicationContext(),
|
||||||
|
R.string.options_not_saved,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
case DialogInterface.BUTTON_POSITIVE:
|
||||||
|
writeChanges();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
|
context);
|
||||||
|
builder.setMessage(getString(R.string.certificate_not_valid))
|
||||||
|
.setPositiveButton(getString(android.R.string.yes),
|
||||||
|
dialogClickListener)
|
||||||
|
.setNegativeButton(getString(android.R.string.no),
|
||||||
|
dialogClickListener).show();
|
||||||
|
} else {
|
||||||
|
writeChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,11 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@ -38,6 +42,7 @@ import android.widget.Toast;
|
|||||||
public class PandroidEventviewerActivity extends TabActivity implements
|
public class PandroidEventviewerActivity extends TabActivity implements
|
||||||
Serializable {
|
Serializable {
|
||||||
private static String TAG = "PandroidEventviewerActivity";
|
private static String TAG = "PandroidEventviewerActivity";
|
||||||
|
private static final int PROBLEM_NOTIFICATION_ID = 1;
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
// Data aplication
|
// Data aplication
|
||||||
@ -346,61 +351,65 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
event.event = getApplication().getString(
|
event.event = getApplication().getString(
|
||||||
R.string.unknown_event_str);
|
R.string.unknown_event_str);
|
||||||
} else {
|
} else {
|
||||||
if (items[0].length() == 0) {
|
try {
|
||||||
event.id_event = 0;
|
if (items[0].length() == 0) {
|
||||||
} else {
|
event.id_event = 0;
|
||||||
event.id_event = Integer.parseInt(items[0]);
|
} else {
|
||||||
}
|
event.id_event = Integer.parseInt(items[0]);
|
||||||
if (items[1].length() == 0) {
|
}
|
||||||
event.id_agent = 0;
|
if (items[1].length() == 0) {
|
||||||
} else {
|
event.id_agent = 0;
|
||||||
event.id_agent = Integer.parseInt(items[1]);
|
} else {
|
||||||
}
|
event.id_agent = Integer.parseInt(items[1]);
|
||||||
event.id_user = items[2];
|
}
|
||||||
if (items[3].length() == 0) {
|
event.id_user = items[2];
|
||||||
event.id_group = 0;
|
if (items[3].length() == 0) {
|
||||||
} else {
|
event.id_group = 0;
|
||||||
event.id_group = Integer.parseInt(items[3]);
|
} else {
|
||||||
}
|
event.id_group = Integer.parseInt(items[3]);
|
||||||
if (items[4].length() == 0) {
|
}
|
||||||
event.status = 0;
|
if (items[4].length() == 0) {
|
||||||
} else {
|
event.status = 0;
|
||||||
event.status = Integer.parseInt(items[4]);
|
} else {
|
||||||
}
|
event.status = Integer.parseInt(items[4]);
|
||||||
event.timestamp = items[5];
|
}
|
||||||
event.event = items[6];
|
event.timestamp = items[5];
|
||||||
if (items[7].length() == 0) {
|
event.event = items[6];
|
||||||
event.utimestamp = 0;
|
if (items[7].length() == 0) {
|
||||||
} else {
|
event.utimestamp = 0;
|
||||||
event.utimestamp = Integer.parseInt(items[7]);
|
} else {
|
||||||
}
|
event.utimestamp = Integer.parseInt(items[7]);
|
||||||
event.event_type = items[8];
|
}
|
||||||
if (items[9].length() == 0) {
|
event.event_type = items[8];
|
||||||
event.id_agentmodule = 0;
|
if (items[9].length() == 0) {
|
||||||
} else {
|
event.id_agentmodule = 0;
|
||||||
event.id_agentmodule = Integer.parseInt(items[9]);
|
} else {
|
||||||
}
|
event.id_agentmodule = Integer.parseInt(items[9]);
|
||||||
if (items[10].length() == 0) {
|
}
|
||||||
event.id_alert_am = 0;
|
if (items[10].length() == 0) {
|
||||||
} else {
|
event.id_alert_am = 0;
|
||||||
event.id_alert_am = Integer.parseInt(items[10]);
|
} else {
|
||||||
}
|
event.id_alert_am = Integer.parseInt(items[10]);
|
||||||
if (items[11].length() == 0) {
|
}
|
||||||
event.criticity = 0;
|
if (items[11].length() == 0) {
|
||||||
} else {
|
event.criticity = 0;
|
||||||
event.criticity = Integer.parseInt(items[11]);
|
} else {
|
||||||
}
|
event.criticity = Integer.parseInt(items[11]);
|
||||||
event.user_comment = items[12];
|
}
|
||||||
event.tags = items[13];
|
event.user_comment = items[12];
|
||||||
event.agent_name = items[16];
|
event.tags = items[13];
|
||||||
event.group_name = items[17];
|
event.agent_name = items[16];
|
||||||
event.group_icon = items[18];
|
event.group_name = items[17];
|
||||||
event.description_event = items[19];
|
event.group_icon = items[18];
|
||||||
event.description_image = items[20];
|
event.description_event = items[19];
|
||||||
event.criticity_name = items[21];
|
event.description_image = items[20];
|
||||||
event.criticity_image = items[22];
|
event.criticity_name = items[21];
|
||||||
|
event.criticity_image = items[22];
|
||||||
|
|
||||||
event.opened = false;
|
event.opened = false;
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
launchProblemParsingNotification();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.eventList.add(event);
|
this.eventList.add(event);
|
||||||
}
|
}
|
||||||
@ -410,7 +419,11 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
* Executes the async task of getting events.
|
* Executes the async task of getting events.
|
||||||
*/
|
*/
|
||||||
public void executeBackgroundGetEvents() {
|
public void executeBackgroundGetEvents() {
|
||||||
new GetEventsAsyncTask(adapter).execute();
|
if (adapter != null) {
|
||||||
|
new GetEventsAsyncTask(adapter).execute();
|
||||||
|
} else {
|
||||||
|
new GetEventsAsyncTask(null).execute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -448,9 +461,34 @@ public class PandroidEventviewerActivity extends TabActivity implements
|
|||||||
i.putExtra("load_more", 1);
|
i.putExtra("load_more", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
adapter.notifyDataSetChanged();
|
// adapter.notifyDataSetChanged();
|
||||||
getApplicationContext().sendBroadcast(i);
|
getApplicationContext().sendBroadcast(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies the user when there is a problem retrieving server's data.
|
||||||
|
*/
|
||||||
|
private void launchProblemParsingNotification() {
|
||||||
|
String ns = Context.NOTIFICATION_SERVICE;
|
||||||
|
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
|
||||||
|
int icon = R.drawable.pandorafms_logo;
|
||||||
|
String tickerText = getString(R.string.notification_error_parsing);
|
||||||
|
String title = getString(R.string.pandroid_event_viewer_str);
|
||||||
|
|
||||||
|
long when = System.currentTimeMillis();
|
||||||
|
|
||||||
|
Notification notification = new Notification(icon, tickerText, when);
|
||||||
|
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||||
|
|
||||||
|
Context context = getApplicationContext();
|
||||||
|
Intent notificationIntent = new Intent(this, Options.class);
|
||||||
|
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
|
||||||
|
notificationIntent, 0);
|
||||||
|
|
||||||
|
notification.setLatestEventInfo(context, title, tickerText,
|
||||||
|
contentIntent);
|
||||||
|
mNotificationManager.notify(PROBLEM_NOTIFICATION_ID, notification);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user