Skip to content

Commit

Permalink
Onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
Pengwius committed Jul 12, 2024
1 parent 2bca012 commit ff6da51
Show file tree
Hide file tree
Showing 16 changed files with 355 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ ext {

dependencies {
// implementation 'com.github.wulkanowy:sdk:master-SNAPSHOT'
implementation 'com.github.Pengwius:wulkanowy-sdk:master-SNAPSHOT'
// implementation 'com.github.Pengwius.wulkanowy-sdk:build:9ab339303b'
// implementation 'com.github.Pengwius:wulkanowy-sdk:master-SNAPSHOT'
implementation 'com.github.Pengwius.wulkanowy-sdk:build:7530e23907'
// implementation("io.github.freewulkanowy.sdk")

coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
Expand Down
Binary file modified app/fdroid/release/baselineProfiles/0/app-fdroid-release.dm
Binary file not shown.
Binary file modified app/fdroid/release/baselineProfiles/1/app-fdroid-release.dm
Binary file not shown.
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.modules.onboarding.OnboardingActivity"
android:exported="true"
android:configChanges="orientation|screenSize"
android:label="@string/login_title"
android:theme="@style/WulkanowyTheme.Login"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.modules.login.LoginActivity"
android:configChanges="orientation|screenSize"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/io/github/freewulkanowy/WulkanowyApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.util.Log.DEBUG
import android.util.Log.INFO
import android.util.Log.VERBOSE
import androidx.hilt.work.HiltWorkerFactory
import androidx.preference.PreferenceManager
import androidx.work.Configuration
import com.yariksoffice.lingver.Lingver
import dagger.hilt.android.HiltAndroidApp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager.POP_BACK_STACK_INCLUSIVE
import androidx.fragment.app.commit
import androidx.preference.PreferenceManager
import dagger.hilt.android.AndroidEntryPoint
import io.github.freewulkanowy.R
import io.github.freewulkanowy.data.pojos.RegisterUser
Expand All @@ -22,6 +23,7 @@ import io.github.freewulkanowy.ui.modules.login.studentselect.LoginStudentSelect
import io.github.freewulkanowy.ui.modules.login.symbol.LoginSymbolFragment
import io.github.freewulkanowy.ui.modules.main.MainActivity
import io.github.freewulkanowy.ui.modules.notifications.NotificationsFragment
import io.github.freewulkanowy.ui.modules.onboarding.OnboardingActivity
import io.github.freewulkanowy.utils.AppInfo
import io.github.freewulkanowy.utils.InAppUpdateHelper
import javax.inject.Inject
Expand Down Expand Up @@ -49,6 +51,15 @@ class LoginActivity : BaseActivity<LoginPresenter, ActivityLoginBinding>(), Logi
messageContainer = binding.loginContainer
inAppUpdateHelper.messageContainer = binding.loginContainer

val prefs = PreferenceManager.getDefaultSharedPreferences(this)
val hasCompletedOnboarding = prefs.getBoolean("completedOnboarding", false)

if (!hasCompletedOnboarding) {
val onboardingIntent = Intent(this, OnboardingActivity::class.java)
startActivity(onboardingIntent)
finish()
}

presenter.onAttachView(this)
inAppUpdateHelper.checkAndInstallUpdates()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.elevation.ElevationOverlayProvider
import com.ncapdevi.fragnav.FragNavController
Expand All @@ -33,6 +34,7 @@ import io.github.freewulkanowy.ui.modules.Destination
import io.github.freewulkanowy.ui.modules.account.accountquick.AccountQuickDialog
import io.github.freewulkanowy.ui.modules.auth.AuthDialog
import io.github.freewulkanowy.ui.modules.captcha.CaptchaDialog
import io.github.freewulkanowy.ui.modules.onboarding.OnboardingActivity
import io.github.freewulkanowy.ui.modules.settings.appearance.menuorder.AppMenuItem
import io.github.freewulkanowy.utils.AnalyticsHelper
import io.github.freewulkanowy.utils.AppInfo
Expand Down Expand Up @@ -114,6 +116,15 @@ class MainActivity : BaseActivity<MainPresenter, ActivityMainBinding>(), MainVie
setContentView(ActivityMainBinding.inflate(layoutInflater).apply { binding = this }.root)
setSupportActionBar(binding.mainToolbar)

val prefs = PreferenceManager.getDefaultSharedPreferences(this)
val hasCompletedOnboarding = prefs.getBoolean("completedOnboarding", false)

if (!hasCompletedOnboarding) {
val onboardingIntent = Intent(this, OnboardingActivity::class.java)
startActivity(onboardingIntent)
finish()
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
WindowCompat.setDecorFitsSystemWindows(window, false)
binding.mainAppBar.isLifted = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.github.freewulkanowy.ui.modules.onboarding

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import io.github.freewulkanowy.R
import io.github.freewulkanowy.databinding.FragmentOnboarding1Binding
import io.github.freewulkanowy.ui.base.BaseFragment

class Onboarding1Fragment : BaseFragment<FragmentOnboarding1Binding>(R.layout.fragment_onboarding_1),
OnboardingView {

companion object {
fun newInstance() = Onboarding1Fragment()
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_onboarding_1, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentOnboarding1Binding.bind(view)

binding.onboardingNextBtn.setOnClickListener {
val newFragment = Onboarding2Fragment()
val transaction = parentFragmentManager.beginTransaction()
transaction.replace(R.id.onboardingContainer, newFragment)
transaction.commit()
}
}

override fun initView() {
(requireActivity() as OnboardingActivity)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.github.freewulkanowy.ui.modules.onboarding

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.preference.PreferenceManager
import io.github.freewulkanowy.R
import io.github.freewulkanowy.databinding.FragmentOnboarding2Binding
import io.github.freewulkanowy.ui.base.BaseFragment
import io.github.freewulkanowy.ui.modules.main.MainActivity

class Onboarding2Fragment : BaseFragment<FragmentOnboarding2Binding>(R.layout.fragment_onboarding_2),
OnboardingView {

companion object {
fun newInstance() = Onboarding2Fragment()
}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_onboarding_2, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding = FragmentOnboarding2Binding.bind(view)

binding.onboardingCloseBtn.setOnClickListener {
val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
prefs.edit().putBoolean("completedOnboarding", true).apply()
startActivity(Intent(requireContext(), MainActivity::class.java))
requireActivity().finish()
}
}

override fun initView() {
(requireActivity() as OnboardingActivity)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.github.freewulkanowy.ui.modules.onboarding

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager.POP_BACK_STACK_INCLUSIVE
import androidx.fragment.app.commit
import dagger.hilt.android.AndroidEntryPoint
import io.github.freewulkanowy.R
import io.github.freewulkanowy.databinding.ActivityOnboardingBinding
import io.github.freewulkanowy.ui.base.BaseActivity
import io.github.freewulkanowy.utils.AppInfo
import io.github.freewulkanowy.utils.InAppUpdateHelper
import javax.inject.Inject

@AndroidEntryPoint
class OnboardingActivity : BaseActivity<OnboardingPresenter, ActivityOnboardingBinding>(), OnboardingView {

@Inject
override lateinit var presenter: OnboardingPresenter

@Inject
lateinit var inAppUpdateHelper: InAppUpdateHelper

@Inject
lateinit var appInfo: AppInfo

companion object {
fun getStartIntent(context: Context) = Intent(context, OnboardingActivity::class.java)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(ActivityOnboardingBinding.inflate(layoutInflater).apply { binding = this }.root)

presenter.onAttachView(this)
inAppUpdateHelper.checkAndInstallUpdates()

if (savedInstanceState == null) {
openFragment(Onboarding1Fragment.newInstance(), clearBackStack = true)
}
}

override fun initView() {}

private fun openFragment(fragment: Fragment, clearBackStack: Boolean = false) {
supportFragmentManager.popBackStack(fragment::class.java.name, POP_BACK_STACK_INCLUSIVE)

supportFragmentManager.commit {
replace(R.id.onboardingContainer, fragment)
setReorderingAllowed(true)
if (!clearBackStack) addToBackStack(fragment::class.java.name)
}
}

override fun onResume() {
super.onResume()
inAppUpdateHelper.onResume()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.freewulkanowy.ui.modules.onboarding

import io.github.freewulkanowy.data.repositories.StudentRepository
import io.github.freewulkanowy.ui.base.BasePresenter
import io.github.freewulkanowy.ui.base.ErrorHandler
import timber.log.Timber
import javax.inject.Inject

class OnboardingPresenter @Inject constructor(
errorHandler: ErrorHandler,
studentRepository: StudentRepository,
) : BasePresenter<OnboardingView>(errorHandler, studentRepository) {

override fun onAttachView(view: OnboardingView) {
super.onAttachView(view)
view.initView()
Timber.i("Onboarding view was initialized")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.freewulkanowy.ui.modules.onboarding

import io.github.freewulkanowy.ui.base.BaseView

interface OnboardingView : BaseView {

fun initView()
}
14 changes: 14 additions & 0 deletions app/src/main/res/layout/activity_onboarding.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/onboardingContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
tools:layout="@layout/fragment_onboarding_1" />

</androidx.constraintlayout.widget.ConstraintLayout>
66 changes: 66 additions & 0 deletions app/src/main/res/layout/fragment_onboarding_1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:fillViewport="true">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/onboardingIcon"
android:layout_width="96dp"
android:layout_height="96dp"
android:layout_marginTop="32dp"
android:src="@mipmap/ic_launcher"
app:layout_constraintBottom_toTopOf="@id/onboarding1Text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:srcCompat="@drawable/ic_launcher_foreground_mono" />

<TextView
android:id="@+id/onboarding1Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="16dp"
android:fontFamily="sans-serif-medium"
android:gravity="center"
android:text="@string/onboarding_1_title"
android:textSize="28sp"
app:layout_constraintBottom_toTopOf="@id/onboarding1Description"
app:layout_constraintTop_toBottomOf="@id/onboardingIcon" />

<TextView
android:id="@+id/onboarding1Description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="32dp"
android:layout_marginTop="16dp"
android:gravity="center"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@id/onboardingNextBtn"
app:layout_constraintTop_toBottomOf="@id/onboarding1Text"
tools:maxLines="15"
android:text="@string/onboarding_1_message" />

<com.google.android.material.button.MaterialButton
android:id="@+id/onboardingNextBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:layout_marginBottom="32dp"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:textSize="16sp"
android:text="@string/onboarding_next_btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:ignore="MissingConstraints" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Loading

0 comments on commit ff6da51

Please sign in to comment.