Updated ACRA library (crash reports via e-mail). Fixed bug in action bar commands...
authorMarco Incalcaterra <marco.incalcaterra@thinksoft.it>
Wed, 6 Jan 2016 16:25:06 +0000 (17:25 +0100)
committerMarco Incalcaterra <marco.incalcaterra@thinksoft.it>
Wed, 6 Jan 2016 16:25:06 +0000 (17:25 +0100)
41 files changed:
ChangeLog
android/src/agent/.classpath
android/src/agent/libs/acra-4.4.0.jar [deleted file]
android/src/agent/res/drawable-hdpi/ic_menu_preferences.png [deleted file]
android/src/agent/res/drawable-ldpi/ic_menu_preferences.png [deleted file]
android/src/agent/res/drawable-mdpi/ic_menu_preferences.png [deleted file]
android/src/agent/res/menu-v11/main_menu.xml [copied from android/src/agent/res/menu/main_menu.xml with 79% similarity]
android/src/agent/res/menu/main_menu.xml
android/src/agent/res/values/strings.xml
android/src/agent/src/org/netxms/agent/android/NXApplication.java
android/src/console/.classpath
android/src/console/libs/acra-4.4.0.jar [deleted file]
android/src/console/res/drawable-hdpi/ic_menu_preferences.png [deleted file]
android/src/console/res/drawable-ldpi-v11/ic_stat_connected.png [deleted file]
android/src/console/res/drawable-ldpi-v11/ic_stat_disconnected.png [deleted file]
android/src/console/res/drawable-ldpi-v9/ic_stat_connected.png [deleted file]
android/src/console/res/drawable-ldpi-v9/ic_stat_disconnected.png [deleted file]
android/src/console/res/drawable-ldpi/alarms.png [deleted file]
android/src/console/res/drawable-ldpi/entire_network.png [deleted file]
android/src/console/res/drawable-ldpi/graphs.png [deleted file]
android/src/console/res/drawable-ldpi/ic_menu_preferences.png [deleted file]
android/src/console/res/drawable-ldpi/ic_stat_connected.png [deleted file]
android/src/console/res/drawable-ldpi/ic_stat_disconnected.png [deleted file]
android/src/console/res/drawable-ldpi/icon.png [deleted file]
android/src/console/res/drawable-ldpi/macaddress.png [deleted file]
android/src/console/res/drawable-ldpi/nodes.png [deleted file]
android/src/console/res/drawable-mdpi-v9/ic_stat_connected.png [deleted file]
android/src/console/res/drawable-mdpi-v9/ic_stat_disconnected.png [deleted file]
android/src/console/res/drawable-mdpi/ic_menu_preferences.png [deleted file]
android/src/console/res/drawable-xhdpi-v9/ic_stat_connected.png [deleted file]
android/src/console/res/drawable-xhdpi-v9/ic_stat_disconnected.png [deleted file]
android/src/console/res/drawable-xhdpi/ic_menu_preferences.png [deleted file]
android/src/console/res/menu-v11/main_menu.xml
android/src/console/res/menu/main_menu.xml
android/src/console/res/values/strings.xml
android/src/console/src/org/netxms/ui/android/NXApplication.java
android/src/console/src/org/netxms/ui/android/helpers/Multipliers.java
android/src/console/src/org/netxms/ui/android/main/activities/HomeScreen.java
android/src/console/src/org/netxms/ui/android/main/adapters/InterfacesAdapter.java
android/src/console/src/org/netxms/ui/android/receivers/ConnectivityChangeIntentReceiver.java
android/src/console/src/org/netxms/ui/android/service/ClientConnectorService.java

index 090459c..78f13ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 * 2.0.2
 *
 
+- Android Console:
+       - Updated ACRA library: now crash reports are sent via e-mail (will use the app installed on device to send mail)
+       - Fixed bug in action bar commands: disconnect and exit sometimes wasn't working
+- Android Agent:
+       - Updated ACRA library: now crash reports are sent via e-mail (will use the app installed on device to send mail)
 - Fixed issues: #1042, #1049
 
 *
index b244194..58f6708 100644 (file)
@@ -3,11 +3,11 @@
        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
-       <classpathentry kind="lib" path="libs/acra-4.4.0.jar"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
        <classpathentry kind="lib" path="libs/android-support-v4.jar"/>
        <classpathentry kind="lib" path="libs/netxms-base-2.0.1.jar"/>
        <classpathentry kind="lib" path="libs/netxms-mobile-agent-2.0.1.jar"/>
+       <classpathentry kind="lib" path="libs/acra-4.7.0.jar"/>
        <classpathentry kind="output" path="bin/classes"/>
 </classpath>
diff --git a/android/src/agent/libs/acra-4.4.0.jar b/android/src/agent/libs/acra-4.4.0.jar
deleted file mode 100644 (file)
index 27fdae4..0000000
Binary files a/android/src/agent/libs/acra-4.4.0.jar and /dev/null differ
diff --git a/android/src/agent/res/drawable-hdpi/ic_menu_preferences.png b/android/src/agent/res/drawable-hdpi/ic_menu_preferences.png
deleted file mode 100644 (file)
index 81bca4a..0000000
Binary files a/android/src/agent/res/drawable-hdpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/src/agent/res/drawable-ldpi/ic_menu_preferences.png b/android/src/agent/res/drawable-ldpi/ic_menu_preferences.png
deleted file mode 100644 (file)
index 19f3c15..0000000
Binary files a/android/src/agent/res/drawable-ldpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/src/agent/res/drawable-mdpi/ic_menu_preferences.png b/android/src/agent/res/drawable-mdpi/ic_menu_preferences.png
deleted file mode 100644 (file)
index 60dbff6..0000000
Binary files a/android/src/agent/res/drawable-mdpi/ic_menu_preferences.png and /dev/null differ
@@ -2,5 +2,5 @@
 <menu
   xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:enabled="true" android:id="@android:id/home" android:title="@string/home" android:visible="true" android:checkable="false" android:checked="false" android:icon="@android:drawable/ic_menu_myplaces" android:showAsAction="ifRoom"></item>
-    <item android:enabled="true" android:id="@+id/settings" android:title="@string/settings" android:visible="true" android:checkable="false" android:checked="false" android:icon="@drawable/ic_menu_preferences" android:showAsAction="ifRoom"></item>
+    <item android:enabled="true" android:id="@+id/settings" android:title="@string/settings" android:visible="true" android:checkable="false" android:checked="false" android:icon="@android:drawable/ic_menu_preferences" android:showAsAction="ifRoom"></item>
 </menu>
index 2b272ef..c695b7d 100644 (file)
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu
   xmlns:android="http://schemas.android.com/apk/res/android">
-       <item android:enabled="true" android:id="@android:id/home" android:title="@string/home" android:visible="true" android:checkable="false" android:checked="false" android:icon="@android:drawable/ic_menu_myplaces" android:showAsAction="ifRoom"></item>
-    <item android:enabled="true" android:id="@+id/settings" android:title="@string/settings" android:visible="true" android:checkable="false" android:checked="false" android:icon="@drawable/ic_menu_preferences" android:showAsAction="ifRoom"></item>
+    <item android:enabled="true" android:id="@+id/settings" android:title="@string/settings" android:visible="true" android:checkable="false" android:checked="false" android:icon="@android:drawable/ic_menu_preferences"></item>
 </menu>
index 69667f4..f76b2d2 100644 (file)
@@ -7,7 +7,8 @@
        <string name="version">Version</string>
        <string name="reconnect">Reconnect</string>
        <string name="ok">OK</string>
-                       
+       <string name="crash_toast_text">NetXMS Agent crashed and needs to send a report to developers</string>
+                               
        <string name="main_title">Home</string>
        <string name="home">Home</string>
                        
index 6b2da23..06d04b1 100644 (file)
@@ -1,11 +1,17 @@
 package org.netxms.agent.android;
 
 import org.acra.ACRA;
+import org.acra.ReportField;
+import org.acra.ReportingInteractionMode;
 import org.acra.annotation.ReportsCrashes;
 
 import android.app.Application;
 
-@ReportsCrashes(formKey = "dGJ5RFRpbmg2ZVRvT2tERU9seHVlTWc6MQ")
+@ReportsCrashes(
+               mailTo = "acra@netxms.org",
+               customReportContent = { ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT },
+               mode = ReportingInteractionMode.TOAST,
+               resToastText = R.string.crash_toast_text)
 public class NXApplication extends Application
 {
        private static boolean activityVisible;
index bc6659b..6751c46 100644 (file)
@@ -6,10 +6,10 @@
        <classpathentry exported="true" kind="lib" path="libs/simple-xml-2.6.4.jar"/>
        <classpathentry exported="true" kind="lib" path="libs/achartengine-1.0.0.jar"/>
        <classpathentry kind="lib" path="libs/android-support-v4.jar"/>
-       <classpathentry kind="lib" path="libs/acra-4.4.0.jar"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
        <classpathentry kind="lib" path="libs/netxms-base-2.0.1.jar"/>
        <classpathentry kind="lib" path="libs/netxms-client-2.0.1.jar"/>
+       <classpathentry kind="lib" path="libs/acra-4.7.0.jar"/>
        <classpathentry kind="output" path="bin/classes"/>
 </classpath>
diff --git a/android/src/console/libs/acra-4.4.0.jar b/android/src/console/libs/acra-4.4.0.jar
deleted file mode 100644 (file)
index 27fdae4..0000000
Binary files a/android/src/console/libs/acra-4.4.0.jar and /dev/null differ
diff --git a/android/src/console/res/drawable-hdpi/ic_menu_preferences.png b/android/src/console/res/drawable-hdpi/ic_menu_preferences.png
deleted file mode 100644 (file)
index 81bca4a..0000000
Binary files a/android/src/console/res/drawable-hdpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi-v11/ic_stat_connected.png b/android/src/console/res/drawable-ldpi-v11/ic_stat_connected.png
deleted file mode 100644 (file)
index 2017fe8..0000000
Binary files a/android/src/console/res/drawable-ldpi-v11/ic_stat_connected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi-v11/ic_stat_disconnected.png b/android/src/console/res/drawable-ldpi-v11/ic_stat_disconnected.png
deleted file mode 100644 (file)
index 847b664..0000000
Binary files a/android/src/console/res/drawable-ldpi-v11/ic_stat_disconnected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi-v9/ic_stat_connected.png b/android/src/console/res/drawable-ldpi-v9/ic_stat_connected.png
deleted file mode 100644 (file)
index e99bd7e..0000000
Binary files a/android/src/console/res/drawable-ldpi-v9/ic_stat_connected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi-v9/ic_stat_disconnected.png b/android/src/console/res/drawable-ldpi-v9/ic_stat_disconnected.png
deleted file mode 100644 (file)
index 1764b24..0000000
Binary files a/android/src/console/res/drawable-ldpi-v9/ic_stat_disconnected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/alarms.png b/android/src/console/res/drawable-ldpi/alarms.png
deleted file mode 100644 (file)
index 8c0d646..0000000
Binary files a/android/src/console/res/drawable-ldpi/alarms.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/entire_network.png b/android/src/console/res/drawable-ldpi/entire_network.png
deleted file mode 100644 (file)
index b4e6a22..0000000
Binary files a/android/src/console/res/drawable-ldpi/entire_network.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/graphs.png b/android/src/console/res/drawable-ldpi/graphs.png
deleted file mode 100644 (file)
index 2c7faa4..0000000
Binary files a/android/src/console/res/drawable-ldpi/graphs.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/ic_menu_preferences.png b/android/src/console/res/drawable-ldpi/ic_menu_preferences.png
deleted file mode 100644 (file)
index 19f3c15..0000000
Binary files a/android/src/console/res/drawable-ldpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/ic_stat_connected.png b/android/src/console/res/drawable-ldpi/ic_stat_connected.png
deleted file mode 100644 (file)
index 7b757b3..0000000
Binary files a/android/src/console/res/drawable-ldpi/ic_stat_connected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/ic_stat_disconnected.png b/android/src/console/res/drawable-ldpi/ic_stat_disconnected.png
deleted file mode 100644 (file)
index 7b4fce8..0000000
Binary files a/android/src/console/res/drawable-ldpi/ic_stat_disconnected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/icon.png b/android/src/console/res/drawable-ldpi/icon.png
deleted file mode 100644 (file)
index b70dafd..0000000
Binary files a/android/src/console/res/drawable-ldpi/icon.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/macaddress.png b/android/src/console/res/drawable-ldpi/macaddress.png
deleted file mode 100644 (file)
index e5473df..0000000
Binary files a/android/src/console/res/drawable-ldpi/macaddress.png and /dev/null differ
diff --git a/android/src/console/res/drawable-ldpi/nodes.png b/android/src/console/res/drawable-ldpi/nodes.png
deleted file mode 100644 (file)
index bcfb6ac..0000000
Binary files a/android/src/console/res/drawable-ldpi/nodes.png and /dev/null differ
diff --git a/android/src/console/res/drawable-mdpi-v9/ic_stat_connected.png b/android/src/console/res/drawable-mdpi-v9/ic_stat_connected.png
deleted file mode 100644 (file)
index 3bad642..0000000
Binary files a/android/src/console/res/drawable-mdpi-v9/ic_stat_connected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-mdpi-v9/ic_stat_disconnected.png b/android/src/console/res/drawable-mdpi-v9/ic_stat_disconnected.png
deleted file mode 100644 (file)
index 30a1a6d..0000000
Binary files a/android/src/console/res/drawable-mdpi-v9/ic_stat_disconnected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-mdpi/ic_menu_preferences.png b/android/src/console/res/drawable-mdpi/ic_menu_preferences.png
deleted file mode 100644 (file)
index 60dbff6..0000000
Binary files a/android/src/console/res/drawable-mdpi/ic_menu_preferences.png and /dev/null differ
diff --git a/android/src/console/res/drawable-xhdpi-v9/ic_stat_connected.png b/android/src/console/res/drawable-xhdpi-v9/ic_stat_connected.png
deleted file mode 100644 (file)
index b64e7d5..0000000
Binary files a/android/src/console/res/drawable-xhdpi-v9/ic_stat_connected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-xhdpi-v9/ic_stat_disconnected.png b/android/src/console/res/drawable-xhdpi-v9/ic_stat_disconnected.png
deleted file mode 100644 (file)
index a09042f..0000000
Binary files a/android/src/console/res/drawable-xhdpi-v9/ic_stat_disconnected.png and /dev/null differ
diff --git a/android/src/console/res/drawable-xhdpi/ic_menu_preferences.png b/android/src/console/res/drawable-xhdpi/ic_menu_preferences.png
deleted file mode 100644 (file)
index dae6f14..0000000
Binary files a/android/src/console/res/drawable-xhdpi/ic_menu_preferences.png and /dev/null differ
index 453c6ff..fc0e6b0 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu
   xmlns:android="http://schemas.android.com/apk/res/android">
-       <item android:enabled="true" android:id="@+id/settings" android:title="@string/settings" android:visible="true" android:checkable="false" android:checked="false" android:icon="@drawable/ic_menu_preferences" android:showAsAction="ifRoom"></item>
+       <item android:enabled="true" android:id="@+id/settings" android:title="@string/settings" android:visible="true" android:checkable="false" android:checked="false" android:icon="@android:drawable/ic_menu_preferences" android:showAsAction="ifRoom"></item>
 </menu>
index 7349507..c49bba1 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
        <item android:enabled="true" android:id="@android:id/home" android:title="@string/home" android:visible="true" android:checkable="false" android:checked="false" android:icon="@android:drawable/ic_menu_myplaces" android:showAsAction="ifRoom" tools:targetApi="11"></item>
-    <item android:enabled="true" android:id="@+id/settings" android:title="@string/settings" android:visible="true" android:checkable="false" android:checked="false" android:icon="@drawable/ic_menu_preferences" android:showAsAction="ifRoom"></item>
+    <item android:enabled="true" android:id="@+id/settings" android:title="@string/settings" android:visible="true" android:checkable="false" android:checked="false" android:icon="@android:drawable/ic_menu_preferences"></item>
 </menu>
index 212c608..197b68e 100644 (file)
@@ -15,6 +15,7 @@
        <string name="no_items">No items to show&#8230;</string>
        <string name="warning">Warning</string>
        <string name="long_time_execution">This task could take a long time to execute. Would you like to proceed anyway?</string>
+       <string name="crash_toast_text">NetXMS Client crashed and needs to send a report to developers</string>
                                                
        <string name="progress_gathering_data">Gathering data&#8230;</string>
        <string name="progress_processing_data">Processing data&#8230;</string>
index 0f2764e..485d1b2 100644 (file)
@@ -1,11 +1,17 @@
 package org.netxms.ui.android;
 
 import org.acra.ACRA;
+import org.acra.ReportField;
+import org.acra.ReportingInteractionMode;
 import org.acra.annotation.ReportsCrashes;
 
 import android.app.Application;
 
-@ReportsCrashes(formKey = "dEhRMG50MjhWTXBWSU5jaDVubzlxT1E6MQ")
+@ReportsCrashes(
+               mailTo = "acra@netxms.org",
+               customReportContent = { ReportField.APP_VERSION_CODE, ReportField.APP_VERSION_NAME, ReportField.ANDROID_VERSION, ReportField.PHONE_MODEL, ReportField.CUSTOM_DATA, ReportField.STACK_TRACE, ReportField.LOGCAT },
+               mode = ReportingInteractionMode.TOAST,
+               resToastText = R.string.crash_toast_text)
 public class NXApplication extends Application
 {
        private static boolean activityVisible;
index 81e0879..59ffed6 100644 (file)
@@ -20,8 +20,7 @@ public class Multipliers
 
        static public String getLabel(int type, int mul)
        {
-               String labels[][] =
-               {
+               String labels[][] = {
                                { "", "", "", "", "", "", "", "" }, // No multiplier
                                { "K", "M", "G", "T", "P", "E", "Z", "Y" }, // Decimal multiplier
                                { "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" } // Binary multiplier
@@ -31,8 +30,7 @@ public class Multipliers
 
        static public double getValue(int type, int mul)
        {
-               double values[][] =
-               {
+               double values[][] = {
                                { 1, 1, 1, 1, 1, 1, 1, 1 },
                                { 1E3, 1E6, 1E9, 1E12, 1E15, 1E18, 1E21, 1E24 },
                                {
@@ -43,9 +41,10 @@ public class Multipliers
                                                1024. * 1024 * 1024 * 1024 * 1024,
                                                1024. * 1024 * 1024 * 1024 * 1024 * 1024,
                                                1024. * 1024 * 1024 * 1024 * 1024 * 1024 * 1024,
-                                               1024. * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024
-                               },
-               };
-               return values[type][mul];
+                                               1024. * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 }, };
+               if (type > 0 && type < values.length && mul > 0 && mul < values[type].length)
+                       return values[type][mul];
+               else
+                       return 1;
        }
 }
index 00ff98d..ba3d70d 100644 (file)
@@ -8,6 +8,7 @@ import org.netxms.client.objects.GenericObject;
 import org.netxms.ui.android.R;
 import org.netxms.ui.android.main.adapters.ActivityListAdapter;
 import org.netxms.ui.android.main.fragments.AlarmBrowserFragment;
+import org.netxms.ui.android.service.ClientConnectorService;
 import org.netxms.ui.android.service.ClientConnectorService.ConnectionStatus;
 
 import android.annotation.SuppressLint;
@@ -45,7 +46,6 @@ public class HomeScreen extends AbstractClientActivity implements OnItemClickLis
        public static final int ACTIVITY_ENTIRENETWORK = 4;
        public static final int ACTIVITY_GRAPHS = 5;
        public static final int ACTIVITY_MACADDRESS = 6;
-       public static final String INTENTIONAL_EXIT_KEY = "IntentionalExit";
 
        private ActivityListAdapter adapter;
        private TextView statusText;
@@ -195,7 +195,8 @@ public class HomeScreen extends AbstractClientActivity implements OnItemClickLis
        {
                if (service != null)
                        service.shutdown();
-               setIntentionalExit(true);// Avoid autorestart on change connectivity status for intentional exit
+               else
+                       setIntentionalExit(true);// Avoid autorestart on change connectivity status for intentional exit (shutdown will do itself)
                moveTaskToBack(true);
                System.exit(0);
        }
@@ -233,7 +234,7 @@ public class HomeScreen extends AbstractClientActivity implements OnItemClickLis
        {
                SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
                SharedPreferences.Editor editor = prefs.edit();
-               editor.putBoolean(INTENTIONAL_EXIT_KEY, flag);
+               editor.putBoolean(ClientConnectorService.INTENTIONAL_EXIT_KEY, flag);
                editor.commit();
        }
 }
index 07aced9..68064a4 100644 (file)
@@ -199,7 +199,7 @@ public class InterfacesAdapter extends BaseExpandableListAdapter
                        case DISABLED:
                                return R.drawable.status_disabled;
                        case TESTING:
-                               return R.drawable.status_unknown;       // TODO: 2014Oct10 Implement corresponding settings section
+                               return R.drawable.status_unknown;
                }
                return R.drawable.status_unknown;
        }
index d6faa62..a149a70 100644 (file)
@@ -1,6 +1,5 @@
 package org.netxms.ui.android.receivers;
 
-import org.netxms.ui.android.main.activities.HomeScreen;
 import org.netxms.ui.android.service.ClientConnectorService;
 
 import android.content.BroadcastReceiver;
@@ -25,7 +24,7 @@ public class ConnectivityChangeIntentReceiver extends BroadcastReceiver
        public void onReceive(Context context, Intent intent)
        {
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
-               if (!sp.getBoolean(HomeScreen.INTENTIONAL_EXIT_KEY, false))
+               if (!sp.getBoolean(ClientConnectorService.INTENTIONAL_EXIT_KEY, false))
                        if (intent.getExtras() != null)
                        {
                                if (!sp.getBoolean("global.scheduler.enable", false)) // Try to connect only when the scheduler is disabled
index 0bd1865..3890b4c 100644 (file)
@@ -79,9 +79,10 @@ public class ClientConnectorService extends Service implements SessionListener
        public static final String ACTION_ALARM_RESOLVE = "org.netxms.ui.android.ACTION_ALARM_RESOLVE";
        public static final String ACTION_ALARM_TERMINATE = "org.netxms.ui.android.ACTION_ALARM_TERMINATE";
        public static final String ACTION_EXIT = "org.netxms.ui.android.ACTION_EXIT";
+       public static final String INTENTIONAL_EXIT_KEY = "IntentionalExit";
+
        private static final String TAG = "nxclient/ClientConnectorService";
        private static final String LASTALARM_KEY = "LastALarmIdNotified";
-
        private static final int NOTIFY_ALARM = 1;
        private static final int NOTIFY_STATUS = 2;
        private static final int NOTIFY_STATUS_NEVER = 0;
@@ -191,6 +192,8 @@ public class ClientConnectorService extends Service implements SessionListener
        public int onStartCommand(Intent intent, int flags, int startId)
        {
                if ((intent != null) && (intent.getAction() != null))
+               {
+                       Log.d(TAG, "onStartCommand: " + intent.getAction());
                        if (intent.getAction().equals(ACTION_CONNECT))
                                reconnect(false);
                        else if (intent.getAction().equals(ACTION_FORCE_CONNECT))
@@ -233,6 +236,7 @@ public class ClientConnectorService extends Service implements SessionListener
                        }
                        else if (intent.getAction().equals(ACTION_EXIT))
                                exitApp();
+               }
                return super.onStartCommand(intent, flags, startId);
        }
 
@@ -265,18 +269,19 @@ public class ClientConnectorService extends Service implements SessionListener
        {
                cancelSchedule();
                clearNotifications();
-               savePreferences();
+               saveSatusOnExit();
                unregisterReceiver(receiver);
                stopSelf();
        }
 
        /**
-        * 
+        * Save status for intentional exit from app 
         */
-       public void savePreferences()
+       public void saveSatusOnExit()
        {
                SharedPreferences.Editor editor = sp.edit();
                editor.putInt(LASTALARM_KEY, (int)lastAlarmIdNotified);
+               editor.putBoolean(ClientConnectorService.INTENTIONAL_EXIT_KEY, true);
                editor.commit();
        }
 
@@ -421,8 +426,6 @@ public class ClientConnectorService extends Service implements SessionListener
         */
        private boolean hasToReconnect()
        {
-               // TODO: cleanup alarm icon on change settings
-               // TODO: check reconnect on new flags added (vibration, led,...)
                boolean needsToReconnect = enabled != sp.getBoolean("global.scheduler.enable", false);
                needsToReconnect |= !server.equalsIgnoreCase(sp.getString("connection.server", ""));
                needsToReconnect |= port != SafeParser.parseInt(sp.getString("connection.port", "4701"), 4701);
@@ -744,7 +747,8 @@ public class ClientConnectorService extends Service implements SessionListener
                        {
                                try
                                {
-                                       session.syncObjectSet(new long[] { objectId }, false, NXCSession.OBJECT_SYNC_NOTIFY);
+                                       if (session != null)
+                                               session.syncObjectSet(new long[] { objectId }, false, NXCSession.OBJECT_SYNC_NOTIFY);
                                }
                                catch (Exception e)
                                {
@@ -806,7 +810,7 @@ public class ClientConnectorService extends Service implements SessionListener
        }
 
        /**
-        * Exit from App
+        * Exit intentionally from App
         */
        private void exitApp()
        {
@@ -821,6 +825,8 @@ public class ClientConnectorService extends Service implements SessionListener
                                }
                        });
                }
+               else    // Home app is no more running
+                       shutdown();
        }
 
        /**
@@ -980,10 +986,25 @@ public class ClientConnectorService extends Service implements SessionListener
                        int short_gap = 100;// Length of Gap Between dots/dashes (real is 200)
                        int medium_gap = 250;// Length of Gap Between Letters (real is 500)
                        //int long_gap = 500;// Length of Gap Between Words (real is 1000)
-                       long[] pattern = { 0, // Start immediately 
-                       dot, short_gap, dot, short_gap, dot, // s 
-                       medium_gap, dash, short_gap, dash, short_gap, dash, // o 
-                       medium_gap, dot, short_gap, dot, short_gap, dot// s 
+                       long[] pattern = {
+                                       0, // Start immediately 
+                                       dot,
+                                       short_gap,
+                                       dot,
+                                       short_gap,
+                                       dot, // s 
+                                       medium_gap,
+                                       dash,
+                                       short_gap,
+                                       dash,
+                                       short_gap,
+                                       dash, // o 
+                                       medium_gap,
+                                       dot,
+                                       short_gap,
+                                       dot,
+                                       short_gap,
+                                       dot// s 
                        };
                        return pattern;
                }
@@ -1111,7 +1132,8 @@ public class ClientConnectorService extends Service implements SessionListener
        {
                try
                {
-                       session.acknowledgeAlarm(id, sticky, 0);
+                       if (session != null)
+                               session.acknowledgeAlarm(id, sticky, 0);
                }
                catch (Exception e)
                {
@@ -1135,7 +1157,8 @@ public class ClientConnectorService extends Service implements SessionListener
        {
                try
                {
-                       session.resolveAlarm(id);
+                       if (session != null)
+                               session.resolveAlarm(id);
                }
                catch (Exception e)
                {
@@ -1159,7 +1182,8 @@ public class ClientConnectorService extends Service implements SessionListener
        {
                try
                {
-                       session.terminateAlarm(id);
+                       if (session != null)
+                               session.terminateAlarm(id);
                }
                catch (Exception e)
                {
@@ -1184,7 +1208,8 @@ public class ClientConnectorService extends Service implements SessionListener
        {
                try
                {
-                       session.setObjectManaged(id, state);
+                       if (session != null)
+                               session.setObjectManaged(id, state);
                }
                catch (Exception e)
                {
@@ -1387,7 +1412,7 @@ public class ClientConnectorService extends Service implements SessionListener
                        if (cal.getTimeInMillis() < next)
                        {
                                cal.setTimeInMillis(next);
-                               return " " + getString(R.string.notify_next_connection_schedule, DateFormat.getDateTimeInstance().format(cal));
+                               return " " + getString(R.string.notify_next_connection_schedule, DateFormat.getDateTimeInstance().format(cal.getTime()));
                        }
                }
                return "";