feat: 配置页面添加主题切换(白天/黑夜/自动)
This commit is contained in:
@@ -12,6 +12,8 @@ import android.widget.CheckBox
|
|||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.RadioButton
|
||||||
|
import android.widget.RadioGroup
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
@@ -60,6 +62,10 @@ class SecondActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private lateinit var promptContainer: LinearLayout
|
private lateinit var promptContainer: LinearLayout
|
||||||
private lateinit var btnAddPrompt: Button
|
private lateinit var btnAddPrompt: Button
|
||||||
|
private lateinit var rgTheme: RadioGroup
|
||||||
|
private lateinit var rbThemeLight: RadioButton
|
||||||
|
private lateinit var rbThemeDark: RadioButton
|
||||||
|
private lateinit var rbThemeAuto: RadioButton
|
||||||
|
|
||||||
private var llmConfigs = mutableListOf<LLMConfig>()
|
private var llmConfigs = mutableListOf<LLMConfig>()
|
||||||
private var promptConfigs = mutableListOf<PromptConfig>()
|
private var promptConfigs = mutableListOf<PromptConfig>()
|
||||||
@@ -109,6 +115,29 @@ class SecondActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
promptContainer = findViewById(R.id.promptContainer)
|
promptContainer = findViewById(R.id.promptContainer)
|
||||||
btnAddPrompt = findViewById(R.id.btnAddPrompt)
|
btnAddPrompt = findViewById(R.id.btnAddPrompt)
|
||||||
|
rgTheme = findViewById(R.id.rgTheme)
|
||||||
|
rbThemeLight = findViewById(R.id.rbThemeLight)
|
||||||
|
rbThemeDark = findViewById(R.id.rbThemeDark)
|
||||||
|
rbThemeAuto = findViewById(R.id.rbThemeAuto)
|
||||||
|
|
||||||
|
// 设置当前主题
|
||||||
|
when (ThemeManager.getThemeMode(this)) {
|
||||||
|
ThemeManager.THEME_LIGHT -> rbThemeLight.isChecked = true
|
||||||
|
ThemeManager.THEME_DARK -> rbThemeDark.isChecked = true
|
||||||
|
else -> rbThemeAuto.isChecked = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 主题切换监听
|
||||||
|
rgTheme.setOnCheckedChangeListener { _, checkedId ->
|
||||||
|
val mode = when (checkedId) {
|
||||||
|
R.id.rbThemeLight -> ThemeManager.THEME_LIGHT
|
||||||
|
R.id.rbThemeDark -> ThemeManager.THEME_DARK
|
||||||
|
else -> ThemeManager.THEME_FOLLOW_SYSTEM
|
||||||
|
}
|
||||||
|
ThemeManager.setThemeMode(this, mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
btnAddPrompt.setOnClickListener { showAddPromptDialog() }
|
||||||
|
|
||||||
btnToggleApiKey1.setOnClickListener { toggleApiKeyVisibility(etApiKey1, btnToggleApiKey1) }
|
btnToggleApiKey1.setOnClickListener { toggleApiKeyVisibility(etApiKey1, btnToggleApiKey1) }
|
||||||
btnToggleApiKey2.setOnClickListener { toggleApiKeyVisibility(etApiKey2, btnToggleApiKey2) }
|
btnToggleApiKey2.setOnClickListener { toggleApiKeyVisibility(etApiKey2, btnToggleApiKey2) }
|
||||||
@@ -117,8 +146,6 @@ class SecondActivity : AppCompatActivity() {
|
|||||||
btnTestConnection1.setOnClickListener { testConnection1() }
|
btnTestConnection1.setOnClickListener { testConnection1() }
|
||||||
btnTestConnection2.setOnClickListener { testConnection2() }
|
btnTestConnection2.setOnClickListener { testConnection2() }
|
||||||
btnTestConnection3.setOnClickListener { testConnection3() }
|
btnTestConnection3.setOnClickListener { testConnection3() }
|
||||||
|
|
||||||
btnAddPrompt.setOnClickListener { showAddPromptDialog() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadConfigurations() {
|
private fun loadConfigurations() {
|
||||||
|
|||||||
@@ -486,6 +486,52 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 主题设置 -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="主题"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="12dp"/>
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/rgTheme"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbThemeLight"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:text="☀️ 白天"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:paddingStart="8dp"/>
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbThemeDark"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:text="🌙 黑夜"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:paddingStart="8dp"/>
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbThemeAuto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:text="⚙️ 自动跟随系统"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
android:paddingStart="8dp"/>
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
<!-- 提示词管理 -->
|
<!-- 提示词管理 -->
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
Reference in New Issue
Block a user