Refactor Splash (WIP)

This commit is contained in:
Adolfo Santiago 2021-11-20 18:04:49 +01:00
parent af78abcc0a
commit 9e32d3c9bd
No known key found for this signature in database
GPG key ID: 244D6F9A317B4A65
11 changed files with 152 additions and 18 deletions

View file

@ -20,6 +20,19 @@
android:supportsRtl="true"
android:theme="@style/TuskyTheme"
android:usesCleartextTraffic="false">
<!--
<activity
android:name=".core.navigation.NavigationActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-->
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
@ -108,7 +121,7 @@
android:windowSoftInputMode="stateVisible|adjustResize" />
<activity
android:name=".components.chat.ChatActivity"
android:windowSoftInputMode="stateVisible|adjustResize"/>
android:windowSoftInputMode="stateVisible|adjustResize" />
<activity
android:name=".ViewThreadActivity"
android:configChanges="orientation|screenSize" />
@ -182,7 +195,7 @@
android:resource="@xml/file_paths" />
</provider>
<!-- disable automatic WorkManager initialization -->
<!-- Disable automatic WorkManager initialization -->
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"

View file

@ -0,0 +1,17 @@
package com.keylesspalace.tusky.core.di
import android.content.Context
import com.zhuinden.simplestack.GlobalServices
class HuskyServices(private val appContext: Context) {
fun getGlobalServices() : GlobalServices {
val builder = GlobalServices.builder()
with(builder) {
}
return builder.build()
}
}

View file

@ -22,12 +22,17 @@ package com.keylesspalace.tusky.core.navigation
import android.os.Bundle
import android.os.PersistableBundle
import androidx.appcompat.app.AppCompatActivity
import com.keylesspalace.tusky.core.di.HuskyServices
import com.keylesspalace.tusky.core.extensions.viewBinding
import com.keylesspalace.tusky.databinding.ActivityNavigationBinding
import com.keylesspalace.tusky.refactor_features.splash.view.navigation.SplashKey
import com.zhuinden.simplestack.History
import com.zhuinden.simplestack.SimpleStateChanger
import com.zhuinden.simplestack.StateChange
import com.zhuinden.simplestack.navigator.Navigator
import com.zhuinden.simplestackextensions.fragments.DefaultFragmentStateChanger
import com.zhuinden.simplestackextensions.navigatorktx.backstack
import com.zhuinden.simplestackextensions.services.DefaultServiceProvider
import timber.log.Timber
class NavigationActivity : AppCompatActivity(), SimpleStateChanger.NavigationHandler {
@ -43,8 +48,8 @@ class NavigationActivity : AppCompatActivity(), SimpleStateChanger.NavigationHan
}
override fun onBackPressed() {
if(!Navigator.onBackPressed(this)) {
Timber.i("No keys found, exiting the application.")
if(!backstack.goBack()) {
Timber.i("No keys found, exiting the application...")
this.finishAndRemoveTask()
}
@ -55,25 +60,23 @@ class NavigationActivity : AppCompatActivity(), SimpleStateChanger.NavigationHan
}
private fun initNavigation() {
Timber.d("Init setup navigation")
fragmentStateChanger = DefaultFragmentStateChanger(
supportFragmentManager,
binding.fragmentContainer.id
)
/*
Navigator.configure()
.setStateChanger(SimpleStateChanger(this))
.setScopedServices(DefaultServiceProvider())
//.setGlobalServices(GlobalServices(applicationContext).getGlobalServices())
.setGlobalServices(HuskyServices(applicationContext).getGlobalServices())
.install(
this,
binding.fragmentContainer,
getHistoryKeys()
History.single(SplashKey())
)
*/
Timber.d("Navigation setup completely")
}
private fun getHistoryKeys() {
}
}

View file

@ -21,5 +21,4 @@ package com.keylesspalace.tusky.core.ui.fragment
import com.zhuinden.simplestackextensions.fragments.KeyedFragment
open class BaseFragment(layoutRes: Int) : KeyedFragment(layoutRes) {
}
open class BaseFragment(layoutRes: Int) : KeyedFragment(layoutRes)

View file

@ -19,4 +19,6 @@
package com.keylesspalace.tusky.core.ui.viewmodel
abstract class BaseViewModel
import com.zhuinden.simplestack.Bundleable
abstract class BaseViewModel : Bundleable

View file

@ -0,0 +1,26 @@
package com.keylesspalace.tusky.refactor_features
import android.app.Application
import com.keylesspalace.tusky.core.logging.HyperlinkDebugTree
import com.keylesspalace.tusky.core.utils.ApplicationUtils
import timber.log.Timber
class HuskyApplication : Application() {
override fun onCreate() {
super.onCreate()
enableDebugConfig()
}
/**
* Enable debug settings at startup.
*/
private fun enableDebugConfig() {
if(ApplicationUtils.isDebug()) {
Timber.plant(HyperlinkDebugTree())
Timber.d("Debug config enabled")
}
}
}

View file

@ -0,0 +1,16 @@
package com.keylesspalace.tusky.refactor_features.splash.view.fragments
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.core.extensions.viewBinding
import com.keylesspalace.tusky.core.ui.fragment.BaseFragment
import com.keylesspalace.tusky.databinding.FragmentSplashBinding
import com.keylesspalace.tusky.refactor_features.splash.view.viewmodel.SplashViewModel
import com.zhuinden.simplestackextensions.fragmentsktx.lookup
class SplashFragment : BaseFragment(R.layout.fragment_splash) {
private val binding by viewBinding(FragmentSplashBinding::bind)
private val viewModel: SplashViewModel by lazy { lookup() }
}

View file

@ -0,0 +1,23 @@
package com.keylesspalace.tusky.refactor_features.splash.view.navigation
import androidx.fragment.app.Fragment
import com.keylesspalace.tusky.core.ui.navigation.BaseServiceKey
import com.keylesspalace.tusky.refactor_features.splash.view.fragments.SplashFragment
import com.keylesspalace.tusky.refactor_features.splash.view.viewmodel.SplashViewModel
import com.zhuinden.simplestack.ServiceBinder
import com.zhuinden.simplestackextensions.servicesktx.add
import kotlinx.android.parcel.Parcelize
@Parcelize
class SplashKey : BaseServiceKey() {
override fun instantiateFragment(): Fragment {
return SplashFragment()
}
override fun bindServices(serviceBinder: ServiceBinder) {
with(serviceBinder) {
add(SplashViewModel())
}
}
}

View file

@ -0,0 +1,17 @@
package com.keylesspalace.tusky.refactor_features.splash.view.viewmodel
import com.keylesspalace.tusky.core.ui.viewmodel.BaseViewModel
import com.zhuinden.statebundle.StateBundle
class SplashViewModel : BaseViewModel() {
override fun toBundle(): StateBundle {
val stateBundle = StateBundle()
return stateBundle
}
override fun fromBundle(bundle: StateBundle?) {
bundle?.let {}
}
}

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/tusky_grey_20"/>
<color android:color="@color/tusky_grey_20" />
</item>
<item>
<bitmap
android:src="@drawable/splash"
android:gravity="center" />
android:gravity="center"
android:src="@drawable/splash" />
</item>
</layer-list>
</layer-list>

View file

@ -0,0 +1,18 @@
<?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">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/background_splash"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
</androidx.constraintlayout.widget.ConstraintLayout>