Collapse about links into a single row

This commit is contained in:
arkon 2021-05-19 22:39:31 -04:00
parent d3ceecf620
commit a410184e0a
6 changed files with 125 additions and 98 deletions

View file

@ -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") }
}
}

View file

@ -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}

View file

@ -4,7 +4,6 @@
android:viewportWidth="71"
android:viewportHeight="55">
<group>
<clip-path android:pathData="M0,0h71v55h-71z" />
<path
android:fillColor="@android:color/black"
android:pathData="M60.1045,4.8978C55.5792,2.8214 50.7265,1.2916 45.6527,0.4154C45.5603,0.3985 45.468,0.4408 45.4204,0.5253C44.7963,1.6353 44.105,3.0834 43.6209,4.2216C38.1637,3.4046 32.7345,3.4046 27.3892,4.2216C26.905,3.0581 26.1886,1.6353 25.5617,0.5253C25.5141,0.4436 25.4218,0.4013 25.3294,0.4154C20.2584,1.2888 15.4057,2.8186 10.8776,4.8978C10.8384,4.9147 10.8048,4.9429 10.7825,4.9795C1.578,18.7309 -0.9436,32.1443 0.2934,45.3914C0.299,45.4562 0.3354,45.5182 0.3858,45.5576C6.4587,50.0174 12.3413,52.7249 18.1147,54.5195C18.2071,54.5477 18.305,54.5139 18.3638,54.4378C19.7295,52.5728 20.9469,50.6063 21.9907,48.5383C22.0523,48.4172 21.9935,48.2735 21.8676,48.2256C19.9366,47.4931 18.0979,46.6 16.3292,45.5858C16.1893,45.5041 16.1781,45.304 16.3068,45.2082C16.679,44.9293 17.0513,44.6391 17.4067,44.3461C17.471,44.2926 17.5606,44.2813 17.6362,44.3151C29.2558,49.6202 41.8354,49.6202 53.3179,44.3151C53.3935,44.2785 53.4831,44.2898 53.5502,44.3433C53.9057,44.6363 54.2779,44.9293 54.6529,45.2082C54.7816,45.304 54.7732,45.5041 54.6333,45.5858C52.8646,46.6197 51.0259,47.4931 49.0921,48.2228C48.9662,48.2707 48.9102,48.4172 48.9718,48.5383C50.038,50.6034 51.2554,52.5699 52.5959,54.435C52.6519,54.5139 52.7526,54.5477 52.845,54.5195C58.6464,52.7249 64.529,50.0174 70.6019,45.5576C70.6551,45.5182 70.6887,45.459 70.6943,45.3942C72.1747,30.0791 68.2147,16.7757 60.1968,4.9823C60.1772,4.9429 60.1437,4.9147 60.1045,4.8978ZM23.7259,37.3253C20.2276,37.3253 17.3451,34.1136 17.3451,30.1693C17.3451,26.225 20.1717,23.0133 23.7259,23.0133C27.308,23.0133 30.1626,26.2532 30.1066,30.1693C30.1066,34.1136 27.28,37.3253 23.7259,37.3253ZM47.3178,37.3253C43.8196,37.3253 40.9371,34.1136 40.9371,30.1693C40.9371,26.225 43.7636,23.0133 47.3178,23.0133C50.9,23.0133 53.7545,26.2532 53.6986,30.1693C53.6986,34.1136 50.9,37.3253 47.3178,37.3253Z" />

View file

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/black"
android:pathData="M17.9,17.39C17.64,16.59 16.89,16 16,16H15V13A1,1 0 0,0 14,12H8V10H10A1,1 0 0,0 11,9V7H13A2,2 0 0,0 15,5V4.59C17.93,5.77 20,8.64 20,12C20,14.08 19.2,15.97 17.9,17.39M11,19.93C7.05,19.44 4,16.08 4,12C4,11.38 4.08,10.78 4.21,10.21L9,15V16A2,2 0 0,0 11,18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</vector>

View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_website"
style="@style/Theme.Widget.Button.Action"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/website"
app:icon="@drawable/ic_public_24dp"
app:iconTint="?attr/colorAccent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_discord"
style="@style/Theme.Widget.Button.Action"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="Discord"
app:icon="@drawable/ic_discord_24dp"
app:iconTint="?attr/colorAccent"
tools:ignore="HardcodedText" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_twitter"
style="@style/Theme.Widget.Button.Action"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="Twitter"
app:icon="@drawable/ic_twitter_24dp"
app:iconTint="?attr/colorAccent"
tools:ignore="HardcodedText" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_facebook"
style="@style/Theme.Widget.Button.Action"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="Facebook"
app:icon="@drawable/ic_facebook_24dp"
app:iconTint="?attr/colorAccent"
tools:ignore="HardcodedText" />
<com.google.android.material.button.MaterialButton
android:id="@+id/btn_github"
style="@style/Theme.Widget.Button.Action"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="GitHub"
app:icon="@drawable/ic_github_24dp"
app:iconTint="?attr/colorAccent"
tools:ignore="HardcodedText" />
</LinearLayout>

View file

@ -451,7 +451,6 @@
<!-- About section -->
<string name="website">Website</string>
<string name="version">Version</string>
<string name="build_time">Build time</string>
<string name="whats_new">What\'s new</string>
<string name="licenses">Open source licenses</string>
<string name="check_for_updates">Check for updates</string>