Skip to content

Commit 8cc2e9e

Browse files
Merge pull request #934 from StepicOrg/release/1.206
Release/1.206
2 parents 6b973f2 + 26c6807 commit 8cc2e9e

File tree

636 files changed

+456
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

636 files changed

+456
-145
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
</intent-filter>
430430
</service>
431431

432-
<receiver android:name="org.stepik.android.view.purchase_notification.receiver.PurchaseNotificationReceiver">
432+
<receiver android:name="org.stepik.android.view.base.receiver.DismissedNotificationReceiver">
433433
<intent-filter>
434434
<action android:name="notification_dismissed" />
435435
</intent-filter>

app/src/main/java/org/stepic/droid/di/AppCoreComponent.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ import org.stepik.android.view.onboarding.ui.activity.OnboardingCourseListsActiv
128128
import org.stepik.android.view.onboarding.ui.activity.OnboardingGoalActivity
129129
import org.stepik.android.view.personal_deadlines.ui.dialogs.EditDeadlinesDialog
130130
import org.stepik.android.view.personal_deadlines.ui.dialogs.LearningRateDialog
131-
import org.stepik.android.view.purchase_notification.receiver.PurchaseNotificationReceiver
131+
import org.stepik.android.view.base.receiver.DismissedNotificationReceiver
132132
import org.stepik.android.view.streak.ui.dialog.StreakNotificationDialogFragment
133133
import org.stepik.android.view.video_player.ui.service.VideoPlayerForegroundService
134134

@@ -377,13 +377,12 @@ interface AppCoreComponent {
377377

378378
fun inject(onboardingActivity: AnimatedOnboardingActivity)
379379

380-
fun inject(purchaseNotificationReceiver: PurchaseNotificationReceiver)
381-
382380
fun inject(filterBottomSheetDialogFragment: FilterBottomSheetDialogFragment)
383381

384382
fun inject(onboardingGoalActivity: OnboardingGoalActivity)
385383
fun inject(onboardingCourseListsActivity: OnboardingCourseListsActivity)
386384

387385
fun inject(transactionBottomSheetDialogFragmentFragment: TransactionBottomSheetDialogFragment)
388386
fun inject(videoPlayerForegroundService: VideoPlayerForegroundService)
387+
fun inject(dismissedNotificationReceiver: DismissedNotificationReceiver)
389388
}

app/src/main/java/org/stepic/droid/notifications/NotificationBroadcastReceiver.kt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import android.content.Context
55
import android.content.Intent
66
import org.stepic.droid.analytic.Analytic
77
import org.stepic.droid.base.App
8-
import org.stepic.droid.preferences.SharedPreferenceHelper
98
import org.stepic.droid.storage.operations.DatabaseFacade
109
import org.stepic.droid.util.AppConstants
11-
import timber.log.Timber
1210
import java.util.concurrent.ThreadPoolExecutor
1311
import javax.inject.Inject
1412

@@ -22,9 +20,6 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
2220
@Inject
2321
lateinit var analytic: Analytic
2422

25-
@Inject
26-
lateinit var sharedPreferences: SharedPreferenceHelper
27-
2823
init {
2924
App.component().inject(this)
3025
}
@@ -39,15 +34,6 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
3934
databaseFacade.removeAllNotificationsWithCourseId(courseId)
4035
}
4136
}
42-
} else if (action == AppConstants.NOTIFICATION_CANCELED_REMINDER) {
43-
Timber.d(Analytic.Notification.REMINDER_SWIPE_TO_CANCEL)
44-
analytic.reportEvent(Analytic.Notification.REMINDER_SWIPE_TO_CANCEL)
45-
} else if (action == AppConstants.NOTIFICATION_CANCELED_STREAK) {
46-
analytic.reportEvent(Analytic.Notification.STREAK_SWIPE_TO_CANCEL)
47-
//continue send notification about streaks
48-
threadPool.execute {
49-
sharedPreferences.resetNumberOfStreakNotifications()
50-
}
5137
}
5238
}
5339
}

app/src/main/java/org/stepic/droid/notifications/model/RetentionNotificationType.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ enum class RetentionNotificationType(
77
@StringRes
88
val titleRes: Int,
99
@StringRes
10-
val messageRes: Int
10+
val messageRes: Int,
11+
val dayValue: Int
1112
) {
12-
DAY1(R.string.retention_notification_day1_title, R.string.retention_notification_day1_message),
13-
DAY3(R.string.retention_notification_day3_title, R.string.retention_notification_day3_message)
13+
DAY1(R.string.retention_notification_day1_title, R.string.retention_notification_day1_message, 1),
14+
DAY3(R.string.retention_notification_day3_title, R.string.retention_notification_day3_message, 3)
1415
}

app/src/main/java/org/stepic/droid/ui/activities/MainFeedActivity.kt

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,20 @@ import org.stepic.droid.ui.fragments.NotificationsFragment
3030
import org.stepic.droid.util.AppConstants
3131
import org.stepic.droid.util.DateTimeHelper
3232
import org.stepic.droid.util.commit
33+
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent
3334
import org.stepik.android.domain.course.analytic.CourseViewSource
3435
import org.stepik.android.domain.streak.interactor.StreakInteractor
3536
import org.stepik.android.model.Course
3637
import org.stepik.android.view.catalog.ui.fragment.CatalogFragment
38+
import org.stepik.android.view.course_list.notification.RemindAppNotificationDelegate
3739
import org.stepik.android.view.course_list.routing.getCourseListCollectionId
3840
import org.stepik.android.view.debug.ui.fragment.DebugMenu
3941
import org.stepik.android.view.profile.ui.fragment.ProfileFragment
4042
import org.stepik.android.view.story_deeplink.routing.getStoryId
4143
import org.stepik.android.view.story_deeplink.ui.dialog.StoryDeepLinkDialogFragment
44+
import org.stepik.android.view.streak.notification.StreakNotificationDelegate
4245
import org.stepik.android.view.streak.ui.dialog.StreakNotificationDialogFragment
4346
import ru.nobird.android.view.base.ui.extension.showIfNotExists
44-
import timber.log.Timber
4547
import java.util.concurrent.ThreadPoolExecutor
4648
import javax.inject.Inject
4749

@@ -58,7 +60,6 @@ class MainFeedActivity : BackToExitActivityWithSmartLockBase(),
5860
companion object {
5961
const val CURRENT_INDEX_KEY = "currentIndexKey"
6062

61-
const val reminderKey = "reminderKey"
6263
const val defaultIndex: Int = 0
6364
private const val LOGGED_ACTION = "LOGGED_ACTION"
6465

@@ -75,6 +76,8 @@ class MainFeedActivity : BackToExitActivityWithSmartLockBase(),
7576
const val NOTIFICATIONS_INDEX: Int = 4
7677
const val DEBUG_INDEX: Int = 5
7778

79+
const val EXTRA_PARCELABLE_ANALYTIC_EVENT = "parcelable_analytic_event"
80+
7881
fun launchAfterLogin(sourceActivity: Activity, course: Course?) {
7982
val intent = Intent(sourceActivity, MainFeedActivity::class.java)
8083
if (course != null) {
@@ -118,41 +121,41 @@ class MainFeedActivity : BackToExitActivityWithSmartLockBase(),
118121

119122
override fun onNewIntent(intent: Intent) {
120123
super.onNewIntent(intent)
121-
notificationClickedCheck(intent)
124+
checkShortcutAction(intent)
122125

123126
openFragment(intent)
124127
}
125128

126-
private fun notificationClickedCheck(intent: Intent) {
129+
/**
130+
* We call this only from onCreate, because all the notifications launch MainFeedActivity through FLAG_ACTIVITY_NEW_TASK
131+
*/
132+
private fun checkNotificationClick(intent: Intent) {
127133
val action = intent.action
128134
if (action != null) {
129-
if (action == AppConstants.OPEN_NOTIFICATION) {
130-
analytic.reportEvent(AppConstants.OPEN_NOTIFICATION)
131-
} else if (action == AppConstants.OPEN_NOTIFICATION_FOR_ENROLL_REMINDER) {
132-
var dayTypeString: String? = intent.getStringExtra(reminderKey)
133-
if (dayTypeString == null) {
134-
dayTypeString = ""
135-
}
136-
analytic.reportEvent(Analytic.Notification.REMIND_OPEN, dayTypeString)
137-
Timber.d(Analytic.Notification.REMIND_OPEN)
138-
sharedPreferenceHelper.clickEnrollNotification(DateTimeHelper.nowUtc())
139-
} else if (action == AppConstants.OPEN_NOTIFICATION_FROM_STREAK) {
140-
sharedPreferenceHelper.resetNumberOfStreakNotifications()
141-
if (intent.hasExtra(Analytic.Streak.NOTIFICATION_TYPE_PARAM)) {
142-
val notificationType = intent.getSerializableExtra(Analytic.Streak.NOTIFICATION_TYPE_PARAM) as Analytic.Streak.NotificationType
143-
val bundle = Bundle()
144-
bundle.putString(Analytic.Streak.NOTIFICATION_TYPE_PARAM, notificationType.name)
145-
analytic.reportEvent(Analytic.Streak.STREAK_NOTIFICATION_OPENED, bundle)
146-
} else {
147-
analytic.reportEvent(Analytic.Streak.STREAK_NOTIFICATION_OPENED)
148-
}
149-
} else if (action == AppConstants.OPEN_SHORTCUT_CATALOG) {
135+
when (action) {
136+
RemindAppNotificationDelegate.REMIND_APP_NOTIFICATION_CLICKED ->
137+
sharedPreferenceHelper.clickEnrollNotification(DateTimeHelper.nowUtc())
138+
139+
StreakNotificationDelegate.STREAK_NOTIFICATION_CLICKED ->
140+
sharedPreferenceHelper.resetNumberOfStreakNotifications()
141+
}
142+
143+
//after tracking check on null user
144+
if (sharedPreferenceHelper.authResponseFromStore == null) {
145+
screenManager.openSplash(this)
146+
}
147+
}
148+
}
149+
150+
private fun checkShortcutAction(intent: Intent) {
151+
val action = intent.action
152+
if (action != null) {
153+
if (action == AppConstants.OPEN_SHORTCUT_CATALOG) {
150154
analytic.reportEvent(Analytic.Shortcut.OPEN_CATALOG)
151155
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
152156
getSystemService(ShortcutManager::class.java)
153157
?.reportShortcutUsed(AppConstants.CATALOG_SHORTCUT_ID)
154158
}
155-
156159
}
157160

158161
//after tracking check on null user
@@ -170,7 +173,14 @@ class MainFeedActivity : BackToExitActivityWithSmartLockBase(),
170173

171174
setContentView(R.layout.activity_main_feed)
172175

173-
notificationClickedCheck(intent)
176+
if (savedInstanceState == null) {
177+
checkShortcutAction(intent)
178+
checkNotificationClick(intent)
179+
val analyticEvent = intent.getParcelableExtra<ParcelableAnalyticEvent>(EXTRA_PARCELABLE_ANALYTIC_EVENT)
180+
if (analyticEvent != null) {
181+
analytic.report(analyticEvent)
182+
}
183+
}
174184

175185
initGoogleApiClient(true)
176186

app/src/main/java/org/stepic/droid/ui/activities/SplashActivity.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ import org.stepic.droid.core.presenters.SplashPresenter
2323
import org.stepic.droid.core.presenters.contracts.SplashView
2424
import org.stepic.droid.util.AppConstants
2525
import org.stepic.droid.util.defaultLocale
26+
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent
2627
import org.stepik.android.view.routing.deeplink.BranchRoute
2728
import java.util.Arrays
2829
import javax.inject.Inject
2930

3031
class SplashActivity : BackToExitActivityBase(), SplashView {
3132

3233
companion object {
34+
const val EXTRA_PARCELABLE_ANALYTIC_EVENT = "parcelable_analytic_event"
35+
3336
private const val RUSSIAN_LANGUAGE_CODE = "ru"
3437
}
3538

@@ -55,7 +58,12 @@ class SplashActivity : BackToExitActivityBase(), SplashView {
5558
// finish()
5659
// return
5760
// }
58-
61+
if (savedInstanceState == null) {
62+
val analyticEvent = intent.getParcelableExtra<ParcelableAnalyticEvent>(EXTRA_PARCELABLE_ANALYTIC_EVENT)
63+
if (analyticEvent != null) {
64+
analytics.report(analyticEvent)
65+
}
66+
}
5967
defineShortcuts()
6068
}
6169

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.stepik.android.domain.base.analytic
2+
3+
import android.os.Parcelable
4+
5+
interface ParcelableAnalyticEvent : AnalyticEvent, Parcelable
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.stepik.android.domain.personal_deadlines.analytic
2+
3+
import kotlinx.android.parcel.Parcelize
4+
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent
5+
6+
@Parcelize
7+
data class DeadlinesNotificationClicked(
8+
val course: Long,
9+
val hours: Long
10+
) : ParcelableAnalyticEvent {
11+
companion object {
12+
private const val PARAM_COURSE = "course"
13+
private const val PARAM_HOURS = "hours"
14+
}
15+
16+
override val name: String =
17+
"Personal deadlines app notification clicked"
18+
19+
override val params: Map<String, Any> =
20+
mapOf(
21+
PARAM_COURSE to course,
22+
PARAM_HOURS to hours
23+
)
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.stepik.android.domain.personal_deadlines.analytic
2+
3+
import kotlinx.android.parcel.Parcelize
4+
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent
5+
6+
@Parcelize
7+
data class DeadlinesNotificationDismissed(
8+
val course: Long,
9+
val hours: Long
10+
) : ParcelableAnalyticEvent {
11+
companion object {
12+
private const val PARAM_COURSE = "course"
13+
private const val PARAM_HOURS = "hours"
14+
}
15+
16+
override val name: String =
17+
"Personal deadlines app notification dismissed"
18+
19+
override val params: Map<String, Any> =
20+
mapOf(
21+
PARAM_COURSE to course,
22+
PARAM_HOURS to hours
23+
)
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.stepik.android.domain.personal_deadlines.analytic
2+
3+
import org.stepik.android.domain.base.analytic.AnalyticEvent
4+
5+
class DeadlinesNotificationShown(
6+
course: Long,
7+
hours: Long
8+
) : AnalyticEvent {
9+
companion object {
10+
private const val PARAM_COURSE = "course"
11+
private const val PARAM_HOURS = "hours"
12+
}
13+
14+
override val name: String =
15+
"Personal deadlines app notification shown"
16+
17+
override val params: Map<String, Any> =
18+
mapOf(
19+
PARAM_COURSE to course,
20+
PARAM_HOURS to hours
21+
)
22+
}

0 commit comments

Comments
 (0)