feat: open profile links
This commit is contained in:
parent
3d187a01ec
commit
94ffc2595c
5 changed files with 90 additions and 52 deletions
|
@ -18,8 +18,8 @@ android {
|
|||
minSdk 21
|
||||
targetSdk 34
|
||||
versionCode((System.currentTimeMillis() / 60000).toInteger())
|
||||
versionName "3.0.0"
|
||||
versionCode 300000000
|
||||
versionName "3.1.0"
|
||||
versionCode 300100000
|
||||
signingConfig signingConfigs.debug
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ android {
|
|||
}
|
||||
debug {
|
||||
applicationIdSuffix ".beta"
|
||||
versionNameSuffix "-beta04"
|
||||
versionNameSuffix "-beta01"
|
||||
manifestPlaceholders.icon_placeholder = "@mipmap/ic_launcher_beta"
|
||||
manifestPlaceholders.icon_placeholder_round = "@mipmap/ic_launcher_beta_round"
|
||||
debuggable false
|
||||
|
|
|
@ -1409,6 +1409,49 @@ fun ImageView.openImage(title: String, image: String) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to open the link in the app, otherwise copies it to the clipboard
|
||||
* @param link the link to open
|
||||
*/
|
||||
fun openOrCopyAnilistLink(link: String) {
|
||||
if (link.startsWith("https://anilist.co/anime/") || link.startsWith("https://anilist.co/manga/")) {
|
||||
val mangaAnime = link.substringAfter("https://anilist.co/").substringBefore("/")
|
||||
val id =
|
||||
link.substringAfter("https://anilist.co/$mangaAnime/").substringBefore("/")
|
||||
.toIntOrNull()
|
||||
if (id != null && currContext() != null) {
|
||||
ContextCompat.startActivity(
|
||||
currContext()!!,
|
||||
Intent(currContext()!!, MediaDetailsActivity::class.java)
|
||||
.putExtra("mediaId", id),
|
||||
null
|
||||
)
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
} else if (link.startsWith("https://anilist.co/user/")) {
|
||||
val username = link.substringAfter("https://anilist.co/user/").substringBefore("/")
|
||||
val id = username.toIntOrNull()
|
||||
if (currContext() != null) {
|
||||
val intent = Intent(currContext()!!, ProfileActivity::class.java)
|
||||
if (id != null) {
|
||||
intent.putExtra("userId", id)
|
||||
} else {
|
||||
intent.putExtra("username", username)
|
||||
}
|
||||
ContextCompat.startActivity(
|
||||
currContext()!!,
|
||||
intent,
|
||||
null
|
||||
)
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the markwon instance with all the plugins
|
||||
* @return the markwon instance
|
||||
|
@ -1424,36 +1467,7 @@ fun buildMarkwon(
|
|||
.usePlugin(object : AbstractMarkwonPlugin() {
|
||||
override fun configureConfiguration(builder: MarkwonConfiguration.Builder) {
|
||||
builder.linkResolver { _, link ->
|
||||
if (link.startsWith("https://anilist.co/anime/") || link.startsWith("https://anilist.co/manga/")) {
|
||||
val mangaAnime = link.substringAfter("https://anilist.co/").substringBefore("/")
|
||||
val id =
|
||||
link.substringAfter("https://anilist.co/$mangaAnime/").substringBefore("/")
|
||||
.toIntOrNull()
|
||||
if (id != null && currContext() != null) {
|
||||
ContextCompat.startActivity(
|
||||
currContext()!!,
|
||||
Intent(currContext()!!, MediaDetailsActivity::class.java)
|
||||
.putExtra("mediaId", id),
|
||||
null
|
||||
)
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
} else if (link.startsWith("https://anilist.co/user/")) {
|
||||
val username = link.substringAfter("https://anilist.co/user/").substringBefore("/")
|
||||
if (currContext() != null) {
|
||||
ContextCompat.startActivity(
|
||||
currContext()!!,
|
||||
Intent(currContext()!!, ProfileActivity::class.java)
|
||||
.putExtra("username", username),
|
||||
null
|
||||
)
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
} else {
|
||||
copyToClipboard(link, true)
|
||||
}
|
||||
openOrCopyAnilistLink(link)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -35,6 +35,6 @@ interface DownloadAddonApiV2 {
|
|||
fun getStackTrace(sessionId: Long): String?
|
||||
|
||||
fun hadError(sessionId: Long): Boolean
|
||||
|
||||
|
||||
fun getFileExtension(): Pair<String, String> = Pair("mkv", "video/x-matroska")
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import ani.dantotsu.media.Character
|
|||
import ani.dantotsu.media.CharacterAdapter
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.media.MediaAdaptor
|
||||
import ani.dantotsu.openOrCopyAnilistLink
|
||||
import ani.dantotsu.setBaseline
|
||||
import ani.dantotsu.setSlideIn
|
||||
import ani.dantotsu.setSlideUp
|
||||
|
@ -97,6 +98,7 @@ class ProfileFragment : Fragment() {
|
|||
view: WebView?,
|
||||
request: WebResourceRequest?
|
||||
): Boolean {
|
||||
openOrCopyAnilistLink(request?.url.toString())
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue