2012-05-12 Santiago Munín <burning1@gmail.com>
* Licenses and javadoc comments added to all files, refactorized code. * Main.java: fixed a bug which was making the app crash when "Reset" button was clicked. * res/drawable-ldpi/help.png, res/drawable-ldpi/cross.png, res/drawable-ldpi/ok.png, res/values/styles.xml: Added in order to build the new notification options' UI. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6298 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f220046f1e
commit
fc4e7ab23f
|
@ -3,5 +3,6 @@
|
|||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -15,75 +15,78 @@
|
|||
// GNU General Public License for more details.
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="pandroid_event_viewer.pandorafms"
|
||||
android:versionCode="2"
|
||||
android:versionName="1.1">
|
||||
<uses-sdk android:minSdkVersion="8" />
|
||||
package="pandroid_event_viewer.pandorafms"
|
||||
android:versionCode="2"
|
||||
android:versionName="1.1" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="8" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<!--
|
||||
<!--
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
|
||||
This is crazy, I want only block the screen rotation, but the android need
|
||||
two things.
|
||||
-->
|
||||
-->
|
||||
|
||||
<application android:icon="@drawable/pandorafms_logo"
|
||||
android:label="Pandroid Event viewer"
|
||||
android:description="@string/pandroid_event_viewer_description_str"
|
||||
>
|
||||
<application
|
||||
android:description="@string/pandroid_event_viewer_description_str"
|
||||
android:icon="@drawable/pandorafms_logo"
|
||||
android:label="Pandroid Event viewer" >
|
||||
<activity
|
||||
android:name=".PandroidEventviewerActivity"
|
||||
android:label="Pandroid Event viewer"
|
||||
android:theme="@android:style/Theme.NoTitleBar"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
<intent-filter>
|
||||
android:name=".PandroidEventviewerActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="Pandroid Event viewer"
|
||||
android:theme="@android:style/Theme.NoTitleBar" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".Main"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
android:name=".Main"
|
||||
android:configChanges="orientation|keyboardHidden" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".EventList"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
android:name=".EventList"
|
||||
android:configChanges="orientation|keyboardHidden" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".Options"
|
||||
android:label="@string/option_title_str"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".About"
|
||||
android:label="@string/pandroid_event_viewer_str"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
>
|
||||
android:name=".Options"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="@string/option_title_str" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".PopupValidationEvent"
|
||||
android:label="@string/validate_event_button_str"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
>
|
||||
android:name=".About"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="@string/pandroid_event_viewer_str"
|
||||
android:theme="@android:style/Theme.Dialog" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".Info"
|
||||
android:label="@string/pandroid_event_viewer_str"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
>
|
||||
<activity
|
||||
android:name=".PopupValidationEvent"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="@string/validate_event_button_str"
|
||||
android:theme="@android:style/Theme.Dialog" >
|
||||
</activity>
|
||||
|
||||
<service android:name=".PandroidEventviewerService"></service>
|
||||
|
||||
<receiver android:process=":remote" android:name=".AlarmReceiver"></receiver>
|
||||
<activity
|
||||
android:name=".Info"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:label="@string/pandroid_event_viewer_str"
|
||||
android:theme="@android:style/Theme.Dialog" >
|
||||
</activity>
|
||||
|
||||
<service android:name=".PandroidEventviewerService" >
|
||||
</service>
|
||||
|
||||
<receiver
|
||||
android:name=".AlarmReceiver"
|
||||
android:process=":remote" >
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -1,3 +1,22 @@
|
|||
2012-05-12 Santiago Munín <burning1@gmail.com>
|
||||
|
||||
* Licenses and javadoc comments added to all files, refactorized code.
|
||||
|
||||
* Main.java: fixed a bug which was making the app crash when "Reset" button was clicked.
|
||||
|
||||
* res/drawable-ldpi/help.png,
|
||||
res/drawable-ldpi/cross.png,
|
||||
res/drawable-ldpi/ok.png,
|
||||
res/values/styles.xml: Added in order to build the new notification options' UI.
|
||||
|
||||
2012-05-08 Santiago Munín <burning1@gmail.com>
|
||||
|
||||
* Options.java: Fixed a null pointer bug which was making the
|
||||
app crash when accessing the options.
|
||||
|
||||
* Main.java: Fixed a null pointer bug which crash at the beginning
|
||||
of the app.
|
||||
|
||||
2012-12-27 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* AndroidManifest.xml,
|
||||
|
@ -11,8 +30,6 @@
|
|||
res/values/strings.xml,res/values-en/strings.xml,
|
||||
res/values-es/strings.xml,res/layout/info.xml: fixed some things and
|
||||
added more stability and a pretty splashscreen.
|
||||
|
||||
MERGED FROM BRANCH 4.0.2
|
||||
|
||||
2012-04-25 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
|
@ -22,8 +39,6 @@
|
|||
combo group because sometimes this is as null.
|
||||
|
||||
Fixes: #3495038
|
||||
|
||||
MERGED FROM BRANCH 4.0.2
|
||||
|
||||
2011-10-24 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -14,166 +14,142 @@
|
|||
// 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"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TextView
|
||||
android:text="@string/agent_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/agent_name"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:editable="true"
|
||||
android:layout_width="fill_parent"
|
||||
/>
|
||||
<TextView
|
||||
android:text="@string/event_search_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<EditText
|
||||
android:id="@+id/event_search_text"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:editable="true"
|
||||
android:layout_width="fill_parent"
|
||||
/>
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<TableRow
|
||||
android:visibility="gone"
|
||||
>
|
||||
<TextView
|
||||
android:text="@string/group_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/group_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
<ProgressBar
|
||||
android:id="@+id/loading_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/severity_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/severity_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:text="@string/status_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/status_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
<!--
|
||||
<TextView
|
||||
android:text="@string/date_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<TimePicker
|
||||
android:textSize="10sp"
|
||||
android:id="@+id/time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<DatePicker
|
||||
android:id="@+id/date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
-->
|
||||
<TextView
|
||||
android:text="@string/max_time_old_event_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/max_time_old_event_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:layout_marginTop="10px"
|
||||
android:layout_marginBottom="10px"
|
||||
android:layout_height="2px"
|
||||
android:layout_width="fill_parent"
|
||||
android:background="#ffffff"
|
||||
/>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<Button
|
||||
android:text="@string/reset_button_str"
|
||||
android:id="@+id/button_reset"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
<Button
|
||||
android:text="@string/search_button_str"
|
||||
android:id="@+id/button_send"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
/>
|
||||
</LinearLayout>
|
||||
<Button
|
||||
android:text="@string/set_as_filter_watcher_button_str"
|
||||
android:id="@+id/button_set_as_filter_watcher"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/agent_label_str" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/agent_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"
|
||||
android:singleLine="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/event_search_label_str" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/event_search_text"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"
|
||||
android:singleLine="true" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TableRow android:visibility="gone" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/group_label_str" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/group_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/severity_label_str" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/severity_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/status_label_str" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/status_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/max_time_old_event_str"/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/max_time_old_event_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="#ffffff" />
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_reset"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/reset_button_str" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_send"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/search_button_str" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_set_as_filter_watcher"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/set_as_filter_watcher_button_str" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -14,82 +14,191 @@
|
|||
// 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"
|
||||
>
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
<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="fill_parent"
|
||||
/>
|
||||
<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="fill_parent"
|
||||
/>
|
||||
<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="fill_parent"
|
||||
android:inputType="textPassword"
|
||||
/>
|
||||
<TextView
|
||||
android:textColor="#ffffff"
|
||||
android:text="@string/refresh_time_label_str"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
/>
|
||||
<Spinner
|
||||
android:id="@+id/refresh_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/update_options"
|
||||
android:text="@string/update_button_str"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
style="@style/options_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:text="@string/connection" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="5dp"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/url_label_str"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/url"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textWebEditText"
|
||||
android:singleLine="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/user_label_str"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/user"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"
|
||||
android:singleLine="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingRight="5dip"
|
||||
android:text="@string/password_label_str"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/password"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
android:singleLine="true" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/refresh_time_label_str"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/refresh_combo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="left" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/check_connection_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableBottom="@drawable/help"
|
||||
android:text="@string/check_connection"
|
||||
android:textColor="#ffffff" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
style="@style/options_header"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:text="@string/notification" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="5dp"
|
||||
android:stretchColumns="0,1" >
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
style="@style/options_entry_text"
|
||||
android:text="@string/vibration" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/vibration_on"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
style="@style/options_entry_text"
|
||||
android:text="@string/led_flash" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/led_flash_on"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="63dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
style="@style/options_entry_text"
|
||||
android:text="@string/sound" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/sound_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="10dp" />
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:background="#ffffff" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/update_options"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/update_button_str"/>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -52,7 +52,7 @@
|
|||
<string name="option_title_str">Options</string>
|
||||
<string name="load_more_events_button_str">Load more events</string>
|
||||
<string name="empty_label_str">Empty list events</string>
|
||||
<string name="refresh_time_label_str">Refresh time watcher</string>
|
||||
<string name="refresh_time_label_str">Refresh time</string>
|
||||
<string name="set_as_filter_watcher_button_str">Filter by default</string>
|
||||
<string name="validate_event_button_str">Validate Event</string>
|
||||
|
||||
|
@ -103,4 +103,13 @@
|
|||
<string name="pandroid_info_txt"><b>Welcome to Pandora FMS Event viewer for Android</b></string>
|
||||
<string name="pandroid_info_long_txt"><p>This app is used for to see confortable and standaralone the events status from the monitoring server of Pandora FMS. From this app you can see in realtime the events and validate or filter.</p>
|
||||
<p>The configuration as default connecting with public demo of Pandora FMS in firefly.artica.es. Please change the configuration for to use your Pandora FMS server.</p></string>
|
||||
|
||||
<string name="check_connection">Connection status</string>
|
||||
<string name="connection">Connection</string>
|
||||
<string name="notification">Notification</string>
|
||||
<string name="vibration">Vibration</string>
|
||||
<string name="led_flash">Led flashes</string>
|
||||
<string name="sound">Sound</string>
|
||||
<string name="select_sound">Select notification sound</string>
|
||||
<string name="silence">Silence</string>
|
||||
</resources>
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="options_header">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:background">#999999</item>
|
||||
<item name="android:paddingTop">2dp</item>
|
||||
<item name="android:paddingBottom">2dp</item>
|
||||
<item name="android:paddingLeft">15dp</item>
|
||||
<item name="android:layout_marginBottom">5dp</item>
|
||||
<item name="android:textSize">20dp</item>
|
||||
<item name="android:textColor">#FFFFFF</item>
|
||||
</style>
|
||||
<!--
|
||||
<style name="options_section">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:orientation">vertical</item>
|
||||
<item name="android:layout_margin">5dp</item>
|
||||
</style>-->
|
||||
|
||||
<style name="options_entry_text">
|
||||
<item name="android:layout_width">fill_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:textSize">20dp</item>
|
||||
<item name="android:layout_margin">5dp</item>
|
||||
<item name="android:textColor">#FFFFFF</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -5,43 +21,51 @@ import android.content.SharedPreferences;
|
|||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* This class contains basic instructions to describe the About popup.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class About extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.info);
|
||||
|
||||
TextView text = (TextView) findViewById(R.id.url_pandora);
|
||||
text.setText(Html.fromHtml("<a href='http://pandorafms.org/'>PandoraFMS.org</a>"));
|
||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
CheckBox check_show = (CheckBox)findViewById(R.id.dont_show_again_extended);
|
||||
|
||||
check_show.setOnClickListener(new View.OnClickListener() {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.info);
|
||||
|
||||
TextView text = (TextView) findViewById(R.id.url_pandora);
|
||||
text.setText(Html
|
||||
.fromHtml("<a href='http://pandorafms.org/'>PandoraFMS.org</a>"));
|
||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
CheckBox check_show = (CheckBox) findViewById(R.id.dont_show_again_extended);
|
||||
|
||||
check_show.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
CheckBox check_show = (CheckBox)v;
|
||||
CheckBox check_show = (CheckBox) v;
|
||||
if (check_show.isChecked()) {
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||
editorPreferences.putBoolean("show_popup_info", false);
|
||||
editorPreferences.commit();
|
||||
}
|
||||
else {
|
||||
getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editorPreferences = preferences
|
||||
.edit();
|
||||
editorPreferences.putBoolean("show_popup_info", false);
|
||||
editorPreferences.commit();
|
||||
} else {
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||
editorPreferences.putBoolean("show_popup_info", true);
|
||||
editorPreferences.commit();
|
||||
getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editorPreferences = preferences
|
||||
.edit();
|
||||
editorPreferences.putBoolean("show_popup_info", true);
|
||||
editorPreferences.commit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,243 +36,312 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* It will receive new events and launch notifications.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class AlarmReceiver extends BroadcastReceiver {
|
||||
private static String TAG = "ALARM RECEIVER";
|
||||
private static final int NOTIFICATION_PANDROID_EVENT_VIEWER = 666;
|
||||
public String url;
|
||||
public String user;
|
||||
public String password;
|
||||
|
||||
|
||||
public long count_events;
|
||||
public int more_criticity;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.e("AlarmReceiver", "onReceive");
|
||||
Log.i(TAG, "onReceive");
|
||||
checkNewEvents(context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if there are new events and, in that case, throw a notification.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public void checkNewEvents(Context context) {
|
||||
if (this.url == null) {
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
context.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
this.url = preferences.getString("url", "");
|
||||
this.user = preferences.getString("user", "");
|
||||
this.password = preferences.getString("password", "");
|
||||
Calendar c = Calendar.getInstance();
|
||||
long now = (c.getTimeInMillis() / 1000);
|
||||
long old_previous_filterTimestamp = preferences.getLong("previous_filterTimestamp", now);
|
||||
|
||||
if ((user.length() == 0) && (password.length() == 0)
|
||||
&& (url.length() == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
UrlEncodedFormEntity entity;
|
||||
HttpPost httpPost;
|
||||
List<NameValuePair> parameters;
|
||||
HttpResponse response;
|
||||
HttpEntity entityResponse;
|
||||
String return_api;
|
||||
|
||||
httpPost = new HttpPost(this.url + "/include/api.php");
|
||||
|
||||
String parametersAPI = serializeParams2Api(context);
|
||||
|
||||
//Get total count.
|
||||
parameters = new ArrayList<NameValuePair>();
|
||||
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", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other", parametersAPI + "|total"));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core.convertStreamToString(entityResponse.getContent());
|
||||
|
||||
return_api = return_api.replace("\n", "");
|
||||
Log.e("AlarmReceiver checkNewEvents", "" + return_api);
|
||||
this.count_events = new Long(return_api).longValue();
|
||||
|
||||
//Check the event more critical
|
||||
if (this.count_events != 0) {
|
||||
parameters = new ArrayList<NameValuePair>();
|
||||
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", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other", parametersAPI + "|more_criticity"));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core.convertStreamToString(entityResponse.getContent());
|
||||
return_api = return_api.replace("\n", "");
|
||||
this.more_criticity = new Integer(return_api).intValue();
|
||||
|
||||
notificationEvent(context);
|
||||
}
|
||||
else {
|
||||
this.more_criticity = -1;
|
||||
|
||||
//Restore timestamp
|
||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||
editorPreferences.putLong("previous_filterTimestamp", old_previous_filterTimestamp);
|
||||
editorPreferences.commit();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e("EXCEPTION checkNewEvents", e.getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
context.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
this.url = preferences.getString("url", "");
|
||||
this.user = preferences.getString("user", "");
|
||||
this.password = preferences.getString("password", "");
|
||||
Calendar c = Calendar.getInstance();
|
||||
long now = (c.getTimeInMillis() / 1000);
|
||||
long old_previous_filterTimestamp = preferences.getLong(
|
||||
"previous_filterTimestamp", now);
|
||||
|
||||
if ((user.length() == 0) && (password.length() == 0)
|
||||
&& (url.length() == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
UrlEncodedFormEntity entity;
|
||||
HttpPost httpPost;
|
||||
List<NameValuePair> parameters;
|
||||
HttpResponse response;
|
||||
HttpEntity entityResponse;
|
||||
String return_api;
|
||||
|
||||
httpPost = new HttpPost(this.url + "/include/api.php");
|
||||
|
||||
String parametersAPI = serializeParams2Api(context);
|
||||
|
||||
// Get total count.
|
||||
parameters = new ArrayList<NameValuePair>();
|
||||
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", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode",
|
||||
"url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other", parametersAPI
|
||||
+ "|total"));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core.convertStreamToString(entityResponse
|
||||
.getContent());
|
||||
|
||||
return_api = return_api.replace("\n", "");
|
||||
Log.i(TAG + " checkNewEvents", return_api);
|
||||
this.count_events = new Long(return_api).longValue();
|
||||
|
||||
// Check the event more critical
|
||||
if (this.count_events != 0) {
|
||||
parameters = new ArrayList<NameValuePair>();
|
||||
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", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode",
|
||||
"url_encode_separator_|"));
|
||||
parameters
|
||||
.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other",
|
||||
parametersAPI + "|more_criticity"));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core.convertStreamToString(entityResponse
|
||||
.getContent());
|
||||
return_api = return_api.replace("\n", "");
|
||||
this.more_criticity = new Integer(return_api).intValue();
|
||||
|
||||
notificationEvent(context);
|
||||
} else {
|
||||
this.more_criticity = -1;
|
||||
|
||||
// Restore timestamp
|
||||
SharedPreferences.Editor editorPreferences = preferences
|
||||
.edit();
|
||||
editorPreferences.putLong("previous_filterTimestamp",
|
||||
old_previous_filterTimestamp);
|
||||
editorPreferences.commit();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG + " EXCEPTION checkNewEvents", e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public String serializeParams2Api(Context context) {
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
context.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
String filterAgentName = preferences.getString("filterAgentName", "");
|
||||
int filterIDGroup = preferences.getInt("filterIDGroup", 0);
|
||||
int filterSeverity = preferences.getInt("filterSeverity", -1);
|
||||
int filterStatus = preferences.getInt("filterStatus", 3);
|
||||
String filterEventSearch = preferences.getString("filterEventSearch", "");
|
||||
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
long now = (c.getTimeInMillis() / 1000);
|
||||
long filterTimestamp = preferences.getLong("filterTimestamp", now);
|
||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||
editorPreferences.putLong("filterTimestamp", now); //Save for the next execution.
|
||||
editorPreferences.putLong("previous_filterTimestamp", filterTimestamp); //Save and the previous for the list.
|
||||
if (editorPreferences.commit()) {
|
||||
Log.e("AlarmReceiver serializeParams2Api", "YES COMMIT");
|
||||
}
|
||||
else {
|
||||
Log.e("AlarmReceiver serializeParams2Api", "NOT COMMIT");
|
||||
}
|
||||
|
||||
|
||||
String return_var = "";
|
||||
|
||||
|
||||
|
||||
return_var += ';'; //Separator for the csv
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(filterSeverity); //Criticity or severity
|
||||
return_var += "|";
|
||||
return_var += filterAgentName; //The agent name
|
||||
return_var += "|";
|
||||
return_var += ""; //Name of module
|
||||
return_var += "|";
|
||||
return_var += ""; //Name of alert template
|
||||
return_var += "|";
|
||||
return_var += ""; //Id user
|
||||
return_var += "|";
|
||||
return_var += Long.toString(filterTimestamp); //The minimun timestamp
|
||||
return_var += "|";
|
||||
return_var += ""; //The maximum timestamp
|
||||
return_var += "|";
|
||||
return_var += filterStatus; //The status
|
||||
return_var += "|";
|
||||
return_var += filterEventSearch; //The free search in the text event description.
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(0); //The pagination of list events
|
||||
return_var += "|";
|
||||
return_var += Long.toString(0); //The offset of list events
|
||||
|
||||
Log.e("AlarmReceiver serializeParams2Api", return_var);
|
||||
|
||||
return return_var;
|
||||
}
|
||||
|
||||
private static final int NOTIFICATION_PANDROID_EVENT_VIEWER = 666;
|
||||
public void notificationEvent(Context context) {
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);
|
||||
|
||||
|
||||
|
||||
mNotificationManager.cancel(NOTIFICATION_PANDROID_EVENT_VIEWER);
|
||||
|
||||
|
||||
int icon;
|
||||
CharSequence tickerText;
|
||||
|
||||
switch (this.more_criticity) {
|
||||
case 0:
|
||||
icon = R.drawable.criticity_0;
|
||||
tickerText = context.getString(R.string.notification_criticity_0_str)
|
||||
.replace("%s", new Long(this.count_events).toString());
|
||||
break;
|
||||
case 1:
|
||||
icon = R.drawable.criticity_1;
|
||||
tickerText = context.getString(R.string.notification_criticity_1_str)
|
||||
.replace("%s", new Long(this.count_events).toString());
|
||||
break;
|
||||
case 2:
|
||||
icon = R.drawable.criticity_2;
|
||||
tickerText = context.getString(R.string.notification_criticity_2_str)
|
||||
.replace("%s", new Long(this.count_events).toString());
|
||||
break;
|
||||
case 3:
|
||||
icon = R.drawable.criticity_3;
|
||||
tickerText = context.getString(R.string.notification_criticity_3_str)
|
||||
.replace("%s", new Long(this.count_events).toString());
|
||||
break;
|
||||
case 4:
|
||||
icon = R.drawable.criticity_4;
|
||||
tickerText = context.getString(R.string.notification_criticity_4_str)
|
||||
.replace("%s", new Long(this.count_events).toString());
|
||||
break;
|
||||
default:
|
||||
icon = R.drawable.criticity_default;
|
||||
tickerText = context.getString(R.string.notification_criticity_2_str)
|
||||
.replace("%s", new Long(this.count_events).toString());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
long when = System.currentTimeMillis();
|
||||
/**
|
||||
* Builds an api call from all filter parameters
|
||||
*
|
||||
* @param context
|
||||
* @return Api call.
|
||||
*/
|
||||
public String serializeParams2Api(Context context) {
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
context.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
Notification notification = new Notification(icon, tickerText, when);
|
||||
|
||||
|
||||
notification.defaults |= Notification.DEFAULT_ALL;
|
||||
|
||||
|
||||
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
|
||||
|
||||
Intent notificationIntent = new Intent(context, PandroidEventviewerActivity.class);
|
||||
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
notificationIntent.putExtra("count_events", this.count_events);
|
||||
notificationIntent.putExtra("more_criticity", this.more_criticity);
|
||||
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
|
||||
|
||||
CharSequence title = context.getString(R.string.pandroid_event_viewer_str);
|
||||
String filterAgentName = preferences.getString("filterAgentName", "");
|
||||
// TODO no api parameter, waiting for it
|
||||
// int filterIDGroup = preferences.getInt("filterIDGroup", 0);
|
||||
int filterSeverity = preferences.getInt("filterSeverity", -1);
|
||||
int filterStatus = preferences.getInt("filterStatus", 3);
|
||||
String filterEventSearch = preferences.getString("filterEventSearch",
|
||||
"");
|
||||
|
||||
notification.setLatestEventInfo(context, title, tickerText, contentIntent);
|
||||
|
||||
|
||||
|
||||
|
||||
mNotificationManager.notify(NOTIFICATION_PANDROID_EVENT_VIEWER, notification);
|
||||
}
|
||||
Calendar c = Calendar.getInstance();
|
||||
long now = (c.getTimeInMillis() / 1000);
|
||||
long filterTimestamp = preferences.getLong("filterTimestamp", now);
|
||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||
// Save for the next execution
|
||||
editorPreferences.putLong("filterTimestamp", now);
|
||||
// Save the previous for the list.
|
||||
editorPreferences.putLong("previous_filterTimestamp", filterTimestamp);
|
||||
if (editorPreferences.commit()) {
|
||||
Log.i(TAG + " (filter options)",
|
||||
"Configuration changes commited (timestamp)");
|
||||
} else {
|
||||
Log.e(TAG + " (filter options)",
|
||||
"Configuration changes not commited");
|
||||
}
|
||||
|
||||
String return_var = "";
|
||||
|
||||
return_var += ';'; // Separator for the csv
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(filterSeverity); // Criticity or severity
|
||||
return_var += "|";
|
||||
return_var += filterAgentName; // The agent name
|
||||
return_var += "|";
|
||||
return_var += ""; // Name of module
|
||||
return_var += "|";
|
||||
return_var += ""; // Name of alert template
|
||||
return_var += "|";
|
||||
return_var += ""; // Id user
|
||||
return_var += "|";
|
||||
return_var += Long.toString(filterTimestamp); // The minimun timestamp
|
||||
return_var += "|";
|
||||
return_var += ""; // The maximum timestamp
|
||||
return_var += "|";
|
||||
return_var += filterStatus; // The status
|
||||
return_var += "|";
|
||||
return_var += filterEventSearch; // The free search in the text event
|
||||
// description.
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(0); // The pagination of list events
|
||||
return_var += "|";
|
||||
return_var += Long.toString(0); // The offset of list events
|
||||
|
||||
Log.i(TAG + " serializeParams2Api", return_var);
|
||||
|
||||
return return_var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Launchs a notification
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public void notificationEvent(Context context) {
|
||||
String ns = Context.NOTIFICATION_SERVICE;
|
||||
NotificationManager mNotificationManager = (NotificationManager) context
|
||||
.getSystemService(ns);
|
||||
|
||||
mNotificationManager.cancel(NOTIFICATION_PANDROID_EVENT_VIEWER);
|
||||
|
||||
int icon;
|
||||
CharSequence tickerText;
|
||||
|
||||
switch (this.more_criticity) {
|
||||
case 0:
|
||||
icon = R.drawable.criticity_0;
|
||||
tickerText = context.getString(
|
||||
R.string.notification_criticity_0_str).replace("%s",
|
||||
new Long(this.count_events).toString());
|
||||
break;
|
||||
case 1:
|
||||
icon = R.drawable.criticity_1;
|
||||
tickerText = context.getString(
|
||||
R.string.notification_criticity_1_str).replace("%s",
|
||||
new Long(this.count_events).toString());
|
||||
break;
|
||||
case 2:
|
||||
icon = R.drawable.criticity_2;
|
||||
tickerText = context.getString(
|
||||
R.string.notification_criticity_2_str).replace("%s",
|
||||
new Long(this.count_events).toString());
|
||||
break;
|
||||
case 3:
|
||||
icon = R.drawable.criticity_3;
|
||||
tickerText = context.getString(
|
||||
R.string.notification_criticity_3_str).replace("%s",
|
||||
new Long(this.count_events).toString());
|
||||
break;
|
||||
case 4:
|
||||
icon = R.drawable.criticity_4;
|
||||
tickerText = context.getString(
|
||||
R.string.notification_criticity_4_str).replace("%s",
|
||||
new Long(this.count_events).toString());
|
||||
break;
|
||||
default:
|
||||
icon = R.drawable.criticity_default;
|
||||
tickerText = context.getString(
|
||||
R.string.notification_criticity_2_str).replace("%s",
|
||||
new Long(this.count_events).toString());
|
||||
break;
|
||||
}
|
||||
|
||||
long when = System.currentTimeMillis();
|
||||
|
||||
Notification notification = new Notification(icon, tickerText, when);
|
||||
|
||||
// notification.defaults |= Notification.DEFAULT_ALL;
|
||||
|
||||
notification.flags |= Notification.FLAG_AUTO_CANCEL;
|
||||
// Notification options
|
||||
SharedPreferences preferences = context.getSharedPreferences(
|
||||
context.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
if (preferences.getBoolean("vibration", true)) {
|
||||
Log.d(TAG, "Vibration");
|
||||
notification.defaults |= Notification.DEFAULT_VIBRATE;
|
||||
|
||||
} else {
|
||||
Log.d(TAG, "No vibration");
|
||||
notification.vibrate = new long[] { 0, 0, 0, 0 };
|
||||
}
|
||||
if (preferences.getBoolean("led", false)) {
|
||||
Log.d(TAG, "Led flash");
|
||||
notification.defaults |= Notification.DEFAULT_LIGHTS;
|
||||
/*
|
||||
* notification.ledARGB = 0xff00ff00; notification.ledOnMS = 300;
|
||||
* notification.ledOffMS = 1000; notification.flags |=
|
||||
* Notification.FLAG_SHOW_LIGHTS;
|
||||
*/
|
||||
}
|
||||
Uri notificationSoundUri = Uri.parse(preferences.getString(
|
||||
"notification_sound_uri",
|
||||
RingtoneManager
|
||||
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
|
||||
.toString()));
|
||||
if (notificationSoundUri != null) {
|
||||
Log.i(TAG, "Setting sound: " + notificationSoundUri.toString());
|
||||
notification.sound = notificationSoundUri;
|
||||
} else {
|
||||
Log.e(TAG, "Ringtone's uri problem (NULL)");
|
||||
}
|
||||
|
||||
Intent notificationIntent = new Intent(context,
|
||||
PandroidEventviewerActivity.class);
|
||||
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
notificationIntent.putExtra("count_events", this.count_events);
|
||||
notificationIntent.putExtra("more_criticity", this.more_criticity);
|
||||
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
|
||||
notificationIntent, 0);
|
||||
|
||||
CharSequence title = context
|
||||
.getString(R.string.pandroid_event_viewer_str);
|
||||
|
||||
notification.setLatestEventInfo(context, title, tickerText,
|
||||
contentIntent);
|
||||
Log.i(TAG, "Launching notification");
|
||||
mNotificationManager.notify(NOTIFICATION_PANDROID_EVENT_VIEWER,
|
||||
notification);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -10,163 +26,150 @@ import java.util.Calendar;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* This class provides basic functions to manage services and some received
|
||||
* data.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class Core implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7071445033114548174L;
|
||||
|
||||
public Intent intent_service;
|
||||
//public Context context; //Fucking marshall exception
|
||||
|
||||
|
||||
public Core() {
|
||||
intent_service = null;
|
||||
//context = null; //Fucking marshall exception
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Starts PandroidEventviewerService.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public void startServiceEventWatcher(Context context) {
|
||||
if (intent_service == null) {
|
||||
|
||||
intent_service = new Intent(context, PandroidEventviewerService.class);
|
||||
//this.context = context; //Fucking marshall exception
|
||||
|
||||
intent_service = new Intent(context,
|
||||
PandroidEventviewerService.class);
|
||||
}
|
||||
|
||||
|
||||
context.startService(intent_service);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Stops PandroidEventviewerService.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public void stopServiceEventWatcher(Context context) {
|
||||
if (intent_service == null) {
|
||||
|
||||
intent_service = new Intent(context, PandroidEventviewerService.class);
|
||||
//this.context = context; //Fucking marshall exception
|
||||
|
||||
intent_service = new Intent(context,
|
||||
PandroidEventviewerService.class);
|
||||
}
|
||||
|
||||
|
||||
context.stopService(this.intent_service);
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
/*
|
||||
public Core(Parcel in) {
|
||||
intent_service = (Intent)in.readValue(null);
|
||||
//context = (Context)in.readValue(null); //Fucking marshall exception
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<Core> CREATOR
|
||||
= new Parcelable.Creator<Core>() {
|
||||
|
||||
@Override
|
||||
public Core createFromParcel(Parcel source) {
|
||||
// TODO Auto-generated method stub
|
||||
return new Core(source);
|
||||
/**
|
||||
* Reads from the input stream and returns a string.
|
||||
*
|
||||
* @param is
|
||||
* @return A string with all data read.
|
||||
*/
|
||||
public static String convertStreamToString(InputStream is) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is),
|
||||
8 * 1024);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Core[] newArray(int size) {
|
||||
// TODO Auto-generated method stub
|
||||
return new Core[size];
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
// TODO Auto-generated method stub
|
||||
dest.writeValue(this.intent_service);
|
||||
//dest.writeValue(this.context); //Fucking marshall exception
|
||||
}
|
||||
*/
|
||||
///////////
|
||||
|
||||
|
||||
public static String convertStreamToString (InputStream is)
|
||||
{
|
||||
BufferedReader reader = new BufferedReader(new
|
||||
InputStreamReader(is), 8*1024);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public long convertMaxTimeOldEventValuesToTimestamp(long timestamp, int arrayKey) {
|
||||
long time = timestamp;
|
||||
/**
|
||||
* Converts the maximum time setted to filter events to a timestamp.
|
||||
*
|
||||
* @param timestamp
|
||||
* @param arrayKey
|
||||
* @return Time in milliseconds.
|
||||
*/
|
||||
public long convertMaxTimeOldEventValuesToTimestamp(long time, int arrayKey) {
|
||||
long return_var = 0;
|
||||
|
||||
|
||||
if (time == 0) {
|
||||
Calendar c = Calendar.getInstance();
|
||||
time = c.getTimeInMillis() / 1000;
|
||||
}
|
||||
|
||||
|
||||
switch (arrayKey) {
|
||||
case 0:
|
||||
return_var = time - 30 * 60;
|
||||
break;
|
||||
case 1:
|
||||
return_var = time - 60 * 60;
|
||||
break;
|
||||
case 2:
|
||||
return_var = time - 2 * (60 * 60);
|
||||
break;
|
||||
case 3:
|
||||
return_var = time - 3 * (60 * 60);
|
||||
break;
|
||||
case 4:
|
||||
return_var = time - 4 * (60 * 60);
|
||||
break;
|
||||
case 5:
|
||||
return_var = time - 5 * (60 * 60);
|
||||
break;
|
||||
case 6:
|
||||
return_var = time - 8 * (60 * 60);
|
||||
break;
|
||||
case 7:
|
||||
return_var = time - 10 * (60 * 60);
|
||||
break;
|
||||
case 8:
|
||||
return_var = time - 12 * (60 * 60);
|
||||
break;
|
||||
case 9:
|
||||
return_var = time - 24 * (60 * 60);
|
||||
break;
|
||||
case 10:
|
||||
return_var = time - 2 * (24 * 60 * 60);
|
||||
break;
|
||||
case 11:
|
||||
return_var = time - 3 * (24 * 60 * 60);
|
||||
break;
|
||||
case 12:
|
||||
return_var = time - 4 * (24 * 60 * 60);
|
||||
break;
|
||||
case 13:
|
||||
return_var = time - 5 * (24 * 60 * 60);
|
||||
break;
|
||||
case 14:
|
||||
return_var = time - 7 * (24 * 60 * 60);
|
||||
break;
|
||||
case 15:
|
||||
return_var = time - 2 * (7 * 24 * 60 * 60);
|
||||
break;
|
||||
case 16:
|
||||
return_var = time - 30 * (24 * 60 * 60);
|
||||
break;
|
||||
case 0:
|
||||
return_var = time - 30 * 60;
|
||||
break;
|
||||
case 1:
|
||||
return_var = time - 60 * 60;
|
||||
break;
|
||||
case 2:
|
||||
return_var = time - 2 * (60 * 60);
|
||||
break;
|
||||
case 3:
|
||||
return_var = time - 3 * (60 * 60);
|
||||
break;
|
||||
case 4:
|
||||
return_var = time - 4 * (60 * 60);
|
||||
break;
|
||||
case 5:
|
||||
return_var = time - 5 * (60 * 60);
|
||||
break;
|
||||
case 6:
|
||||
return_var = time - 8 * (60 * 60);
|
||||
break;
|
||||
case 7:
|
||||
return_var = time - 10 * (60 * 60);
|
||||
break;
|
||||
case 8:
|
||||
return_var = time - 12 * (60 * 60);
|
||||
break;
|
||||
case 9:
|
||||
return_var = time - 24 * (60 * 60);
|
||||
break;
|
||||
case 10:
|
||||
return_var = time - 2 * (24 * 60 * 60);
|
||||
break;
|
||||
case 11:
|
||||
return_var = time - 3 * (24 * 60 * 60);
|
||||
break;
|
||||
case 12:
|
||||
return_var = time - 4 * (24 * 60 * 60);
|
||||
break;
|
||||
case 13:
|
||||
return_var = time - 5 * (24 * 60 * 60);
|
||||
break;
|
||||
case 14:
|
||||
return_var = time - 7 * (24 * 60 * 60);
|
||||
break;
|
||||
case 15:
|
||||
return_var = time - 2 * (7 * 24 * 60 * 60);
|
||||
break;
|
||||
case 16:
|
||||
return_var = time - 30 * (24 * 60 * 60);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return return_var;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,27 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
/**
|
||||
* This class represents an event.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class EventListItem {
|
||||
public int id_event;
|
||||
public int id_agent;
|
||||
|
@ -22,9 +44,9 @@ public class EventListItem {
|
|||
public String description_image;
|
||||
public String criticity_name;
|
||||
public String criticity_image;
|
||||
|
||||
|
||||
public boolean opened;
|
||||
|
||||
|
||||
public EventListItem() {
|
||||
id_event = 0;
|
||||
id_agent = 0;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -6,15 +22,21 @@ import android.text.Html;
|
|||
import android.text.method.LinkMovementMethod;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* This class contains basic instructions to describe the Information popup.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class Info extends Activity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.about);
|
||||
|
||||
TextView text = (TextView) findViewById(R.id.url_pandora);
|
||||
text.setText(Html.fromHtml("<a href='http://pandorafms.org/'>PandoraFMS.org</a>"));
|
||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.about);
|
||||
|
||||
TextView text = (TextView) findViewById(R.id.url_pandora);
|
||||
text.setText(Html
|
||||
.fromHtml("<a href='http://pandorafms.org/'>PandoraFMS.org</a>"));
|
||||
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -5,6 +21,7 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
|
@ -32,394 +49,395 @@ import android.widget.ProgressBar;
|
|||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Activity with the filter options.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class Main extends Activity {
|
||||
public PandroidEventviewerActivity object;
|
||||
public HashMap<Integer, String> pandoraGroups;
|
||||
public Spinner comboSeverity;
|
||||
public Core core;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
private static String TAG = "MAIN";
|
||||
private PandroidEventviewerActivity object;
|
||||
private HashMap<Integer, String> pandoraGroups;
|
||||
private Spinner comboSeverity;
|
||||
private Core core;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
Intent i = getIntent();
|
||||
this.object = (PandroidEventviewerActivity)i.getSerializableExtra("object");
|
||||
this.core = (Core)i.getSerializableExtra("core");
|
||||
|
||||
this.object = (PandroidEventviewerActivity) i
|
||||
.getSerializableExtra("object");
|
||||
this.core = (Core) i.getSerializableExtra("core");
|
||||
|
||||
this.pandoraGroups = new HashMap<Integer, String>();
|
||||
|
||||
|
||||
setContentView(R.layout.main);
|
||||
|
||||
|
||||
final Button buttonReset = (Button) findViewById(R.id.button_reset);
|
||||
final Button buttonSearch = (Button) findViewById(R.id.button_send);
|
||||
final Button buttonbuttonSetAsFilterWatcher = (Button) findViewById(R.id.button_set_as_filter_watcher);
|
||||
|
||||
//Check if the user preferences it is set.
|
||||
if (object.user.length() == 0 || object.password.length() == 0 ||
|
||||
object.url.length() == 0) {
|
||||
|
||||
// Check if the user preferences it is set.
|
||||
if (object.user.length() == 0 || object.password.length() == 0
|
||||
|| object.url.length() == 0) {
|
||||
Toast toast = Toast.makeText(this.getApplicationContext(),
|
||||
this.getString(R.string.please_set_preferences_str),
|
||||
Toast.LENGTH_SHORT);
|
||||
this.getString(R.string.please_set_preferences_str),
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
|
||||
|
||||
buttonReset.setEnabled(false);
|
||||
buttonSearch.setEnabled(false);
|
||||
buttonbuttonSetAsFilterWatcher.setEnabled(false);
|
||||
}
|
||||
else if (object.user.equals("demo") || object.password.equals("demo")) {
|
||||
} else if (object.user.equals("demo") || object.password.equals("demo")) {
|
||||
Toast toast = Toast.makeText(this.getApplicationContext(),
|
||||
this.getString(R.string.preferences_set_demo_pandora_str),
|
||||
Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
else {
|
||||
toast.show();
|
||||
} else {
|
||||
buttonSearch.setEnabled(false);
|
||||
buttonReset.setEnabled(false);
|
||||
buttonbuttonSetAsFilterWatcher.setEnabled(false);
|
||||
|
||||
|
||||
new GetGroupsAsyncTask().execute();
|
||||
}
|
||||
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
|
||||
comboSeverity = (Spinner) findViewById(R.id.severity_combo);
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
|
||||
this, R.array.severity_array_values, android.R.layout.simple_spinner_item);
|
||||
this, R.array.severity_array_values,
|
||||
android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
comboSeverity.setAdapter(adapter);
|
||||
|
||||
|
||||
|
||||
Spinner combo;
|
||||
combo = (Spinner) findViewById(R.id.status_combo);
|
||||
adapter = ArrayAdapter.createFromResource(
|
||||
this, R.array.event_status_values, android.R.layout.simple_spinner_item);
|
||||
adapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.event_status_values,
|
||||
android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
combo.setAdapter(adapter);
|
||||
combo.setSelection(3);
|
||||
|
||||
|
||||
combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
|
||||
adapter = ArrayAdapter.createFromResource(
|
||||
this, R.array.max_time_old_event_values, android.R.layout.simple_spinner_item);
|
||||
adapter = ArrayAdapter.createFromResource(this,
|
||||
R.array.max_time_old_event_values,
|
||||
android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
combo.setAdapter(adapter);
|
||||
combo.setSelection(preferences.getInt("filterLastTime", 6));
|
||||
|
||||
|
||||
|
||||
buttonReset.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
reset_form();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
buttonSearch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
search_form();
|
||||
}
|
||||
});
|
||||
|
||||
buttonbuttonSetAsFilterWatcher.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
save_filter_watcher();
|
||||
}
|
||||
});
|
||||
|
||||
if (this.object.show_popup_info) {
|
||||
this.object.show_popup_info = false;
|
||||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
buttonbuttonSetAsFilterWatcher
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
save_filter_watcher();
|
||||
}
|
||||
});
|
||||
|
||||
if (this.object.show_popup_info) {
|
||||
this.object.show_popup_info = false;
|
||||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onRestart() {
|
||||
super.onRestart();
|
||||
|
||||
|
||||
if (this.pandoraGroups.size() == 0) {
|
||||
Log.e("Main onRestart", "Main onRestart");
|
||||
Log.i(TAG, "onRestart: getting groups");
|
||||
new GetGroupsAsyncTask().execute();
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getGroups() {
|
||||
|
||||
/**
|
||||
* Get groups throught an api call.
|
||||
*
|
||||
* @return A list of groups.
|
||||
*/
|
||||
private List<String> getGroups() {
|
||||
ArrayList<String> array = new ArrayList<String>();
|
||||
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
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", "groups"));
|
||||
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("other_mode",
|
||||
"url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other", ";"));
|
||||
|
||||
|
||||
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 return_api = Core.convertStreamToString(entityResponse
|
||||
.getContent());
|
||||
|
||||
String[] lines = return_api.split("\n");
|
||||
|
||||
for (int i= 0; i < lines.length; i++) {
|
||||
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String[] groups = lines[i].split(";", 21);
|
||||
|
||||
|
||||
this.pandoraGroups.put(new Integer(groups[0]), groups[1]);
|
||||
|
||||
|
||||
array.add(groups[1]);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG +": getting groups", e.getMessage());
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e("EXCEPTION ArrayList", e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public class GetGroupsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
public ArrayList<String> lista;
|
||||
|
||||
|
||||
/**
|
||||
* Async task which get groups.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
private class GetGroupsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
private List<String> list;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
lista = getGroups();
|
||||
|
||||
list = getGroups();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void unused)
|
||||
{
|
||||
Spinner combo = (Spinner)findViewById(R.id.group_combo);
|
||||
|
||||
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(getApplicationContext(),
|
||||
android.R.layout.simple_spinner_item,
|
||||
lista);
|
||||
protected void onPostExecute(Void unused) {
|
||||
Spinner combo = (Spinner) findViewById(R.id.group_combo);
|
||||
|
||||
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_group);
|
||||
|
||||
|
||||
loadingGroup.setVisibility(ProgressBar.GONE);
|
||||
combo.setVisibility(Spinner.VISIBLE);
|
||||
|
||||
|
||||
Button buttonReset = (Button) findViewById(R.id.button_reset);
|
||||
Button buttonSearch = (Button) findViewById(R.id.button_send);
|
||||
Button buttonbuttonSetAsFilterWatcher = (Button) findViewById(R.id.button_set_as_filter_watcher);
|
||||
|
||||
|
||||
buttonReset.setEnabled(true);
|
||||
buttonSearch.setEnabled(true);
|
||||
buttonbuttonSetAsFilterWatcher.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
//For options
|
||||
|
||||
// For options
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.options_menu, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
Intent i;
|
||||
switch (item.getItemId()) {
|
||||
case R.id.options_button_menu_options:
|
||||
i = new Intent(this, Options.class);
|
||||
//i.putExtra("object", object);
|
||||
i.putExtra("core", new Core());
|
||||
|
||||
startActivity(i);
|
||||
break;
|
||||
case R.id.about_button_menu_options:
|
||||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
case R.id.options_button_menu_options:
|
||||
i = new Intent(this, Options.class);
|
||||
i.putExtra("core", new Core());
|
||||
|
||||
startActivity(i);
|
||||
break;
|
||||
case R.id.about_button_menu_options:
|
||||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void search_form() {
|
||||
//Clean the EventList
|
||||
|
||||
/**
|
||||
* Performs the search choice
|
||||
*/
|
||||
private void search_form() {
|
||||
// Clean the EventList
|
||||
this.object.eventList = new ArrayList<EventListItem>();
|
||||
|
||||
|
||||
this.object.loadInProgress = true;
|
||||
|
||||
//Get form data
|
||||
/*
|
||||
DatePicker datePicker = (DatePicker)findViewById(R.id.date);
|
||||
TimePicker timePicker = (TimePicker)findViewById(R.id.time);
|
||||
int day = datePicker.getDayOfMonth();
|
||||
int month = datePicker.getMonth();
|
||||
int year = datePicker.getYear();
|
||||
int hour = timePicker.getCurrentHour();
|
||||
int minute = timePicker.getCurrentMinute();
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(year, month, day, hour, minute);
|
||||
|
||||
this.object.timestamp = c.getTimeInMillis() / 1000;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int timeKey = 0;
|
||||
Spinner combo = (Spinner)findViewById(R.id.max_time_old_event_combo);
|
||||
Spinner combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
|
||||
timeKey = combo.getSelectedItemPosition();
|
||||
|
||||
this.object.timestamp = this.core.convertMaxTimeOldEventValuesToTimestamp(0, timeKey);
|
||||
|
||||
|
||||
this.object.timestamp = this.core
|
||||
.convertMaxTimeOldEventValuesToTimestamp(0, timeKey);
|
||||
|
||||
EditText text = (EditText) findViewById(R.id.agent_name);
|
||||
this.object.agentNameStr = text.getText().toString();
|
||||
|
||||
|
||||
this.object.id_group = 0;
|
||||
|
||||
|
||||
combo = (Spinner) findViewById(R.id.group_combo);
|
||||
String selectedGroup = combo.getSelectedItem().toString();
|
||||
|
||||
Iterator it = pandoraGroups.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Integer, String> e = (Map.Entry<Integer, String>)it.next();
|
||||
|
||||
if (e.getValue().equals(selectedGroup)) {
|
||||
this.object.id_group = e.getKey();
|
||||
if (combo.getSelectedItem() != null) {
|
||||
String selectedGroup = combo.getSelectedItem().toString();
|
||||
|
||||
Iterator<Entry<Integer, String>> it = pandoraGroups.entrySet()
|
||||
.iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Integer, String> e = (Map.Entry<Integer, String>) it
|
||||
.next();
|
||||
|
||||
if (e.getValue().equals(selectedGroup)) {
|
||||
this.object.id_group = e.getKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
combo = (Spinner) findViewById(R.id.severity_combo);
|
||||
this.object.severity = combo.getSelectedItemPosition() - 1;
|
||||
|
||||
combo = (Spinner)findViewById(R.id.status_combo);
|
||||
Log.e("Main search_form", "status_combo = " + combo.getSelectedItemPosition());
|
||||
//this.object.status = combo.getSelectedItemPosition() - 1;//The next version re-add please
|
||||
|
||||
combo = (Spinner) findViewById(R.id.status_combo);
|
||||
this.object.status = combo.getSelectedItemPosition() - 0;
|
||||
|
||||
text = (EditText)findViewById(R.id.event_search_text);
|
||||
|
||||
text = (EditText) findViewById(R.id.event_search_text);
|
||||
this.object.eventSearch = text.getText().toString();
|
||||
|
||||
|
||||
this.object.getNewListEvents = true;
|
||||
this.object.executeBackgroundGetEvents();
|
||||
|
||||
|
||||
TabActivity ta = (TabActivity) this.getParent();
|
||||
ta.getTabHost().setCurrentTab(1);
|
||||
}
|
||||
|
||||
public void save_filter_watcher() {
|
||||
|
||||
/**
|
||||
* Saves filter data
|
||||
*/
|
||||
private void save_filter_watcher() {
|
||||
String filterAgentName = "";
|
||||
int filterIDGroup = 0;
|
||||
int filterSeverity = -1;
|
||||
int filterStatus = -1;
|
||||
int filterLastTime = 0;
|
||||
String filterEventSearch = "";
|
||||
|
||||
|
||||
|
||||
EditText text = (EditText) findViewById(R.id.agent_name);
|
||||
filterAgentName = text.getText().toString();
|
||||
|
||||
|
||||
Spinner combo;
|
||||
combo = (Spinner) findViewById(R.id.group_combo);
|
||||
if ((combo != null) && (combo.getSelectedItem() != null)) {
|
||||
String selectedGroup = combo.getSelectedItem().toString();
|
||||
|
||||
Iterator it = pandoraGroups.entrySet().iterator();
|
||||
|
||||
Iterator<Entry<Integer, String>> it = pandoraGroups.entrySet()
|
||||
.iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Integer, String> e = (Map.Entry<Integer, String>)it.next();
|
||||
|
||||
Map.Entry<Integer, String> e = it.next();
|
||||
|
||||
if (e.getValue().equals(selectedGroup)) {
|
||||
filterIDGroup = e.getKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
combo = (Spinner) findViewById(R.id.severity_combo);
|
||||
filterSeverity = combo.getSelectedItemPosition() - 1;
|
||||
|
||||
combo = (Spinner)findViewById(R.id.status_combo);
|
||||
//filterStatus = combo.getSelectedItemPosition() - 1;//The next version re-add please
|
||||
|
||||
combo = (Spinner) findViewById(R.id.status_combo);
|
||||
filterStatus = combo.getSelectedItemPosition() - 0;
|
||||
|
||||
combo = (Spinner)findViewById(R.id.max_time_old_event_combo);
|
||||
|
||||
combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
|
||||
filterLastTime = combo.getSelectedItemPosition();
|
||||
|
||||
text = (EditText)findViewById(R.id.event_search_text);
|
||||
|
||||
text = (EditText) findViewById(R.id.event_search_text);
|
||||
filterEventSearch = text.getText().toString();
|
||||
|
||||
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||
|
||||
|
||||
editorPreferences.putString("filterAgentName", filterAgentName);
|
||||
editorPreferences.putInt("filterIDGroup", filterIDGroup);
|
||||
editorPreferences.putInt("filterSeverity", filterSeverity);
|
||||
editorPreferences.putInt("filterStatus", filterStatus);
|
||||
editorPreferences.putString("filterEventSearch", filterEventSearch);
|
||||
editorPreferences.putInt("filterLastTime", filterLastTime);
|
||||
|
||||
|
||||
if (editorPreferences.commit()) {
|
||||
this.core.stopServiceEventWatcher(getApplicationContext());
|
||||
this.core.startServiceEventWatcher(getApplicationContext());
|
||||
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
this.getString(R.string.filter_update_succesful_str), Toast.LENGTH_SHORT);
|
||||
this.getString(R.string.filter_update_succesful_str),
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
this.getString(R.string.filter_update_fail_str), Toast.LENGTH_SHORT);
|
||||
this.getString(R.string.filter_update_fail_str),
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void reset_form() {
|
||||
EditText text = (EditText)findViewById(R.id.agent_name);
|
||||
|
||||
/**
|
||||
* Resets the filter form.
|
||||
*/
|
||||
private void reset_form() {
|
||||
EditText text = (EditText) findViewById(R.id.agent_name);
|
||||
text.setText("");
|
||||
|
||||
|
||||
Spinner combo = (Spinner) findViewById(R.id.group_combo);
|
||||
combo.setSelection(0);
|
||||
|
||||
|
||||
combo = (Spinner) findViewById(R.id.severity_combo);
|
||||
combo.setSelection(0);
|
||||
|
||||
combo = (Spinner)findViewById(R.id.max_time_old_event_combo);
|
||||
|
||||
combo = (Spinner) findViewById(R.id.max_time_old_event_combo);
|
||||
combo.setSelection(6);
|
||||
|
||||
combo = (Spinner) findViewById(R.id.status_combo);
|
||||
combo.setSelection(3);
|
||||
|
||||
combo = (Spinner)findViewById(R.id.status_combo);
|
||||
combo.setSelection(4);
|
||||
|
||||
text = (EditText)findViewById(R.id.event_search_text);
|
||||
text = (EditText) findViewById(R.id.event_search_text);
|
||||
text.setText("");
|
||||
|
||||
/*
|
||||
Calendar c = Calendar.getInstance();
|
||||
DatePicker datePicker = (DatePicker)findViewById(R.id.date);
|
||||
datePicker.updateDate(c.get(Calendar.YEAR),
|
||||
c.get(Calendar.MONTH),
|
||||
c.get(Calendar.DAY_OF_MONTH));
|
||||
|
||||
TimePicker timePicker = (TimePicker)findViewById(R.id.time);
|
||||
timePicker.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
|
||||
timePicker.setCurrentMinute(c.get(Calendar.MINUTE));
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,116 +1,282 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Options activity.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class Options extends Activity {
|
||||
public String url;
|
||||
public String user;
|
||||
public String password;
|
||||
public int refreshTimeKey;
|
||||
|
||||
public Core core;
|
||||
public PandroidEventviewerActivity object;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent i = getIntent();
|
||||
this.core = (Core)i.getSerializableExtra("core");
|
||||
//this.object = (PandroidEventviewerActivity)i.getSerializableExtra("object");
|
||||
//this.core = this.object.core;
|
||||
|
||||
|
||||
|
||||
setContentView(R.layout.options);
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
url = preferences.getString("url", "http://firefly.artica.es/pandora_demo");
|
||||
user = preferences.getString("user", "demo");
|
||||
password = preferences.getString("password", "demo");
|
||||
refreshTimeKey = preferences.getInt("refreshTimeKey", 3);
|
||||
|
||||
EditText text = (EditText) findViewById(R.id.url);
|
||||
text.setText(url);
|
||||
text = (EditText) findViewById(R.id.user);
|
||||
text.setText(user);
|
||||
text = (EditText) findViewById(R.id.password);
|
||||
text.setText(password);
|
||||
|
||||
Spinner combo = (Spinner) findViewById(R.id.refresh_combo);
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
|
||||
this, R.array.refresh_combo, android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
combo.setAdapter(adapter);
|
||||
combo.setSelection(refreshTimeKey);
|
||||
|
||||
final Button buttonSearch = (Button) findViewById(R.id.update_options);
|
||||
buttonSearch.setOnClickListener(new View.OnClickListener() {
|
||||
private static String TAG = "Options";
|
||||
private static int RINGTONE_PICK_CODE = 999;
|
||||
private String url;
|
||||
private String user;
|
||||
private String password;
|
||||
private int refreshTimeKey;
|
||||
private TextView connectionStatus;
|
||||
|
||||
private Core core;
|
||||
private PandroidEventviewerActivity object;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent i = getIntent();
|
||||
this.core = (Core) i.getSerializableExtra("core");
|
||||
|
||||
setContentView(R.layout.options);
|
||||
connectionStatus = (TextView) findViewById(R.id.check_connection_status);
|
||||
new CheckConnectionAsyncTask().execute();
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
// Connection
|
||||
url = preferences.getString("url",
|
||||
"http://firefly.artica.es/pandora_demo");
|
||||
user = preferences.getString("user", "demo");
|
||||
password = preferences.getString("password", "demo");
|
||||
refreshTimeKey = preferences.getInt("refreshTimeKey", 3);
|
||||
|
||||
EditText text = (EditText) findViewById(R.id.url);
|
||||
text.setText(url);
|
||||
text = (EditText) findViewById(R.id.user);
|
||||
text.setText(user);
|
||||
text = (EditText) findViewById(R.id.password);
|
||||
text.setText(password);
|
||||
|
||||
Spinner combo = (Spinner) findViewById(R.id.refresh_combo);
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
|
||||
this, R.array.refresh_combo,
|
||||
android.R.layout.simple_spinner_item);
|
||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
combo.setAdapter(adapter);
|
||||
combo.setSelection(refreshTimeKey);
|
||||
|
||||
final Button buttonSearch = (Button) findViewById(R.id.update_options);
|
||||
buttonSearch.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
save_options();
|
||||
new CheckConnectionAsyncTask().execute();
|
||||
}
|
||||
});
|
||||
|
||||
if (this.object.show_popup_info) {
|
||||
this.object.show_popup_info = false;
|
||||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
String url = text.getText().toString();
|
||||
if (url.charAt(url.length() - 1) == '/') {
|
||||
url = url.substring(0, url.length() - 1);
|
||||
}
|
||||
|
||||
editorPreferences.putString("url", url);
|
||||
//this.object.url = url;
|
||||
text = (EditText) findViewById(R.id.user);
|
||||
editorPreferences.putString("user", text.getText().toString());
|
||||
//this.object.user = text.getText().toString();
|
||||
text = (EditText) findViewById(R.id.password);
|
||||
editorPreferences.putString("password", text.getText().toString());
|
||||
//this.object.password = text.getText().toString();
|
||||
|
||||
Spinner combo = (Spinner) findViewById(R.id.refresh_combo);
|
||||
editorPreferences.putInt("refreshTimeKey", combo.getSelectedItemPosition());
|
||||
|
||||
Context context = this.getApplicationContext();
|
||||
int duration = Toast.LENGTH_SHORT;
|
||||
|
||||
if (editorPreferences.commit()) {
|
||||
if (this.core != null) {
|
||||
this.core.stopServiceEventWatcher(getApplicationContext());
|
||||
this.core.startServiceEventWatcher(getApplicationContext());
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object != null && this.object.show_popup_info) {
|
||||
this.object.show_popup_info = false;
|
||||
i = new Intent(this, About.class);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
// Notification
|
||||
boolean vibration = preferences.getBoolean("vibration", true);
|
||||
CheckBox cb = (CheckBox) findViewById(R.id.vibration_on);
|
||||
cb.setChecked(vibration);
|
||||
boolean led = preferences.getBoolean("led", false);
|
||||
cb = (CheckBox) findViewById(R.id.led_flash_on);
|
||||
cb.setChecked(led);
|
||||
|
||||
Button notificationSound = (Button) findViewById(R.id.sound_button);
|
||||
Uri defaultSoundUri = Uri.parse(preferences.getString(
|
||||
"notification_sound_uri",
|
||||
RingtoneManager
|
||||
.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
|
||||
.toString()));
|
||||
this.setNewRingtone(notificationSound, defaultSoundUri);
|
||||
|
||||
notificationSound.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.i(TAG, "Selecting ringtone");
|
||||
Intent intent = new Intent(
|
||||
RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE,
|
||||
getString(R.string.select_sound));
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT,
|
||||
false);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT,
|
||||
true);
|
||||
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
|
||||
RingtoneManager.TYPE_NOTIFICATION);
|
||||
startActivityForResult(intent, RINGTONE_PICK_CODE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Gets sound selected
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == RINGTONE_PICK_CODE) {
|
||||
if (data != null) {
|
||||
Uri uri = data
|
||||
.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
this.setNewRingtone(((Button) findViewById(R.id.sound_button)),
|
||||
uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all options
|
||||
*/
|
||||
private void save_options() {
|
||||
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();
|
||||
if (url.charAt(url.length() - 1) == '/') {
|
||||
url = url.substring(0, url.length() - 1);
|
||||
}
|
||||
|
||||
editorPreferences.putString("url", url);
|
||||
text = (EditText) findViewById(R.id.user);
|
||||
editorPreferences.putString("user", text.getText().toString());
|
||||
text = (EditText) findViewById(R.id.password);
|
||||
editorPreferences.putString("password", text.getText().toString());
|
||||
|
||||
Spinner combo = (Spinner) findViewById(R.id.refresh_combo);
|
||||
editorPreferences.putInt("refreshTimeKey",
|
||||
combo.getSelectedItemPosition());
|
||||
|
||||
// Notification settings
|
||||
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());
|
||||
|
||||
Context context = this.getApplicationContext();
|
||||
|
||||
if (editorPreferences.commit()) {
|
||||
if (this.core != null) {
|
||||
this.core.stopServiceEventWatcher(getApplicationContext());
|
||||
this.core.startServiceEventWatcher(getApplicationContext());
|
||||
}
|
||||
Log.i(TAG, "Settings saved");
|
||||
Toast toast = Toast.makeText(context,
|
||||
this.getString(R.string.config_update_succesful_str),
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
} else {
|
||||
Toast toast = Toast.makeText(context,
|
||||
this.getString(R.string.config_update_fail_str),
|
||||
Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets ringtone's title (shortens it if necessary) on the button and
|
||||
* changes ringtone's uri in options. If there is a problem with the given
|
||||
* Uri, just put "Silence".
|
||||
*
|
||||
* @param button
|
||||
* Target button.
|
||||
* @param uri
|
||||
* Ringtone's uri.
|
||||
*/
|
||||
private void setNewRingtone(Button button, Uri uri) {
|
||||
if (uri != null) {
|
||||
Log.i(TAG, "New ringtone selected: " + uri.toString());
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editorPreferences = preferences.edit();
|
||||
editorPreferences.putString("notification_sound_uri",
|
||||
uri.toString());
|
||||
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(),
|
||||
uri);
|
||||
if (editorPreferences.commit()) {
|
||||
Log.i(TAG, "New ringtone saved.");
|
||||
} else {
|
||||
Log.e(TAG, "Problem saving new ringtone preference.");
|
||||
}
|
||||
if (r != null) {
|
||||
String text = r.getTitle(getApplicationContext());
|
||||
if (text.length() > 15) {
|
||||
button.setText(text.substring(0, 15) + "...");
|
||||
} else {
|
||||
button.setText(text);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Sound setting problem (null ringtone)");
|
||||
button.setText(getString(R.string.silence));
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Sound setting problem (null uri)");
|
||||
button.setText(getString(R.string.silence));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if connection parameters are ok.
|
||||
*
|
||||
* @author Santiago Munín González
|
||||
*
|
||||
*/
|
||||
private class CheckConnectionAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private boolean connectionOk = false;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
// TODO implement check
|
||||
this.connectionOk = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose an image (ok or wrong)
|
||||
*/
|
||||
protected void onPostExecute(Void v) {
|
||||
if (this.connectionOk) {
|
||||
connectionStatus.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
||||
0, R.drawable.ok);
|
||||
} else {
|
||||
connectionStatus.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
||||
0, R.drawable.cross);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
/*
|
||||
Pandora FMS - http://pandorafms.com
|
||||
|
||||
// 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
|
||||
==================================================
|
||||
Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// 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.
|
||||
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.
|
||||
*/
|
||||
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
|
@ -29,8 +32,6 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import pandroid_event_viewer.pandorafms.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Intent;
|
||||
|
@ -42,457 +43,476 @@ import android.util.Log;
|
|||
import android.widget.TabHost;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class PandroidEventviewerActivity extends TabActivity implements Serializable {
|
||||
public class PandroidEventviewerActivity extends TabActivity implements
|
||||
Serializable {
|
||||
private static String TAG = "PandroidEventviewerActivity";
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//Data aplication
|
||||
|
||||
// Data aplication
|
||||
public ArrayList<EventListItem> eventList;
|
||||
public long count_events;
|
||||
|
||||
//Flags
|
||||
|
||||
// Flags
|
||||
public boolean loadInProgress;
|
||||
public boolean getNewListEvents;
|
||||
|
||||
//Configuration
|
||||
|
||||
// Configuration
|
||||
public boolean show_popup_info;
|
||||
public String url;
|
||||
public String user;
|
||||
public String password;
|
||||
|
||||
//Parameters to search in the API
|
||||
public String agentNameStr;
|
||||
public int id_group;
|
||||
public long timestamp;
|
||||
public int severity;
|
||||
public int pagination;
|
||||
public long offset;
|
||||
public int status;
|
||||
public String eventSearch;
|
||||
public int filterLastTime;
|
||||
|
||||
public Intent intent_service;
|
||||
|
||||
public Core core;
|
||||
|
||||
public boolean showOptionsFirstTime;
|
||||
public boolean showTabListFirstTime;
|
||||
|
||||
/** 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.show_popup_info = preferences.getBoolean("show_popup_info", true);
|
||||
this.url = preferences.getString("url", "");
|
||||
this.user = preferences.getString("user", "");
|
||||
this.password = preferences.getString("password", "");
|
||||
|
||||
final TabHost tabHost = getTabHost();
|
||||
|
||||
this.loadInProgress = false;
|
||||
|
||||
this.core = new Core();
|
||||
|
||||
//Check if the preferences is setted, if not show the option activity.
|
||||
if ((user.length() == 0) && (password.length() == 0)
|
||||
&& (url.length() == 0)) {
|
||||
|
||||
Intent i = new Intent(this, Options.class);
|
||||
//i.putExtra("object", this);
|
||||
i.putExtra("core", this.core);
|
||||
|
||||
startActivity(i);
|
||||
|
||||
this.showOptionsFirstTime = true;
|
||||
}
|
||||
else {
|
||||
this.loadInProgress = true;
|
||||
|
||||
this.showOptionsFirstTime = false;
|
||||
this.showTabListFirstTime = true;
|
||||
}
|
||||
|
||||
this.pagination = 20;
|
||||
this.offset = 0;
|
||||
this.agentNameStr = preferences.getString("filterAgentName", "");
|
||||
this.severity = preferences.getInt("filterSeverity", -1);
|
||||
this.status = preferences.getInt("filterStatus", 3);
|
||||
this.eventSearch = preferences.getString("filterEventSearch", "");
|
||||
this.filterLastTime = preferences.getInt("filterLastTime", 6);
|
||||
this.timestamp = this.core.convertMaxTimeOldEventValuesToTimestamp(0, this.filterLastTime);
|
||||
|
||||
this.eventList = new ArrayList<EventListItem>();
|
||||
this.getNewListEvents = true;
|
||||
|
||||
if (!this.showOptionsFirstTime) {
|
||||
//Start the background service for the notifications
|
||||
this.core.startServiceEventWatcher(getApplicationContext());
|
||||
}
|
||||
|
||||
Intent i_main = new Intent(this, Main.class);
|
||||
i_main.putExtra("object", this);
|
||||
i_main.putExtra("core", this.core);
|
||||
|
||||
tabHost.addTab
|
||||
(
|
||||
tabHost.newTabSpec(getResources().getString(R.string.item_tab_main_text))
|
||||
.setIndicator(getResources().getString(R.string.item_tab_main_text)
|
||||
)
|
||||
.setContent(i_main)
|
||||
);
|
||||
|
||||
public String user;
|
||||
public String password;
|
||||
|
||||
// Parameters to search in the API
|
||||
public String agentNameStr;
|
||||
public int id_group;
|
||||
public long timestamp;
|
||||
public int severity;
|
||||
public int pagination;
|
||||
public long offset;
|
||||
public int status;
|
||||
public String eventSearch;
|
||||
public int filterLastTime;
|
||||
|
||||
private Core core;
|
||||
|
||||
public boolean showOptionsFirstTime;
|
||||
public boolean showTabListFirstTime;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
this.show_popup_info = preferences.getBoolean("show_popup_info", true);
|
||||
this.url = preferences.getString("url", "");
|
||||
this.user = preferences.getString("user", "");
|
||||
this.password = preferences.getString("password", "");
|
||||
|
||||
final TabHost tabHost = getTabHost();
|
||||
|
||||
this.loadInProgress = false;
|
||||
|
||||
this.core = new Core();
|
||||
|
||||
// Check if the preferences is setted, if not show the option activity.
|
||||
if ((user.length() == 0) && (password.length() == 0)
|
||||
&& (url.length() == 0)) {
|
||||
|
||||
Intent i = new Intent(this, Options.class);
|
||||
// i.putExtra("object", this);
|
||||
i.putExtra("core", this.core);
|
||||
|
||||
startActivity(i);
|
||||
|
||||
this.showOptionsFirstTime = true;
|
||||
} else {
|
||||
this.loadInProgress = true;
|
||||
|
||||
this.showOptionsFirstTime = false;
|
||||
this.showTabListFirstTime = true;
|
||||
}
|
||||
|
||||
this.pagination = 20;
|
||||
this.offset = 0;
|
||||
this.agentNameStr = preferences.getString("filterAgentName", "");
|
||||
this.severity = preferences.getInt("filterSeverity", -1);
|
||||
this.status = preferences.getInt("filterStatus", 3);
|
||||
this.eventSearch = preferences.getString("filterEventSearch", "");
|
||||
this.filterLastTime = preferences.getInt("filterLastTime", 6);
|
||||
this.timestamp = this.core.convertMaxTimeOldEventValuesToTimestamp(0,
|
||||
this.filterLastTime);
|
||||
|
||||
this.eventList = new ArrayList<EventListItem>();
|
||||
this.getNewListEvents = true;
|
||||
|
||||
if (!this.showOptionsFirstTime) {
|
||||
// Start the background service for the notifications
|
||||
this.core.startServiceEventWatcher(getApplicationContext());
|
||||
}
|
||||
|
||||
Intent i_main = new Intent(this, Main.class);
|
||||
i_main.putExtra("object", this);
|
||||
i_main.putExtra("core", this.core);
|
||||
|
||||
tabHost.addTab(tabHost
|
||||
.newTabSpec(
|
||||
getResources().getString(R.string.item_tab_main_text))
|
||||
.setIndicator(
|
||||
getResources().getString(R.string.item_tab_main_text))
|
||||
.setContent(i_main));
|
||||
|
||||
Intent i_event_list = new Intent(this, EventList.class);
|
||||
i_event_list.putExtra("object", this);
|
||||
|
||||
tabHost.addTab
|
||||
(
|
||||
tabHost.newTabSpec(getResources().getString(R.string.item_tab_event_list_text))
|
||||
.setIndicator(getResources().getString(R.string.item_tab_event_list_text)
|
||||
)
|
||||
.setContent(i_event_list)
|
||||
);
|
||||
|
||||
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=45;
|
||||
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height=45;
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.getTabHost().setCurrentTab(1);
|
||||
|
||||
Intent i = getIntent();
|
||||
long count_events = i.getLongExtra("count_events", 0);
|
||||
|
||||
if (count_events > 0) {
|
||||
process_notification(i);
|
||||
}
|
||||
else {
|
||||
if (this.showTabListFirstTime) {
|
||||
executeBackgroundGetEvents();
|
||||
this.showTabListFirstTime = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
public void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
||||
process_notification(intent);
|
||||
}
|
||||
|
||||
public void process_notification(Intent intent) {
|
||||
long count_events = intent.getLongExtra("count_events", 0);
|
||||
int more_criticity = intent.getIntExtra("more_criticity", -1);
|
||||
|
||||
CharSequence text;
|
||||
|
||||
if (count_events > 0) {
|
||||
//From the notificy
|
||||
switch (more_criticity) {
|
||||
case 0:
|
||||
text = getString(R.string.loading_events_criticity_0_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
case 1:
|
||||
text = getString(R.string.loading_events_criticity_1_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
case 2:
|
||||
text = getString(R.string.loading_events_criticity_2_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
case 3:
|
||||
text = getString(R.string.loading_events_criticity_3_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
case 4:
|
||||
text = getString(R.string.loading_events_criticity_4_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
default:
|
||||
text = getString(R.string.loading_events_criticity_2_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
|
||||
//Set the same parameters to extract the events of the notification.
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
long timestamp_notification = preferences.getLong("previous_filterTimestamp", (new Date().getTime() / 1000));
|
||||
Log.e("PandroidEventviewerActivity process_notification", "time_noti = " + timestamp_notification);
|
||||
this.timestamp = timestamp_notification;
|
||||
Log.e("PandroidEventviewerActivity process_notification", "" +this.timestamp);
|
||||
this.agentNameStr = preferences.getString("filterAgentName", "");
|
||||
this.id_group = preferences.getInt("filterIDGroup", 0);
|
||||
this.severity = preferences.getInt("filterSeverity", -1);
|
||||
this.status = preferences.getInt("filterStatus", 3);
|
||||
this.eventSearch = preferences.getString("filterEventSearch", "");
|
||||
|
||||
this.getTabHost().setCurrentTab(1);
|
||||
|
||||
this.loadInProgress = true;
|
||||
this.getNewListEvents = true;
|
||||
this.eventList = new ArrayList<EventListItem>();
|
||||
executeBackgroundGetEvents();
|
||||
}
|
||||
}
|
||||
|
||||
public String serializeParams2Api() {
|
||||
String return_var = "";
|
||||
|
||||
return_var += ';'; //Separator for the csv
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(this.severity); //Criticity or severity
|
||||
return_var += "|";
|
||||
return_var += this.agentNameStr; //The agent name
|
||||
return_var += "|";
|
||||
return_var += ""; //Name of module
|
||||
return_var += "|";
|
||||
return_var += ""; //Name of alert template
|
||||
return_var += "|";
|
||||
return_var += ""; //Id user
|
||||
return_var += "|";
|
||||
return_var += Long.toString(this.timestamp); //The minimun timestamp
|
||||
return_var += "|";
|
||||
return_var += ""; //The maximum timestamp
|
||||
return_var += "|";
|
||||
return_var += this.status; //The status
|
||||
return_var += "|";
|
||||
return_var += this.eventSearch; //The free search in the text event description.
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(this.pagination); //The pagination of list events
|
||||
return_var += "|";
|
||||
return_var += Long.toString(this.offset); //The offset of list events
|
||||
|
||||
Log.e("PandroidEventviewerActivity serializeParams2Api", return_var);
|
||||
|
||||
return return_var;
|
||||
}
|
||||
|
||||
public void getEvents(boolean newEvents) {
|
||||
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();
|
||||
UrlEncodedFormEntity entity;
|
||||
HttpPost httpPost;
|
||||
List<NameValuePair> parameters;
|
||||
HttpResponse response;
|
||||
HttpEntity entityResponse;
|
||||
String return_api;
|
||||
|
||||
httpPost = new HttpPost(url + "/include/api.php");
|
||||
|
||||
//Get total count.
|
||||
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", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other", serializeParams2Api() + "|total"));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core.convertStreamToString(entityResponse.getContent());
|
||||
return_api = return_api.replace("\n", "");
|
||||
Log.e("PandroidEventviewerActivity getEvents", return_api);
|
||||
this.count_events = new Long(return_api).longValue();
|
||||
Log.e("getEvents", return_api);
|
||||
|
||||
if (this.count_events == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the list of events.
|
||||
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", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other", serializeParams2Api()));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
|
||||
return_api = Core.convertStreamToString(entityResponse.getContent());
|
||||
return_api = return_api.replaceAll("\\<.*?\\>", ""); //Clean html tags.
|
||||
|
||||
//Work around for the crap of \n in this event bad xml
|
||||
//return_api = return_api.replaceAll("Unable to process XML data file [^\n]*\n[^\n]*line 187 thread .\n", "Bad XML");
|
||||
|
||||
|
||||
|
||||
Pattern pattern = Pattern.compile("Unable to process XML data file '(.*)'");
|
||||
Matcher matcher;
|
||||
String filename;
|
||||
|
||||
boolean endReplace = false; int i22 = 0;
|
||||
while (!endReplace) { Log.e("loop", i22 + ""); i22++;
|
||||
matcher = pattern.matcher(return_api);
|
||||
|
||||
if (matcher.find()) {
|
||||
filename = matcher.group(1);
|
||||
return_api = return_api.replaceFirst("Unable to process XML data file[^\n]*\n[^\n]*line 187 thread .*\n", "Bad XML: " + filename);
|
||||
}
|
||||
else {
|
||||
endReplace = true;
|
||||
}
|
||||
}
|
||||
|
||||
Log.e("return_api", return_api);
|
||||
|
||||
String[] lines = return_api.split("\n");
|
||||
|
||||
if (return_api.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i= 0; i < lines.length; i++) {
|
||||
String[] items = lines[i].split(";", 21);
|
||||
|
||||
EventListItem event = new EventListItem();
|
||||
|
||||
if (items.length != 21) {
|
||||
event.event = getApplication().getString(R.string.unknown_event_str);
|
||||
}
|
||||
else {
|
||||
if (items[0].length() == 0) {
|
||||
event.id_event = 0;
|
||||
}
|
||||
else {
|
||||
event.id_event = Integer.parseInt(items[0]);
|
||||
}
|
||||
if (items[1].length() == 0) {
|
||||
event.id_agent = 0;
|
||||
}
|
||||
else {
|
||||
event.id_agent = Integer.parseInt(items[1]);
|
||||
}
|
||||
event.id_user = items[2];
|
||||
if (items[3].length() == 0) {
|
||||
event.id_group = 0;
|
||||
}
|
||||
else {
|
||||
event.id_group = Integer.parseInt(items[3]);
|
||||
}
|
||||
if (items[4].length() == 0) {
|
||||
event.status = 0;
|
||||
}
|
||||
else {
|
||||
event.status = Integer.parseInt(items[4]);
|
||||
}
|
||||
event.timestamp = items[5];
|
||||
event.event = items[6];
|
||||
if (items[7].length() == 0) {
|
||||
event.utimestamp = 0;
|
||||
}
|
||||
else {
|
||||
event.utimestamp = Integer.parseInt(items[7]);
|
||||
}
|
||||
event.event_type = items[8];
|
||||
if (items[9].length() == 0) {
|
||||
event.id_agentmodule = 0;
|
||||
}
|
||||
else {
|
||||
event.id_agentmodule = Integer.parseInt(items[9]);
|
||||
}
|
||||
if (items[10].length() == 0) {
|
||||
event.id_alert_am = 0;
|
||||
}
|
||||
else {
|
||||
event.id_alert_am = Integer.parseInt(items[10]);
|
||||
}
|
||||
if (items[11].length() == 0) {
|
||||
event.criticity = 0;
|
||||
}
|
||||
else {
|
||||
event.criticity = Integer.parseInt(items[11]);
|
||||
}
|
||||
event.user_comment = items[12];
|
||||
event.tags = items[13];
|
||||
event.agent_name = items[14];
|
||||
event.group_name = items[15];
|
||||
event.group_icon = items[16];
|
||||
event.description_event = items[17];
|
||||
event.description_image = items[18];
|
||||
event.criticity_name = items[19];
|
||||
event.criticity_image = items[20];
|
||||
|
||||
event.opened = false;
|
||||
}
|
||||
this.eventList.add(event);
|
||||
}
|
||||
//this.count_events = (long)this.eventList.size();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e("EXCEPTION PandroidEventviewerActivity getEvents", e.getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void executeBackgroundGetEvents() {
|
||||
new GetEventsAsyncTask().execute();
|
||||
}
|
||||
tabHost.addTab(tabHost
|
||||
.newTabSpec(
|
||||
getResources().getString(
|
||||
R.string.item_tab_event_list_text))
|
||||
.setIndicator(
|
||||
getResources().getString(
|
||||
R.string.item_tab_event_list_text))
|
||||
.setContent(i_event_list));
|
||||
|
||||
|
||||
public class GetEventsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 45;
|
||||
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 45;
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
this.getTabHost().setCurrentTab(1);
|
||||
|
||||
Intent i = getIntent();
|
||||
long count_events = i.getLongExtra("count_events", 0);
|
||||
|
||||
if (count_events > 0) {
|
||||
process_notification(i);
|
||||
} else {
|
||||
if (this.showTabListFirstTime) {
|
||||
executeBackgroundGetEvents();
|
||||
this.showTabListFirstTime = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
public void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
||||
process_notification(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes status bar notifications' clicks.
|
||||
*
|
||||
* @param intent
|
||||
*/
|
||||
private void process_notification(Intent intent) {
|
||||
long count_events = intent.getLongExtra("count_events", 0);
|
||||
int more_criticity = intent.getIntExtra("more_criticity", -1);
|
||||
|
||||
CharSequence text;
|
||||
|
||||
if (count_events > 0) {
|
||||
// From the notificy
|
||||
switch (more_criticity) {
|
||||
case 0:
|
||||
text = getString(R.string.loading_events_criticity_0_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
case 1:
|
||||
text = getString(R.string.loading_events_criticity_1_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
case 2:
|
||||
text = getString(R.string.loading_events_criticity_2_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
case 3:
|
||||
text = getString(R.string.loading_events_criticity_3_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
case 4:
|
||||
text = getString(R.string.loading_events_criticity_4_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
default:
|
||||
text = getString(R.string.loading_events_criticity_2_str)
|
||||
.replace("%s", new Long(count_events).toString());
|
||||
break;
|
||||
}
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(), text,
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
|
||||
// Set the same parameters to extract the events of the
|
||||
// notification.
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
long timestamp_notification = preferences.getLong(
|
||||
"previous_filterTimestamp", (new Date().getTime() / 1000));
|
||||
Log.i(TAG + " process_notification_timestamp", ""
|
||||
+ timestamp_notification);
|
||||
this.timestamp = timestamp_notification;
|
||||
this.agentNameStr = preferences.getString("filterAgentName", "");
|
||||
this.id_group = preferences.getInt("filterIDGroup", 0);
|
||||
this.severity = preferences.getInt("filterSeverity", -1);
|
||||
this.status = preferences.getInt("filterStatus", 3);
|
||||
this.eventSearch = preferences.getString("filterEventSearch", "");
|
||||
|
||||
this.getTabHost().setCurrentTab(1);
|
||||
|
||||
this.loadInProgress = true;
|
||||
this.getNewListEvents = true;
|
||||
this.eventList = new ArrayList<EventListItem>();
|
||||
executeBackgroundGetEvents();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes all params.
|
||||
*
|
||||
* @return All params in a string.
|
||||
*/
|
||||
private String serializeParams2Api() {
|
||||
String return_var = "";
|
||||
|
||||
return_var += ';'; // Separator for the csv
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(this.severity); // Criticity or severity
|
||||
return_var += "|";
|
||||
return_var += this.agentNameStr; // The agent name
|
||||
return_var += "|";
|
||||
return_var += ""; // Name of module
|
||||
return_var += "|";
|
||||
return_var += ""; // Name of alert template
|
||||
return_var += "|";
|
||||
return_var += ""; // Id user
|
||||
return_var += "|";
|
||||
return_var += Long.toString(this.timestamp); // The minimun timestamp
|
||||
return_var += "|";
|
||||
return_var += ""; // The maximum timestamp
|
||||
return_var += "|";
|
||||
return_var += this.status; // The status
|
||||
return_var += "|";
|
||||
return_var += this.eventSearch; // The free search in the text event
|
||||
// description.
|
||||
return_var += "|";
|
||||
return_var += Integer.toString(this.pagination); // The pagination of
|
||||
// list events
|
||||
return_var += "|";
|
||||
return_var += Long.toString(this.offset); // The offset of list events
|
||||
|
||||
Log.i(TAG + " serializeParams2Api", return_var);
|
||||
|
||||
return return_var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events from pandora console.
|
||||
*
|
||||
* @param newEvents
|
||||
*/
|
||||
private void getEvents(boolean newEvents) {
|
||||
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();
|
||||
UrlEncodedFormEntity entity;
|
||||
HttpPost httpPost;
|
||||
List<NameValuePair> parameters;
|
||||
HttpResponse response;
|
||||
HttpEntity entityResponse;
|
||||
String return_api;
|
||||
|
||||
httpPost = new HttpPost(url + "/include/api.php");
|
||||
|
||||
// Get total count.
|
||||
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", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode",
|
||||
"url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other",
|
||||
serializeParams2Api() + "|total"));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core
|
||||
.convertStreamToString(entityResponse.getContent());
|
||||
return_api = return_api.replace("\n", "");
|
||||
Log.i(TAG + " getEvents", return_api);
|
||||
this.count_events = new Long(return_api).longValue();
|
||||
|
||||
if (this.count_events == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the list of events.
|
||||
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", "events"));
|
||||
parameters.add(new BasicNameValuePair("other_mode",
|
||||
"url_encode_separator_|"));
|
||||
parameters.add(new BasicNameValuePair("return_type", "csv"));
|
||||
parameters.add(new BasicNameValuePair("other",
|
||||
serializeParams2Api()));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
|
||||
return_api = Core
|
||||
.convertStreamToString(entityResponse.getContent());
|
||||
return_api = return_api.replaceAll("\\<.*?\\>", ""); // Clean html
|
||||
// tags.
|
||||
|
||||
Pattern pattern = Pattern
|
||||
.compile("Unable to process XML data file '(.*)'");
|
||||
Matcher matcher;
|
||||
String filename;
|
||||
|
||||
boolean endReplace = false;
|
||||
int i22 = 0;
|
||||
while (!endReplace) {
|
||||
Log.i(TAG + " getEvents - loop", i22 + "");
|
||||
i22++;
|
||||
matcher = pattern.matcher(return_api);
|
||||
|
||||
if (matcher.find()) {
|
||||
filename = matcher.group(1);
|
||||
return_api = return_api
|
||||
.replaceFirst(
|
||||
"Unable to process XML data file[^\n]*\n[^\n]*line 187 thread .*\n",
|
||||
"Bad XML: " + filename);
|
||||
} else {
|
||||
endReplace = true;
|
||||
}
|
||||
}
|
||||
|
||||
Log.i(TAG + " getEvents - return_api", return_api);
|
||||
|
||||
String[] lines = return_api.split("\n");
|
||||
|
||||
if (return_api.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String[] items = lines[i].split(";", 21);
|
||||
|
||||
EventListItem event = new EventListItem();
|
||||
|
||||
if (items.length != 21) {
|
||||
event.event = getApplication().getString(
|
||||
R.string.unknown_event_str);
|
||||
} else {
|
||||
if (items[0].length() == 0) {
|
||||
event.id_event = 0;
|
||||
} else {
|
||||
event.id_event = Integer.parseInt(items[0]);
|
||||
}
|
||||
if (items[1].length() == 0) {
|
||||
event.id_agent = 0;
|
||||
} else {
|
||||
event.id_agent = Integer.parseInt(items[1]);
|
||||
}
|
||||
event.id_user = items[2];
|
||||
if (items[3].length() == 0) {
|
||||
event.id_group = 0;
|
||||
} else {
|
||||
event.id_group = Integer.parseInt(items[3]);
|
||||
}
|
||||
if (items[4].length() == 0) {
|
||||
event.status = 0;
|
||||
} else {
|
||||
event.status = Integer.parseInt(items[4]);
|
||||
}
|
||||
event.timestamp = items[5];
|
||||
event.event = items[6];
|
||||
if (items[7].length() == 0) {
|
||||
event.utimestamp = 0;
|
||||
} else {
|
||||
event.utimestamp = Integer.parseInt(items[7]);
|
||||
}
|
||||
event.event_type = items[8];
|
||||
if (items[9].length() == 0) {
|
||||
event.id_agentmodule = 0;
|
||||
} else {
|
||||
event.id_agentmodule = Integer.parseInt(items[9]);
|
||||
}
|
||||
if (items[10].length() == 0) {
|
||||
event.id_alert_am = 0;
|
||||
} else {
|
||||
event.id_alert_am = Integer.parseInt(items[10]);
|
||||
}
|
||||
if (items[11].length() == 0) {
|
||||
event.criticity = 0;
|
||||
} else {
|
||||
event.criticity = Integer.parseInt(items[11]);
|
||||
}
|
||||
event.user_comment = items[12];
|
||||
event.tags = items[13];
|
||||
event.agent_name = items[14];
|
||||
event.group_name = items[15];
|
||||
event.group_icon = items[16];
|
||||
event.description_event = items[17];
|
||||
event.description_image = items[18];
|
||||
event.criticity_name = items[19];
|
||||
event.criticity_image = items[20];
|
||||
|
||||
event.opened = false;
|
||||
}
|
||||
this.eventList.add(event);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG + " getEvents", e.getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the async task of getting events.
|
||||
*/
|
||||
public void executeBackgroundGetEvents() {
|
||||
new GetEventsAsyncTask().execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get events from pandora console (async task)
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class GetEventsAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
Log.e("GetEventsAsyncTask doInBackground", "doInBackground");
|
||||
Log.i(TAG + " GetEventsAsyncTask", "doInBackground");
|
||||
if (getNewListEvents) {
|
||||
getEvents(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
getEvents(false);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void unused)
|
||||
{
|
||||
protected void onPostExecute(Void unused) {
|
||||
Intent i = new Intent("eventlist.java");
|
||||
|
||||
|
||||
if (getNewListEvents) {
|
||||
loadInProgress = false;
|
||||
getNewListEvents = false;
|
||||
|
||||
|
||||
i.putExtra("load_more", 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i.putExtra("load_more", 1);
|
||||
}
|
||||
|
||||
|
||||
getApplicationContext().sendBroadcast(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -9,10 +25,16 @@ import android.content.Intent;
|
|||
import android.content.SharedPreferences;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* This service will launch AlarmReceiver periodically.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class PandroidEventviewerService extends Service {
|
||||
private static String TAG = "PandroidEventviewerService";
|
||||
public AlarmManager alarmM;
|
||||
PendingIntent pendingI;
|
||||
PendingIntent pendingI;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
|
@ -21,90 +43,94 @@ public class PandroidEventviewerService extends Service {
|
|||
}
|
||||
|
||||
public void onCreate() {
|
||||
alarmM = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
|
||||
Intent intentAlarm = new Intent(this, AlarmReceiver.class);
|
||||
this.pendingI = PendingIntent.getBroadcast(this, 0, intentAlarm, 0);
|
||||
|
||||
int sleepTimeAlarm = convertRefreshTimeKeyToTime();
|
||||
|
||||
Log.e("PandroidEventviewerService", "sleepTimeAlarm = " + sleepTimeAlarm);
|
||||
|
||||
alarmM.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), sleepTimeAlarm, this.pendingI);
|
||||
alarmM = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
|
||||
Intent intentAlarm = new Intent(this, AlarmReceiver.class);
|
||||
this.pendingI = PendingIntent.getBroadcast(this, 0, intentAlarm, 0);
|
||||
|
||||
int sleepTimeAlarm = convertRefreshTimeKeyToTime();
|
||||
|
||||
Log.i(TAG, "sleepTimeAlarm = " + sleepTimeAlarm);
|
||||
|
||||
alarmM.setRepeating(AlarmManager.RTC_WAKEUP,
|
||||
System.currentTimeMillis(), sleepTimeAlarm, this.pendingI);
|
||||
}
|
||||
|
||||
public int convertRefreshTimeKeyToTime() {
|
||||
/**
|
||||
* Converts chosen time from spinner to seconds (either are seconds or not)
|
||||
* @return
|
||||
*/
|
||||
private int convertRefreshTimeKeyToTime() {
|
||||
int returnvar = 60 * 10;
|
||||
|
||||
|
||||
SharedPreferences preferences = getSharedPreferences(
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
this.getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
int refreshTimeKey = preferences.getInt("refreshTimeKey", 3);
|
||||
|
||||
|
||||
switch (refreshTimeKey) {
|
||||
case 0:
|
||||
returnvar = 30; //30 seconds
|
||||
break;
|
||||
case 1:
|
||||
returnvar = 60; //1 minute
|
||||
break;
|
||||
case 2:
|
||||
returnvar = 60 * 5; //5 minutes
|
||||
break;
|
||||
case 3:
|
||||
returnvar = 60 * 10; //10 minutes
|
||||
break;
|
||||
case 4:
|
||||
returnvar = 60 * 15; //15 minutes
|
||||
break;
|
||||
case 5:
|
||||
returnvar = 60 * 30; //30 minutes
|
||||
break;
|
||||
case 6:
|
||||
returnvar = 60 * 45; //45 minutes
|
||||
break;
|
||||
case 7:
|
||||
returnvar = 3600; //1 hour
|
||||
break;
|
||||
case 8:
|
||||
returnvar = 3600 + (60 * 30); //1 hour and 30 minutes
|
||||
break;
|
||||
case 9:
|
||||
returnvar = 3600 * 2; //2 hours
|
||||
break;
|
||||
case 10:
|
||||
returnvar = 3600 * 3; //3 hours
|
||||
break;
|
||||
case 11:
|
||||
returnvar = 3600 * 4; //4 hours
|
||||
break;
|
||||
case 12:
|
||||
returnvar = 3600 * 6; //6 hours
|
||||
break;
|
||||
case 13:
|
||||
returnvar = 3600 * 8; //8 hours
|
||||
break;
|
||||
case 14:
|
||||
returnvar = 3600 * 10; //10 hours
|
||||
break;
|
||||
case 15:
|
||||
returnvar = 3600 * 12; //12 hours
|
||||
break;
|
||||
case 16:
|
||||
returnvar = 3600 * 24; //24 hours
|
||||
break;
|
||||
case 17:
|
||||
returnvar = 3600 * 36; //36 hours
|
||||
break;
|
||||
case 18:
|
||||
returnvar = 3600 * 48; //48 hours
|
||||
break;
|
||||
case 0:
|
||||
returnvar = 30; // 30 seconds
|
||||
break;
|
||||
case 1:
|
||||
returnvar = 60; // 1 minute
|
||||
break;
|
||||
case 2:
|
||||
returnvar = 60 * 5; // 5 minutes
|
||||
break;
|
||||
case 3:
|
||||
returnvar = 60 * 10; // 10 minutes
|
||||
break;
|
||||
case 4:
|
||||
returnvar = 60 * 15; // 15 minutes
|
||||
break;
|
||||
case 5:
|
||||
returnvar = 60 * 30; // 30 minutes
|
||||
break;
|
||||
case 6:
|
||||
returnvar = 60 * 45; // 45 minutes
|
||||
break;
|
||||
case 7:
|
||||
returnvar = 3600; // 1 hour
|
||||
break;
|
||||
case 8:
|
||||
returnvar = 3600 + (60 * 30); // 1 hour and 30 minutes
|
||||
break;
|
||||
case 9:
|
||||
returnvar = 3600 * 2; // 2 hours
|
||||
break;
|
||||
case 10:
|
||||
returnvar = 3600 * 3; // 3 hours
|
||||
break;
|
||||
case 11:
|
||||
returnvar = 3600 * 4; // 4 hours
|
||||
break;
|
||||
case 12:
|
||||
returnvar = 3600 * 6; // 6 hours
|
||||
break;
|
||||
case 13:
|
||||
returnvar = 3600 * 8; // 8 hours
|
||||
break;
|
||||
case 14:
|
||||
returnvar = 3600 * 10; // 10 hours
|
||||
break;
|
||||
case 15:
|
||||
returnvar = 3600 * 12; // 12 hours
|
||||
break;
|
||||
case 16:
|
||||
returnvar = 3600 * 24; // 24 hours
|
||||
break;
|
||||
case 17:
|
||||
returnvar = 3600 * 36; // 36 hours
|
||||
break;
|
||||
case 18:
|
||||
returnvar = 3600 * 48; // 48 hours
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return returnvar * 1000;
|
||||
}
|
||||
|
||||
|
||||
public void onDestroy() {
|
||||
alarmM.cancel(this.pendingI);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
package pandroid_event_viewer.pandorafms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -23,133 +39,153 @@ import android.widget.EditText;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Provides the functionality necessary to validate an event.
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
public class PopupValidationEvent extends Activity {
|
||||
public int id_event;
|
||||
public String comment;
|
||||
|
||||
public PandroidEventviewerActivity object;
|
||||
public Core core;
|
||||
|
||||
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);
|
||||
|
||||
Intent i = getIntent();
|
||||
this.id_event = i.getIntExtra("id_event", -1);
|
||||
//this.object = (PandroidEventviewerActivity)i.getSerializableExtra("object");
|
||||
this.core = (Core)i.getSerializableExtra("core");
|
||||
|
||||
setContentView(R.layout.popup_validation_event);
|
||||
|
||||
final Button button = (Button) findViewById(R.id.button_validate_event);
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
validateEvent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void validateEvent() {
|
||||
EditText textbox = (EditText) findViewById(R.id.comment);
|
||||
String comment = textbox.getText().toString();
|
||||
Button button = (Button) findViewById(R.id.button_validate_event);
|
||||
ProgressBar pb = (ProgressBar) findViewById(R.id.send_progress);
|
||||
|
||||
button.setVisibility(Button.GONE);
|
||||
pb.setVisibility(ProgressBar.VISIBLE);
|
||||
|
||||
this.comment = "Validate from Pandroid Eventviewer Mobile: " + comment;
|
||||
|
||||
new SendValidationAsyncTask().execute();
|
||||
}
|
||||
|
||||
public void destroyPopup() {
|
||||
finish();
|
||||
}
|
||||
|
||||
public boolean sendValidation() {
|
||||
boolean return_var = false;
|
||||
|
||||
private int id_event;
|
||||
private String comment;
|
||||
private String url;
|
||||
private String user;
|
||||
private String password;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent i = getIntent();
|
||||
this.id_event = i.getIntExtra("id_event", -1);
|
||||
// this.core = (Core)i.getSerializableExtra("core");
|
||||
|
||||
setContentView(R.layout.popup_validation_event);
|
||||
final Button button = (Button) findViewById(R.id.button_validate_event);
|
||||
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
validateEvent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the event
|
||||
*/
|
||||
private void validateEvent() {
|
||||
EditText textbox = (EditText) findViewById(R.id.comment);
|
||||
String comment = textbox.getText().toString();
|
||||
Button button = (Button) findViewById(R.id.button_validate_event);
|
||||
ProgressBar pb = (ProgressBar) findViewById(R.id.send_progress);
|
||||
|
||||
button.setVisibility(Button.GONE);
|
||||
pb.setVisibility(ProgressBar.VISIBLE);
|
||||
|
||||
this.comment = "Validate from Pandroid Eventviewer Mobile: " + comment;
|
||||
|
||||
new SendValidationAsyncTask().execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish the activity
|
||||
*/
|
||||
private void destroyPopup() {
|
||||
finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the validation to server.
|
||||
*
|
||||
* @return <b>true</b> if it was done.
|
||||
*/
|
||||
private boolean sendValidation() {
|
||||
boolean return_var = false;
|
||||
|
||||
if (this.url == null) {
|
||||
SharedPreferences preferences = getApplicationContext().getSharedPreferences(
|
||||
getApplicationContext().getString(R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
this.url = preferences.getString("url", "");
|
||||
this.user = preferences.getString("user", "");
|
||||
this.password = preferences.getString("password", "");
|
||||
SharedPreferences preferences = getApplicationContext()
|
||||
.getSharedPreferences(
|
||||
getApplicationContext().getString(
|
||||
R.string.const_string_preferences),
|
||||
Activity.MODE_PRIVATE);
|
||||
|
||||
this.url = preferences.getString("url", "");
|
||||
this.user = preferences.getString("user", "");
|
||||
this.password = preferences.getString("password", "");
|
||||
}
|
||||
try {
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
UrlEncodedFormEntity entity;
|
||||
HttpPost httpPost;
|
||||
List<NameValuePair> parameters;
|
||||
HttpResponse response;
|
||||
HttpEntity entityResponse;
|
||||
String return_api;
|
||||
|
||||
httpPost = new HttpPost(this.url + "/include/api.php");
|
||||
|
||||
//Set event validation.
|
||||
parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("user", this.user));
|
||||
parameters.add(new BasicNameValuePair("pass", this.password));
|
||||
parameters.add(new BasicNameValuePair("op", "set"));
|
||||
parameters.add(new BasicNameValuePair("op2", "validate_events"));
|
||||
parameters.add(new BasicNameValuePair("id", new Integer(this.id_event).toString()));
|
||||
parameters.add(new BasicNameValuePair("other", this.comment));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core.convertStreamToString(entityResponse.getContent());
|
||||
return_api = return_api.replace("\n", "");
|
||||
|
||||
if (return_api.startsWith("Correct validation")) {
|
||||
return_var = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e("EXCEPTION sendValidation", e.getMessage());
|
||||
}
|
||||
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
UrlEncodedFormEntity entity;
|
||||
HttpPost httpPost;
|
||||
List<NameValuePair> parameters;
|
||||
HttpResponse response;
|
||||
HttpEntity entityResponse;
|
||||
String return_api;
|
||||
|
||||
httpPost = new HttpPost(this.url + "/include/api.php");
|
||||
|
||||
// Set event validation.
|
||||
parameters = new ArrayList<NameValuePair>();
|
||||
parameters.add(new BasicNameValuePair("user", this.user));
|
||||
parameters.add(new BasicNameValuePair("pass", this.password));
|
||||
parameters.add(new BasicNameValuePair("op", "set"));
|
||||
parameters.add(new BasicNameValuePair("op2", "validate_events"));
|
||||
parameters.add(new BasicNameValuePair("id", new Integer(
|
||||
this.id_event).toString()));
|
||||
parameters.add(new BasicNameValuePair("other", this.comment));
|
||||
entity = new UrlEncodedFormEntity(parameters);
|
||||
httpPost.setEntity(entity);
|
||||
response = httpClient.execute(httpPost);
|
||||
entityResponse = response.getEntity();
|
||||
return_api = Core
|
||||
.convertStreamToString(entityResponse.getContent());
|
||||
return_api = return_api.replace("\n", "");
|
||||
|
||||
if (return_api.startsWith("Correct validation")) {
|
||||
return_var = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("EXCEPTION sendValidation", e.getMessage());
|
||||
}
|
||||
|
||||
return return_var;
|
||||
}
|
||||
|
||||
public class SendValidationAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
public ArrayList<String> lista;
|
||||
public boolean result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a validation (async task)
|
||||
*
|
||||
* @author Miguel de Dios Matías
|
||||
*
|
||||
*/
|
||||
private class SendValidationAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
private boolean result;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
result = sendValidation();
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void unused)
|
||||
{
|
||||
protected void onPostExecute(Void unused) {
|
||||
String text;
|
||||
|
||||
|
||||
if (result) {
|
||||
text = getApplicationContext().getString(R.string.successful_validate_event_str);
|
||||
text = getApplicationContext().getString(
|
||||
R.string.successful_validate_event_str);
|
||||
} else {
|
||||
text = getApplicationContext().getString(
|
||||
R.string.fail_validate_event_str);
|
||||
}
|
||||
else {
|
||||
text = getApplicationContext().getString(R.string.fail_validate_event_str);
|
||||
}
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
|
||||
destroyPopup();
|
||||
|
||||
Toast toast = Toast.makeText(getApplicationContext(), text,
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
|
||||
destroyPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue