From 1f6cd8f9e60d8e528b1d6a64ade4cc4e605a0b15 Mon Sep 17 00:00:00 2001 From: Rafa Hernandez Date: Sun, 18 Feb 2018 12:38:02 -0400 Subject: [PATCH] feat(design): add send anonymous data method Signed-off-by: Rafa Hernandez --- .../flyve/inventory/agent/utils/Helpers.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/flyve/inventory/agent/utils/Helpers.java b/app/src/main/java/org/flyve/inventory/agent/utils/Helpers.java index 6a87912d4..666e5e14d 100644 --- a/app/src/main/java/org/flyve/inventory/agent/utils/Helpers.java +++ b/app/src/main/java/org/flyve/inventory/agent/utils/Helpers.java @@ -7,15 +7,17 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.graphics.BitmapFactory; import android.media.RingtoneManager; import android.net.Uri; import android.os.Build; +import android.preference.PreferenceManager; import android.support.design.widget.Snackbar; import android.support.v4.app.NotificationCompat; import android.view.View; -import org.flyve.inventory.agent.AboutActivity; +import org.flyve.inventory.InventoryTask; import org.flyve.inventory.agent.MainActivity; import org.flyve.inventory.agent.R; @@ -58,10 +60,10 @@ private Helpers() { /** * Generate a snackbar with the given arguments - * @param Activity the view to show - * @param string the message to display - * @param string the text to display for the action - * @param View.OnClickListener the callback to be invoked when the action is clicked + * @param activity the view to show + * @param message to display + * @param action the text to display for the action + * @param fail the callback to be invoked when the action is clicked */ public static void snackClose(Activity activity, String message, String action, Boolean fail) { @@ -91,6 +93,27 @@ public static String splitCamelCase(String s) { ); } + public static void sendAnonymousData(Context context, InventoryTask inventoryTask) { + // Sending anonymous information + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); + Boolean val = sharedPreferences.getBoolean("anonymousData",false); + if(val) { + inventoryTask.getJSONWithoutPrivateData(new InventoryTask.OnTaskCompleted() { + @Override + public void onTaskSuccess(String s) { + FlyveLog.d(s); + ConnectionHTTP.syncWebData("https://inventory.chollima.pro/-1001180163835/", s); + } + + @Override + public void onTaskError(Throwable throwable) { + FlyveLog.e(throwable.getMessage()); + } + }); + } + } + + public static boolean isForeground() { ActivityManager.RunningAppProcessInfo appProcessInfo = new ActivityManager.RunningAppProcessInfo(); ActivityManager.getMyMemoryState(appProcessInfo);