Skip to content

Commit

Permalink
feat(design): add send anonymous data method
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Hernandez <[email protected]>
  • Loading branch information
rafaelje authored and ajsb85 committed Mar 26, 2018
1 parent 96e5bf3 commit 1f6cd8f
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions app/src/main/java/org/flyve/inventory/agent/utils/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1f6cd8f

Please sign in to comment.