Skip to content

Commit

Permalink
Fixed: After restoring the tab it hides a few area of the article fro…
Browse files Browse the repository at this point in the history
…m the top.

* It was showing with the top margin we have set in `TabsAdapter` for not showing the top margin in tabs, and `tempWebViewForUndo` saved with that margin, so when we are showing this in our reader, it was showing with that margin. So to fix this we are removing this margin from the `tempWebViewForUndo` if `tabSwitcher` is not showing, for properly showing the webView content. If the tab switcher is showing it will work as before.
* Used the `safelyAddWebView` method when we were selecting the tab as this method is doing the same that we are doing in `selectTab` method so to reduce duplicate code we used this method.
  • Loading branch information
MohitMaliDeveloper committed Mar 11, 2024
1 parent 08face5 commit 3366b4b
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import android.os.IBinder
import android.os.Looper
import android.provider.Settings
import android.util.AttributeSet
import org.kiwix.kiwixmobile.core.utils.files.Log
import android.view.ActionMode
import android.view.LayoutInflater
import android.view.Menu
Expand All @@ -57,6 +56,7 @@ import android.widget.Button
import android.widget.FrameLayout
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
Expand Down Expand Up @@ -159,6 +159,7 @@ import org.kiwix.kiwixmobile.core.utils.dialog.DialogShower
import org.kiwix.kiwixmobile.core.utils.dialog.KiwixDialog
import org.kiwix.kiwixmobile.core.utils.files.FileUtils.deleteCachedFiles
import org.kiwix.kiwixmobile.core.utils.files.FileUtils.readFile
import org.kiwix.kiwixmobile.core.utils.files.Log
import org.kiwix.kiwixmobile.core.utils.titleToUrl
import org.kiwix.kiwixmobile.core.utils.urlSuffixToParsableUrl
import org.kiwix.libkiwix.Book
Expand Down Expand Up @@ -1221,6 +1222,16 @@ abstract class CoreReaderFragment :
reopenBook()
}
tempWebViewForUndo?.let {
if (tabSwitcherRoot?.visibility == View.GONE) {
// Remove the top margin from the webView when the tabSwitcher is not visible.
// We have added this margin in `TabsAdapter` to not show the top margin in tabs.
// `tempWebViewForUndo` saved with that margin so before showing it to the `contentFrame`
// We need to set full width and height for properly showing the content of webView.
it.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT

Check warning on line 1232 in core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt#L1230-L1232

Added lines #L1230 - L1232 were not covered by tests
)
}
zimReaderContainer?.setZimFile(tempZimFileForUndo)
webViewList.add(index, it)
tabsAdapter?.notifyDataSetChanged()
Expand All @@ -1243,10 +1254,7 @@ abstract class CoreReaderFragment :
contentFrame?.let {
it.removeAllViews()
val webView = safelyGetWebView(position) ?: return@selectTab
webView.parent?.let {
(webView.parent as ViewGroup).removeView(webView)
}
it.addView(webView)
safelyAddWebView(webView)
tabsAdapter?.selected = currentWebViewIndex
updateBottomToolbarVisibility()
loadPrefs()
Expand Down

0 comments on commit 3366b4b

Please sign in to comment.