@@ -30,18 +30,20 @@ import org.stepic.droid.ui.fragments.NotificationsFragment
3030import org.stepic.droid.util.AppConstants
3131import org.stepic.droid.util.DateTimeHelper
3232import org.stepic.droid.util.commit
33+ import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent
3334import org.stepik.android.domain.course.analytic.CourseViewSource
3435import org.stepik.android.domain.streak.interactor.StreakInteractor
3536import org.stepik.android.model.Course
3637import org.stepik.android.view.catalog.ui.fragment.CatalogFragment
38+ import org.stepik.android.view.course_list.notification.RemindAppNotificationDelegate
3739import org.stepik.android.view.course_list.routing.getCourseListCollectionId
3840import org.stepik.android.view.debug.ui.fragment.DebugMenu
3941import org.stepik.android.view.profile.ui.fragment.ProfileFragment
4042import org.stepik.android.view.story_deeplink.routing.getStoryId
4143import org.stepik.android.view.story_deeplink.ui.dialog.StoryDeepLinkDialogFragment
44+ import org.stepik.android.view.streak.notification.StreakNotificationDelegate
4245import org.stepik.android.view.streak.ui.dialog.StreakNotificationDialogFragment
4346import ru.nobird.android.view.base.ui.extension.showIfNotExists
44- import timber.log.Timber
4547import java.util.concurrent.ThreadPoolExecutor
4648import 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
0 commit comments