From 6a948a088d0f3291a9f67bb9f7e421d9616f033b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20L=C3=B6bbecke?= Date: Sun, 26 May 2024 14:03:12 +0200 Subject: [PATCH] Updated gradle --- .../viewpump/ViewPumpAppCompatDelegate.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/viewpump/src/main/java/dev/b3nedikt/viewpump/ViewPumpAppCompatDelegate.kt b/viewpump/src/main/java/dev/b3nedikt/viewpump/ViewPumpAppCompatDelegate.kt index f4d0e90..b49d020 100644 --- a/viewpump/src/main/java/dev/b3nedikt/viewpump/ViewPumpAppCompatDelegate.kt +++ b/viewpump/src/main/java/dev/b3nedikt/viewpump/ViewPumpAppCompatDelegate.kt @@ -91,14 +91,16 @@ class ViewPumpAppCompatDelegate @JvmOverloads constructor( // WebViews cannot deal with custom resources, so we need to make // sure we use the unwrapped context here. if (name == "WebView") { - view = WebView(getWrappedContext(context), attrs) + view = WebView(getWrappedContext(), attrs) } if (view is WebView && name != "WebView") { view = createCustomWebView(view, context, attrs) } - view = createDialogWidgetView(context, name, view, attrs) + if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.P) { + view = createDialogWidgetView(context, name, view, attrs) + } // The framework SearchView needs to be inflated manually, // as it is not inflated by the AppCompatViewInflater @@ -161,7 +163,7 @@ class ViewPumpAppCompatDelegate @JvmOverloads constructor( it.parameterTypes[1] == AttributeSet::class.java } ?.newInstance( - getWrappedContext(context), + getWrappedContext(), attrs ) as View? } @@ -176,34 +178,34 @@ class ViewPumpAppCompatDelegate @JvmOverloads constructor( return when (name) { "com.android.internal.widget.AlertDialogLayout" -> - AlertDialogLayout(getWrappedContext(context), attrs) + AlertDialogLayout(getWrappedContext(), attrs) "com.android.internal.widget.DialogTitle" -> - DialogTitle(getWrappedContext(context), attrs) + DialogTitle(getWrappedContext(), attrs) "com.android.internal.widget.ButtonBarLayout" -> - ButtonBarLayout(getWrappedContext(context), attrs) + ButtonBarLayout(getWrappedContext(), attrs) // The following three widgets only exist on Samsung devices with android 9, // we replace them with their counterparts from android.widgets "CalendarView" -> - CalendarView(ContextThemeWrapper(getWrappedContext(context), context.theme), attrs) + CalendarView(ContextThemeWrapper(getWrappedContext(), context.theme), attrs) "DatePicker" -> - DatePicker(ContextThemeWrapper(getWrappedContext(context), context.theme), attrs) + DatePicker(ContextThemeWrapper(getWrappedContext(), context.theme), attrs) "NumberPicker" -> - NumberPicker(ContextThemeWrapper(getWrappedContext(context), context.theme), attrs) + NumberPicker(ContextThemeWrapper(getWrappedContext(), context.theme), attrs) else -> view } } - private fun getWrappedContext(context: Context): Context { + private fun getWrappedContext(): Context { val wrappedContext = webViewContext if (wrappedContext != null) return wrappedContext - webViewContext = super.attachBaseContext2(WebViewContextWrapper(context)) + webViewContext = baseDelegate.attachBaseContext2(WebViewContextWrapper(baseContext)) return webViewContext!! } } \ No newline at end of file