From 5ef967f097676176f30b432b393d52cfd524ea97 Mon Sep 17 00:00:00 2001 From: X1nto Date: Fri, 8 Oct 2021 15:19:15 +0400 Subject: [PATCH] fuck crowdin --- app/build.gradle.kts | 7 ---- .../main/java/com/vanced/manager/core/App.kt | 32 +----------------- .../com/vanced/manager/ui/MainActivity.kt | 32 +----------------- .../ui/fragments/DevSettingsFragment.kt | 33 ------------------- .../manager/ui/fragments/HomeFragment.kt | 4 +-- .../manager/ui/viewmodels/HomeViewModel.kt | 2 -- .../vanced/manager/utils/LanguageHelper.kt | 27 --------------- 7 files changed, 3 insertions(+), 134 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 15ae5f06..a7e04f3f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -24,10 +24,6 @@ android { } buildConfigField("String[]", "MANAGER_LANGUAGES", "{$languages}") - buildConfigField("Boolean", "ENABLE_CROWDIN_AUTH", "false") - buildConfigField("String", "CROWDIN_HASH", "\"${System.getenv("CROWDIN_HASH")}\"") - buildConfigField("String", "CROWDIN_CLIENT_ID", "\"${System.getenv("CROWDIN_CLIENT_ID")}\"") - buildConfigField("String", "CROWDIN_CLIENT_SECRET", "\"${System.getenv("CROWDIN_CLIENT_SECRET")}\"") } lint { @@ -133,9 +129,6 @@ dependencies { // JSON parser implementation("com.beust:klaxon:5.5") - // Crowdin - implementation("com.github.crowdin.mobile-sdk-android:sdk:1.4.7") - // HTTP networking implementation("com.github.kittinunf.fuel:fuel:2.3.1") implementation("com.github.kittinunf.fuel:fuel-coroutines:2.3.1") diff --git a/app/src/main/java/com/vanced/manager/core/App.kt b/app/src/main/java/com/vanced/manager/core/App.kt index 54cace32..37b468c1 100644 --- a/app/src/main/java/com/vanced/manager/core/App.kt +++ b/app/src/main/java/com/vanced/manager/core/App.kt @@ -1,14 +1,8 @@ package com.vanced.manager.core import android.app.Application -import android.content.res.Configuration import androidx.preference.PreferenceManager.getDefaultSharedPreferences -import com.crowdin.platform.Crowdin -import com.crowdin.platform.CrowdinConfig -import com.crowdin.platform.data.model.AuthConfig -import com.crowdin.platform.data.remote.NetworkType import com.vanced.manager.BuildConfig.* -import com.vanced.manager.utils.AppUtils.log import com.vanced.manager.utils.loadJson import com.vanced.manager.utils.managerAccent import com.vanced.manager.utils.mutableAccentColor @@ -17,7 +11,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch -open class App : Application() { +class App : Application() { private val prefs by lazy { getDefaultSharedPreferences(this) } private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) @@ -26,30 +20,6 @@ open class App : Application() { scope.launch { loadJson(this@App) } super.onCreate() mutableAccentColor.value = prefs.managerAccent - Crowdin.init( - this, - CrowdinConfig.Builder().apply { - withDistributionHash(CROWDIN_HASH) - withNetworkType(NetworkType.WIFI) - if (ENABLE_CROWDIN_AUTH) { - if (prefs.getBoolean("crowdin_real_time", false)) - withRealTimeUpdates() - - withSourceLanguage("en") - withAuthConfig(AuthConfig(CROWDIN_CLIENT_ID, CROWDIN_CLIENT_SECRET, null)) - withScreenshotEnabled() - log("test", "crowdin credentials") - } - }.build() - ) - - if (prefs.getBoolean("crowdin_upload_screenshot", false)) - Crowdin.registerScreenShotContentObserver(this) - } - override fun onConfigurationChanged(newConfig: Configuration) { - super.onConfigurationChanged(newConfig) - Crowdin.onConfigurationChanged() - } } diff --git a/app/src/main/java/com/vanced/manager/ui/MainActivity.kt b/app/src/main/java/com/vanced/manager/ui/MainActivity.kt index 22f60c50..e00c8433 100644 --- a/app/src/main/java/com/vanced/manager/ui/MainActivity.kt +++ b/app/src/main/java/com/vanced/manager/ui/MainActivity.kt @@ -15,10 +15,7 @@ import androidx.navigation.findNavController import androidx.navigation.ui.AppBarConfiguration import androidx.navigation.ui.setupWithNavController import androidx.preference.PreferenceManager.getDefaultSharedPreferences -import com.crowdin.platform.Crowdin -import com.crowdin.platform.LoadingStateListener import com.google.firebase.messaging.FirebaseMessaging -import com.vanced.manager.BuildConfig.ENABLE_CROWDIN_AUTH import com.vanced.manager.BuildConfig.VERSION_CODE import com.vanced.manager.R import com.vanced.manager.databinding.ActivityMainBinding @@ -40,23 +37,9 @@ class MainActivity : AppCompatActivity() { lateinit var binding: ActivityMainBinding private val navHost by lazy { findNavController(R.id.nav_host) } - private val loadingObserver = object : LoadingStateListener { - val tag = "VMLocalisation" - override fun onDataChanged() { - log(tag, "Loaded data") - } - - override fun onFailure(throwable: Throwable) { - log(tag, "Failed to load data: ${throwable.stackTraceToString()}") - } - - } - override fun onCreate(savedInstanceState: Bundle?) { setFinalTheme() super.onCreate(savedInstanceState) - if (ENABLE_CROWDIN_AUTH) - authCrowdin() binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) @@ -92,15 +75,9 @@ class MainActivity : AppCompatActivity() { ) else null } - override fun onPause() { - super.onPause() - Crowdin.unregisterDataLoadingObserver(loadingObserver) - } - override fun onResume() { setFinalTheme() super.onResume() - Crowdin.registerDataLoadingObserver(loadingObserver) } override fun onOptionsItemSelected(item: MenuItem): Boolean { @@ -153,14 +130,7 @@ class MainActivity : AppCompatActivity() { } override fun attachBaseContext(newBase: Context) { - super.attachBaseContext(Crowdin.wrapContext(LanguageContextWrapper.wrap(newBase))) - } - - //I have no idea why the fuck is super method deprecated - @Suppress("DEPRECATION") - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) - onActivityResult(requestCode) + super.attachBaseContext(LanguageContextWrapper.wrap(newBase)) } override fun onConfigurationChanged(newConfig: Configuration) { diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/DevSettingsFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/DevSettingsFragment.kt index ef271d6a..3126b4c9 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/DevSettingsFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/DevSettingsFragment.kt @@ -3,22 +3,15 @@ package com.vanced.manager.ui.fragments import android.content.Intent import android.os.Build import android.os.Bundle -import android.provider.Settings import android.view.LayoutInflater import android.view.ViewGroup -import androidx.annotation.RequiresApi import androidx.core.content.edit -import androidx.core.net.toUri -import androidx.core.view.isVisible import androidx.preference.PreferenceManager.getDefaultSharedPreferences -import com.crowdin.platform.Crowdin -import com.vanced.manager.BuildConfig import com.vanced.manager.core.ui.base.BindingFragment import com.vanced.manager.databinding.FragmentDevSettingsBinding import com.vanced.manager.ui.WelcomeActivity import com.vanced.manager.ui.dialogs.ManagerUpdateDialog import com.vanced.manager.ui.dialogs.URLChangeDialog -import com.vanced.manager.utils.authCrowdin class DevSettingsFragment : BindingFragment() { @@ -40,7 +33,6 @@ class DevSettingsFragment : BindingFragment() { bindWelcomeLauncher() bindForceUpdate() bindChannelURL() - bindCrowdin() bindKernelArch() bindAndroidVersion() } @@ -72,31 +64,6 @@ class DevSettingsFragment : BindingFragment() { } } - private fun FragmentDevSettingsBinding.bindCrowdin() { - if (BuildConfig.ENABLE_CROWDIN_AUTH) { - val isAuthorized = Crowdin.isAuthorized() - crowdinCategory.isVisible = true - - crowdinAuth.isVisible = !isAuthorized - screenshotUploading.isVisible = isAuthorized - realTimeUpdates.isVisible = isAuthorized - - crowdinAuth.setOnClickListener { - requireActivity().authCrowdin() - @RequiresApi(Build.VERSION_CODES.M) - if (!Settings.canDrawOverlays(requireActivity())) { - val intent = Intent( - Settings.ACTION_MANAGE_OVERLAY_PERMISSION, - ("package:" + requireActivity().packageName).toUri() - ) - startActivityForResult(intent, 69) - } - - Crowdin.authorize(requireActivity()) - } - } - } - private fun FragmentDevSettingsBinding.bindKernelArch() { val supportedAbis: Array = Build.SUPPORTED_ABIS diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt index 45398958..b434c083 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt @@ -13,7 +13,6 @@ import androidx.fragment.app.viewModels import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.preference.PreferenceManager import androidx.recyclerview.widget.LinearLayoutManager -import com.crowdin.platform.util.inflateWithCrowdin import com.google.android.flexbox.FlexboxLayoutManager import com.google.android.flexbox.JustifyContent import com.vanced.manager.BuildConfig.VERSION_CODE @@ -100,8 +99,7 @@ class HomeFragment : BindingFragment() { } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { - inflater.inflateWithCrowdin(R.menu.toolbar_menu, menu, resources) - super.onCreateOptionsMenu(menu, inflater) + inflater.inflate(R.menu.toolbar_menu, menu) } override fun onPause() { diff --git a/app/src/main/java/com/vanced/manager/ui/viewmodels/HomeViewModel.kt b/app/src/main/java/com/vanced/manager/ui/viewmodels/HomeViewModel.kt index c880f707..63fd3b6f 100644 --- a/app/src/main/java/com/vanced/manager/ui/viewmodels/HomeViewModel.kt +++ b/app/src/main/java/com/vanced/manager/ui/viewmodels/HomeViewModel.kt @@ -10,7 +10,6 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import androidx.preference.PreferenceManager.getDefaultSharedPreferences -import com.crowdin.platform.Crowdin import com.vanced.manager.R import com.vanced.manager.adapter.LinkAdapter.Companion.DISCORD import com.vanced.manager.adapter.LinkAdapter.Companion.REDDIT @@ -56,7 +55,6 @@ class HomeViewModel(private val activity: FragmentActivity) : ViewModel() { fun fetchData() { viewModelScope.launch { loadJson(activity) - Crowdin.forceUpdate(activity) } } diff --git a/app/src/main/java/com/vanced/manager/utils/LanguageHelper.kt b/app/src/main/java/com/vanced/manager/utils/LanguageHelper.kt index 489f036a..8a88d86d 100644 --- a/app/src/main/java/com/vanced/manager/utils/LanguageHelper.kt +++ b/app/src/main/java/com/vanced/manager/utils/LanguageHelper.kt @@ -1,15 +1,10 @@ package com.vanced.manager.utils -import android.app.Activity import android.content.Context -import android.content.Intent import android.content.res.Resources -import android.net.Uri import android.os.Build import android.os.LocaleList -import android.provider.Settings import androidx.annotation.RequiresApi -import com.crowdin.platform.Crowdin import com.vanced.manager.R import java.util.* @@ -56,26 +51,4 @@ fun LocaleList.toLangTags(): Array { langTags[i] = langTags[i].substring(0, 2) } return langTags -} - -fun Activity.authCrowdin() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (!Settings.canDrawOverlays(this)) { - val intent = Intent( - Settings.ACTION_MANAGE_OVERLAY_PERMISSION, - Uri.parse("package:$packageName") - ) - startActivityForResult(intent, 69) - return - } - Crowdin.authorize(this) - } -} - -fun Activity.onActivityResult(requestCode: Int) { - if (requestCode == 69 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (Settings.canDrawOverlays(this)) { - Crowdin.authorize(this) - } - } } \ No newline at end of file