LibreTube/app/src/main/java/com/github/libretube/MainActivity.kt

89 lines
3.3 KiB
Kotlin
Raw Normal View History

2022-02-01 21:22:06 +05:30
package com.github.libretube
2021-12-09 18:01:40 +05:30
2021-12-16 03:54:40 +05:30
import android.content.res.Configuration
2021-12-09 18:31:47 +05:30
import androidx.appcompat.app.AppCompatActivity
2021-12-09 18:01:40 +05:30
import android.os.Bundle
2021-12-28 01:37:07 +05:30
import android.view.Menu
import android.view.MenuItem
2022-01-29 18:41:00 +05:30
import android.view.View
import android.widget.FrameLayout
import androidx.appcompat.widget.Toolbar
2021-12-16 03:54:40 +05:30
import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.fragment.app.Fragment
2021-12-28 01:37:07 +05:30
import androidx.navigation.Navigation
2021-12-09 18:31:47 +05:30
import com.google.android.material.bottomnavigation.BottomNavigationView
2021-12-09 18:25:32 +05:30
import androidx.navigation.findNavController
import androidx.navigation.ui.NavigationUI
2021-12-28 01:37:07 +05:30
import androidx.navigation.ui.NavigationUI.onNavDestinationSelected
2021-12-09 18:25:32 +05:30
import androidx.navigation.ui.setupWithNavController
2021-12-14 21:45:53 +05:30
import com.google.android.exoplayer2.ExoPlayer
2021-12-09 18:01:40 +05:30
class MainActivity : AppCompatActivity() {
2021-12-28 01:37:07 +05:30
lateinit var bottomNavigationView: BottomNavigationView
lateinit var toolbar: Toolbar
2022-01-28 23:16:11 +05:30
var f = false
2021-12-09 18:01:40 +05:30
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportActionBar?.hide()
2021-12-09 18:01:40 +05:30
setContentView(R.layout.activity_main)
2021-12-28 01:37:07 +05:30
bottomNavigationView = findViewById<BottomNavigationView>(R.id.bottomNav)
2021-12-09 18:25:32 +05:30
val navController = findNavController(R.id.fragment)
bottomNavigationView.setupWithNavController(navController)
2021-12-28 01:37:07 +05:30
/* bottomNavigationView.setOnItemSelectedListener {
println("fuckoff")
onNavDestinationSelected(it,navController)
}*/
toolbar = findViewById(R.id.toolbar)
toolbar.setOnMenuItemClickListener{
when (it.itemId){
R.id.action_search -> {
val navController = findNavController(R.id.fragment)
navController.popBackStack()
navController.navigate(R.id.searchFragment)
2022-01-28 23:16:11 +05:30
f = true
true
}
R.id.action_settings -> {
true
}
}
false
2021-12-28 01:37:07 +05:30
}
2021-12-09 18:01:40 +05:30
}
2021-12-16 03:54:40 +05:30
2022-01-28 23:16:11 +05:30
override fun onBackPressed() {
if (f){
val navController = findNavController(R.id.fragment)
navController.popBackStack()
navController.navigate(R.id.home2)
f = false
}else {super.onBackPressed()}
}
2021-12-16 03:54:40 +05:30
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
val orientation = newConfig.orientation
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
2021-12-16 03:54:40 +05:30
println("Portrait")
//findViewById<MotionLayout>(R.id.playerMotionLayout).getTransition(R.id.yt_transition).isEnabled = true
} else if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
println("Landscape")
2022-01-29 18:41:00 +05:30
window.decorView.apply {
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN
}
2021-12-16 03:54:40 +05:30
//findViewById<MotionLayout>(R.id.playerMotionLayout).getTransition(R.id.yt_transition).isEnabled = false
}
}
2021-12-09 18:01:40 +05:30
}