mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-26 21:13:01 +00:00
fixed crowdin-related issues
This commit is contained in:
parent
d41095a6f0
commit
6015b072b6
9 changed files with 68 additions and 22 deletions
|
@ -26,6 +26,10 @@ android {
|
|||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
buildConfigField "String[]", "MANAGER_LANGUAGES", "{" + surroundWithQuotes(langs) + "}"
|
||||
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')}\""
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.vanced.manager.core
|
|||
|
||||
import android.app.Application
|
||||
import android.content.res.Configuration
|
||||
import android.util.Log
|
||||
import androidx.databinding.ObservableField
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.beust.klaxon.JsonObject
|
||||
|
@ -10,6 +11,7 @@ import com.crowdin.platform.CrowdinConfig
|
|||
import com.crowdin.platform.data.model.AuthConfig
|
||||
import com.crowdin.platform.data.remote.NetworkType
|
||||
import com.downloader.PRDownloader
|
||||
import com.vanced.manager.BuildConfig.*
|
||||
import com.vanced.manager.utils.InternetTools.baseUrl
|
||||
import com.vanced.manager.utils.JsonHelper.getJson
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
@ -31,21 +33,21 @@ open class App: Application() {
|
|||
loadJson()
|
||||
super.onCreate()
|
||||
PRDownloader.initialize(this)
|
||||
val clientId = prefs.getString("crowdin_client_id", "")
|
||||
val clientSecret = prefs.getString("crowdin_client_secret", "")
|
||||
|
||||
Crowdin.init(this,
|
||||
CrowdinConfig.Builder().apply {
|
||||
withDistributionHash("3b84be9663023b0b1a22988j4s6")
|
||||
withDistributionHash(CROWDIN_HASH)
|
||||
withNetworkType(NetworkType.WIFI)
|
||||
if (clientId != "" && clientSecret != "") {
|
||||
if (ENABLE_CROWDIN_AUTH) {
|
||||
withRealTimeUpdates()
|
||||
withSourceLanguage("en")
|
||||
withAuthConfig(AuthConfig(clientId!!, clientSecret!!, null))
|
||||
withAuthConfig(AuthConfig(CROWDIN_CLIENT_ID, CROWDIN_CLIENT_SECRET, null))
|
||||
withScreenshotEnabled()
|
||||
Log.d("test", "crowdin credentials")
|
||||
}
|
||||
}.build()
|
||||
)
|
||||
|
||||
if (prefs.getBoolean("crowdin_upload_screenshot", false))
|
||||
Crowdin.registerScreenShotContentObserver(this)
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ class MainActivity : AppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setFinalTheme(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
|
||||
|
||||
with(binding) {
|
||||
|
@ -113,7 +114,7 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(LanguageContextWrapper.wrap(newBase))
|
||||
super.attachBaseContext(Crowdin.wrapContext(LanguageContextWrapper.wrap(newBase)))
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
|
|
|
@ -19,8 +19,8 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
) : FrameLayout(context, attrs, defStyle, defStyleRes) {
|
||||
|
||||
private val prefs by lazy { getDefaultSharedPreferences(context) }
|
||||
private var prefKey: String = ""
|
||||
private var defValue: Boolean = false
|
||||
var prefKey: String = ""
|
||||
var defValue: Boolean = false
|
||||
private var mListener: OnCheckedListener? = null
|
||||
|
||||
init {
|
||||
|
@ -101,7 +101,7 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
@JvmStatic
|
||||
@BindingAdapter("app:switch_def_val")
|
||||
@BindingAdapter("app:switch_def_value")
|
||||
fun setDefaultValue(view: PreferenceSwitch, newVal: Boolean) {
|
||||
view.defValue = newVal
|
||||
view.preference_switch.isChecked = view.prefs.getBoolean(view.prefKey, view.defValue)
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package com.vanced.manager.ui.fragments
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.preference.SwitchPreferenceCompat
|
||||
import com.crowdin.platform.Crowdin
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.ui.WelcomeActivity
|
||||
import com.vanced.manager.ui.dialogs.ManagerUpdateDialog
|
||||
|
@ -40,6 +45,25 @@ class DevSettingsFragment: PreferenceFragmentCompat() {
|
|||
|
||||
}
|
||||
|
||||
findPreference<SwitchPreferenceCompat>("crowdin_upload_screenshot")?.isVisible = Crowdin.isAuthorized()
|
||||
findPreference<SwitchPreferenceCompat>("crowdin_real_time")?.isVisible = Crowdin.isAuthorized()
|
||||
|
||||
findPreference<Preference>("crowdin_auth")?.setOnPreferenceClickListener {
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
if (!Settings.canDrawOverlays(requireActivity())) {
|
||||
val intent = Intent(
|
||||
Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||
Uri.parse("package:" + requireActivity().packageName)
|
||||
)
|
||||
startActivityForResult(intent, 69)
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
|
||||
Crowdin.authorize(requireActivity())
|
||||
true
|
||||
}
|
||||
|
||||
findPreference<Preference>("install_url")?.setOnPreferenceClickListener {
|
||||
URLChangeDialog().show(childFragmentManager.beginTransaction(), "Install URL")
|
||||
true
|
||||
|
@ -58,10 +82,23 @@ class DevSettingsFragment: PreferenceFragmentCompat() {
|
|||
|
||||
val forceUpdate: Preference? = findPreference("force_update")
|
||||
forceUpdate?.setOnPreferenceClickListener {
|
||||
ManagerUpdateDialog(true).show(requireActivity().supportFragmentManager, "update_manager")
|
||||
ManagerUpdateDialog(true).show(
|
||||
requireActivity().supportFragmentManager,
|
||||
"update_manager"
|
||||
)
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == 69) {
|
||||
@RequiresApi(23)
|
||||
if (Settings.canDrawOverlays(requireActivity())) {
|
||||
Crowdin.authorize(requireActivity())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -42,6 +42,8 @@
|
|||
android:id="@+id/firebase"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:switch_def_value="true"
|
||||
app:switch_key="firebase"
|
||||
app:switch_summary="@string/firebase_summary"
|
||||
app:switch_title="@string/firebase_title" />
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
android:text="@string/versionName"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#fff"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="16sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<Preference
|
||||
android:key="firstlaunch_switch"
|
||||
|
@ -19,21 +20,19 @@
|
|||
<PreferenceCategory
|
||||
android:title="Crowdin">
|
||||
|
||||
<Preference
|
||||
android:title="Authorize"
|
||||
android:key="crowdin_auth" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:title="Screenshot Uploading (ADMIN ONLY)"
|
||||
android:key="crowdin_upload_screenshot" />
|
||||
android:key="crowdin_upload_screenshot"
|
||||
app:isPreferenceVisible="false"/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:title="Real-time updates"
|
||||
android:key="crowdin_real_time" />
|
||||
|
||||
<EditTextPreference
|
||||
android:title="Client ID"
|
||||
android:key="crowdin_client_id"/>
|
||||
|
||||
<EditTextPreference
|
||||
android:title="Client Secret"
|
||||
android:key="crowdin_client_secret"/>
|
||||
android:key="crowdin_real_time"
|
||||
app:isPreferenceVisible="false"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
|
Loading…
Reference in a new issue