From 34c4951241e23deb059143dcca52e0f4b825abb3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 7 Mar 2017 23:10:41 +0100 Subject: [PATCH] Animated splash screen (mind: preview for the circular loader seems broken in Android Studio, but works in app) --- app/build.gradle | 1 + app/src/main/AndroidManifest.xml | 2 +- .../keylesspalace/tusky/SplashActivity.java | 22 ++++++++++++--- .../main/res/drawable/splash_background.xml | 9 ------- app/src/main/res/layout/activity_splash.xml | 27 +++++++++++++++++++ app/src/main/res/values/styles.xml | 4 --- 6 files changed, 47 insertions(+), 18 deletions(-) delete mode 100644 app/src/main/res/drawable/splash_background.xml create mode 100644 app/src/main/res/layout/activity_splash.xml diff --git a/app/build.gradle b/app/build.gradle index 73233f09a..c9c6c400b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,4 +34,5 @@ dependencies { compile 'com.pkmmte.view:circularimageview:1.1' compile 'com.github.peter9870:sparkbutton:master' testCompile 'junit:junit:4.12' + compile 'com.mikhaellopez:circularfillableloaders:1.2.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2601bee29..4bdc081e5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,7 +14,7 @@ android:theme="@style/AppTheme"> + android:theme="@android:style/Theme.Black.NoTitleBar"> diff --git a/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java b/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java index 1297196c6..c3e38c035 100644 --- a/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/SplashActivity.java @@ -15,29 +15,43 @@ package com.keylesspalace.tusky; +import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.os.Handler; import android.support.v7.app.AppCompatActivity; -public class SplashActivity extends AppCompatActivity { +public class SplashActivity extends Activity { + private static int SPLASH_TIME_OUT = 2000; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.activity_splash); /* Determine whether the user is currently logged in, and if so go ahead and load the * timeline. Otherwise, start the activity_login screen. */ SharedPreferences preferences = getSharedPreferences( getString(R.string.preferences_file_key), Context.MODE_PRIVATE); String domain = preferences.getString("domain", null); String accessToken = preferences.getString("accessToken", null); - Intent intent; + + + final Intent intent; + if (domain != null && accessToken != null) { intent = new Intent(this, MainActivity.class); } else { intent = new Intent(this, LoginActivity.class); } - startActivity(intent); - finish(); + + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + startActivity(intent); + finish(); + } + }, SPLASH_TIME_OUT); } } diff --git a/app/src/main/res/drawable/splash_background.xml b/app/src/main/res/drawable/splash_background.xml deleted file mode 100644 index fb783fdf3..000000000 --- a/app/src/main/res/drawable/splash_background.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/activity_splash.xml b/app/src/main/res/layout/activity_splash.xml new file mode 100644 index 000000000..11c059c1e --- /dev/null +++ b/app/src/main/res/layout/activity_splash.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 1574f158c..a62b68a74 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,9 +1,5 @@ - -