mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Add link to official subreddit
This commit is contained in:
		@@ -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))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -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") }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user