Skip to content

Commit

Permalink
Fix #11: Introduce Oppia splash screen. (#60)
Browse files Browse the repository at this point in the history
* created splash screen

* changed splash image

* added fade transition

* handle configuration changes

* created background for splashtheme

This is to avoid black or white screen when app is launched and resources are not yet initialized

* implemented Logging system

- Used hyperLog library to store app logs in local file.
- Logger class is used to log files in entire application
- OppiaApplication class is created to initialize hyperlog

* fixed issues

* Update misc.xml

* Fixed issues

- Removed unwanted spaces
- Removed wait time during transition
- Added Javadoc comment
- created background image for splashActivity and it is set to theme.
- Added animation to SplashTheme styles.

* working on test cases

* resoilved conflicts

* Update styles.xml

* fixed java doc comments

* Update activity_splash.xml

Changed to framelayout

* Fixed issues

* uncommented some code

* fixed .idea file

* writting unit test

* Workinh on writting testcase for fragment

* Fixing issue with test case

* uncommented code

* Fixed spacing, rename layout files

* working on test case

* issue in passing test case

* Update SplashFragment.kt

* Update SplashFragment.kt

* working on testcase

* integrated testcase

* Delete kotlinc.xml

* Update build.gradle

* Update AndroidManifest.xml

* fixed issues

* Fixed testcases

* removed unused imports

* added comma for dependency

* fixed minor issues

* added javadoc comments for activitytestrule

* removed blank spaces

* removed splashFragment as its not used anywhere

* Delete splash_fragment.xml

* deleted bg_splash

* Update build.gradle

* removed blank spaces

* Update SplashActivityTest.kt

* Update SplashActivityTest.kt

* Delete AndroidManifest.xml

* Update styles.xml

* Update SplashActivityTest.kt

* Delete output.json

* Delete manifest-merger-debug-report.txt

* Update SplashActivityTest.kt

* Update SplashActivityTest.kt

* Update SplashActivityTest.kt

* updated manifest

* Update AndroidManifest.xml
  • Loading branch information
veena14cs authored Oct 1, 2019
1 parent 328e089 commit e92f2c7
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ dependencies {
'androidx.test.ext:junit:1.1.1',
'androidx.test:runner:1.2.0',
'com.google.truth:truth:0.43',
'androidx.test.espresso:espresso-intents:3.1.0',
)
androidTestUtil(
'androidx.test:orchestrator:1.2.0',
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name=".splash.SplashActivity"
android:theme="@style/SplashScreenTheme">
</activity>
</application>
</manifest>
22 changes: 22 additions & 0 deletions app/src/main/java/org/oppia/app/splash/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.oppia.app.splash

import android.content.Intent
import android.os.Bundle
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import org.oppia.app.R
import org.oppia.app.home.HomeActivity

/** An activity that shows a temporary loading page until the app is fully loaded then navigates to [HomeActivity]. */
class SplashActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.splash_activity)

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
val intent = Intent(this@SplashActivity, HomeActivity::class.java)
startActivity(intent)
finish()
}
}
5 changes: 5 additions & 0 deletions app/src/main/res/anim/fade_in.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@integer/fade_in_duration_ms" />
6 changes: 6 additions & 0 deletions app/src/main/res/anim/fade_out.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="1.0" android:toAlpha="0.0"
android:fillAfter="true"
android:duration="@integer/fade_out_duration_ms" />
30 changes: 30 additions & 0 deletions app/src/main/res/drawable/splash_page.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="360dp"
android:height="640dp"
android:viewportWidth="360"
android:viewportHeight="640">
<group>
<clip-path android:pathData="M0,0h360v640h-360z M 0,0"/>
<path
android:pathData="M0,0h360v640h-360z"
android:fillColor="#019489"/>
</group>
<path
android:pathData="M80,258c0,-6.78 1.62,-12.35 5.16,-17.27A23.25,23.25 0,0 1,100.65 231a30.08,30.08 0,0 1,14.68 0.94,22.51 22.51,0 0,1 12.72,10.43 26.89,26.89 0,0 1,3.37 10,36.05 36.05,0 0,1 0.14,9.68c-1.08,8.47 -4.93,15.28 -12.15,20a23.15,23.15 0,0 1,-11.91 3.88,26.84 26.84,0 0,1 -13,-2.4 23.73,23.73 0,0 1,-9.82 -8.77,28.77 28.77,0 0,1 -4.38,-12.28C80.17,260.72 80.07,259 80,258ZM105,275.24h0a6.62,6.62 0,0 1,0.17 -0.71,22.8 22.8,0 0,1 2.23,-6.07 11.78,11.78 0,0 1,3.24 -3.81c0.23,-0.2 0.23,-0.31 0.13,-0.54a3.9,3.9 0,0 1,2 -5.16,1.24 1.24,0 0,1 0.23,-0.11 4,4 0,0 1,5.17 2.3,4.22 4.22,0 0,1 0.23,2 4,4 0,0 1,-5.9 2.87c-0.34,-0.2 -0.64,-0.47 -1,-0.74 -3.78,3.1 -5,7.46 -5.74,12a1.14,1.14 0,0 0,0.31 0,15.8 15.8,0 0,0 7.35,-1.69 17.6,17.6 0,0 0,5.81 -4.49,20.44 20.44,0 0,0 2.87,-4.55 20.89,20.89 0,0 0,1.68 -8,27.87 27.87,0 0,0 -0.37,-5.06 17.58,17.58 0,0 0,-4.32 -9.11,14.66 14.66,0 0,0 -5.36,-3.81 18.8,18.8 0,0 0,-6.95 -1.42c-0.81,0 -1.66,0 -2.47,0.07a16.25,16.25 0,0 0,-11.87 5.94A17.1,17.1 0,0 0,89.58 250a20.29,20.29 0,0 0,-1.48 8.6,21.78 21.78,0 0,0 2.33,9.48 16.34,16.34 0,0 0,10.62 8.68c0.65,0.16 1.29,0.27 2,0.4a3.52,3.52 0,0 0,0 -0.61,41.92 41.92,0 0,0 -1.35,-8A18.49,18.49 0,0 0,99 262.64a0.5,0.5 0,0 0,-0.67 -0.24,4 4,0 0,1 -5,-2.59 4.61,4.61 0,0 1,-0.17 -1.18,4 4,0 0,1 3.91,-4 3.9,3.9 0,0 1,2.57 0.91,3.83 3.83,0 0,1 1.35,4 4.07,4.07 0,0 1,-1.42 2.23c0.27,0.44 0.57,0.81 0.81,1.25a27.63,27.63 0,0 1,3.21 10.42c0.06,0.58 0.16,1.15 0.23,1.76L104,275.2v-4.52a71.54,71.54 0,0 1,0.47 -8.54,30.53 30.53,0 0,1 1.85,-7.89 0.31,0.31 0,0 0,-0.1 -0.34,4 4,0 1,1 5.54,-1.15 3.92,3.92 0,0 1,-4 1.72c-0.31,0 -0.37,0 -0.47,0.24 -0.24,0.64 -0.51,1.28 -0.71,1.92a32.28,32.28 0,0 0,-1.15 5.94c-0.14,1.55 -0.3,3.1 -0.37,4.66s-0.07,2.9 -0.1,4.35a34.72,34.72 0,0 1,0.13 3.64Z"
android:fillColor="#fff"/>
<path
android:pathData="M192.6,280.12c0.06,1.32 0.2,2.63 0.2,3.91q0,8.1 0.1,16.2c0,1.18 0,2.36 -0.07,3.54a1.85,1.85 0,0 1,-2.09 1.86h-4.08a2.09,2.09 0,0 1,-2.36 -2.23v-0.47c0,-13 0,-25.88 0,-38.84 0,-3.07 -0.14,-6.14 -0.34,-9.21 -0.1,-1.72 -0.47,-3.41 -0.71,-5.09a5.42,5.42 0,0 1,-0.1 -1.08,2.18 2.18,0 0,1 2,-2.3h0a18.69,18.69 0,0 1,2.8 0A2.57,2.57 0,0 1,190.3 248a17.75,17.75 0,0 1,1.38 4.52c0,0.17 0.07,0.3 0.11,0.57l0.27,-0.44a14.07,14.07 0,0 1,9 -6.61c4.56,-1.08 8.94,-0.67 12.89,2a15.24,15.24 0,0 1,5.74 7.7,24.36 24.36,0 0,1 1.38,7.12 32.22,32.22 0,0 1,-0.81 9.48,21.8 21.8,0 0,1 -5.77,10.42 13.79,13.79 0,0 1,-8.6 4,14.9 14.9,0 0,1 -6.85,-0.91 12.63,12.63 0,0 1,-6.08 -5.3l-0.23,-0.37A0.26,0.26 0,0 0,192.6 280.12ZM192.12,266.42v1.05a12.27,12.27 0,0 0,3.44 8.74,9.75 9.75,0 0,0 6.82,3.34 7.66,7.66 0,0 0,7.09 -3.68,13.84 13.84,0 0,0 1.62,-3.51 25.18,25.18 0,0 0,1 -8.4,13.44 13.44,0 0,0 -1.35,-5.74 8.91,8.91 0,0 0,-3.95 -4.42,8.45 8.45,0 0,0 -7.22,-0.2 11.78,11.78 0,0 0,-6.51 6.75,12.92 12.92,0 0,0 -1,6.07Z"
android:fillColor="#fff"/>
<path
android:pathData="M148.43,280.19c0.07,1.14 0.13,2.29 0.17,3.47s0.1,2.53 0.1,3.78L148.7,303a4.54,4.54 0,0 1,-0.14 1.18,1.76 1.76,0 0,1 -1.85,1.52c-1.52,0 -3,0 -4.56,0a2,2 0,0 1,-2.06 -2.09,4.57 4.57,0 0,1 0,-0.64c0,-12.82 0,-25.68 0,-38.5 0,-3.1 -0.14,-6.21 -0.34,-9.31 -0.1,-1.79 -0.47,-3.55 -0.71,-5.3a7,7 0,0 1,-0.06 -1.45,2.15 2.15,0 0,1 2.05,-1.89 18.83,18.83 0,0 1,2.81 0,2.57 2.57,0 0,1 2.29,1.58 17,17 0,0 1,1.38 4.63c0,0.13 0,0.27 0.07,0.4 0.51,-0.67 0.95,-1.38 1.45,-2a14.32,14.32 0,0 1,10 -5.4,16.17 16.17,0 0,1 7.89,0.91 14.67,14.67 0,0 1,8.27 8.4,23.11 23.11,0 0,1 1.62,7 33.29,33.29 0,0 1,-0.17 7.33,22.69 22.69,0 0,1 -6.34,13.39 13.47,13.47 0,0 1,-8.64 4,14.64 14.64,0 0,1 -6.85,-0.91 12.59,12.59 0,0 1,-6 -5.26,3.21 3.21,0 0,0 -0.27,-0.41ZM147.92,266.45v0.91a12.36,12.36 0,0 0,4.49 9.86,9.13 9.13,0 0,0 5.74,2.33 7.68,7.68 0,0 0,7.11 -3.68,14.68 14.68,0 0,0 2,-4.73 25.93,25.93 0,0 0,0.68 -5.33,15.69 15.69,0 0,0 -1.32,-7.56 9,9 0,0 0,-4 -4.45,8.41 8.41,0 0,0 -7.42,-0.1 12,12 0,0 0,-6.31 6.65,14.35 14.35,0 0,0 -1,6.1Z"
android:fillColor="#fff"/>
<path
android:pathData="M270.5,264.87c0.24,-2.67 0.24,-5.2 -1.08,-7.53a8,8 0,0 0,-5.8 -3.94,17 17,0 0,0 -11,1.65 15.44,15.44 0,0 1,-1.42 0.67,1.43 1.43,0 0,1 -2,-0.57 9.1,9.1 0,0 1,-1.55 -3.44,2.26 2.26,0 0,1 0.68,-2.13 9.11,9.11 0,0 1,3.17 -2.12,18.5 18.5,0 0,1 6.44,-1.69 44.88,44.88 0,0 1,5.2 -0.17,15.67 15.67,0 0,1 10.12,4 14.14,14.14 0,0 1,4.52 8.61,25.57 25.57,0 0,1 -0.13,8.37c-0.2,1.31 -0.47,2.63 -0.71,4a1.09,1.09 0,0 0,0.07 0.57,57.81 57.81,0 0,1 2.36,8.3c0.27,1.49 0.44,3 0.61,4.56a2.18,2.18 0,0 1,0 0.67A1.49,1.49 0,0 1,278.4 286c-1.35,0 -2.67,0 -4,0a1.45,1.45 0,0 1,-1.62 -1.48c-0.2,-1.49 -0.44,-2.94 -0.64,-4.42a0.58,0.58 0,0 0,-0.07 -0.21c-0.51,0.71 -1,1.45 -1.55,2.13a13.42,13.42 0,0 1,-7.53 4.45,15.58 15.58,0 0,1 -10.76,-1.11 11.65,11.65 0,0 1,-6.95 -10.26,13 13,0 0,1 1.35,-7.12 11.35,11.35 0,0 1,6.48 -5.43,19.29 19.29,0 0,1 13.19,-0.07 14.31,14.31 0,0 1,3.91 2.23ZM260.69,268.11a12.55,12.55 0,0 0,-1.93 0.23,5.91 5.91,0 0,0 -4.52,3.78 5.44,5.44 0,0 0,2.94 6.85,8.64 8.64,0 0,0 4.32,0.64 9.23,9.23 0,0 0,6.47 -3.13,3.93 3.93,0 0,0 0.07,-5.54 6.82,6.82 0,0 0,-1.18 -1A11.33,11.33 0,0 0,260.69 268.11Z"
android:fillColor="#fff"/>
<path
android:pathData="M236.36,262.67v13.54a6.27,6.27 0,0 0,0.1 1.14,1.54 1.54,0 0,0 2.16,1.32c0.4,-0.14 0.81,-0.31 1.21,-0.47s0.58,-0.21 0.88,-0.31a1,1 0,0 1,1.38 0.58c0.54,1.08 1,2.22 1.49,3.34a2,2 0,0 1,-0.78 2.29,10.33 10.33,0 0,1 -5,2.23 11.81,11.81 0,0 1,-4.59 -0.17,5.86 5.86,0 0,1 -4.32,-3.88 15.61,15.61 0,0 1,-0.94 -5.57c0,-9.35 0,-18.69 0,-28a2.28,2.28 0,0 1,0.54 -1.62,1.76 1.76,0 0,1 1.41,-0.67h4.19a2.06,2.06 0,0 1,2.29 2.29v4.25Z"
android:fillColor="#fff"/>
<path
android:pathData="M232.28,228.33A5.52,5.52 0,0 1,238 234a5.67,5.67 0,0 1,-5.74 5.74,5.76 5.76,0 0,1 -5.73,-5.77v-0.07A5.65,5.65 0,0 1,232.28 228.33Z"
android:fillColor="#fff"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/layout/splash_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="@+id/fragment_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".splash.SplashActivity">
</FrameLayout>

3 changes: 3 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="fade_in_duration_ms">1000</integer>
<integer name="fade_out_duration_ms">1000</integer>

<dimen name="audio_fragment_corner_radius">8dp</dimen>
<dimen name="audio_fragment_margin">32dp</dimen>
<dimen name="cellular_data_dialog_padding">24dp</dimen>
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@
<item name="colorAccent">@color/colorPrimary</item>
</style>

<style name="OppiaThemeWithoutActionBar" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="SplashScreenTheme" parent="OppiaThemeWithoutActionBar">
<item name="android:windowBackground">@drawable/splash_page</item>
<item name="android:windowAnimationStyle">@style/FadeTransitionAnimation.Activity</item>
</style>

<!-- Base style for animations. This style specifies no animations. -->
<style name="FadeTransitionAnimation" />

<!-- Standard animations for a full-screen window or activity. -->
<style name="FadeTransitionAnimation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/fade_in</item>
<item name="android:activityOpenExitAnimation">@anim/fade_out</item>
</style>

<style name="FullScreenDialogStyle" parent="Theme.AppCompat.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="colorPrimaryDark">@color/colorConceptToolbarHeading</item>
Expand Down
43 changes: 43 additions & 0 deletions app/src/sharedTest/java/org/oppia/app/splash/SplashActivityTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.oppia.app.splash

import androidx.test.espresso.intent.Intents
import androidx.test.espresso.intent.Intents.intended
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.rule.ActivityTestRule
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.oppia.app.home.HomeActivity

/**
* Tests for [SplashActivity]. For context on the activity test rule setup see:
* https://jabknowsnothing.wordpress.com/2015/11/05/activitytestrule-espressos-test-lifecycle/.
*/
@RunWith(AndroidJUnit4::class)
class SplashActivityTest {

// The initialTouchMode enables the activity to be launched in touch mode. The launchActivity is
// disabled to launch Activity explicitly within each test case.
@get:Rule
var activityTestRule: ActivityTestRule<SplashActivity> = ActivityTestRule(
SplashActivity::class.java, /* initialTouchMode= */ true, /* launchActivity= */ false)

@Before
fun setUp() {
Intents.init()
}

@Test
fun testSplashActivity_initialOpen_routesToHomeActivity() {
activityTestRule.launchActivity(null)
intended(hasComponent(HomeActivity::class.java.getName()))
}

@After
fun tearDown() {
Intents.release()
}
}

0 comments on commit e92f2c7

Please sign in to comment.