-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make pod features more granular Don't assume all AirPods/Beats return a correct connection state. * Refactoring * Fix refactoring regression * AirPods Gen1 don't support state detection
- Loading branch information
Showing
24 changed files
with
152 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app-common/src/main/java/eu/darken/capod/pods/core/apple/airpods/HasStateDetectionAirPods.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package eu.darken.capod.pods.core.apple.airpods | ||
|
||
import android.content.Context | ||
import androidx.annotation.StringRes | ||
import eu.darken.capod.common.R | ||
import eu.darken.capod.pods.core.HasStateDetection | ||
import eu.darken.capod.pods.core.apple.ApplePods | ||
|
||
interface HasStateDetectionAirPods : HasStateDetection, ApplePods { | ||
|
||
override val state: ConnectionState | ||
get() = ConnectionState.values().firstOrNull { rawSuffix == it.raw } ?: ConnectionState.UNKNOWN | ||
|
||
enum class ConnectionState(val raw: UByte?, @StringRes val labelRes: Int) : HasStateDetection.State { | ||
DISCONNECTED(0x00, R.string.pods_connection_state_disconnected_label), | ||
IDLE(0x04, R.string.pods_connection_state_idle_label), | ||
MUSIC(0x05, R.string.pods_connection_state_music_label), | ||
CALL(0x06, R.string.pods_connection_state_call_label), | ||
RINGING(0x07, R.string.pods_connection_state_ringing_label), | ||
HANGING_UP(0x09, R.string.pods_connection_state_hanging_up_label), | ||
UNKNOWN(null, R.string.pods_connection_state_unknown_label); | ||
|
||
override fun getLabel(context: Context): String = context.getString(labelRes) | ||
|
||
constructor(raw: Int, @StringRes labelRes: Int) : this(raw.toUByte(), labelRes) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.