mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-16 19:09:17 +01:00
Copy debug info when tapping version
This commit is contained in:
parent
6064eda68f
commit
57911c42d1
@ -1,14 +1,11 @@
|
|||||||
package eu.kanade.tachiyomi.ui.manga.info
|
package eu.kanade.tachiyomi.ui.manga.info
|
||||||
|
|
||||||
import android.content.ClipData
|
|
||||||
import android.content.ClipboardManager
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
@ -33,7 +30,7 @@ import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
|
|||||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController
|
||||||
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchController
|
import eu.kanade.tachiyomi.ui.source.globalsearch.GlobalSearchController
|
||||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
import eu.kanade.tachiyomi.util.lang.truncateCenter
|
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.setChips
|
import eu.kanade.tachiyomi.util.view.setChips
|
||||||
@ -107,7 +104,7 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
|||||||
|
|
||||||
binding.mangaFullTitle.longClicks()
|
binding.mangaFullTitle.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
copyToClipboard(view.context.getString(R.string.title), binding.mangaFullTitle.text.toString())
|
activity?.copyToClipboard(view.context.getString(R.string.title), binding.mangaFullTitle.text.toString())
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
@ -119,7 +116,7 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
|||||||
|
|
||||||
binding.mangaArtist.longClicks()
|
binding.mangaArtist.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
copyToClipboard(binding.mangaArtistLabel.text.toString(), binding.mangaArtist.text.toString())
|
activity?.copyToClipboard(binding.mangaArtistLabel.text.toString(), binding.mangaArtist.text.toString())
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
@ -131,7 +128,7 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
|||||||
|
|
||||||
binding.mangaAuthor.longClicks()
|
binding.mangaAuthor.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
copyToClipboard(binding.mangaAuthor.text.toString(), binding.mangaAuthor.text.toString())
|
activity?.copyToClipboard(binding.mangaAuthor.text.toString(), binding.mangaAuthor.text.toString())
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
@ -143,13 +140,13 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
|||||||
|
|
||||||
binding.mangaSummary.longClicks()
|
binding.mangaSummary.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
copyToClipboard(view.context.getString(R.string.description), binding.mangaSummary.text.toString())
|
activity?.copyToClipboard(view.context.getString(R.string.description), binding.mangaSummary.text.toString())
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
binding.mangaCover.longClicks()
|
binding.mangaCover.longClicks()
|
||||||
.onEach {
|
.onEach {
|
||||||
copyToClipboard(view.context.getString(R.string.title), presenter.manga.title)
|
activity?.copyToClipboard(view.context.getString(R.string.title), presenter.manga.title)
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
@ -482,27 +479,6 @@ class MangaInfoController(private val fromSource: Boolean = false) :
|
|||||||
presenter.moveMangaToCategories(manga, categories)
|
presenter.moveMangaToCategories(manga, categories)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Copies a string to clipboard
|
|
||||||
*
|
|
||||||
* @param label Label to show to the user describing the content
|
|
||||||
* @param content the actual text to copy to the board
|
|
||||||
*/
|
|
||||||
private fun copyToClipboard(label: String, content: String) {
|
|
||||||
if (content.isBlank()) return
|
|
||||||
|
|
||||||
val activity = activity ?: return
|
|
||||||
val view = view ?: return
|
|
||||||
|
|
||||||
val clipboard = activity.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
|
||||||
clipboard.setPrimaryClip(ClipData.newPlainText(label, content))
|
|
||||||
|
|
||||||
activity.toast(
|
|
||||||
view.context.getString(R.string.copied_to_clipboard, content.truncateCenter(20)),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a global search using the provided query.
|
* Perform a global search using the provided query.
|
||||||
*
|
*
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.more
|
|||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.preference.PreferenceScreen
|
import androidx.preference.PreferenceScreen
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
@ -23,6 +24,7 @@ import eu.kanade.tachiyomi.util.preference.onClick
|
|||||||
import eu.kanade.tachiyomi.util.preference.preference
|
import eu.kanade.tachiyomi.util.preference.preference
|
||||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||||
import eu.kanade.tachiyomi.util.preference.titleRes
|
import eu.kanade.tachiyomi.util.preference.titleRes
|
||||||
|
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.ParseException
|
import java.text.ParseException
|
||||||
@ -55,6 +57,8 @@ class AboutController : SettingsController() {
|
|||||||
} else {
|
} else {
|
||||||
"Stable ${BuildConfig.VERSION_NAME}"
|
"Stable ${BuildConfig.VERSION_NAME}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onClick { copyDebugInfo() }
|
||||||
}
|
}
|
||||||
preference {
|
preference {
|
||||||
titleRes = R.string.build_time
|
titleRes = R.string.build_time
|
||||||
@ -186,6 +190,22 @@ class AboutController : SettingsController() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun copyDebugInfo() {
|
||||||
|
val deviceInfo =
|
||||||
|
"""
|
||||||
|
App version: ${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}, ${BuildConfig.COMMIT_SHA}, ${BuildConfig.VERSION_CODE})
|
||||||
|
Android version: ${Build.VERSION.RELEASE} (SDK ${Build.VERSION.SDK_INT})
|
||||||
|
Android build ID: ${Build.DISPLAY}
|
||||||
|
Device brand: ${Build.BRAND}
|
||||||
|
Device manufacturer: ${Build.MANUFACTURER}
|
||||||
|
Device name: ${Build.DEVICE}
|
||||||
|
Device model: ${Build.MODEL}
|
||||||
|
Device product name: ${Build.PRODUCT}
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
activity?.copyToClipboard("Debug information", deviceInfo)
|
||||||
|
}
|
||||||
|
|
||||||
private fun getFormattedBuildTime(): String {
|
private fun getFormattedBuildTime(): String {
|
||||||
return try {
|
return try {
|
||||||
val inputDf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
|
val inputDf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package eu.kanade.tachiyomi.util.system
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
|
import android.content.Context
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.util.lang.truncateCenter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies a string to clipboard
|
||||||
|
*
|
||||||
|
* @param label Label to show to the user describing the content
|
||||||
|
* @param content the actual text to copy to the board
|
||||||
|
*/
|
||||||
|
fun Activity.copyToClipboard(label: String, content: String) {
|
||||||
|
if (content.isBlank()) return
|
||||||
|
|
||||||
|
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
clipboard.setPrimaryClip(ClipData.newPlainText(label, content))
|
||||||
|
|
||||||
|
toast(getString(R.string.copied_to_clipboard, content.truncateCenter(50)))
|
||||||
|
}
|
@ -428,7 +428,7 @@
|
|||||||
<string name="manga_info_expand">Show more info</string>
|
<string name="manga_info_expand">Show more info</string>
|
||||||
<string name="manga_info_collapse">Show less info</string>
|
<string name="manga_info_collapse">Show less info</string>
|
||||||
<string name="delete_downloads_for_manga">Delete downloaded chapters?</string>
|
<string name="delete_downloads_for_manga">Delete downloaded chapters?</string>
|
||||||
<string name="copied_to_clipboard">%1$s copied to clipboard</string>
|
<string name="copied_to_clipboard">Copied to clipboard:\n%1$s</string>
|
||||||
<string name="source_not_installed">Source not installed: %1$s</string>
|
<string name="source_not_installed">Source not installed: %1$s</string>
|
||||||
<string name="snack_add_to_library">Add manga to library?</string>
|
<string name="snack_add_to_library">Add manga to library?</string>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user