Skip to content

Commit

Permalink
android - hide nav bar and status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkodiusz committed May 1, 2022
1 parent 330d9a7 commit 6d53438
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package com.jedrzejewski.crawler
import com.android.volley.Request
import com.android.volley.RequestQueue
import com.android.volley.toolbox.StringRequest
import com.android.volley.toolbox.Volley

object HttpManager {

private const val LOCAL_IP = "192.168.44.1"
// private const val LOCAL_IP = "192.168.44.1"
private const val LOCAL_IP = "192.168.1.109"

fun sendMovementRequest(queue: RequestQueue, left: Int, right: Int) {
val url = "http://$LOCAL_IP/move?left=$left&right=$right"
Expand All @@ -17,8 +19,7 @@ object HttpManager {
val stringRequest = StringRequest(
Request.Method.GET,
url,
{ response -> System.out.println("response => $response")
},
{},
{}
)
queue.add(stringRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.jedrzejewski.crawler

import android.content.pm.ActivityInfo
import android.os.Bundle
import android.view.View
import android.widget.SeekBar
import androidx.appcompat.app.AppCompatActivity
import com.android.volley.toolbox.Volley
Expand All @@ -12,11 +13,12 @@ class MainActivity : AppCompatActivity() {
var leftSpeedLevel = 0
var rightSpeedLevel = 0

@Override
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
hideStatusAndNavBars()

val queue = Volley.newRequestQueue(this)

Expand Down Expand Up @@ -61,6 +63,34 @@ class MainActivity : AppCompatActivity() {
})
}

@Override
@Suppress("DEPRECATION")
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
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
}
}

@Suppress("DEPRECATION")
private fun hideStatusAndNavBars() {
val flags = 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

window.decorView.systemUiVisibility = flags
val decorView = window.decorView
decorView.setOnSystemUiVisibilityChangeListener { visibility ->
if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {
decorView.systemUiVisibility = flags
}
}
}

private fun convertPercentageToRange(progress: Int): Int {
//converts percentage to range from -10 to 10
return (progress/100.0*20 - 10).toInt()
Expand Down

0 comments on commit 6d53438

Please sign in to comment.