-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Introduced new SplashTestActivity to have an implementation of Compile Time PlatformParameter * Add PlatformParameterModule to all TestApplicationComponents + removing Target annotation from Qualifiers * Correcting Lint issues * KDoc Changes * KDoc changes + Refactoring functions * Nit comment related changes * Further KDoc changes * Rearrange Activity in Manifest * Changing function names in Presenter and coverted KDoc to comment * Reverted the Prod SplashActivityPresenter and made Second Test Case for PlatformParameterIntegrationTest is made to run on Espresso only
- Loading branch information
Showing
104 changed files
with
547 additions
and
62 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
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
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/oppia/android/app/testing/SplashTestActivity.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,27 @@ | ||
package org.oppia.android.app.testing | ||
|
||
import android.os.Bundle | ||
import org.oppia.android.app.activity.InjectableAppCompatActivity | ||
import org.oppia.android.app.splash.SplashActivity | ||
import org.oppia.android.util.platformparameter.PlatformParameterValue | ||
import javax.inject.Inject | ||
|
||
/** | ||
* A test activity to verify the injection of [PlatformParameterValue] in the [SplashActivity]. | ||
* This test activity is used in integration tests for platform parameters. | ||
*/ | ||
class SplashTestActivity : InjectableAppCompatActivity() { | ||
|
||
@Inject | ||
lateinit var splashTestActivityPresenter: SplashTestActivityPresenter | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
activityComponent.inject(this) | ||
splashTestActivityPresenter.handleOnCreate() | ||
} | ||
|
||
companion object { | ||
val WELCOME_MSG = "Welcome User" | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
app/src/main/java/org/oppia/android/app/testing/SplashTestActivityPresenter.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,56 @@ | ||
package org.oppia.android.app.testing | ||
|
||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.Observer | ||
import androidx.lifecycle.Transformations | ||
import org.oppia.android.R | ||
import org.oppia.android.app.activity.ActivityScope | ||
import org.oppia.android.domain.platformparameter.PlatformParameterController | ||
import org.oppia.android.util.data.AsyncResult | ||
import org.oppia.android.util.data.DataProviders.Companion.toLiveData | ||
import org.oppia.android.util.platformparameter.PlatformParameterValue | ||
import org.oppia.android.util.platformparameter.SplashScreenWelcomeMsg | ||
import javax.inject.Inject | ||
import javax.inject.Provider | ||
|
||
/** The presenter for [SplashTestActivity]. */ | ||
@ActivityScope | ||
class SplashTestActivityPresenter @Inject constructor( | ||
private val activity: AppCompatActivity, | ||
private val platformParameterController: PlatformParameterController, | ||
@SplashScreenWelcomeMsg | ||
private val splashScreenWelcomeMsgParam: Provider<PlatformParameterValue<Boolean>> | ||
) { | ||
fun handleOnCreate() { | ||
activity.setContentView(R.layout.splash_test_activity) | ||
loadPlatformParameters() | ||
} | ||
|
||
private fun loadPlatformParameters() { | ||
fetchPlatformParametersFromDatabase().observe( | ||
activity, | ||
Observer { | ||
showToastIfAllowed() | ||
} | ||
) | ||
} | ||
|
||
private fun fetchPlatformParametersFromDatabase(): LiveData<Boolean> { | ||
return Transformations.map( | ||
platformParameterController.getParameterDatabase().toLiveData(), | ||
::processPlatformParameters | ||
) | ||
} | ||
|
||
private fun processPlatformParameters(loadingStatus: AsyncResult<Unit>): Boolean { | ||
return loadingStatus.isSuccess() | ||
} | ||
|
||
private fun showToastIfAllowed() { | ||
if (splashScreenWelcomeMsgParam.get().value) { | ||
Toast.makeText(activity, SplashTestActivity.WELCOME_MSG, Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
} |
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/fragment_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".app.splash.SplashActivity" /> |
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
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
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
Oops, something went wrong.