Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/oppia/oppia-android into #…
Browse files Browse the repository at this point in the history
  • Loading branch information
XichengSpencer committed Feb 23, 2024
2 parents 0c1b62a + 67c7a92 commit 22040e2
Show file tree
Hide file tree
Showing 395 changed files with 9,378 additions and 3,250 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,20 @@
# All domain and utility-specific shared test infrastructure.
/testing/src/main/java/org/oppia/android/testing/FakeAnalyticsEventLogger.kt @oppia/android-app-infrastructure-reviewers
/testing/src/main/java/org/oppia/android/testing/FakeExceptionLogger.kt @oppia/android-app-infrastructure-reviewers
/testing/src/main/java/org/oppia/android/testing/FakeFirebaseAuthInstanceWrapperImpl.kt @oppia/android-app-infrastructure-reviewers
/testing/src/main/java/org/oppia/android/testing/FakeFirestoreEventLogger.kt @oppia/android-app-infrastructure-reviewers
/testing/src/main/java/org/oppia/android/testing/FakeFirestoreInstanceWrapperImpl.kt @oppia/android-app-infrastructure-reviewers
/testing/src/main/java/org/oppia/android/testing/FakePerformanceMetricAssessor.kt @oppia/android-app-infrastructure-reviewers
/testing/src/main/java/org/oppia/android/testing/FakePerformanceMetricsEventLogger.kt @oppia/android-app-infrastructure-reviewers
/testing/src/main/java/org/oppia/android/testing/TestImageLoaderModule.kt @oppia/android-app-infrastructure-reviewers
/testing/src/main/java/org/oppia/android/testing/TestLogReportingModule.kt @oppia/android-app-infrastructure-reviewers
/testing/src/test/java/org/oppia/android/testing/FakeAnalyticsEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers
/testing/src/test/java/org/oppia/android/testing/FakeExceptionLoggerTest.kt @oppia/android-app-infrastructure-reviewers
/testing/src/test/java/org/oppia/android/testing/FakeFirestoreEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers
/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricAssessorTest.kt @oppia/android-app-infrastructure-reviewers
/testing/src/test/java/org/oppia/android/testing/FakePerformanceMetricsEventLoggerTest.kt @oppia/android-app-infrastructure-reviewers

/testing/src/*/java/org/oppia/android/testing/firebase/ @oppia/android-app-infrastructure-reviewers
/testing/src/*/java/org/oppia/android/testing/lightweightcheckpointing/ @oppia/android-app-infrastructure-reviewers
/testing/src/*/java/org/oppia/android/testing/logging/ @oppia/android-app-infrastructure-reviewers
/testing/src/*/java/org/oppia/android/testing/math/ @oppia/android-app-infrastructure-reviewers
Expand Down
13 changes: 12 additions & 1 deletion app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ kt_android_library(
"//third_party:androidx_databinding_databinding-runtime",
"//utility",
"//utility/src/main/java/org/oppia/android/util/extensions:context_extensions",
"//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_event_logger",
"//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module",
"//utility/src/main/java/org/oppia/android/util/math:fraction_parser",
"//utility/src/main/java/org/oppia/android/util/networking:network_connection_debug_util",
"//utility/src/main/java/org/oppia/android/util/parser/html:html_parser",
Expand Down Expand Up @@ -1018,4 +1018,15 @@ android_library(
],
)

android_library(
name = "firestore_deps",
exports = [
"//third_party:com_google_auto_value_auto-value-annotations",
"//third_party:com_google_firebase_firebase-appcheck",
"//third_party:com_google_firebase_firebase-appcheck-debug",
"//third_party:com_google_firebase_firebase-appcheck-playintegrity",
"//third_party:org_checkerframework_checker-qual",
],
)

dagger_rules()
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,13 @@ dependencies {
'com.google.dagger:dagger:2.24',
'com.google.firebase:firebase-analytics:17.5.0',
'com.google.firebase:firebase-analytics-ktx:17.5.0',
'com.google.firebase:firebase-appcheck:16.0.0',
'com.google.firebase:firebase-appcheck-debug:16.0.0',
'com.google.firebase:firebase-appcheck-playintegrity:16.0.0',
'com.google.firebase:firebase-core:17.5.0',
'com.google.firebase:firebase-crashlytics:17.0.0',
'com.google.firebase:firebase-firestore-ktx:24.2.1',
'com.google.firebase:firebase-auth-ktx:19.3.1',
'com.google.guava:guava:28.1-android',
'com.google.protobuf:protobuf-javalite:3.17.3',
'com.github.oppia:CircularImageview:35d08ba88a',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import androidx.lifecycle.ViewModel
import org.oppia.android.R
import org.oppia.android.app.fragment.FragmentScope
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.utility.getLastUpdateTime
import org.oppia.android.app.utility.getVersionName
import org.oppia.android.app.viewmodel.ObservableViewModel
import org.oppia.android.util.extensions.getLastUpdateTime
import org.oppia.android.util.extensions.getVersionName
import javax.inject.Inject

/** [ViewModel] for [AppVersionFragment]. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ import androidx.multidex.MultiDexApplication
import androidx.work.Configuration
import androidx.work.WorkManager
import com.google.firebase.FirebaseApp
import com.google.firebase.appcheck.FirebaseAppCheck
import com.google.firebase.appcheck.debug.DebugAppCheckProviderFactory
import com.google.firebase.appcheck.playintegrity.PlayIntegrityAppCheckProviderFactory
import org.oppia.android.app.activity.ActivityComponent
import org.oppia.android.app.activity.ActivityComponentFactory
import org.oppia.android.app.model.BuildFlavor
import org.oppia.android.domain.oppialogger.ApplicationStartupListener

/** The root base [Application] of the Oppia app. */
Expand Down Expand Up @@ -47,6 +51,20 @@ abstract class AbstractOppiaApplication(
// TODO(#4751): Re-enable WorkManager for S+.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
FirebaseApp.initializeApp(applicationContext)
// FirebaseAppCheck protects our API resources from abuse. It works with Firebase services,
// Google Cloud services, and can also be implemented for our own APIs.
// See https://firebase.google.com/docs/app-check for currently supported Firebase products.
// Note that as of this code being checked in, only the app's Firestore usage is affected by
// App Check (Analytics is NOT affected).
if (component.getCurrentBuildFlavor() == BuildFlavor.DEVELOPER) {
FirebaseAppCheck.getInstance().installAppCheckProviderFactory(
DebugAppCheckProviderFactory.getInstance(),
)
} else {
FirebaseAppCheck.getInstance().installAppCheckProviderFactory(
PlayIntegrityAppCheckProviderFactory.getInstance(),
)
}
WorkManager.initialize(applicationContext, workManagerConfiguration)
val workManager = WorkManager.getInstance(applicationContext)
component.getAnalyticsStartupListenerStartupListeners().forEach { it.onCreate(workManager) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Application
import androidx.work.Configuration
import dagger.BindsInstance
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.model.BuildFlavor
import org.oppia.android.domain.oppialogger.ApplicationStartupListener
import org.oppia.android.domain.oppialogger.analytics.AnalyticsStartupListener
import javax.inject.Provider
Expand All @@ -30,4 +31,6 @@ interface ApplicationComponent : ApplicationInjector {
fun getAnalyticsStartupListenerStartupListeners(): Set<AnalyticsStartupListener>

fun getWorkManagerConfiguration(): Configuration

fun getCurrentBuildFlavor(): BuildFlavor
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.oppia.android.app.shim.ViewBindingShimModule
import org.oppia.android.app.translation.ActivityRecreatorProdModule
import org.oppia.android.data.backends.gae.NetworkConfigProdModule
import org.oppia.android.data.backends.gae.NetworkModule
import org.oppia.android.domain.auth.AuthenticationModule
import org.oppia.android.domain.classify.InteractionsModule
import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule
import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule
Expand Down Expand Up @@ -99,6 +100,7 @@ import javax.inject.Singleton
PerformanceMetricsConfigurationsModule::class, AlphaBuildFlavorModule::class,
EventLoggingConfigurationModule::class, CpuPerformanceSnapshotterModule::class,
PerformanceMetricsAssessorModule::class, ExplorationProgressModule::class,
AuthenticationModule::class,
]
)
interface AlphaApplicationComponent : ApplicationComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ kt_android_library(
"//app/src/main/java/org/oppia/android/app/application:abstract_application",
"//app/src/main/java/org/oppia/android/app/application:application_component",
"//app/src/main/java/org/oppia/android/app/application:common_application_modules",
"//domain/src/main/java/org/oppia/android/domain/auth:auth_module",
"//utility/src/main/java/org/oppia/android/util/logging:standard_event_logging_configuration_module",
"//utility/src/main/java/org/oppia/android/util/logging/firebase:prod_module",
"//utility/src/main/java/org/oppia/android/util/networking:prod_module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.oppia.android.app.shim.ViewBindingShimModule
import org.oppia.android.app.translation.ActivityRecreatorProdModule
import org.oppia.android.data.backends.gae.NetworkConfigProdModule
import org.oppia.android.data.backends.gae.NetworkModule
import org.oppia.android.domain.auth.AuthenticationModule
import org.oppia.android.domain.classify.InteractionsModule
import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule
import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule
Expand Down Expand Up @@ -100,6 +101,7 @@ import javax.inject.Singleton
PerformanceMetricsConfigurationsModule::class, AlphaBuildFlavorModule::class,
KenyaAlphaEventLoggingConfigurationModule::class, CpuPerformanceSnapshotterModule::class,
PerformanceMetricsAssessorModule::class, ExplorationProgressModule::class,
AuthenticationModule::class,
]
)
interface AlphaKenyaApplicationComponent : ApplicationComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ kt_android_library(
"//app/src/main/java/org/oppia/android/app/application:application_component",
"//app/src/main/java/org/oppia/android/app/application:common_application_modules",
"//app/src/main/java/org/oppia/android/app/application/alpha:alpha_build_flavor_module",
"//domain/src/main/java/org/oppia/android/domain/auth:auth_module",
"//utility/src/main/java/org/oppia/android/util/logging:kenya_alpha_event_logging_configuration_module",
"//utility/src/main/java/org/oppia/android/util/logging/firebase:prod_module",
"//utility/src/main/java/org/oppia/android/util/networking:prod_module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ kt_android_library(
"//app/src/main/java/org/oppia/android/app/application:abstract_application",
"//app/src/main/java/org/oppia/android/app/application:application_component",
"//app/src/main/java/org/oppia/android/app/application:common_application_modules",
"//domain/src/main/java/org/oppia/android/domain/auth:auth_module",
"//utility/src/main/java/org/oppia/android/util/logging:standard_event_logging_configuration_module",
"//utility/src/main/java/org/oppia/android/util/logging/firebase:prod_module",
"//utility/src/main/java/org/oppia/android/util/networking:prod_module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.oppia.android.app.shim.ViewBindingShimModule
import org.oppia.android.app.translation.ActivityRecreatorProdModule
import org.oppia.android.data.backends.gae.NetworkConfigProdModule
import org.oppia.android.data.backends.gae.NetworkModule
import org.oppia.android.domain.auth.AuthenticationModule
import org.oppia.android.domain.classify.InteractionsModule
import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule
import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule
Expand Down Expand Up @@ -99,7 +100,7 @@ import javax.inject.Singleton
PerformanceMetricsConfigurationsModule::class, BetaBuildFlavorModule::class,
EventLoggingConfigurationModule::class, ActivityRouterModule::class,
CpuPerformanceSnapshotterModule::class, PerformanceMetricsAssessorModule::class,
ExplorationProgressModule::class,
ExplorationProgressModule::class, AuthenticationModule::class,
]
)
interface BetaApplicationComponent : ApplicationComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ kt_android_library(
"//app/src/main/java/org/oppia/android/app/application:abstract_application",
"//app/src/main/java/org/oppia/android/app/application:application_component",
"//app/src/main/java/org/oppia/android/app/application:common_application_modules",
"//domain/src/main/java/org/oppia/android/domain/auth:auth_module",
"//utility/src/main/java/org/oppia/android/util/logging:standard_event_logging_configuration_module",
"//utility/src/main/java/org/oppia/android/util/logging/firebase:debug_module",
"//utility/src/main/java/org/oppia/android/util/networking:debug_module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.oppia.android.app.shim.ViewBindingShimModule
import org.oppia.android.app.translation.ActivityRecreatorProdModule
import org.oppia.android.data.backends.gae.NetworkConfigProdModule
import org.oppia.android.data.backends.gae.NetworkModule
import org.oppia.android.domain.auth.AuthenticationModule
import org.oppia.android.domain.classify.InteractionsModule
import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule
import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule
Expand Down Expand Up @@ -101,6 +102,7 @@ import javax.inject.Singleton
PerformanceMetricsAssessorModule::class, PerformanceMetricsConfigurationsModule::class,
DeveloperBuildFlavorModule::class, EventLoggingConfigurationModule::class,
CpuPerformanceSnapshotterModule::class, ExplorationProgressModule::class,
AuthenticationModule::class,
]
)
interface DeveloperApplicationComponent : ApplicationComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ kt_android_library(
"//app/src/main/java/org/oppia/android/app/application:abstract_application",
"//app/src/main/java/org/oppia/android/app/application:application_component",
"//app/src/main/java/org/oppia/android/app/application:common_application_modules",
"//domain/src/main/java/org/oppia/android/domain/auth:auth_module",
"//utility/src/main/java/org/oppia/android/util/logging:standard_event_logging_configuration_module",
"//utility/src/main/java/org/oppia/android/util/logging/firebase:prod_module",
"//utility/src/main/java/org/oppia/android/util/networking:prod_module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.oppia.android.app.shim.ViewBindingShimModule
import org.oppia.android.app.translation.ActivityRecreatorProdModule
import org.oppia.android.data.backends.gae.NetworkConfigProdModule
import org.oppia.android.data.backends.gae.NetworkModule
import org.oppia.android.domain.auth.AuthenticationModule
import org.oppia.android.domain.classify.InteractionsModule
import org.oppia.android.domain.classify.rules.algebraicexpressioninput.AlgebraicExpressionInputModule
import org.oppia.android.domain.classify.rules.continueinteraction.ContinueModule
Expand Down Expand Up @@ -99,7 +100,7 @@ import javax.inject.Singleton
PerformanceMetricsConfigurationsModule::class, GaBuildFlavorModule::class,
EventLoggingConfigurationModule::class, ActivityRouterModule::class,
CpuPerformanceSnapshotterModule::class, PerformanceMetricsAssessorModule::class,
ExplorationProgressModule::class,
ExplorationProgressModule::class, AuthenticationModule::class,
]
)
interface GaApplicationComponent : ApplicationComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import org.oppia.android.app.utility.KeyboardHelper.Companion.showSoftKeyboard
// background="@drawable/edit_text_background"
// maxLength="200".

// TODO(#4135): Add a dedicated test suite for this class.

/** The custom EditText class for fraction input interaction view. */
class FractionInputInteractionView @JvmOverloads constructor(
context: Context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.app.viewmodel.ObservableViewModel
import org.oppia.android.util.locale.OppiaLocale
import org.oppia.android.util.logging.firebase.DebugAnalyticsEventLogger
import org.oppia.android.util.logging.firebase.DebugFirestoreEventLoggerImpl
import javax.inject.Inject

/**
Expand All @@ -14,11 +15,15 @@ import javax.inject.Inject
@FragmentScope
class ViewEventLogsViewModel @Inject constructor(
debugAnalyticsEventLogger: DebugAnalyticsEventLogger,
debugFirestoreEventLogger: DebugFirestoreEventLoggerImpl,
private val machineLocale: OppiaLocale.MachineLocale,
private val resourceHandler: AppLanguageResourceHandler
) : ObservableViewModel() {
// Retrieves events from cache that are meant to be uploaded to Firebase Firestore.
private val firestoreEvents = debugFirestoreEventLogger.getEventList()

private val eventList = debugAnalyticsEventLogger.getEventList()
// Retrieves events from cache that are meant to be uploaded to Firebase Analytics.
private val analyticsEvents = debugAnalyticsEventLogger.getEventList()

/**
* List of [EventLogItemViewModel] used to populate recyclerview of [ViewEventLogsFragment]
Expand All @@ -29,8 +34,10 @@ class ViewEventLogsViewModel @Inject constructor(
}

private fun processEventLogsList(): List<EventLogItemViewModel> {
return eventList.map {
EventLogItemViewModel(it, machineLocale, resourceHandler)
}.reversed()
return (analyticsEvents + firestoreEvents)
.map {
EventLogItemViewModel(it, machineLocale, resourceHandler)
}
.sortedByDescending { it.eventLog.timestamp }
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
package org.oppia.android.app.notice

import org.oppia.android.app.splash.DeprecationNoticeActionType
import org.oppia.android.app.model.DeprecationNoticeType

/** Listener for when an option on any deprecation dialog is clicked. */
interface DeprecationNoticeActionListener {
/** Called when a dialog button is clicked. */
fun onActionButtonClicked(noticeType: DeprecationNoticeActionType)
fun onActionButtonClicked(noticeActionResponse: DeprecationNoticeActionResponse)
}

/** Sealed data class for the response to a deprecation notice action. */
sealed class DeprecationNoticeActionResponse {
/** Action for when the user presses the 'Close' button on a deprecation dialog. */
object Close : DeprecationNoticeActionResponse()

/** Action for when the user presses the 'Dismiss' button on a deprecation dialog. */
data class Dismiss(
val deprecationNoticeType: DeprecationNoticeType,
val deprecatedVersion: Int,
) : DeprecationNoticeActionResponse()

/** Action for when the user presses the 'Update' button on a deprecation dialog. */
object Update : DeprecationNoticeActionResponse()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import android.app.Dialog
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import org.oppia.android.R
import org.oppia.android.app.splash.DeprecationNoticeActionType
import org.oppia.android.app.translation.AppLanguageResourceHandler
import javax.inject.Inject

/** Presenter class responsible for showing an app deprecation dialog to the user. */
class ForcedAppDeprecationNoticeDialogFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val resourceHandler: AppLanguageResourceHandler
private val resourceHandler: AppLanguageResourceHandler,
) {
private val deprecationNoticeActionListener by lazy {
activity as DeprecationNoticeActionListener
Expand All @@ -31,12 +30,12 @@ class ForcedAppDeprecationNoticeDialogFragmentPresenter @Inject constructor(
)
.setPositiveButton(R.string.forced_app_update_dialog_update_button_text) { _, _ ->
deprecationNoticeActionListener.onActionButtonClicked(
DeprecationNoticeActionType.UPDATE
DeprecationNoticeActionResponse.Update
)
}
.setNegativeButton(R.string.forced_app_update_dialog_close_button_text) { _, _ ->
deprecationNoticeActionListener.onActionButtonClicked(
DeprecationNoticeActionType.CLOSE
DeprecationNoticeActionResponse.Close
)
}
.setCancelable(false)
Expand Down
Loading

0 comments on commit 22040e2

Please sign in to comment.