use of org.flyve.mdm.agent.data.localstorage.LocalStorage in project android-mdm-agent by flyve-mdm.
the class FragmentConfiguration method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
v = inflater.inflate(R.layout.fragment_configuration, container, false);
cache = new AppData(FragmentConfiguration.this.getContext());
Switch swNotifications = this.v.findViewById(R.id.swNotifications);
swNotifications.setChecked(cache.getDisableNotification());
swNotifications.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
cache.setDisableNotification(b);
}
});
Switch swConnectionNotification = this.v.findViewById(R.id.swConnectionNotification);
swConnectionNotification.setChecked(cache.getEnableNotificationConnection());
swConnectionNotification.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
cache.setEnableNotificationConnection(b);
}
});
Switch swDarkTheme = this.v.findViewById(R.id.swDarkTheme);
swDarkTheme.setChecked(cache.getDarkTheme());
swDarkTheme.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
cache.setDarkTheme(b);
}
});
// use for lock option
Switch switchDrawOverlay = this.v.findViewById(R.id.swtDrawOverlay);
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
switchDrawOverlay.setChecked(Settings.canDrawOverlays(getActivity()));
switchDrawOverlay.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getActivity().getPackageName()));
startActivityForResult(intent, REQUEST_DRAWOVERLAY_CODE);
}
});
} else {
switchDrawOverlay.setVisibility(View.INVISIBLE);
}
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(R.string.danger);
builder.setMessage(R.string.erase_all_data_question);
builder.setPositiveButton(R.string.YES, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
LocalStorage localStorage = new LocalStorage(FragmentConfiguration.this.getContext());
localStorage.clearSettings();
new MqttData(FragmentConfiguration.this.getContext()).deleteAll();
dialog.dismiss();
}
});
builder.setNegativeButton(R.string.NO, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
return v;
}
Aggregations