Android: Fix deprecations AlertDialog.setButton()

https://developer.android.com/reference/android/app/
AlertDialog#setButton(java.lang.CharSequence,
%20android.content.DialogInterface.OnClickListener)

Change-Id: I470acba581b7226b2d4a56754cf6372baa167eb4
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
(cherry picked from commit 40b42ac517c45beff3caf5e991c84739ac014912)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Assam Boudjelthia 2022-09-30 14:33:40 +03:00 committed by Qt Cherry-pick Bot
parent d6c932e001
commit fe24040e90

View File

@ -5,6 +5,7 @@
package org.qtproject.qt.android.bindings;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
@ -146,7 +147,8 @@ public abstract class QtLoader {
// fatal error, show the error and quit
AlertDialog errorDialog = new AlertDialog.Builder(m_context).create();
errorDialog.setMessage(loaderParams.getString(ERROR_MESSAGE_KEY));
errorDialog.setButton(resources.getString(android.R.string.ok),
errorDialog.setButton(Dialog.BUTTON_POSITIVE,
resources.getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@ -197,7 +199,8 @@ public abstract class QtLoader {
int id = resources.getIdentifier("fatal_error_msg", "string",
packageName);
errorDialog.setMessage(resources.getString(id));
errorDialog.setButton(resources.getString(android.R.string.ok),
errorDialog.setButton(Dialog.BUTTON_POSITIVE,
resources.getString(android.R.string.ok),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {