mirror of
https://github.com/Cateners/tiny_computer.git
synced 2026-05-20 16:35:47 +08:00
修复:AVNC原生界面与Flutter界面样式不符
1.更新Android端material库为1.11.0 2.在Android端启用动态颜色 3.更改主题样式为Material3 4.为两个原生页面启用边倒边沉浸 5.修改Android端项目名称为TinyComputer(顺手改了, 默认为android)
This commit is contained in:
@@ -119,7 +119,7 @@ dependencies {
|
|||||||
kapt "androidx.room:room-compiler:$roomVersion"
|
kapt "androidx.room:room-compiler:$roomVersion"
|
||||||
|
|
||||||
|
|
||||||
implementation "com.google.android.material:material:1.7.0"
|
implementation "com.google.android.material:material:1.11.0"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"
|
||||||
implementation "org.connectbot:sshlib:2.2.23"
|
implementation "org.connectbot:sshlib:2.2.23"
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
<application
|
<application
|
||||||
android:label="小小电脑"
|
android:label="小小电脑"
|
||||||
android:name="${applicationName}"
|
android:name=".MainApplication"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:theme="@style/App.Theme">
|
android:theme="@style/App.Theme">
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.tiny_computer
|
||||||
|
|
||||||
|
import com.google.android.material.color.DynamicColors
|
||||||
|
import io.flutter.app.FlutterApplication
|
||||||
|
|
||||||
|
class MainApplication : FlutterApplication() {
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
DynamicColors.applyToActivitiesIfAvailable(this@MainApplication)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,10 @@
|
|||||||
package com.gaurav.avnc.ui.about
|
package com.gaurav.avnc.ui.about
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import com.example.tiny_computer.R
|
import com.example.tiny_computer.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,12 +26,19 @@ class AboutActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
enableEdgeToEdge()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
setContentView(R.layout.activity_about)
|
setContentView(R.layout.activity_about)
|
||||||
setSupportActionBar(findViewById(R.id.toolbar))
|
setSupportActionBar(findViewById(R.id.toolbar))
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.about_main)) { v, insets ->
|
||||||
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.replace(R.id.fragment_host, AboutFragment())
|
.replace(R.id.fragment_host, AboutFragment())
|
||||||
|
|||||||
@@ -12,9 +12,12 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
|||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.annotation.Keep
|
import androidx.annotation.Keep
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.text.HtmlCompat
|
import androidx.core.text.HtmlCompat
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.SwitchPreference
|
import androidx.preference.SwitchPreference
|
||||||
@@ -26,10 +29,16 @@ class PrefsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPreference
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
DeviceAuthPrompt.applyFingerprintDialogFix(supportFragmentManager)
|
DeviceAuthPrompt.applyFingerprintDialogFix(supportFragmentManager)
|
||||||
|
enableEdgeToEdge()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
setContentView(R.layout.activity_settings)
|
||||||
|
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.settings_main)) { v, insets ->
|
||||||
|
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||||
|
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||||
|
insets
|
||||||
|
}
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
supportFragmentManager
|
supportFragmentManager
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
~ See COPYING.txt for more details.
|
~ See COPYING.txt for more details.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/about_main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/settings_main"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|||||||
@@ -31,29 +31,29 @@
|
|||||||
Note: Some custom ROMs don't respect/support the splash theme introduced in API 31.
|
Note: Some custom ROMs don't respect/support the splash theme introduced in API 31.
|
||||||
On such devices, we still rely on the above mentioned workaround.
|
On such devices, we still rely on the above mentioned workaround.
|
||||||
-->
|
-->
|
||||||
<style name="App.SplashTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar" />
|
<style name="App.SplashTheme" parent="Theme.Material3.DayNight.NoActionBar" />
|
||||||
|
|
||||||
<style name="App.SplashTheme.Light" parent="Theme.MaterialComponents.Light.NoActionBar" />
|
<style name="App.SplashTheme.Light" parent="Theme.Material3.Light.NoActionBar" />
|
||||||
|
|
||||||
<style name="App.SplashTheme.Dark" parent="Theme.MaterialComponents.NoActionBar" />
|
<style name="App.SplashTheme.Dark" parent="Theme.Material3.Dark.NoActionBar" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
This base theme is used for configuration-specific styling (e.g. night mode, API 23)
|
This base theme is used for configuration-specific styling (e.g. night mode, API 23)
|
||||||
-->
|
-->
|
||||||
<style name="App.BaseTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar" />
|
<style name="App.BaseTheme" parent="Theme.Material3.DayNight.NoActionBar" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
This is the main theme.
|
This is the main theme.
|
||||||
-->
|
-->
|
||||||
<style name="App.Theme" parent="App.BaseTheme">
|
<style name="App.Theme" parent="App.BaseTheme">
|
||||||
<item name="appBarLayoutStyle">@style/Widget.MaterialComponents.AppBarLayout.Surface</item>
|
<item name="appBarLayoutStyle">@style/Widget.Material3.AppBarLayout</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="AlertDialog.Dimmed" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
|
<style name="AlertDialog.Dimmed" parent="ThemeOverlay.Material3.MaterialAlertDialog">
|
||||||
<item name="android:backgroundDimAmount">.6</item>
|
<item name="android:backgroundDimAmount">.6</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="UrlBar" parent="Widget.MaterialComponents.Toolbar">
|
<style name="UrlBar" parent="Widget.Material3.Toolbar">
|
||||||
<item name="android:background">@drawable/bg_urlbar</item>
|
<item name="android:background">@drawable/bg_urlbar</item>
|
||||||
<item name="android:layout_marginStart">@dimen/margin_normal</item>
|
<item name="android:layout_marginStart">@dimen/margin_normal</item>
|
||||||
<item name="android:layout_marginEnd">@dimen/margin_normal</item>
|
<item name="android:layout_marginEnd">@dimen/margin_normal</item>
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
<item name="android:minWidth">50dp</item>
|
<item name="android:minWidth">50dp</item>
|
||||||
<item name="android:gravity">center</item>
|
<item name="android:gravity">center</item>
|
||||||
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
|
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
|
||||||
<item name="android:textAppearance">@style/TextAppearance.MaterialComponents.Body2</item>
|
<item name="android:textAppearance">@style/TextAppearance.Material3.BodyMedium</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="VirtualKey.Compact">
|
<style name="VirtualKey.Compact">
|
||||||
|
|||||||
@@ -23,4 +23,5 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
|
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rootProject.name = "TinyComputer"
|
||||||
include ":app"
|
include ":app"
|
||||||
|
|||||||
Reference in New Issue
Block a user