-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into selection-state-retain
- Loading branch information
Showing
193 changed files
with
15,519 additions
and
793 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ bazel-* | |
.bazelproject | ||
.aswb | ||
*.pb | ||
coverage_reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
) | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/org/oppia/android/app/classroom/ClassroomListActivityPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? | ||
} | ||
} |
Oops, something went wrong.