~captainepoch/husky

9e32d3c9bdab3d44623c1d1583f2f008254e170f — Adolfo Santiago a month ago af78abc
Refactor Splash (WIP)
M husky/app/src/main/AndroidManifest.xml => husky/app/src/main/AndroidManifest.xml +15 -2
@@ 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"

A husky/app/src/main/java/com/keylesspalace/tusky/core/di/GlobalServices.kt => husky/app/src/main/java/com/keylesspalace/tusky/core/di/GlobalServices.kt +17 -0
@@ 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()
    }
}

M husky/app/src/main/java/com/keylesspalace/tusky/core/navigation/NavigationActivity.kt => husky/app/src/main/java/com/keylesspalace/tusky/core/navigation/NavigationActivity.kt +12 -9
@@ 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() {
        Timber.d("Navigation setup completely")
    }
}

M husky/app/src/main/java/com/keylesspalace/tusky/core/ui/fragment/BaseFragment.kt => husky/app/src/main/java/com/keylesspalace/tusky/core/ui/fragment/BaseFragment.kt +1 -2
@@ 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)

M husky/app/src/main/java/com/keylesspalace/tusky/core/ui/viewmodel/BaseViewModel.kt => husky/app/src/main/java/com/keylesspalace/tusky/core/ui/viewmodel/BaseViewModel.kt +3 -1
@@ 19,4 19,6 @@

package com.keylesspalace.tusky.core.ui.viewmodel

abstract class BaseViewModel
import com.zhuinden.simplestack.Bundleable

abstract class BaseViewModel : Bundleable

A husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/HuskyApplication.kt => husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/HuskyApplication.kt +26 -0
@@ 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")
        }
    }
}

A husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/fragments/SplashFragment.kt => husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/fragments/SplashFragment.kt +16 -0
@@ 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() }

}

A husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/navigation/SplashKey.kt => husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/navigation/SplashKey.kt +23 -0
@@ 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())
        }
    }
}

A husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/viewmodel/SplashViewModel.kt => husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/viewmodel/SplashViewModel.kt +17 -0
@@ 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 {}
    }
}

M husky/app/src/main/res/drawable/background_splash.xml => husky/app/src/main/res/drawable/background_splash.xml +4 -4
@@ 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>
\ No newline at end of file
</layer-list>

A husky/app/src/main/res/layout/fragment_splash.xml => husky/app/src/main/res/layout/fragment_splash.xml +18 -0
@@ 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>