use of androidx.appcompat.app.AlertDialog in project kdeconnect-android by KDE.
the class NotificationFilterActivity method displayAppList.
private void displayAppList() {
final ListView listView = binding.lvFilterApps;
AppListAdapter adapter = new AppListAdapter();
listView.setAdapter(adapter);
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView.setLongClickable(true);
listView.setOnItemClickListener((adapterView, view, i, l) -> {
if (i == 0) {
boolean enabled = listView.isItemChecked(0);
for (int j = 0; j < apps.length; j++) {
listView.setItemChecked(j, enabled);
}
appDatabase.setAllEnabled(enabled);
} else {
boolean checked = listView.isItemChecked(i);
appDatabase.setEnabled(apps[i - 1].pkg, checked);
apps[i - 1].isEnabled = checked;
}
});
listView.setOnItemLongClickListener((adapterView, view, i, l) -> {
if (i == 0)
return true;
Context context = this;
AlertDialog.Builder builder = new AlertDialog.Builder(context);
View mView = getLayoutInflater().inflate(R.layout.popup_notificationsfilter, null);
builder.setMessage(context.getResources().getString(R.string.extra_options));
ListView lv = mView.findViewById(R.id.extra_options_list);
final String[] options = new String[] { context.getResources().getString(R.string.privacy_options) };
ArrayAdapter<String> extra_options_adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, options);
lv.setAdapter(extra_options_adapter);
builder.setView(mView);
AlertDialog ad = builder.create();
lv.setOnItemClickListener((new_adapterView, new_view, new_i, new_l) -> {
switch(new_i) {
case 0:
AlertDialog.Builder myBuilder = new AlertDialog.Builder(context);
String packageName = apps[i - 1].pkg;
View myView = getLayoutInflater().inflate(R.layout.privacy_options, null);
CheckBox checkbox_contents = myView.findViewById(R.id.checkbox_contents);
checkbox_contents.setChecked(appDatabase.getPrivacy(packageName, AppDatabase.PrivacyOptions.BLOCK_CONTENTS));
checkbox_contents.setText(context.getResources().getString(R.string.block_contents));
CheckBox checkbox_images = myView.findViewById(R.id.checkbox_images);
checkbox_images.setChecked(appDatabase.getPrivacy(packageName, AppDatabase.PrivacyOptions.BLOCK_IMAGES));
checkbox_images.setText(context.getResources().getString(R.string.block_images));
myBuilder.setView(myView);
myBuilder.setTitle(context.getResources().getString(R.string.privacy_options));
myBuilder.setPositiveButton(context.getResources().getString(R.string.ok), (dialog, id) -> dialog.dismiss());
myBuilder.setMessage(context.getResources().getString(R.string.set_privacy_options));
checkbox_contents.setOnCheckedChangeListener((compoundButton, b) -> appDatabase.setPrivacy(packageName, AppDatabase.PrivacyOptions.BLOCK_CONTENTS, compoundButton.isChecked()));
checkbox_images.setOnCheckedChangeListener((compoundButton, b) -> appDatabase.setPrivacy(packageName, AppDatabase.PrivacyOptions.BLOCK_IMAGES, compoundButton.isChecked()));
ad.cancel();
myBuilder.show();
break;
}
});
ad.show();
return true;
});
// "Select all" button
listView.setItemChecked(0, appDatabase.getAllEnabled());
for (int i = 0; i < apps.length; i++) {
listView.setItemChecked(i + 1, apps[i].isEnabled);
}
listView.setVisibility(View.VISIBLE);
binding.spinner.setVisibility(View.GONE);
}
use of androidx.appcompat.app.AlertDialog in project android by owncloud.
the class ReceiveExternalFilesActivity method showUploadTextDialog.
/**
* Show a dialog where the user can enter a filename for the file he wants to place the text in.
*/
private void showUploadTextDialog() {
final AlertDialog.Builder builder = new Builder(this);
final View dialogView = getLayoutInflater().inflate(R.layout.dialog_upload_text, null);
builder.setView(dialogView);
builder.setTitle(R.string.uploader_upload_text_dialog_title);
builder.setCancelable(false);
builder.setPositiveButton(R.string.uploader_btn_upload_text, null);
builder.setNegativeButton(android.R.string.cancel, null);
final TextInputEditText input = dialogView.findViewById(R.id.inputFileName);
final TextInputLayout inputLayout = dialogView.findViewById(R.id.inputTextLayout);
input.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
inputLayout.setError(null);
inputLayout.setErrorEnabled(false);
}
});
final AlertDialog alertDialog = builder.create();
setFileNameFromIntent(alertDialog, input);
alertDialog.setOnShowListener(dialog -> {
Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
button.setOnClickListener(view -> {
String fileName = input.getText().toString();
String error = null;
if (fileName.length() > MAX_FILENAME_LENGTH) {
error = String.format(getString(R.string.uploader_upload_text_dialog_filename_error_length_max), MAX_FILENAME_LENGTH);
} else if (fileName.length() == 0) {
error = getString(R.string.uploader_upload_text_dialog_filename_error_empty);
} else {
fileName += ".txt";
Uri fileUri = savePlainTextToFile(fileName);
mStreamsToUpload.clear();
mStreamsToUpload.add(fileUri);
uploadFiles();
}
inputLayout.setErrorEnabled(error != null);
inputLayout.setError(error);
});
});
alertDialog.show();
}
use of androidx.appcompat.app.AlertDialog in project kdeconnect-android by KDE.
the class StoragePreferenceDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog dialog = (AlertDialog) super.onCreateDialog(savedInstanceState);
dialog.setOnShowListener(dialog1 -> {
AlertDialog alertDialog = (AlertDialog) dialog1;
positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
positiveButton.setEnabled(enablePositiveButton);
});
return dialog;
}
use of androidx.appcompat.app.AlertDialog in project BigImageViewer by Piasy.
the class LongImageActivity method showDialog.
private AlertDialog showDialog() {
final ViewGroup container = findViewById(R.id.container);
final AlertDialog.Builder builder = new AlertDialog.Builder(LongImageActivity.this);
final View rootView = LayoutInflater.from(LongImageActivity.this).inflate(R.layout.dialog_long_image, container, false);
builder.setView(rootView);
final TextView textScan = rootView.findViewById(R.id.action_scan_qr);
final TextView textSave = rootView.findViewById(R.id.action_save_image);
textScan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
decodeQrCode();
dialog.dismiss();
}
});
textSave.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveImage();
dialog.dismiss();
}
});
return builder.create();
}
use of androidx.appcompat.app.AlertDialog in project AntennaPod by AntennaPod.
the class SynchronizationPreferencesFragment method chooseProviderAndLogin.
private void chooseProviderAndLogin() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.dialog_choose_sync_service_title);
SynchronizationProviderViewData[] providers = SynchronizationProviderViewData.values();
ListAdapter adapter = new ArrayAdapter<SynchronizationProviderViewData>(getContext(), R.layout.alertdialog_sync_provider_chooser, providers) {
ViewHolder holder;
class ViewHolder {
ImageView icon;
TextView title;
}
public View getView(int position, View convertView, ViewGroup parent) {
final LayoutInflater inflater = LayoutInflater.from(getContext());
if (convertView == null) {
convertView = inflater.inflate(R.layout.alertdialog_sync_provider_chooser, null);
holder = new ViewHolder();
holder.icon = (ImageView) convertView.findViewById(R.id.icon);
holder.title = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
SynchronizationProviderViewData synchronizationProviderViewData = getItem(position);
holder.title.setText(synchronizationProviderViewData.getSummaryResource());
holder.icon.setImageResource(synchronizationProviderViewData.getIconResource());
return convertView;
}
};
builder.setAdapter(adapter, (dialog, which) -> {
switch(providers[which]) {
case GPODDER_NET:
new GpodderAuthenticationFragment().show(getChildFragmentManager(), GpodderAuthenticationFragment.TAG);
break;
case NEXTCLOUD_GPODDER:
new NextcloudAuthenticationFragment().show(getChildFragmentManager(), NextcloudAuthenticationFragment.TAG);
break;
default:
break;
}
updateScreen();
});
AlertDialog dialog = builder.create();
dialog.show();
}
Aggregations