Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Notifications Refresh] 🤖 Milestone Details: hides the title for achievements #20715

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
@file:JvmName("NoteExtensions")
package org.wordpress.android.models


val Note.type
get() = NoteType.from(rawType)

fun Note.isAchievement() = AchievementType.isAchievementType(rawType)

sealed class Notification {
data class PostLike(val url: String, val title: String): Notification()
data object NewPost: Notification()
Expand Down Expand Up @@ -34,3 +37,29 @@ enum class NoteType(val rawType: String) {
fun from(rawType: String) = map[rawType] ?: Unknown
}
}

enum class AchievementType(val rawType: String) {
UserGoalMet("user_goal_met"),
AutomatticianAchievement("automattician_achievement"),
AchieveBurritoFriday("achieve_burrito_friday"),
AchieveDailyStreak("achieve_daily_streak"),
FollowedMilestoneAchievement("followed_milestone_achievement"),
LikeMilestoneAchievement("like_milestone_achievement"),
OnFireAchievement("on_fire_achievement"),
PostMilestoneAchievement("post_milestone_achievement"),
AchieveUserAnniversary("achieve_user_anniversary"),
BestFollowedDayFeat("best_followed_day_feat"),
BestLikedDayFeat("best_liked_day_feat"),
NewTrafficSurge("new_traffic_surge"),
PrivacyChange("privacy_change"),
FreeTrialStart("free_trial_start"),
FreeTrialNearEndNote("free_trial_near_end_note"),
FreeTrialEnd("free_trial_end"),
ViewMilestone(Note.NOTE_VIEW_MILESTONE),
AscProfileRegenerationStarted("asc_profile_regeneration_started"),
AscProfileRegenerationFinished("asc_profile_regeneration_finished");

companion object {
fun isAchievementType(rawType: String) = entries.any { it.rawType == rawType }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.wordpress.android.fluxc.store.SiteStore;
import org.wordpress.android.fluxc.tools.FormattableRangeType;
import org.wordpress.android.models.Note;
import org.wordpress.android.models.NoteExtensions;
import org.wordpress.android.push.GCMMessageHandler;
import org.wordpress.android.ui.ActivityLauncher;
import org.wordpress.android.ui.CollapseFullScreenDialogFragment;
Expand Down Expand Up @@ -366,6 +367,10 @@ private void setActionBarTitleForNote(Note note) {
title = getString(R.string.reader_title_post_detail);
}

if (NoteExtensions.isAchievement(note)) {
title = "";
}

getSupportActionBar().setTitle(title);
// important for accessibility - talkback
setTitle(getString(R.string.notif_detail_screen_title, title));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.wordpress.android.models

import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.junit.Test
import org.wordpress.android.BaseUnitTest
import kotlin.test.assertFalse
import kotlin.test.assertTrue

@ExperimentalCoroutinesApi
class AchievementTypeTest : BaseUnitTest() {
@Test
fun `isAchievementType returns true for valid achievement types`() {
for (type in AchievementType.entries) {
assertTrue(AchievementType.isAchievementType(type.rawType))
}
}

@Test
fun `isAchievementType returns false for invalid achievement type`() {
assertFalse(AchievementType.isAchievementType("invalid_type"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.wordpress.android.models

import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.junit.Test
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
import org.wordpress.android.BaseUnitTest
import kotlin.test.assertFalse
import kotlin.test.assertTrue

@ExperimentalCoroutinesApi
class NoteExtensionsTest : BaseUnitTest() {
@Test
fun `A comment_like note is not an achievement note`(){
val note = mock<Note>()
whenever(note.rawType).thenReturn("comment_like")
val result = note.isAchievement()
assertFalse(result)
}

@Test
fun `A user_goal_met note is an achievement note`(){
val note = mock<Note>()
whenever(note.rawType).thenReturn("user_goal_met")
val result = note.isAchievement()
assertTrue(result)
}
}
Loading