mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
convert prefs to viewbinding
This commit is contained in:
parent
9ebd3d5f7e
commit
92993db5c7
@ -3,11 +3,9 @@ package com.github.libretube
|
||||
import android.app.NotificationManager
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.ImageButton
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.app.ActivityCompat
|
||||
import com.github.libretube.databinding.ActivitySettingsBinding
|
||||
import com.github.libretube.preferences.MainSettings
|
||||
import com.github.libretube.util.ThemeHelper
|
||||
import com.google.android.material.color.DynamicColors
|
||||
@ -17,24 +15,27 @@ var requireMainActivityRestart = false
|
||||
|
||||
class SettingsActivity : AppCompatActivity() {
|
||||
val TAG = "SettingsActivity"
|
||||
lateinit var binding: ActivitySettingsBinding
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
DynamicColors.applyToActivityIfAvailable(this)
|
||||
ThemeHelper.updateTheme(this)
|
||||
|
||||
// makes the preference dialogs use material dialogs
|
||||
setTheme(R.style.MaterialAlertDialog)
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = ActivitySettingsBinding.inflate(layoutInflater)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
overridePendingTransition(50, 50)
|
||||
}
|
||||
val view = this.findViewById<View>(android.R.id.content)
|
||||
view.alpha = 0F
|
||||
view.animate().alpha(1F).duration = 300
|
||||
binding.root.alpha = 0F
|
||||
binding.root.animate().alpha(1F).duration = 300
|
||||
|
||||
setContentView(R.layout.activity_settings)
|
||||
setContentView(binding.root)
|
||||
|
||||
val backButton = view.findViewById<ImageButton>(R.id.back_imageButton)
|
||||
backButton.setOnClickListener {
|
||||
binding.backImageButton.setOnClickListener {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
@ -66,8 +67,7 @@ class SettingsActivity : AppCompatActivity() {
|
||||
.beginTransaction()
|
||||
.replace(R.id.settings, MainSettings())
|
||||
.commit()
|
||||
val topBarTextView = findViewById<TextView>(R.id.topBar_textView)
|
||||
topBarTextView?.text = getString(R.string.settings)
|
||||
binding.topBarTextView.text = getString(R.string.settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,8 @@ class LoginDialog : DialogFragment() {
|
||||
|
||||
binding.login.setOnClickListener {
|
||||
if (binding.username.text.toString() != "" && binding.password.text.toString() != "") {
|
||||
val login = Login(binding.username.text.toString(), binding.password.text.toString())
|
||||
val login =
|
||||
Login(binding.username.text.toString(), binding.password.text.toString())
|
||||
login(login)
|
||||
} else {
|
||||
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
||||
|
@ -17,15 +17,19 @@ import com.github.libretube.DONATE_URL
|
||||
import com.github.libretube.PIPED_GITHUB_URL
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.WEBSITE_URL
|
||||
import com.github.libretube.databinding.FragmentAboutBinding
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class AboutFragment : Fragment() {
|
||||
private lateinit var binding: FragmentAboutBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_about, container, false)
|
||||
): View {
|
||||
binding = FragmentAboutBinding.inflate(layoutInflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.github.libretube.preferences
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.SettingsActivity
|
||||
import com.github.libretube.requireMainActivityRestart
|
||||
import com.github.libretube.util.PreferenceHelper
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
@ -15,8 +15,8 @@ class AdvancedSettings : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.advanced_settings, rootKey)
|
||||
|
||||
val topBarTextView = activity?.findViewById<TextView>(R.id.topBar_textView)
|
||||
topBarTextView?.text = getString(R.string.advanced)
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.advanced)
|
||||
|
||||
val clearHistory = findPreference<Preference>("clear_history")
|
||||
clearHistory?.setOnPreferenceClickListener {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.github.libretube.preferences
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.SwitchPreference
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.SettingsActivity
|
||||
import com.github.libretube.requireMainActivityRestart
|
||||
import com.github.libretube.util.ThemeHelper
|
||||
|
||||
@ -15,8 +15,8 @@ class AppearanceSettings : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.appearance_settings, rootKey)
|
||||
|
||||
val topBarTextView = activity?.findViewById<TextView>(R.id.topBar_textView)
|
||||
topBarTextView?.text = getString(R.string.appearance)
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.appearance)
|
||||
|
||||
val themeToggle = findPreference<ListPreference>("theme_togglee")
|
||||
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
||||
|
@ -8,7 +8,6 @@ import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.core.app.ActivityCompat
|
||||
@ -19,6 +18,7 @@ import androidx.preference.ListPreference
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.SettingsActivity
|
||||
import com.github.libretube.dialogs.CustomInstanceDialog
|
||||
import com.github.libretube.dialogs.DeleteAccountDialog
|
||||
import com.github.libretube.dialogs.LoginDialog
|
||||
@ -111,8 +111,8 @@ class InstanceSettings : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.instance_settings, rootKey)
|
||||
|
||||
val topBarTextView = activity?.findViewById<TextView>(R.id.topBar_textView)
|
||||
topBarTextView?.text = getString(R.string.instance)
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.instance)
|
||||
|
||||
val instance = findPreference<ListPreference>("selectInstance")
|
||||
// fetchInstance()
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.github.libretube.preferences
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.SettingsActivity
|
||||
|
||||
class PlayerSettings : PreferenceFragmentCompat() {
|
||||
val TAG = "PlayerSettings"
|
||||
@ -11,7 +11,7 @@ class PlayerSettings : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.player_settings, rootKey)
|
||||
|
||||
val topBarTextView = activity?.findViewById<TextView>(R.id.topBar_textView)
|
||||
topBarTextView?.text = getString(R.string.player)
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.player)
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.github.libretube.preferences
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.SettingsActivity
|
||||
|
||||
class SponsorBlockSettings : PreferenceFragmentCompat() {
|
||||
private val TAG = "SponsorBlockSettings"
|
||||
@ -11,7 +11,7 @@ class SponsorBlockSettings : PreferenceFragmentCompat() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey)
|
||||
|
||||
val topBarTextView = activity?.findViewById<TextView>(R.id.topBar_textView)
|
||||
topBarTextView?.text = getString(R.string.sponsorblock)
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.binding.topBarTextView.text = getString(R.string.sponsorblock)
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="1280dp"
|
||||
android:height="1280dp"
|
||||
android:viewportWidth="1280"
|
||||
android:viewportHeight="1280">
|
||||
<path
|
||||
android:pathData="m863.3,639.7c0,-2.3 -1.2,-4.4 -3.1,-5.5L527.9,437.1c-5.8,-3.4 -13.1,0.8 -13.1,7.6v85c0,3.2 1.7,6.1 4.4,7.7l165.6,94.8c5.9,3.4 5.9,12 0,15.4l-165.6,94.8c-2.7,1.6 -4.4,4.5 -4.4,7.7v84.9c0,6.8 7.3,11.1 13.1,7.6L860.1,645.2c1.9,-1.2 3.1,-3.3 3.1,-5.5z"
|
||||
android:strokeWidth="30"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="#000000"/>
|
||||
<path
|
||||
android:pathData="m582.8,634.5c4.2,2.4 4.2,8.5 0,10.9l-73.8,42.5c-4.1,2.4 -9.2,-0.6 -9.2,-5.4v-85.1c0,-4.8 5.1,-7.8 9.2,-5.4z"
|
||||
android:strokeWidth="0"
|
||||
android:fillColor="#000000"
|
||||
android:strokeColor="#000000"/>
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="m863.3,639.7c0,-2.3 -1.2,-4.4 -3.1,-5.5L527.9,437.1c-5.8,-3.4 -13.1,0.8 -13.1,7.6v85c0,3.2 1.7,6.1 4.4,7.7l165.6,94.8c5.9,3.4 5.9,12 0,15.4l-165.6,94.8c-2.7,1.6 -4.4,4.5 -4.4,7.7v84.9c0,6.8 7.3,11.1 13.1,7.6L860.1,645.2c1.9,-1.2 3.1,-3.3 3.1,-5.5z"
|
||||
android:strokeWidth="30"
|
||||
android:strokeColor="#000000" />
|
||||
<path
|
||||
android:fillColor="#000000"
|
||||
android:pathData="m582.8,634.5c4.2,2.4 4.2,8.5 0,10.9l-73.8,42.5c-4.1,2.4 -9.2,-0.6 -9.2,-5.4v-85.1c0,-4.8 5.1,-7.8 9.2,-5.4z"
|
||||
android:strokeWidth="0"
|
||||
android:strokeColor="#000000" />
|
||||
</vector>
|
||||
|
@ -3,9 +3,9 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="5dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="5dp">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/chapter_image"
|
||||
|
Loading…
Reference in New Issue
Block a user