All Projects → bleeding182 → magikarp

bleeding182 / magikarp

Licence: MIT license
[Work in Progress] Splash Screens for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to magikarp

Pwa Asset Generator
Automates PWA asset generation and image declaration. Automatically generates icon and splash screen images, favicons and mstile images. Updates manifest.json and index.html files with the generated images according to Web App Manifest specs and Apple Human Interface guidelines.
Stars: ✭ 1,787 (+9305.26%)
Mutual labels:  splash-screen
React Native Splash Screen
A splash screen for react-native, hide when application loaded ,it works on iOS and Android.
Stars: ✭ 5,038 (+26415.79%)
Mutual labels:  splash-screen
AdaptivePlus-Android
Free forever Marketing SDK with a dashboard for in-app SplashScreen banners with built-in analytics
Stars: ✭ 16 (-15.79%)
Mutual labels:  splash-screen
SplashScreen
A demo project showcasing different methods to create splash screen in Android and discusses the details in the companion Medium article.
Stars: ✭ 37 (+94.74%)
Mutual labels:  splash-screen
DarkModeSplashScreen
A sample app for iOS and Android written in Xamarin.Forms showing how to implement a Splash Page for Dark Mode
Stars: ✭ 28 (+47.37%)
Mutual labels:  splash-screen
ReactNativeStarterKits
Agiletech React Native Starter Kits
Stars: ✭ 21 (+10.53%)
Mutual labels:  splash-screen
SplashScreenExample
How to implement a Splash Screen in ReactNative
Stars: ✭ 14 (-26.32%)
Mutual labels:  splash-screen
emacs-splash
An alternative splash screen for GNU Emacs
Stars: ✭ 59 (+210.53%)
Mutual labels:  splash-screen
Splashy
Splash screen library for Android
Stars: ✭ 112 (+489.47%)
Mutual labels:  splash-screen
react-native-lottie-splash-screen
⚡ Lottie splash screen for your react native app!
Stars: ✭ 124 (+552.63%)
Mutual labels:  splash-screen
vue-splash
splash plugin for vue js
Stars: ✭ 120 (+531.58%)
Mutual labels:  splash-screen
AnimateViewLibrary
Developing easy to use any animation set for splash screen or any other views in your Android application. Easy to use, so you can animate your whole app just using this library
Stars: ✭ 19 (+0%)
Mutual labels:  splash-screen
retropiesplashscreen
Splashscreen Randomizer for Retropie!
Stars: ✭ 19 (+0%)
Mutual labels:  splash-screen

Magikarp

Magikarp used splash—and something happened!

A small library that has your splash screen needs covered. Check out the demo app which showcases the the available options! You can also read an introductory article on my blog.

Why?

As the name might suggest this library is intended to help you with your splash screens. On Android we can differentiate between two kinds of splash screen (not counting really bad ideas like splash Actvities):

  1. The splash screen during app startup time (windowBackground of the activity's theme) which will be visible until the first frame of the content view gets drawn
  2. View overlays while the content is loading

We can't fully avoid 1. as our app startup time will get slower the bigger the project becomes, so this is a great spot to show our splash screen with minimal impact for the user—otherwise they'd just be looking at a white screen instead.

Approach 2. can be used if we know that we need to do some unsightly (e.g. getting the user position, moving the map, and waiting for the tiles to finish loading). We can also use this to have a smooth animation between our splash screen and our content.

While we could still use the same approach to show a splash screen for 5s this is not recommended since users usually want to use your app and not stare at a splash screen—even though some designers might think of it backwards

Features

This library offers help with both approaches mentioned:

  • A basic lifecycle callback that can swap themes for easy integration of a splash theme in your app
  • A view overlay to animate your splash screen (while your content is loading)

Splash Theme

To use a splash theme start by creating the theme. It is a good idea to use the same flags that your theme will use (fullscreen, etc) but the important bit is to specify the splash drawable as android:windowBackground

<style name="AppTheme.Splash">
    <item name="android:windowBackground">@drawable/splash_screen</item>
</style>

A simple splash screen will usually consist of your primary color with the app icon centered in it:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <color android:color="@color/colorPrimary"/>
    </item>

    <item android:id="@+id/icon">
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher_foreground"/>
    </item>
</layer-list>

In your Application initialize Magikarp with the default theme of your app:

public class App extends Application {

  @Override
  public void onCreate() {
    super.onCreate();
    
    // ...

    Magikarp.addSplashScreen(this, R.style.AppTheme);
  }
}

Finally, register your Application and splash theme in the manifest, and keep in mind that you should not set any theme on your Activities directly, or it will use the window background from that theme instead.

<application
    android:name=".App"
    android:theme="@style/AppTheme.Splash"/>

That's it! If an Activity needs a different theme you can set declare it by setting "theme" as <meta-inf /> on the Activity.

<activity>
    <meta-data
        android:name="theme"
        android:resource="@style/ThemeOverlay.AppCompat.Dark"/>
</activity>

Animated Splash Screen

Magikarp offers a very simple reveal animation to keep showing a splash screen while your content loads. Pass in the same drawable your splash screen uses and call .reveal() to animate the splash screen away once you're ready.

RevealCallback callback = Magikarp.splash(this, R.drawable.splash_screen);
// ... do some loading ...
callback.reveal();

You can also create more complex animations with the drawable by using callback.getDrawable().

private Animator createSplashAnimation(RevealCallback callback) {
  final Drawable drawable = ((LayerDrawable) callback.getDrawable()).findDrawableByLayerId(R.id.icon);
  final float dp100 = 200 // 100 "dp"
  
  final ValueAnimator splashAnimator = ValueAnimator.ofInt(0, (int) dp100, 0);
  splashAnimator.setDuration(450);
  splashAnimator.setInterpolator(new AnticipateOvershootInterpolator());
  splashAnimator.setRepeatMode(ValueAnimator.RESTART);
  splashAnimator.setStartDelay(100);
  splashAnimator.setRepeatCount(1);

  final Rect drawableBounds = drawable.copyBounds();
  final int top = drawableBounds.top;
  final int left = drawableBounds.left;
  splashAnimator.addUpdateListener(
      animation -> {
        drawable.copyBounds(drawableBounds);
        int value = (int) animation.getAnimatedValue();
        drawableBounds.offsetTo(left, top - value);
        drawable.setBounds(drawableBounds);
      });

  final AnimatorSet animatorSet = new AnimatorSet();
  animatorSet.playSequentially(splashAnimator, callback.createRevealAnimator());
  return animatorSet;
}

Then use callback.reveal(animator) to play your custom animation instead!

Usage

You can try it out using JitPack by adding the following to your build.gradle file:

repositories {
    maven { url 'https://jitpack.io' }
}
dependencies {
    implementation 'com.github.bleeding182:magikarp:-SNAPSHOT'
}

Feature Backlog

This library should remain simple, as such the library should handle the two use cases mentioned and it should handle them well.

For now there is only support to animate the drawable as shown in the example to prevent splash screens with more complexity than the rest of the app, but view animation support could be added if the need arises.

Contributing

This library will keep a 0.* version until I can get some feedback about how you are using it along with any issues. As such, please feel free to add suggestions or feedback.

License

This code is published under MIT, so please feel free to use what you need.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].