mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-26 23:35:02 +02:00
2011-10-20 Miguel de Dios <miguel.dedios@artica.es>
* AndroidManifest.xml: added new activies and permission of batery. * src/pandroid/agent/PandroidAgent.java, src/pandroid/agent/Setup.java, src/pandroid/agent/Status.java, src/pandroid/agent/PandroidAgentListener.java, src/pandroid/agent/EventReceiver.java, src/pandroid/agent/Help.java, src/pandroid/agent/About.java: wip. * res/values/strings.xml, res/values-en/strings.xml, res/values-es/strings.xml: added strings and translations into spanish. * res/menu/options_menu.xml: added a menu file. * res/drawable-ldpi/help.png, res/drawable-ldpi/about.png, res/drawable-ldpi/pandorafms_logo.png: added image files. * res/layout/setup.xml, res/layout/status.xml, res/layout/help.xml, res/layout/about.xml: wip and added the need layout for new activies. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5072 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
479cc042fb
commit
71b0ac6703
@ -1,3 +1,24 @@
|
|||||||
|
2011-10-20 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* AndroidManifest.xml: added new activies and permission of batery.
|
||||||
|
|
||||||
|
* src/pandroid/agent/PandroidAgent.java, src/pandroid/agent/Setup.java,
|
||||||
|
src/pandroid/agent/Status.java,
|
||||||
|
src/pandroid/agent/PandroidAgentListener.java,
|
||||||
|
src/pandroid/agent/EventReceiver.java, src/pandroid/agent/Help.java,
|
||||||
|
src/pandroid/agent/About.java: wip.
|
||||||
|
|
||||||
|
* res/values/strings.xml, res/values-en/strings.xml,
|
||||||
|
res/values-es/strings.xml: added strings and translations into spanish.
|
||||||
|
|
||||||
|
* res/menu/options_menu.xml: added a menu file.
|
||||||
|
|
||||||
|
* res/drawable-ldpi/help.png, res/drawable-ldpi/about.png,
|
||||||
|
res/drawable-ldpi/pandorafms_logo.png: added image files.
|
||||||
|
|
||||||
|
* res/layout/setup.xml, res/layout/status.xml, res/layout/help.xml,
|
||||||
|
res/layout/about.xml: wip and added the need layout for new activies.
|
||||||
|
|
||||||
2011-10-12 Miguel de Dios <miguel.dedios@artica.es>
|
2011-10-12 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* android/.classpath, android/libs/commons-lang3-3.0.1.jar: added the
|
* android/.classpath, android/libs/commons-lang3-3.0.1.jar: added the
|
||||||
|
@ -21,6 +21,16 @@
|
|||||||
|
|
||||||
<service android:enabled="true" android:name="pandroid.agent.PandroidAgentListener" />
|
<service android:enabled="true" android:name="pandroid.agent.PandroidAgentListener" />
|
||||||
<receiver android:name="pandroid.agent.EventReceiver" />
|
<receiver android:name="pandroid.agent.EventReceiver" />
|
||||||
|
<activity
|
||||||
|
android:name=".About"
|
||||||
|
android:label="@string/pandroid_agent_str"
|
||||||
|
android:theme="@android:style/Theme.Dialog"
|
||||||
|
/>
|
||||||
|
<activity
|
||||||
|
android:name=".Help"
|
||||||
|
android:label="@string/help_str"
|
||||||
|
android:theme="@android:style/Theme.Dialog"
|
||||||
|
/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
@ -29,6 +39,7 @@
|
|||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||||
<uses-permission android:name="android.permission.GET_TASKS"/>
|
<uses-permission android:name="android.permission.GET_TASKS"/>
|
||||||
|
<uses-permission android:name="android.permission.BATTERY_STATS"/>
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.sensor.light" />
|
<uses-feature android:name="android.hardware.sensor.light" />
|
||||||
<uses-feature android:name="android.hardware.location" />
|
<uses-feature android:name="android.hardware.location" />
|
||||||
|
BIN
pandora_agents/android/res/drawable-ldpi/about.png
Normal file
BIN
pandora_agents/android/res/drawable-ldpi/about.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 764 B |
BIN
pandora_agents/android/res/drawable-ldpi/help.png
Normal file
BIN
pandora_agents/android/res/drawable-ldpi/help.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 761 B |
BIN
pandora_agents/android/res/drawable-ldpi/pandorafms_logo.png
Normal file
BIN
pandora_agents/android/res/drawable-ldpi/pandorafms_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
56
pandora_agents/android/res/layout/about.xml
Normal file
56
pandora_agents/android/res/layout/about.xml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
// 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.
|
||||||
|
-->
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:padding="10dip"
|
||||||
|
>
|
||||||
|
<ImageView
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:id="@+id/img_logo_about"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:padding="5px"
|
||||||
|
android:src="@drawable/pandorafms_logo"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Copyright (c) 2011 Artica"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/licensed_under_gpl_str"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/develop_team_str"
|
||||||
|
android:gravity="left"
|
||||||
|
/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/url_pandora"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
30
pandora_agents/android/res/layout/help.xml
Normal file
30
pandora_agents/android/res/layout/help.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
// 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.
|
||||||
|
-->
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:padding="10dip"
|
||||||
|
android:background="#000000"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/help_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
@ -95,7 +95,7 @@
|
|||||||
android:textSize="14dip"
|
android:textSize="14dip"
|
||||||
android:textColor="#bbbbbb"
|
android:textColor="#bbbbbb"
|
||||||
/>
|
/>
|
||||||
<CheckBox
|
<!--<CheckBox
|
||||||
android:id="@+id/checkTaskReport"
|
android:id="@+id/checkTaskReport"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -132,7 +132,12 @@
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/update"
|
android:text="@string/update"
|
||||||
android:enabled="false"
|
/>-->
|
||||||
|
<Button
|
||||||
|
android:id="@+id/update"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/update"
|
||||||
/>
|
/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/battery_label_str"
|
android:layout_below="@id/battery_label_str"
|
||||||
/>
|
/>
|
||||||
<TextView
|
<!--<TextView
|
||||||
android:id="@+id/orientation_label_str"
|
android:id="@+id/orientation_label_str"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -124,16 +124,16 @@
|
|||||||
android:text="@string/proximity"
|
android:text="@string/proximity"
|
||||||
android:textSize="14dip"
|
android:textSize="14dip"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_below="@id/orientation_value_str"
|
android:layout_below="@id/battery_value_str"
|
||||||
/>
|
/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/proximity_value_str"
|
android:id="@+id/proximity_value_str"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/proximity_label_str"
|
android:layout_below="@id/proximity_label_str"
|
||||||
/>
|
/>-->
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
<TextView
|
<!--<TextView
|
||||||
android:id="@+id/task_label_str"
|
android:id="@+id/task_label_str"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -145,7 +145,7 @@
|
|||||||
android:id="@+id/task_value_str"
|
android:id="@+id/task_value_str"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
/>
|
/>-->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/memory_label_str"
|
android:id="@+id/memory_label_str"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
28
pandora_agents/android/res/menu/options_menu.xml
Normal file
28
pandora_agents/android/res/menu/options_menu.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
// 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.
|
||||||
|
-->
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item
|
||||||
|
android:id="@+id/help_button_menu_options"
|
||||||
|
android:title="@string/help_label_str"
|
||||||
|
android:icon="@drawable/help"
|
||||||
|
/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/about_button_menu_options"
|
||||||
|
android:title="@string/about_label_str"
|
||||||
|
android:icon="@drawable/about"
|
||||||
|
/>
|
||||||
|
</menu>
|
50
pandora_agents/android/res/values-en/strings.xml
Executable file
50
pandora_agents/android/res/values-en/strings.xml
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="const_string_preferences">PANDROID_DATA</string>
|
||||||
|
|
||||||
|
<string name="status_str">Status</string>
|
||||||
|
<string name="setup_str">Setup</string>
|
||||||
|
<string name="app_name">Pandroid Agent</string>
|
||||||
|
<string name="interval">Interval:</string>
|
||||||
|
<string name="update">Update conf.</string>
|
||||||
|
<string name="reset">Set default</string>
|
||||||
|
<string name="serverAddr">Server Address:</string>
|
||||||
|
<string name="serverPort">Server Port:</string>
|
||||||
|
<string name="confTitle">Pandroid Agent Configuration</string>
|
||||||
|
<string name="agent">Agent name:</string>
|
||||||
|
<string name="gpsReport">Report GPS data</string>
|
||||||
|
<string name="memoryReport">Report memory system</string>
|
||||||
|
<string name="taskReport">Report task</string>
|
||||||
|
<string name="gpsMode">GPS Mode</string>
|
||||||
|
<string name="gpsCurrent">Current position (high battery cost)</string>
|
||||||
|
<string name="summary">Current configuration:</string>
|
||||||
|
<string name="starStop">Restart</string>
|
||||||
|
<string name="gpsLast">Last known position</string>
|
||||||
|
<string name="loading">Loading...</string>
|
||||||
|
<string name="process">Process</string>
|
||||||
|
<string name="last_values">Last values</string>
|
||||||
|
<string name="latitude">Latitude</string>
|
||||||
|
<string name="longitude">Longitude</string>
|
||||||
|
<string name="battery_level">Battery Level</string>
|
||||||
|
<string name="orientation">Orientation</string>
|
||||||
|
<string name="proximity">Proximity</string>
|
||||||
|
<string name="incorrect_update">Unsucessful update options.</string>
|
||||||
|
<string name="correct_update">sucessful update options.</string>
|
||||||
|
<string name="task">Task</string>
|
||||||
|
<string name="memory">Memory</string>
|
||||||
|
<string name="help_label_str">Help</string>
|
||||||
|
<string name="about_label_str">About</string>
|
||||||
|
<string name="licensed_under_gpl_str">Licensed under GPL v2</string>
|
||||||
|
<string name="develop_team_str">Developer: Sergio M. Zarzuelo, Miguel de Dios</string>
|
||||||
|
<string name="pandroid_agent_str">Pandroid Agent</string>
|
||||||
|
<string name="help_str">Help</string>
|
||||||
|
<string name="memory_avaliable_str" formatted="false">Avaliable: %iKb Total: %iKb</string>
|
||||||
|
<string name="never_str">Never.</string>
|
||||||
|
<string name="now_str">Now.</string>
|
||||||
|
<string name="seconds_str">seconds ago.</string>
|
||||||
|
<string name="conctact_error_str">Contact error</string>
|
||||||
|
<string name="last_contact_str">Last Contact:\n</string>
|
||||||
|
<string name="help_text_str">
|
||||||
|
<p>Un texto</p><p>Otro texto<br/><a href="http://google.es">google</a> el <i>texto</i></p>
|
||||||
|
</string>
|
||||||
|
</resources>
|
50
pandora_agents/android/res/values-es/strings.xml
Executable file
50
pandora_agents/android/res/values-es/strings.xml
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="const_string_preferences">PANDROID_DATA</string>
|
||||||
|
|
||||||
|
<string name="status_str">Estado</string>
|
||||||
|
<string name="setup_str">Configuración</string>
|
||||||
|
<string name="app_name">Agente Pandroid</string>
|
||||||
|
<string name="interval">Intervalo:</string>
|
||||||
|
<string name="update">Actualiza conf.</string>
|
||||||
|
<string name="reset">Por defecto</string>
|
||||||
|
<string name="serverAddr">Url del server:</string>
|
||||||
|
<string name="serverPort">Puerto del server:</string>
|
||||||
|
<string name="confTitle">Configuración del Agente Pandroid</string>
|
||||||
|
<string name="agent">Nombre Agente:</string>
|
||||||
|
<string name="gpsReport">Reporta datos GPS</string>
|
||||||
|
<string name="memoryReport">Reporta estado memoria</string>
|
||||||
|
<string name="taskReport">Reporta tareas</string>
|
||||||
|
<string name="gpsMode">Modo GPS</string>
|
||||||
|
<string name="gpsCurrent">Actual posición (alto consumo de batería)</string>
|
||||||
|
<string name="summary">Configuración actual:</string>
|
||||||
|
<string name="starStop">Reiniciar</string>
|
||||||
|
<string name="gpsLast">Última posición conocida</string>
|
||||||
|
<string name="loading">Cargando...</string>
|
||||||
|
<string name="process">Procesando</string>
|
||||||
|
<string name="last_values">Últimos valores</string>
|
||||||
|
<string name="latitude">Latitud</string>
|
||||||
|
<string name="longitude">Longitud</string>
|
||||||
|
<string name="battery_level">Nivel de batería</string>
|
||||||
|
<string name="orientation">Orientación</string>
|
||||||
|
<string name="proximity">Proximidad</string>
|
||||||
|
<string name="incorrect_update">Incorrecta actulización configuración.</string>
|
||||||
|
<string name="correct_update">Correcta actualización configuración.</string>
|
||||||
|
<string name="task">Tarea</string>
|
||||||
|
<string name="memory">Memoria</string>
|
||||||
|
<string name="help_label_str">Ayuda</string>
|
||||||
|
<string name="about_label_str">Sobre</string>
|
||||||
|
<string name="licensed_under_gpl_str">Licenciado bajo GPL v2</string>
|
||||||
|
<string name="develop_team_str">Desarrolladores: Sergio M. Zarzuelo, Miguel de Dios</string>
|
||||||
|
<string name="pandroid_agent_str">Agente Pandroid</string>
|
||||||
|
<string name="help_str">Ayuda</string>
|
||||||
|
<string name="memory_avaliable_str" formatted="false">Disponible: %iKb Total: %iKb</string>
|
||||||
|
<string name="never_str">Nunca.</string>
|
||||||
|
<string name="now_str">Ahora.</string>
|
||||||
|
<string name="seconds_str">segundos</string>
|
||||||
|
<string name="conctact_error_str">Error contacto</string>
|
||||||
|
<string name="last_contact_str">Último contacto:\n</string>
|
||||||
|
<string name="help_text_str">
|
||||||
|
<p>Un texto</p><p>Otro texto<br/><a href="http://google.es">google</a> el <i>texto</i></p>
|
||||||
|
</string>
|
||||||
|
</resources>
|
@ -2,6 +2,8 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="const_string_preferences">PANDROID_DATA</string>
|
<string name="const_string_preferences">PANDROID_DATA</string>
|
||||||
|
|
||||||
|
<string name="status_str">Status</string>
|
||||||
|
<string name="setup_str">Setup</string>
|
||||||
<string name="app_name">Pandroid Agent</string>
|
<string name="app_name">Pandroid Agent</string>
|
||||||
<string name="interval">Interval:</string>
|
<string name="interval">Interval:</string>
|
||||||
<string name="update">Update conf.</string>
|
<string name="update">Update conf.</string>
|
||||||
@ -30,4 +32,19 @@
|
|||||||
<string name="correct_update">sucessful update options.</string>
|
<string name="correct_update">sucessful update options.</string>
|
||||||
<string name="task">Task</string>
|
<string name="task">Task</string>
|
||||||
<string name="memory">Memory</string>
|
<string name="memory">Memory</string>
|
||||||
|
<string name="help_label_str">Help</string>
|
||||||
|
<string name="about_label_str">About</string>
|
||||||
|
<string name="licensed_under_gpl_str">Licensed under GPL v2</string>
|
||||||
|
<string name="develop_team_str">Developer: Sergio M. Zarzuelo, Miguel de Dios</string>
|
||||||
|
<string name="pandroid_agent_str">Pandroid Agent</string>
|
||||||
|
<string name="help_str">Help</string>
|
||||||
|
<string name="memory_avaliable_str" formatted="false">Avaliable: %iKb Total: %iKb</string>
|
||||||
|
<string name="never_str">Never.</string>
|
||||||
|
<string name="now_str">Now.</string>
|
||||||
|
<string name="seconds_str">seconds ago.</string>
|
||||||
|
<string name="conctact_error_str">Contact error</string>
|
||||||
|
<string name="last_contact_str">Last Contact:\n</string>
|
||||||
|
<string name="help_text_str">
|
||||||
|
<p>Un texto</p><p>Otro texto<br/><a href="http://google.es">google</a> el <i>texto</i></p>
|
||||||
|
</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
20
pandora_agents/android/src/pandroid/agent/About.java
Normal file
20
pandora_agents/android/src/pandroid/agent/About.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package pandroid.agent;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class About 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());
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ import android.util.Log;
|
|||||||
public class EventReceiver extends BroadcastReceiver {
|
public class EventReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {Log.e("EventReceiver", "onReceive");
|
public void onReceive(Context context, Intent intent) {
|
||||||
context.startService(new Intent(context, PandroidAgentListener.class));
|
context.startService(new Intent(context, PandroidAgentListener.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
21
pandora_agents/android/src/pandroid/agent/Help.java
Normal file
21
pandora_agents/android/src/pandroid/agent/Help.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package pandroid.agent;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class Help extends Activity {
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.help);
|
||||||
|
|
||||||
|
|
||||||
|
TextView text = (TextView) findViewById(R.id.help_text);
|
||||||
|
text.setText(Html.fromHtml(getString(R.string.help_text_str)));
|
||||||
|
text.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
}
|
||||||
|
}
|
@ -71,378 +71,19 @@ public class PandroidAgent extends TabActivity {
|
|||||||
tabHost.addTab
|
tabHost.addTab
|
||||||
(
|
(
|
||||||
tabHost.newTabSpec("Status")
|
tabHost.newTabSpec("Status")
|
||||||
.setIndicator("Status")
|
.setIndicator(getString(R.string.status_str))
|
||||||
.setContent(new Intent(this, Status.class))
|
.setContent(new Intent(this, Status.class))
|
||||||
);
|
);
|
||||||
|
|
||||||
tabHost.addTab
|
tabHost.addTab
|
||||||
(
|
(
|
||||||
tabHost.newTabSpec("Setup")
|
tabHost.newTabSpec("Setup")
|
||||||
.setIndicator("Setup")
|
.setIndicator(getString(R.string.setup_str))
|
||||||
.setContent(new Intent(this, Setup.class))
|
.setContent(new Intent(this, Setup.class))
|
||||||
);
|
);
|
||||||
|
|
||||||
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=45;
|
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height=45;
|
||||||
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height=45;
|
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height=45;
|
||||||
|
|
||||||
if (true) return; //For disable the next code.
|
|
||||||
|
|
||||||
|
|
||||||
this.setContentView(R.layout.main);
|
|
||||||
|
|
||||||
// Customize the agent name with the unique Sim ID
|
|
||||||
defaultAgentName += getSimID();
|
|
||||||
|
|
||||||
// Load the stored data into views
|
|
||||||
loadViews();
|
|
||||||
|
|
||||||
// Set the cleaning returns listener
|
|
||||||
setCleanReturns();
|
|
||||||
|
|
||||||
// Set the button events listener
|
|
||||||
setButtonEvents();
|
|
||||||
|
|
||||||
// Start the agent listener service
|
|
||||||
//ComponentName service = startService(new Intent(this, PandroidAgentListener.class));
|
|
||||||
|
|
||||||
|
|
||||||
if(!alarmEnabled) {
|
|
||||||
// Setting an alarm to call service
|
|
||||||
Intent intentReceiver = new Intent(this, EventReceiver.class);
|
|
||||||
sender = PendingIntent.getBroadcast(this, 0, intentReceiver, 0);
|
|
||||||
|
|
||||||
am = (AlarmManager) getSystemService(ALARM_SERVICE);
|
|
||||||
|
|
||||||
// Start the alert listener
|
|
||||||
restartAgentListener();
|
|
||||||
|
|
||||||
// Update the UI each second
|
|
||||||
h.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
updateUI();
|
|
||||||
|
|
||||||
h.postDelayed(this, 1000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSimID() {
|
|
||||||
String simID = null;
|
|
||||||
String serviceName = Context.TELEPHONY_SERVICE;
|
|
||||||
TelephonyManager m_telephonyManager = (TelephonyManager) getSystemService(serviceName);
|
|
||||||
simID = m_telephonyManager.getSimSerialNumber();
|
|
||||||
return simID;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void putSharedData(String preferenceName, String tokenName, String data, String type) {
|
|
||||||
int mode = Activity.MODE_PRIVATE;
|
|
||||||
SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
|
||||||
SharedPreferences.Editor editor = agentPreferences.edit();
|
|
||||||
|
|
||||||
if(type == "boolean") {
|
|
||||||
editor.putBoolean(tokenName, Boolean.parseBoolean(data));
|
|
||||||
}
|
|
||||||
else if(type == "float") {
|
|
||||||
editor.putFloat(tokenName, Float.parseFloat(data));
|
|
||||||
}
|
|
||||||
else if(type == "integer") {
|
|
||||||
editor.putInt(tokenName, Integer.parseInt(data));
|
|
||||||
}
|
|
||||||
else if(type == "long") {
|
|
||||||
editor.putLong(tokenName, Long.parseLong(data));
|
|
||||||
}
|
|
||||||
else if(type == "string") {
|
|
||||||
editor.putString(tokenName, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSharedData(String preferenceName, String tokenName, String defaultValue, String type) {
|
|
||||||
int mode = Activity.MODE_PRIVATE;
|
|
||||||
SharedPreferences agentPreferences = getSharedPreferences(preferenceName, mode);
|
|
||||||
|
|
||||||
if(type == "boolean") {
|
|
||||||
boolean a = agentPreferences.getBoolean(tokenName, Boolean.parseBoolean(defaultValue));
|
|
||||||
return new Boolean(a).toString();
|
|
||||||
}
|
|
||||||
else if(type == "float") {
|
|
||||||
float a = agentPreferences.getFloat(tokenName, Float.parseFloat(defaultValue));
|
|
||||||
return new Float(a).toString();
|
|
||||||
}
|
|
||||||
else if(type == "integer") {
|
|
||||||
int a = agentPreferences.getInt(tokenName, Integer.parseInt(defaultValue));
|
|
||||||
return new Integer(a).toString();
|
|
||||||
}
|
|
||||||
else if(type == "long") {
|
|
||||||
long a = agentPreferences.getLong(tokenName, Long.parseLong(defaultValue));
|
|
||||||
return new Long(a).toString();
|
|
||||||
}
|
|
||||||
else if(type == "string") {
|
|
||||||
return agentPreferences.getString(tokenName, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCleanReturns() {
|
|
||||||
EditText intervalInput = (EditText) findViewById(R.id.intervalInput);
|
|
||||||
intervalInput.setOnKeyListener(new OnKeyListener() {
|
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
||||||
if(keyCode == 66) {
|
|
||||||
EditText intervalInput = (EditText) findViewById(R.id.intervalInput);
|
|
||||||
if(intervalInput.getText().toString().length() > 0) {
|
|
||||||
intervalInput.setText(intervalInput.getText().toString().replaceAll("[\\r\\n]", ""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
EditText serverAddrInput = (EditText) findViewById(R.id.serverAddrInput);
|
|
||||||
serverAddrInput.setOnKeyListener(new OnKeyListener() {
|
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
||||||
if(keyCode == 66) {
|
|
||||||
EditText serverAddrInput = (EditText) findViewById(R.id.serverAddrInput);
|
|
||||||
if(serverAddrInput.getText().toString().length() > 0) {
|
|
||||||
serverAddrInput.setText(serverAddrInput.getText().toString().replaceAll("[\\r\\n]", ""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
EditText serverPortInput = (EditText) findViewById(R.id.serverPortInput);
|
|
||||||
serverPortInput.setOnKeyListener(new OnKeyListener() {
|
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
||||||
if(keyCode == 66) {
|
|
||||||
EditText serverPortInput = (EditText) findViewById(R.id.serverPortInput);
|
|
||||||
if(serverPortInput.getText().toString().length() > 0) {
|
|
||||||
serverPortInput.setText(serverPortInput.getText().toString().replaceAll("[\\r\\n]", ""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
EditText agentNameInput = (EditText) findViewById(R.id.agentNameInput);
|
|
||||||
agentNameInput.setOnKeyListener(new OnKeyListener() {
|
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
||||||
if(keyCode == 66) {
|
|
||||||
EditText agentNameInput = (EditText) findViewById(R.id.agentNameInput);
|
|
||||||
if(agentNameInput.getText().toString().length() > 0) {
|
|
||||||
agentNameInput.setText(agentNameInput.getText().toString().replaceAll("[\\r\\n]", ""));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setButtonEvents() {
|
|
||||||
// Set update button events
|
|
||||||
Button updateButton = (Button) findViewById(R.id.update);
|
|
||||||
|
|
||||||
updateButton.setOnClickListener(new OnClickListener() {
|
|
||||||
public void onClick(View view) {
|
|
||||||
updateConf();
|
|
||||||
updateUI();
|
|
||||||
restartAgentListener();
|
|
||||||
hideKeyboard();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set reset button events
|
|
||||||
Button resetButton = (Button) findViewById(R.id.reset);
|
|
||||||
|
|
||||||
resetButton.setOnClickListener(new OnClickListener() {
|
|
||||||
public void onClick(View view) {
|
|
||||||
resetValues();
|
|
||||||
loadViews();
|
|
||||||
updateConf();
|
|
||||||
restartAgentListener();
|
|
||||||
hideKeyboard();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set reset button events
|
|
||||||
// Button startStopButton = (Button) findViewById(R.id.starStop);
|
|
||||||
//
|
|
||||||
// startStopButton.setOnClickListener(new OnClickListener() {
|
|
||||||
// public void onClick(View view) {
|
|
||||||
// thread.stop();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetValues() {
|
|
||||||
putSharedData("PANDROID_DATA", "serverAddr", defaultServerAddr, "string");
|
|
||||||
putSharedData("PANDROID_DATA", "serverPort", defaultServerPort, "string");
|
|
||||||
putSharedData("PANDROID_DATA", "interval", Integer.toString(defaultInterval), "integer");
|
|
||||||
putSharedData("PANDROID_DATA", "agentName", defaultAgentName, "string");
|
|
||||||
putSharedData("PANDROID_DATA", "latitude", "181", "float");
|
|
||||||
putSharedData("PANDROID_DATA", "longitude", "181", "float");
|
|
||||||
putSharedData("PANDROID_DATA", "gpsStatus", defaultGpsStatus, "string");
|
|
||||||
putSharedData("PANDROID_DATA", "lastContact", "-1", "long");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateConf() {
|
|
||||||
EditText intervalInput = (EditText) findViewById(R.id.intervalInput);
|
|
||||||
String interval = intervalInput.getText().toString().replace("\n", "");
|
|
||||||
putSharedData("PANDROID_DATA", "interval", interval, "integer");
|
|
||||||
|
|
||||||
EditText serverAddrInput = (EditText) findViewById(R.id.serverAddrInput);
|
|
||||||
String serverAddr = serverAddrInput.getText().toString();
|
|
||||||
putSharedData("PANDROID_DATA", "serverAddr", serverAddr, "string");
|
|
||||||
|
|
||||||
EditText serverPortInput = (EditText) findViewById(R.id.serverPortInput);
|
|
||||||
String serverPort = serverPortInput.getText().toString();
|
|
||||||
putSharedData("PANDROID_DATA", "serverPort", serverPort, "string");
|
|
||||||
|
|
||||||
EditText agentNameInput = (EditText) findViewById(R.id.agentNameInput);
|
|
||||||
String agentName = agentNameInput.getText().toString();
|
|
||||||
putSharedData("PANDROID_DATA", "agentName", agentName, "string");
|
|
||||||
|
|
||||||
CheckBox checkGpsReport = (CheckBox) findViewById(R.id.checkGpsReport);
|
|
||||||
|
|
||||||
if(checkGpsReport.isChecked()) {
|
|
||||||
putSharedData("PANDROID_DATA", "gpsStatus", "enabled", "string");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
putSharedData("PANDROID_DATA", "gpsStatus", "disabled", "string");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void hideKeyboard() {
|
|
||||||
EditText serverAddrInput = (EditText) findViewById(R.id.serverAddrInput);
|
|
||||||
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
imm.hideSoftInputFromWindow(serverAddrInput.getWindowToken(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateUI() {
|
|
||||||
// Update connection data summary
|
|
||||||
updateSummary();
|
|
||||||
|
|
||||||
// Update the last contact info
|
|
||||||
updateLastContactInfo();
|
|
||||||
|
|
||||||
// Update the last XML sended info
|
|
||||||
updateLastXML();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLastXML() {
|
|
||||||
TextView xml = (TextView) this.findViewById(R.id.xml);
|
|
||||||
if(showLastXML) {
|
|
||||||
String lastXML = getSharedData("PANDROID_DATA", "lastXML", "[no data]", "string");
|
|
||||||
xml.setText("Last XML builded: \n\n" + lastXML);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xml.setText("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stopAgentListener() {
|
|
||||||
am.cancel(sender);
|
|
||||||
alarmEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startAgentListener() {
|
|
||||||
alarmEnabled = true;
|
|
||||||
|
|
||||||
int interval = Integer.parseInt(getSharedData("PANDROID_DATA", "interval", Integer.toString(defaultInterval), "integer"));
|
|
||||||
|
|
||||||
// Set the alarm with the interval frequency
|
|
||||||
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (interval * 1000), sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void restartAgentListener() {
|
|
||||||
stopAgentListener();
|
|
||||||
startAgentListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLastContactInfo() {
|
|
||||||
//putSharedData("PANDROID_DATA", "lastContact", "-1", "long");
|
|
||||||
long lastContact = Long.parseLong(getSharedData("PANDROID_DATA", "lastContact", "-1", "long"));
|
|
||||||
int contactError = Integer.parseInt(getSharedData("PANDROID_DATA", "contactError", "0", "integer"));
|
|
||||||
|
|
||||||
Date date = new Date();
|
|
||||||
long timestamp = date.getTime() / 1000;
|
|
||||||
long timeAgo = -1;
|
|
||||||
if(lastContact != -1){
|
|
||||||
timeAgo = timestamp - lastContact;
|
|
||||||
}
|
|
||||||
|
|
||||||
int interval = Integer.parseInt(getSharedData("PANDROID_DATA", "interval", Integer.toString(defaultInterval), "integer"));
|
|
||||||
|
|
||||||
if(timeAgo >= interval) {
|
|
||||||
timeAgo = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
String stringAgo = "";
|
|
||||||
|
|
||||||
if(lastContact == -1) {
|
|
||||||
stringAgo = "Never.";
|
|
||||||
}
|
|
||||||
else if(timeAgo == 0) {
|
|
||||||
stringAgo = "Now.";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stringAgo = timeAgo + " seconds ago.";
|
|
||||||
}
|
|
||||||
|
|
||||||
if(contactError == 1) {
|
|
||||||
changeContactInfo("Contact error", "#FF0000");
|
|
||||||
stopAgentListener();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
changeContactInfo("Last Contact: " + stringAgo, "#00FF00");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeContactInfo(String msg, String colorCode) {
|
|
||||||
TextView lastContactInfo = (TextView) this.findViewById(R.id.lastContactInfo);
|
|
||||||
lastContactInfo.setTextColor(Color.parseColor(colorCode));
|
|
||||||
lastContactInfo.setText(msg);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSummary() {
|
|
||||||
String serverAddr = getSharedData("PANDROID_DATA", "serverAddr", "[no data]", "string");
|
|
||||||
String serverPort = getSharedData("PANDROID_DATA", "serverPort", "[no data]", "string");
|
|
||||||
String interval = getSharedData("PANDROID_DATA", "interval", "300", "integer");
|
|
||||||
String agentName = getSharedData("PANDROID_DATA", "agentName", "[no data]", "string");
|
|
||||||
String gpsStatus = getSharedData("PANDROID_DATA", "gpsStatus", "[no data]", "string");
|
|
||||||
|
|
||||||
// Update the connection summary
|
|
||||||
TextView summary = (TextView) this.findViewById(R.id.fieldSummary);
|
|
||||||
summary.setText("Server: " + serverAddr + "\nPort: " + serverPort + "\nInterval: " + interval + " seconds\nAgent name: " + agentName + "\nGPS Report: " + gpsStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadViews(){
|
|
||||||
// Init form values
|
|
||||||
EditText serverAddrInput = (EditText) findViewById(R.id.serverAddrInput);
|
|
||||||
serverAddrInput.setText(getSharedData("PANDROID_DATA", "serverAddr", defaultServerAddr, "string"));
|
|
||||||
|
|
||||||
EditText serverPortInput = (EditText) findViewById(R.id.serverPortInput);
|
|
||||||
serverPortInput.setText(getSharedData("PANDROID_DATA", "serverPort", defaultServerPort, "string"));
|
|
||||||
|
|
||||||
EditText intervalInput = (EditText) findViewById(R.id.intervalInput);
|
|
||||||
int interval = Integer.parseInt(getSharedData("PANDROID_DATA", "interval", Integer.toString(defaultInterval), "integer"));
|
|
||||||
intervalInput.setText(Integer.toString(interval));
|
|
||||||
|
|
||||||
EditText agentNameInput = (EditText) findViewById(R.id.agentNameInput);
|
|
||||||
agentNameInput.setText(getSharedData("PANDROID_DATA", "agentName", defaultAgentName, "string"));
|
|
||||||
|
|
||||||
CheckBox checkGpsReport = (CheckBox) findViewById(R.id.checkGpsReport);
|
|
||||||
|
|
||||||
String gpsStatus = getSharedData("PANDROID_DATA", "gpsStatus", defaultGpsStatus, "string");
|
|
||||||
boolean gpsEnabled = gpsStatus.equals("enabled");
|
|
||||||
checkGpsReport.setChecked(gpsEnabled);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -76,8 +76,6 @@ public class PandroidAgentListener extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.e("PandroidAgentListener", "onStartCommand");
|
|
||||||
|
|
||||||
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
|
WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock");
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
@ -167,7 +165,7 @@ public class PandroidAgentListener extends Service {
|
|||||||
String taskRun = getSharedData("PANDROID_DATA", "taskRun", "false", "string");
|
String taskRun = getSharedData("PANDROID_DATA", "taskRun", "false", "string");
|
||||||
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
|
String taskHumanName = getSharedData("PANDROID_DATA", "taskHumanName", "", "string");
|
||||||
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
|
taskHumanName = StringEscapeUtils.escapeHtml4(taskHumanName);
|
||||||
Log.e("taskHumanName", taskHumanName);
|
|
||||||
String task = getSharedData("PANDROID_DATA", "task", "", "string");
|
String task = getSharedData("PANDROID_DATA", "task", "", "string");
|
||||||
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", defaultMemoryStatus, "string");
|
String memoryStatus = getSharedData("PANDROID_DATA", "memoryStatus", defaultMemoryStatus, "string");
|
||||||
String availableRamKb = getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
|
String availableRamKb = getSharedData("PANDROID_DATA", "availableRamKb", "0" , "long");
|
||||||
@ -289,7 +287,13 @@ public class PandroidAgentListener extends Service {
|
|||||||
private void batteryLevel() {
|
private void batteryLevel() {
|
||||||
BroadcastReceiver batteryLevelReceiver = new BroadcastReceiver() {
|
BroadcastReceiver batteryLevelReceiver = new BroadcastReceiver() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
context.unregisterReceiver(this);
|
try {
|
||||||
|
context.unregisterReceiver(this);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e) {
|
||||||
|
//None
|
||||||
|
}
|
||||||
|
|
||||||
int rawlevel = intent.getIntExtra("level", -1);
|
int rawlevel = intent.getIntExtra("level", -1);
|
||||||
int scale = intent.getIntExtra("scale", -1);
|
int scale = intent.getIntExtra("scale", -1);
|
||||||
if (rawlevel >= 0 && scale > 0) {
|
if (rawlevel >= 0 && scale > 0) {
|
||||||
@ -302,7 +306,6 @@ public class PandroidAgentListener extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sensors() {
|
private void sensors() {
|
||||||
|
|
||||||
// Sensor listeners
|
// Sensor listeners
|
||||||
|
|
||||||
SensorEventListener orientationLevelReceiver = new SensorEventListener() {
|
SensorEventListener orientationLevelReceiver = new SensorEventListener() {
|
||||||
@ -346,14 +349,17 @@ public class PandroidAgentListener extends Service {
|
|||||||
sensorManager.registerListener(
|
sensorManager.registerListener(
|
||||||
orientationLevelReceiver,
|
orientationLevelReceiver,
|
||||||
orientSensor,
|
orientSensor,
|
||||||
SensorManager.SENSOR_DELAY_UI );
|
(20));
|
||||||
|
//SensorManager.SENSOR_DELAY_UI );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( proxSensor != null ) {
|
if( proxSensor != null ) {
|
||||||
sensorManager.registerListener(
|
sensorManager.registerListener(
|
||||||
proximityLevelReceiver,
|
proximityLevelReceiver,
|
||||||
proxSensor,
|
proxSensor,
|
||||||
SensorManager.SENSOR_DELAY_UI );
|
//(defaultInterval * 1000000));
|
||||||
|
(20));
|
||||||
|
//SensorManager.SENSOR_DELAY_UI );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,8 +375,8 @@ public class PandroidAgentListener extends Service {
|
|||||||
putSharedData("PANDROID_DATA", "longitude", "181.0", "float");
|
putSharedData("PANDROID_DATA", "longitude", "181.0", "float");
|
||||||
}
|
}
|
||||||
|
|
||||||
sensors();
|
//sensors();
|
||||||
getTaskStatus();
|
//getTaskStatus();
|
||||||
getMemoryStatus();
|
getMemoryStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,10 +7,14 @@ import java.util.List;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManager.RunningAppProcessInfo;
|
import android.app.ActivityManager.RunningAppProcessInfo;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
@ -37,10 +41,34 @@ public class Setup extends Activity {
|
|||||||
|
|
||||||
Core.loadConf(getApplicationContext());
|
Core.loadConf(getApplicationContext());
|
||||||
loadViews();
|
loadViews();
|
||||||
loadInBackgroundProcessInExecution();
|
//loadInBackgroundProcessInExecution();
|
||||||
setButtonEvents();
|
setButtonEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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.help_button_menu_options:
|
||||||
|
i = new Intent(this, Help.class);
|
||||||
|
startActivity(i);
|
||||||
|
break;
|
||||||
|
case R.id.about_button_menu_options:
|
||||||
|
i = new Intent(this, About.class);
|
||||||
|
startActivity(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void setButtonEvents() {
|
private void setButtonEvents() {
|
||||||
// Set update button events
|
// Set update button events
|
||||||
Button updateButton = (Button) findViewById(R.id.update);
|
Button updateButton = (Button) findViewById(R.id.update);
|
||||||
@ -107,6 +135,7 @@ public class Setup extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void unused)
|
protected void onPostExecute(Void unused)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
Spinner combo = (Spinner)findViewById(R.id.processes_combo);
|
Spinner combo = (Spinner)findViewById(R.id.processes_combo);
|
||||||
ArrayList<String> listProcess = new ArrayList<String>(listProcesses.keySet());
|
ArrayList<String> listProcess = new ArrayList<String>(listProcesses.keySet());
|
||||||
ArrayList<String> listProcessHuman = new ArrayList<String>(listProcesses.values());
|
ArrayList<String> listProcessHuman = new ArrayList<String>(listProcesses.values());
|
||||||
@ -148,6 +177,7 @@ public class Setup extends Activity {
|
|||||||
|
|
||||||
Button button = (Button)findViewById(R.id.update);
|
Button button = (Button)findViewById(R.id.update);
|
||||||
button.setEnabled(true);
|
button.setEnabled(true);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -182,6 +212,7 @@ public class Setup extends Activity {
|
|||||||
else
|
else
|
||||||
Core.memoryStatus = "disabled";
|
Core.memoryStatus = "disabled";
|
||||||
|
|
||||||
|
/*
|
||||||
checkBox = (CheckBox) findViewById(R.id.checkTaskReport);
|
checkBox = (CheckBox) findViewById(R.id.checkTaskReport);
|
||||||
if (checkBox.isChecked()) {
|
if (checkBox.isChecked()) {
|
||||||
Core.taskStatus = "enabled";
|
Core.taskStatus = "enabled";
|
||||||
@ -198,6 +229,7 @@ public class Setup extends Activity {
|
|||||||
Core.task = "";
|
Core.task = "";
|
||||||
Core.taskHumanName = "";
|
Core.taskHumanName = "";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadViews(){
|
private void loadViews(){
|
||||||
@ -222,8 +254,9 @@ public class Setup extends Activity {
|
|||||||
|
|
||||||
checkBox = (CheckBox) findViewById(R.id.checkMemoryReport);
|
checkBox = (CheckBox) findViewById(R.id.checkMemoryReport);
|
||||||
checkBox.setChecked(Core.memoryStatus.equals("enabled"));
|
checkBox.setChecked(Core.memoryStatus.equals("enabled"));
|
||||||
|
/*
|
||||||
checkBox = (CheckBox) findViewById(R.id.checkTaskReport);
|
checkBox = (CheckBox) findViewById(R.id.checkTaskReport);
|
||||||
checkBox.setChecked(Core.taskStatus.equals("enabled"));
|
checkBox.setChecked(Core.taskStatus.equals("enabled"));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,13 @@ package pandroid.agent;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.SharedPreferences;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.MenuInflater;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.MenuItem;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class Status extends Activity {
|
public class Status extends Activity {
|
||||||
@ -25,7 +24,6 @@ public class Status extends Activity {
|
|||||||
Core.loadLastValues(getApplicationContext());
|
Core.loadLastValues(getApplicationContext());
|
||||||
showLastValues();
|
showLastValues();
|
||||||
updateLastContactInfo();
|
updateLastContactInfo();
|
||||||
setButtonEvents();
|
|
||||||
|
|
||||||
// Update the UI each second
|
// Update the UI each second
|
||||||
h.post(new Runnable() {
|
h.post(new Runnable() {
|
||||||
@ -40,20 +38,29 @@ public class Status extends Activity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setButtonEvents() {
|
//For options
|
||||||
// Set update button events
|
@Override
|
||||||
/*
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
Button getButton = (Button) findViewById(R.id.get_xml);
|
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.help_button_menu_options:
|
||||||
|
i = new Intent(this, Help.class);
|
||||||
|
startActivity(i);
|
||||||
|
break;
|
||||||
|
case R.id.about_button_menu_options:
|
||||||
|
i = new Intent(this, About.class);
|
||||||
|
startActivity(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
getButton.setOnClickListener(new OnClickListener() {
|
return true;
|
||||||
public void onClick(View view) {
|
}
|
||||||
updateLastXML();
|
|
||||||
showLastValues();
|
|
||||||
updateLastContactInfo();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLastXML() {
|
private void updateLastXML() {
|
||||||
/*
|
/*
|
||||||
@ -72,7 +79,6 @@ public class Status extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLastContactInfo() {
|
private void updateLastContactInfo() {
|
||||||
//putSharedData("PANDROID_DATA", "lastContact", "-1", "long");
|
|
||||||
long lastContact = Core.lastContact;
|
long lastContact = Core.lastContact;
|
||||||
int contactError = Core.contactError;
|
int contactError = Core.contactError;
|
||||||
|
|
||||||
@ -92,25 +98,25 @@ public class Status extends Activity {
|
|||||||
String stringAgo = "";
|
String stringAgo = "";
|
||||||
|
|
||||||
if(lastContact == -1) {
|
if(lastContact == -1) {
|
||||||
stringAgo = "Never.";
|
stringAgo = getString(R.string.never_str);
|
||||||
}
|
}
|
||||||
else if(timeAgo == 0) {
|
else if(timeAgo == 0) {
|
||||||
stringAgo = "Now.";
|
stringAgo = getString(R.string.now_str);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stringAgo = timeAgo + " seconds ago.";
|
stringAgo = timeAgo + " " + getString(R.string.seconds_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(contactError == 1) {
|
if(contactError == 1) {
|
||||||
TextView lastContactInfo = (TextView) this.findViewById(R.id.lastContactInfo_label_str);
|
TextView lastContactInfo = (TextView) this.findViewById(R.id.lastContactInfo_label_str);
|
||||||
lastContactInfo.setTextColor(Color.parseColor("#FF0000"));
|
lastContactInfo.setTextColor(Color.parseColor("#FF0000"));
|
||||||
lastContactInfo.setText("Contact error");
|
lastContactInfo.setText(getString(R.string.conctact_error_str));
|
||||||
//stopAgentListener();
|
//stopAgentListener();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TextView lastContactInfo = (TextView) this.findViewById(R.id.lastContactInfo_label_str);
|
TextView lastContactInfo = (TextView) this.findViewById(R.id.lastContactInfo_label_str);
|
||||||
lastContactInfo.setTextColor(Color.parseColor("#00FF00"));
|
lastContactInfo.setTextColor(Color.parseColor("#00FF00"));
|
||||||
lastContactInfo.setText("Last Contact:\n" + stringAgo);
|
lastContactInfo.setText(getString(R.string.last_contact_str) + stringAgo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +138,7 @@ public class Status extends Activity {
|
|||||||
if (Core.batteryLevel != Core.CONST_INVALID_BATTERY_LEVEL) {
|
if (Core.batteryLevel != Core.CONST_INVALID_BATTERY_LEVEL) {
|
||||||
textView.setText("" + Core.batteryLevel);
|
textView.setText("" + Core.batteryLevel);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
textView = (TextView)findViewById(R.id.orientation_value_str);
|
textView = (TextView)findViewById(R.id.orientation_value_str);
|
||||||
textView.setText("");
|
textView.setText("");
|
||||||
|
|
||||||
@ -145,7 +151,9 @@ public class Status extends Activity {
|
|||||||
if (Core.proximity != Core.CONST_INVALID_PROXIMITY) {
|
if (Core.proximity != Core.CONST_INVALID_PROXIMITY) {
|
||||||
textView.setText("" + Core.proximity);
|
textView.setText("" + Core.proximity);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
textView = (TextView)findViewById(R.id.task_value_str);
|
textView = (TextView)findViewById(R.id.task_value_str);
|
||||||
textView.setText("");
|
textView.setText("");
|
||||||
if (Core.taskStatus.equals("enabled") && Core.taskHumanName.length() != 0) {
|
if (Core.taskStatus.equals("enabled") && Core.taskHumanName.length() != 0) {
|
||||||
@ -158,16 +166,15 @@ public class Status extends Activity {
|
|||||||
}
|
}
|
||||||
textView.setText(text);
|
textView.setText(text);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
textView = (TextView)findViewById(R.id.memory_value_str);
|
textView = (TextView)findViewById(R.id.memory_value_str);
|
||||||
textView.setText("");
|
textView.setText("");
|
||||||
if (Core.memoryStatus.equals("enabled")) {
|
if (Core.memoryStatus.equals("enabled")) {
|
||||||
textView.setText("Avaliable: " + Core.availableRamKb + "Kb Total: " + Core.totalRamKb + "Kb");
|
String textMemory = getString(R.string.memory_avaliable_str);
|
||||||
}
|
textMemory = textMemory.replaceFirst("%i", "" + Core.availableRamKb);
|
||||||
|
textMemory = textMemory.replaceFirst("%i", "" + Core.totalRamKb);
|
||||||
textView = (TextView)findViewById(R.id.proximity_value_str);
|
textView.setText(textMemory);
|
||||||
if (Core.proximity != Core.CONST_INVALID_PROXIMITY) {
|
|
||||||
textView.setText("" + Core.proximity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user