master
Zhengyu Peng 3 years ago
parent c65a56a37d
commit 6c841a629f

@ -3,6 +3,7 @@
<component name="DesignSurface"> <component name="DesignSurface">
<option name="filePathToZoomLevelMap"> <option name="filePathToZoomLevelMap">
<map> <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" /> <entry key="..\:/Users/rooki/Documents/GitHub/hexapod/software/android/app/src/main/res/layout/activity_main.xml" value="0.2717391304347826" />
</map> </map>
</option> </option>

@ -8,7 +8,7 @@ android {
defaultConfig { defaultConfig {
applicationId "com.rookiedev.hexapod" applicationId "com.rookiedev.hexapod"
minSdk 29 minSdk 30
targetSdk 31 targetSdk 31
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"

@ -9,6 +9,12 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Hexapod"> 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 <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true"> 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 package com.rookiedev.hexapod
import android.content.Intent
import android.net.InetAddresses.isNumericAddress import android.net.InetAddresses.isNumericAddress
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle import android.os.Bundle
@ -26,6 +27,9 @@ class MainActivity : AppCompatActivity() {
// your code to perform when the user clicks on the button // your code to perform when the user clicks on the button
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show() 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> <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
</style> </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> </resources>
Loading…
Cancel
Save