-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
143 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,70 @@ | ||
package com.sosauce.cutecalc | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.IntentFilter | ||
import android.os.Build | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.activity.viewModels | ||
import androidx.annotation.RequiresApi | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.ui.Modifier | ||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen | ||
import com.sosauce.cutecalc.ecosys.CuteMusicReceiver | ||
import com.sosauce.cutecalc.ecosys.EcosystemViewModel | ||
import com.sosauce.cutecalc.logic.navigation.Nav | ||
import com.sosauce.cutecalc.ui.theme.CuteCalcTheme | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
|
||
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") | ||
class MainActivity : ComponentActivity() { | ||
|
||
//private val cm_receiver = CuteMusicReceiver() | ||
|
||
private val ecosystemViewModel by viewModels<EcosystemViewModel>() | ||
private val cmReceiver = CuteMusicReceiver( | ||
action = { | ||
if (it.isEmpty()) { | ||
ecosystemViewModel.currentlyPlaying = null | ||
} else { | ||
ecosystemViewModel.currentlyPlaying = it | ||
} | ||
} | ||
) | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
registerReceiver( | ||
cmReceiver, | ||
IntentFilter("CM_CUR_PLAY_CHANGED"), | ||
RECEIVER_EXPORTED | ||
) | ||
} | ||
|
||
installSplashScreen() | ||
enableEdgeToEdge() | ||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
// registerReceiver( | ||
// cm_receiver, | ||
// IntentFilter("CM"), RECEIVER_NOT_EXPORTED | ||
// ) | ||
// } | ||
setContent { | ||
CuteCalcTheme { | ||
Scaffold( | ||
modifier = Modifier.fillMaxSize() | ||
) { | ||
) { _ -> | ||
MaterialTheme( | ||
content = { | ||
Nav() | ||
Nav( | ||
ecosystemViewModel | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
// override fun onDestroy() { | ||
// super.onDestroy() | ||
// unregisterReceiver(cm_receiver) | ||
// } | ||
override fun onDestroy() { | ||
super.onDestroy() | ||
unregisterReceiver(cmReceiver) | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/sosauce/cutecalc/ecosys/EcosystemViewModel.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,17 @@ | ||
package com.sosauce.cutecalc.ecosys | ||
|
||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.setValue | ||
import androidx.lifecycle.ViewModel | ||
|
||
class EcosystemViewModel: ViewModel() { | ||
|
||
var currentlyPlaying by mutableStateOf<String?>(null) | ||
|
||
// inner class CuteMusic { | ||
// var currentlyPlaying by mutableStateOf<String?>(null) | ||
// } | ||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.sosauce.cutecalc.utils | ||
|
||
const val CUTE_MUSIC = "com.sosauce.cutemusic" |