Skip to content

Commit

Permalink
Merge pull request #269 from rebelonion/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rebelonion authored Mar 20, 2024
2 parents 0f9bf3c + 42f23e4 commit 59784de
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ android {
targetSdk 34
versionCode((System.currentTimeMillis() / 60000).toInteger())
versionName "3.0.0"
versionCode 220000000
versionCode 300000000
signingConfig signingConfigs.debug
}

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/ani/dantotsu/home/AnimeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ class AnimeFragment : Fragment() {
binding.root.requestApplyInsets()
binding.root.requestLayout()
}
if (this::animePageAdapter.isInitialized && _binding != null) {
animePageAdapter.updateNotificationCount()
}
super.onResume()
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/ani/dantotsu/home/AnimePageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ class AnimePageAdapter : RecyclerView.Adapter<AnimePageAdapter.AnimePageViewHold
}
}

fun updateNotificationCount() {
if (this::binding.isInitialized) {
binding.animeNotificationCount.visibility =
if (Anilist.unreadNotificationCount > 0) View.VISIBLE else View.GONE
binding.animeNotificationCount.text = Anilist.unreadNotificationCount.toString()
}
}

inner class AnimePageViewHolder(val binding: ItemAnimePageBinding) :
RecyclerView.ViewHolder(binding.root)
}
3 changes: 3 additions & 0 deletions app/src/main/java/ani/dantotsu/home/MangaFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ class MangaFragment : Fragment() {
binding.root.requestApplyInsets()
binding.root.requestLayout()
}
if (this::mangaPageAdapter.isInitialized && _binding != null) {
mangaPageAdapter.updateNotificationCount()
}
super.onResume()
}

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/ani/dantotsu/home/MangaPageAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ class MangaPageAdapter : RecyclerView.Adapter<MangaPageAdapter.MangaPageViewHold
}
}

fun updateNotificationCount() {
if (this::binding.isInitialized) {
binding.mangaNotificationCount.visibility =
if (Anilist.unreadNotificationCount > 0) View.VISIBLE else View.GONE
binding.mangaNotificationCount.text = Anilist.unreadNotificationCount.toString()
}
}

inner class MangaPageViewHolder(val binding: ItemMangaPageBinding) :
RecyclerView.ViewHolder(binding.root)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class CommentsFragment : Fragment() {
savedInstanceState: Bundle?
): View {
binding = FragmentCommentsBinding.inflate(inflater, container, false)
binding.commentsLayout.isNestedScrollingEnabled = true
return binding.root
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import java.util.concurrent.TimeUnit

class AlarmManagerScheduler(private val context: Context) : TaskScheduler {
override fun scheduleRepeatingTask(taskType: TaskType, interval: Long) {
if (interval < TimeUnit.MINUTES.toMillis(15)) {
cancelTask(taskType)
return
}
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val intent = when (taskType) {
TaskType.COMMENT_NOTIFICATION -> Intent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import ani.dantotsu.notifications.subscription.SubscriptionNotificationWorker

class WorkManagerScheduler(private val context: Context) : TaskScheduler {
override fun scheduleRepeatingTask(taskType: TaskType, interval: Long) {
if (interval < PeriodicWorkRequest.MIN_PERIODIC_INTERVAL_MILLIS) {
cancelTask(taskType)
return
}
val constraints = Constraints.Builder()
.setRequiredNetworkType(androidx.work.NetworkType.CONNECTED)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class NotificationActivity : AppCompatActivity() {
)
newNotifications += notification
}
newNotifications.sortByDescending { it.createdAt }
}

notificationList += newNotifications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package ani.dantotsu.profile.activity

import android.util.TypedValue
import android.view.View
import android.view.ViewGroup
import androidx.core.view.updateLayoutParams
import ani.dantotsu.R
import ani.dantotsu.blurImage
import ani.dantotsu.connections.anilist.api.Notification
Expand Down Expand Up @@ -37,17 +39,25 @@ class NotificationItem(
?: notification.user?.avatar?.medium else notification.media?.bannerImage
?: notification.media?.coverImage?.large
blurImage(binding.notificationBannerImage, cover)

val defaultHeight = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
170f,
153f,
binding.root.context.resources.displayMetrics
).toInt()

val userHeight = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
90f,
binding.root.context.resources.displayMetrics
).toInt()

val textMarginStart = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
125f,
binding.root.context.resources.displayMetrics
).toInt()

if (user) {
binding.notificationCover.visibility = View.GONE
binding.notificationCoverUser.visibility = View.VISIBLE
Expand All @@ -60,12 +70,16 @@ class NotificationItem(
binding.notificationCoverUser.loadImage(notification.user?.avatar?.large)
}
binding.notificationBannerImage.layoutParams.height = userHeight
binding.notificationGradiant.layoutParams.height = userHeight
(binding.notificationTextContainer.layoutParams as ViewGroup.MarginLayoutParams).marginStart = userHeight
} else {
binding.notificationCover.visibility = View.VISIBLE
binding.notificationCoverUser.visibility = View.VISIBLE
binding.notificationCoverUserContainer.visibility = View.GONE
binding.notificationCover.loadImage(notification.media?.coverImage?.large)
binding.notificationBannerImage.layoutParams.height = defaultHeight
binding.notificationGradiant.layoutParams.height = defaultHeight
(binding.notificationTextContainer.layoutParams as ViewGroup.MarginLayoutParams).marginStart = textMarginStart
}
}

Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/fragment_comments.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView 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:id="@+id/commentsLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:colorBackground">
android:background="?android:colorBackground"
android:fillViewport="true">


<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Expand Down Expand Up @@ -82,4 +83,4 @@
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</FrameLayout>
</androidx.core.widget.NestedScrollView>
42 changes: 24 additions & 18 deletions app/src/main/res/layout/item_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="18dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="18dp"
android:background="?android:colorBackground"
android:fontFamily="@font/poppins_semi_bold"
android:text="@string/lorem_ipsum"
android:textAlignment="center"
tools:visibility="gone"
android:background="?android:colorBackground"
android:textSize="12sp" />
android:textSize="12sp"
tools:visibility="gone" />

<FrameLayout
android:id="@+id/activityBannerContainer"
Expand All @@ -114,22 +114,22 @@
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:backgroundTint="?attr/colorSurface"
app:strokeColor="@color/transparent"
app:cardCornerRadius="24dp">
app:cardCornerRadius="24dp"
app:strokeColor="@color/transparent">

<ImageView
android:id="@+id/activityBannerImage"
android:layout_width="match_parent"
android:layout_height="169dp"
android:layout_height="152dp"
android:scaleType="centerCrop"
tools:ignore="ContentDescription"
tools:srcCompat="@tools:sample/backgrounds/scenic" />

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="170dp"
app:srcCompat="@drawable/linear_gradient_nav_inv"
android:layout_height="153dp"
app:srcCompat="@drawable/linear_gradient_nav"
tools:ignore="ContentDescription" />


Expand All @@ -138,14 +138,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_margin="16dp"
android:layout_marginStart="16dp"
android:backgroundTint="@color/bg_white"
app:cardCornerRadius="16dp">
app:cardCornerRadius="16dp"
app:strokeColor="@color/transparent">

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/activityCover"
android:layout_width="102dp"
android:layout_height="154dp"
android:layout_width="108dp"
android:layout_height="160dp"
android:layout_gravity="center"
android:scaleType="centerCrop"
app:srcCompat="@drawable/ic_round_add_circle_24"
Expand All @@ -161,15 +163,15 @@
android:layout_marginStart="128dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical">
android:orientation="vertical"
android:padding="8dp">

<TextView
android:id="@+id/activityMediaName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@font/poppins_semi_bold"
android:textColor="@color/bg_opp"
android:fontFamily="@font/poppins_bold"
android:maxLines="2"
android:text="@string/anime"
android:textSize="16sp"
Expand All @@ -181,9 +183,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:alpha="0.66"
android:ellipsize="end"
android:fontFamily="@font/poppins_semi_bold"
android:textColor="@color/bg_opp"
android:maxLines="2"
android:text="@string/slogan"
android:textColor="@color/bg_opp"
android:textSize="14sp"
android:textStyle="bold"
tools:ignore="HardcodedText" />
Expand Down Expand Up @@ -224,7 +229,8 @@
android:id="@+id/activityReplies"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:layout_marginStart="16dp"/>
android:layout_marginStart="16dp"
android:nestedScrollingEnabled="false"
android:visibility="gone" />

</LinearLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_comments.xml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
android:paddingStart="16dp"
android:visibility="visible"
tools:ignore="RtlSymmetry"
android:nestedScrollingEnabled="false"
tools:visibility="visible" />

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/item_follower.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ImageView
android:id="@+id/profileBannerImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="89dp"
android:scaleType="centerCrop"
tools:srcCompat="@tools:sample/backgrounds/scenic"
tools:ignore="ContentDescription" />
Expand Down
27 changes: 16 additions & 11 deletions app/src/main/res/layout/item_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
<ImageView
android:id="@+id/notificationBannerImage"
android:layout_width="match_parent"
android:layout_height="170dp"
android:layout_height="153dp"
android:scaleType="centerCrop"
tools:ignore="ContentDescription"
tools:srcCompat="@tools:sample/backgrounds/scenic" />

<ImageView
android:id="@+id/notificationGradiant"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="153dp"
app:srcCompat="@drawable/linear_gradient_nav"
tools:ignore="ContentDescription" />

Expand All @@ -35,18 +36,19 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_marginStart="16dp"
android:layout_margin="16dp"
android:backgroundTint="@color/transparent"
app:cardCornerRadius="16dp"
app:strokeColor="@color/transparent">

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/notificationCover"
android:layout_width="96dp"
android:layout_height="144dp"
android:layout_gravity="center"
app:srcCompat="@drawable/ic_round_add_circle_24"
android:layout_width="108dp"
android:layout_height="160dp"
android:scaleType="centerCrop"
app:shapeAppearanceOverlay="@style/roundedImageView"
tools:ignore="ContentDescription,ImageContrastCheck"
tools:srcCompat="@tools:sample/backgrounds/scenic"
tools:tint="@color/transparent" />

</com.google.android.material.card.MaterialCardView>
Expand Down Expand Up @@ -74,19 +76,22 @@
</com.google.android.material.card.MaterialCardView>

<LinearLayout
android:layout_width="wrap_content"
android:id="@+id/notificationTextContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_marginStart="125dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:padding="8dp"
android:orientation="vertical">

<TextView
android:id="@+id/notificationText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:fontFamily="@font/poppins_semi_bold"
android:fontFamily="@font/poppins_bold"
android:maxLines="3"
android:textSize="14dp"
android:transitionName="mediaTitle"
Expand All @@ -98,11 +103,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginEnd="20dp"
android:alpha="0.66"
android:fontFamily="@font/poppins_semi_bold"
android:text="Wed,06 March 2024, 7:00PM"
android:textSize="10sp"
tools:ignore="HardcodedText" />
tools:ignore="HardcodedText,SmallSp" />
</LinearLayout>

</com.google.android.material.card.MaterialCardView>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<color name="nav_bg">#1C1C1C</color>
<color name="nav_bg_inv">#001C1C1C</color>
<color name="nav_tab">#40ffffff</color>
<color name="gradiant_bg_start">#AA1C1C1C</color>
<color name="gradiant_bg_end">#20000000</color>
<color name="gradiant_bg_end">#AA1C1C1C</color>
<color name="gradiant_bg_start">#434343</color>
<color name="nav_tab_disabled">#40ffffff</color>
<color name="transparent">#00000000</color>
<color name="nav_status">#80000000</color>
Expand Down
Loading

0 comments on commit 59784de

Please sign in to comment.