settings fragment

This commit is contained in:
rimthekid 2022-02-08 13:28:50 +04:00
parent 27e7d56340
commit 9ba4b17c0d
7 changed files with 47 additions and 18 deletions

View File

@ -41,6 +41,7 @@ dependencies {
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation("androidx.preference:preference-ktx:1.2.0")
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

View File

@ -53,6 +53,21 @@ class ChannelFragment : Fragment() {
recyclerView.layoutManager = LinearLayoutManager(context)
fetchChannel(view)
val scrollView = view.findViewById<ScrollView>(R.id.channel_scrollView)
scrollView.viewTreeObserver
.addOnScrollChangedListener {
if (scrollView.getChildAt(0).bottom
== (scrollView.height + scrollView.scrollY)) {
//scroll view is at bottom
if(nextPage!=null && !isLoading){
isLoading=true
fetchNextPage()
}
} else {
//scroll view is not at bottom
}
}
}
@ -81,21 +96,7 @@ class ChannelFragment : Fragment() {
Picasso.get().load(response.avatarUrl).into(channelImage)
channelAdapter = ChannelAdapter(response.relatedStreams!!.toMutableList())
view.findViewById<RecyclerView>(R.id.channel_recView).adapter = channelAdapter
val scrollView = view.findViewById<ScrollView>(R.id.channel_scrollView)
scrollView.viewTreeObserver
.addOnScrollChangedListener {
if (scrollView.getChildAt(0).bottom
== (scrollView.height + scrollView.scrollY)) {
//scroll view is at bottom
if(nextPage!=null && !isLoading){
isLoading=true
fetchNextPage()
}
} else {
//scroll view is not at bottom
}
}
}
}
}

View File

@ -64,7 +64,7 @@ class LoginDialog : DialogFragment() {
}
if (response.error!= null){
Toast.makeText(context, response.error, Toast.LENGTH_SHORT).show()
}else{
}else if(response.token!=null){
Toast.makeText(context,R.string.loggedIn, Toast.LENGTH_SHORT).show()
dialog?.dismiss()
}
@ -91,7 +91,7 @@ class LoginDialog : DialogFragment() {
}
if (response.error!= null){
Toast.makeText(context, response.error, Toast.LENGTH_SHORT).show()
}else{
}else if(response.token!=null){
Toast.makeText(context,R.string.registered, Toast.LENGTH_SHORT).show()
dialog?.dismiss()
}

View File

@ -28,8 +28,6 @@ class MainActivity : AppCompatActivity() {
lateinit var bottomNavigationView: BottomNavigationView
lateinit var toolbar: Toolbar
lateinit var navController : NavController
var f = false
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -57,6 +55,7 @@ class MainActivity : AppCompatActivity() {
toolbar.setNavigationOnClickListener{
//settings fragment stuff
navController.navigate(R.id.settings)
true
}

View File

@ -0,0 +1,10 @@
package com.github.libretube
import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat
class Settings : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.settings, rootKey)
}
}

View File

@ -54,4 +54,8 @@
android:name="playlist_id"
app:argType="string" />
</fragment>
<fragment
android:id="@+id/settings"
android:name="com.github.libretube.Settings"
android:label="Settings" />
</navigation>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.preference.SwitchPreferenceCompat
app:key="notifications"
app:title="Enable message notifications"/>
<androidx.preference.Preference
app:key="feedback"
app:title="Send feedback"
app:summary="Report technical issues or suggest new features"/>
</androidx.preference.PreferenceScreen>