use of androidx.appcompat.widget.AppCompatCheckedTextView in project collect by opendatakit.
the class ShowQRCodeFragment method passwordWarningClicked.
private void passwordWarningClicked() {
if (dialog == null) {
final String[] items = { getString(R.string.admin_password), getString(R.string.server_password) };
dialog = new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.include_password_dialog).setMultiChoiceItems(items, checkedItems, (dialog, which, isChecked) -> checkedItems[which] = isChecked).setCancelable(false).setPositiveButton(R.string.generate, (dialog, which) -> {
qrCodeViewModel.setIncludedKeys(getSelectedPasswordKeys());
dialog.dismiss();
}).setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()).create();
// disable checkbox if password not set
dialog.getListView().setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
@Override
public void onChildViewAdded(View parent, View child) {
CharSequence text = ((AppCompatCheckedTextView) child).getText();
int itemIndex = Arrays.asList(items).indexOf(text);
if (!passwordsSet[itemIndex]) {
child.setEnabled(passwordsSet[itemIndex]);
child.setOnClickListener(null);
}
}
@Override
public void onChildViewRemoved(View view, View view1) {
}
});
}
dialog.show();
}
Aggregations