Skip to content

Commit

Permalink
Support edge to edge
Browse files Browse the repository at this point in the history
Signed-off-by: Aayush Gupta <[email protected]>
  • Loading branch information
theimpulson committed Sep 18, 2024
1 parent fa56a74 commit b9b7c96
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/src/main/java/com/stevesoltys/seedvault/extensions/Activity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* SPDX-FileCopyrightText: 2024 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/

package com.stevesoltys.seedvault.extensions

import android.app.Activity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat

fun Activity.setupEdgeToEdge() {
val rootView = window.decorView.rootView
WindowCompat.setDecorFitsSystemWindows(window, false)
ViewCompat.setOnApplyWindowInsetsListener(rootView) { v, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(insets.left, insets.top, insets.right, insets.bottom)
WindowInsetsCompat.CONSUMED
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@

package com.stevesoltys.seedvault.ui

import android.os.Bundle
import android.view.MenuItem
import androidx.annotation.CallSuper
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.extensions.setupEdgeToEdge

abstract class BackupActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
setupEdgeToEdge()
super.onCreate(savedInstanceState)
}

@CallSuper
override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
android.R.id.home -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ package com.stevesoltys.seedvault.ui.storage
import android.content.Intent.FLAG_GRANT_PREFIX_URI_PERMISSION
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.stevesoltys.seedvault.extensions.setupEdgeToEdge

class PermissionGrantActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
setupEdgeToEdge()
super.onCreate(savedInstanceState)

if (intent?.data != null) {
Expand Down

0 comments on commit b9b7c96

Please sign in to comment.