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("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 {
|
lint {
|
||||||
|
@ -133,9 +129,6 @@ dependencies {
|
||||||
// JSON parser
|
// JSON parser
|
||||||
implementation("com.beust:klaxon:5.5")
|
implementation("com.beust:klaxon:5.5")
|
||||||
|
|
||||||
// Crowdin
|
|
||||||
implementation("com.github.crowdin.mobile-sdk-android:sdk:1.4.7")
|
|
||||||
|
|
||||||
// HTTP networking
|
// HTTP networking
|
||||||
implementation("com.github.kittinunf.fuel:fuel:2.3.1")
|
implementation("com.github.kittinunf.fuel:fuel:2.3.1")
|
||||||
implementation("com.github.kittinunf.fuel:fuel-coroutines:2.3.1")
|
implementation("com.github.kittinunf.fuel:fuel-coroutines:2.3.1")
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
package com.vanced.manager.core
|
package com.vanced.manager.core
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.res.Configuration
|
|
||||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
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.BuildConfig.*
|
||||||
import com.vanced.manager.utils.AppUtils.log
|
|
||||||
import com.vanced.manager.utils.loadJson
|
import com.vanced.manager.utils.loadJson
|
||||||
import com.vanced.manager.utils.managerAccent
|
import com.vanced.manager.utils.managerAccent
|
||||||
import com.vanced.manager.utils.mutableAccentColor
|
import com.vanced.manager.utils.mutableAccentColor
|
||||||
|
@ -17,7 +11,7 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
open class App : Application() {
|
class App : Application() {
|
||||||
|
|
||||||
private val prefs by lazy { getDefaultSharedPreferences(this) }
|
private val prefs by lazy { getDefaultSharedPreferences(this) }
|
||||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
@ -26,30 +20,6 @@ open class App : Application() {
|
||||||
scope.launch { loadJson(this@App) }
|
scope.launch { loadJson(this@App) }
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
mutableAccentColor.value = prefs.managerAccent
|
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.AppBarConfiguration
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||||
import com.crowdin.platform.Crowdin
|
|
||||||
import com.crowdin.platform.LoadingStateListener
|
|
||||||
import com.google.firebase.messaging.FirebaseMessaging
|
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.BuildConfig.VERSION_CODE
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.databinding.ActivityMainBinding
|
import com.vanced.manager.databinding.ActivityMainBinding
|
||||||
|
@ -40,23 +37,9 @@ class MainActivity : AppCompatActivity() {
|
||||||
lateinit var binding: ActivityMainBinding
|
lateinit var binding: ActivityMainBinding
|
||||||
private val navHost by lazy { findNavController(R.id.nav_host) }
|
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?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
setFinalTheme()
|
setFinalTheme()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
if (ENABLE_CROWDIN_AUTH)
|
|
||||||
authCrowdin()
|
|
||||||
|
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
@ -92,15 +75,9 @@ class MainActivity : AppCompatActivity() {
|
||||||
) else null
|
) else null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
|
||||||
super.onPause()
|
|
||||||
Crowdin.unregisterDataLoadingObserver(loadingObserver)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
setFinalTheme()
|
setFinalTheme()
|
||||||
super.onResume()
|
super.onResume()
|
||||||
Crowdin.registerDataLoadingObserver(loadingObserver)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
@ -153,14 +130,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context) {
|
override fun attachBaseContext(newBase: Context) {
|
||||||
super.attachBaseContext(Crowdin.wrapContext(LanguageContextWrapper.wrap(newBase)))
|
super.attachBaseContext(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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
|
|
|
@ -3,22 +3,15 @@ package com.vanced.manager.ui.fragments
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.Settings
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.net.toUri
|
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
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.core.ui.base.BindingFragment
|
||||||
import com.vanced.manager.databinding.FragmentDevSettingsBinding
|
import com.vanced.manager.databinding.FragmentDevSettingsBinding
|
||||||
import com.vanced.manager.ui.WelcomeActivity
|
import com.vanced.manager.ui.WelcomeActivity
|
||||||
import com.vanced.manager.ui.dialogs.ManagerUpdateDialog
|
import com.vanced.manager.ui.dialogs.ManagerUpdateDialog
|
||||||
import com.vanced.manager.ui.dialogs.URLChangeDialog
|
import com.vanced.manager.ui.dialogs.URLChangeDialog
|
||||||
import com.vanced.manager.utils.authCrowdin
|
|
||||||
|
|
||||||
class DevSettingsFragment : BindingFragment<FragmentDevSettingsBinding>() {
|
class DevSettingsFragment : BindingFragment<FragmentDevSettingsBinding>() {
|
||||||
|
|
||||||
|
@ -40,7 +33,6 @@ class DevSettingsFragment : BindingFragment<FragmentDevSettingsBinding>() {
|
||||||
bindWelcomeLauncher()
|
bindWelcomeLauncher()
|
||||||
bindForceUpdate()
|
bindForceUpdate()
|
||||||
bindChannelURL()
|
bindChannelURL()
|
||||||
bindCrowdin()
|
|
||||||
bindKernelArch()
|
bindKernelArch()
|
||||||
bindAndroidVersion()
|
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() {
|
private fun FragmentDevSettingsBinding.bindKernelArch() {
|
||||||
val supportedAbis: Array<String> = Build.SUPPORTED_ABIS
|
val supportedAbis: Array<String> = Build.SUPPORTED_ABIS
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import androidx.fragment.app.viewModels
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.crowdin.platform.util.inflateWithCrowdin
|
|
||||||
import com.google.android.flexbox.FlexboxLayoutManager
|
import com.google.android.flexbox.FlexboxLayoutManager
|
||||||
import com.google.android.flexbox.JustifyContent
|
import com.google.android.flexbox.JustifyContent
|
||||||
import com.vanced.manager.BuildConfig.VERSION_CODE
|
import com.vanced.manager.BuildConfig.VERSION_CODE
|
||||||
|
@ -100,8 +99,7 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
inflater.inflateWithCrowdin(R.menu.toolbar_menu, menu, resources)
|
inflater.inflate(R.menu.toolbar_menu, menu)
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||||
import com.crowdin.platform.Crowdin
|
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import com.vanced.manager.adapter.LinkAdapter.Companion.DISCORD
|
import com.vanced.manager.adapter.LinkAdapter.Companion.DISCORD
|
||||||
import com.vanced.manager.adapter.LinkAdapter.Companion.REDDIT
|
import com.vanced.manager.adapter.LinkAdapter.Companion.REDDIT
|
||||||
|
@ -56,7 +55,6 @@ class HomeViewModel(private val activity: FragmentActivity) : ViewModel() {
|
||||||
fun fetchData() {
|
fun fetchData() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
loadJson(activity)
|
loadJson(activity)
|
||||||
Crowdin.forceUpdate(activity)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
package com.vanced.manager.utils
|
package com.vanced.manager.utils
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.LocaleList
|
import android.os.LocaleList
|
||||||
import android.provider.Settings
|
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import com.crowdin.platform.Crowdin
|
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -57,25 +52,3 @@ fun LocaleList.toLangTags(): Array<String> {
|
||||||
}
|
}
|
||||||
return langTags
|
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