Remove newHusky flavor

This commit is contained in:
Adolfo Santiago 2022-05-09 13:44:20 +02:00
parent 43b2e5e9bd
commit d4fea4419a
No known key found for this signature in database
GPG Key ID: 244D6F9A317B4A65
21 changed files with 0 additions and 608 deletions

View File

@ -70,21 +70,6 @@ android {
flavorDimensions buildVersions.flavorDimensions.husky, buildVersions.flavorDimensions.release
productFlavors {
newhusky {
dimension buildVersions.flavorDimensions.release
applicationId buildVersions.newHusky.applicationId
compileSdkVersion buildVersions.newHusky.compileSdk
minSdkVersion buildVersions.newHusky.minSdk
targetSdkVersion buildVersions.newHusky.targetSdk
versionCode buildVersions.newHusky.versionCode
versionName buildVersions.newHusky.versionName
versionNameSuffix = "-${buildVersions.newHusky.suffix}"
}
husky {
dimension buildVersions.flavorDimensions.husky
}

View File

@ -21,18 +21,6 @@
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">

View File

@ -1,42 +0,0 @@
<?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>

View File

@ -1,26 +0,0 @@
package com.husky.project
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

@ -1,16 +0,0 @@
package com.husky.project.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

@ -1,9 +0,0 @@
package com.husky.project.core.extensions
import kotlinx.coroutines.Job
fun Job?.cancelIfActive() {
if(this?.isActive == true) {
this.cancel()
}
}

View File

@ -1,32 +0,0 @@
/*
* Husky -- A Pleroma client for Android
*
* Copyright (C) 2021 The Husky Developers
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
package com.husky.project.core.extensions
import androidx.fragment.app.Fragment
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
fun <T : Any, L : LiveData<T>> Fragment.viewObserve(liveData: L, body: (T?) -> Unit) =
liveData.observe(viewLifecycleOwner, Observer(body))
/*fun <L : LiveData<Failure>> Fragment.viewFailureObserve(
liveData: L,
body: (Failure?) -> Unit
) = liveData.observe(viewLifecycleOwner, Observer(body))*/

View File

@ -1,87 +0,0 @@
/*
* Husky -- A Pleroma client for Android
*
* Copyright (C) 2021 The Husky Developers
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
package com.husky.project.core.navigation
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.husky.project.core.di.HuskyServices
import com.husky.project.core.ui.fragment.BaseFragment
import com.husky.project.core.ui.navigation.BaseKey
import com.husky.project.features.splash.view.navigation.SplashKey
import com.keylesspalace.tusky.core.extensions.viewBinding
import com.keylesspalace.tusky.databinding.ActivityNavigationBinding
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 {
private val binding by viewBinding(ActivityNavigationBinding::inflate)
private lateinit var fragmentStateChanger: DefaultFragmentStateChanger
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
initNavigation()
}
override fun onBackPressed() {
val currentFragment = supportFragmentManager.findFragmentByTag(
backstack.top<BaseKey>().fragmentTag
)
if(currentFragment is BaseFragment && currentFragment.onHandleBack()) {
Timber.i("Handled back from Fragment[${currentFragment.tag}]")
if(!backstack.goBack()) {
Timber.i("No keys found, exiting the application...")
this.finish()
}
}
}
override fun onNavigationEvent(stateChange: StateChange) {
fragmentStateChanger.handleStateChange(stateChange)
}
private fun initNavigation() {
fragmentStateChanger = DefaultFragmentStateChanger(
supportFragmentManager,
binding.fragmentContainer.id
)
Navigator.configure()
.setStateChanger(SimpleStateChanger(this))
.setScopedServices(DefaultServiceProvider())
.setGlobalServices(HuskyServices(applicationContext).getGlobalServices())
.install(
this,
binding.fragmentContainer,
History.single(SplashKey())
)
Timber.d("Navigation setup completely")
}
}

View File

@ -1,30 +0,0 @@
/*
* Husky -- A Pleroma client for Android
*
* Copyright (C) 2021 The Husky Developers
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
package com.husky.project.core.ui.fragment
import androidx.annotation.LayoutRes
import com.zhuinden.simplestackextensions.fragments.KeyedFragment
open class BaseFragment(@LayoutRes layoutRes: Int) : KeyedFragment(layoutRes) {
fun onHandleBack(): Boolean {
return true
}
}

View File

@ -1,27 +0,0 @@
/*
* Husky -- A Pleroma client for Android
*
* Copyright (C) 2021 The Husky Developers
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
package com.husky.project.core.ui.navigation
import com.zhuinden.simplestackextensions.fragments.DefaultFragmentKey
abstract class BaseKey : DefaultFragmentKey() {
override fun getFragmentTag(): String = this.javaClass.name
}

View File

@ -1,27 +0,0 @@
/*
* Husky -- A Pleroma client for Android
*
* Copyright (C) 2021 The Husky Developers
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
package com.husky.project.core.ui.navigation
import com.zhuinden.simplestackextensions.services.DefaultServiceProvider
abstract class BaseServiceKey : BaseKey(), DefaultServiceProvider.HasServices {
override fun getScopeTag(): String = this.javaClass.name
}

View File

@ -1,33 +0,0 @@
/*
* Husky -- A Pleroma client for Android
*
* Copyright (C) 2021 The Husky Developers
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
package com.husky.project.core.ui.viewmodel
import com.zhuinden.simplestack.Bundleable
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
abstract class BaseViewModel : Bundleable {
val viewModelScope: CoroutineScope
get() {
return CloseableCoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
}
}

View File

@ -1,31 +0,0 @@
/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.husky.project.core.ui.viewmodel
import java.io.Closeable
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
internal class CloseableCoroutineScope(context: CoroutineContext) : Closeable, CoroutineScope {
override val coroutineContext: CoroutineContext = context
override fun close() {
coroutineContext.cancel()
}
}

View File

@ -1,69 +0,0 @@
package com.husky.project.features.login.view.fragments
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AlertDialog
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.core.extensions.addHttpsProtocolUrl
import com.keylesspalace.tusky.core.extensions.dialogWithLink
import com.keylesspalace.tusky.core.extensions.viewBinding
import com.husky.project.core.extensions.viewObserve
import com.husky.project.core.ui.fragment.BaseFragment
import com.keylesspalace.tusky.databinding.ActivityLoginBinding
import com.husky.project.features.login.view.viewmodel.LoginViewModel
import com.keylesspalace.tusky.util.afterTextChanged
import com.zhuinden.simplestackextensions.fragmentsktx.lookup
class LoginFragment : BaseFragment(R.layout.activity_login) {
private val binding by viewBinding(ActivityLoginBinding::bind)
private val viewModel by lazy { lookup<LoginViewModel>() }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initObservers()
initListeners()
}
private fun initObservers() {
with(viewModel) {
viewObserve(verifyUrl, ::handleVerifyUrl)
}
}
private fun initListeners() {
binding.domainEditText.afterTextChanged {
if(it.isEmpty()) {
setDomainUrlError(false)
}
}
binding.loginButton.setOnClickListener {
viewModel.verifyUrl(binding.domainEditText.text.toString().addHttpsProtocolUrl())
}
binding.whatsAnInstanceTextView.setOnClickListener {
AlertDialog.Builder(requireActivity()).dialogWithLink(
getString(R.string.dialog_whats_an_instance),
getString(R.string.action_close)
)
}
}
private fun handleVerifyUrl(isValid: Boolean?) {
isValid?.let { valid ->
if(valid == true) {
}
setDomainUrlError(isValid)
}
}
private fun setDomainUrlError(isValid: Boolean) {
binding.domainTextInputLayout.error = if(isValid) {
null
} else {
getString(R.string.error_invalid_domain)
}
}
}

View File

@ -1,23 +0,0 @@
package com.husky.project.features.login.view.navigation
import androidx.fragment.app.Fragment
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
@Parcelize
class LoginKey : BaseServiceKey() {
override fun instantiateFragment(): Fragment {
return LoginFragment()
}
override fun bindServices(serviceBinder: ServiceBinder) {
with(serviceBinder) {
add(LoginViewModel())
}
}
}

View File

@ -1,42 +0,0 @@
package com.husky.project.features.login.view.viewmodel
import android.util.Patterns
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.husky.project.core.extensions.cancelIfActive
import com.husky.project.core.ui.viewmodel.BaseViewModel
import com.husky.project.features.login.view.viewmodel.LoginViewModelKeys.Bundle
import com.keylesspalace.tusky.core.extensions.orEmpty
import com.zhuinden.statebundle.StateBundle
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
class LoginViewModel : BaseViewModel() {
private var ver: Job? = null
private val _verifyUrl = MutableLiveData<Boolean>()
val verifyUrl: LiveData<Boolean>
get() = _verifyUrl
override fun toBundle(): StateBundle = StateBundle().apply {
putBoolean(
Bundle.VERIFY_URL,
_verifyUrl.value.orEmpty()
)
}
override fun fromBundle(bundle: StateBundle?) {
bundle?.run {
_verifyUrl.value = getBoolean(Bundle.VERIFY_URL)
}
}
fun verifyUrl(url: String) {
ver?.cancelIfActive()
ver = viewModelScope.launch {
}
_verifyUrl.value = Patterns.WEB_URL.matcher(url).matches()
}
}

View File

@ -1,8 +0,0 @@
package com.husky.project.features.login.view.viewmodel
sealed class LoginViewModelKeys {
object Bundle {
const val VERIFY_URL = "verifyUrl"
}
}

View File

@ -1,26 +0,0 @@
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.husky.project.core.ui.fragment.BaseFragment
import com.keylesspalace.tusky.databinding.FragmentSplashBinding
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
import com.zhuinden.simplestackextensions.fragmentsktx.lookup
class SplashFragment : BaseFragment(R.layout.fragment_splash) {
private val binding by viewBinding(FragmentSplashBinding::bind)
private val viewModel by lazy { lookup<SplashViewModel>() }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
backstack.setHistory(History.single(LoginKey()), StateChange.FORWARD)
}
}

View File

@ -1,23 +0,0 @@
package com.husky.project.features.splash.view.navigation
import androidx.fragment.app.Fragment
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
@Parcelize
class SplashKey : BaseServiceKey() {
override fun instantiateFragment(): Fragment {
return SplashFragment()
}
override fun bindServices(serviceBinder: ServiceBinder) {
with(serviceBinder) {
add(SplashViewModel())
}
}
}

View File

@ -1,17 +0,0 @@
package com.husky.project.features.splash.view.viewmodel
import com.husky.project.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

@ -30,19 +30,6 @@ dev.versionCode = 1
dev.versionName = "1.0.0"
buildVersions.dev = dev
// Husky refactor info
def newHusky = [:]
newHusky.suffix = "newHusky"
newHusky.applicationId = "su.xash.husky.${newHusky.suffix}"
newHusky.compileSdk = 30
newHusky.minSdk = 23
newHusky.targetSdk = 30
newHusky.versionCode = 1
newHusky.versionName = "2.0.0"
buildVersions.newHusky = newHusky
// Flavors dimensions
def flavorDimensions = [:]
flavorDimensions.husky = "husky"