Skip to content

Commit

Permalink
Merge pull request #11 from SidharthMudgil/feature-interaction-controls
Browse files Browse the repository at this point in the history
feature interaction controls
  • Loading branch information
SidharthMudgil authored Aug 29, 2023
2 parents e0ad411 + 17a5b10 commit 1f8b62c
Show file tree
Hide file tree
Showing 75 changed files with 787 additions and 134 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.preference:preference:1.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
Expand All @@ -57,8 +58,8 @@ dependencies {
implementation "androidx.camera:camera-view:1.2.3"

// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:2.7.0"
implementation "androidx.navigation:navigation-ui-ktx:2.7.0"
implementation "androidx.navigation:navigation-fragment-ktx:2.7.1"
implementation "androidx.navigation:navigation-ui-ktx:2.7.1"

// Coroutines
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/sidharth/lg_motion/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ class MainActivity : AppCompatActivity(), ProgressIndicatorCallback {

private fun checkBottomNavigationViewMenuItem(id: Int) {
when (id) {
R.id.cameraFragment, R.id.audioFragment, R.id.infoFragment -> {
R.id.cameraFragment, R.id.audioFragment -> {
activityMainBinding.bottomNavigationView?.menu?.findItem(R.id.homeFragment)?.isChecked =
true
activityMainBinding.navigationRailView?.menu?.findItem(R.id.homeFragment)?.isChecked =
true
}

R.id.aboutFragment, R.id.openSourceLicenseFragment, R.id.privacyPolicyFragment -> {
R.id.aboutFragment, R.id.openSourceLicenseFragment, R.id.privacyPolicyFragment, R.id.facialGesturesSettingsFragment -> {
activityMainBinding.bottomNavigationView?.menu?.findItem(R.id.settingsFragment)?.isChecked =
true
activityMainBinding.navigationRailView?.menu?.findItem(R.id.settingsFragment)?.isChecked =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sidharth.lg_motion.ui.home.fragment

import android.content.Context
import android.content.SharedPreferences
import android.media.AudioManager
import android.os.Bundle
import android.util.Log
Expand All @@ -9,6 +10,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import com.sidharth.lg_motion.databinding.FragmentAudioBinding
import com.sidharth.lg_motion.util.LiquidGalaxyManager
import com.sidharth.lg_motion.util.LottieSpeechAnimator
Expand All @@ -20,6 +22,10 @@ import kotlinx.coroutines.launch
class AudioFragment : Fragment(), LottieSpeechAnimator.OnSpeechRecognitionListener {
private lateinit var binding: FragmentAudioBinding
private lateinit var lottieSpeechAnimator: LottieSpeechAnimator
private val preferences: SharedPreferences by lazy {
PreferenceManager.getDefaultSharedPreferences(requireContext())
}
private var continuousListen: Boolean = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -30,18 +36,29 @@ class AudioFragment : Fragment(), LottieSpeechAnimator.OnSpeechRecognitionListen
AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE
)
}
continuousListen = preferences.getBoolean("continuous_listen", false)
binding = FragmentAudioBinding.inflate(layoutInflater)
lottieSpeechAnimator = LottieSpeechAnimator(requireContext(), binding.animationView)
lottieSpeechAnimator = LottieSpeechAnimator(
context = requireContext(),
animationView = binding.animationView,
listenContinuously = continuousListen
)
lottieSpeechAnimator.setOnSpeechRecognitionListener(this)
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding.listen.setOnClickListener {
lottieSpeechAnimator.stop()
if (continuousListen) {
binding.listen.visibility = View.GONE
lottieSpeechAnimator.start()
} else {
binding.listen.visibility = View.VISIBLE
binding.listen.setOnClickListener {
lottieSpeechAnimator.stop()
lottieSpeechAnimator.start()
}
}
return binding.root
}
Expand Down
Loading

0 comments on commit 1f8b62c

Please sign in to comment.