fix: undo all of the margin hacks

Using 72dp as the height appears to have been a bit of a hack to appear beyond the navigation bar. In cases where the bar is not present, such as landscape, this left a gap between the bottom of the screen and bar. On API 23, the result was the opposite. All of this can be addressed by simply relying on the actual measurements and not compensating for compensation.
This commit is contained in:
TwistedUmbrellaX 2024-03-18 18:18:35 -04:00
parent d1e03b8237
commit e5f58f20c7
10 changed files with 124 additions and 84 deletions

View file

@ -5,6 +5,7 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.graphics.Rect
import android.content.res.Configuration
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.util.TypedValue
@ -24,6 +25,7 @@ import androidx.core.text.bold
import androidx.core.text.color
import androidx.core.view.marginBottom
import androidx.core.view.updateLayoutParams
import androidx.core.view.updateMargins
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Lifecycle
@ -105,7 +107,7 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
//Ui init
initActivity(this)
binding.mediaViewPager.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin += navBarHeight }
binding.mediaViewPager.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin = navBarHeight }
val oldMargin = binding.mediaViewPager.marginBottom
AndroidBug5497Workaround.assistActivity(this) {
if (it) {
@ -120,6 +122,9 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
binding.mediaTabContainer.visibility = View.VISIBLE
}
}
val navBarMargin = if (resources.configuration.orientation ==
Configuration.ORIENTATION_LANDSCAPE) navBarHeight else 0
binding.mediaTabContainer.updateLayoutParams<ViewGroup.MarginLayoutParams> { rightMargin = navBarMargin }
binding.mediaBanner.updateLayoutParams { height += statusBarHeight }
binding.mediaBannerNoKen.updateLayoutParams { height += statusBarHeight }
binding.mediaClose.updateLayoutParams<ViewGroup.MarginLayoutParams> { topMargin += statusBarHeight }
@ -432,6 +437,14 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
return R.id.info
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
val margin = if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) navBarHeight else 0
val params : ViewGroup.MarginLayoutParams =
binding.mediaTabContainer.layoutParams as ViewGroup.MarginLayoutParams
params.updateMargins(right = margin)
}
override fun onResume() {
if (this::tabLayout.isInitialized) {
tabLayout.selectTab(selected)
@ -602,4 +615,4 @@ class MediaDetailsActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedLi
companion object {
var mediaSingleton: Media? = null
}
}
}