Skip to content

Commit

Permalink
Merge pull request #966 from StepicOrg/release/1.217
Browse files Browse the repository at this point in the history
Release/1.217
  • Loading branch information
rostikjoystick authored Apr 6, 2022
2 parents 8a60892 + fa40c1e commit f14c043
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 38 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ dependencies {
implementation libraries.firebaseAppindexing
implementation libraries.googleauth
implementation libraries.firebaseConfig
implementation libraries.firebasePerf

// implementation libraries.facebookSdk
implementation libraries.vkSdk
Expand Down Expand Up @@ -256,6 +255,8 @@ dependencies {
androidTestImplementation libraries.espressoCore
androidTestImplementation libraries.espressoContrib
androidTestImplementation libraries.espressoIntents
androidTestImplementation libraries.kaspresso
androidTestImplementation libraries.kaspressoAllure

debugImplementation libraries.soloader
debugImplementation libraries.flipperCore
Expand All @@ -277,5 +278,4 @@ afterEvaluate {
apply plugin: 'com.google.gms.google-services'
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Release")) {
apply plugin: 'com.getkeepsafe.dexcount'
}
apply plugin: 'com.google.firebase.firebase-perf'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.stepik.android.view.auth.ui.activity

import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
import org.junit.Rule
import org.junit.Test

class AuthSampleTest : TestCase() {
@get:Rule
val activityTestRule = ActivityScenarioRule(SocialAuthActivity::class.java)

@Test
fun test() =
run {
step("Open Social Auth Screen") {
testLogger.d("I am testLogger")
SocialAuthScreen {
signInWithEmailButton {
isVisible()
click()
}
}
}

step("Open Credential Auth Screen") {
CredentialAuthScreen {
loginField.isVisible()
loginField.typeText("[email protected]")
passwordField.typeText("stepikthebest")
loginField.hasText("[email protected]")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.stepik.android.view.auth.ui.activity

import org.stepic.droid.R
import com.kaspersky.kaspresso.screens.KScreen
import io.github.kakaocup.kakao.edit.KEditText

object CredentialAuthScreen : KScreen<CredentialAuthScreen>() {
override val layoutId: Int = R.layout.activity_auth_credential
override val viewClass: Class<*> = CredentialAuthActivity::class.java

val loginField = KEditText { withId(R.id.loginField) }
val passwordField = KEditText { withId(R.id.passwordField) }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.stepik.android.view.auth.ui.activity

import com.kaspersky.kaspresso.screens.KScreen
import io.github.kakaocup.kakao.text.KButton
import org.stepic.droid.R

object SocialAuthScreen : KScreen<SocialAuthScreen>() {

override val layoutId: Int = R.layout.activity_auth_social
override val viewClass: Class<*> = SocialAuthActivity::class.java

val signInWithEmailButton = KButton { withId(R.id.signInWithEmail) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface AmplitudeAnalytic {
const val IS_NIGHT_MODE_ENABLED = "is_night_mode_enabled"
const val IS_AR_SUPPORTED = "is_ar_supported"
const val IS_GOOGLE_SERVICES_AVAILABLE = "is_google_services_available"
const val ACCESSIBILITY_FONT_SCALE = "accessibility_font_scale"
const val ACCESSIBILITY_SCREEN_READER_ENABLED = "accessibility_screen_reader_enabled"
}

object Launch {
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/org/stepic/droid/analytic/Analytic.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,6 @@ interface Params {
}
}

interface Traces {
String COURSE_CONTENT_LOADING = "course_content_loading";
String SPLASH_LOADING = "splash_loading";
}

void reportEvent(String eventName, Bundle bundle);

void reportEvent(String eventName, String id);
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/java/org/stepic/droid/analytic/AnalyticImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import com.yandex.metrica.profile.UserProfile
import org.json.JSONObject
import org.stepic.droid.base.App
import org.stepic.droid.configuration.Config
import org.stepic.droid.configuration.RemoteConfig
import org.stepic.droid.di.AppSingleton
import org.stepic.droid.util.isARSupported
import org.stepic.droid.util.isScreenReaderOn
import org.stepik.android.domain.base.analytic.AnalyticEvent
import org.stepik.android.domain.base.analytic.AnalyticSource
import org.stepik.android.domain.base.analytic.UserProperty
Expand Down Expand Up @@ -66,17 +66,23 @@ constructor(
.set(AmplitudeAnalytic.Properties.PUSH_PERMISSION, if (isNotificationsEnabled) "granted" else "not_granted")
.set(AmplitudeAnalytic.Properties.IS_NIGHT_MODE_ENABLED, context.isNightModeEnabled().toString())
.set(AmplitudeAnalytic.Properties.IS_AR_SUPPORTED, context.isARSupported().toString())
.set(AmplitudeAnalytic.Properties.ACCESSIBILITY_FONT_SCALE, context.resources.configuration.fontScale.toString())
.set(AmplitudeAnalytic.Properties.ACCESSIBILITY_SCREEN_READER_ENABLED, context.isScreenReaderOn().toString())
)

updateYandexUserProfile {
apply(Attribute.notificationsEnabled().withValue(isNotificationsEnabled))
apply(Attribute.customBoolean(AmplitudeAnalytic.Properties.IS_NIGHT_MODE_ENABLED).withValue(context.isNightModeEnabled()))
apply(Attribute.customBoolean(AmplitudeAnalytic.Properties.IS_AR_SUPPORTED).withValue(context.isARSupported()))
apply(Attribute.customNumber(AmplitudeAnalytic.Properties.ACCESSIBILITY_FONT_SCALE).withValue(context.resources.configuration.fontScale.toDouble()))
apply(Attribute.customBoolean(AmplitudeAnalytic.Properties.ACCESSIBILITY_SCREEN_READER_ENABLED).withValue(context.isScreenReaderOn()))
}

setFirebaseUserProperty(AmplitudeAnalytic.Properties.PUSH_PERMISSION, if (isNotificationsEnabled) "granted" else "not_granted")
setFirebaseUserProperty(AmplitudeAnalytic.Properties.IS_NIGHT_MODE_ENABLED, context.isNightModeEnabled().toString())
setFirebaseUserProperty(AmplitudeAnalytic.Properties.IS_AR_SUPPORTED, context.isARSupported().toString())
setFirebaseUserProperty(AmplitudeAnalytic.Properties.ACCESSIBILITY_FONT_SCALE, context.resources.configuration.fontScale.toString())
setFirebaseUserProperty(AmplitudeAnalytic.Properties.ACCESSIBILITY_SCREEN_READER_ENABLED, context.isScreenReaderOn().toString())
}

// Amplitude properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.stepic.droid.core.presenters

import android.content.res.Resources
import com.google.android.gms.tasks.Tasks
import com.google.firebase.perf.FirebasePerformance
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.ktx.get
import io.reactivex.Completable
Expand Down Expand Up @@ -32,7 +31,6 @@ import org.stepik.android.view.routing.deeplink.BranchDeepLinkParser
import org.stepik.android.view.routing.deeplink.BranchRoute
import org.stepik.android.view.splash.notification.RemindRegistrationNotificationDelegate
import org.stepik.android.view.splash.notification.RetentionNotificationDelegate
import java.util.concurrent.TimeUnit
import javax.inject.Inject

@SplashScope
Expand Down Expand Up @@ -73,7 +71,6 @@ constructor(
private var disposable: Disposable? = null

fun onSplashCreated(referringParams: JSONObject? = null) {
val splashLoadingTrace = FirebasePerformance.startTrace(Analytic.Traces.SPLASH_LOADING)
disposable = Completable
.fromCallable {
countNumberOfLaunches()
Expand All @@ -94,9 +91,6 @@ constructor(
.andThen(resolveSplashRoute(referringParams))
.subscribeOn(backgroundScheduler)
.observeOn(mainScheduler)
.doFinally {
splashLoadingTrace.stop()
}
.subscribeBy(
onError = emptyOnErrorStub,
onSuccess = {
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/org/stepic/droid/util/ContextExtensions.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package org.stepic.droid.util

import android.accessibilityservice.AccessibilityServiceInfo
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.os.Build
import android.util.TypedValue
import android.view.accessibility.AccessibilityManager
import android.widget.Toast
import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
import androidx.appcompat.content.res.AppCompatResources

fun Context.copyTextToClipboard(label: String? = null, textToCopy: String, toastMessage: String) {
val clipboardManager = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
Expand Down Expand Up @@ -61,4 +58,9 @@ fun Context.isARSupported(): Boolean =
true
} catch (e : PackageManager.NameNotFoundException) {
false
}
}

fun Context.isScreenReaderOn(): Boolean {
val am = getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
return am.isEnabled && am.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_SPOKEN).isNotEmpty()
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package org.stepik.android.domain.course_content.interactor

import com.google.firebase.perf.FirebasePerformance
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.rxkotlin.Observables
import io.reactivex.rxkotlin.Singles.zip
import io.reactivex.rxkotlin.toObservable
import io.reactivex.schedulers.Schedulers
import io.reactivex.subjects.PublishSubject
import org.stepic.droid.analytic.AmplitudeAnalytic
import org.stepic.droid.analytic.Analytic
import ru.nobird.app.core.model.mapToLongArray
import org.stepic.droid.util.plus
import org.stepik.android.domain.base.DataSourceType
Expand Down Expand Up @@ -74,21 +71,12 @@ constructor(
private fun getEmptySections(course: Course): Observable<Pair<Course, List<CourseContentItem>>> =
Observable.just(course to emptyList())

private fun getContent(course: Course, items: List<CourseContentItem>, dataSourceType: DataSourceType): Observable<Pair<Course, List<CourseContentItem>>> {
val courseContentLoadingTrace = FirebasePerformance.getInstance().newTrace(Analytic.Traces.COURSE_CONTENT_LOADING)
courseContentLoadingTrace.putAttribute(AmplitudeAnalytic.Course.Params.COURSE, course.id.toString())
courseContentLoadingTrace.putAttribute(AmplitudeAnalytic.Course.Params.SOURCE, dataSourceType.name)
courseContentLoadingTrace.start()

return getSectionsOfCourse(course, dataSourceType)
private fun getContent(course: Course, items: List<CourseContentItem>, dataSourceType: DataSourceType): Observable<Pair<Course, List<CourseContentItem>>> =
getSectionsOfCourse(course, dataSourceType)
.flatMap { populateSections(course, it, items, dataSourceType) }
.flatMapObservable { populatedItems ->
Observable.just(course to populatedItems) + loadUnits(course, populatedItems, dataSourceType)
}
.doOnComplete {
courseContentLoadingTrace.stop()
}
}

private fun getSectionsOfCourse(course: Course, dataSourceType: DataSourceType): Single<List<Section>> =
sectionRepository
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ buildscript {
classpath gradlePlugins.android
classpath gradlePlugins.googleServices
classpath gradlePlugins.crashlyticsPlugin
classpath gradlePlugins.firebasePerfPlugin
classpath gradlePlugins.kotlin
classpath gradlePlugins.dexcount
}
Expand Down
8 changes: 6 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext.versions = [
code : 2245,
name : '1.216',
code : 2246,
name : '1.217',

minSdk : 21,
targetSdk : 30,
Expand Down Expand Up @@ -103,6 +103,7 @@ ext.versions = [
hamcrest : '2.1',
espresso : '3.1.0',
testCore : '1.1.1',
kaspresso : '1.4.1',

ktlint : '0.34.2',
ktlintRules : '1.0.0',
Expand Down Expand Up @@ -241,6 +242,9 @@ ext.libraries = [
espressoCore : "androidx.test.espresso:espresso-core:$versions.espresso",
espressoContrib : "androidx.test.espresso:espresso-contrib:$versions.espresso",
espressoIntents : "androidx.test.espresso:espresso-intents:$versions.espresso",
kaspresso : "com.kaspersky.android-components:kaspresso:$versions.kaspresso",
kaspressoAllure : "com.kaspersky.android-components:kaspresso-allure-support:$versions.kaspresso",


ktlint : "com.pinterest:ktlint:$versions.ktlint",
ktlintRules : "ru.nobird.android.ktlint:rules:$versions.ktlintRules",
Expand Down

0 comments on commit f14c043

Please sign in to comment.