Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature SplashScreen using SplashAPI #1416

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ext {
compileSdkVersion = 34
buildToolsVersion = '30.0.3'
kotlinVersion = "1.9.10" // 1.9.10
compose_version = '1.5.4'

// App dependencies
supportLibraryVersion = '28.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import static org.junit.Assert.assertEquals;

import android.content.Context;

import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -14,12 +15,12 @@
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4ClassRunner.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
Context appContext = InstrumentationRegistry.getInstrumentation().getContext();

assertEquals("org.mifos.mobilewallet.core.test", appContext.getPackageName());
}
Expand Down
22 changes: 15 additions & 7 deletions mifospay/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation project(':core')
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation "androidx.core:core-ktx:1.12.0"
Expand All @@ -60,11 +57,19 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.3.2'
api 'com.google.android.material:material:1.0.0' // update require alot of UI changes

// Compose
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")

implementation "com.jakewharton:butterknife:$rootProject.butterKnifeVersion"
kapt "com.jakewharton:butterknife-compiler:$rootProject.butterKnifeVersion"

// Splash API
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation("androidx.core:core-splashscreen:1.0.1")

implementation "com.google.dagger:dagger:$rootProject.daggerVersion"
kapt "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
Expand Down Expand Up @@ -97,9 +102,12 @@ dependencies {
implementation 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.github.yalantis:ucrop:2.2.2'
testImplementation "junit:junit:$rootProject.junitVersion"

implementation project(':core')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
testImplementation "junit:junit:$rootProject.junitVersion"
}

kapt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
Context appContext = InstrumentationRegistry.getInstrumentation().getContext();

assertEquals("org.mifos.mobilewallet.mifospay", appContext.getPackageName());
}
Expand Down
2 changes: 1 addition & 1 deletion mifospay/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<activity android:name=".merchants.ui.MerchantTransferActivity" />
<activity
android:name=".SplashScreenActivity"
android:theme="@style/SplashTheme"
android:theme="@style/SplashScreenTheme"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.mifos.mobilewallet.mifospay

import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.ActivityInfo
import android.os.Build
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.mifos.mobilewallet.mifospay.auth.ui.LoginActivity

@SuppressLint("CustomSplashScreen")
class SplashScreenActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
val splashScreen = installSplashScreen()
splashScreen.setKeepOnScreenCondition { true }
}
super.onCreate(savedInstanceState)
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
lifecycleScope.launch {
delay(2000)
startActivity(Intent(this@SplashScreenActivity, LoginActivity::class.java))
finish()
}
}
}
11 changes: 11 additions & 0 deletions mifospay/src/main/res/drawable/bg_splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/black" />
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/splash_icon" />
</item>
</layer-list>
12 changes: 12 additions & 0 deletions mifospay/src/main/res/drawable/bg_splash_12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/black" />
</item>

<item
android:width="100dp"
android:height="100dp"
android:drawable="@drawable/splash_icon"
android:gravity="center" />
</layer-list>
Binary file added mifospay/src/main/res/drawable/splash_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions mifospay/src/main/res/values-v31/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="SplashScreenTheme" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/black</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/bg_splash_12</item>
<item name="windowSplashScreenAnimationDuration">3000</item>
<item name="postSplashScreenTheme">@style/AppTheme</item>
</style>

</resources>
8 changes: 4 additions & 4 deletions mifospay/src/main/res/values/splash.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<resources>

<style name="Theme.SplashScreen.MySplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#FFD0BCFF</item>
<!--<item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>-->
<style name="Theme.SplashScreen.MifosSplash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#000000</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_icon</item>
<item name="postSplashScreenTheme">@style/Theme.SplashScreen</item>
</style>
</resources>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="SplashScreenTheme" parent="AppTheme">
<item name="android:windowBackground">@drawable/bg_splash</item>
</style>

<style name="TextAppearance.App.TextInputLayout" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/colorAccent</item>
<item name="android:textSize">14sp</item>
Expand Down