Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
fix(enroll): add button to delete al data
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Hernandez <[email protected]>
  • Loading branch information
rafaelje authored and Hector Rondon committed Mar 28, 2018
1 parent 0a60281 commit efba45d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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;
}
}
11 changes: 11 additions & 0 deletions app/src/main/res/layout/fragment_configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,16 @@
android:layout_margin="5dp"
android:visibility="gone"
/>

<Button
android:id="@+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete Data"
style="?android:attr/borderlessButtonStyle"
android:layout_gravity="right"
android:layout_marginTop="40dp"
android:textColor="@color/red"
/>
</LinearLayout>
</ScrollView>

0 comments on commit efba45d

Please sign in to comment.