增加配置按钮,目前还有错误
This commit is contained in:
@@ -10,6 +10,7 @@ android {
|
||||
defaultConfig {
|
||||
applicationId = "com.example.flomo_ai"
|
||||
minSdk = 28
|
||||
//noinspection OldTargetApi
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.1"
|
||||
@@ -68,13 +69,13 @@ dependencies {
|
||||
androidTestImplementation(libs.androidx.ui.test.junit4)
|
||||
debugImplementation(libs.androidx.ui.tooling)
|
||||
debugImplementation(libs.androidx.ui.test.manifest)
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
implementation("io.github.nefilim.kjwt:kjwt-jwks:0.9.0")
|
||||
implementation("com.nimbusds:nimbus-jose-jwt:9.40")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
implementation("com.squareup.okhttp3:logging-interceptor:4.9.3")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
|
||||
implementation("com.squareup.moshi:moshi-kotlin:1.12.0")
|
||||
implementation(libs.gson)
|
||||
implementation(libs.kjwt.jwks)
|
||||
implementation(libs.nimbus.jose.jwt)
|
||||
implementation(libs.okhttp)
|
||||
implementation(libs.logging.interceptor)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
implementation(libs.kotlinx.coroutines.android)
|
||||
implementation(libs.moshi.kotlin)
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
||||
@@ -11,6 +11,15 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.net.Uri
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import java.io.InputStream
|
||||
import android.widget.RelativeLayout
|
||||
|
||||
|
||||
class SecondActivity : AppCompatActivity() {
|
||||
private lateinit var etApiButtonName: EditText
|
||||
private lateinit var etApiName: EditText
|
||||
@@ -20,14 +29,13 @@ class SecondActivity : AppCompatActivity() {
|
||||
private lateinit var etApiModel: EditText
|
||||
private lateinit var btnSave: Button
|
||||
private lateinit var llConfigList: LinearLayout
|
||||
|
||||
private lateinit var backgroundLayout: RelativeLayout
|
||||
private var configs = mutableListOf<APIConfig>()
|
||||
private var editingId: Long? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(androidx.appcompat.R.style.Theme_AppCompat)
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_second)
|
||||
|
||||
initViews()
|
||||
loadConfigs()
|
||||
@@ -45,8 +53,29 @@ class SecondActivity : AppCompatActivity() {
|
||||
addConfig()
|
||||
}
|
||||
}
|
||||
|
||||
backgroundLayout = findViewById(R.id.mainLinearLayout)
|
||||
|
||||
val btnSelectImage: Button = findViewById(R.id.chooseButton)
|
||||
|
||||
val getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? ->
|
||||
uri?.let {
|
||||
try {
|
||||
val inputStream: InputStream = contentResolver.openInputStream(uri)!!
|
||||
val bitmap: Bitmap = BitmapFactory.decodeStream(inputStream)
|
||||
backgroundLayout.background = BitmapDrawable(resources, bitmap)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
btnSelectImage.setOnClickListener {
|
||||
getContent.launch("image/*")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun initViews() {
|
||||
etApiButtonName = findViewById(R.id.etApiButtonName)
|
||||
etApiName = findViewById(R.id.etApiName)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 MiB |
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/mainLinearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
|
||||
@@ -16,20 +16,25 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/back_to_main" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="文字处理AI区的配置"
|
||||
android:textSize="16sp" />
|
||||
android:text="文字处理 AI 区的配置"
|
||||
android:textSize="16sp"
|
||||
tools:ignore="HardcodedText,TextSizeCheck" />
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etApiButtonName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:autofillHints=""
|
||||
android:hint="API 按钮显示名称"
|
||||
android:minHeight="48dp" />
|
||||
android:minHeight="48dp"
|
||||
tools:ignore="HardcodedText,TextFields" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etApiName"
|
||||
@@ -53,7 +58,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:hint="@string/api_key"
|
||||
android:minHeight="48dp" />
|
||||
android:minHeight="48dp"
|
||||
tools:ignore="TextFields" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etApiSecretKey"
|
||||
@@ -69,7 +75,8 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:hint="API 模型类型"
|
||||
android:minHeight="48dp" />
|
||||
android:minHeight="48dp"
|
||||
tools:ignore="TextFields" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSave"
|
||||
@@ -84,7 +91,20 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_marginTop="16dp" />
|
||||
android:background="#background_color"> <!-- 设置背景色 -->
|
||||
android:background="#background_color"> <!-- 设置背景色 -->
|
||||
|
||||
<TextView
|
||||
android:text="设置背景图片"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/chooseButton"
|
||||
android:text="上传图片"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
@@ -9,8 +9,8 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools.build:gradle:7.0.3") // 确保这里的版本号是最新的
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10") // 确保这里的版本号是最新的
|
||||
classpath("com.google.code.gson:gson:2.10.1") // 使用 classpath 而不是 implementation
|
||||
classpath(libs.gradle) // 确保这里的版本号是最新的
|
||||
classpath(libs.kotlin.gradle.plugin) // 确保这里的版本号是最新的
|
||||
classpath(libs.gson) // 使用 classpath 而不是 implementation
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,30 @@
|
||||
[versions]
|
||||
agp = "8.6.0"
|
||||
gradle = "7.0.4"
|
||||
gson = "2.10.1"
|
||||
kjwtJwks = "0.9.0"
|
||||
kotlin = "1.9.0"
|
||||
coreKtx = "1.10.1"
|
||||
junit = "4.13.2"
|
||||
junitVersion = "1.1.5"
|
||||
espressoCore = "3.5.1"
|
||||
kotlinGradlePlugin = "1.6.10"
|
||||
kotlinxCoroutinesAndroid = "1.7.1"
|
||||
kotlinxCoroutinesCore = "1.7.1"
|
||||
lifecycleRuntimeKtx = "2.6.1"
|
||||
activityCompose = "1.8.0"
|
||||
composeBom = "2024.04.01"
|
||||
appcompat = "1.7.0-alpha02"
|
||||
appcompatVersion = "1.7.0"
|
||||
loggingInterceptor = "4.9.3"
|
||||
material = "1.12.0"
|
||||
moshiKotlin = "1.12.0"
|
||||
nimbusJoseJwt = "9.40"
|
||||
okhttp = "4.12.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||
gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" }
|
||||
gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||
@@ -31,7 +41,15 @@ androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit
|
||||
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompatVersion" }
|
||||
kjwt-jwks = { module = "io.github.nefilim.kjwt:kjwt-jwks", version.ref = "kjwtJwks" }
|
||||
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlinGradlePlugin" }
|
||||
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinxCoroutinesAndroid" }
|
||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesCore" }
|
||||
logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "loggingInterceptor" }
|
||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||
moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshiKotlin" }
|
||||
nimbus-jose-jwt = { module = "com.nimbusds:nimbus-jose-jwt", version.ref = "nimbusJoseJwt" }
|
||||
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
|
||||
Reference in New Issue
Block a user