Skip to content

Commit

Permalink
WTF: rebel pls fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed Mar 5, 2024
1 parent 36c6495 commit 8da0092
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 16 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
android:name=".profile.ProfileActivity"
android:windowSoftInputMode="adjustResize|stateHidden"
android:parentActivityName=".MainActivity" />
<activity
android:name=".profile.FollowActivity"
android:windowSoftInputMode="adjustResize|stateHidden"
android:parentActivityName=".MainActivity" />
<activity
android:name=".others.imagesearch.ImageSearchActivity"
android:parentActivityName=".MainActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@ Page(page:$page,perPage:50) {
show = true
)
}

suspend fun userFavMedia(anime: Boolean, id: Int): ArrayList<Media> {
var hasNextPage = true
var page = 0
Expand All @@ -1280,6 +1281,9 @@ Page(page:$page,perPage:50) {
private fun userFavMediaQuery(anime: Boolean, page: Int, id: Int): String {
return """User(id:${id}){id favourites{${if (anime) "anime" else "manga"}(page:$page){pageInfo{hasNextPage}edges{favouriteOrder node{id idMal isAdult mediaListEntry{ progress private score(format:POINT_100) status } chapters isFavourite format episodes nextAiringEpisode{episode}meanScore isFavourite format startDate{year month day} title{english romaji userPreferred}type status(version:2)bannerImage coverImage{large}}}}}}"""
}
suspend fun userFollowing(id: Int): Query.Following?{
return executeQuery<Query.Following>("""{Following:Page {following(userId:${id},sort:[USERNAME]){id name avatar{large medium}bannerImage}}}""", force = true)
}
private suspend fun userBannerImage(type: String,id: Int?): String? {
val response =
executeQuery<Query.MediaListCollection>("""{ MediaListCollection(userId: ${id}, type: $type, chunk:1,perChunk:25, sort: [SCORE_DESC,UPDATED_TIME_DESC]) { lists { entries{ media { id bannerImage } } } } } """)
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/ani/dantotsu/connections/anilist/api/Data.kt
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,17 @@ class Query {
val user: UserProfile?
)
}

@Serializable
data class Following(
@SerialName("data")
val data: Data
) {
@Serializable
data class Data(
@SerialName("following")
val following: ani.dantotsu.connections.anilist.api.User?
)
}
@Serializable
data class UserProfile(
@SerialName("id")
Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/ani/dantotsu/profile/FollowActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ani.dantotsu.profile

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.databinding.ActivityFollowBinding
import ani.dantotsu.initActivity
import ani.dantotsu.themes.ThemeManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext


class FollowActivity : AppCompatActivity(){
private lateinit var binding: ActivityFollowBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ThemeManager(this).applyTheme()
initActivity(this)
binding = ActivityFollowBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.listTitle.text = intent.getStringExtra("title")
lifecycleScope.launch(Dispatchers.IO) {
val respond = Anilist.query.userFollowing(intent.getIntExtra("userId", 0))
val user = respond?.data?.following
withContext(Dispatchers.Main) {
user?.id
}
}
}
}
25 changes: 11 additions & 14 deletions app/src/main/java/ani/dantotsu/profile/ProfileActivity.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package ani.dantotsu.profile

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
Expand Down Expand Up @@ -98,14 +100,15 @@ class ProfileActivity : AppCompatActivity() {
}
binding.profileProgressBar.visibility = View.GONE
binding.profileTopContainer.visibility = View.VISIBLE
binding.profileBannerImage.loadImage(user.bannerImage)
binding.profileBannerImage.setOnLongClickListener {
ImageViewDialog.newInstance(
this@ProfileActivity,
"${user.name}'s [Banner]",
user.bannerImage

binding.temp.setOnClickListener {
ContextCompat.startActivity(
this@ProfileActivity, Intent(this@ProfileActivity, FollowActivity::class.java)
.putExtra("title", "Following")
.putExtra("userId", user.id), null
)
}

binding.profileUserAvatar.loadImage(user.avatar?.medium)
binding.profileUserAvatar.setOnLongClickListener {
ImageViewDialog.newInstance(
Expand All @@ -114,6 +117,7 @@ class ProfileActivity : AppCompatActivity() {
user.avatar?.medium
)
}

binding.profileUserName.text = "${user.name} $userLevel"
if (!(PrefManager.getVal(PrefName.BannerAnimations) as Boolean)) binding.profileBannerImage.pause()
binding.profileBannerImage.loadImage(user.bannerImage)
Expand All @@ -125,14 +129,7 @@ class ProfileActivity : AppCompatActivity() {
user.bannerImage
)
}
binding.profileUserAvatar.loadImage(user.avatar?.medium)
binding.profileUserAvatar.setOnLongClickListener {
ImageViewDialog.newInstance(
this@ProfileActivity,
user.name + " [Avatar]",
user.avatar?.medium
)
}

}
}

Expand Down
38 changes: 38 additions & 0 deletions app/src/main/res/layout/activity_follow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<ProgressBar
android:id="@+id/listProgressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"/>

<TextView
android:id="@+id/listTitle"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginStart="32dp"
android:ellipsize="end"
android:fontFamily="@font/poppins_bold"
android:gravity="center|start"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title"
android:textColor="?attr/colorOnBackground"
android:textSize="16sp"
tools:text="xyz" />


<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
tools:listitem="@layout/item_follow"/>
</LinearLayout>
16 changes: 15 additions & 1 deletion app/src/main/res/layout/activity_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,21 @@
app:cornerRadius="8dp"
app:strokeColor="?attr/colorPrimaryContainer"
tools:ignore="SpeakableTextPresentCheck" />

<Button
android:id="@+id/temp"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:enabled="true"
android:layout_gravity="center"
android:fontFamily="@font/poppins_bold"
android:textColor="@color/bg_opp"
android:text="temp"
android:textSize="14sp"
android:backgroundTint="?attr/colorPrimaryContainer"
app:cornerRadius="8dp"
app:strokeColor="?attr/colorPrimaryContainer"
tools:ignore="SpeakableTextPresentCheck" />
</LinearLayout>

<androidx.viewpager2.widget.ViewPager2
Expand Down
55 changes: 55 additions & 0 deletions app/src/main/res/layout/item_follow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="80dp"
app:cardCornerRadius="16dp"
android:layout_marginBottom="16dp">

<ImageView
android:id="@+id/followBanner"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="ContentDescription,ImageContrastCheck" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:orientation="horizontal">

<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_gravity="center"
app:cardCornerRadius="32dp">

<ImageView
android:id="@+id/followProfile"

android:layout_width="64dp"
android:layout_height="64dp"
tools:ignore="ContentDescription,ImageContrastCheck"
tools:srcCompat="@tools:sample/avatars" />
</androidx.cardview.widget.CardView>

<TextView
android:id="@+id/followName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="10dp"
android:gravity="center_vertical"
android:fontFamily="@font/poppins_bold"
android:textColor="?attr/colorSecondary"
tools:text="Username"
tools:ignore="RtlSymmetry" />

</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_gravity="bottom"
android:layout_height="4dp"
android:layout_marginStart="-16dp"
android:layout_marginEnd="-16dp"
android:background="?android:attr/listDivider" />
</androidx.cardview.widget.CardView>

0 comments on commit 8da0092

Please sign in to comment.