use of androidx.appcompat.app.AlertDialog in project android by nextcloud.
the class SyncFileNotEnoughSpaceDialogFragment method onStart.
@Override
public void onStart() {
super.onStart();
AlertDialog alertDialog = (AlertDialog) getDialog();
if (alertDialog != null) {
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE), alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL), alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE));
}
}
use of androidx.appcompat.app.AlertDialog in project android by nextcloud.
the class SyncedFoldersActivity method showBatteryOptimizationInfo.
private void showBatteryOptimizationInfo() {
if (powerManagementService.isPowerSavingExclusionAvailable() || checkIfBatteryOptimizationEnabled()) {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, R.style.Theme_ownCloud_Dialog).setTitle(getString(R.string.battery_optimization_title)).setMessage(getString(R.string.battery_optimization_message)).setPositiveButton(getString(R.string.battery_optimization_disable), (dialog, which) -> {
// show instant upload
@SuppressLint("BatteryLife") Intent intent = new Intent(ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:" + BuildConfig.APPLICATION_ID));
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}).setNeutralButton(getString(R.string.battery_optimization_close), (dialog, which) -> dialog.dismiss()).setIcon(R.drawable.ic_battery_alert);
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
AlertDialog alertDialog = alertDialogBuilder.show();
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE), alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
}
}
}
use of androidx.appcompat.app.AlertDialog in project WordPress-Login-Flow-Android by wordpress-mobile.
the class LoginHttpAuthDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder alert = new MaterialAlertDialogBuilder(getActivity());
alert.setTitle(R.string.http_authorization_required);
if (!TextUtils.isEmpty(mMessage))
alert.setMessage(mMessage);
// noinspection InflateParams
View httpAuth = getActivity().getLayoutInflater().inflate(R.layout.login_alert_http_auth, null);
alert.setView(httpAuth);
final EditText usernameEditText = (EditText) httpAuth.findViewById(R.id.login_http_username);
final EditText passwordEditText = (EditText) httpAuth.findViewById(R.id.login_http_password);
passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
String username = EditTextUtils.getText(usernameEditText);
String password = EditTextUtils.getText(passwordEditText);
sendResult(username, password);
dismiss();
return true;
}
});
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dismiss();
}
});
alert.setPositiveButton(R.string.next, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String username = EditTextUtils.getText(usernameEditText);
String password = EditTextUtils.getText(passwordEditText);
sendResult(username, password);
}
});
final AlertDialog alertDialog = alert.create();
// update the Next button when username edit box changes
usernameEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
updateButton(alertDialog, usernameEditText);
}
});
// update the Next button on first appearance
alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
updateButton(alertDialog, usernameEditText);
}
});
return alertDialog;
}
use of androidx.appcompat.app.AlertDialog in project WordPress-Login-Flow-Android by wordpress-mobile.
the class LoginEmailFragment method showErrorDialog.
private void showErrorDialog(String message) {
AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity()).setMessage(message).setPositiveButton(R.string.login_error_button, null).create();
dialog.show();
}
use of androidx.appcompat.app.AlertDialog in project CustomActivityOnCrash by Ereza.
the class DefaultErrorActivity method onCreate.
@SuppressLint("PrivateResource")
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// This is needed to avoid a crash if the developer has not specified
// an app-level theme that extends Theme.AppCompat
TypedArray a = obtainStyledAttributes(R.styleable.AppCompatTheme);
if (!a.hasValue(R.styleable.AppCompatTheme_windowActionBar)) {
setTheme(R.style.Theme_AppCompat_Light_DarkActionBar);
}
a.recycle();
setContentView(R.layout.customactivityoncrash_default_error_activity);
// Close/restart button logic:
// If a class if set, use restart.
// Else, use close and just finish the app.
// It is recommended that you follow this logic if implementing a custom error activity.
Button restartButton = findViewById(R.id.customactivityoncrash_error_activity_restart_button);
final CaocConfig config = CustomActivityOnCrash.getConfigFromIntent(getIntent());
if (config == null) {
// This should never happen - Just finish the activity to avoid a recursive crash.
finish();
return;
}
if (config.isShowRestartButton() && config.getRestartActivityClass() != null) {
restartButton.setText(R.string.customactivityoncrash_error_activity_restart_app);
restartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CustomActivityOnCrash.restartApplication(DefaultErrorActivity.this, config);
}
});
} else {
restartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CustomActivityOnCrash.closeApplication(DefaultErrorActivity.this, config);
}
});
}
Button moreInfoButton = findViewById(R.id.customactivityoncrash_error_activity_more_info_button);
if (config.isShowErrorDetails()) {
moreInfoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// We retrieve all the error data and show it
AlertDialog dialog = new AlertDialog.Builder(DefaultErrorActivity.this).setTitle(R.string.customactivityoncrash_error_activity_error_details_title).setMessage(CustomActivityOnCrash.getAllErrorDetailsFromIntent(DefaultErrorActivity.this, getIntent())).setPositiveButton(R.string.customactivityoncrash_error_activity_error_details_close, null).setNeutralButton(R.string.customactivityoncrash_error_activity_error_details_copy, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
copyErrorToClipboard();
}
}).show();
TextView textView = dialog.findViewById(android.R.id.message);
if (textView != null) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.customactivityoncrash_error_activity_error_details_text_size));
}
}
});
} else {
moreInfoButton.setVisibility(View.GONE);
}
Integer defaultErrorActivityDrawableId = config.getErrorDrawable();
ImageView errorImageView = findViewById(R.id.customactivityoncrash_error_activity_image);
if (defaultErrorActivityDrawableId != null) {
errorImageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(), defaultErrorActivityDrawableId, getTheme()));
}
}
Aggregations