Browse Source

Tweak About view, make links actually clickable

arkon 3 years ago
parent
commit
68286b2acc

+ 11 - 32
app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt

@@ -1,13 +1,9 @@
 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
@@ -16,6 +12,7 @@ import eu.kanade.tachiyomi.data.updater.UpdateResult
 import eu.kanade.tachiyomi.data.updater.UpdaterService
 import eu.kanade.tachiyomi.data.updater.github.GithubUpdateChecker
 import eu.kanade.tachiyomi.ui.base.controller.DialogController
+import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
 import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
 import eu.kanade.tachiyomi.ui.setting.SettingsController
 import eu.kanade.tachiyomi.util.CrashLogUtil
@@ -27,6 +24,7 @@ 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
 import eu.kanade.tachiyomi.util.system.toast
 import timber.log.Timber
 import java.text.DateFormat
@@ -35,7 +33,7 @@ import java.text.SimpleDateFormat
 import java.util.Locale
 import java.util.TimeZone
 
-class AboutController : SettingsController() {
+class AboutController : SettingsController(), NoToolbarElevationController {
 
     private val updateChecker by lazy { GithubUpdateChecker() }
 
@@ -46,6 +44,8 @@ class AboutController : SettingsController() {
     override fun setupPreferenceScreen(screen: PreferenceScreen) = screen.apply {
         titleRes = R.string.pref_category_about
 
+        add(MoreHeaderPreference(context))
+
         add(AboutLinksPreference(context))
 
         preferenceCategory {
@@ -58,7 +58,12 @@ class AboutController : SettingsController() {
                     "Stable ${BuildConfig.VERSION_NAME} (${getFormattedBuildTime()})"
                 }
 
-                onClick { copyDebugInfo() }
+                onClick {
+                    activity?.let {
+                        val deviceInfo = CrashLogUtil(it).getDebugInfo()
+                        it.copyToClipboard("Debug information", deviceInfo)
+                    }
+                }
             }
             if (isUpdaterEnabled) {
                 preference {
@@ -153,13 +158,6 @@ class AboutController : SettingsController() {
         }
     }
 
-    private fun copyDebugInfo() {
-        activity?.let {
-            val deviceInfo = CrashLogUtil(it).getDebugInfo()
-            activity?.copyToClipboard("Debug information", deviceInfo)
-        }
-    }
-
     private fun getFormattedBuildTime(): String {
         return try {
             val inputDf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
@@ -179,22 +177,3 @@ 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") }
-    }
-}

+ 27 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutLinksPreference.kt

@@ -0,0 +1,27 @@
+package eu.kanade.tachiyomi.ui.more
+
+import android.content.Context
+import android.util.AttributeSet
+import androidx.preference.Preference
+import androidx.preference.PreferenceViewHolder
+import eu.kanade.tachiyomi.R
+import eu.kanade.tachiyomi.util.system.openInBrowser
+
+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 { 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") }
+    }
+}

+ 0 - 11
app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreController.kt

@@ -1,8 +1,6 @@
 package eu.kanade.tachiyomi.ui.more
 
-import android.content.Context
 import android.os.Bundle
-import android.util.AttributeSet
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
@@ -168,15 +166,6 @@ class MoreController :
         return subscribe(onNext).also { untilDestroySubscriptions.add(it) }
     }
 
-    private class MoreHeaderPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
-        Preference(context, attrs) {
-
-        init {
-            layoutResource = R.layout.pref_more_header
-            isSelectable = false
-        }
-    }
-
     companion object {
         const val URL_HELP = "https://tachiyomi.org/help/"
     }

+ 15 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/more/MoreHeaderPreference.kt

@@ -0,0 +1,15 @@
+package eu.kanade.tachiyomi.ui.more
+
+import android.content.Context
+import android.util.AttributeSet
+import androidx.preference.Preference
+import eu.kanade.tachiyomi.R
+
+class MoreHeaderPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
+    Preference(context, attrs) {
+
+    init {
+        layoutResource = R.layout.pref_more_header
+        isSelectable = false
+    }
+}