~captainepoch/husky

22a0efd2732994745660ac73d1114ce4b53fe94d — Adolfo Santiago 3 months ago 68e9138
New flavors: dev and newhusky

As I explained earlier when I took over Husky maintenance, I'm making
changes in the application to add stuff that would make it more
maintenable in the long term, that is, an architecture, new stuff that
would make the application better in performance, while also keeping all
the good stuff of Husky.

The flavor 'newhusky' is for that matter. I'm going to keep working on
keeping Husky maintained, and at the same time I'll make the "new" Husky
in another flavor. It won't change anything because, being two flavors,
releases will be made with the current application, so be patient,
please.
22 files changed, 170 insertions(+), 73 deletions(-)

M husky/app/build.gradle.kts
M husky/app/src/main/java/com/keylesspalace/tusky/core/utils/Flavor.kt
A husky/app/src/newhusky/AndroidManifest.xml
R husky/app/src/{main/java/com/keylesspalace/tusky/refactor_features/HuskyApplication.kt => newhusky/java/com/husky/project/HuskyApplication.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/di/GlobalServices.kt => newhusky/java/com/husky/project/core/di/GlobalServices.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/extensions/LifecycleExt.kt => newhusky/java/com/husky/project/core/extensions/LifecycleExt.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/navigation/NavigationActivity.kt => newhusky/java/com/husky/project/core/navigation/NavigationActivity.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/ui/fragment/BaseBackFragment.kt => newhusky/java/com/husky/project/core/ui/fragment/BaseBackFragment.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/ui/fragment/BaseFragment.kt => newhusky/java/com/husky/project/core/ui/fragment/BaseFragment.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/ui/navigation/BaseKey.kt => newhusky/java/com/husky/project/core/ui/navigation/BaseKey.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/ui/navigation/BaseServiceKey.kt => newhusky/java/com/husky/project/core/ui/navigation/BaseServiceKey.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/ui/viewmodel/BaseViewModel.kt => newhusky/java/com/husky/project/core/ui/viewmodel/BaseViewModel.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/core/ui/viewmodel/RegisteredViewModel.kt => newhusky/java/com/husky/project/core/ui/viewmodel/ServicesViewModel.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/refactor_features/login/view/fragments/LoginFragment.kt => newhusky/java/com/husky/project/features/login/view/fragments/LoginFragment.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/refactor_features/login/view/navigation/LoginKey.kt => newhusky/java/com/husky/project/features/login/view/navigation/LoginKey.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/refactor_features/login/view/viewmodel/LoginViewModel.kt => newhusky/java/com/husky/project/features/login/view/viewmodel/LoginViewModel.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/refactor_features/login/view/viewmodel/LoginViewModelKeys.kt => newhusky/java/com/husky/project/features/login/view/viewmodel/LoginViewModelKeys.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/refactor_features/splash/view/fragments/SplashFragment.kt => newhusky/java/com/husky/project/features/splash/view/fragments/SplashFragment.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/refactor_features/splash/view/navigation/SplashKey.kt => newhusky/java/com/husky/project/features/splash/view/navigation/SplashKey.kt}
R husky/app/src/{main/java/com/keylesspalace/tusky/refactor_features/splash/view/viewmodel/SplashViewModel.kt => newhusky/java/com/husky/project/features/splash/view/viewmodel/SplashViewModel.kt}
M husky/build.gradle.kts
M husky/buildSrc/src/main/kotlin/Dependencies.kt
M husky/app/build.gradle.kts => husky/app/build.gradle.kts +36 -1
@@ 1,5 1,5 @@
import com.project.starter.easylauncher.filter.ColorRibbonFilter
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
import com.project.starter.easylauncher.filter.ColorRibbonFilter

plugins {
    id(AppPlugins.androidApplication)


@@ 81,10 81,34 @@ android {
        )
    )
    productFlavors {
        create(Flavors.newhusky) {
            dimension = Flavors.Dimensions.release

            applicationId = DefaultConfig.NewHusky.applicationID

            minSdk = DefaultConfig.minSdk
            targetSdk = DefaultConfig.targetSdk

            versionCode = DefaultConfig.NewHusky.versionCode
            versionName = DefaultConfig.NewHusky.versionName
        }

        create(Flavors.husky) {
            dimension = Flavors.Dimensions.husky
        }

        create(Flavors.dev) {
            dimension = Flavors.Dimensions.release

            applicationId = DefaultConfig.Dev.applicationID

            minSdk = DefaultConfig.minSdk
            targetSdk = DefaultConfig.targetSdk

            versionCode = DefaultConfig.Dev.versionCode
            versionName = DefaultConfig.Dev.versionName
        }

        create(Flavors.beta) {
            dimension = Flavors.Dimensions.release



@@ 258,5 282,16 @@ easylauncher {
                )
            )
        }

        register(Flavors.newhusky) {
            filters(
                customRibbon(
                    label = "NEW",
                    gravity = ColorRibbonFilter.Gravity.TOPRIGHT,
                    ribbonColor = "#DCDCDC",
                    labelColor = "#000000"
                )
            )
        }
    }
}

M husky/app/src/main/java/com/keylesspalace/tusky/core/utils/Flavor.kt => husky/app/src/main/java/com/keylesspalace/tusky/core/utils/Flavor.kt +3 -1
@@ 22,7 22,8 @@ package com.keylesspalace.tusky.core.utils
enum class Flavor(private val flavor: String) {

    BETA("huskyBeta"),
    STABLE("huskyStable");
    STABLE("huskyStable"),
    NEW_HUSKY("huskyNewhusky");

    companion object {



@@ 35,6 36,7 @@ enum class Flavor(private val flavor: String) {
        fun getFlavor(flavor: String) =
            when(flavor) {
                BETA.flavor -> BETA
                NEW_HUSKY.flavor -> NEW_HUSKY
                else -> STABLE
            }
    }

A husky/app/src/newhusky/AndroidManifest.xml => husky/app/src/newhusky/AndroidManifest.xml +42 -0
@@ 0,0 1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.keylesspalace.tusky">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:name="com.husky.project.HuskyApplication"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/TuskyTheme"
        android:usesCleartextTraffic="false"
        tools:replace="android:name">

        <activity
            android:name="com.husky.project.core.navigation.NavigationActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Remove Husky's LAUNCH original activity -->
        <activity
            android:name=".SplashActivity"
            tools:node="remove" />

        <!-- Disable automatic WorkManager initialization -->
        <provider
            android:name="androidx.work.impl.WorkManagerInitializer"
            android:authorities="${applicationId}.workmanager-init"
            android:exported="false"
            tools:node="remove" />
    </application>

</manifest>

R husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/HuskyApplication.kt => husky/app/src/newhusky/java/com/husky/project/HuskyApplication.kt +1 -1
@@ 1,4 1,4 @@
package com.keylesspalace.tusky.refactor_features
package com.husky.project

import android.app.Application
import com.keylesspalace.tusky.core.logging.HyperlinkDebugTree

R husky/app/src/main/java/com/keylesspalace/tusky/core/di/GlobalServices.kt => husky/app/src/newhusky/java/com/husky/project/core/di/GlobalServices.kt +1 -1
@@ 1,4 1,4 @@
package com.keylesspalace.tusky.core.di
package com.husky.project.core.di

import android.content.Context
import com.zhuinden.simplestack.GlobalServices

R husky/app/src/main/java/com/keylesspalace/tusky/core/extensions/LifecycleExt.kt => husky/app/src/newhusky/java/com/husky/project/core/extensions/LifecycleExt.kt +0 -0
R husky/app/src/main/java/com/keylesspalace/tusky/core/navigation/NavigationActivity.kt => husky/app/src/newhusky/java/com/husky/project/core/navigation/NavigationActivity.kt +3 -3
@@ 17,14 17,14 @@
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package com.keylesspalace.tusky.core.navigation
package com.husky.project.core.navigation

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.keylesspalace.tusky.core.di.HuskyServices
import com.husky.project.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.husky.project.features.splash.view.navigation.SplashKey
import com.zhuinden.simplestack.History
import com.zhuinden.simplestack.SimpleStateChanger
import com.zhuinden.simplestack.StateChange

R husky/app/src/main/java/com/keylesspalace/tusky/core/ui/fragment/BaseBackFragment.kt => husky/app/src/newhusky/java/com/husky/project/core/ui/fragment/BaseBackFragment.kt +1 -1
@@ 1,4 1,4 @@
package com.keylesspalace.tusky.core.ui.fragment
package com.husky.project.core.ui.fragment

abstract class BaseBackFragment(layoutRes: Int) : BaseFragment(layoutRes) {


R husky/app/src/main/java/com/keylesspalace/tusky/core/ui/fragment/BaseFragment.kt => husky/app/src/newhusky/java/com/husky/project/core/ui/fragment/BaseFragment.kt +1 -1
@@ 17,7 17,7 @@
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package com.keylesspalace.tusky.core.ui.fragment
package com.husky.project.core.ui.fragment

import com.zhuinden.simplestackextensions.fragments.KeyedFragment


R husky/app/src/main/java/com/keylesspalace/tusky/core/ui/navigation/BaseKey.kt => husky/app/src/newhusky/java/com/husky/project/core/ui/navigation/BaseKey.kt +1 -1
@@ 17,7 17,7 @@
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package com.keylesspalace.tusky.core.ui.navigation
package com.husky.project.core.ui.navigation

import com.zhuinden.simplestackextensions.fragments.DefaultFragmentKey


R husky/app/src/main/java/com/keylesspalace/tusky/core/ui/navigation/BaseServiceKey.kt => husky/app/src/newhusky/java/com/husky/project/core/ui/navigation/BaseServiceKey.kt +1 -1
@@ 17,7 17,7 @@
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package com.keylesspalace.tusky.core.ui.navigation
package com.husky.project.core.ui.navigation

import com.zhuinden.simplestackextensions.services.DefaultServiceProvider


R husky/app/src/main/java/com/keylesspalace/tusky/core/ui/viewmodel/BaseViewModel.kt => husky/app/src/newhusky/java/com/husky/project/core/ui/viewmodel/BaseViewModel.kt +1 -1
@@ 17,7 17,7 @@
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

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

import com.zhuinden.simplestack.Bundleable


R husky/app/src/main/java/com/keylesspalace/tusky/core/ui/viewmodel/RegisteredViewModel.kt => husky/app/src/newhusky/java/com/husky/project/core/ui/viewmodel/ServicesViewModel.kt +2 -2
@@ 1,10 1,10 @@
package com.keylesspalace.tusky.core.ui.viewmodel
package com.husky.project.core.ui.viewmodel

import com.zhuinden.simplestack.ScopedServices
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable

abstract class RegisteredViewModel : BaseViewModel(), ScopedServices.Registered {
abstract class ServicesViewModel : BaseViewModel(), ScopedServices.Registered {

    private val compositeDisposable = CompositeDisposable()


R husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/login/view/fragments/LoginFragment.kt => husky/app/src/newhusky/java/com/husky/project/features/login/view/fragments/LoginFragment.kt +3 -3
@@ 1,4 1,4 @@
package com.keylesspalace.tusky.refactor_features.login.view.fragments
package com.husky.project.features.login.view.fragments

import android.os.Bundle
import android.view.View


@@ 8,9 8,9 @@ import com.keylesspalace.tusky.core.extensions.addHttpsProtocolUrl
import com.keylesspalace.tusky.core.extensions.dialogWithLink
import com.keylesspalace.tusky.core.extensions.viewBinding
import com.keylesspalace.tusky.core.extensions.viewObserve
import com.keylesspalace.tusky.core.ui.fragment.BaseFragment
import com.husky.project.core.ui.fragment.BaseFragment
import com.keylesspalace.tusky.databinding.ActivityLoginBinding
import com.keylesspalace.tusky.refactor_features.login.view.viewmodel.LoginViewModel
import com.husky.project.features.login.view.viewmodel.LoginViewModel
import com.keylesspalace.tusky.util.afterTextChanged
import com.zhuinden.simplestackextensions.fragmentsktx.lookup


R husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/login/view/navigation/LoginKey.kt => husky/app/src/newhusky/java/com/husky/project/features/login/view/navigation/LoginKey.kt +4 -4
@@ 1,9 1,9 @@
package com.keylesspalace.tusky.refactor_features.login.view.navigation
package com.husky.project.features.login.view.navigation

import androidx.fragment.app.Fragment
import com.keylesspalace.tusky.core.ui.navigation.BaseServiceKey
import com.keylesspalace.tusky.refactor_features.login.view.fragments.LoginFragment
import com.keylesspalace.tusky.refactor_features.login.view.viewmodel.LoginViewModel
import com.husky.project.core.ui.navigation.BaseServiceKey
import com.husky.project.features.login.view.fragments.LoginFragment
import com.husky.project.features.login.view.viewmodel.LoginViewModel
import com.zhuinden.simplestack.ServiceBinder
import com.zhuinden.simplestackextensions.servicesktx.add
import kotlinx.android.parcel.Parcelize

R husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/login/view/viewmodel/LoginViewModel.kt => husky/app/src/newhusky/java/com/husky/project/features/login/view/viewmodel/LoginViewModel.kt +6 -5
@@ 1,13 1,14 @@
package com.keylesspalace.tusky.refactor_features.login.view.viewmodel
package com.husky.project.features.login.view.viewmodel

import android.util.Patterns
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.husky.project.features.login.view.viewmodel.LoginViewModelKeys.Bundle
import com.keylesspalace.tusky.core.extensions.orEmpty
import com.keylesspalace.tusky.core.ui.viewmodel.RegisteredViewModel
import com.husky.project.core.ui.viewmodel.ServicesViewModel
import com.zhuinden.statebundle.StateBundle

class LoginViewModel : RegisteredViewModel() {
class LoginViewModel : ServicesViewModel() {

    private val mVerifyUrl = MutableLiveData<Boolean>()
    val verifyUrl: LiveData<Boolean>


@@ 15,14 16,14 @@ class LoginViewModel : RegisteredViewModel() {

    override fun toBundle(): StateBundle = StateBundle().apply {
        putBoolean(
            LoginViewModelKeys.Bundle.VERIFY_URL,
            Bundle.VERIFY_URL,
            mVerifyUrl.value.orEmpty()
        )
    }

    override fun fromBundle(bundle: StateBundle?) {
        bundle?.run {
            mVerifyUrl.value = getBoolean(LoginViewModelKeys.Bundle.VERIFY_URL)
            mVerifyUrl.value = getBoolean(Bundle.VERIFY_URL)
        }
    }


R husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/login/view/viewmodel/LoginViewModelKeys.kt => husky/app/src/newhusky/java/com/husky/project/features/login/view/viewmodel/LoginViewModelKeys.kt +1 -1
@@ 1,4 1,4 @@
package com.keylesspalace.tusky.refactor_features.login.view.viewmodel
package com.husky.project.features.login.view.viewmodel

sealed class LoginViewModelKeys {


R husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/fragments/SplashFragment.kt => husky/app/src/newhusky/java/com/husky/project/features/splash/view/fragments/SplashFragment.kt +4 -4
@@ 1,13 1,13 @@
package com.keylesspalace.tusky.refactor_features.splash.view.fragments
package com.husky.project.features.splash.view.fragments

import android.os.Bundle
import android.view.View
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.core.extensions.viewBinding
import com.keylesspalace.tusky.core.ui.fragment.BaseFragment
import com.husky.project.core.ui.fragment.BaseFragment
import com.keylesspalace.tusky.databinding.FragmentSplashBinding
import com.keylesspalace.tusky.refactor_features.login.view.navigation.LoginKey
import com.keylesspalace.tusky.refactor_features.splash.view.viewmodel.SplashViewModel
import com.husky.project.features.login.view.navigation.LoginKey
import com.husky.project.features.splash.view.viewmodel.SplashViewModel
import com.zhuinden.simplestack.History
import com.zhuinden.simplestack.StateChange
import com.zhuinden.simplestackextensions.fragmentsktx.backstack

R husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/navigation/SplashKey.kt => husky/app/src/newhusky/java/com/husky/project/features/splash/view/navigation/SplashKey.kt +4 -4
@@ 1,9 1,9 @@
package com.keylesspalace.tusky.refactor_features.splash.view.navigation
package com.husky.project.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.husky.project.core.ui.navigation.BaseServiceKey
import com.husky.project.features.splash.view.fragments.SplashFragment
import com.husky.project.features.splash.view.viewmodel.SplashViewModel
import com.zhuinden.simplestack.ServiceBinder
import com.zhuinden.simplestackextensions.servicesktx.add
import kotlinx.android.parcel.Parcelize

R husky/app/src/main/java/com/keylesspalace/tusky/refactor_features/splash/view/viewmodel/SplashViewModel.kt => husky/app/src/newhusky/java/com/husky/project/features/splash/view/viewmodel/SplashViewModel.kt +2 -2
@@ 1,6 1,6 @@
package com.keylesspalace.tusky.refactor_features.splash.view.viewmodel
package com.husky.project.features.splash.view.viewmodel

import com.keylesspalace.tusky.core.ui.viewmodel.BaseViewModel
import com.husky.project.core.ui.viewmodel.BaseViewModel
import com.zhuinden.statebundle.StateBundle

class SplashViewModel : BaseViewModel() {

M husky/build.gradle.kts => husky/build.gradle.kts +36 -36
@@ 1,48 1,48 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask

buildscript {
	addRepos(repositories)
    addRepos(repositories)

	dependencies {
		// Base
		classpath(GradlePlugins.android)
		classpath(GradlePlugins.kotlin)
    dependencies {
        // Base
        classpath(GradlePlugins.android)
        classpath(GradlePlugins.kotlin)

		// Plugins
		classpath(GradlePlugins.gradleVersions)
	}
        // Plugins
        classpath(GradlePlugins.gradleVersions)
    }
}

allprojects {
	addRepos(repositories)

	tasks.withType<JavaCompile> {
		options.encoding = DefaultConfig.encoding
		options.compilerArgs.addAll(
			listOf(
				"-Xlint:all",
				"-Xlint:unchecked",
				"-Xlint:-deprecation"
			)
		)
	}

	apply {
		plugin(AppPlugins.manesVersions)
	}

	tasks.withType<DependencyUpdatesTask> {
		gradleReleaseChannel = "current"

		rejectVersionIf {
			!isNonStable(candidate.version)
		}
	}
    addRepos(repositories)

    tasks.withType<JavaCompile> {
        options.encoding = DefaultConfig.encoding
        options.compilerArgs.addAll(
            listOf(
                "-Xlint:all",
                "-Xlint:unchecked",
                "-Xlint:-deprecation"
            )
        )
    }

    apply {
        plugin(AppPlugins.manesVersions)
    }

    tasks.withType<DependencyUpdatesTask> {
        gradleReleaseChannel = "current"

        rejectVersionIf {
            !isNonStable(candidate.version)
        }
    }
}

tasks.register<Delete>(BuildTasks.taskTypeClean) {
	delete(buildDir)
	delete("${projectDir}/buildSrc/build")
	delete("${projectDir}/app/huskyBeta")
	delete("${projectDir}/app/huskyStable")
    delete(buildDir)
    delete("${projectDir}/buildSrc/build")
    delete("${projectDir}/app/huskyBeta")
    delete("${projectDir}/app/huskyStable")
}

M husky/buildSrc/src/main/kotlin/Dependencies.kt => husky/buildSrc/src/main/kotlin/Dependencies.kt +17 -0
@@ 30,6 30,20 @@ object DefaultConfig {
    const val instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

    const val encoding = "UTF-8"

    object Dev {
        const val applicationID = "su.xash.husky.dev"

        const val versionCode = 1
        const val versionName = "1.0.0"
    }

    object NewHusky {
        const val applicationID = "su.xash.husky.alpha"

        const val versionCode = 1
        const val versionName = "2.0.0"
    }
}

object BetaConfig {


@@ 49,8 63,11 @@ object Flavors {
    }

    const val husky = "husky"
    const val dev = "dev"
    const val beta = "beta"
    const val stable = "stable"

    const val newhusky = "newhusky"
}

object ProguardFile {