0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-01 00:32:39 +00:00

bug fixes and improvements

This commit is contained in:
X1nto 2020-08-06 11:46:07 +04:00
parent e9695caf76
commit b5026a7758
12 changed files with 137 additions and 119 deletions

View file

@ -18,6 +18,11 @@ jobs:
with:
java-version: 1.8
- name: Write firebase config to file
run: echo $FIREBASE_CONFIG > app/google-services.json
env:
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
- name: Grant rights
run: chmod +x ./gradlew

View file

@ -45,7 +45,7 @@ class MicrogDownloadService: Service() {
.build()
.setOnProgressListener { progress ->
val mProgress = progress.currentBytes * 100 / progress.totalBytes
localBroadcastManager.sendBroadcast(Intent(HomeFragment.MICROG_DOWNLOADING).putExtra("progress", mProgress).putExtra("file", getFileNameFromUrl(url)))
localBroadcastManager.sendBroadcast(Intent(HomeFragment.MICROG_DOWNLOADING).putExtra("progress", mProgress.toInt()).putExtra("file", getFileNameFromUrl(url)))
}
.start(object : OnDownloadListener {
override fun onDownloadComplete() {

View file

@ -71,7 +71,7 @@ class VancedDownloadService: Service() {
.build()
.setOnProgressListener { progress ->
val mProgress = progress.currentBytes * 100 / progress.totalBytes
localBroadcastManager.sendBroadcast(Intent(HomeFragment.VANCED_DOWNLOADING).putExtra("progress", mProgress).putExtra("file", getFileNameFromUrl(url)))
localBroadcastManager.sendBroadcast(Intent(HomeFragment.VANCED_DOWNLOADING).putExtra("progress", mProgress.toInt()).putExtra("file", getFileNameFromUrl(url)))
}
.start(object : OnDownloadListener {
override fun onDownloadComplete() {

View file

@ -1,15 +1,11 @@
package com.vanced.manager.ui
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Bundle
import android.util.Log
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.navigation.NavDestination
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
@ -17,6 +13,7 @@ import androidx.navigation.ui.setupWithNavController
import androidx.preference.PreferenceManager
import com.crowdin.platform.Crowdin
import com.crowdin.platform.LoadingStateListener
import com.google.firebase.messaging.FirebaseMessaging
import com.vanced.manager.R
import com.vanced.manager.databinding.ActivityMainBinding
import com.vanced.manager.ui.dialogs.DialogContainer
@ -32,14 +29,6 @@ class MainActivity : AppCompatActivity() {
private lateinit var binding: ActivityMainBinding
private val navHost by lazy { findNavController(R.id.bottom_nav_host) }
private val localBroadcastManager by lazy { LocalBroadcastManager.getInstance(this) }
private val broadcastReceiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (intent.action) {
}
}
}
private val loadingObserver = object : LoadingStateListener {
val tag = "VMLocalisation"
@ -69,26 +58,25 @@ class MainActivity : AppCompatActivity() {
setDisplayHomeAsUpEnabled(currFrag.id != R.id.home_fragment)
}
Crowdin.registerDataLoadingObserver(loadingObserver)
initDialogs()
}
override fun onPause() {
super.onPause()
localBroadcastManager.unregisterReceiver(broadcastReceiver)
Crowdin.unregisterDataLoadingObserver(loadingObserver)
}
override fun onResume() {
setFinalTheme(this)
super.onResume()
registerReceivers()
Crowdin.registerDataLoadingObserver(loadingObserver)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (!isInstallationRunning(this)) {
if (isInstallationRunning(this))
return false
when (item.itemId) {
android.R.id.home -> {
onBackPressed()
@ -108,7 +96,7 @@ class MainActivity : AppCompatActivity() {
}
else -> super.onOptionsItemSelected(item)
}
}
return false
}
@ -120,25 +108,19 @@ class MainActivity : AppCompatActivity() {
super.attachBaseContext(Crowdin.wrapContext(newBase))
}
private fun registerReceivers() {
val intentFilter = IntentFilter()
localBroadcastManager.registerReceiver(broadcastReceiver, intentFilter)
}
fun restartActivity() {
startActivity(Intent(this@MainActivity, MainActivity::class.java))
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
finish()
}
private fun initDialogs() {
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
val variant = prefs.getString("vanced_variant", "nonroot")
val showRootDialog = prefs.getBoolean("show_root_dialog", true)
when {
prefs.getBoolean("firstStart", true) -> DialogContainer.showSecurityDialog(this)
prefs.getBoolean("firstStart", true) -> {
DialogContainer.showSecurityDialog(this)
with(FirebaseMessaging.getInstance()) {
subscribeToTopic("Vanced-Update")
subscribeToTopic("MicroG-Update")
}
}
!prefs.getBoolean("statement", true) -> DialogContainer.statementFalse(this)
variant == "root" -> {
if (showRootDialog)
@ -170,6 +152,4 @@ class MainActivity : AppCompatActivity() {
}
}
companion object {
}
}

View file

@ -17,14 +17,18 @@ object DialogContainer {
MaterialAlertDialogBuilder(context)
.setTitle(context.resources.getString(R.string.welcome))
.setMessage(context.resources.getString(R.string.security_context))
.setCancelable(false)
.setPositiveButton(context.resources.getString(R.string.close)) { dialog, _ ->
run {
dialog.dismiss()
}
.setOnDismissListener {
if (MiuiHelper.isMiui()) {
showMiuiDialog(context)
}
}
.setOnCancelListener {
if (MiuiHelper.isMiui()) {
showMiuiDialog(context)
}
}
.create()
.show()
@ -57,6 +61,7 @@ object DialogContainer {
openUrl("https://lmgtfy.com/?q=andnixsh+apk+verification+disable", R.color.Twitter, activity)
}
.setOnDismissListener { PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean("show_root_dialog", false).apply() }
.setOnCancelListener { PreferenceManager.getDefaultSharedPreferences(activity).edit().putBoolean("show_root_dialog", false).apply() }
.create()
.show()
}

View file

@ -3,10 +3,9 @@ package com.vanced.manager.ui.fragments
import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import android.widget.Toast
import androidx.preference.*
import com.google.firebase.messaging.FirebaseMessaging
import com.vanced.manager.R
class SettingsFragment : PreferenceFragmentCompat() {
@ -17,57 +16,79 @@ class SettingsFragment : PreferenceFragmentCompat() {
activity?.title = getString(R.string.title_settings)
setHasOptionsMenu(true)
val updateCheck: Preference? = findPreference("update_check")
updateCheck?.setOnPreferenceClickListener {
val fm = childFragmentManager.beginTransaction()
val updateDialog = UpdateCheckFragment()
updateDialog.show(fm, "Update Center")
findPreference<Preference>("update_check")?.setOnPreferenceClickListener {
UpdateCheckFragment().show(childFragmentManager.beginTransaction(), "Update Center")
true
}
val themeSwitch: ListPreference? = findPreference("theme_mode")
findPreference<SwitchPreference>("vanced_notifs")?.apply {
title = getString(R.string.push_notifications, "Vanced")
summary = getString(R.string.push_notifications_summary, "Vanced")
setOnPreferenceChangeListener { _, newValue ->
when (newValue) {
true -> FirebaseMessaging.getInstance().subscribeToTopic("Vanced-Update")
false -> FirebaseMessaging.getInstance().unsubscribeFromTopic("Vanced-Update")
}
true
}
}
findPreference<SwitchPreference>("microg_notifs")?.apply {
title = getString(R.string.push_notifications, "microG")
summary = getString(R.string.push_notifications_summary, "microG")
setOnPreferenceChangeListener { _, newValue ->
when (newValue) {
true -> FirebaseMessaging.getInstance().subscribeToTopic("MicroG-Update")
false -> FirebaseMessaging.getInstance().unsubscribeFromTopic("MicroG-Update")
}
Toast.makeText(requireActivity(), "Set value to $newValue", Toast.LENGTH_SHORT).show()
true
}
}
val themePref = preferenceScreen.sharedPreferences.getString("theme_mode", "Follow System")
themeSwitch?.summary =
when (themePref) {
findPreference<ListPreference>("theme_mode")?.apply {
summary = when (themePref) {
"Light" -> getString(R.string.theme_light)
"Dark" -> getString(R.string.theme_dark)
"Follow System" -> getString(R.string.theme_follow)
else -> ""
else -> getString(R.string.theme_follow)
}
setOnPreferenceChangeListener { _, newValue ->
if (themePref != newValue) {
requireActivity().recreate()
return@setOnPreferenceChangeListener true
}
false
}
themeSwitch?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate()
true
}
val accentSwitch: ListPreference? = findPreference("accent_color")
val accentPref = preferenceScreen.sharedPreferences.getString("accent_color", "Blue")
accentSwitch?.summary =
when (accentPref) {
findPreference<ListPreference>("accent_color")?.apply {
summary = when (accentPref) {
"Blue" -> getString(R.string.accent_blue)
"Red" -> getString(R.string.accent_red)
"Green" -> getString(R.string.accent_green)
"Yellow" -> getString(R.string.accent_yellow)
"Purple" -> getString(R.string.accent_purple)
else -> ""
else -> getString(R.string.accent_purple)
}
setOnPreferenceChangeListener { _, newValue ->
if (accentPref != newValue) {
requireActivity().recreate()
return@setOnPreferenceChangeListener true
}
false
}
accentSwitch?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate()
true
}
val chosenPrefs: Preference? = findPreference("vanced_chosen_modes")
chosenPrefs?.setOnPreferenceClickListener {
val fm = childFragmentManager.beginTransaction()
val chosenPrefsDialog = ChosenPreferenceDialogFragment()
chosenPrefsDialog.show(fm, "Chosen Preferences")
ChosenPreferenceDialogFragment().show(childFragmentManager.beginTransaction(), "Chosen Preferences")
true
}
val installUrl: Preference? = findPreference("install_url")
installUrl?.setOnPreferenceClickListener {
val fm = childFragmentManager.beginTransaction()
val chosenPrefsDialog = URLChangeFragment()
chosenPrefsDialog.show(fm, "Install URL")
URLChangeFragment().show(childFragmentManager.beginTransaction(), "Install URL")
true
}

View file

@ -48,7 +48,10 @@ class VancedLanguageSelectionFragment : Fragment() {
chosenLangs.add(lang)
}
}
activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)?.edit()?.putString("lang", chosenLangs.joinToString())?.apply()
activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)?.edit()?.apply {
putString("lang", chosenLangs.joinToString())?.apply()
putBoolean("valuesModified", true)
}
activity?.startService(Intent(activity, VancedDownloadService::class.java))
view.findNavController().navigate(R.id.action_installTo_homeFragment)
}

View file

@ -25,7 +25,7 @@
android:background="?colorSurface"
android:layout_alignParentTop="true">
<androidx.appcompat.widget.Toolbar
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/home_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"

View file

@ -6,7 +6,7 @@
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#2C7EB9</item>
<item name="colorSecondary">#3E78AF</item>
<item name="colorSecondaryVariant">#803E78AF</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
<item name="colorSurface">#ffffff</item>
<item name="colorSurfaceVariant">#F3F3F3</item>
<item name="colorSurfaceSurfaceVariant">?colorSurface</item>

View file

@ -33,7 +33,7 @@
<string name="latest">Latest:</string>
<string name="successfully_installed">Successfully installed %1$s</string>
<string name="network_error">Network connection unavailable</string>
<string name="no_microg">No MicroG!</string>
<string name="no_microg">microG isn\'t installed</string>
<string name="root_not_granted">Root access not granted</string>
<string name="unavailable">Unavailable</string>
<string name="update">Update</string>
@ -63,8 +63,8 @@
<string name="theme_dark">Dark Theme</string>
<string name="theme_light">Light Theme</string>
<string name="update_url">Update Channel URL</string>
<string name="push_notifications">Push Notifications</string>
<string name="push_notifications_summary">Receive push notifications when an update is released</string>
<string name="push_notifications">%1$s Push Notifications</string>
<string name="push_notifications_summary">Receive push notifications when an update for %1$s is released</string>
<string name="re_check">Re-check</string>
<string name="update_center">Manager Update Center</string>
<string name="update_found">Update found!</string>

View file

@ -8,7 +8,7 @@
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#2C7EB9</item>
<item name="colorSecondary">#3E78AF</item>
<item name="colorSecondaryVariant">#803E78AF</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
<item name="colorSurface">#ffffff</item>
<item name="colorSurfaceVariant">#F3F3F3</item>
<item name="colorSurfaceSurfaceVariant">?colorSurface</item>
@ -40,7 +40,7 @@
<item name="colorPrimary">#D71414</item>
<item name="colorPrimaryVariant">#B92C2C</item>
<item name="colorSecondary">#AF3E3E</item>
<item name="colorSecondaryVariant">#80AF3E3E</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
</style>
@ -49,7 +49,7 @@
<item name="colorPrimary">#3ED714</item>
<item name="colorPrimaryVariant">#2CB943</item>
<item name="colorSecondary">#3EAF51</item>
<item name="colorSecondaryVariant">#803EAF44</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
</style>
@ -58,7 +58,7 @@
<item name="colorPrimary">#ffd500</item>
<item name="colorPrimaryVariant">#A6FFD500</item>
<item name="colorSecondary">#D3B418</item>
<item name="colorSecondaryVariant">#B7D3B418</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
</style>
@ -67,7 +67,7 @@
<item name="colorPrimary">#6D49B7</item>
<item name="colorPrimaryVariant">#563C8D</item>
<item name="colorSecondary">#734BC7</item>
<item name="colorSecondaryVariant">#9A734BC7</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
</style>
@ -78,7 +78,7 @@
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#2C7EB9</item>
<item name="colorSecondary">#3E78AF</item>
<item name="colorSecondaryVariant">#803E78AF</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
<item name="colorSurface">#000000</item>
<item name="colorSurfaceVariant">#111111</item>
<item name="colorSurfaceSurfaceVariant">?colorSurface</item>
@ -111,7 +111,7 @@
<item name="colorPrimary">#D71414</item>
<item name="colorPrimaryVariant">#B92C2C</item>
<item name="colorSecondary">#AF3E3E</item>
<item name="colorSecondaryVariant">#80AF3E3E</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
</style>
@ -120,7 +120,7 @@
<item name="colorPrimary">#3ED714</item>
<item name="colorPrimaryVariant">#2CB943</item>
<item name="colorSecondary">#3EAF51</item>
<item name="colorSecondaryVariant">#803EAF44</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
</style>
@ -129,7 +129,7 @@
<item name="colorPrimary">#ffd500</item>
<item name="colorPrimaryVariant">#A6FFD500</item>
<item name="colorSecondary">#D3B418</item>
<item name="colorSecondaryVariant">#B7D3B418</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
</style>
@ -138,7 +138,7 @@
<item name="colorPrimary">#6D49B7</item>
<item name="colorPrimaryVariant">#563C8D</item>
<item name="colorSecondary">#734BC7</item>
<item name="colorSecondaryVariant">#9A734BC7</item>
<item name="colorSecondaryVariant">?colorPrimary</item>
</style>

View file

@ -21,9 +21,13 @@
android:summaryOff="@string/link_external_browser" />
<SwitchPreference
android:title="@string/push_notifications"
android:key="push_notifications_status"
android:summary="@string/push_notifications_summary"
android:key="vanced_notifs"
android:defaultValue="true"
android:icon="@drawable/ic_notifications_black_24dp"/>
<SwitchPreference
android:key="microg_notifs"
android:defaultValue="true"
android:icon="@drawable/ic_notifications_black_24dp"/>
</PreferenceCategory>