Skip to content

Commit 8d3fed8

Browse files
committed
Included Splash Screen and Onboarding Screen
1 parent 8fc4c4b commit 8d3fed8

24 files changed

+3834
-11
lines changed

.idea/gradle.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

+9
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ apply plugin: 'com.android.application'
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-android-extensions'
44

5+
56
android {
67
compileSdkVersion 30
78
buildToolsVersion "30.0.2"
89

10+
911
defaultConfig {
1012
applicationId "com.wellnesscity.health"
1113
minSdkVersion 22
@@ -30,8 +32,15 @@ dependencies {
3032
implementation 'androidx.core:core-ktx:1.3.2'
3133
implementation 'androidx.appcompat:appcompat:1.2.0'
3234
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
35+
//noinspection GradleCompatible,GradleCompatible
36+
implementation 'com.android.support:appcompat-v7:28.0.0'
37+
implementation 'com.android.support.constraint:constraint-layout:2.0.1'
3338
testImplementation 'junit:junit:4.12'
3439
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
3540
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3641

42+
//ViewPager2
43+
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
44+
//Material Design
45+
implementation 'com.google.android.material:material:1.3.0-alpha03'
3746
}

app/src/main/AndroidManifest.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
package="com.wellnesscity.health">
45

56
<application
@@ -9,13 +10,16 @@
910
android:roundIcon="@mipmap/ic_launcher_round"
1011
android:supportsRtl="true"
1112
android:theme="@style/AppTheme">
12-
<activity android:name=".MainActivity">
13+
14+
<activity android:name=".MainActivity"></activity>
15+
<activity android:name=".SplashScreenActivity">
1316
<intent-filter>
1417
<action android:name="android.intent.action.MAIN" />
1518

1619
<category android:name="android.intent.category.LAUNCHER" />
1720
</intent-filter>
1821
</activity>
22+
<activity android:name=".OnboardingActivity"></activity>
1923
</application>
2024

2125
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.wellnesscity.health
2+
3+
data class IntroSlide(
4+
val title: String,
5+
val description: String,
6+
val icon: Int
7+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.wellnesscity.health
2+
3+
import android.view.LayoutInflater
4+
import android.view.View
5+
import android.view.ViewGroup
6+
import android.widget.ImageView
7+
import android.widget.TextView
8+
import androidx.recyclerview.widget.RecyclerView
9+
10+
class IntroSliderAdapter(private val introSlides: List<IntroSlide>)
11+
: RecyclerView.Adapter<IntroSliderAdapter.IntroSlideViewHolder>(){
12+
13+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IntroSlideViewHolder {
14+
return IntroSlideViewHolder(
15+
LayoutInflater.from(parent.context).inflate(
16+
R.layout.slide_item_container,
17+
parent,
18+
false
19+
)
20+
)
21+
}
22+
23+
override fun getItemCount(): Int {
24+
return introSlides.size
25+
}
26+
27+
override fun onBindViewHolder(holder: IntroSlideViewHolder, position: Int) {
28+
holder.bind(introSlides[position])
29+
}
30+
31+
inner class IntroSlideViewHolder(view: View) : RecyclerView.ViewHolder(view) {
32+
33+
private val textTitle = view.findViewById<TextView>(R.id.textTitle)
34+
private val textDescription = view.findViewById<TextView>(R.id.textDescription)
35+
private val imageIcon = view.findViewById<ImageView>(R.id.imageSlideIcon)
36+
37+
fun bind(introSlide: IntroSlide) {
38+
textTitle.text = introSlide.title
39+
textDescription.text = introSlide.description
40+
imageIcon.setImageResource(introSlide.icon)
41+
}
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.wellnesscity.health
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import android.os.Bundle
5+
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
6+
import android.widget.ImageView
7+
import android.widget.LinearLayout
8+
import androidx.core.content.ContextCompat
9+
import androidx.core.view.get
10+
import kotlinx.android.synthetic.main.onboarding_screen.*
11+
12+
class OnboardingActivity : AppCompatActivity() {
13+
14+
private val introSliderAdapter = IntroSliderAdapter(
15+
listOf(
16+
IntroSlide(
17+
"Health Tips / Advice",
18+
"Discover tips and advice to help you to help maintain transform and main your health",
19+
R.drawable.ic_bro
20+
),
21+
IntroSlide(
22+
"Diet Tips / Advice",
23+
"Find out basics of health diet and good nutrition, Start eating well and keep a balanced diet",
24+
R.drawable.ic_amico
25+
),
26+
IntroSlide(
27+
"Covid 19 Symptoms/Prevention tips",
28+
"Get regular Reminders of Covid19 prevention tips ensuring you stay safe",
29+
R.drawable.ic_pana
30+
)
31+
)
32+
)
33+
34+
override fun onCreate(savedInstanceState: Bundle?) {
35+
super.onCreate(savedInstanceState)
36+
setContentView(R.layout.onboarding_screen)
37+
introSliderViewPager.adapter = introSliderAdapter
38+
setupIndicators()
39+
setCurrentIndicator(0)
40+
}
41+
42+
private fun setupIndicators() {
43+
val indicators = arrayOfNulls<ImageView>(introSliderAdapter.itemCount)
44+
val layoutParams: LinearLayout.LayoutParams =
45+
LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)
46+
layoutParams.setMargins(8,0,8,0)
47+
for(i in indicators.indices) {
48+
indicators[i] = ImageView(applicationContext)
49+
indicators[i].apply {
50+
this?.setImageDrawable(
51+
ContextCompat.getDrawable(
52+
applicationContext,
53+
R.drawable.indicator_inactive
54+
)
55+
)
56+
this?.layoutParams = layoutParams
57+
}
58+
indicatorsContainer.addView(indicators[i])
59+
}
60+
61+
}
62+
63+
private fun setCurrentIndicator(index: Int){
64+
val childCount = indicatorsContainer.childCount
65+
for (i in 0 until childCount) {
66+
val imageView = indicatorsContainer[i] as ImageView
67+
if (i == index){
68+
imageView.setImageDrawable(
69+
ContextCompat.getDrawable(
70+
applicationContext,
71+
R.drawable.indicator_active
72+
)
73+
)
74+
} else {
75+
imageView.setImageDrawable(
76+
ContextCompat.getDrawable(
77+
applicationContext,
78+
R.drawable.indicator_inactive
79+
)
80+
)
81+
}
82+
}
83+
84+
}
85+
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.wellnesscity.health
2+
3+
import android.content.Intent
4+
import androidx.appcompat.app.AppCompatActivity
5+
import android.os.Bundle
6+
import android.os.Handler
7+
8+
class SplashScreenActivity : AppCompatActivity() {
9+
override fun onCreate(savedInstanceState: Bundle?) {
10+
super.onCreate(savedInstanceState)
11+
setContentView(R.layout.splash_screen)
12+
13+
supportActionBar?.hide()
14+
15+
Handler().postDelayed({
16+
val intent = Intent (this@SplashScreenActivity, OnboardingActivity::class.java)
17+
startActivity(intent)
18+
finish()
19+
}, 3000)
20+
}
21+
}

0 commit comments

Comments
 (0)