Android: fix deprecations for getDrawable() on QtMessageDialogHelper

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Icd359663af11f44b4bcf0cd4e4f1f7f5a51242e4
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
This commit is contained in:
Assam Boudjelthia 2022-12-20 16:27:21 +02:00
parent 40b42ac517
commit 31a0d99fa5

View File

@ -73,7 +73,8 @@ public class QtMessageDialogHelper
try { try {
TypedValue typedValue = new TypedValue(); TypedValue typedValue = new TypedValue();
m_theme.resolveAttribute(android.R.attr.alertDialogIcon, typedValue, true); m_theme.resolveAttribute(android.R.attr.alertDialogIcon, typedValue, true);
return m_activity.getResources().getDrawable(typedValue.resourceId); return m_activity.getResources().getDrawable(typedValue.resourceId,
m_activity.getTheme());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -83,7 +84,8 @@ public class QtMessageDialogHelper
{ {
case 1: // Information case 1: // Information
try { try {
return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_info); return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_info,
m_activity.getTheme());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -97,14 +99,16 @@ public class QtMessageDialogHelper
// break; // break;
case 3: // Critical case 3: // Critical
try { try {
return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert); return m_activity.getResources().getDrawable(android.R.drawable.ic_dialog_alert,
m_activity.getTheme());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
break; break;
case 4: // Question case 4: // Question
try { try {
return m_activity.getResources().getDrawable(android.R.drawable.ic_menu_help); return m_activity.getResources().getDrawable(android.R.drawable.ic_menu_help,
m_activity.getTheme());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }