Merge branch 'update_dependencies' into 'master'

Update dependencies

See merge request pixeldroid/PixelDroid!312
This commit is contained in:
Matthieu 2021-03-14 21:44:47 +00:00
commit ad39fdb9f6
4 changed files with 38 additions and 28 deletions

View File

@ -96,32 +96,32 @@ dependencies {
implementation 'androidx.core:core-ktx:1.3.2' implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.preference:preference-ktx:1.1.1' implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.3' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.3' implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation "androidx.browser:browser:1.3.0" implementation "androidx.browser:browser:1.3.0"
implementation 'androidx.recyclerview:recyclerview:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.3' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.3' implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha12' implementation 'androidx.paging:paging-runtime-ktx:3.0.0-beta02'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0" implementation "androidx.lifecycle:lifecycle-common-java8:2.3.0"
implementation "androidx.annotation:annotation:1.1.0" implementation "androidx.annotation:annotation:1.1.0"
implementation 'androidx.gridlayout:gridlayout:1.0.0' implementation 'androidx.gridlayout:gridlayout:1.0.0'
// Use the most recent version of CameraX // Use the most recent version of CameraX
def cameraX_version = '1.0.0-rc02' def cameraX_version = '1.0.0-rc03'
implementation "androidx.camera:camera-core:${cameraX_version}" implementation "androidx.camera:camera-core:${cameraX_version}"
implementation "androidx.camera:camera-camera2:${cameraX_version}" implementation "androidx.camera:camera-camera2:${cameraX_version}"
// CameraX Lifecycle library // CameraX Lifecycle library
implementation "androidx.camera:camera-lifecycle:$cameraX_version" implementation "androidx.camera:camera-lifecycle:$cameraX_version"
// CameraX View class // CameraX View class
implementation 'androidx.camera:camera-view:1.0.0-alpha21' implementation 'androidx.camera:camera-view:1.0.0-alpha22'
def room_version = "2.3.0-beta01" def room_version = "2.3.0-beta03"
implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version" kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version" implementation "androidx.room:room-ktx:$room_version"
@ -190,7 +190,7 @@ dependencies {
// debugImplementation required vs testImplementation: https://issuetracker.google.com/issues/128612536 // debugImplementation required vs testImplementation: https://issuetracker.google.com/issues/128612536
//noinspection FragmentGradleConfiguration //noinspection FragmentGradleConfiguration
stagingImplementation("androidx.fragment:fragment-testing:1.3.0") { stagingImplementation("androidx.fragment:fragment-testing:1.3.1") {
exclude group:'androidx.test', module:'monitor' exclude group:'androidx.test', module:'monitor'
} }

View File

@ -220,9 +220,7 @@ class HomeFeedTest {
@Test @Test
fun performClickOnSensitiveWarning() { fun performClickOnSensitiveWarning() {
waitForView(R.id.username) waitForView(R.id.username)
onView(withId(R.id.list)).perform(scrollToPosition<StatusViewHolder>(1))
onView(second(withId(R.id.sensitiveWarning))).check(matches(withEffectiveVisibility(Visibility.VISIBLE))) onView(second(withId(R.id.sensitiveWarning))).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
onView(withId(R.id.list)) onView(withId(R.id.list))

View File

@ -6,14 +6,15 @@ import com.h.pixeldroid.utils.api.PixelfedAPI
import com.h.pixeldroid.utils.api.objects.Account import com.h.pixeldroid.utils.api.objects.Account
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
import java.math.BigInteger
class FollowersPagingSource( class FollowersPagingSource(
private val api: PixelfedAPI, private val api: PixelfedAPI,
private val accessToken: String, private val accessToken: String,
private val accountId: String, private val accountId: String,
private val following: Boolean private val following: Boolean
) : PagingSource<Int, Account>() { ) : PagingSource<String, Account>() {
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Account> { override suspend fun load(params: LoadParams<String>): LoadResult<String, Account> {
val position = params.key val position = params.key
return try { return try {
val response = val response =
@ -24,14 +25,14 @@ class FollowersPagingSource(
api.followers(account_id = accountId, api.followers(account_id = accountId,
authorization = "Bearer $accessToken", authorization = "Bearer $accessToken",
limit = params.loadSize, limit = params.loadSize,
page = position?.toString(), page = position,
max_id = position?.toString()) max_id = position)
} else { } else {
api.following(account_id = accountId, api.following(account_id = accountId,
authorization = "Bearer $accessToken", authorization = "Bearer $accessToken",
limit = params.loadSize, limit = params.loadSize,
page = position?.toString(), page = position,
max_id = position?.toString()) max_id = position)
} }
val accounts = if(response.isSuccessful){ val accounts = if(response.isSuccessful){
@ -40,19 +41,19 @@ class FollowersPagingSource(
throw HttpException(response) throw HttpException(response)
} }
val nextPosition = if(response.headers()["Link"] != null){ val nextPosition: String = if(response.headers()["Link"] != null){
//Header is of the form: //Header is of the form:
// Link: <https://mastodon.social/api/v1/accounts/1/followers?limit=2&max_id=7628164>; rel="next", <https://mastodon.social/api/v1/accounts/1/followers?limit=2&since_id=7628165>; rel="prev" // Link: <https://mastodon.social/api/v1/accounts/1/followers?limit=2&max_id=7628164>; rel="next", <https://mastodon.social/api/v1/accounts/1/followers?limit=2&since_id=7628165>; rel="prev"
// So we want the first max_id value. In case there are arguments after // So we want the first max_id value. In case there are arguments after
// the max_id in the URL, we make sure to stop at the first '?' // the max_id in the URL, we make sure to stop at the first '?'
response.headers()["Link"] response.headers()["Link"]
.orEmpty() .orEmpty()
.substringAfter("max_id=") .substringAfter("max_id=", "")
.substringBefore('?') .substringBefore('?', "")
.substringBefore('>') .substringBefore('>', "")
.toIntOrNull() ?: 0
} else { } else {
params.key?.plus(1) ?: 2 // No Link header, so we just increment the position value
(position?.toBigIntegerOrNull() ?: 1.toBigInteger()).inc().toString()
} }
LoadResult.Page( LoadResult.Page(
@ -66,4 +67,9 @@ class FollowersPagingSource(
LoadResult.Error(exception) LoadResult.Error(exception)
} }
} }
override fun getRefreshKey(state: PagingState<String, Account>): String? =
state.anchorPosition?.run {
state.closestItemToPosition(this)?.id
}
} }

View File

@ -1,6 +1,7 @@
package com.h.pixeldroid.posts.feeds.uncachedFeeds.search package com.h.pixeldroid.posts.feeds.uncachedFeeds.search
import androidx.paging.PagingSource import androidx.paging.PagingSource
import androidx.paging.PagingState
import com.h.pixeldroid.utils.api.PixelfedAPI import com.h.pixeldroid.utils.api.PixelfedAPI
import com.h.pixeldroid.utils.api.objects.FeedContent import com.h.pixeldroid.utils.api.objects.FeedContent
import com.h.pixeldroid.utils.api.objects.Results import com.h.pixeldroid.utils.api.objects.Results
@ -44,4 +45,9 @@ class SearchPagingSource<T: FeedContent>(
LoadResult.Error(exception) LoadResult.Error(exception)
} }
} }
override fun getRefreshKey(state: PagingState<Int, T>): Int? =
state.anchorPosition?.run {
state.closestItemToPosition(this)?.id?.toIntOrNull()
}
} }