From b82febf82adfabed0594137003b8bc78c9ad9727 Mon Sep 17 00:00:00 2001 From: moreoronce Date: Mon, 7 Oct 2024 09:00:14 +0800 Subject: [PATCH] Refactor and Optimize Layouts and Resources - Updated activity_main.xml for better layout alignment and consistent use of Material Design components. - Added ids to LinearLayouts for easier reference and manipulation. - Enhanced styles in styles.xml to unify the UI appearance across the app. - Adjusted themes in themes.xml to incorporate the latest Material Components. - Revised colors.xml and strings.xml to include new color schemes and text resources. - Updated backup_rules.xml and various drawable resources for consistency and clarity. --- .gitignore | 16 ++- .idea/deploymentTargetSelector.xml | 18 --- app/build.gradle.kts | 1 + .../com/example/lobchat/WebViewActivity.kt | 12 ++ app/src/main/res/layout/activity_main.xml | 136 ++++++++---------- 5 files changed, 86 insertions(+), 97 deletions(-) delete mode 100644 .idea/deploymentTargetSelector.xml diff --git a/.gitignore b/.gitignore index aa724b7..49463a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,19 @@ *.iml .gradle /local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml +/.idea .DS_Store /build /captures .externalNativeBuild .cxx local.properties +/wrapper +/daemon +/cache +/native +/jdks +/android +/.tmp +/kotlin-profile + diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml deleted file mode 100644 index fcc5e40..0000000 --- a/.idea/deploymentTargetSelector.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b750540..8716c94 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -65,6 +65,7 @@ dependencies { implementation(libs.androidx.material3) implementation(libs.androidx.appcompat) implementation(libs.androidx.constraintlayout) + implementation("androidx.activity:activity-ktx:1.9.2") implementation(libs.material) testImplementation(libs.junit) diff --git a/app/src/main/java/com/example/lobchat/WebViewActivity.kt b/app/src/main/java/com/example/lobchat/WebViewActivity.kt index e64dd06..a282aa1 100644 --- a/app/src/main/java/com/example/lobchat/WebViewActivity.kt +++ b/app/src/main/java/com/example/lobchat/WebViewActivity.kt @@ -49,6 +49,18 @@ class WebViewActivity : AppCompatActivity() { } } + // 增加处理Android返回键逻辑 + override fun onBackPressed() { + if (webView.canGoBack()) { + // 如果WebView能够返回上一页 + webView.goBack() + } else { + // 否则调用super以处理默认的后退行为 + super.onBackPressed() + } + } + + private fun setupWebView() { val webSettings: WebSettings = webView.settings webSettings.javaScriptEnabled = true diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ee2b36b..0006c88 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,91 +1,81 @@ + android:layout_height="match_parent"> - - - - - - - - -