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
PitchDetectionHandler { result, audioEvent -> | |
val pitchInHz = result.pitch.toDouble() | |
if (shouldUpdateTunerState(pitchInHz, audioEvent)) { | |
val capturedNoteState = getCurrentPitchState(pitchInHz) | |
_tunerState.postValue(capturedNoteState) | |
saveLastUpdatedTime() | |
} | |
} |
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
sealed class TunerState(open val note: NotesEnum, val bgColor: Color) { | |
class Down(override val note: NotesEnum) : TunerState(note, OutOfTuneColor) | |
class Tuned(override val note: NotesEnum) : TunerState(note, TunedColor) | |
class Up(override val note: NotesEnum) : TunerState(note, OutOfTuneColor) | |
} |
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
@Preview(widthDp = 200, heightDp = 200) | |
@Composable | |
fun TunedView() { | |
TunerScreen(TunerState.Tuned(NotesEnum.A)) | |
} | |
@Preview(widthDp = 200, heightDp = 200) | |
@Composable | |
fun OutOfTuneViewDown() { | |
TunerScreen(TunerState.Down(NotesEnum.A)) |
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
@Composable | |
fun TunerScreen(tunerState: TunerState) { | |
Column( | |
modifier = Modifier.fillMaxSize().background(tunerState.bgColor), | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally | |
) { | |
Row(verticalAlignment = Alignment.CenterVertically) { | |
LeftArrow(isVisible = tunerState is TunerState.Down) | |
TextNote(note = tunerState.note.title) |
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
MaterialTheme { | |
Scaffold( | |
timeText = { TimeText() } | |
) { | |
Column( | |
verticalArrangement = Arrangement.Center, | |
horizontalAlignment = Alignment.CenterHorizontally, | |
modifier = Modifier.fillMaxSize() | |
) { | |
Text("Hello World", color = Color.White) |
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
class MainActivity : ComponentActivity() { | |
private val viewModel: MainViewModel by viewModels() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
MaterialTheme { } | |
} | |
} | |
} |
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
implementation "androidx.wear.compose:compose-foundation:$version" | |
implementation "androidx.wear.compose:compose-material:$version" | |
implementation "androidx.wear.compose:compose-navigation:$version" |
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
dependencies { | |
implementation 'androidx.core:core-ktx:1.7.0' | |
// Compose | |
implementation "androidx.activity:activity-compose:1.3.1" | |
implementation "androidx.compose.runtime:runtime-livedata:1.0.5" | |
implementation "androidx.compose.ui:ui-tooling-preview:1.0.5" | |
implementation "androidx.compose.ui:ui:1.0.5" | |
implementation "androidx.compose.compiler:compiler:1.0.5" | |
implementation "androidx.compose.foundation:foundation:1.0.5" |
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
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="dev.arildo.tuner"> | |
<uses-feature android:name="android.hardware.type.watch" /> | |
<application | |
android:allowBackup="true".........> | |
<uses-library android:name="com.google.android.wearable" android:required="true" /> | |
<meta-data android:name="com.google.android.wearable.standalone" android:value="true" /> |
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
interface Switchable { | |
fun turnOn() {} | |
fun turnOff() {} | |
} | |
interface Switch { | |
fun press() {} | |
} | |
class Light : Switchable { |