aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-17 23:09:05 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-09-17 23:09:05 +0530
commit4bee579e48aa1bc9ff74b8f088131ebf91dd216a (patch)
treeccd837871d00a2ef53fa0d502ca70a1ad0d09b59 /ui/src/main/java
parentui: replace deprecated onActivityCreated with onViewCreated (diff)
downloadwireguard-android-4bee579e48aa1bc9ff74b8f088131ebf91dd216a.tar.xz
wireguard-android-4bee579e48aa1bc9ff74b8f088131ebf91dd216a.zip
ui: retire EdgeToEdge
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java')
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt6
-rw-r--r--ui/src/main/java/com/wireguard/android/activity/MainActivity.kt12
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt8
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt4
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt6
-rw-r--r--ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt66
6 files changed, 1 insertions, 101 deletions
diff --git a/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt b/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt
index 84cc6c7..eeabe4d 100644
--- a/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt
@@ -39,9 +39,6 @@ import com.wireguard.android.R
import com.wireguard.android.databinding.LogViewerActivityBinding
import com.wireguard.android.util.DownloadsFileSaver
import com.wireguard.android.util.ErrorMessages
-import com.wireguard.android.widget.EdgeToEdge.setUpFAB
-import com.wireguard.android.widget.EdgeToEdge.setUpRoot
-import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent
import com.wireguard.crypto.KeyPair
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -97,9 +94,6 @@ class LogViewerActivity : AppCompatActivity() {
binding = LogViewerActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
- setUpFAB(binding.shareFab)
- setUpRoot(binding.root)
- setUpScrollingContent(binding.recyclerView, binding.shareFab)
logAdapter = LogEntryAdapter()
binding.recyclerView.apply {
recyclerView = this
diff --git a/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt b/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt
index f567e76..336cda8 100644
--- a/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt
+++ b/ui/src/main/java/com/wireguard/android/activity/MainActivity.kt
@@ -10,8 +10,6 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.ActionBar
-import androidx.core.view.ViewCompat
-import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import com.wireguard.android.R
@@ -59,16 +57,6 @@ class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener
isTwoPaneLayout = findViewById<View?>(R.id.master_detail_wrapper) != null
supportFragmentManager.addOnBackStackChangedListener(this)
onBackStackChanged()
- // Dispatch insets on back stack change
- // This is required to ensure replaced fragments are also able to consume insets
- findViewById<View>(R.id.main_activity_container).setOnApplyWindowInsetsListener { _, insets ->
- supportFragmentManager.addOnBackStackChangedListener {
- supportFragmentManager.fragments.forEach {
- ViewCompat.dispatchApplyWindowInsets(it.requireView(), WindowInsetsCompat.toWindowInsetsCompat(insets))
- }
- }
- insets
- }
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
index 7562766..21f0be5 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
@@ -17,8 +17,6 @@ import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.TunnelDetailFragmentBinding
import com.wireguard.android.databinding.TunnelDetailPeerBinding
import com.wireguard.android.model.ObservableTunnel
-import com.wireguard.android.widget.EdgeToEdge.setUpRoot
-import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent
import kotlinx.coroutines.launch
import java.util.Timer
import java.util.TimerTask
@@ -55,11 +53,7 @@ class TunnelDetailFragment : BaseFragment() {
savedInstanceState: Bundle?): View? {
super.onCreateView(inflater, container, savedInstanceState)
binding = TunnelDetailFragmentBinding.inflate(inflater, container, false)
- binding?.apply {
- executePendingBindings()
- setUpRoot(root as ViewGroup)
- setUpScrollingContent(root as ViewGroup, null)
- }
+ binding?.executePendingBindings()
return binding!!.root
}
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
index f26862a..2634921 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.kt
@@ -29,8 +29,6 @@ import com.wireguard.android.util.AdminKnobs
import com.wireguard.android.util.BiometricAuthenticator
import com.wireguard.android.util.ErrorMessages
import com.wireguard.android.viewmodel.ConfigProxy
-import com.wireguard.android.widget.EdgeToEdge.setUpRoot
-import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent
import com.wireguard.config.Config
import kotlinx.coroutines.launch
@@ -77,8 +75,6 @@ class TunnelEditorFragment : BaseFragment() {
binding = TunnelEditorFragmentBinding.inflate(inflater, container, false)
binding?.apply {
executePendingBindings()
- setUpRoot(root as ViewGroup)
- setUpScrollingContent(mainContainer, null)
privateKeyTextLayout.setEndIconOnClickListener { config?.`interface`?.generateKeyPair() }
}
return binding?.root
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
index 29b667b..11ebc4d 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt
@@ -32,9 +32,6 @@ import com.wireguard.android.databinding.TunnelListItemBinding
import com.wireguard.android.fragment.ConfigNamingDialogFragment.Companion.newInstance
import com.wireguard.android.model.ObservableTunnel
import com.wireguard.android.util.ErrorMessages
-import com.wireguard.android.widget.EdgeToEdge.setUpFAB
-import com.wireguard.android.widget.EdgeToEdge.setUpRoot
-import com.wireguard.android.widget.EdgeToEdge.setUpScrollingContent
import com.wireguard.android.widget.MultiselectableRelativeLayout
import com.wireguard.config.Config
import kotlinx.coroutines.Deferred
@@ -209,9 +206,6 @@ class TunnelListFragment : BaseFragment() {
bottomSheet.show(childFragmentManager, "BOTTOM_SHEET")
}
executePendingBindings()
- setUpRoot(root as ViewGroup)
- setUpFAB(createFab)
- setUpScrollingContent(tunnelList, createFab)
}
return binding!!.root
}
diff --git a/ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt b/ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt
deleted file mode 100644
index 3f109b3..0000000
--- a/ui/src/main/java/com/wireguard/android/widget/EdgeToEdge.kt
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright © 2020 WireGuard LLC. All Rights Reserved.
- * SPDX-License-Identifier: Apache-2.0
- */
-package com.wireguard.android.widget
-
-import android.view.View
-import android.view.ViewGroup
-import androidx.core.view.marginBottom
-import androidx.core.view.marginLeft
-import androidx.core.view.marginRight
-import androidx.core.view.marginTop
-import androidx.core.view.updateLayoutParams
-import androidx.core.view.updatePadding
-import com.google.android.material.floatingactionbutton.FloatingActionButton
-
-/**
- * A utility for edge-to-edge display. It provides several features needed to make the app
- * displayed edge-to-edge on Android Q with gestural navigation.
- */
-
-object EdgeToEdge {
- @JvmStatic
- fun setUpRoot(root: ViewGroup) {
- root.systemUiVisibility =
- View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
- }
-
- @JvmStatic
- fun setUpScrollingContent(scrollingContent: ViewGroup, fab: FloatingActionButton?) {
- val originalPaddingLeft = scrollingContent.paddingLeft
- val originalPaddingRight = scrollingContent.paddingRight
- val originalPaddingBottom = scrollingContent.paddingBottom
-
- val fabPaddingBottom = fab?.height ?: 0
-
- val originalMarginTop = scrollingContent.marginTop
-
- scrollingContent.setOnApplyWindowInsetsListener { _, windowInsets ->
- scrollingContent.updatePadding(
- left = originalPaddingLeft + windowInsets.systemWindowInsetLeft,
- right = originalPaddingRight + windowInsets.systemWindowInsetRight,
- bottom = originalPaddingBottom + fabPaddingBottom + windowInsets.systemWindowInsetBottom
- )
- scrollingContent.updateLayoutParams<ViewGroup.MarginLayoutParams> {
- topMargin = originalMarginTop + windowInsets.systemWindowInsetTop
- }
- windowInsets
- }
- }
-
- @JvmStatic
- fun setUpFAB(fab: FloatingActionButton) {
- val originalMarginLeft = fab.marginLeft
- val originalMarginRight = fab.marginRight
- val originalMarginBottom = fab.marginBottom
- fab.setOnApplyWindowInsetsListener { _, windowInsets ->
- fab.updateLayoutParams<ViewGroup.MarginLayoutParams> {
- leftMargin = originalMarginLeft + windowInsets.systemWindowInsetLeft
- rightMargin = originalMarginRight + windowInsets.systemWindowInsetRight
- bottomMargin = originalMarginBottom + windowInsets.systemWindowInsetBottom
- }
- windowInsets
- }
- }
-}