From a410184e0aeeef067915090a3530f79f8f8348e9 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 19 May 2021 22:39:31 -0400 Subject: [PATCH] Collapse about links into a single row --- .../tachiyomi/ui/more/AboutController.kt | 137 +++++++----------- .../eu/kanade/tachiyomi/util/CrashLogUtil.kt | 2 +- app/src/main/res/drawable/ic_discord_24dp.xml | 1 - app/src/main/res/drawable/ic_earth_24dp.xml | 9 -- app/src/main/res/layout/pref_about_links.xml | 73 ++++++++++ app/src/main/res/values/strings.xml | 1 - 6 files changed, 125 insertions(+), 98 deletions(-) delete mode 100644 app/src/main/res/drawable/ic_earth_24dp.xml create mode 100644 app/src/main/res/layout/pref_about_links.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 ed8eaa5163..c82ef5095c 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 @@ -1,9 +1,13 @@ package eu.kanade.tachiyomi.ui.more import android.app.Dialog +import android.content.Context import android.os.Bundle +import android.util.AttributeSet import androidx.core.os.bundleOf +import androidx.preference.Preference import androidx.preference.PreferenceScreen +import androidx.preference.PreferenceViewHolder import com.afollestad.materialdialogs.MaterialDialog import com.mikepenz.aboutlibraries.LibsBuilder import eu.kanade.tachiyomi.BuildConfig @@ -17,14 +21,12 @@ import eu.kanade.tachiyomi.ui.setting.SettingsController import eu.kanade.tachiyomi.util.CrashLogUtil import eu.kanade.tachiyomi.util.lang.launchNow import eu.kanade.tachiyomi.util.lang.toDateTimestampString -import eu.kanade.tachiyomi.util.preference.iconRes -import eu.kanade.tachiyomi.util.preference.iconTint +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.getResourceColor import eu.kanade.tachiyomi.util.system.toast import timber.log.Timber import java.text.DateFormat @@ -44,95 +46,39 @@ class AboutController : SettingsController() { override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply { titleRes = R.string.pref_category_about - val tintColor = context.getResourceColor(R.attr.colorAccent) - - preference { - key = "pref_about_version" - titleRes = R.string.version - summary = if (BuildConfig.DEBUG) { - "Preview r${BuildConfig.COMMIT_COUNT} (${BuildConfig.COMMIT_SHA})" - } else { - "Stable ${BuildConfig.VERSION_NAME}" - } - - onClick { copyDebugInfo() } - } - preference { - key = "pref_about_build_time" - titleRes = R.string.build_time - summary = 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) - } - } + add(AboutLinksPreference(context)) preferenceCategory { preference { - key = "pref_about_website" - titleRes = R.string.website - iconRes = R.drawable.ic_earth_24dp - iconTint = tintColor - "https://tachiyomi.org".also { - summary = it - onClick { openInBrowser(it) } + 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 { copyDebugInfo() } + } + if (isUpdaterEnabled) { + preference { + key = "pref_about_check_for_updates" + titleRes = R.string.check_for_updates + + onClick { checkVersion() } } } preference { - key = "pref_about_discord" - title = "Discord" - iconRes = R.drawable.ic_discord_24dp - iconTint = tintColor - "https://discord.gg/tachiyomi".also { - summary = it - onClick { openInBrowser(it) } - } - } - preference { - key = "pref_about_twitter" - title = "Twitter" - iconRes = R.drawable.ic_twitter_24dp - iconTint = tintColor - "https://twitter.com/tachiyomiorg".also { - summary = it - onClick { openInBrowser(it) } - } - } - preference { - key = "pref_about_facebook" - title = "Facebook" - iconRes = R.drawable.ic_facebook_24dp - iconTint = tintColor - "https://facebook.com/tachiyomiorg".also { - summary = it - onClick { openInBrowser(it) } - } - } - preference { - key = "pref_about_github" - title = "GitHub" - iconRes = R.drawable.ic_github_24dp - iconTint = tintColor - "https://github.com/tachiyomiorg".also { - summary = it - onClick { openInBrowser(it) } + 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 { @@ -233,3 +179,22 @@ class AboutController : SettingsController() { } } } + +private class AboutLinksPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : + Preference(context, attrs) { + + init { + layoutResource = R.layout.pref_about_links + isSelectable = false + } + + override fun onBindViewHolder(holder: PreferenceViewHolder) { + super.onBindViewHolder(holder) + + // holder.findViewById(R.id.btn_website).setOnClickListener { openInBrowser("https://tachiyomi.org") } + // holder.findViewById(R.id.btn_discord).setOnClickListener { openInBrowser("https://discord.gg/tachiyomi") } + // holder.findViewById(R.id.btn_twitter).setOnClickListener { openInBrowser("https://twitter.com/tachiyomiorg") } + // holder.findViewById(R.id.btn_facebook).setOnClickListener { openInBrowser("https://facebook.com/tachiyomiorg") } + // holder.findViewById(R.id.btn_github).setOnClickListener { openInBrowser("https://github.com/tachiyomiorg") } + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt index 16367fd7df..b4715e4b75 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt @@ -37,7 +37,7 @@ class CrashLogUtil(private val context: Context) { fun getDebugInfo(): String { return """ - App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE}) + App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE}, ${BuildConfig.BUILD_TIME}) Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT}) Android build ID: ${Build.DISPLAY} Device brand: ${Build.BRAND} diff --git a/app/src/main/res/drawable/ic_discord_24dp.xml b/app/src/main/res/drawable/ic_discord_24dp.xml index 4593a323cf..16bcbb9b9e 100644 --- a/app/src/main/res/drawable/ic_discord_24dp.xml +++ b/app/src/main/res/drawable/ic_discord_24dp.xml @@ -4,7 +4,6 @@ android:viewportWidth="71" android:viewportHeight="55"> - diff --git a/app/src/main/res/drawable/ic_earth_24dp.xml b/app/src/main/res/drawable/ic_earth_24dp.xml deleted file mode 100644 index 8b11a470f2..0000000000 --- a/app/src/main/res/drawable/ic_earth_24dp.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/pref_about_links.xml b/app/src/main/res/layout/pref_about_links.xml new file mode 100644 index 0000000000..a2ab4e822b --- /dev/null +++ b/app/src/main/res/layout/pref_about_links.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 79b25cd0b9..a8c832eb75 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -451,7 +451,6 @@ Website Version - Build time What\'s new Open source licenses Check for updates