update
This commit is contained in:
		
							
								
								
									
										1
									
								
								software/android/.idea/misc.xml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								software/android/.idea/misc.xml
									
									
									
										generated
									
									
									
								
							@@ -3,6 +3,7 @@
 | 
			
		||||
  <component name="DesignSurface">
 | 
			
		||||
    <option name="filePathToZoomLevelMap">
 | 
			
		||||
      <map>
 | 
			
		||||
        <entry key="..\:/Users/rooki/Documents/GitHub/hexapod/software/android/app/src/main/res/layout/activity_control.xml" value="0.32472826086956524" />
 | 
			
		||||
        <entry key="..\:/Users/rooki/Documents/GitHub/hexapod/software/android/app/src/main/res/layout/activity_main.xml" value="0.2717391304347826" />
 | 
			
		||||
      </map>
 | 
			
		||||
    </option>
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ android {
 | 
			
		||||
 | 
			
		||||
    defaultConfig {
 | 
			
		||||
        applicationId "com.rookiedev.hexapod"
 | 
			
		||||
        minSdk 29
 | 
			
		||||
        minSdk 30
 | 
			
		||||
        targetSdk 31
 | 
			
		||||
        versionCode 1
 | 
			
		||||
        versionName "1.0"
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,12 @@
 | 
			
		||||
        android:roundIcon="@mipmap/ic_launcher_round"
 | 
			
		||||
        android:supportsRtl="true"
 | 
			
		||||
        android:theme="@style/Theme.Hexapod">
 | 
			
		||||
        <activity
 | 
			
		||||
            android:name=".ControlActivity"
 | 
			
		||||
            android:exported="false"
 | 
			
		||||
            android:theme="@style/Theme.HexapodFullScreen"
 | 
			
		||||
            android:screenOrientation="landscape"
 | 
			
		||||
            android:configChanges="orientation|keyboardHidden"/>
 | 
			
		||||
        <activity
 | 
			
		||||
            android:name=".MainActivity"
 | 
			
		||||
            android:exported="true">
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,75 @@
 | 
			
		||||
package com.rookiedev.hexapod
 | 
			
		||||
 | 
			
		||||
import androidx.appcompat.app.AppCompatActivity
 | 
			
		||||
import android.os.Bundle
 | 
			
		||||
import android.view.WindowInsets
 | 
			
		||||
import android.view.WindowInsetsController
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Behaviors of immersive mode.
 | 
			
		||||
 */
 | 
			
		||||
enum class BehaviorOption(
 | 
			
		||||
    val title: String,
 | 
			
		||||
    val value: Int
 | 
			
		||||
) {
 | 
			
		||||
    // Swipe from the edge to show a hidden bar. Gesture navigation works regardless of visibility
 | 
			
		||||
    // of the navigation bar.
 | 
			
		||||
    Default(
 | 
			
		||||
        "BEHAVIOR_DEFAULT",
 | 
			
		||||
        WindowInsetsController.BEHAVIOR_DEFAULT
 | 
			
		||||
    ),
 | 
			
		||||
    // "Sticky immersive mode". Swipe from the edge to temporarily reveal the hidden bar.
 | 
			
		||||
    ShowTransientBarsBySwipe(
 | 
			
		||||
        "BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE",
 | 
			
		||||
        WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Type of system bars to hide or show.
 | 
			
		||||
 */
 | 
			
		||||
enum class TypeOption(
 | 
			
		||||
    val title: String,
 | 
			
		||||
    val value: Int
 | 
			
		||||
) {
 | 
			
		||||
    // Both the status bar and the navigation bar
 | 
			
		||||
    SystemBars(
 | 
			
		||||
        "systemBars()",
 | 
			
		||||
        WindowInsets.Type.systemBars()
 | 
			
		||||
    ),
 | 
			
		||||
    // The status bar only.
 | 
			
		||||
    StatusBar(
 | 
			
		||||
        "statusBars()",
 | 
			
		||||
        WindowInsets.Type.statusBars()
 | 
			
		||||
    ),
 | 
			
		||||
    // The navigation bar only
 | 
			
		||||
    NavigationBar(
 | 
			
		||||
        "navigationBars()",
 | 
			
		||||
        WindowInsets.Type.navigationBars()
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ControlActivity : AppCompatActivity() {
 | 
			
		||||
    override fun onCreate(savedInstanceState: Bundle?) {
 | 
			
		||||
        super.onCreate(savedInstanceState)
 | 
			
		||||
        setContentView(R.layout.activity_control)
 | 
			
		||||
 | 
			
		||||
        controlWindowInsets(true)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun controlWindowInsets(hide: Boolean) {
 | 
			
		||||
        // WindowInsetsController can hide or show specified system bars.
 | 
			
		||||
        val insetsController = window.decorView.windowInsetsController ?: return
 | 
			
		||||
        // The behavior of the immersive mode.
 | 
			
		||||
        val behavior = BehaviorOption.values()[1].value
 | 
			
		||||
        // The type of system bars to hide or show.
 | 
			
		||||
        val type = TypeOption.values()[0].value
 | 
			
		||||
        insetsController.systemBarsBehavior = behavior
 | 
			
		||||
        if (hide) {
 | 
			
		||||
            insetsController.hide(type)
 | 
			
		||||
        } else {
 | 
			
		||||
            insetsController.show(type)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
package com.rookiedev.hexapod
 | 
			
		||||
 | 
			
		||||
import android.content.Intent
 | 
			
		||||
import android.net.InetAddresses.isNumericAddress
 | 
			
		||||
import androidx.appcompat.app.AppCompatActivity
 | 
			
		||||
import android.os.Bundle
 | 
			
		||||
@@ -26,6 +27,9 @@ class MainActivity : AppCompatActivity() {
 | 
			
		||||
            // your code to perform when the user clicks on the button
 | 
			
		||||
 | 
			
		||||
            Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
 | 
			
		||||
            val intent = Intent(this, ControlActivity::class.java).apply {
 | 
			
		||||
            }
 | 
			
		||||
            startActivity(intent)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,9 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
 | 
			
		||||
    xmlns:app="http://schemas.android.com/apk/res-auto"
 | 
			
		||||
    xmlns:tools="http://schemas.android.com/tools"
 | 
			
		||||
    android:layout_width="match_parent"
 | 
			
		||||
    android:layout_height="match_parent"
 | 
			
		||||
    tools:context=".ControlActivity">
 | 
			
		||||
 | 
			
		||||
</androidx.constraintlayout.widget.ConstraintLayout>
 | 
			
		||||
@@ -13,4 +13,18 @@
 | 
			
		||||
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
 | 
			
		||||
        <!-- Customize your theme here. -->
 | 
			
		||||
    </style>
 | 
			
		||||
 | 
			
		||||
    <style name="Theme.HexapodFullScreen" parent="Theme.MaterialComponents.DayNight.NoActionBar">
 | 
			
		||||
        <!-- Primary brand color. -->
 | 
			
		||||
        <item name="colorPrimary">@color/purple_500</item>
 | 
			
		||||
        <item name="colorPrimaryVariant">@color/purple_700</item>
 | 
			
		||||
        <item name="colorOnPrimary">@color/white</item>
 | 
			
		||||
        <!-- Secondary brand color. -->
 | 
			
		||||
        <item name="colorSecondary">@color/teal_200</item>
 | 
			
		||||
        <item name="colorSecondaryVariant">@color/teal_700</item>
 | 
			
		||||
        <item name="colorOnSecondary">@color/black</item>
 | 
			
		||||
        <!-- Status bar color. -->
 | 
			
		||||
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
 | 
			
		||||
        <!-- Customize your theme here. -->
 | 
			
		||||
    </style>
 | 
			
		||||
</resources>
 | 
			
		||||
		Reference in New Issue
	
	Block a user