Added basic onboarding activity
This commit is contained in:
1 parent
64357697bd
commit
58839c3714
16 files changed
+224
-35
No files matched your search
+3
-1
@@ -72,13 +72,15 @@ dependencies {
|
||||
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
|
||||
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
|
||||
implementation "androidx.preference:preference-ktx:$preference_version"
|
||||
implementation "androidx.viewpager2:viewpager2:$view_pager2_version"
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
implementation "androidx.room:room-ktx:$room_version"
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
|
||||
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_viewmodel_version"
|
||||
implementation "com.google.dagger:hilt-android:$hilt_version"
|
||||
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
|
||||
|
||||
implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_viewmodel_version"
|
||||
kapt "androidx.hilt:hilt-compiler:$hilt_viewmodel_version"
|
||||
|
||||
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||
|
||||
@@ -1,22 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Look4Sat. Amateur radio and weather satellite tracker and passes predictor for Android.
|
||||
~ Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
||||
~
|
||||
~ This program is free software; you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation; either version 2 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along
|
||||
~ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
-->
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.rtbishop.look4sat">
|
||||
|
||||
@@ -32,7 +14,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".ui.activities.MainActivity"
|
||||
android:name=".ui.splash.SplashActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/AppTheme.Splash">
|
||||
<intent-filter>
|
||||
@@ -41,6 +23,9 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.activities.MainActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -50,7 +50,10 @@ class SharedViewModel @ViewModelInject constructor(
|
||||
private var shouldTriggerCalculation = true
|
||||
|
||||
init {
|
||||
if (prefsManager.isFirstLaunch()) updateDefaultSourcesAndEntries()
|
||||
if (prefsManager.isFirstLaunch()) {
|
||||
updateDefaultSourcesAndEntries()
|
||||
prefsManager.setFirstLaunchDone()
|
||||
}
|
||||
startApplicationTimer()
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ import dagger.hilt.android.AndroidEntryPoint
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(R.style.AppTheme)
|
||||
super.onCreate(savedInstanceState)
|
||||
val binding = ActivityMainBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
val navHost = supportFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment
|
||||
binding.navBottom.setupWithNavController(navHost.navController)
|
||||
ActivityMainBinding.inflate(layoutInflater).apply {
|
||||
setContentView(root)
|
||||
val navHost = supportFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment
|
||||
navBottom.setupWithNavController(navHost.navController)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.rtbishop.look4sat.ui.splash
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.rtbishop.look4sat.R
|
||||
|
||||
class FirstFragment : Fragment(R.layout.fragment_first)
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.rtbishop.look4sat.ui.splash
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.rtbishop.look4sat.R
|
||||
|
||||
class SecondFragment: Fragment(R.layout.fragment_second)
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.rtbishop.look4sat.ui.splash
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.databinding.ActivitySplashBinding
|
||||
import com.rtbishop.look4sat.ui.activities.MainActivity
|
||||
import com.rtbishop.look4sat.utility.PrefsManager
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class SplashActivity : FragmentActivity() {
|
||||
|
||||
private val pagesCount = 3
|
||||
|
||||
@Inject
|
||||
lateinit var prefsManager: PrefsManager
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (prefsManager.isFirstLaunch()) showOnboarding()
|
||||
else startMainActivity()
|
||||
}
|
||||
|
||||
private fun showOnboarding() {
|
||||
setTheme(R.style.AppTheme)
|
||||
ActivitySplashBinding.inflate(layoutInflater).apply {
|
||||
setContentView(root)
|
||||
splashPager.apply {
|
||||
adapter = SplashPagerAdapter(this@SplashActivity)
|
||||
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
|
||||
override fun onPageSelected(position: Int) {
|
||||
super.onPageSelected(position)
|
||||
if (position == pagesCount - 1) {
|
||||
splashNext.setImageResource(R.drawable.ic_check)
|
||||
}
|
||||
}
|
||||
})
|
||||
// isUserInputEnabled = false
|
||||
}
|
||||
splashNext.setOnClickListener {
|
||||
if (splashPager.currentItem < pagesCount - 1) splashPager.currentItem++
|
||||
else if (splashPager.currentItem == pagesCount - 1) startMainActivity()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startMainActivity() {
|
||||
startActivity(Intent(this, MainActivity::class.java))
|
||||
}
|
||||
|
||||
private inner class SplashPagerAdapter(activity: FragmentActivity) :
|
||||
FragmentStateAdapter(activity) {
|
||||
|
||||
override fun getItemCount(): Int = pagesCount
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return when (position) {
|
||||
0 -> FirstFragment()
|
||||
1 -> SecondFragment()
|
||||
2 -> ThirdFragment()
|
||||
else -> FirstFragment()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.rtbishop.look4sat.ui.splash
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.rtbishop.look4sat.R
|
||||
|
||||
class ThirdFragment : Fragment(R.layout.fragment_third)
|
||||
@@ -79,13 +79,13 @@ class PrefsManager @Inject constructor(val preferences: SharedPreferences) {
|
||||
}
|
||||
|
||||
fun isFirstLaunch(): Boolean {
|
||||
val isFirstLaunch = preferences.getBoolean(keyIsFirstLaunch, true)
|
||||
return if (isFirstLaunch) {
|
||||
preferences.edit {
|
||||
putBoolean(keyIsFirstLaunch, false)
|
||||
apply()
|
||||
}
|
||||
isFirstLaunch
|
||||
} else isFirstLaunch
|
||||
return preferences.getBoolean(keyIsFirstLaunch, true)
|
||||
}
|
||||
|
||||
fun setFirstLaunchDone() {
|
||||
preferences.edit {
|
||||
putBoolean(keyIsFirstLaunch, false)
|
||||
apply()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
tools:context=".ui.splash.SplashActivity">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/splashPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/splashNext"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="76dp"
|
||||
android:contentDescription="@string/placeholder"
|
||||
app:fabSize="mini"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:srcCompat="@drawable/ic_next" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
tools:context=".ui.splash.FirstFragment" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="First Fragment"
|
||||
android:textSize="36sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
tools:context=".ui.splash.FirstFragment" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Second Fragment"
|
||||
android:textSize="36sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
tools:context=".ui.splash.FirstFragment" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Third Fragment"
|
||||
android:textSize="36sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -25,6 +25,7 @@ buildscript {
|
||||
constraint_layout_version = '2.0.4'
|
||||
navigation_version = '2.3.1'
|
||||
preference_version = '1.1.1'
|
||||
view_pager2_version = '1.0.0'
|
||||
room_version = '2.2.5'
|
||||
hilt_version = '2.29.1-alpha'
|
||||
hilt_viewmodel_version = '1.0.0-alpha02'
|
||||
|
||||
Reference in new issue
Block a user