mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
commit
8a9f86a91a
@ -45,6 +45,7 @@ class MainActivity : AppCompatActivity() {
|
||||
lateinit var binding: ActivityMainBinding
|
||||
|
||||
lateinit var navController: NavController
|
||||
private var startFragmentId = R.id.homeFragment
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
@ -91,7 +92,7 @@ class MainActivity : AppCompatActivity() {
|
||||
false
|
||||
|
||||
// save start tab fragment id
|
||||
val fragmentId = when (PreferenceHelper.getString(this, "default_tab", "home")) {
|
||||
startFragmentId = when (PreferenceHelper.getString(this, "default_tab", "home")) {
|
||||
"home" -> R.id.homeFragment
|
||||
"subscriptions" -> R.id.subscriptionsFragment
|
||||
"library" -> R.id.libraryFragment
|
||||
@ -99,23 +100,23 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
// set default tab as start fragment
|
||||
navController.graph.setStartDestination(fragmentId)
|
||||
navController.graph.setStartDestination(startFragmentId)
|
||||
|
||||
// navigate to the default fragment
|
||||
navController.navigate(fragmentId)
|
||||
navController.navigate(startFragmentId)
|
||||
|
||||
binding.bottomNav.setOnItemSelectedListener {
|
||||
// clear backstack if it's the start fragment
|
||||
if (startFragmentId == it.itemId) navController.backQueue.clear()
|
||||
// set menu item on click listeners
|
||||
when (it.itemId) {
|
||||
R.id.homeFragment -> {
|
||||
navController.backQueue.clear()
|
||||
navController.navigate(R.id.homeFragment)
|
||||
}
|
||||
R.id.subscriptionsFragment -> {
|
||||
// navController.backQueue.clear()
|
||||
navController.navigate(R.id.subscriptionsFragment)
|
||||
}
|
||||
R.id.libraryFragment -> {
|
||||
// navController.backQueue.clear()
|
||||
navController.navigate(R.id.libraryFragment)
|
||||
}
|
||||
}
|
||||
@ -268,33 +269,30 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
try {
|
||||
val mainMotionLayout = binding.mainMotionLayout
|
||||
if (mainMotionLayout.progress == 0.toFloat()) {
|
||||
mainMotionLayout.transitionToEnd()
|
||||
findViewById<ConstraintLayout>(R.id.main_container).isClickable = false
|
||||
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
||||
motionLayout.transitionToEnd()
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
with(motionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||
enableTransition(R.id.yt_transition, true)
|
||||
}
|
||||
findViewById<LinearLayout>(R.id.linLayout).visibility = View.VISIBLE
|
||||
isFullScreen = false
|
||||
} else {
|
||||
navController.popBackStack()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
navController.popBackStack()
|
||||
moveTaskToBack(true)
|
||||
} catch (e: Exception) {
|
||||
super.onBackPressed()
|
||||
}
|
||||
if (binding.mainMotionLayout.progress == 0F) {
|
||||
try { minimizePlayer() } catch (e: Exception) {}
|
||||
} else if (navController.currentDestination?.id == startFragmentId) {
|
||||
navController.popBackStack()
|
||||
super.onBackPressed()
|
||||
} else {
|
||||
navController.popBackStack()
|
||||
}
|
||||
}
|
||||
|
||||
private fun minimizePlayer() {
|
||||
binding.mainMotionLayout.transitionToEnd()
|
||||
findViewById<ConstraintLayout>(R.id.main_container).isClickable = false
|
||||
val motionLayout = findViewById<MotionLayout>(R.id.playerMotionLayout)
|
||||
motionLayout.transitionToEnd()
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
with(motionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||
enableTransition(R.id.yt_transition, true)
|
||||
}
|
||||
findViewById<LinearLayout>(R.id.linLayout).visibility = View.VISIBLE
|
||||
isFullScreen = false
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
val orientation = newConfig.orientation
|
||||
|
@ -12,6 +12,6 @@ class PlayerSettings : PreferenceFragmentCompat() {
|
||||
setPreferencesFromResource(R.xml.player_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.player))
|
||||
settingsActivity.changeTopBarText(getString(R.string.audio_video))
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +180,8 @@
|
||||
<ImageButton
|
||||
android:id="@+id/fullscreen"
|
||||
style="@style/ExoStyledControls.Button.Bottom.FullScreen"
|
||||
android:src="@drawable/ic_fullscreen" />
|
||||
android:src="@drawable/ic_fullscreen"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -608,7 +608,7 @@
|
||||
<item>@string/birdIcon</item>
|
||||
</string-array>
|
||||
<string-array name="iconsValue">
|
||||
<item>MainActivity</item>
|
||||
<item>activities.MainActivity</item>
|
||||
<item>IconLegacy</item>
|
||||
<item>IconGradient</item>
|
||||
<item>IconFire</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user