mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-25 20:55:12 +00:00
fixed build stuff
This commit is contained in:
parent
e2460ad261
commit
b5ee717bad
7 changed files with 93 additions and 47 deletions
|
@ -5,13 +5,8 @@ import android.os.Bundle
|
|||
import android.util.Log
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.animation.AnimationUtils
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.NavDestination
|
||||
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
|
||||
|
@ -34,8 +29,7 @@ import kotlinx.coroutines.launch
|
|||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
private val navHost by lazy { findNavController(R.id.bottom_nav_host) }
|
||||
|
||||
|
||||
private val loadingObserver = object : LoadingStateListener {
|
||||
val tag = "VMLocalisation"
|
||||
override fun onDataChanged() {
|
||||
|
@ -85,8 +79,6 @@ class MainActivity : AppCompatActivity() {
|
|||
with(binding) {
|
||||
lifecycleOwner = this@MainActivity
|
||||
setSupportActionBar(homeToolbar)
|
||||
val appBarConfiguration = AppBarConfiguration(navHost.graph)
|
||||
homeToolbar.setupWithNavController(navHost, appBarConfiguration)
|
||||
mainViewpager.adapter = SectionVariantAdapter(this@MainActivity)
|
||||
TabLayoutMediator(mainTablayout, mainViewpager) { tab, position ->
|
||||
when (position) {
|
||||
|
@ -106,19 +98,6 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
}
|
||||
|
||||
navHost.addOnDestinationChangedListener { _, currFrag: NavDestination, _ ->
|
||||
setDisplayHomeAsUpEnabled(currFrag.id != R.id.home_fragment)
|
||||
val tabHide = AnimationUtils.loadAnimation(this, R.anim.tablayout_exit)
|
||||
val tabShow = AnimationUtils.loadAnimation(this, R.anim.tablayout_enter)
|
||||
if (currFrag.id != R.id.home_fragment) {
|
||||
binding.variantTabContainer.startAnimation(tabHide)
|
||||
binding.variantTabContainer.visibility = View.GONE
|
||||
} else {
|
||||
binding.variantTabContainer.visibility = View.VISIBLE
|
||||
binding.variantTabContainer.startAnimation(tabShow)
|
||||
}
|
||||
}
|
||||
|
||||
initDialogs()
|
||||
|
||||
}
|
||||
|
@ -145,16 +124,13 @@ class MainActivity : AppCompatActivity() {
|
|||
return true
|
||||
}
|
||||
R.id.toolbar_about -> {
|
||||
navHost.navigate(R.id.toAboutFragment)
|
||||
return true
|
||||
return false
|
||||
}
|
||||
R.id.toolbar_settings -> {
|
||||
navHost.navigate(R.id.action_settingsFragment)
|
||||
return true
|
||||
return false
|
||||
}
|
||||
R.id.dev_settings -> {
|
||||
navHost.navigate(R.id.toDevSettingsFragment)
|
||||
return true
|
||||
return false
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
@ -162,10 +138,6 @@ class MainActivity : AppCompatActivity() {
|
|||
return false
|
||||
}
|
||||
|
||||
private fun setDisplayHomeAsUpEnabled(isNeeded: Boolean) {
|
||||
binding.homeToolbar.navigationIcon = if (isNeeded) getDrawable(R.drawable.ic_keyboard_backspace_black_24dp) else null
|
||||
}
|
||||
|
||||
override fun attachBaseContext(newBase: Context) {
|
||||
super.attachBaseContext(Crowdin.wrapContext(newBase))
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ class ChosenPreferenceDialogFragment : DialogFragment() {
|
|||
private lateinit var binding: FragmentChosenPreferencesBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
dialog?.window?.apply { setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) }
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_chosen_preferences, container, false)
|
||||
|
|
|
@ -2,20 +2,79 @@ package com.vanced.manager.ui.fragments
|
|||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.LinearLayout
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.vanced.manager.databinding.FragmentMainBinding
|
||||
import com.vanced.manager.R
|
||||
|
||||
class MainFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentMainBinding
|
||||
private val navHost by lazy { activity?.findNavController(R.id.nav_host) }
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
requireActivity().title = getString(R.string.title_home)
|
||||
setHasOptionsMenu(true)
|
||||
return inflater.inflate(R.layout.fragment_main, container, false)
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val appBarConfiguration = AppBarConfiguration(navHost?.graph!!)
|
||||
activity?.findViewById<MaterialToolbar>(R.id.home_toolbar)?.setupWithNavController(navHost!!, appBarConfiguration)
|
||||
|
||||
navHost?.addOnDestinationChangedListener { _, currFrag: NavDestination, _ ->
|
||||
setDisplayHomeAsUpEnabled(currFrag.id != R.id.home_fragment)
|
||||
with (activity) {
|
||||
val tabHide = this.let { AnimationUtils.loadAnimation(it, R.anim.tablayout_exit) }
|
||||
val tabShow = this.let { AnimationUtils.loadAnimation(it, R.anim.tablayout_enter) }
|
||||
if (currFrag.id != R.id.home_fragment) {
|
||||
this?.findViewById<LinearLayout>(R.id.variant_tab_container)?.startAnimation(tabHide)
|
||||
this?.findViewById<LinearLayout>(R.id.variant_tab_container)?.visibility = View.GONE
|
||||
} else {
|
||||
this?.findViewById<LinearLayout>(R.id.variant_tab_container)?.visibility = View.VISIBLE
|
||||
this?.findViewById<LinearLayout>(R.id.variant_tab_container)?.startAnimation(tabShow)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setDisplayHomeAsUpEnabled(isNeeded: Boolean) {
|
||||
activity?.findViewById<MaterialToolbar>(R.id.home_toolbar)?.navigationIcon = if (isNeeded) activity?.getDrawable(R.drawable.ic_keyboard_backspace_black_24dp) else null
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.toolbar_about -> {
|
||||
navHost?.navigate(R.id.toAboutFragment)
|
||||
return true
|
||||
}
|
||||
R.id.toolbar_settings -> {
|
||||
navHost?.navigate(R.id.action_settingsFragment)
|
||||
return true
|
||||
}
|
||||
R.id.dev_settings -> {
|
||||
navHost?.navigate(R.id.toDevSettingsFragment)
|
||||
return true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="@style/MaterialCard"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:bind="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/bottom_nav_host"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_below="@id/home_appbar"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/mobile_navigation" />
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<fragment
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/nav_host"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/mobile_navigation"
|
||||
tools:context=".ui.fragments.MainFragment" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.4.0'
|
||||
ext.kotlin_version = '1.3.72'
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
|
Loading…
Reference in a new issue