Merge pull request #655 from Bnyro/master

[SILENT] activities package
This commit is contained in:
Bnyro 2022-07-01 16:55:52 +02:00 committed by GitHub
commit 0c332c9e71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 121 additions and 103 deletions

View File

@ -24,13 +24,15 @@
<activity <activity
android:name=".util.Player" android:name=".util.Player"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:exported="false" android:exported="false" />
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<activity <activity
android:name=".SettingsActivity" android:name=".activities.NoInternetActivity"
android:label="@string/noInternet"/>
<activity
android:name=".activities.SettingsActivity"
android:label="@string/settings" /> android:label="@string/settings" />
<activity <activity
android:name=".MainActivity" android:name=".activities.MainActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:exported="true" android:exported="true"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
@ -53,7 +55,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_gradient_round" android:roundIcon="@mipmap/ic_gradient_round"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"
android:targetActivity=".MainActivity"> android:targetActivity=".activities.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -70,7 +72,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_fire_round" android:roundIcon="@mipmap/ic_fire_round"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"
android:targetActivity=".MainActivity"> android:targetActivity=".activities.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -87,7 +89,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_flame_round" android:roundIcon="@mipmap/ic_flame_round"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"
android:targetActivity=".MainActivity"> android:targetActivity=".activities.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -104,7 +106,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_shaped_round" android:roundIcon="@mipmap/ic_shaped_round"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"
android:targetActivity=".MainActivity"> android:targetActivity=".activities.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -121,7 +123,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_torch_round" android:roundIcon="@mipmap/ic_torch_round"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"
android:targetActivity=".MainActivity"> android:targetActivity=".activities.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -138,7 +140,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_legacy_round" android:roundIcon="@mipmap/ic_legacy_round"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"
android:targetActivity=".MainActivity"> android:targetActivity=".activities.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -155,7 +157,7 @@
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_bird_round" android:roundIcon="@mipmap/ic_bird_round"
android:supportsPictureInPicture="true" android:supportsPictureInPicture="true"
android:targetActivity=".MainActivity"> android:targetActivity=".activities.MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
@ -163,7 +165,7 @@
</activity-alias> </activity-alias>
<activity <activity
android:name=".RouterActivity" android:name=".activities.RouterActivity"
android:exported="true" android:exported="true"
android:launchMode="singleInstance"> android:launchMode="singleInstance">
<intent-filter> <intent-filter>

View File

@ -1,4 +1,4 @@
package com.github.libretube package com.github.libretube.activities
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
@ -19,11 +19,8 @@ import android.view.WindowInsets
import android.view.WindowInsetsController import android.view.WindowInsetsController
import android.view.WindowManager import android.view.WindowManager
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
@ -32,6 +29,7 @@ import androidx.fragment.app.Fragment
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.findNavController import androidx.navigation.findNavController
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import com.github.libretube.R
import com.github.libretube.databinding.ActivityMainBinding import com.github.libretube.databinding.ActivityMainBinding
import com.github.libretube.fragments.PlayerFragment import com.github.libretube.fragments.PlayerFragment
import com.github.libretube.fragments.isFullScreen import com.github.libretube.fragments.isFullScreen
@ -50,7 +48,6 @@ class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding lateinit var binding: ActivityMainBinding
private lateinit var bottomNavigationView: BottomNavigationView private lateinit var bottomNavigationView: BottomNavigationView
private lateinit var toolbar: Toolbar
lateinit var navController: NavController lateinit var navController: NavController
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -70,14 +67,8 @@ class MainActivity : AppCompatActivity() {
// show noInternet Activity if no internet available on app startup // show noInternet Activity if no internet available on app startup
if (!isNetworkAvailable(this)) { if (!isNetworkAvailable(this)) {
setContentView(R.layout.activity_nointernet) val noInternetIntent = Intent(this, NoInternetActivity::class.java)
findViewById<Button>(R.id.retry_button).setOnClickListener { startActivity(noInternetIntent)
recreate()
}
findViewById<ImageView>(R.id.noInternet_settingsImageView).setOnClickListener {
val intent = Intent(this, SettingsActivity::class.java)
startActivity(intent)
}
} else { } else {
binding = ActivityMainBinding.inflate(layoutInflater) binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
@ -286,7 +277,6 @@ class MainActivity : AppCompatActivity() {
navController.popBackStack() navController.popBackStack()
} }
} catch (e: Exception) { } catch (e: Exception) {
// try catch to prevent nointernet activity to crash
try { try {
navController.popBackStack() navController.popBackStack()
moveTaskToBack(true) moveTaskToBack(true)
@ -364,10 +354,6 @@ fun Fragment.hideKeyboard() {
view?.let { activity?.hideKeyboard(it) } view?.let { activity?.hideKeyboard(it) }
} }
fun Activity.hideKeyboard() {
hideKeyboard(currentFocus ?: View(this))
}
fun Context.hideKeyboard(view: View) { fun Context.hideKeyboard(view: View) {
val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0) inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)

View File

@ -0,0 +1,31 @@
package com.github.libretube.activities
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.databinding.ActivityNointernetBinding
import com.github.libretube.util.ThemeHelper
import com.google.android.material.color.DynamicColors
class NoInternetActivity : AppCompatActivity() {
private lateinit var binding: ActivityNointernetBinding
override fun onCreate(savedInstanceState: Bundle?) {
DynamicColors.applyToActivityIfAvailable(this)
super.onCreate(savedInstanceState)
binding = ActivityNointernetBinding.inflate(layoutInflater)
binding.retryButton.setOnClickListener {
ThemeHelper.restartMainActivity(this)
}
binding.noInternetSettingsImageView.setOnClickListener {
val intent = Intent(this, SettingsActivity::class.java)
startActivity(intent)
}
setContentView(binding.root)
}
override fun onBackPressed() {
finishAffinity()
super.onBackPressed()
}
}

View File

@ -1,4 +1,4 @@
package com.github.libretube package com.github.libretube.activities
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
@ -6,6 +6,7 @@ import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.util.Log
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.github.libretube.R
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
class RouterActivity : AppCompatActivity() { class RouterActivity : AppCompatActivity() {

View File

@ -1,10 +1,11 @@
package com.github.libretube package com.github.libretube.activities
import android.app.NotificationManager import android.app.NotificationManager
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import com.github.libretube.R
import com.github.libretube.databinding.ActivitySettingsBinding import com.github.libretube.databinding.ActivitySettingsBinding
import com.github.libretube.preferences.MainSettings import com.github.libretube.preferences.MainSettings
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper

View File

@ -9,8 +9,8 @@ import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.CommentsRowBinding import com.github.libretube.databinding.CommentsRowBinding
import com.github.libretube.obj.Comment import com.github.libretube.obj.Comment
import com.github.libretube.obj.CommentsPage import com.github.libretube.obj.CommentsPage

View File

@ -7,8 +7,8 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.PlaylistsRowBinding import com.github.libretube.databinding.PlaylistsRowBinding
import com.github.libretube.obj.PlaylistId import com.github.libretube.obj.PlaylistId
import com.github.libretube.obj.Playlists import com.github.libretube.obj.Playlists

View File

@ -6,8 +6,8 @@ import android.view.ViewGroup
import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.RepliesRowBinding import com.github.libretube.databinding.RepliesRowBinding
import com.github.libretube.obj.Comment import com.github.libretube.obj.Comment
import com.github.libretube.util.formatShort import com.github.libretube.util.formatShort

View File

@ -11,8 +11,11 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.ChannelSearchRowBinding
import com.github.libretube.databinding.PlaylistSearchRowBinding
import com.github.libretube.databinding.VideoSearchRowBinding
import com.github.libretube.dialogs.PlaylistOptionsDialog import com.github.libretube.dialogs.PlaylistOptionsDialog
import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment import com.github.libretube.fragments.PlayerFragment
@ -37,15 +40,15 @@ class SearchAdapter(
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SearchViewHolder {
val layout = when (viewType) { val layoutInflater = LayoutInflater.from(parent.context)
0 -> R.layout.video_search_row
1 -> R.layout.channel_search_row val binding = when (viewType) {
2 -> R.layout.playlist_search_row 0 -> VideoSearchRowBinding.inflate(layoutInflater, parent, false)
1 -> ChannelSearchRowBinding.inflate(layoutInflater, parent, false)
2 -> PlaylistSearchRowBinding.inflate(layoutInflater, parent, false)
else -> throw IllegalArgumentException("Invalid type") else -> throw IllegalArgumentException("Invalid type")
} }
val layoutInflater = LayoutInflater.from(parent.context) return SearchViewHolder(binding.root, childFragmentManager)
val cell = layoutInflater.inflate(layout, parent, false)
return SearchViewHolder(cell, childFragmentManager)
} }
override fun onBindViewHolder(holder: SearchViewHolder, position: Int) { override fun onBindViewHolder(holder: SearchViewHolder, position: Int) {

View File

@ -10,8 +10,8 @@ import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.TrendingRowBinding import com.github.libretube.databinding.TrendingRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment import com.github.libretube.fragments.PlayerFragment

View File

@ -7,8 +7,8 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.ChannelSubscriptionRowBinding import com.github.libretube.databinding.ChannelSubscriptionRowBinding
import com.github.libretube.obj.Subscribe import com.github.libretube.obj.Subscribe
import com.github.libretube.obj.Subscription import com.github.libretube.obj.Subscription

View File

@ -10,8 +10,8 @@ import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.TrendingRowBinding import com.github.libretube.databinding.TrendingRowBinding
import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog
import com.github.libretube.fragments.PlayerFragment import com.github.libretube.fragments.PlayerFragment

View File

@ -9,9 +9,9 @@ import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.requireMainActivityRestart
import com.github.libretube.databinding.DialogDeleteAccountBinding import com.github.libretube.databinding.DialogDeleteAccountBinding
import com.github.libretube.obj.DeleteUserRequest import com.github.libretube.obj.DeleteUserRequest
import com.github.libretube.requireMainActivityRestart
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder

View File

@ -13,8 +13,8 @@ import android.widget.ArrayAdapter
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.databinding.DialogDownloadBinding import com.github.libretube.databinding.DialogDownloadBinding
import com.github.libretube.obj.Streams import com.github.libretube.obj.Streams
import com.github.libretube.services.DownloadService import com.github.libretube.services.DownloadService

View File

@ -6,8 +6,8 @@ import android.os.Bundle
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.Toast import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.github.libretube.BackgroundMode
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.util.BackgroundMode
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder

View File

@ -19,11 +19,6 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Button
import android.widget.FrameLayout
import android.widget.ImageButton
import android.widget.LinearLayout
import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.constraintlayout.motion.widget.MotionLayout import androidx.constraintlayout.motion.widget.MotionLayout
import androidx.core.net.toUri import androidx.core.net.toUri
@ -33,8 +28,9 @@ import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.MainActivity
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.MainActivity
import com.github.libretube.activities.hideKeyboard
import com.github.libretube.adapters.ChaptersAdapter import com.github.libretube.adapters.ChaptersAdapter
import com.github.libretube.adapters.CommentsAdapter import com.github.libretube.adapters.CommentsAdapter
import com.github.libretube.adapters.TrendingAdapter import com.github.libretube.adapters.TrendingAdapter
@ -42,7 +38,6 @@ import com.github.libretube.databinding.FragmentPlayerBinding
import com.github.libretube.dialogs.AddtoPlaylistDialog import com.github.libretube.dialogs.AddtoPlaylistDialog
import com.github.libretube.dialogs.DownloadDialog import com.github.libretube.dialogs.DownloadDialog
import com.github.libretube.dialogs.ShareDialog import com.github.libretube.dialogs.ShareDialog
import com.github.libretube.hideKeyboard
import com.github.libretube.obj.ChapterSegment import com.github.libretube.obj.ChapterSegment
import com.github.libretube.obj.PipedStream import com.github.libretube.obj.PipedStream
import com.github.libretube.obj.Playlist import com.github.libretube.obj.Playlist
@ -80,7 +75,6 @@ import com.google.android.exoplayer2.upstream.DefaultDataSource
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
import com.google.android.exoplayer2.util.RepeatModeUtil import com.google.android.exoplayer2.util.RepeatModeUtil
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -233,7 +227,7 @@ class PlayerFragment : Fragment() {
.remove(this) .remove(this)
.commit() .commit()
} }
view.findViewById<ImageButton>(R.id.close_imageButton).setOnClickListener { binding.player.binding.closeImageButton.setOnClickListener {
isMiniPlayerVisible = false isMiniPlayerVisible = false
binding.playerMotionLayout.transitionToEnd() binding.playerMotionLayout.transitionToEnd()
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
@ -261,13 +255,12 @@ class PlayerFragment : Fragment() {
if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE if (binding.descLinLayout.isVisible) View.GONE else View.VISIBLE
} }
view.findViewById<MaterialCardView>(R.id.comments_toggle) binding.commentsToggle.setOnClickListener {
.setOnClickListener {
toggleComments() toggleComments()
} }
val fullScreenButton = view.findViewById<ImageButton>(R.id.fullscreen) val fullScreenButton = binding.player.binding.fullscreen
val exoTitle = view.findViewById<TextView>(R.id.exo_title) val exoTitle = binding.player.binding.exoTitle
// FullScreen button trigger // FullScreen button trigger
fullScreenButton.setOnClickListener { fullScreenButton.setOnClickListener {
@ -303,7 +296,8 @@ class PlayerFragment : Fragment() {
} }
// switching between original aspect ratio (black bars) and zoomed to fill device screen // switching between original aspect ratio (black bars) and zoomed to fill device screen
view.findViewById<ImageButton>(R.id.aspect_ratio_button).setOnClickListener { val aspectRatioButton = binding.player.binding.aspectRatioButton
aspectRatioButton.setOnClickListener {
if (isZoomed) { if (isZoomed) {
exoPlayerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT exoPlayerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
isZoomed = false isZoomed = false
@ -314,7 +308,7 @@ class PlayerFragment : Fragment() {
} }
// lock and unlock the player // lock and unlock the player
val lockPlayerButton = view.findViewById<ImageButton>(R.id.lock_player) val lockPlayerButton = binding.player.binding.lockPlayer
lockPlayerButton.setOnClickListener { lockPlayerButton.setOnClickListener {
// change the locked/unlocked icon // change the locked/unlocked icon
if (!isPlayerLocked) { if (!isPlayerLocked) {
@ -630,7 +624,7 @@ class PlayerFragment : Fragment() {
binding.playerTitle.text = response.title binding.playerTitle.text = response.title
binding.playerDescription.text = response.description binding.playerDescription.text = response.description
view.findViewById<TextView>(R.id.exo_title).text = response.title binding.player.binding.exoTitle.text = response.title
// Listener for play and pause icon change // Listener for play and pause icon change
exoPlayer.addListener(object : Player.Listener { exoPlayer.addListener(object : Player.Listener {
@ -802,8 +796,8 @@ class PlayerFragment : Fragment() {
PreferenceHelper.getString(requireContext(), "player_video_format", "WEBM") PreferenceHelper.getString(requireContext(), "player_video_format", "WEBM")
val defres = PreferenceHelper.getString(requireContext(), "default_res", "")!! val defres = PreferenceHelper.getString(requireContext(), "default_res", "")!!
val qualityText = view.findViewById<TextView>(R.id.quality_text) val qualityText = binding.player.binding.qualityText
val qualitySelect = view.findViewById<LinearLayout>(R.id.quality_linLayout) val qualitySelect = binding.player.binding.qualitySelect
var videosNameArray: Array<CharSequence> = arrayOf() var videosNameArray: Array<CharSequence> = arrayOf()
var videosUrlArray: Array<Uri> = arrayOf() var videosUrlArray: Array<Uri> = arrayOf()
@ -987,12 +981,12 @@ class PlayerFragment : Fragment() {
private fun lockPlayer(isLocked: Boolean) { private fun lockPlayer(isLocked: Boolean) {
val visibility = if (isLocked) View.VISIBLE else View.INVISIBLE val visibility = if (isLocked) View.VISIBLE else View.INVISIBLE
exoPlayerView.findViewById<LinearLayout>(R.id.exo_top_bar_right).visibility = visibility binding.player.binding.exoTopBarRight.visibility = visibility
exoPlayerView.findViewById<ImageButton>(R.id.exo_play_pause).visibility = visibility binding.player.binding.exoPlayPause.visibility = visibility
exoPlayerView.findViewById<Button>(R.id.exo_ffwd_with_amount).visibility = visibility binding.player.binding.exoFfwdWithAmount.visibility = visibility
exoPlayerView.findViewById<Button>(R.id.exo_rew_with_amount).visibility = visibility binding.player.binding.exoRewWithAmount.visibility = visibility
exoPlayerView.findViewById<FrameLayout>(R.id.exo_bottom_bar).visibility = visibility binding.player.binding.exoBottomBar.visibility = visibility
exoPlayerView.findViewById<TextView>(R.id.exo_title).visibility = binding.player.binding.exoTitle.visibility =
if (isLocked && isFullScreen) View.VISIBLE else View.INVISIBLE if (isLocked && isFullScreen) View.VISIBLE else View.INVISIBLE
} }
@ -1154,7 +1148,7 @@ class PlayerFragment : Fragment() {
enableTransition(R.id.yt_transition, false) enableTransition(R.id.yt_transition, false)
} }
binding.mainContainer.isClickable = true binding.mainContainer.isClickable = true
view?.findViewById<LinearLayout>(R.id.exo_top_bar)?.visibility = View.GONE binding.player.binding.exoTopBar.visibility = View.GONE
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
isFullScreen = false isFullScreen = false
@ -1166,7 +1160,7 @@ class PlayerFragment : Fragment() {
exoPlayerView.showController() exoPlayerView.showController()
exoPlayerView.useController = true exoPlayerView.useController = true
binding.mainContainer.isClickable = false binding.mainContainer.isClickable = false
view?.findViewById<LinearLayout>(R.id.exo_top_bar)?.visibility = View.VISIBLE binding.player.binding.exoTopBar.visibility = View.VISIBLE
} }
} }

View File

@ -20,11 +20,11 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.activities.hideKeyboard
import com.github.libretube.adapters.SearchAdapter import com.github.libretube.adapters.SearchAdapter
import com.github.libretube.adapters.SearchHistoryAdapter import com.github.libretube.adapters.SearchHistoryAdapter
import com.github.libretube.adapters.SearchSuggestionsAdapter import com.github.libretube.adapters.SearchSuggestionsAdapter
import com.github.libretube.databinding.FragmentSearchBinding import com.github.libretube.databinding.FragmentSearchBinding
import com.github.libretube.hideKeyboard
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder

View File

@ -9,14 +9,14 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.github.libretube.AUTHORS_URL
import com.github.libretube.CONTRIBUTING_URL
import com.github.libretube.DONATE_URL
import com.github.libretube.PIPED_GITHUB_URL
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.SettingsActivity import com.github.libretube.activities.SettingsActivity
import com.github.libretube.WEBSITE_URL
import com.github.libretube.databinding.FragmentAboutBinding import com.github.libretube.databinding.FragmentAboutBinding
import com.github.libretube.util.AUTHORS_URL
import com.github.libretube.util.CONTRIBUTING_URL
import com.github.libretube.util.DONATE_URL
import com.github.libretube.util.PIPED_GITHUB_URL
import com.github.libretube.util.WEBSITE_URL
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
class AboutFragment : Fragment() { class AboutFragment : Fragment() {

View File

@ -4,8 +4,8 @@ import android.os.Bundle
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.SettingsActivity import com.github.libretube.activities.SettingsActivity
import com.github.libretube.requireMainActivityRestart import com.github.libretube.activities.requireMainActivityRestart
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder

View File

@ -6,8 +6,8 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference import androidx.preference.SwitchPreference
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.SettingsActivity import com.github.libretube.activities.SettingsActivity
import com.github.libretube.requireMainActivityRestart import com.github.libretube.activities.requireMainActivityRestart
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
class AppearanceSettings : PreferenceFragmentCompat() { class AppearanceSettings : PreferenceFragmentCompat() {

View File

@ -18,12 +18,12 @@ import androidx.preference.ListPreference
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.SettingsActivity import com.github.libretube.activities.SettingsActivity
import com.github.libretube.activities.requireMainActivityRestart
import com.github.libretube.dialogs.CustomInstanceDialog import com.github.libretube.dialogs.CustomInstanceDialog
import com.github.libretube.dialogs.DeleteAccountDialog import com.github.libretube.dialogs.DeleteAccountDialog
import com.github.libretube.dialogs.LoginDialog import com.github.libretube.dialogs.LoginDialog
import com.github.libretube.dialogs.LogoutDialog import com.github.libretube.dialogs.LogoutDialog
import com.github.libretube.requireMainActivityRestart
import com.github.libretube.util.PreferenceHelper import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance import com.github.libretube.util.RetrofitInstance
import org.json.JSONObject import org.json.JSONObject

View File

@ -8,8 +8,8 @@ import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.BuildConfig import com.github.libretube.BuildConfig
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.isCurrentViewMainSettings import com.github.libretube.activities.isCurrentViewMainSettings
import com.github.libretube.requireMainActivityRestart import com.github.libretube.activities.requireMainActivityRestart
import com.github.libretube.util.ThemeHelper import com.github.libretube.util.ThemeHelper
import com.github.libretube.util.checkUpdate import com.github.libretube.util.checkUpdate

View File

@ -3,7 +3,7 @@ package com.github.libretube.preferences
import android.os.Bundle import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.SettingsActivity import com.github.libretube.activities.SettingsActivity
class PlayerSettings : PreferenceFragmentCompat() { class PlayerSettings : PreferenceFragmentCompat() {
val TAG = "PlayerSettings" val TAG = "PlayerSettings"

View File

@ -3,7 +3,7 @@ package com.github.libretube.preferences
import android.os.Bundle import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceFragmentCompat
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.SettingsActivity import com.github.libretube.activities.SettingsActivity
class SponsorBlockSettings : PreferenceFragmentCompat() { class SponsorBlockSettings : PreferenceFragmentCompat() {
private val TAG = "SponsorBlockSettings" private val TAG = "SponsorBlockSettings"

View File

@ -1,12 +1,9 @@
package com.github.libretube package com.github.libretube.util
import android.app.NotificationManager import android.app.NotificationManager
import android.content.Context import android.content.Context
import android.support.v4.media.session.MediaSessionCompat import android.support.v4.media.session.MediaSessionCompat
import com.github.libretube.obj.Streams import com.github.libretube.obj.Streams
import com.github.libretube.util.DescriptionAdapter
import com.github.libretube.util.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import com.google.android.exoplayer2.C import com.google.android.exoplayer2.C
import com.google.android.exoplayer2.ExoPlayer import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem import com.google.android.exoplayer2.MediaItem

View File

@ -1,4 +1,4 @@
package com.github.libretube package com.github.libretube.util
const val GITHUB_API_URL = "https://api.github.com/repos/libre-tube/LibreTube/releases/latest" const val GITHUB_API_URL = "https://api.github.com/repos/libre-tube/LibreTube/releases/latest"
const val WEBSITE_URL = "https://libre-tube.github.io/" const val WEBSITE_URL = "https://libre-tube.github.io/"

View File

@ -4,12 +4,14 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.view.MotionEvent import android.view.MotionEvent
import com.github.libretube.databinding.ExoStyledPlayerControlViewBinding
import com.google.android.exoplayer2.ui.StyledPlayerView import com.google.android.exoplayer2.ui.StyledPlayerView
internal class CustomExoPlayerView( internal class CustomExoPlayerView(
context: Context, context: Context,
attributeSet: AttributeSet? = null attributeSet: AttributeSet? = null
) : StyledPlayerView(context, attributeSet) { ) : StyledPlayerView(context, attributeSet) {
val binding: ExoStyledPlayerControlViewBinding = ExoStyledPlayerControlViewBinding.bind(this)
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean { override fun onTouchEvent(event: MotionEvent): Boolean {

View File

@ -5,7 +5,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import com.github.libretube.MainActivity import com.github.libretube.activities.MainActivity
import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.ui.PlayerNotificationManager import com.google.android.exoplayer2.ui.PlayerNotificationManager
import java.net.URL import java.net.URL

View File

@ -3,7 +3,6 @@ package com.github.libretube.util
import android.util.Log import android.util.Log
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import com.github.libretube.BuildConfig import com.github.libretube.BuildConfig
import com.github.libretube.GITHUB_API_URL
import com.github.libretube.dialogs.NoUpdateAvailableDialog import com.github.libretube.dialogs.NoUpdateAvailableDialog
import com.github.libretube.dialogs.UpdateAvailableDialog import com.github.libretube.dialogs.UpdateAvailableDialog
import com.github.libretube.obj.UpdateInfo import com.github.libretube.obj.UpdateInfo

View File

@ -6,10 +6,12 @@
<ImageView <ImageView
android:id="@+id/noInternet_settingsImageView" android:id="@+id/noInternet_settingsImageView"
android:layout_width="30dp" android:padding="3dp"
android:layout_height="30dp" android:layout_width="33dp"
android:layout_height="33dp"
android:layout_margin="16dp" android:layout_margin="16dp"
android:src="@drawable/ic_settings" android:src="@drawable/ic_settings"
android:background="?attr/selectableItemBackgroundBorderless"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />