Skip to content

Commit

Permalink
Introduce Splash Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Tejasvp25 committed May 27, 2021
1 parent 57e65df commit eef1191
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 7 deletions.
14 changes: 8 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HerokuDynoManager">
<activity android:name=".ui.main.view.SplashScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.main.view.AppInfoActivity"
android:parentActivityName=".ui.main.view.AppListActivity"
android:theme="@style/Theme.HerokuDynoManager.ActionBar" />
<activity
android:name=".ui.main.view.AppListActivity"
android:theme="@style/Theme.HerokuDynoManager.ActionBar" />
<activity android:name=".ui.main.view.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<activity android:name=".ui.main.view.MainActivity"/>

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AppListActivity : AppCompatActivity() {
private fun setupObserver(){
viewModel.apps.observe(this, Observer {
when(it.status){

Status.SUCCESS ->
it.data?.let {
if(it.size > 0) {
Expand All @@ -64,7 +65,7 @@ class AppListActivity : AppCompatActivity() {
progress_bar_applist.visibility = View.GONE
img_error.visibility = View.VISIBLE
text_error_msg.visibility = View.VISIBLE
text_error_msg.text = if(it.statusCode == 401 )"Unauthorized\nPlease Check Your Auth Token !" else "Unexpected Error Occurred"
text_error_msg.text = "Check Internet Connection\nAnd\nAPI key"
}
Status.LOADING -> {
applist_recyclerview.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.tejas.herokudynomanager.ui.main.view

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.CountDownTimer
import androidx.lifecycle.asLiveData
import com.tejas.herokudynomanager.R
import com.tejas.herokudynomanager.utils.DatastorePreference
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.*
import javax.inject.Inject

@AndroidEntryPoint
class SplashScreenActivity : AppCompatActivity() {
@Inject
lateinit var mDatastorePreference: DatastorePreference

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

override fun onStart() {
super.onStart()
mDatastorePreference.apiKey
.asLiveData()
.observe(this, {
val timer = object: CountDownTimer(1500, 100) {
override fun onTick(millisUntilFinished: Long) {}
override fun onFinish() {
if(it!!.equals("")){
val intent = Intent(applicationContext,MainActivity::class.java)
startActivity(intent)
}else{
val intent = Intent(applicationContext,AppListActivity::class.java)
intent.putExtra("api_key",it)
startActivity(intent)
}
}
}
timer.start()
})
}
}
54 changes: 54 additions & 0 deletions app/src/main/res/layout/activity_splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ui.main.view.SplashScreenActivity">

<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.8"
android:orientation="vertical"
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_heroku_logo_solid_purple"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_medium"
android:layout_gravity="center"
android:text="@string/str_unofficial"
android:textSize="@dimen/text_big"
android:textStyle="bold"/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_medium"
android:layout_gravity="center"
android:text="@string/app_name"
android:textSize="@dimen/text_very_big"
android:textStyle="bold" />
</androidx.appcompat.widget.LinearLayoutCompat>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_medium"
android:layout_gravity="center"
android:text="Made with ❤ In India \n By Tejasvp25"
android:textSize="@dimen/text_big"
android:textStyle="bold"
android:textAlignment="center" />
</FrameLayout>

</androidx.appcompat.widget.LinearLayoutCompat>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
<string name="str_api_key">Api Key</string>
<string name="str_theme">Theme</string>
<string name="str_update_api_key">Update Api Key</string>
<string name="str_unofficial">(Unofficial)</string>
</resources>

0 comments on commit eef1191

Please sign in to comment.