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