mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-28 14:03:00 +00:00
fuck crowdin
This commit is contained in:
parent
7fca85be14
commit
5ef967f097
7 changed files with 3 additions and 134 deletions
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<FragmentDevSettingsBinding>() {
|
||||
|
||||
|
@ -40,7 +33,6 @@ class DevSettingsFragment : BindingFragment<FragmentDevSettingsBinding>() {
|
|||
bindWelcomeLauncher()
|
||||
bindForceUpdate()
|
||||
bindChannelURL()
|
||||
bindCrowdin()
|
||||
bindKernelArch()
|
||||
bindAndroidVersion()
|
||||
}
|
||||
|
@ -72,31 +64,6 @@ class DevSettingsFragment : BindingFragment<FragmentDevSettingsBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
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<String> = Build.SUPPORTED_ABIS
|
||||
|
||||
|
|
|
@ -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<FragmentHomeBinding>() {
|
|||
}
|
||||
|
||||
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() {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String> {
|
|||
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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue