Skip to content

Commit

Permalink
Merge pull request #80 from gulerbu/dialogs/webview_focus
Browse files Browse the repository at this point in the history
Fix webview focus problem
  • Loading branch information
gulerbu authored Jul 27, 2021
2 parents c9ba131 + c72ff39 commit bef46f3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/ComponentVersions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object ComponentVersions {
const val ratingBarVersion = "1.0.2"
const val imageSliderVersion = "1.0.8"
const val phoneNumberVersion = "1.0.2"
const val dialogsVersion = "1.2.4"
const val dialogsVersion = "1.2.5"
const val cardInputViewVersion = "1.1.2"
const val quantityPickerViewVersion = "1.2.4"
const val timelineViewVersion = "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import android.text.SpannableString
import android.text.method.LinkMovementMethod
import android.text.util.Linkify
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS
import android.view.ViewGroup.FOCUS_DOWN
import android.view.ViewOutlineProvider
import android.webkit.WebChromeClient
import android.webkit.WebViewClient
import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.ViewModelProviders
Expand Down Expand Up @@ -92,8 +95,6 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog() {
dialogListViewModel.clearSearch()
}

constraintLayout.descendantFocusability = FOCUS_AFTER_DESCENDANTS

setUpViewModel(items)
}
}
Expand Down Expand Up @@ -153,6 +154,7 @@ class DialogFragment internal constructor() : BaseBottomSheetDialog() {
visibility = viewState.getWebViewContentVisibility()
if (visibility == View.VISIBLE) {
webChromeClient = WebChromeClient()
webViewClient = WebViewClient()
dialogArguments.webViewBuilder?.invoke(webViewContent)

loadWebViewContent(viewState.webViewContent)
Expand Down
7 changes: 3 additions & 4 deletions libraries/dialogs/src/main/res/layout/fragment_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical">

<LinearLayout
android:id="@+id/viewTitleBackground"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:focusableInTouchMode="true"
android:paddingStart="@dimen/dialogs_margin_outer"
android:paddingEnd="@dimen/dialogs_margin_outer">

Expand Down Expand Up @@ -49,8 +47,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants">
android:layout_height="match_parent">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/imageContent"
Expand Down Expand Up @@ -82,6 +79,8 @@
android:layout_height="wrap_content"
android:paddingTop="@dimen/dialogs_margin_inner"
android:paddingBottom="@dimen/dialogs_margin_inner"
android:focusable="true"
android:focusableInTouchMode="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textContent"
Expand Down
4 changes: 3 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
</intent-filter>
</activity>
<activity android:name=".RatingBarActivity" />
<activity android:name=".DialogsActivity" />
<activity android:name=".DialogsActivity"
android:windowSoftInputMode="adjustResize">
</activity>
<activity android:name=".ImageSliderActivity" />
<activity android:name=".PhoneNumberActivity" />
<activity android:name=".ToolbarActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.trendyol.uicomponents
import android.os.Bundle
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.webkit.WebViewClient
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
Expand Down Expand Up @@ -121,10 +122,11 @@ class DialogsActivity : AppCompatActivity() {
title = "Info Dialog Sample"
showCloseButton = true
closeButtonListener = infoDialogClosed
webViewContent = WebViewContent.UrlContent("https://kargotakip.trendyol.com/")
webViewContent = WebViewContent.UrlContent("https://github.com/Trendyol/android-ui-components")
webViewBuilder = {
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
webViewClient = WebViewClient()
}
}.showDialog(supportFragmentManager)

Expand Down

0 comments on commit bef46f3

Please sign in to comment.