Skip to content

Commit

Permalink
Merge branch 'develop' into selection-state-retain
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwajith-Shettigar authored Jul 11, 2024
2 parents 4a84e3d + 1c4b17a commit 4aa6f3d
Show file tree
Hide file tree
Showing 193 changed files with 15,519 additions and 793 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ bazel-*
.bazelproject
.aswb
*.pb
coverage_reports
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ package_group(
{
"flavor": "oppia_kitkat",
"main_dex_list": "//:config/kitkat_main_dex_class_list.txt",
"min_sdk_version": 19,
"min_sdk_version": 21,
"multidex": "manual_main_dex",
"target_sdk_version": 33,
},
Expand Down
19 changes: 17 additions & 2 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ VIEW_MODELS_WITH_RESOURCE_IMPORTS = [
"src/main/java/org/oppia/android/app/home/recentlyplayed/PromotedStoryViewModel.kt",
"src/main/java/org/oppia/android/app/home/recentlyplayed/RecentlyPlayedViewModel.kt",
"src/main/java/org/oppia/android/app/home/topiclist/TopicSummaryViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/CreateProfileViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/OnboadingSlideViewModel.kt",
"src/main/java/org/oppia/android/app/onboarding/OnboardingViewModel.kt",
"src/main/java/org/oppia/android/app/ongoingtopiclist/OngoingTopicItemViewModel.kt",
Expand Down Expand Up @@ -602,6 +603,7 @@ android_library(
"//model/src/main/proto:thumbnail_java_proto_lite",
"//model/src/main/proto:version_java_proto_lite",
"//third_party:androidx_annotation_annotation",
"//third_party:androidx_compose_ui_ui",
"//third_party:androidx_constraintlayout_constraintlayout",
"//third_party:androidx_core_core",
"//third_party:androidx_databinding_databinding-adapters",
Expand Down Expand Up @@ -763,6 +765,7 @@ kt_android_library(
custom_package = "org.oppia.android.app.ui",
enable_data_binding = 1,
manifest = "src/main/AppAndroidManifest.xml",
plugins = ["//tools/kotlin:jetpack_compose_compiler_plugin"],
visibility = ["//visibility:public"],
deps = [
":binding_adapters",
Expand All @@ -787,6 +790,15 @@ kt_android_library(
"//domain/src/main/java/org/oppia/android/domain/survey:gating_controller",
"//domain/src/main/java/org/oppia/android/domain/survey:survey_controller",
"//model/src/main/proto:arguments_java_proto_lite",
"//third_party:androidx_activity_activity-compose",
"//third_party:androidx_annotation_annotation",
"//third_party:androidx_appcompat_appcompat",
"//third_party:androidx_compose_foundation_foundation",
"//third_party:androidx_compose_foundation_foundation-layout",
"//third_party:androidx_compose_material_material",
"//third_party:androidx_compose_runtime_runtime",
"//third_party:androidx_compose_ui_ui",
"//third_party:androidx_core_core-ktx",
"//third_party:androidx_databinding_databinding-adapters",
"//third_party:androidx_databinding_databinding-common",
"//third_party:androidx_databinding_databinding-runtime",
Expand All @@ -800,6 +812,7 @@ kt_android_library(
"//third_party:com_github_takusemba_spotlight",
"//third_party:com_google_android_flexbox_flexbox",
"//third_party:javax_annotation_javax_annotation-api_jar",
"//third_party:org_jetbrains_kotlin_kotlin-stdlib-jdk8_jar",
"//utility",
"//utility/src/main/java/org/oppia/android/util/extensions:bundle_extensions",
"//utility/src/main/java/org/oppia/android/util/parser/image:image_loader",
Expand Down Expand Up @@ -831,6 +844,7 @@ kt_android_library(
"src/sharedTest/java/org/oppia/android/app/utility/FontSizeMatcher.kt",
"src/sharedTest/java/org/oppia/android/app/utility/OrientationChangeAction.kt",
"src/sharedTest/java/org/oppia/android/app/utility/ProgressMatcher.kt",
"src/sharedTest/java/org/oppia/android/app/utility/ProtoExtraMatcher.kt",
"src/sharedTest/java/org/oppia/android/app/utility/TabMatcher.kt",
],
visibility = [
Expand Down Expand Up @@ -898,6 +912,7 @@ TEST_DEPS = [
"//testing/src/main/java/org/oppia/android/testing/threading:test_module",
"//testing/src/main/java/org/oppia/android/testing/time:test_module",
"//third_party:androidx_annotation_annotation",
"//third_party:androidx_compose_ui_ui-test-junit4",
"//third_party:androidx_core_core",
"//third_party:androidx_databinding_databinding-adapters",
"//third_party:androidx_databinding_databinding-common",
Expand Down Expand Up @@ -956,7 +971,7 @@ MIGRATED_TESTS = [
filtered_tests = MIGRATED_TESTS,
manifest_values = {
"applicationId": "org.oppia.android",
"minSdkVersion": "19",
"minSdkVersion": "21",
"targetSdkVersion": "30",
"versionCode": "0",
"versionName": "0.1-alpha",
Expand All @@ -972,7 +987,7 @@ MIGRATED_TESTS = [
filtered_tests = MIGRATED_TESTS,
manifest_values = {
"applicationId": "org.oppia.android",
"minSdkVersion": "19",
"minSdkVersion": "21",
"targetSdkVersion": "30",
"versionCode": "0",
"versionName": "0.1-alpha",
Expand Down
23 changes: 21 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 33
buildToolsVersion "29.0.2"
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "org.oppia.android"
minSdkVersion 19
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
Expand All @@ -30,6 +30,15 @@ android {
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
useIR = true
freeCompilerArgs += ["-opt-in=kotlin.RequiresOptIn"]
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion kotlin_version
}
buildTypes {
release {
Expand Down Expand Up @@ -147,6 +156,13 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(
'androidx.appcompat:appcompat:1.0.2',
"androidx.compose.foundation:foundation:$compose_version",
"androidx.compose.foundation:foundation-layout:$compose_version",
"androidx.compose.material:material:$compose_version",
"androidx.compose.runtime:runtime:$compose_version",
"androidx.compose.runtime:runtime-livedata:$compose_version",
"androidx.compose.ui:ui:$compose_version",
"androidx.compose.ui:ui-tooling:$compose_version",
'androidx.constraintlayout:constraintlayout:1.1.3',
'androidx.core:core-ktx:1.0.2',
'androidx.legacy:legacy-support-v4:1.0.0',
Expand All @@ -164,6 +180,7 @@ dependencies {
'com.github.bumptech.glide:glide:4.11.0',
'com.google.android.flexbox:flexbox:3.0.0',
'com.google.android.material:material:1.3.0',
"com.google.android.material:compose-theme-adapter:$compose_version",
'com.google.dagger:dagger:2.41',
'com.google.firebase:firebase-analytics:17.5.0',
'com.google.firebase:firebase-analytics-ktx:17.5.0',
Expand All @@ -189,6 +206,7 @@ dependencies {
'org.glassfish.jaxb:jaxb-runtime:2.3.2',
)
testImplementation(
"androidx.compose.ui:ui-test-junit4:$compose_version",
'androidx.test:core:1.2.0',
'androidx.test.espresso:espresso-contrib:3.1.0',
'androidx.test.espresso:espresso-core:3.2.0',
Expand All @@ -207,6 +225,7 @@ dependencies {
project(":testing"),
)
androidTestImplementation(
"androidx.compose.ui:ui-test-junit4:$compose_version",
'androidx.test:core:1.2.0',
'androidx.test.espresso:espresso-contrib:3.1.0',
'androidx.test.espresso:espresso-core:3.2.0',
Expand Down
21 changes: 20 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,30 @@
<activity
android:name=".app.testing.ColorBindingAdaptersTestActivity"
android:theme="@style/OppiaThemeWithoutActionBar" />

<activity
android:name=".app.classroom.ClassroomListActivity"
android:label="@string/classroom_list_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.onboarding.OnboardingProfileTypeActivity"
android:label="@string/onboarding_profile_type_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.onboarding.CreateProfileActivity"
android:label="@string/create_profile_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<activity
android:name=".app.onboarding.IntroActivity"
android:label="@string/onboarding_learner_intro_activity_title"
android:theme="@style/OppiaThemeWithoutActionBar" />
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
android:exported="false"
tools:node="remove" />
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dagger.Subcomponent
import org.oppia.android.app.administratorcontrols.AdministratorControlsActivity
import org.oppia.android.app.administratorcontrols.appversion.AppVersionActivity
import org.oppia.android.app.administratorcontrols.learneranalytics.ProfileAndDeviceIdActivity
import org.oppia.android.app.classroom.ClassroomListActivity
import org.oppia.android.app.completedstorylist.CompletedStoryListActivity
import org.oppia.android.app.devoptions.DeveloperOptionsActivity
import org.oppia.android.app.devoptions.forcenetworktype.ForceNetworkTypeActivity
Expand All @@ -31,7 +32,10 @@ import org.oppia.android.app.help.thirdparty.ThirdPartyDependencyListActivity
import org.oppia.android.app.home.HomeActivity
import org.oppia.android.app.home.recentlyplayed.RecentlyPlayedActivity
import org.oppia.android.app.mydownloads.MyDownloadsActivity
import org.oppia.android.app.onboarding.CreateProfileActivity
import org.oppia.android.app.onboarding.IntroActivity
import org.oppia.android.app.onboarding.OnboardingActivity
import org.oppia.android.app.onboarding.OnboardingProfileTypeActivity
import org.oppia.android.app.ongoingtopiclist.OngoingTopicListActivity
import org.oppia.android.app.options.AppLanguageActivity
import org.oppia.android.app.options.AudioLanguageActivity
Expand Down Expand Up @@ -218,4 +222,8 @@ interface ActivityComponentImpl :
fun inject(walkthroughActivity: WalkthroughActivity)
fun inject(surveyActivity: SurveyActivity)
fun inject(colorBindingAdaptersTestActivity: ColorBindingAdaptersTestActivity)
fun inject(classroomListActivity: ClassroomListActivity)
fun inject(onboardingProfileTypeActivity: OnboardingProfileTypeActivity)
fun inject(createProfileActivity: CreateProfileActivity)
fun inject(introActivity: IntroActivity)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package org.oppia.android.app.classroom

import android.content.Context
import android.content.Intent
import android.os.Bundle
import org.oppia.android.R
import org.oppia.android.app.activity.ActivityComponentImpl
import org.oppia.android.app.activity.InjectableAutoLocalizedAppCompatActivity
import org.oppia.android.app.activity.route.ActivityRouter
import org.oppia.android.app.drawer.ExitProfileDialogFragment
import org.oppia.android.app.drawer.TAG_SWITCH_PROFILE_DIALOG
import org.oppia.android.app.home.RouteToRecentlyPlayedListener
import org.oppia.android.app.home.RouteToTopicListener
import org.oppia.android.app.home.RouteToTopicPlayStoryListener
import org.oppia.android.app.model.DestinationScreen
import org.oppia.android.app.model.ExitProfileDialogArguments
import org.oppia.android.app.model.HighlightItem
import org.oppia.android.app.model.ProfileId
import org.oppia.android.app.model.RecentlyPlayedActivityParams
import org.oppia.android.app.model.RecentlyPlayedActivityTitle
import org.oppia.android.app.model.ScreenName.CLASSROOM_LIST_ACTIVITY
import org.oppia.android.app.topic.TopicActivity
import org.oppia.android.app.translation.AppLanguageResourceHandler
import org.oppia.android.util.logging.CurrentAppScreenNameIntentDecorator.decorateWithScreenName
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.decorateWithUserProfileId
import org.oppia.android.util.profile.CurrentUserProfileIdIntentDecorator.extractCurrentUserProfileId
import javax.inject.Inject

/** The activity for displaying [ClassroomListFragment]. */
class ClassroomListActivity :
InjectableAutoLocalizedAppCompatActivity(),
RouteToTopicListener,
RouteToTopicPlayStoryListener,
RouteToRecentlyPlayedListener {
@Inject
lateinit var classroomListActivityPresenter: ClassroomListActivityPresenter

@Inject
lateinit var resourceHandler: AppLanguageResourceHandler

@Inject
lateinit var activityRouter: ActivityRouter

private var internalProfileId: Int = -1

companion object {
/** Returns a new [Intent] to route to [ClassroomListActivity] for a specified [profileId]. */
fun createClassroomListActivity(context: Context, profileId: ProfileId?): Intent {
return Intent(context, ClassroomListActivity::class.java).apply {
decorateWithScreenName(CLASSROOM_LIST_ACTIVITY)
profileId?.let { decorateWithUserProfileId(profileId) }
}
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
(activityComponent as ActivityComponentImpl).inject(this)

internalProfileId = intent.extractCurrentUserProfileId().internalId
classroomListActivityPresenter.handleOnCreate()
title = resourceHandler.getStringInLocale(R.string.classroom_list_activity_title)
}

override fun onRestart() {
super.onRestart()
classroomListActivityPresenter.handleOnRestart()
}

override fun onBackPressed() {
val previousFragment =
supportFragmentManager.findFragmentByTag(TAG_SWITCH_PROFILE_DIALOG)
if (previousFragment != null) {
supportFragmentManager.beginTransaction().remove(previousFragment).commitNow()
}
val exitProfileDialogArguments =
ExitProfileDialogArguments
.newBuilder()
.setHighlightItem(HighlightItem.NONE)
.build()
val dialogFragment = ExitProfileDialogFragment
.newInstance(exitProfileDialogArguments = exitProfileDialogArguments)
dialogFragment.showNow(supportFragmentManager, TAG_SWITCH_PROFILE_DIALOG)
}

override fun routeToRecentlyPlayed(recentlyPlayedActivityTitle: RecentlyPlayedActivityTitle) {
val recentlyPlayedActivityParams =
RecentlyPlayedActivityParams
.newBuilder()
.setProfileId(ProfileId.newBuilder().setInternalId(internalProfileId).build())
.setActivityTitle(recentlyPlayedActivityTitle).build()

activityRouter.routeToScreen(
DestinationScreen
.newBuilder()
.setRecentlyPlayedActivityParams(recentlyPlayedActivityParams)
.build()
)
}

override fun routeToTopic(internalProfileId: Int, topicId: String) {
startActivity(TopicActivity.createTopicActivityIntent(this, internalProfileId, topicId))
}

override fun routeToTopicPlayStory(internalProfileId: Int, topicId: String, storyId: String) {
startActivity(
TopicActivity.createTopicPlayStoryActivityIntent(
this,
internalProfileId,
topicId,
storyId
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.oppia.android.app.classroom

import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.drawerlayout.widget.DrawerLayout
import org.oppia.android.R
import org.oppia.android.app.drawer.NavigationDrawerFragment
import javax.inject.Inject

/** Tag for identifying the [ClassroomListFragment] in transactions. */
private const val TAG_CLASSROOM_LIST_FRAGMENT = "CLASSROOM_LIST_FRAGMENT"

/** The presenter for [ClassroomListActivity]. */
class ClassroomListActivityPresenter @Inject constructor(private val activity: AppCompatActivity) {
private var navigationDrawerFragment: NavigationDrawerFragment? = null

/**
* Handles the creation of the activity. Sets the content view, sets up the navigation drawer,
* and adds the [ClassroomListFragment] if it's not already added.
*/
fun handleOnCreate() {
activity.setContentView(R.layout.classroom_list_activity)
setUpNavigationDrawer()
if (getClassroomListFragment() == null) {
activity.supportFragmentManager.beginTransaction().add(
R.id.classroom_list_fragment_placeholder,
ClassroomListFragment(),
TAG_CLASSROOM_LIST_FRAGMENT
).commitNow()
}
}

/** Handles the activity restart. Re-initializes the navigation drawer. */
fun handleOnRestart() {
setUpNavigationDrawer()
}

private fun setUpNavigationDrawer() {
val toolbar = activity.findViewById<View>(R.id.classroom_list_activity_toolbar) as Toolbar
activity.setSupportActionBar(toolbar)
activity.supportActionBar!!.setDisplayShowHomeEnabled(true)
navigationDrawerFragment = activity
.supportFragmentManager
.findFragmentById(
R.id.classroom_list_activity_fragment_navigation_drawer
) as NavigationDrawerFragment
navigationDrawerFragment!!.setUpDrawer(
activity.findViewById<View>(R.id.classroom_list_activity_drawer_layout) as DrawerLayout,
toolbar, R.id.nav_home
)
}

private fun getClassroomListFragment(): ClassroomListFragment? {
return activity.supportFragmentManager.findFragmentById(
R.id.classroom_list_fragment_placeholder
) as ClassroomListFragment?
}
}
Loading

0 comments on commit 4aa6f3d

Please sign in to comment.