Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.github.quarck.calnotify.logs.DevLog
import com.github.quarck.calnotify.utils.background
import com.github.quarck.calnotify.utils.find
import com.github.quarck.calnotify.utils.findOrThrow
import com.github.quarck.calnotify.utils.setupStatusBarSpacer

enum class CalendarListEntryType {Header, Calendar, Divider }

Expand Down Expand Up @@ -169,6 +170,7 @@ class CalendarsActivity : AppCompatActivity() {
DevLog.debug(LOG_TAG, "onCreate")

setContentView(R.layout.activity_calendars)
setupStatusBarSpacer()
setSupportActionBar(find<Toolbar?>(R.id.toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import com.github.quarck.calnotify.permissions.PermissionsManager
import com.github.quarck.calnotify.utils.background
import com.github.quarck.calnotify.utils.find
import com.github.quarck.calnotify.utils.findOrThrow
import com.github.quarck.calnotify.utils.setupStatusBarSpacer


class BlueboothDeviceListEntry(
Expand Down Expand Up @@ -124,6 +125,7 @@ class CarModeActivity : AppCompatActivity() {
DevLog.debug(LOG_TAG, "onCreate")

setContentView(R.layout.activity_car_mode)
setupStatusBarSpacer()
setSupportActionBar(find<Toolbar?>(R.id.toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import android.widget.TextView
import com.github.quarck.calnotify.BuildConfig
import com.github.quarck.calnotify.R
import com.github.quarck.calnotify.utils.find
import com.github.quarck.calnotify.utils.setupStatusBarSpacer
import java.text.SimpleDateFormat
import java.util.*

Expand All @@ -39,6 +40,7 @@ class AboutActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_about)
setupStatusBarSpacer()

setSupportActionBar(find<Toolbar?>(R.id.toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.github.quarck.calnotify.logs.DevLog
import com.github.quarck.calnotify.utils.background
import com.github.quarck.calnotify.utils.find
import com.github.quarck.calnotify.utils.findOrThrow
import com.github.quarck.calnotify.utils.setupStatusBarSpacer
class DismissedEventsActivity : AppCompatActivity(), DismissedEventListCallback {

private val settings: Settings by lazy { Settings(this) }
Expand All @@ -33,6 +34,7 @@ class DismissedEventsActivity : AppCompatActivity(), DismissedEventListCallback
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_dismissed_events)
setupStatusBarSpacer()

setSupportActionBar(find<Toolbar?>(R.id.toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import com.github.quarck.calnotify.logs.DevLog
import com.github.quarck.calnotify.textutils.EventFormatter
import com.github.quarck.calnotify.textutils.dateToStr
import com.github.quarck.calnotify.utils.*
import com.github.quarck.calnotify.utils.setupStatusBarSpacer
import java.util.*

// FIXME: on the snooze activity - show all the reminders, not just next
Expand Down Expand Up @@ -315,6 +316,7 @@ open class EditEventActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)

setContentView(R.layout.activity_add_event)
setupStatusBarSpacer()

val toolbar = find<Toolbar?>(R.id.toolbar)
toolbar?.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import com.github.quarck.calnotify.quiethours.QuietHoursManager
import com.github.quarck.calnotify.utils.background
import com.github.quarck.calnotify.utils.find
import com.github.quarck.calnotify.utils.findOrThrow
import com.github.quarck.calnotify.utils.setupStatusBarSpacer
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar

Expand Down Expand Up @@ -112,15 +113,7 @@ class MainActivityLegacy : MainActivityBase(), EventListCallback {
window.statusBarColor = getColor(R.color.primary_dark)

// Set status bar spacer height
findViewById<View>(R.id.status_bar_spacer)?.let { spacer ->
ViewCompat.setOnApplyWindowInsetsListener(spacer) { view, insets ->
val statusBarInset = insets.getInsets(WindowInsetsCompat.Type.statusBars()).top
view.layoutParams.height = statusBarInset
view.requestLayout()
insets
}
ViewCompat.requestApplyInsets(spacer)
}
setupStatusBarSpacer()

// Apply nav bar inset to FAB bottom margin
findViewById<FloatingActionButton>(R.id.action_btn_add_event)?.let { fab ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import com.github.quarck.calnotify.globalState
import com.github.quarck.calnotify.utils.DateTimeUtils
import com.github.quarck.calnotify.utils.find
import com.github.quarck.calnotify.utils.findOrThrow
import com.github.quarck.calnotify.utils.setupStatusBarSpacer
import com.github.quarck.calnotify.utils.truncateForChip
import androidx.appcompat.view.ContextThemeWrapper
import com.google.android.material.bottomnavigation.BottomNavigationView
Expand Down Expand Up @@ -117,16 +118,7 @@ class MainActivityModern : MainActivityBase() {
window.statusBarColor = getColor(R.color.primary_dark)

// Set status bar spacer height (pinned, doesn't scroll with toolbar)
val statusBarSpacer = findViewById<View>(R.id.status_bar_spacer)
statusBarSpacer?.let { spacer ->
ViewCompat.setOnApplyWindowInsetsListener(spacer) { view, insets ->
val statusBarInset = insets.getInsets(WindowInsetsCompat.Type.statusBars()).top
view.layoutParams.height = statusBarInset
view.requestLayout()
insets
}
ViewCompat.requestApplyInsets(spacer)
}
setupStatusBarSpacer()

// Set up navigation
val navHostFragment = supportFragmentManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import com.github.quarck.calnotify.textutils.EventFormatterInterface
import com.github.quarck.calnotify.utils.CNPlusClockInterface
import com.github.quarck.calnotify.utils.CNPlusSystemClock
import com.github.quarck.calnotify.utils.background
import com.github.quarck.calnotify.utils.setupStatusBarSpacer

/**
* Activity for pre-actions on upcoming events.
Expand Down Expand Up @@ -143,6 +144,7 @@ class PreActionActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_pre_action)
setupStatusBarSpacer()

settings = Settings(this)
formatter = EventFormatter(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import com.github.quarck.calnotify.R
import com.github.quarck.calnotify.utils.setupStatusBarSpacer

class PrivacyPolicyActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_privacy_policy)
setupStatusBarSpacer()
val toolbar = findViewById(R.id.toolbar) as Toolbar
setSupportActionBar(toolbar)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.github.quarck.calnotify.logs.DevLog
import com.github.quarck.calnotify.utils.find
import com.github.quarck.calnotify.utils.CNPlusClockInterface
import com.github.quarck.calnotify.utils.CNPlusSystemClock
import com.github.quarck.calnotify.utils.setupStatusBarSpacer

class ReportABugActivity : AppCompatActivity() {
private var easterEggCount = 0;
Expand All @@ -42,6 +43,7 @@ class ReportABugActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_report_a_bug)
setupStatusBarSpacer()

setSupportActionBar(find<Toolbar?>(R.id.toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.github.quarck.calnotify.R
import com.github.quarck.calnotify.prefs.NavigationSettingsFragmentX
import com.github.quarck.calnotify.utils.setupStatusBarSpacer
import com.github.quarck.calnotify.prefs.PreferenceHeadersFragment

/**
Expand All @@ -38,6 +39,7 @@ class SettingsActivityX : AppCompatActivity(),
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_settings_x)
setupStatusBarSpacer()

setSupportActionBar(findViewById(R.id.toolbar))
supportActionBar?.setDisplayHomeAsUpEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.github.quarck.calnotify.quiethours.QuietHoursManager
import com.github.quarck.calnotify.textutils.EventFormatter
import com.github.quarck.calnotify.textutils.EventFormatterInterface
import com.github.quarck.calnotify.utils.*
import com.github.quarck.calnotify.utils.setupStatusBarSpacer
import java.util.*
import com.github.quarck.calnotify.*
import com.github.quarck.calnotify.logs.DevLog
Expand Down Expand Up @@ -113,6 +114,7 @@ open class SnoozeAllActivity : AppCompatActivity() {
state = ViewEventActivityState.fromBundle(savedInstanceState)

setContentView(R.layout.activity_snooze_all)
setupStatusBarSpacer()

val currentTime = clock.currentTimeMillis()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import com.github.quarck.calnotify.quiethours.QuietHoursManager
import com.github.quarck.calnotify.textutils.EventFormatter
import com.github.quarck.calnotify.textutils.EventFormatterInterface
import com.github.quarck.calnotify.utils.*
import com.github.quarck.calnotify.utils.setupStatusBarSpacer
import java.util.*
import com.github.quarck.calnotify.*
import com.github.quarck.calnotify.logs.DevLog
Expand Down Expand Up @@ -314,6 +315,9 @@ open class ViewEventActivityNoRecents : AppCompatActivity() {

window.statusBarColor = color.scaleColor(0.7f)

// Set status bar spacer height (for edge-to-edge displays)
setupStatusBarSpacer()

// val shouldOfferMove = (!event.isRepeating) && (DateTimeUtils.isUTCTodayOrInThePast(event.startTime))
val shouldOfferMove = (DateTimeUtils.isUTCTodayOrInThePast(event.startTime))
if (shouldOfferMove) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// Calendar Notifications Plus
// Copyright (C) 2025 William Harris (wharris+cnplus@upscalews.com)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//

package com.github.quarck.calnotify.utils

import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.github.quarck.calnotify.R

/**
* Sets up the status bar spacer for edge-to-edge display support.
* Call this after setContentView() in activities that have a status_bar_spacer view.
*
* The spacer view should be positioned at the top of the AppBarLayout or header area,
* with initial height of 0dp. This function sets its height to match the actual
* status bar inset on the device.
*/
fun AppCompatActivity.setupStatusBarSpacer() {
findViewById<View>(R.id.status_bar_spacer)?.let { spacer ->
ViewCompat.setOnApplyWindowInsetsListener(spacer) { view, insets ->
val statusBarInset = insets.getInsets(WindowInsetsCompat.Type.statusBars()).top
view.layoutParams.height = statusBarInset
view.requestLayout()
insets
}
ViewCompat.requestApplyInsets(spacer)
}
}
8 changes: 7 additions & 1 deletion android/app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:fitsSystemWindows="true"
tools:context=".ui.AboutActivity">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<!-- Status bar spacer - height set programmatically -->
<View
android:id="@+id/status_bar_spacer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/colorPrimary" />

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
Expand Down
1 change: 0 additions & 1 deletion android/app/src/main/res/layout/activity_add_event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:fitsSystemWindows="true"
tools:context="com.github.quarck.calnotify.ui.EditEventActivity">

<com.google.android.material.appbar.AppBarLayout
Expand Down
8 changes: 7 additions & 1 deletion android/app/src/main/res/layout/activity_calendars.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:fitsSystemWindows="true"
tools:context=".prefs.CalendarsActivity">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<!-- Status bar spacer - height set programmatically -->
<View
android:id="@+id/status_bar_spacer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/colorPrimary" />

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
Expand Down
8 changes: 7 additions & 1 deletion android/app/src/main/res/layout/activity_car_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:fitsSystemWindows="true"
tools:context=".prefs.CarModeActivity">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<!-- Status bar spacer - height set programmatically -->
<View
android:id="@+id/status_bar_spacer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/colorPrimary" />

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="0dp"
android:fitsSystemWindows="true"
tools:context=".ui.DismissedEventsActivity">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<!-- Status bar spacer - height set programmatically -->
<View
android:id="@+id/status_bar_spacer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/colorPrimary" />

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
Expand Down
Loading
Loading