Compare commits

...

3 commits

Author SHA1 Message Date
a6777d1d17 Apply layout insets to more activities
All checks were successful
/ build-debug (push) Successful in 5m28s
2024-09-28 11:05:18 -04:00
dc70f7ca46 Fix toolbar id in app-unpriv 2024-09-28 10:58:46 -04:00
77d95e4d02 Remove unused log 2024-09-28 10:44:29 -04:00
6 changed files with 53 additions and 5 deletions

View file

@ -19,6 +19,9 @@ import android.widget.PopupMenu
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
@ -76,6 +79,21 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
fab = view.requireViewById(R.id.fab)
profileList = view.requireViewById(R.id.profile_list)
val origFabMarginRight = (fab.layoutParams as ViewGroup.MarginLayoutParams).rightMargin
val origFabMarginBottom = (fab.layoutParams as ViewGroup.MarginLayoutParams).bottomMargin
ViewCompat.setOnApplyWindowInsetsListener(fab) { v, insets ->
val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
rightMargin = origFabMarginRight + bars.right
bottomMargin = origFabMarginBottom + bars.bottom
}
WindowInsetsCompat.CONSUMED
}
setupRootViewInsets(profileList)
return view
}

View file

@ -49,6 +49,8 @@ class LogsActivity : AppCompatActivity() {
scrollView = requireViewById(R.id.scroll_view)
logText = requireViewById(R.id.log_text)
setupRootViewInsets(scrollView)
swipeRefresh.setOnRefreshListener {
lifecycleScope.launch {
reload()

View file

@ -42,15 +42,17 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
setSupportActionBar(requireViewById(R.id.toolbar))
setupToolbarInsets()
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
swipeRefresh = requireViewById(R.id.swipe_refresh)
notificationList = requireViewById(R.id.recycler_view)
setupRootViewInsets(notificationList)
}
override fun onInit() {
euiccChannel = euiccChannelManager
.findEuiccChannelBySlotBlocking(intent.getIntExtra("logicalSlotId", 0))!!
swipeRefresh = requireViewById(R.id.swipe_refresh)
notificationList = requireViewById(R.id.recycler_view)
notificationList.layoutManager =
LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
notificationList.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL))

View file

@ -3,6 +3,9 @@ package im.angry.openeuicc.ui
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.datastore.preferences.core.Preferences
import androidx.lifecycle.lifecycleScope
import androidx.preference.CheckBoxPreference
@ -46,6 +49,14 @@ class SettingsFragment: PreferenceFragmentCompat() {
?.bindBooleanFlow(preferenceRepository.disableSafeguardFlow, PreferenceKeys.DISABLE_SAFEGUARD_REMOVABLE_ESIM)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return super.onCreateView(inflater, container, savedInstanceState).also(::setupRootViewInsets)
}
private fun CheckBoxPreference.bindBooleanFlow(flow: Flow<Boolean>, key: Preferences.Key<Boolean>) {
lifecycleScope.launch {
flow.collect { isChecked = it }

View file

@ -52,7 +52,20 @@ fun AppCompatActivity.setupToolbarInsets() {
height = v.top
}
android.util.Log.d("aaa", "${(v as Toolbar).minimumHeight}")
WindowInsetsCompat.CONSUMED
}
}
fun setupRootViewInsets(view: View) {
ViewCompat.setOnApplyWindowInsetsListener(view) { v, insets ->
val bars = insets.getInsets(
WindowInsetsCompat.Type.systemBars()
or WindowInsetsCompat.Type.displayCutout()
)
// Don't set padding bottom because we do want scrolling root views to extend into nav bar
v.updatePadding(bars.left, v.paddingTop, bars.right, v.paddingBottom)
WindowInsetsCompat.CONSUMED
}
}

View file

@ -26,7 +26,7 @@ class CompatibilityCheckActivity: AppCompatActivity() {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_compatibility_check)
setSupportActionBar(requireViewById(R.id.toolbar))
setSupportActionBar(requireViewById(im.angry.openeuicc.common.R.id.toolbar))
setupToolbarInsets()
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
@ -35,6 +35,8 @@ class CompatibilityCheckActivity: AppCompatActivity() {
LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
compatibilityCheckList.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL))
compatibilityCheckList.adapter = adapter
setupRootViewInsets(compatibilityCheckList)
}
override fun onStart() {