diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7845ca7..b2c2511 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7845ca7..b2c2511 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/app/src/main/cpp/AndroidBridge.cpp b/app/src/main/cpp/AndroidBridge.cpp
index 4991080..58a30cf 100644
--- a/app/src/main/cpp/AndroidBridge.cpp
+++ b/app/src/main/cpp/AndroidBridge.cpp
@@ -9,17 +9,17 @@
extern "C" {
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_startAudio(JNIEnv *env, jobject activity) {
+Java_com_lukas_music_MainActivity_00024Companion_startAudio(JNIEnv *env, jobject activity) {
audioEngine = new AudioEngine();
}
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_muteAudio(JNIEnv *env, jobject activity, float volume) {
+Java_com_lukas_music_MainActivity_00024Companion_muteAudio(JNIEnv *env, jobject activity, float volume) {
audioEngine->stop();
}
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_unmuteAudio(JNIEnv *env, jobject activity, float volume) {
+Java_com_lukas_music_MainActivity_00024Companion_unmuteAudio(JNIEnv *env, jobject activity, float volume) {
audioEngine->start();
}
}
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7845ca7..b2c2511 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/app/src/main/cpp/AndroidBridge.cpp b/app/src/main/cpp/AndroidBridge.cpp
index 4991080..58a30cf 100644
--- a/app/src/main/cpp/AndroidBridge.cpp
+++ b/app/src/main/cpp/AndroidBridge.cpp
@@ -9,17 +9,17 @@
extern "C" {
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_startAudio(JNIEnv *env, jobject activity) {
+Java_com_lukas_music_MainActivity_00024Companion_startAudio(JNIEnv *env, jobject activity) {
audioEngine = new AudioEngine();
}
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_muteAudio(JNIEnv *env, jobject activity, float volume) {
+Java_com_lukas_music_MainActivity_00024Companion_muteAudio(JNIEnv *env, jobject activity, float volume) {
audioEngine->stop();
}
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_unmuteAudio(JNIEnv *env, jobject activity, float volume) {
+Java_com_lukas_music_MainActivity_00024Companion_unmuteAudio(JNIEnv *env, jobject activity, float volume) {
audioEngine->start();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/MainActivity.kt b/app/src/main/java/com/lukas/music/MainActivity.kt
index 100fd06..5602623 100644
--- a/app/src/main/java/com/lukas/music/MainActivity.kt
+++ b/app/src/main/java/com/lukas/music/MainActivity.kt
@@ -2,9 +2,8 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
+import android.widget.Switch
import androidx.fragment.app.Fragment
-import androidx.viewpager2.widget.ViewPager2
-import com.google.android.material.tabs.TabLayout
import com.lukas.music.databinding.ActivityMainBinding
import com.lukas.music.ui.tab.TabAdapter
import com.lukas.music.ui.fragments.CreditsFragment
@@ -14,7 +13,8 @@
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
- private val tabFragments = listOf(PlayFragment(), CreditsFragment())
+ private val playFragment = PlayFragment()
+ private val tabFragments = listOf(playFragment, CreditsFragment())
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -24,14 +24,15 @@
binding.tabPager.adapter = TabAdapter(supportFragmentManager, lifecycle, tabFragments)
binding.tabPager.registerOnPageChangeCallback(PageListener(binding.tabLayout))
binding.tabLayout.addOnTabSelectedListener(TabListener(binding.tabPager))
- // startAudio()
+ startAudio()
+ // muteAudio()
}
- private external fun startAudio()
- private external fun muteAudio()
- private external fun unmuteAudio()
-
companion object {
+ external fun startAudio()
+ external fun muteAudio()
+ external fun unmuteAudio()
+
init {
System.loadLibrary("music")
}
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7845ca7..b2c2511 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/app/src/main/cpp/AndroidBridge.cpp b/app/src/main/cpp/AndroidBridge.cpp
index 4991080..58a30cf 100644
--- a/app/src/main/cpp/AndroidBridge.cpp
+++ b/app/src/main/cpp/AndroidBridge.cpp
@@ -9,17 +9,17 @@
extern "C" {
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_startAudio(JNIEnv *env, jobject activity) {
+Java_com_lukas_music_MainActivity_00024Companion_startAudio(JNIEnv *env, jobject activity) {
audioEngine = new AudioEngine();
}
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_muteAudio(JNIEnv *env, jobject activity, float volume) {
+Java_com_lukas_music_MainActivity_00024Companion_muteAudio(JNIEnv *env, jobject activity, float volume) {
audioEngine->stop();
}
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_unmuteAudio(JNIEnv *env, jobject activity, float volume) {
+Java_com_lukas_music_MainActivity_00024Companion_unmuteAudio(JNIEnv *env, jobject activity, float volume) {
audioEngine->start();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/MainActivity.kt b/app/src/main/java/com/lukas/music/MainActivity.kt
index 100fd06..5602623 100644
--- a/app/src/main/java/com/lukas/music/MainActivity.kt
+++ b/app/src/main/java/com/lukas/music/MainActivity.kt
@@ -2,9 +2,8 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
+import android.widget.Switch
import androidx.fragment.app.Fragment
-import androidx.viewpager2.widget.ViewPager2
-import com.google.android.material.tabs.TabLayout
import com.lukas.music.databinding.ActivityMainBinding
import com.lukas.music.ui.tab.TabAdapter
import com.lukas.music.ui.fragments.CreditsFragment
@@ -14,7 +13,8 @@
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
- private val tabFragments = listOf(PlayFragment(), CreditsFragment())
+ private val playFragment = PlayFragment()
+ private val tabFragments = listOf(playFragment, CreditsFragment())
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -24,14 +24,15 @@
binding.tabPager.adapter = TabAdapter(supportFragmentManager, lifecycle, tabFragments)
binding.tabPager.registerOnPageChangeCallback(PageListener(binding.tabLayout))
binding.tabLayout.addOnTabSelectedListener(TabListener(binding.tabPager))
- // startAudio()
+ startAudio()
+ // muteAudio()
}
- private external fun startAudio()
- private external fun muteAudio()
- private external fun unmuteAudio()
-
companion object {
+ external fun startAudio()
+ external fun muteAudio()
+ external fun unmuteAudio()
+
init {
System.loadLibrary("music")
}
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
index b6a755b..5a3abe0 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
@@ -5,20 +5,26 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import com.lukas.music.MainActivity
import com.lukas.music.R
+import com.lukas.music.databinding.FragmentPlayBinding
class PlayFragment : Fragment() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- arguments?.let {
- }
- }
+ lateinit var binding: FragmentPlayBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
- return inflater.inflate(R.layout.fragment_play, container, false)
+ binding = FragmentPlayBinding.inflate(inflater)
+ binding.playSwitch.setOnCheckedChangeListener { _, isOn ->
+ if (isOn) {
+ MainActivity.unmuteAudio()
+ } else {
+ MainActivity.muteAudio()
+ }
+ }
+ return binding.root
}
companion object {
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7845ca7..b2c2511 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/app/src/main/cpp/AndroidBridge.cpp b/app/src/main/cpp/AndroidBridge.cpp
index 4991080..58a30cf 100644
--- a/app/src/main/cpp/AndroidBridge.cpp
+++ b/app/src/main/cpp/AndroidBridge.cpp
@@ -9,17 +9,17 @@
extern "C" {
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_startAudio(JNIEnv *env, jobject activity) {
+Java_com_lukas_music_MainActivity_00024Companion_startAudio(JNIEnv *env, jobject activity) {
audioEngine = new AudioEngine();
}
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_muteAudio(JNIEnv *env, jobject activity, float volume) {
+Java_com_lukas_music_MainActivity_00024Companion_muteAudio(JNIEnv *env, jobject activity, float volume) {
audioEngine->stop();
}
JNIEXPORT void JNICALL
-Java_com_lukas_music_MainActivity_unmuteAudio(JNIEnv *env, jobject activity, float volume) {
+Java_com_lukas_music_MainActivity_00024Companion_unmuteAudio(JNIEnv *env, jobject activity, float volume) {
audioEngine->start();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/MainActivity.kt b/app/src/main/java/com/lukas/music/MainActivity.kt
index 100fd06..5602623 100644
--- a/app/src/main/java/com/lukas/music/MainActivity.kt
+++ b/app/src/main/java/com/lukas/music/MainActivity.kt
@@ -2,9 +2,8 @@
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
+import android.widget.Switch
import androidx.fragment.app.Fragment
-import androidx.viewpager2.widget.ViewPager2
-import com.google.android.material.tabs.TabLayout
import com.lukas.music.databinding.ActivityMainBinding
import com.lukas.music.ui.tab.TabAdapter
import com.lukas.music.ui.fragments.CreditsFragment
@@ -14,7 +13,8 @@
class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
- private val tabFragments = listOf(PlayFragment(), CreditsFragment())
+ private val playFragment = PlayFragment()
+ private val tabFragments = listOf(playFragment, CreditsFragment())
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -24,14 +24,15 @@
binding.tabPager.adapter = TabAdapter(supportFragmentManager, lifecycle, tabFragments)
binding.tabPager.registerOnPageChangeCallback(PageListener(binding.tabLayout))
binding.tabLayout.addOnTabSelectedListener(TabListener(binding.tabPager))
- // startAudio()
+ startAudio()
+ // muteAudio()
}
- private external fun startAudio()
- private external fun muteAudio()
- private external fun unmuteAudio()
-
companion object {
+ external fun startAudio()
+ external fun muteAudio()
+ external fun unmuteAudio()
+
init {
System.loadLibrary("music")
}
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
index b6a755b..5a3abe0 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
@@ -5,20 +5,26 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import com.lukas.music.MainActivity
import com.lukas.music.R
+import com.lukas.music.databinding.FragmentPlayBinding
class PlayFragment : Fragment() {
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- arguments?.let {
- }
- }
+ lateinit var binding: FragmentPlayBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
- return inflater.inflate(R.layout.fragment_play, container, false)
+ binding = FragmentPlayBinding.inflate(inflater)
+ binding.playSwitch.setOnCheckedChangeListener { _, isOn ->
+ if (isOn) {
+ MainActivity.unmuteAudio()
+ } else {
+ MainActivity.muteAudio()
+ }
+ }
+ return binding.root
}
companion object {
diff --git a/app/src/main/res/layout/fragment_play.xml b/app/src/main/res/layout/fragment_play.xml
index 0ef6fc8..e960c03 100644
--- a/app/src/main/res/layout/fragment_play.xml
+++ b/app/src/main/res/layout/fragment_play.xml
@@ -1,14 +1,25 @@
-
-
+ android:layout_height="match_parent">
+
+
\ No newline at end of file