Android: Choose correct icon for QMessageBox

QMessageBox contains an icon that can be set using icon type. Before
this commit, android.R.attr.alertDialogIcon was used regardless of the
expected icon type. Only if setting failed, the icon from
android.R.drawable was set (depending on the expected icon type).

Previously, usage of android.R.attr.alertDialogIcon was the way to
consider Theme in choosing icon view. Since
31a0d99fa565d39bf39f0c3ae5ed00859679a969 commit, getDrawable(id, theme)
is used with second parameter: Resources.Theme.

Because of that we can start to use only icons from android.R.drawable
and remove usage of android.R.attr.alertDialogIcon

Fixes: QTBUG-123334
Pick-to: 6.6 6.5
Change-Id: I6cfdaf30aea5d132e38ba5d78054089b51cf5f13
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 229cadb7a36694b7ab639047dceb73cf2dfce858)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Bartlomiej Moskal 2024-04-02 12:24:33 +02:00 committed by Qt Cherry-pick Bot
parent 45b90af43c
commit 01c11c3006

View File

@ -69,15 +69,6 @@ public class QtMessageDialogHelper
if (m_standardIcon == 0)
return null;
try {
TypedValue typedValue = new TypedValue();
m_theme.resolveAttribute(android.R.attr.alertDialogIcon, typedValue, true);
return m_activity.getResources().getDrawable(typedValue.resourceId,
m_activity.getTheme());
} catch (Exception e) {
e.printStackTrace();
}
// Information, Warning, Critical, Question
switch (m_standardIcon)
{
@ -87,7 +78,6 @@ public class QtMessageDialogHelper
case 2: // Warning
return m_activity.getResources().getDrawable(android.R.drawable.stat_sys_warning,
m_activity.getTheme());
// break;
case 3: // Critical
return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert,
m_activity.getTheme());