Skip to content

Commit

Permalink
Addressed comment based feedback, swapped canUseHeadTracking boolean …
Browse files Browse the repository at this point in the history
…checks, Re-adds statusbar fullscreen mode
  • Loading branch information
IanCrossCD committed Nov 22, 2023
1 parent e3f1c33 commit fb6e85d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
15 changes: 12 additions & 3 deletions app/src/main/java/com/willowtree/vocable/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class MainActivity : AppCompatActivity(),
binding.pointerView.isVisible = false
setContentView(binding.root)

val shouldForceDisableHeadTracking = !BuildConfig.USE_HEAD_TRACKING
val isNotSupportedDevice = !checkIsSupportedDeviceOrFinish()
val canUseHeadTracking = BuildConfig.USE_HEAD_TRACKING
val isSupportedDevice = checkIsSupportedDeviceOrFinish()

if (!shouldForceDisableHeadTracking && !isNotSupportedDevice) {
if (canUseHeadTracking && isSupportedDevice) {
selectionModeViewModel.headTrackingPermissionState.observe(this) { headTrackingState ->
when (headTrackingState) {
HeadTrackingPermissionState.PermissionRequested -> requestPermissions()
Expand All @@ -77,6 +77,7 @@ class MainActivity : AppCompatActivity(),
}
}


faceTrackingViewModel.showError.observe(this) { showError ->
if (!sharedPrefs.getHeadTrackingEnabled()) {
getPointerView().isVisible = false
Expand Down Expand Up @@ -113,6 +114,14 @@ class MainActivity : AppCompatActivity(),
.beginTransaction()
.replace(R.id.face_fragment, FaceTrackFragment())
.commitAllowingStateLoss()
} else {
window
.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
.or(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
.or(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
.or(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)
.or(View.SYSTEM_UI_FLAG_FULLSCREEN)
.or(View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
}

faceTrackingViewModel.pointerLocation.observe(this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class FaceTrackFragment : ArFragment() {
}
}

/**
* These being in `onActivityCreated` seem to be mandatory, but I'm not sure why.
*/
@Deprecated("Deprecated in Java")
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
Expand Down Expand Up @@ -79,6 +76,8 @@ class FaceTrackFragment : ArFragment() {
*
* Funnels permission work back into Activity to allow it to be handle in a singular place.
* More importantly we DO NOT allow the super to be called. Denied permissions will trigger built in dialogs and ultimately close the app
*
* This is ultimately a result of our dependency on [ArFragment], which we would like to move away from
*/
@Deprecated(
"Deprecated, but it is what is used",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ class SelectionModeViewModelTest {
}

@Test
fun `permission state Requested on init if head tracking E=enabled`() = runTest {
fun `permission state Requested on init if head tracking Enabled`() = runTest {

val viewModel = createViewModel(createSharedPrefs(headTrackingEnabled = true))

assert(viewModel.headTrackingPermissionState.getOrAwaitValue() is HeadTrackingPermissionState.PermissionRequested)
}

@Test
fun `permission state Disabled on init if head tracking enabled`() = runTest {
fun `permission state Disabled on init if head tracking disabled`() = runTest {

val viewModel = createViewModel(createSharedPrefs(headTrackingEnabled = false))

Expand Down

0 comments on commit fb6e85d

Please sign in to comment.