From cc304de7a7eff3224158ea1099dd5d576f104f56 Mon Sep 17 00:00:00 2001 From: kr328 Date: Sun, 16 May 2021 18:36:28 +0800 Subject: [PATCH] Improve: add sources code urls for flavor 'foss' --- .../github/kr328/clash/design/HelpDesign.kt | 95 +++++++++++++++++++ design/src/main/res/values-zh/strings.xml | 2 + design/src/main/res/values/strings.xml | 4 + .../github/kr328/clash/design/HelpDesign.kt | 0 4 files changed, 101 insertions(+) create mode 100644 design/src/foss/java/com/github/kr328/clash/design/HelpDesign.kt rename design/src/{main => premium}/java/com/github/kr328/clash/design/HelpDesign.kt (100%) diff --git a/design/src/foss/java/com/github/kr328/clash/design/HelpDesign.kt b/design/src/foss/java/com/github/kr328/clash/design/HelpDesign.kt new file mode 100644 index 00000000..4522fc03 --- /dev/null +++ b/design/src/foss/java/com/github/kr328/clash/design/HelpDesign.kt @@ -0,0 +1,95 @@ +package com.github.kr328.clash.design + +import android.content.Context +import android.net.Uri +import android.view.View +import com.github.kr328.clash.common.compat.preferredLocale +import com.github.kr328.clash.design.databinding.DesignSettingsCommonBinding +import com.github.kr328.clash.design.preference.category +import com.github.kr328.clash.design.preference.clickable +import com.github.kr328.clash.design.preference.preferenceScreen +import com.github.kr328.clash.design.preference.tips +import com.github.kr328.clash.design.util.applyFrom +import com.github.kr328.clash.design.util.bindAppBarElevation +import com.github.kr328.clash.design.util.layoutInflater +import com.github.kr328.clash.design.util.root + +class HelpDesign( + context: Context, + openLink: (Uri) -> Unit, +) : Design(context) { + private val binding = DesignSettingsCommonBinding + .inflate(context.layoutInflater, context.root, false) + + override val root: View + get() = binding.root + + init { + binding.surface = surface + + binding.activityBarLayout.applyFrom(context) + + binding.scrollRoot.bindAppBarElevation(binding.activityBarLayout) + + val screen = preferenceScreen(context) { + tips(R.string.tips_help) + + category(R.string.document) + + clickable( + title = R.string.clash_wiki, + summary = R.string.clash_wiki_url + ) { + clicked { + openLink(Uri.parse(context.getString(R.string.clash_wiki_url))) + } + } + + category(R.string.feedback) + + clickable( + title = R.string.github_issues, + summary = R.string.github_issues_url + ) { + clicked { + openLink(Uri.parse(context.getString(R.string.github_issues_url))) + } + } + + category(R.string.sources) + + clickable( + title = R.string.clash_for_android, + summary = R.string.github_url + ) { + clicked { + openLink(Uri.parse(context.getString(R.string.github_url))) + } + } + + clickable( + title = R.string.clash_core, + summary = R.string.clash_core_url + ) { + clicked { + openLink(Uri.parse(context.getString(R.string.clash_core_url))) + } + } + + if (context.resources.configuration.preferredLocale.language == "zh") { + category(R.string.donate) + + clickable( + title = R.string.donate, + summary = R.string.donate_url + ) { + clicked { + openLink(Uri.parse(context.getString(R.string.donate_url))) + } + } + } + } + + binding.content.addView(screen.root) + } +} \ No newline at end of file diff --git a/design/src/main/res/values-zh/strings.xml b/design/src/main/res/values-zh/strings.xml index ca171514..cfdbb80a 100644 --- a/design/src/main/res/values-zh/strings.xml +++ b/design/src/main/res/values-zh/strings.xml @@ -208,4 +208,6 @@ 配置文件需要在激活之前保存 仅在本次会话中有效 导入 + 源代码 + Clash 核心 \ No newline at end of file diff --git a/design/src/main/res/values/strings.xml b/design/src/main/res/values/strings.xml index bce0365b..045856e8 100644 --- a/design/src/main/res/values/strings.xml +++ b/design/src/main/res/values/strings.xml @@ -193,13 +193,17 @@ Document Feedback + Sources Donate Clash Wiki Github Issues Google Play + Clash Core https://github.com/Dreamacro/clash/wiki https://github.com/Kr328/ClashForAndroid/issues https://donate.kr328.app + https://github.com/Kr328/ClashForAndroid + https://github.com/Dreamacro/clash Clash Config(including Proxy/Rules)]]> freeware and we do NOT provide any service for it]]> diff --git a/design/src/main/java/com/github/kr328/clash/design/HelpDesign.kt b/design/src/premium/java/com/github/kr328/clash/design/HelpDesign.kt similarity index 100% rename from design/src/main/java/com/github/kr328/clash/design/HelpDesign.kt rename to design/src/premium/java/com/github/kr328/clash/design/HelpDesign.kt