diff --git a/app/build.gradle b/app/build.gradle index 0e063ce46..24a9bac54 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/java/com/github/libretube/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ChannelFragment.kt index 7a91275a9..439500a5d 100644 --- a/app/src/main/java/com/github/libretube/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ChannelFragment.kt @@ -53,6 +53,21 @@ class ChannelFragment : Fragment() { recyclerView.layoutManager = LinearLayoutManager(context) fetchChannel(view) + val scrollView = view.findViewById(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(R.id.channel_recView).adapter = channelAdapter - val scrollView = view.findViewById(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 - } - } } } } diff --git a/app/src/main/java/com/github/libretube/LoginDialog.kt b/app/src/main/java/com/github/libretube/LoginDialog.kt index 7e91142dc..d18d86ff7 100644 --- a/app/src/main/java/com/github/libretube/LoginDialog.kt +++ b/app/src/main/java/com/github/libretube/LoginDialog.kt @@ -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() } diff --git a/app/src/main/java/com/github/libretube/MainActivity.kt b/app/src/main/java/com/github/libretube/MainActivity.kt index a0dc61bd3..e2b55b576 100644 --- a/app/src/main/java/com/github/libretube/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/MainActivity.kt @@ -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 } diff --git a/app/src/main/java/com/github/libretube/Settings.kt b/app/src/main/java/com/github/libretube/Settings.kt new file mode 100644 index 000000000..48d92b703 --- /dev/null +++ b/app/src/main/java/com/github/libretube/Settings.kt @@ -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) + } +} diff --git a/app/src/main/res/navigation/nav.xml b/app/src/main/res/navigation/nav.xml index 803933ff9..918b24dd7 100644 --- a/app/src/main/res/navigation/nav.xml +++ b/app/src/main/res/navigation/nav.xml @@ -54,4 +54,8 @@ android:name="playlist_id" app:argType="string" /> + \ No newline at end of file diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml new file mode 100644 index 000000000..ba7093668 --- /dev/null +++ b/app/src/main/res/xml/settings.xml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file