From efba45dba2f5ee2ef973983a42dca374f61742d8 Mon Sep 17 00:00:00 2001 From: Rafa Hernandez Date: Wed, 28 Mar 2018 13:43:18 -0400 Subject: [PATCH] fix(enroll): add button to delete al data Signed-off-by: Rafa Hernandez --- .../mdm/agent/ui/FragmentConfiguration.java | 40 ++++++++++++++++++- .../res/layout/fragment_configuration.xml | 11 +++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/flyve/mdm/agent/ui/FragmentConfiguration.java b/app/src/main/java/org/flyve/mdm/agent/ui/FragmentConfiguration.java index 76cfdc6c53..a4b2b68498 100644 --- a/app/src/main/java/org/flyve/mdm/agent/ui/FragmentConfiguration.java +++ b/app/src/main/java/org/flyve/mdm/agent/ui/FragmentConfiguration.java @@ -23,16 +23,20 @@ package org.flyve.mdm.agent.ui; +import android.content.DialogInterface; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v7.app.AlertDialog; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.CompoundButton; import android.widget.Switch; import org.flyve.mdm.agent.R; import org.flyve.mdm.agent.data.AppData; +import org.flyve.mdm.agent.data.LocalStorage; public class FragmentConfiguration extends Fragment { @@ -65,7 +69,39 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) { } }); - return v; - } + Button btnClear = v.findViewById(R.id.btnClear); + btnClear.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + AlertDialog.Builder builder = new AlertDialog.Builder(FragmentConfiguration.this.getContext()); + + builder.setTitle("DANGER"); + builder.setMessage("Are you sure do you want erase all the data?"); + + builder.setPositiveButton("YES", new DialogInterface.OnClickListener() { + + public void onClick(DialogInterface dialog, int which) { + LocalStorage localStorage = new LocalStorage(FragmentConfiguration.this.getContext()); + localStorage.clearSettings(); + dialog.dismiss(); + } + }); + + builder.setNegativeButton("NO", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + + // Do nothing + dialog.dismiss(); + } + }); + + AlertDialog alert = builder.create(); + alert.show(); + } + }); + + return v; } +} diff --git a/app/src/main/res/layout/fragment_configuration.xml b/app/src/main/res/layout/fragment_configuration.xml index 41011eade4..6ce8ce8dda 100644 --- a/app/src/main/res/layout/fragment_configuration.xml +++ b/app/src/main/res/layout/fragment_configuration.xml @@ -27,5 +27,16 @@ android:layout_margin="5dp" android:visibility="gone" /> + +