@@ -42,28 +42,9 @@ AndroidUtils *AndroidUtils::instance()
42
42
void AndroidUtils::setStatusBarColor (const QColor &color)
43
43
{
44
44
#ifdef Q_OS_ANDROID
45
- if (QtAndroid::androidSdkVersion () >= 21 ) {
46
- QtAndroid::runOnAndroidThreadSync ([=](){
47
- auto activity = QtAndroid::androidActivity ();
48
- if (activity.isValid ()) {
49
- const auto FLAG_TRANSLUCENT_STATUS = QAndroidJniObject::getStaticField<jint>(" android/view/WindowManager$LayoutParams" ,
50
- " FLAG_TRANSLUCENT_STATUS" );
51
- const auto FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = QAndroidJniObject::getStaticField<jint>(" android/view/WindowManager$LayoutParams" ,
52
- " FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS" );
53
- const auto aColor = QAndroidJniObject::callStaticMethod<jint>(" android/graphics/Color" ,
54
- " parseColor" ,
55
- " (Ljava/lang/String;)I" ,
56
- QAndroidJniObject::fromString (color.name ()).object ());
57
-
58
- QAndroidJniObject window = activity.callObjectMethod (" getWindow" , " ()Landroid/view/Window;" );
59
- if (window.isValid ()) {
60
- window.callMethod <void >(" clearFlags" , " (I)V" , FLAG_TRANSLUCENT_STATUS);
61
- window.callMethod <void >(" addFlags" , " (I)V" , FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
62
- window.callMethod <void >(" setStatusBarColor" , " (I)V" , aColor);
63
- }
64
- }
65
- });
66
- }
45
+ AndroidNative::SystemDispatcher::instance ()->dispatch (" AndroidUtils.setStatusBarColor" , {
46
+ {" color" , color.name ()}
47
+ });
67
48
#else
68
49
Q_UNUSED (color);
69
50
#endif
@@ -85,30 +66,8 @@ void AndroidUtils::showToast(const QString &message, bool showLong)
85
66
void AndroidUtils::hapticFeedback (HapticFeedbackConstant constant)
86
67
{
87
68
#ifdef Q_OS_ANDROID
88
- jint type = 0 ;
89
- switch (constant) {
90
- case AndroidUtils::LongPress:
91
- type = QAndroidJniObject::getStaticField<jint>(" android/view/HapticFeedbackConstants" , " LONG_PRESS" );
92
- break ;
93
- case AndroidUtils::VirtualKey:
94
- type = QAndroidJniObject::getStaticField<jint>(" android/view/HapticFeedbackConstants" , " VIRTUAL_KEY" );
95
- break ;
96
- case AndroidUtils::KeyboardTap:
97
- type = QAndroidJniObject::getStaticField<jint>(" android/view/HapticFeedbackConstants" , " KEYBOARD_TAP" );
98
- break ;
99
- case AndroidUtils::ClockTick:
100
- type = QAndroidJniObject::getStaticField<jint>(" android/view/HapticFeedbackConstants" , " CLOCK_TICK" );
101
- break ;
102
- case AndroidUtils::ContextClick:
103
- type = QAndroidJniObject::getStaticField<jint>(" android/view/HapticFeedbackConstants" , " CONTEXT_CLICK" );
104
- break ;
105
- default :
106
- Q_UNREACHABLE ();
107
- return ;
108
- }
109
-
110
69
AndroidNative::SystemDispatcher::instance ()->dispatch (" AndroidUtils.hapticFeedback" , {
111
- {" feedbackConstant" , (int )type }
70
+ {" feedbackConstant" , (int )constant }
112
71
});
113
72
#else
114
73
Q_UNUSED (constant);
0 commit comments