diff --git a/app/build.gradle b/app/build.gradle index 728a0d6..4c98290 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,36 +12,36 @@ try { } android { - namespace 'com.github.shingyx.boomswitch' + namespace = 'com.github.shingyx.boomswitch' signingConfigs { release { - storeFile rootProject.file(keystoreProperties['storeFile'] ?: "default.jks") - storePassword keystoreProperties['storePassword'] - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] + storeFile = rootProject.file(keystoreProperties['storeFile'] ?: "default.jks") + storePassword = keystoreProperties['storePassword'] + keyAlias = keystoreProperties['keyAlias'] + keyPassword = keystoreProperties['keyPassword'] } } - compileSdk 36 + compileSdk = 36 defaultConfig { - applicationId "com.github.shingyx.boomswitch" - minSdk 23 - targetSdk 36 - versionCode 12 - versionName "1.8" + applicationId = "com.github.shingyx.boomswitch" + minSdk = 23 + targetSdk = 36 + versionCode = 12 + versionName = "1.8" } buildTypes { debug { - applicationIdSuffix ".dev" - versionNameSuffix "-dev" + applicationIdSuffix = ".dev" + versionNameSuffix = "-dev" } release { - minifyEnabled true + minifyEnabled = true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') - signingConfig signingConfigs.release + signingConfig = signingConfigs.release } } buildFeatures { - viewBinding true + viewBinding = true } kotlin { jvmToolchain(21) @@ -57,7 +57,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.7.1' implementation 'androidx.constraintlayout:constraintlayout:2.2.1' - implementation 'com.google.android.gms:play-services-oss-licenses:17.2.1' + implementation 'com.google.android.gms:play-services-oss-licenses:17.2.2' implementation 'com.google.android.material:material:1.12.0' implementation 'com.jakewharton.timber:timber:5.0.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 06cc656..b448bd0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + + android:theme="@style/AppTheme"> + android:exported="false" + android:theme="@style/AppThemeNoActionBar" /> diff --git a/app/src/main/java/com/github/shingyx/boomswitch/ui/HelpActivity.kt b/app/src/main/java/com/github/shingyx/boomswitch/ui/HelpActivity.kt index 6ae070e..98eeec5 100644 --- a/app/src/main/java/com/github/shingyx/boomswitch/ui/HelpActivity.kt +++ b/app/src/main/java/com/github/shingyx/boomswitch/ui/HelpActivity.kt @@ -13,6 +13,8 @@ class HelpActivity : AppCompatActivity() { super.onCreate(savedInstanceState) binding = ActivityHelpBinding.inflate(layoutInflater) setContentView(binding.root) + setSupportActionBar(binding.toolbar) + setSystemBarColors(this, binding.root) supportActionBar?.run { setTitle(R.string.help) diff --git a/app/src/main/java/com/github/shingyx/boomswitch/ui/LayoutUtil.kt b/app/src/main/java/com/github/shingyx/boomswitch/ui/LayoutUtil.kt new file mode 100644 index 0000000..91ac09b --- /dev/null +++ b/app/src/main/java/com/github/shingyx/boomswitch/ui/LayoutUtil.kt @@ -0,0 +1,48 @@ +package com.github.shingyx.boomswitch.ui + +import android.content.Context +import android.content.res.Configuration +import android.os.Build +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.updateLayoutParams +import com.github.shingyx.boomswitch.R + +fun setSystemBarColors(activity: AppCompatActivity, rootLayout: View) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.VANILLA_ICE_CREAM) { + return + } + // navigation bar visibility + activity.window.isNavigationBarContrastEnforced = false + val windowInsetsController = WindowCompat.getInsetsController(activity.window, rootLayout) + windowInsetsController.isAppearanceLightNavigationBars = !isNightMode(activity) + + ViewCompat.setOnApplyWindowInsetsListener(rootLayout) { view, windowInsets -> + // ui margins + val statusBarInsets = windowInsets.getInsets(WindowInsetsCompat.Type.statusBars()) + val navigationBarInsets = windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars()) + view.updateLayoutParams { + topMargin = statusBarInsets.top + bottomMargin = navigationBarInsets.bottom + } + // status bar background + val statusBarView = + View(activity).apply { + layoutParams = + ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, statusBarInsets.top) + setBackgroundColor(activity.getColor(R.color.toolbar_color)) + } + activity.addContentView(statusBarView, statusBarView.layoutParams) + + WindowInsetsCompat.CONSUMED + } +} + +private fun isNightMode(context: Context): Boolean { + val nightModeFlags = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK + return nightModeFlags == Configuration.UI_MODE_NIGHT_YES +} diff --git a/app/src/main/java/com/github/shingyx/boomswitch/ui/MainActivity.kt b/app/src/main/java/com/github/shingyx/boomswitch/ui/MainActivity.kt index 5414a16..a03ca38 100644 --- a/app/src/main/java/com/github/shingyx/boomswitch/ui/MainActivity.kt +++ b/app/src/main/java/com/github/shingyx/boomswitch/ui/MainActivity.kt @@ -53,6 +53,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() { binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) setSupportActionBar(binding.toolbar) + setSystemBarColors(this, binding.root) handler = Handler(Looper.getMainLooper()) adapter = BluetoothDeviceAdapter(this) diff --git a/app/src/main/res/layout/activity_help.xml b/app/src/main/res/layout/activity_help.xml index 650633d..680eed8 100644 --- a/app/src/main/res/layout/activity_help.xml +++ b/app/src/main/res/layout/activity_help.xml @@ -1,48 +1,67 @@ - - + android:layout_height="wrap_content"> - + android:theme="@style/MainToolbarStyle" + app:titleTextColor="?android:attr/titleTextColor" /> - + + + + + android:orientation="vertical" + android:padding="16dp"> - + android:text="@string/help_intro" + android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" /> - + - + + + + + - + - + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 5b9b6dc..9f9fe38 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -3,7 +3,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:fitsSystemWindows="true" android:orientation="vertical" tools:context=".ui.MainActivity"> diff --git a/build.gradle b/build.gradle index eb503e1..617aa33 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,17 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '2.1.20' + ext.kotlin_version = '2.2.0' repositories { google() mavenCentral() maven { - url "https://plugins.gradle.org/m2/" + url = "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:8.11.1' - classpath 'com.google.android.gms:oss-licenses-plugin:0.10.6' + classpath 'com.android.tools.build:gradle:8.12.1' + classpath 'com.google.android.gms:oss-licenses-plugin:0.10.7' classpath "com.ncorti.ktfmt.gradle:plugin:0.23.0" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong