feat: open user links in dantotsu
This commit is contained in:
parent
353452dd21
commit
5c2ae57d77
6 changed files with 67 additions and 16 deletions
|
@ -261,6 +261,17 @@
|
|||
<data android:host="myanimelist.net" />
|
||||
<data android:pathPrefix="/anime" />
|
||||
</intent-filter>
|
||||
<intent-filter android:label="@string/view_profile_in_dantotsu">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="http" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="anilist.co" />
|
||||
<data android:pathPrefix="/user" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
|
|
|
@ -50,6 +50,7 @@ import ani.dantotsu.home.MangaFragment
|
|||
import ani.dantotsu.home.NoInternet
|
||||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
import ani.dantotsu.others.CustomBottomDialog
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.profile.activity.FeedActivity
|
||||
import ani.dantotsu.profile.activity.NotificationActivity
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
|
@ -389,6 +390,22 @@ class MainActivity : AppCompatActivity() {
|
|||
snackString(this@MainActivity.getString(R.string.anilist_not_found))
|
||||
}
|
||||
}
|
||||
val username = intent.extras?.getString("username")
|
||||
if (username != null) {
|
||||
val nameInt = username.toIntOrNull()
|
||||
if (nameInt != null) {
|
||||
startActivity(
|
||||
Intent(this@MainActivity, ProfileActivity::class.java)
|
||||
.putExtra("userId", nameInt)
|
||||
)
|
||||
} else {
|
||||
startActivity(
|
||||
Intent(this@MainActivity, ProfileActivity::class.java)
|
||||
.putExtra("username", username)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
delay(500)
|
||||
startSubscription()
|
||||
}
|
||||
|
|
|
@ -1347,6 +1347,18 @@ Page(page:$page,perPage:50) {
|
|||
)
|
||||
}
|
||||
|
||||
suspend fun getUserProfile(username: String): Query.UserProfileResponse? {
|
||||
val id = getUserId(username) ?: return null
|
||||
return getUserProfile(id)
|
||||
}
|
||||
|
||||
suspend fun getUserId(username: String): Int? {
|
||||
return executeQuery<Query.User>(
|
||||
"""{User(name:"$username"){id}}""",
|
||||
force = true
|
||||
)?.data?.user?.id
|
||||
}
|
||||
|
||||
suspend fun getUserStatistics(id: Int, sort: String = "ID"): Query.StatisticsResponse? {
|
||||
return executeQuery<Query.StatisticsResponse>(
|
||||
"""{User(id:$id){id name mediaListOptions{scoreFormat}statistics{anime{...UserStatistics}manga{...UserStatistics}}}}fragment UserStatistics on UserStatistics{count meanScore standardDeviation minutesWatched episodesWatched chaptersRead volumesRead formats(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds format}statuses(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds status}scores(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds score}lengths(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds length}releaseYears(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds releaseYear}startYears(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds startYear}genres(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds genre}tags(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds tag{id name}}countries(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds country}voiceActors(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds voiceActor{id name{first middle last full native alternative userPreferred}}characterIds}staff(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds staff{id name{first middle last full native alternative userPreferred}}}studios(sort:$sort){count meanScore minutesWatched chaptersRead mediaIds studio{id name isAnimationStudio}}}""",
|
||||
|
|
|
@ -11,20 +11,27 @@ import ani.dantotsu.themes.ThemeManager
|
|||
class UrlMedia : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
ThemeManager(this).applyTheme()
|
||||
val data: Uri? = intent?.data
|
||||
val type = data?.pathSegments?.getOrNull(0)
|
||||
if (type == "anime" || type == "manga") {
|
||||
var id: Int? = intent?.extras?.getInt("media", 0) ?: 0
|
||||
var isMAL = false
|
||||
var continueMedia = true
|
||||
if (id == 0) {
|
||||
continueMedia = false
|
||||
val data: Uri? = intent?.data
|
||||
isMAL = data?.host != "anilist.co"
|
||||
id = data?.pathSegments?.getOrNull(1)?.toIntOrNull()
|
||||
isMAL = data.host != "anilist.co"
|
||||
id = data.pathSegments?.getOrNull(1)?.toIntOrNull()
|
||||
} else loadMedia = id
|
||||
startMainActivity(
|
||||
this,
|
||||
bundleOf("mediaId" to id, "mal" to isMAL, "continue" to continueMedia)
|
||||
)
|
||||
} else if (type == "user") {
|
||||
val username = data.pathSegments?.getOrNull(1)
|
||||
startMainActivity(this, bundleOf("username" to username))
|
||||
} else {
|
||||
startMainActivity(this)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,8 +67,11 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
binding.profileViewPager.isUserInputEnabled = false
|
||||
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
val userid = intent.getIntExtra("userId", 0)
|
||||
val respond = Anilist.query.getUserProfile(userid)
|
||||
val userid = intent.getIntExtra("userId", -1)
|
||||
val username = intent.getStringExtra("username") ?: ""
|
||||
val respond =
|
||||
if (userid != -1) Anilist.query.getUserProfile(userid) else
|
||||
Anilist.query.getUserProfile(username)
|
||||
val user = respond?.data?.user
|
||||
if (user == null) {
|
||||
toast("User not found")
|
||||
|
|
|
@ -486,6 +486,7 @@
|
|||
|
||||
<string name="read_on_dantotsu">Read on Dantotsu</string>
|
||||
<string name="watch_on_dantotsu">Watch on Dantotsu</string>
|
||||
<string name="view_profile_in_dantotsu">View Profile in Dantotsu</string>
|
||||
<string name="continue_episode">"Continue : Episode "</string>
|
||||
<string name="continue_chapter">"Continue : "</string>
|
||||
<string name="episode">"Episode "</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue