neiam
/neiam-devices
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
droid: keep the settings clear of the status and navigation bars
3702d46 · Gabriel Morell · 2026-09-29 23:53
Message
{commit_body(@commit)}
Files changed
modified
droid/app/src/main/java/io/neiam/moire/SettingsActivity.kt
+43
−2
@@ -12,10 +12,17 @@ import android.location.LocationManager
| 12 | 12 | import android.os.Build |
| 13 | 13 | import android.os.Bundle |
| 14 | 14 | import android.text.InputType |
| 15 | +import android.view.View | |
| 15 | 16 | import android.widget.Toast |
| 17 | +import androidx.activity.SystemBarStyle | |
| 18 | +import androidx.activity.enableEdgeToEdge | |
| 16 | 19 | import androidx.activity.result.contract.ActivityResultContracts |
| 17 | 20 | import androidx.appcompat.app.AppCompatActivity |
| 21 | +import androidx.appcompat.widget.Toolbar | |
| 18 | 22 | import androidx.core.content.ContextCompat |
| 23 | +import androidx.core.view.ViewCompat | |
| 24 | +import androidx.core.view.WindowInsetsCompat | |
| 25 | +import androidx.core.view.updatePadding | |
| 19 | 26 | import androidx.preference.EditTextPreference |
| 20 | 27 | import androidx.preference.ListPreference |
| 21 | 28 | import androidx.preference.Preference |
@@ -23,13 +30,35 @@ import androidx.preference.PreferenceFragmentCompat
| 23 | 30 | import androidx.preference.SeekBarPreference |
| 24 | 31 | import java.util.Locale |
| 25 | 32 | |
| 26 | −/** The launcher entry and the wallpaper's settings, in one screen. */ | |
| 33 | +/** | |
| 34 | + * The launcher entry and the wallpaper's settings, in one screen. | |
| 35 | + * | |
| 36 | + * Android 15 draws apps that target it edge to edge, under the status | |
| 37 | + * and navigation bars, so the screen pads itself clear of them: the | |
| 38 | + * toolbar below the status bar, the list above the navigation bar. | |
| 39 | + */ | |
| 27 | 40 | class SettingsActivity : AppCompatActivity() { |
| 28 | 41 | override fun onCreate(savedInstanceState: Bundle?) { |
| 42 | + // Light status bar icons over the dark toolbar, whatever the | |
| 43 | + // system's own light or dark setting. | |
| 44 | + enableEdgeToEdge(statusBarStyle = SystemBarStyle.dark(android.graphics.Color.TRANSPARENT)) | |
| 29 | 45 | super.onCreate(savedInstanceState) |
| 46 | + setContentView(R.layout.activity_settings) | |
| 47 | + | |
| 48 | + val toolbar = findViewById<Toolbar>(R.id.toolbar) | |
| 49 | + toolbar.title = getString(R.string.app_name) | |
| 50 | + setSupportActionBar(toolbar) | |
| 51 | + | |
| 52 | + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.root)) { root, insets -> | |
| 53 | + val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()) | |
| 54 | + root.updatePadding(left = bars.left, right = bars.right) | |
| 55 | + toolbar.updatePadding(top = bars.top) | |
| 56 | + insets | |
| 57 | + } | |
| 58 | + | |
| 30 | 59 | if (savedInstanceState == null) { |
| 31 | 60 | supportFragmentManager.beginTransaction() |
| 32 | − .replace(android.R.id.content, SettingsFragment()) | |
| 61 | + .replace(R.id.settings, SettingsFragment()) | |
| 33 | 62 | .commit() |
| 34 | 63 | } |
| 35 | 64 | } |
@@ -95,6 +124,18 @@ class SettingsActivity : AppCompatActivity() {
| 95 | 124 | refresh() |
| 96 | 125 | } |
| 97 | 126 | |
| 127 | + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| 128 | + super.onViewCreated(view, savedInstanceState) | |
| 129 | + // Scrolls under the navigation bar but can always be scrolled | |
| 130 | + // clear of it. | |
| 131 | + listView.clipToPadding = false | |
| 132 | + ViewCompat.setOnApplyWindowInsetsListener(listView) { list, insets -> | |
| 133 | + val bars = insets.getInsets(WindowInsetsCompat.Type.navigationBars()) | |
| 134 | + list.updatePadding(bottom = bars.bottom) | |
| 135 | + insets | |
| 136 | + } | |
| 137 | + } | |
| 138 | + | |
| 98 | 139 | override fun onResume() { |
| 99 | 140 | super.onResume() |
| 100 | 141 | preferenceManager.sharedPreferences?.registerOnSharedPreferenceChangeListener(this) |
added
droid/app/src/main/res/layout/activity_settings.xml
+24
−0
@@ -0,0 +1,24 @@
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 2 | +<!-- The screen draws edge to edge (Android 15 requires it of apps that | |
| 3 | + target it); SettingsActivity pads the toolbar below the status bar | |
| 4 | + and the list above the navigation bar. --> | |
| 5 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 6 | + android:id="@+id/root" | |
| 7 | + android:layout_width="match_parent" | |
| 8 | + android:layout_height="match_parent" | |
| 9 | + android:orientation="vertical"> | |
| 10 | + | |
| 11 | + <androidx.appcompat.widget.Toolbar | |
| 12 | + android:id="@+id/toolbar" | |
| 13 | + android:layout_width="match_parent" | |
| 14 | + android:layout_height="wrap_content" | |
| 15 | + android:minHeight="?attr/actionBarSize" | |
| 16 | + android:background="?attr/colorPrimary" | |
| 17 | + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> | |
| 18 | + | |
| 19 | + <FrameLayout | |
| 20 | + android:id="@+id/settings" | |
| 21 | + android:layout_width="match_parent" | |
| 22 | + android:layout_height="0dp" | |
| 23 | + android:layout_weight="1" /> | |
| 24 | +</LinearLayout> |
modified
droid/app/src/main/res/values/themes.xml
+1
−1
@@ -1,6 +1,6 @@
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <resources> |
| 3 | − <style name="Theme.Moire" parent="Theme.AppCompat.DayNight.DarkActionBar"> | |
| 3 | + <style name="Theme.Moire" parent="Theme.AppCompat.DayNight.NoActionBar"> | |
| 4 | 4 | <item name="colorPrimary">#661e1e</item> |
| 5 | 5 | <item name="colorPrimaryDark">#470005</item> |
| 6 | 6 | <item name="colorAccent">#b6797a</item> |
Parents: 12bf40f