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.
This commit is contained in:
parent
e1314869dc
commit
b82febf82a
5 changed files with 86 additions and 97 deletions
16
.gitignore
vendored
16
.gitignore
vendored
|
|
@ -1,15 +1,19 @@
|
||||||
*.iml
|
*.iml
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea/caches
|
/.idea
|
||||||
/.idea/libraries
|
|
||||||
/.idea/modules.xml
|
|
||||||
/.idea/workspace.xml
|
|
||||||
/.idea/navEditor.xml
|
|
||||||
/.idea/assetWizardSettings.xml
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
.cxx
|
.cxx
|
||||||
local.properties
|
local.properties
|
||||||
|
/wrapper
|
||||||
|
/daemon
|
||||||
|
/cache
|
||||||
|
/native
|
||||||
|
/jdks
|
||||||
|
/android
|
||||||
|
/.tmp
|
||||||
|
/kotlin-profile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetSelector">
|
|
||||||
<selectionStates>
|
|
||||||
<SelectionState runConfigName="Unnamed">
|
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
|
||||||
<DropdownSelection timestamp="2024-10-05T10:05:39.736702200Z">
|
|
||||||
<Target type="DEFAULT_BOOT">
|
|
||||||
<handle>
|
|
||||||
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\Archol\.android\avd\Pixel_5_API_28.avd" />
|
|
||||||
</handle>
|
|
||||||
</Target>
|
|
||||||
</DropdownSelection>
|
|
||||||
<DialogSelection />
|
|
||||||
</SelectionState>
|
|
||||||
</selectionStates>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
|
|
@ -65,6 +65,7 @@ dependencies {
|
||||||
implementation(libs.androidx.material3)
|
implementation(libs.androidx.material3)
|
||||||
implementation(libs.androidx.appcompat)
|
implementation(libs.androidx.appcompat)
|
||||||
implementation(libs.androidx.constraintlayout)
|
implementation(libs.androidx.constraintlayout)
|
||||||
|
implementation("androidx.activity:activity-ktx:1.9.2")
|
||||||
implementation(libs.material)
|
implementation(libs.material)
|
||||||
|
|
||||||
testImplementation(libs.junit)
|
testImplementation(libs.junit)
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,18 @@ class WebViewActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 增加处理Android返回键逻辑
|
||||||
|
override fun onBackPressed() {
|
||||||
|
if (webView.canGoBack()) {
|
||||||
|
// 如果WebView能够返回上一页
|
||||||
|
webView.goBack()
|
||||||
|
} else {
|
||||||
|
// 否则调用super以处理默认的后退行为
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun setupWebView() {
|
private fun setupWebView() {
|
||||||
val webSettings: WebSettings = webView.settings
|
val webSettings: WebSettings = webView.settings
|
||||||
webSettings.javaScriptEnabled = true
|
webSettings.javaScriptEnabled = true
|
||||||
|
|
|
||||||
|
|
@ -1,91 +1,81 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
tools:context=".MainActivity">
|
|
||||||
|
|
||||||
<!-- URL 输入部分,包括 Logo、URL 输入框和提交按钮 -->
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/urlInputLayout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ImageView
|
<!-- 包含两个ImageView的容器 -->
|
||||||
android:id="@+id/logo_3d"
|
<LinearLayout
|
||||||
android:layout_width="80dp"
|
android:id="@+id/logoPos"
|
||||||
android:layout_height="80dp"
|
|
||||||
android:layout_marginTop="84dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:contentDescription="@string/logo_3d_description"
|
|
||||||
android:src="@drawable/logo_3d"
|
|
||||||
app:layout_constraintEnd_toStartOf="@+id/appLogo"
|
|
||||||
app:layout_constraintHorizontal_chainStyle="packed"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/appLogo"
|
|
||||||
android:layout_width="200dp"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
android:contentDescription="@string/logo_3d_description"
|
|
||||||
android:src="@drawable/logo"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/logo_3d"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/logo_3d" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/urlInput"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="16dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:autofillHints="url"
|
|
||||||
android:background="@drawable/search_box_background"
|
|
||||||
android:hint="@string/enter_your_server_url"
|
|
||||||
android:inputType="textUri"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:textColor="@color/cyan_dark_0"
|
|
||||||
android:textColorHint="@color/gray_dark_8"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:lineSpacingExtra="1.571dp"
|
|
||||||
android:paddingTop="6dp"
|
|
||||||
android:paddingBottom="6dp"
|
|
||||||
android:paddingLeft="15dp"
|
|
||||||
android:paddingRight="15dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/appLogo" />
|
|
||||||
|
|
||||||
<!-- 提交按钮 -->
|
|
||||||
<Button
|
|
||||||
android:id="@+id/loadUrlButton"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:orientation="horizontal"
|
||||||
android:background="@drawable/button_rounded_background"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:lineSpacingExtra="1.57dp"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:paddingLeft="15dp"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:paddingTop="6dp"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:paddingRight="15dp"
|
android:layout_marginTop="84dp">
|
||||||
android:paddingBottom="6dp"
|
|
||||||
android:text="@string/send"
|
<ImageView
|
||||||
android:textAllCaps="false"
|
android:id="@+id/logo_3d"
|
||||||
android:textColor="@android:color/white"
|
android:layout_width="80dp"
|
||||||
android:textSize="14sp"
|
android:layout_height="80dp"
|
||||||
|
android:contentDescription="@string/logo_3d_description"
|
||||||
|
android:src="@drawable/logo_3d" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/appLogo"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:contentDescription="@string/app_logo"
|
||||||
|
android:src="@drawable/logo" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 输入框和按钮 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/urlInput" />
|
app:layout_constraintTop_toBottomOf="@id/logoPos"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
app:layout_constraintWidth_percent="0.8">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/urlInput"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/enter_your_server_url"
|
||||||
|
android:inputType="textUri"
|
||||||
|
android:textColor="@color/cyan_dark_0"
|
||||||
|
android:textColorHint="@color/gray_dark_8"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/loadUrlButton"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:backgroundTint="@color/gray_dark_0"
|
||||||
|
android:text="@string/send"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
app:cornerRadius="4dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<!-- WebView 控件 -->
|
|
||||||
<WebView
|
|
||||||
android:id="@+id/webView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue