Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #71 from YTVanced/dev
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
KevinX8 committed Jul 4, 2020
2 parents 6341baa + ec2c205 commit 90c457c
Show file tree
Hide file tree
Showing 64 changed files with 2,573 additions and 820 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,4 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: 'Vanced-Manager'
path: app/build/outputs/apk/debug/app-debug.apk

- name: Upload to Discord
uses: sinshutu/upload-to-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: app/build/outputs/apk/debug/app-debug.apk
path: app/build/outputs/apk/debug/app-debug.apk
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pull requests should be made to the Dev branch as that is the working branch, master is for release code.
======
For anyone who wants to provide translations please submit them to https://translate.vanced.app as we also use it for YouTube Vanced. Any issues with translations should be posted there too.
For anyone who wants to provide translations please submit them to https://translatemanager.vanced.app as we also use it for YouTube Vanced. Any issues with translations should be posted there too.
======
[![Github All Releases](https://img.shields.io/github/downloads/YTVanced/VancedManager/total.svg)]() [![Github All Releases](https://img.shields.io/github/release/YTVanced/VancedManager.svg)]()
# Vanced Manager
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.vanced.manager"
minSdkVersion 21
targetSdkVersion 29
versionCode 10
versionName "1.0.2"
versionCode 11
versionName "1.1.0 (Big Sur)"

vectorDrawables.useSupportLibrary = true
}
Expand Down
21 changes: 1 addition & 20 deletions app/src/main/java/com/vanced/manager/core/App.kt
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
package com.vanced.manager.core

import android.app.Application
import android.widget.Toast
import androidx.preference.PreferenceManager
import com.dezlum.codelabs.getjson.GetJson
import com.downloader.PRDownloader
import com.vanced.manager.R
import com.vanced.manager.utils.InternetTools
import com.vanced.manager.utils.NotificationHelper.createNotifChannel

class App: Application() {

override fun onCreate() {
super.onCreate()
//checkUpdates()
PRDownloader.initialize(applicationContext)
PRDownloader.initialize(this)
createNotifChannel(this)
}

/*
private fun checkUpdates() {
val checkPrefs = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("auto_check_update", true)
if (checkPrefs) {
if (GetJson().isConnected(this) && InternetTools.isUpdateAvailable()) {
Toast.makeText(this, getString(R.string.update_found), Toast.LENGTH_SHORT).show()
} else
Toast.makeText(this, getString(R.string.update_notfound), Toast.LENGTH_SHORT).show()
}
}
*/

}
2 changes: 0 additions & 2 deletions app/src/main/java/com/vanced/manager/core/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ open class Main: AppCompatActivity() {
if (GetJson().isConnected(this) && isUpdateAvailable()) {
val fm = supportFragmentManager
UpdateCheckFragment().show(fm, "UpdateCheck")
} else {
Toast.makeText(this, getString(R.string.update_notfound), Toast.LENGTH_SHORT).show()
}
}

Expand Down
70 changes: 28 additions & 42 deletions app/src/main/java/com/vanced/manager/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.navigation.NavDestination
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupWithNavController
import com.google.android.material.appbar.MaterialToolbar
import com.vanced.manager.R
import com.vanced.manager.core.Main
import com.vanced.manager.databinding.ActivityMainBinding
Expand All @@ -24,36 +23,9 @@ import com.vanced.manager.utils.ThemeHelper.setFinalTheme

class MainActivity : Main() {

private var isParent = true
private lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
setFinalTheme(this)
super.onCreate(savedInstanceState)

binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
binding.lifecycleOwner = this

val toolbar: MaterialToolbar = findViewById(R.id.home_toolbar)
setSupportActionBar(toolbar)

val navHost = findNavController(R.id.bottom_nav_host)
val appBarConfiguration = AppBarConfiguration(navHost.graph)
toolbar.setupWithNavController(navHost, appBarConfiguration)

navHost.addOnDestinationChangedListener{_, currFrag: NavDestination, _ ->
isParent = when (currFrag.id) {
R.id.home_fragment -> true
else -> false
}

setDisplayHomeAsUpEnabled(!isParent)

}

registerReceivers()

}
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) {
Expand All @@ -74,9 +46,26 @@ class MainActivity : Main() {
}
}

override fun onCreate(savedInstanceState: Bundle?) {
setFinalTheme(this)
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)

with(binding) {
lifecycleOwner = this@MainActivity
setSupportActionBar(homeToolbar)
val appBarConfiguration = AppBarConfiguration(navHost.graph)
homeToolbar.setupWithNavController(navHost, appBarConfiguration)
}

navHost.addOnDestinationChangedListener { _, currFrag: NavDestination, _ ->
setDisplayHomeAsUpEnabled(currFrag.id != R.id.home_fragment)
}
}

override fun onPause() {
super.onPause()
LocalBroadcastManager.getInstance(this).unregisterReceiver(broadcastReceiver)
localBroadcastManager.unregisterReceiver(broadcastReceiver)
}

override fun onResume() {
Expand All @@ -100,7 +89,7 @@ class MainActivity : Main() {
navHost.navigate(R.id.action_settingsFragment)
return true
}
R.id.dev_settings -> {
R.id.dev_settings -> {
navHost.navigate(R.id.toDevSettingsFragment)
return true
}
Expand All @@ -110,11 +99,8 @@ class MainActivity : Main() {
}

private fun setDisplayHomeAsUpEnabled(isNeeded: Boolean) {
val toolbar: MaterialToolbar = findViewById(R.id.home_toolbar)
when {
isNeeded -> toolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp)
else -> toolbar.navigationIcon = null
}
binding.homeToolbar.navigationIcon = if (isNeeded) getDrawable(R.drawable.ic_keyboard_backspace_black_24dp) else null

}

private fun registerReceivers() {
Expand All @@ -123,7 +109,7 @@ class MainActivity : Main() {
intentFilter.addAction(INSTALL_FAILED)
intentFilter.addAction(APP_UNINSTALLED)
intentFilter.addAction(APP_NOT_UNINSTALLED)
LocalBroadcastManager.getInstance(this).registerReceiver(broadcastReceiver, intentFilter)
localBroadcastManager.registerReceiver(broadcastReceiver, intentFilter)

}

Expand All @@ -134,9 +120,9 @@ class MainActivity : Main() {
}

companion object {
const val INSTALL_COMPLETED = "Installation completed"
const val INSTALL_FAILED = "it just failed idk"
const val APP_UNINSTALLED = "App uninstalled"
const val APP_NOT_UNINSTALLED = "App not uninstalled"
const val INSTALL_COMPLETED = "install_completed"
const val INSTALL_FAILED = "install_failed"
const val APP_UNINSTALLED = "app_uninstalled"
const val APP_NOT_UNINSTALLED = "app_not_installed"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AboutFragment : About() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
activity?.title = getString(R.string.title_about)
requireActivity().title = getString(R.string.title_about)
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_about, container, false)
return binding.root
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,41 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView
import androidx.core.content.edit
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.DialogFragment

import com.vanced.manager.R
import com.vanced.manager.databinding.FragmentChosenPreferencesBinding

class ChosenPreferenceDialogFragment : DialogFragment() {

private lateinit var binding: FragmentChosenPreferencesBinding

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
if (dialog != null && dialog?.window != null) {
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
}
return inflater.inflate(R.layout.fragment_chosen_preferences, container, false)
dialog?.window?.apply { setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) }
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_chosen_preferences, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

val closebtn = view.findViewById<Button>(R.id.chosen_prefs_close)
val resetbtn = view.findViewById<Button>(R.id.chosen_prefs_reset)
val themetxt = view.findViewById<TextView>(R.id.chosen_theme)
val langtxt = view.findViewById<TextView>(R.id.chosen_lang)
val prefs = requireActivity().getSharedPreferences("installPrefs", Context.MODE_PRIVATE)

val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
binding.chosenTheme.text = requireActivity().getString(R.string.chosen_theme, prefs.getString("theme", "dark"))
binding.chosenLang.text = requireActivity().getString(R.string.chosen_lang, prefs.getString("lang", "en"))

themetxt.text = activity?.getString(R.string.chosen_theme, prefs?.getString("theme", "dark"))
langtxt.text = activity?.getString(R.string.chosen_lang, prefs?.getString("lang", "en"))

closebtn.setOnClickListener { dismiss() }

resetbtn.setOnClickListener {
prefs?.edit()?.putString("theme", "dark")?.apply()
prefs?.edit()?.putString("lang", "en")?.apply()
prefs?.edit()?.putBoolean("valuesModified", false)?.apply()
binding.chosenPrefsClose.setOnClickListener { dismiss() }
binding.chosenPrefsReset.setOnClickListener {
prefs.edit {
putString("theme", "dark")
putString("lang", "en")
putBoolean("valuesModified", false)
}
dismiss()
}



}



}
Loading

0 comments on commit 90c457c

Please sign in to comment.