Skip to content

Commit

Permalink
Merge pull request #934 from StepicOrg/release/1.206
Browse files Browse the repository at this point in the history
Release/1.206
  • Loading branch information
rostikjoystick authored Jan 19, 2022
2 parents 6b973f2 + 26c6807 commit 8cc2e9e
Show file tree
Hide file tree
Showing 636 changed files with 456 additions and 145 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
</intent-filter>
</service>

<receiver android:name="org.stepik.android.view.purchase_notification.receiver.PurchaseNotificationReceiver">
<receiver android:name="org.stepik.android.view.base.receiver.DismissedNotificationReceiver">
<intent-filter>
<action android:name="notification_dismissed" />
</intent-filter>
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/org/stepic/droid/di/AppCoreComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ import org.stepik.android.view.onboarding.ui.activity.OnboardingCourseListsActiv
import org.stepik.android.view.onboarding.ui.activity.OnboardingGoalActivity
import org.stepik.android.view.personal_deadlines.ui.dialogs.EditDeadlinesDialog
import org.stepik.android.view.personal_deadlines.ui.dialogs.LearningRateDialog
import org.stepik.android.view.purchase_notification.receiver.PurchaseNotificationReceiver
import org.stepik.android.view.base.receiver.DismissedNotificationReceiver
import org.stepik.android.view.streak.ui.dialog.StreakNotificationDialogFragment
import org.stepik.android.view.video_player.ui.service.VideoPlayerForegroundService

Expand Down Expand Up @@ -377,13 +377,12 @@ interface AppCoreComponent {

fun inject(onboardingActivity: AnimatedOnboardingActivity)

fun inject(purchaseNotificationReceiver: PurchaseNotificationReceiver)

fun inject(filterBottomSheetDialogFragment: FilterBottomSheetDialogFragment)

fun inject(onboardingGoalActivity: OnboardingGoalActivity)
fun inject(onboardingCourseListsActivity: OnboardingCourseListsActivity)

fun inject(transactionBottomSheetDialogFragmentFragment: TransactionBottomSheetDialogFragment)
fun inject(videoPlayerForegroundService: VideoPlayerForegroundService)
fun inject(dismissedNotificationReceiver: DismissedNotificationReceiver)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import android.content.Context
import android.content.Intent
import org.stepic.droid.analytic.Analytic
import org.stepic.droid.base.App
import org.stepic.droid.preferences.SharedPreferenceHelper
import org.stepic.droid.storage.operations.DatabaseFacade
import org.stepic.droid.util.AppConstants
import timber.log.Timber
import java.util.concurrent.ThreadPoolExecutor
import javax.inject.Inject

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

@Inject
lateinit var sharedPreferences: SharedPreferenceHelper

init {
App.component().inject(this)
}
Expand All @@ -39,15 +34,6 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
databaseFacade.removeAllNotificationsWithCourseId(courseId)
}
}
} else if (action == AppConstants.NOTIFICATION_CANCELED_REMINDER) {
Timber.d(Analytic.Notification.REMINDER_SWIPE_TO_CANCEL)
analytic.reportEvent(Analytic.Notification.REMINDER_SWIPE_TO_CANCEL)
} else if (action == AppConstants.NOTIFICATION_CANCELED_STREAK) {
analytic.reportEvent(Analytic.Notification.STREAK_SWIPE_TO_CANCEL)
//continue send notification about streaks
threadPool.execute {
sharedPreferences.resetNumberOfStreakNotifications()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ enum class RetentionNotificationType(
@StringRes
val titleRes: Int,
@StringRes
val messageRes: Int
val messageRes: Int,
val dayValue: Int
) {
DAY1(R.string.retention_notification_day1_title, R.string.retention_notification_day1_message),
DAY3(R.string.retention_notification_day3_title, R.string.retention_notification_day3_message)
DAY1(R.string.retention_notification_day1_title, R.string.retention_notification_day1_message, 1),
DAY3(R.string.retention_notification_day3_title, R.string.retention_notification_day3_message, 3)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ import org.stepic.droid.ui.fragments.NotificationsFragment
import org.stepic.droid.util.AppConstants
import org.stepic.droid.util.DateTimeHelper
import org.stepic.droid.util.commit
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent
import org.stepik.android.domain.course.analytic.CourseViewSource
import org.stepik.android.domain.streak.interactor.StreakInteractor
import org.stepik.android.model.Course
import org.stepik.android.view.catalog.ui.fragment.CatalogFragment
import org.stepik.android.view.course_list.notification.RemindAppNotificationDelegate
import org.stepik.android.view.course_list.routing.getCourseListCollectionId
import org.stepik.android.view.debug.ui.fragment.DebugMenu
import org.stepik.android.view.profile.ui.fragment.ProfileFragment
import org.stepik.android.view.story_deeplink.routing.getStoryId
import org.stepik.android.view.story_deeplink.ui.dialog.StoryDeepLinkDialogFragment
import org.stepik.android.view.streak.notification.StreakNotificationDelegate
import org.stepik.android.view.streak.ui.dialog.StreakNotificationDialogFragment
import ru.nobird.android.view.base.ui.extension.showIfNotExists
import timber.log.Timber
import java.util.concurrent.ThreadPoolExecutor
import javax.inject.Inject

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

const val reminderKey = "reminderKey"
const val defaultIndex: Int = 0
private const val LOGGED_ACTION = "LOGGED_ACTION"

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

const val EXTRA_PARCELABLE_ANALYTIC_EVENT = "parcelable_analytic_event"

fun launchAfterLogin(sourceActivity: Activity, course: Course?) {
val intent = Intent(sourceActivity, MainFeedActivity::class.java)
if (course != null) {
Expand Down Expand Up @@ -118,41 +121,41 @@ class MainFeedActivity : BackToExitActivityWithSmartLockBase(),

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
notificationClickedCheck(intent)
checkShortcutAction(intent)

openFragment(intent)
}

private fun notificationClickedCheck(intent: Intent) {
/**
* We call this only from onCreate, because all the notifications launch MainFeedActivity through FLAG_ACTIVITY_NEW_TASK
*/
private fun checkNotificationClick(intent: Intent) {
val action = intent.action
if (action != null) {
if (action == AppConstants.OPEN_NOTIFICATION) {
analytic.reportEvent(AppConstants.OPEN_NOTIFICATION)
} else if (action == AppConstants.OPEN_NOTIFICATION_FOR_ENROLL_REMINDER) {
var dayTypeString: String? = intent.getStringExtra(reminderKey)
if (dayTypeString == null) {
dayTypeString = ""
}
analytic.reportEvent(Analytic.Notification.REMIND_OPEN, dayTypeString)
Timber.d(Analytic.Notification.REMIND_OPEN)
sharedPreferenceHelper.clickEnrollNotification(DateTimeHelper.nowUtc())
} else if (action == AppConstants.OPEN_NOTIFICATION_FROM_STREAK) {
sharedPreferenceHelper.resetNumberOfStreakNotifications()
if (intent.hasExtra(Analytic.Streak.NOTIFICATION_TYPE_PARAM)) {
val notificationType = intent.getSerializableExtra(Analytic.Streak.NOTIFICATION_TYPE_PARAM) as Analytic.Streak.NotificationType
val bundle = Bundle()
bundle.putString(Analytic.Streak.NOTIFICATION_TYPE_PARAM, notificationType.name)
analytic.reportEvent(Analytic.Streak.STREAK_NOTIFICATION_OPENED, bundle)
} else {
analytic.reportEvent(Analytic.Streak.STREAK_NOTIFICATION_OPENED)
}
} else if (action == AppConstants.OPEN_SHORTCUT_CATALOG) {
when (action) {
RemindAppNotificationDelegate.REMIND_APP_NOTIFICATION_CLICKED ->
sharedPreferenceHelper.clickEnrollNotification(DateTimeHelper.nowUtc())

StreakNotificationDelegate.STREAK_NOTIFICATION_CLICKED ->
sharedPreferenceHelper.resetNumberOfStreakNotifications()
}

//after tracking check on null user
if (sharedPreferenceHelper.authResponseFromStore == null) {
screenManager.openSplash(this)
}
}
}

private fun checkShortcutAction(intent: Intent) {
val action = intent.action
if (action != null) {
if (action == AppConstants.OPEN_SHORTCUT_CATALOG) {
analytic.reportEvent(Analytic.Shortcut.OPEN_CATALOG)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
getSystemService(ShortcutManager::class.java)
?.reportShortcutUsed(AppConstants.CATALOG_SHORTCUT_ID)
}

}

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

setContentView(R.layout.activity_main_feed)

notificationClickedCheck(intent)
if (savedInstanceState == null) {
checkShortcutAction(intent)
checkNotificationClick(intent)
val analyticEvent = intent.getParcelableExtra<ParcelableAnalyticEvent>(EXTRA_PARCELABLE_ANALYTIC_EVENT)
if (analyticEvent != null) {
analytic.report(analyticEvent)
}
}

initGoogleApiClient(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ import org.stepic.droid.core.presenters.SplashPresenter
import org.stepic.droid.core.presenters.contracts.SplashView
import org.stepic.droid.util.AppConstants
import org.stepic.droid.util.defaultLocale
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent
import org.stepik.android.view.routing.deeplink.BranchRoute
import java.util.Arrays
import javax.inject.Inject

class SplashActivity : BackToExitActivityBase(), SplashView {

companion object {
const val EXTRA_PARCELABLE_ANALYTIC_EVENT = "parcelable_analytic_event"

private const val RUSSIAN_LANGUAGE_CODE = "ru"
}

Expand All @@ -55,7 +58,12 @@ class SplashActivity : BackToExitActivityBase(), SplashView {
// finish()
// return
// }

if (savedInstanceState == null) {
val analyticEvent = intent.getParcelableExtra<ParcelableAnalyticEvent>(EXTRA_PARCELABLE_ANALYTIC_EVENT)
if (analyticEvent != null) {
analytics.report(analyticEvent)
}
}
defineShortcuts()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.stepik.android.domain.base.analytic

import android.os.Parcelable

interface ParcelableAnalyticEvent : AnalyticEvent, Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.stepik.android.domain.personal_deadlines.analytic

import kotlinx.android.parcel.Parcelize
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent

@Parcelize
data class DeadlinesNotificationClicked(
val course: Long,
val hours: Long
) : ParcelableAnalyticEvent {
companion object {
private const val PARAM_COURSE = "course"
private const val PARAM_HOURS = "hours"
}

override val name: String =
"Personal deadlines app notification clicked"

override val params: Map<String, Any> =
mapOf(
PARAM_COURSE to course,
PARAM_HOURS to hours
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.stepik.android.domain.personal_deadlines.analytic

import kotlinx.android.parcel.Parcelize
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent

@Parcelize
data class DeadlinesNotificationDismissed(
val course: Long,
val hours: Long
) : ParcelableAnalyticEvent {
companion object {
private const val PARAM_COURSE = "course"
private const val PARAM_HOURS = "hours"
}

override val name: String =
"Personal deadlines app notification dismissed"

override val params: Map<String, Any> =
mapOf(
PARAM_COURSE to course,
PARAM_HOURS to hours
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.stepik.android.domain.personal_deadlines.analytic

import org.stepik.android.domain.base.analytic.AnalyticEvent

class DeadlinesNotificationShown(
course: Long,
hours: Long
) : AnalyticEvent {
companion object {
private const val PARAM_COURSE = "course"
private const val PARAM_HOURS = "hours"
}

override val name: String =
"Personal deadlines app notification shown"

override val params: Map<String, Any> =
mapOf(
PARAM_COURSE to course,
PARAM_HOURS to hours
)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.stepik.android.domain.purchase_notification.analytic

import org.stepik.android.domain.base.analytic.AnalyticEvent
import kotlinx.android.parcel.Parcelize
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent

class PurchaseNotificationClicked(courseId: Long) : AnalyticEvent {
@Parcelize
data class PurchaseNotificationClicked(val courseId: Long) : ParcelableAnalyticEvent {
companion object {
private const val PARAM_COURSE = "course"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.stepik.android.domain.purchase_notification.analytic

import org.stepik.android.domain.base.analytic.AnalyticEvent
import kotlinx.android.parcel.Parcelize
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent

class PurchaseNotificationDismissed(courseId: Long) : AnalyticEvent {
@Parcelize
data class PurchaseNotificationDismissed(val courseId: Long) : ParcelableAnalyticEvent {
companion object {
private const val PARAM_COURSE = "course"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.stepik.android.domain.remind.analytic

import kotlinx.android.parcel.Parcelize
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent

@Parcelize
object RemindAppNotificationClicked : ParcelableAnalyticEvent {
override val name: String =
"Remind app notification clicked"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.stepik.android.domain.remind.analytic

import kotlinx.android.parcel.Parcelize
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent

@Parcelize
object RemindAppNotificationDismissed : ParcelableAnalyticEvent {
override val name: String =
"Remind app notification dismissed"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.stepik.android.domain.remind.analytic

import org.stepik.android.domain.base.analytic.AnalyticEvent

object RemindAppNotificationShown : AnalyticEvent {
override val name: String =
"Remind app notification shown"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.stepik.android.domain.remind.analytic

import kotlinx.android.parcel.Parcelize
import org.stepik.android.domain.base.analytic.ParcelableAnalyticEvent

@Parcelize
object RemindRegistrationNotificationClicked : ParcelableAnalyticEvent {
override val name: String =
"Remind registration notification clicked"
}
Loading

0 comments on commit 8cc2e9e

Please sign in to comment.