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

Splash Screen with GIF Animations for Services Application #303

Open
wants to merge 1 commit into
base: upgrade-jdk11
Choose a base branch
from
Open
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 services_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ dependencies {
implementation "androidx.navigation:navigation-fragment:2.5.3"
implementation "androidx.navigation:navigation-ui:2.5.3"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.github.bumptech.glide:glide:4.15.1'

implementation group: 'com.google.zxing', name: 'core', version: '3.3.0'
implementation group: 'com.journeyapps', name: 'zxing-android-embedded', version: '3.5.0'
Expand Down
2 changes: 1 addition & 1 deletion services_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
android:syncable="false" />

<activity
android:name=".MainActivity"
android:name=".SplashScreenActivity"
android:label="@string/app_name"
android:theme="@style/ODKX">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.opendatakit.services;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.LinearLayout;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;

public class SplashScreenActivity extends AppCompatActivity {

private static final int LOGO_DISPLAY_TIME = 500;
private static final int GIF_DISPLAY_TIME = 10000;
private Handler handler = new Handler();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);

ImageView iv = findViewById(R.id.splash);
LinearLayout ll = findViewById(R.id.splash_layout);
ImageView gif = findViewById(R.id.gif);


handler.postDelayed(() -> {
iv.setVisibility(ImageView.GONE); // Hide the logo
ll.setVisibility(LinearLayout.VISIBLE);

gif.setVisibility(ImageView.VISIBLE);
Glide.with(SplashScreenActivity.this)
.asGif()
.load(R.drawable.settings_gif) // Replace with your actual GIF resource
.into(gif);
}, LOGO_DISPLAY_TIME);


handler.postDelayed(() -> {
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
startActivity(intent);
finish();
}, LOGO_DISPLAY_TIME + GIF_DISPLAY_TIME); // Add the display time of the logo
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions services_app/src/main/res/layout/splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/splash_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:gravity="center"
android:orientation="vertical"
android:padding="16dp">



<ImageView
android:id="@+id/splash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:contentDescription="@string/app_name"
android:gravity="center"
android:padding="0dip"
android:scaleType="fitCenter"
android:src="@drawable/logo_services"
android:visibility="visible" />

<ImageView
android:id="@+id/gif"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/services_gif"
android:src="@drawable/settings_gif"
android:visibility="gone" />


</LinearLayout>
1 change: 1 addition & 0 deletions services_app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -450,5 +450,6 @@
<string name="sign_in_using_credentials">Sign in using Credentials</string>
<string name="set_credentials">Set Credentials</string>
<string name="sign_in_as_anonymous">Sign in as Anonymous User</string>
<string name="services_gif">Service GIF</string>

</resources>