From 8af8c57bb414beafb4eed2bfb448b072f2fe60e4 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 25 May 2021 18:33:56 -0400 Subject: [PATCH] Add link to official subreddit --- .../tachiyomi/ui/more/AboutController.kt | 97 ++++++++--------- .../tachiyomi/ui/more/AboutLinksPreference.kt | 30 ++++- .../tachiyomi/util/view/ViewExtensions.kt | 11 +- app/src/main/res/drawable/ic_reddit_24dp.xml | 9 ++ app/src/main/res/layout/pref_about_links.xml | 103 +++++++++--------- 5 files changed, 143 insertions(+), 107 deletions(-) create mode 100644 app/src/main/res/drawable/ic_reddit_24dp.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 24b7191113..7c0f065a67 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -21,7 +21,6 @@ import eu.kanade.tachiyomi.util.lang.toDateTimestampString import eu.kanade.tachiyomi.util.preference.add import eu.kanade.tachiyomi.util.preference.onClick import eu.kanade.tachiyomi.util.preference.preference -import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.copyToClipboard import eu.kanade.tachiyomi.util.system.openInBrowser @@ -46,60 +45,58 @@ class AboutController : SettingsController(), NoToolbarElevationController { add(MoreHeaderPreference(context)) - add(AboutLinksPreference(context)) - - preferenceCategory { - preference { - key = "pref_about_version" - titleRes = R.string.version - summary = if (BuildConfig.DEBUG) { - "Preview r${BuildConfig.COMMIT_COUNT} (${BuildConfig.COMMIT_SHA}, ${getFormattedBuildTime()})" - } else { - "Stable ${BuildConfig.VERSION_NAME} (${getFormattedBuildTime()})" - } - - onClick { - activity?.let { - val deviceInfo = CrashLogUtil(it).getDebugInfo() - it.copyToClipboard("Debug information", deviceInfo) - } - } + preference { + key = "pref_about_version" + titleRes = R.string.version + summary = if (BuildConfig.DEBUG) { + "Preview r${BuildConfig.COMMIT_COUNT} (${BuildConfig.COMMIT_SHA}, ${getFormattedBuildTime()})" + } else { + "Stable ${BuildConfig.VERSION_NAME} (${getFormattedBuildTime()})" } - if (isUpdaterEnabled) { - preference { - key = "pref_about_check_for_updates" - titleRes = R.string.check_for_updates - onClick { checkVersion() } - } - } - preference { - key = "pref_about_whats_new" - titleRes = R.string.whats_new - - onClick { - val url = if (BuildConfig.DEBUG) { - "https://github.com/tachiyomiorg/tachiyomi-preview/releases/tag/r${BuildConfig.COMMIT_COUNT}" - } else { - "https://github.com/tachiyomiorg/tachiyomi/releases/tag/v${BuildConfig.VERSION_NAME}" - } - openInBrowser(url) - } - } - preference { - key = "pref_about_licenses" - titleRes = R.string.licenses - onClick { - LibsBuilder() - .withActivityTitle(activity!!.getString(R.string.licenses)) - .withAboutIconShown(false) - .withAboutVersionShown(false) - .withLicenseShown(true) - .withEdgeToEdge(true) - .start(activity!!) + onClick { + activity?.let { + val deviceInfo = CrashLogUtil(it).getDebugInfo() + it.copyToClipboard("Debug information", deviceInfo) } } } + if (isUpdaterEnabled) { + preference { + key = "pref_about_check_for_updates" + titleRes = R.string.check_for_updates + + onClick { checkVersion() } + } + } + preference { + key = "pref_about_whats_new" + titleRes = R.string.whats_new + + onClick { + val url = if (BuildConfig.DEBUG) { + "https://github.com/tachiyomiorg/tachiyomi-preview/releases/tag/r${BuildConfig.COMMIT_COUNT}" + } else { + "https://github.com/tachiyomiorg/tachiyomi/releases/tag/v${BuildConfig.VERSION_NAME}" + } + openInBrowser(url) + } + } + preference { + key = "pref_about_licenses" + titleRes = R.string.licenses + onClick { + LibsBuilder() + .withActivityTitle(activity!!.getString(R.string.licenses)) + .withAboutIconShown(false) + .withAboutVersionShown(false) + .withLicenseShown(true) + .withEdgeToEdge(true) + .start(activity!!) + } + } + + add(AboutLinksPreference(context)) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutLinksPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutLinksPreference.kt index 02a99e93b1..182f050f6a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutLinksPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutLinksPreference.kt @@ -6,6 +6,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceViewHolder import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.openInBrowser +import eu.kanade.tachiyomi.util.view.setTooltip class AboutLinksPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : Preference(context, attrs) { @@ -18,10 +19,29 @@ class AboutLinksPreference @JvmOverloads constructor(context: Context, attrs: At override fun onBindViewHolder(holder: PreferenceViewHolder) { super.onBindViewHolder(holder) - holder.findViewById(R.id.btn_website).setOnClickListener { context.openInBrowser("https://tachiyomi.org") } - holder.findViewById(R.id.btn_discord).setOnClickListener { context.openInBrowser("https://discord.gg/tachiyomi") } - holder.findViewById(R.id.btn_twitter).setOnClickListener { context.openInBrowser("https://twitter.com/tachiyomiorg") } - holder.findViewById(R.id.btn_facebook).setOnClickListener { context.openInBrowser("https://facebook.com/tachiyomiorg") } - holder.findViewById(R.id.btn_github).setOnClickListener { context.openInBrowser("https://github.com/tachiyomiorg") } + holder.findViewById(R.id.btn_website).apply { + setTooltip(contentDescription.toString()) + setOnClickListener { context.openInBrowser("https://tachiyomi.org") } + } + holder.findViewById(R.id.btn_discord).apply { + setTooltip(contentDescription.toString()) + setOnClickListener { context.openInBrowser("https://discord.gg/tachiyomi") } + } + holder.findViewById(R.id.btn_twitter).apply { + setTooltip(contentDescription.toString()) + setOnClickListener { context.openInBrowser("https://twitter.com/tachiyomiorg") } + } + holder.findViewById(R.id.btn_facebook).apply { + setTooltip(contentDescription.toString()) + setOnClickListener { context.openInBrowser("https://facebook.com/tachiyomiorg") } + } + holder.findViewById(R.id.btn_reddit).apply { + setTooltip(contentDescription.toString()) + setOnClickListener { context.openInBrowser("https://www.reddit.com/r/Tachiyomi") } + } + holder.findViewById(R.id.btn_github).apply { + setTooltip(contentDescription.toString()) + setOnClickListener { context.openInBrowser("https://github.com/tachiyomiorg") } + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index 3133f0e95b..5e608b393c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -55,7 +55,16 @@ inline fun View.snack( * @param stringRes String resource for tooltip. */ inline fun View.setTooltip(@StringRes stringRes: Int) { - TooltipCompat.setTooltipText(this, context.getString(stringRes)) + setTooltip(context.getString(stringRes)) +} + +/** + * Adds a tooltip shown on long press. + * + * @param text Text for tooltip. + */ +inline fun View.setTooltip(text: String) { + TooltipCompat.setTooltipText(this, text) } /** diff --git a/app/src/main/res/drawable/ic_reddit_24dp.xml b/app/src/main/res/drawable/ic_reddit_24dp.xml new file mode 100644 index 0000000000..de352a164c --- /dev/null +++ b/app/src/main/res/drawable/ic_reddit_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/pref_about_links.xml b/app/src/main/res/layout/pref_about_links.xml index 696f0b895a..67d262431d 100644 --- a/app/src/main/res/layout/pref_about_links.xml +++ b/app/src/main/res/layout/pref_about_links.xml @@ -4,70 +4,71 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:padding="8dp"> + android:gravity="center"> - + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:background="?attr/selectableItemBackgroundBorderless" + android:contentDescription="@string/website" + android:padding="16dp" + android:src="@drawable/ic_public_24dp" + app:tint="?attr/colorAccent" /> - - - - + +