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
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew --no-daemon buildDebug assembleDebug
./gradlew --no-daemon buildDebug assembleDebug ktfmtCheck
- name: Upload debug apk
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
apply plugin: "com.ncorti.ktfmt.gradle"
apply plugin: 'kotlin-android'

def keystorePropertiesFile = rootProject.file("keystore.properties")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import timber.log.Timber
import timber.log.Timber.DebugTree

class BoomSwitchApplication : Application() {
override fun onCreate() {
super.onCreate()
override fun onCreate() {
super.onCreate()

if (BuildConfig.DEBUG) {
Timber.plant(DebugTree())
}

Preferences.initialize(this)
Preferences.appColorTheme.apply()
if (BuildConfig.DEBUG) {
Timber.plant(DebugTree())
}

Preferences.initialize(this)
Preferences.appColorTheme.apply()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@ import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatDelegate
import com.github.shingyx.boomswitch.R

enum class AppColorTheme(
val nightModeValue: Int,
@StringRes val descriptionResId: Int
) {
LIGHT(AppCompatDelegate.MODE_NIGHT_NO, R.string.light),
DARK(AppCompatDelegate.MODE_NIGHT_YES, R.string.dark),
DEFAULT(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, R.string.system_default);
enum class AppColorTheme(val nightModeValue: Int, @StringRes val descriptionResId: Int) {
LIGHT(AppCompatDelegate.MODE_NIGHT_NO, R.string.light),
DARK(AppCompatDelegate.MODE_NIGHT_YES, R.string.dark),
DEFAULT(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, R.string.system_default);

fun apply() {
AppCompatDelegate.setDefaultNightMode(nightModeValue)
}
fun apply() {
AppCompatDelegate.setDefaultNightMode(nightModeValue)
}

companion object {
fun fromNightModeValue(nightModeValue: Int): AppColorTheme {
return when (nightModeValue) {
AppCompatDelegate.MODE_NIGHT_NO -> LIGHT
AppCompatDelegate.MODE_NIGHT_YES -> DARK
else -> DEFAULT
}
}
companion object {
fun fromNightModeValue(nightModeValue: Int): AppColorTheme {
return when (nightModeValue) {
AppCompatDelegate.MODE_NIGHT_NO -> LIGHT
AppCompatDelegate.MODE_NIGHT_YES -> DARK
else -> DEFAULT
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,29 @@ package com.github.shingyx.boomswitch.data

import android.content.Intent

data class BluetoothDeviceInfo(
val name: String,
val address: String
) : Comparable<BluetoothDeviceInfo> {
override fun toString(): String {
return name
}
data class BluetoothDeviceInfo(val name: String, val address: String) :
Comparable<BluetoothDeviceInfo> {
override fun toString(): String {
return name
}

override fun compareTo(other: BluetoothDeviceInfo): Int {
return name.compareTo(other.name, true)
}
override fun compareTo(other: BluetoothDeviceInfo): Int {
return name.compareTo(other.name, true)
}

fun addToIntent(intent: Intent) {
intent.putExtra(EXTRA_NAME, name)
intent.putExtra(EXTRA_ADDRESS, address)
}
fun addToIntent(intent: Intent) {
intent.putExtra(EXTRA_NAME, name)
intent.putExtra(EXTRA_ADDRESS, address)
}

companion object {
const val EXTRA_NAME = "com.github.shingyx.boomswitch.EXTRA_BLUETOOTH_DEVICE_NAME"
const val EXTRA_ADDRESS = "com.github.shingyx.boomswitch.EXTRA_BLUETOOTH_DEVICE_ADDRESS"
companion object {
const val EXTRA_NAME = "com.github.shingyx.boomswitch.EXTRA_BLUETOOTH_DEVICE_NAME"
const val EXTRA_ADDRESS = "com.github.shingyx.boomswitch.EXTRA_BLUETOOTH_DEVICE_ADDRESS"

fun createFromIntent(intent: Intent): BluetoothDeviceInfo? {
val name = intent.getStringExtra(EXTRA_NAME) ?: return null
val address = intent.getStringExtra(EXTRA_ADDRESS) ?: return null
return BluetoothDeviceInfo(name, address)
}
fun createFromIntent(intent: Intent): BluetoothDeviceInfo? {
val name = intent.getStringExtra(EXTRA_NAME) ?: return null
val address = intent.getStringExtra(EXTRA_ADDRESS) ?: return null
return BluetoothDeviceInfo(name, address)
}
}
}
Loading