Skip to content

Commit

Permalink
Merge branch 'develop' into kavyanshkhandelwal/oppia#5273/fix-unused-…
Browse files Browse the repository at this point in the history
…attribute-warning
  • Loading branch information
kavyanshkhandelwal authored Jan 22, 2025
2 parents 1a1527f + 68f20cb commit b3ecdf3
Show file tree
Hide file tree
Showing 53 changed files with 2,432 additions and 262 deletions.
26 changes: 13 additions & 13 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ android_sdk_repository(
build_tools_version = BUILD_TOOLS_VERSION,
)

# The rules_java contains the java_lite_proto_library rule used in the model module.
http_archive(
name = "rules_java",
sha256 = HTTP_DEPENDENCY_VERSIONS["rules_java"]["sha"],
url = "https://github.com/bazelbuild/rules_java/releases/download/{0}/rules_java-{0}.tar.gz".format(HTTP_DEPENDENCY_VERSIONS["rules_java"]["version"]),
)

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()

# Oppia's backend proto API definitions.
git_repository(
name = "oppia_proto_api",
Expand Down Expand Up @@ -75,19 +88,6 @@ bind(
actual = "//tools:java_toolchain",
)

# The rules_java contains the java_lite_proto_library rule used in the model module.
http_archive(
name = "rules_java",
sha256 = HTTP_DEPENDENCY_VERSIONS["rules_java"]["sha"],
url = "https://github.com/bazelbuild/rules_java/releases/download/{0}/rules_java-{0}.tar.gz".format(HTTP_DEPENDENCY_VERSIONS["rules_java"]["version"]),
)

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()

# The rules_proto contains the proto_library rule used in the model module.
http_archive(
name = "rules_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import org.oppia.android.domain.translation.TranslationController
import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import org.oppia.android.util.locale.OppiaLocale
import org.oppia.android.util.parser.html.ClassroomHtmlParserEntityType
import org.oppia.android.util.parser.html.StoryHtmlParserEntityType
import org.oppia.android.util.parser.html.TopicHtmlParserEntityType
import org.oppia.android.util.platformparameter.EnableOnboardingFlowV2
Expand All @@ -77,32 +78,33 @@ import javax.inject.Inject
const val CLASSROOM_LIST_SCREEN_TEST_TAG = "TEST_TAG.classroom_list_screen"

/** The presenter for [ClassroomListFragment]. */
class ClassroomListFragmentPresenter
@Inject
constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val profileManagementController: ProfileManagementController,
private val topicListController: TopicListController,
private val classroomController: ClassroomController,
private val oppiaLogger: OppiaLogger,
@TopicHtmlParserEntityType private val topicEntityType: String,
@StoryHtmlParserEntityType private val storyEntityType: String,
private val resourceHandler: AppLanguageResourceHandler,
private val dateTimeUtil: DateTimeUtil,
private val translationController: TranslationController,
private val machineLocale: OppiaLocale.MachineLocale,
private val analyticsController: AnalyticsController,
@EnableOnboardingFlowV2
private val enableOnboardingFlowV2: PlatformParameterValue<Boolean>,
private val appStartupStateController: AppStartupStateController,
) {
private val routeToTopicPlayStoryListener = activity as RouteToTopicPlayStoryListener
private val exitProfileListener = activity as ExitProfileListener
private lateinit var binding: ClassroomListFragmentBinding
private lateinit var classroomListViewModel: ClassroomListViewModel
private val profileId = activity.intent.extractCurrentUserProfileId()
private var onBackPressedCallback: OnBackPressedCallback? = null

class ClassroomListFragmentPresenter @Inject constructor(
private val activity: AppCompatActivity,
private val fragment: Fragment,
private val profileManagementController: ProfileManagementController,
private val topicListController: TopicListController,
private val classroomController: ClassroomController,
private val oppiaLogger: OppiaLogger,
@ClassroomHtmlParserEntityType private val classroomEntityType: String,
@TopicHtmlParserEntityType private val topicEntityType: String,
@StoryHtmlParserEntityType private val storyEntityType: String,
private val resourceHandler: AppLanguageResourceHandler,
private val dateTimeUtil: DateTimeUtil,
private val translationController: TranslationController,
private val machineLocale: OppiaLocale.MachineLocale,
private val analyticsController: AnalyticsController,
@EnableOnboardingFlowV2
private val enableOnboardingFlowV2: PlatformParameterValue<Boolean>,
private val appStartupStateController: AppStartupStateController
) {
private val routeToTopicPlayStoryListener = activity as RouteToTopicPlayStoryListener
private val exitProfileListener = activity as ExitProfileListener
private lateinit var binding: ClassroomListFragmentBinding
private lateinit var classroomListViewModel: ClassroomListViewModel
private val profileId = activity.intent.extractCurrentUserProfileId()
private var onBackPressedCallback: OnBackPressedCallback? = null


/** Creates and returns the view for the [ClassroomListFragment]. */
fun handleCreateView(
Expand All @@ -119,21 +121,23 @@ class ClassroomListFragmentPresenter

logHomeActivityEvent()

classroomListViewModel =
ClassroomListViewModel(
activity,
fragment,
oppiaLogger,
profileId,
profileManagementController,
topicListController,
classroomController,
topicEntityType,
storyEntityType,
resourceHandler,
dateTimeUtil,
translationController,
)

classroomListViewModel = ClassroomListViewModel(
activity,
fragment,
oppiaLogger,
profileId,
profileManagementController,
topicListController,
classroomController,
classroomEntityType,
topicEntityType,
storyEntityType,
resourceHandler,
dateTimeUtil,
translationController
)


classroomListViewModel.homeItemViewModelListLiveData.observe(activity) {
refreshComposeView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ import org.oppia.android.util.data.AsyncResult
import org.oppia.android.util.data.DataProvider
import org.oppia.android.util.data.DataProviders.Companion.combineWith
import org.oppia.android.util.data.DataProviders.Companion.toLiveData
import org.oppia.android.util.parser.html.StoryHtmlParserEntityType
import org.oppia.android.util.parser.html.TopicHtmlParserEntityType

private const val PROFILE_AND_PROMOTED_ACTIVITY_COMBINED_PROVIDER_ID =
"profile+promotedActivityList"
Expand All @@ -57,8 +55,9 @@ class ClassroomListViewModel(
private val profileManagementController: ProfileManagementController,
private val topicListController: TopicListController,
private val classroomController: ClassroomController,
@TopicHtmlParserEntityType private val topicEntityType: String,
@StoryHtmlParserEntityType private val storyEntityType: String,
private val classroomEntityType: String,
private val topicEntityType: String,
private val storyEntityType: String,
private val resourceHandler: AppLanguageResourceHandler,
private val dateTimeUtil: DateTimeUtil,
private val translationController: TranslationController,
Expand Down Expand Up @@ -271,7 +270,10 @@ class ClassroomListViewModel(
ClassroomSummaryViewModel(
fragment as ClassroomSummaryClickListener,
ephemeralClassroomSummary,
translationController,

classroomEntityType,
translationController

)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.oppia.android.app.classroom

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import org.oppia.android.app.customview.LessonThumbnailImageView
import org.oppia.android.app.model.LessonThumbnail

/**
* A composable function that displays a lesson thumbnail image using a custom Android view.
*
* This function integrates the [LessonThumbnailImageView] within a Compose layout, allowing it
* to render a lesson thumbnail image based on the provided parameters. The implementation
* currently relies on a traditional Android View approach due to compatibility issues with the
* Glide Compose library.
*
* @param entityId the unique identifier for the entity associated with the thumbnail
* @param entityType the type of the entity (e.g., classroom, topic, story)
* @param lessonThumbnail the [LessonThumbnail] containing metadata required to load the image
* @param modifier the [Modifier] to be applied to the layout, defaulting to [Modifier]
*/
@Composable
fun ThumbnailImage(
entityId: String,
entityType: String,
lessonThumbnail: LessonThumbnail?,
modifier: Modifier = Modifier,
) {
// TODO(#5422): Migrate to Jetpack Compose once the Glide Compose library becomes compatible.
AndroidView(
modifier = modifier.fillMaxSize(),
factory = { context ->
LessonThumbnailImageView(context).apply {
setLessonThumbnail(lessonThumbnail)
setEntityId(entityId)
setEntityType(entityType)
}
},
update = { view ->
view.setLessonThumbnail(lessonThumbnail)
view.setEntityId(entityId)
view.setEntityType(entityType)
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.oppia.android.app.classroom.classroomlist

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -23,14 +22,13 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.integerResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.oppia.android.R
import org.oppia.android.app.classroom.getDrawableResource
import org.oppia.android.app.classroom.ThumbnailImage
import org.oppia.android.app.home.classroomlist.ClassroomSummaryViewModel

/** Test tag for the classroom list. */
Expand Down Expand Up @@ -108,21 +106,16 @@ fun ClassroomCard(
horizontalAlignment = Alignment.CenterHorizontally,
) {
AnimatedVisibility(visible = !isSticky) {
Image(
painter =
painterResource(
id =
classroomSummaryViewModel
.classroomSummary
.classroomThumbnail
.getDrawableResource(),
),
contentDescription = classroomSummaryViewModel.title,
modifier =
Modifier
.testTag("${CLASSROOM_CARD_ICON_TEST_TAG}_${classroomSummaryViewModel.title}")
.padding(bottom = dimensionResource(id = R.dimen.classrooms_card_icon_padding_bottom))
.size(size = dimensionResource(id = R.dimen.classrooms_card_icon_size)),

ThumbnailImage(
entityId = classroomSummaryViewModel.classroomSummary.classroomId,
entityType = classroomSummaryViewModel.entityType,
lessonThumbnail = classroomSummaryViewModel.classroomSummary.classroomThumbnail,
modifier = Modifier
.testTag("${CLASSROOM_CARD_ICON_TEST_TAG}_${classroomSummaryViewModel.title}")
.padding(bottom = dimensionResource(id = R.dimen.classrooms_card_icon_padding_bottom))
.size(size = dimensionResource(id = R.dimen.classrooms_card_icon_size)),

)
}
Text(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.oppia.android.app.classroom.promotedlist

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -18,11 +17,9 @@ import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
Expand All @@ -31,7 +28,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.oppia.android.R
import org.oppia.android.app.classroom.getDrawableResource
import org.oppia.android.app.classroom.ThumbnailImage
import org.oppia.android.app.home.promotedlist.ComingSoonTopicListViewModel
import org.oppia.android.app.home.promotedlist.ComingSoonTopicsViewModel
import org.oppia.android.util.locale.OppiaLocale
Expand Down Expand Up @@ -106,27 +103,13 @@ fun ComingSoonTopicCard(
Column(
verticalArrangement = Arrangement.Center,
) {
Image(
painter =
painterResource(
id = comingSoonTopicsViewModel.topicSummary.lessonThumbnail.getDrawableResource(),
),
contentDescription =
"Picture of a " +
"${comingSoonTopicsViewModel.topicSummary.lessonThumbnail.thumbnailGraphic.name}.",
modifier =
Modifier
.aspectRatio(4f / 3f)
.background(
Color(
(
0xff000000L or
comingSoonTopicsViewModel
.topicSummary.lessonThumbnail.backgroundColorRgb
.toLong()
).toInt(),
),
),

ThumbnailImage(
entityId = comingSoonTopicsViewModel.topicSummary.topicId,
entityType = comingSoonTopicsViewModel.entityType,
lessonThumbnail = comingSoonTopicsViewModel.topicSummary.lessonThumbnail,
modifier = Modifier.aspectRatio(4f / 3f)

)
ComingSoonTopicCardTextSection(comingSoonTopicsViewModel)
}
Expand Down
Loading

0 comments on commit b3ecdf3

Please sign in to comment.