mirror of
https://gitlab.shinice.net/pixeldroid/PixelDroid
synced 2025-01-27 05:54:50 +01:00
Merge branch 'refactorholder' into 'master'
Fix coverage stat, update dependencies, remove useless db passing See merge request pixeldroid/PixelDroid!327
This commit is contained in:
commit
e2bbfccda3
@ -52,6 +52,7 @@ emulatorTest:
|
||||
- cat app/build/reports/jacoco/jacocoTestReport/html/index.html | grep -o 'Total[^%]*%'
|
||||
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- ./app/build/reports/jacoco/jacocoTestReport/
|
||||
expire_in: 1 week
|
||||
|
@ -136,17 +136,17 @@ dependencies {
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
|
||||
//Dagger (dependency injection)
|
||||
implementation 'com.google.dagger:dagger-android:2.30.1'
|
||||
implementation 'com.google.dagger:dagger-android-support:2.30.1'
|
||||
implementation 'com.google.dagger:dagger-android:2.34.1'
|
||||
implementation 'com.google.dagger:dagger-android-support:2.34.1'
|
||||
// if you use the support libraries
|
||||
kapt 'com.google.dagger:dagger-android-processor:2.30.1'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.30.1'
|
||||
kapt 'com.google.dagger:dagger-android-processor:2.34.1'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.34.1'
|
||||
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.20'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
implementation 'com.github.connyduck:sparkbutton:4.1.0'
|
||||
|
||||
@ -154,26 +154,26 @@ dependencies {
|
||||
implementation 'info.androidhive:imagefilters:1.0.7'
|
||||
implementation 'com.github.yalantis:ucrop:2.2.6-native'
|
||||
|
||||
implementation("com.github.bumptech.glide:glide:4.11.0") {
|
||||
implementation('com.github.bumptech.glide:glide:4.12.0') {
|
||||
exclude group: "com.android.support"
|
||||
}
|
||||
|
||||
implementation "com.github.bumptech.glide:okhttp-integration:4.11.0"
|
||||
implementation("com.github.bumptech.glide:recyclerview-integration:4.11.0") {
|
||||
implementation 'com.github.bumptech.glide:okhttp-integration:4.12.0'
|
||||
implementation('com.github.bumptech.glide:recyclerview-integration:4.12.0') {
|
||||
// Excludes the support library because it's already included by Glide.
|
||||
transitive = false
|
||||
}
|
||||
kapt 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
kapt 'com.github.bumptech.glide:compiler:4.12.0'
|
||||
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
|
||||
implementation "com.mikepenz:materialdrawer:8.1.8"
|
||||
implementation 'com.mikepenz:materialdrawer:8.4.0'
|
||||
// Add for NavController support
|
||||
implementation "com.mikepenz:materialdrawer-nav:8.1.5"
|
||||
implementation 'com.mikepenz:materialdrawer-nav:8.4.0'
|
||||
|
||||
//iconics
|
||||
implementation "com.mikepenz:iconics-core:5.0.3"
|
||||
implementation "com.mikepenz:materialdrawer-iconics:8.1.8"
|
||||
implementation "com.mikepenz:iconics-core:5.2.8"
|
||||
implementation 'com.mikepenz:materialdrawer-iconics:8.4.0'
|
||||
implementation "com.mikepenz:iconics-views:5.0.3"
|
||||
implementation 'com.mikepenz:google-material-typeface:3.0.1.4.original-kotlin@aar'
|
||||
|
||||
@ -196,7 +196,7 @@ dependencies {
|
||||
|
||||
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.27.2'
|
||||
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation "androidx.room:room-testing:$room_version"
|
||||
|
||||
|
||||
@ -227,10 +227,10 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['connectedStagingAndroidTe
|
||||
}
|
||||
|
||||
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
|
||||
def kotlinDebugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
|
||||
def kotlinTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/staging", excludes: fileFilter)
|
||||
def mainSrc = "$project.projectDir/src/main/java"
|
||||
getSourceDirectories().from(files([mainSrc]))
|
||||
getClassDirectories().from(files([kotlinDebugTree]))
|
||||
getClassDirectories().from(files([kotlinTree]))
|
||||
getExecutionData().from(fileTree(dir: project.buildDir, includes: [
|
||||
|
||||
'outputs/code_coverage/stagingAndroidTest/connected/*coverage.ec',
|
||||
|
@ -16,12 +16,12 @@
|
||||
license: The Apache Software License, Version 2.0
|
||||
licenseUrl: http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
url: https://github.com/mikepenz/MaterialDrawer
|
||||
- artifact: org.jetbrains.kotlin:kotlin-android-extensions-runtime:+
|
||||
name: kotlin-android-extensions-runtime
|
||||
copyrightHolder: JetBrains s.r.o. and contributors
|
||||
license: The Apache License, Version 2.0
|
||||
- artifact: androidx.startup:startup-runtime:+
|
||||
name: startup-runtime
|
||||
copyrightHolder: Google Inc.
|
||||
license: The Apache Software License, Version 2.0
|
||||
licenseUrl: http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
url: https://kotlinlang.org/
|
||||
url: https://developer.android.com/jetpack/androidx/releases/startup#1.0.0
|
||||
- artifact: com.mikepenz:iconics-views:+
|
||||
name: iconics-views
|
||||
copyrightHolder: Mike Penz and contributors
|
||||
@ -793,4 +793,4 @@
|
||||
copyrightHolder: Google Inc
|
||||
license: The Apache Software License, Version 2.0
|
||||
licenseUrl: http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
url: https://developer.android.com/jetpack/androidx/releases/tracing#1.0.0
|
||||
url: https://developer.android.com/jetpack/androidx/releases/tracing#1.0.0
|
||||
|
6
app/src/main/assets/licenses.html
generated
6
app/src/main/assets/licenses.html
generated
@ -818,9 +818,9 @@
|
||||
</div>
|
||||
<div class="library">
|
||||
<!-- https://opensource.org/licenses/Apache-2.0 -->
|
||||
<h1 class="title">kotlin-android-extensions-runtime</h1>
|
||||
<p class="notice">Copyright © JetBrains s.r.o. and contributors. All rights reserved.</p>
|
||||
<p><a href="https://kotlinlang.org/">https://kotlinlang.org/</a></p>
|
||||
<h1 class="title">startup-runtime</h1>
|
||||
<p class="notice">Copyright © Google Inc. All rights reserved.</p>
|
||||
<p><a href="https://developer.android.com/jetpack/androidx/releases/startup#1.0.0">https://developer.android.com/jetpack/androidx/releases/startup#1.0.0</a></p>
|
||||
<input type="checkbox"><label></label>
|
||||
<div class="license">
|
||||
<h2>
|
||||
|
@ -25,14 +25,13 @@ Overview of the flow of the login process: (boxes are requests done in parallel,
|
||||
since they do not depend on each other)
|
||||
|
||||
_________________________________
|
||||
|[PixelfedAPI.registerApplicationAsync]|
|
||||
|[PixelfedAPI.registerApplication]|
|
||||
|[PixelfedAPI.wellKnownNodeInfo] |
|
||||
̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅ +----> [PixelfedAPI.nodeInfoSchema]
|
||||
+----> [promptOAuth]
|
||||
+---->____________________________
|
||||
|[PixelfedAPI.instance] |
|
||||
|[PixelfedAPI.obtainToken] |
|
||||
̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅ +----> [PixelfedAPI.verifyCredentials]
|
||||
̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅̅
|
||||
+----> [PixelfedAPI.nodeInfoSchema] (and then [PixelfedAPI.instance] if needed)
|
||||
+----> [promptOAuth]
|
||||
+----> [PixelfedAPI.obtainToken]
|
||||
+----> [PixelfedAPI.verifyCredentials]
|
||||
|
||||
*/
|
||||
|
||||
@ -311,7 +310,7 @@ class LoginActivity : BaseActivity() {
|
||||
clientId = clientId,
|
||||
clientSecret = clientSecret
|
||||
)
|
||||
apiHolder.setDomainToCurrentUser(db)
|
||||
apiHolder.setToCurrentUser()
|
||||
val intent = Intent(this@LoginActivity, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
|
@ -177,7 +177,7 @@ class MainActivity : BaseActivity() {
|
||||
} else {
|
||||
val newActive = remainingUsers.first()
|
||||
db.userDao().activateUser(newActive.user_id)
|
||||
apiHolder.setDomainToCurrentUser(db)
|
||||
apiHolder.setToCurrentUser()
|
||||
//relaunch the app
|
||||
launchActivity(MainActivity(), firstTime = true)
|
||||
}
|
||||
@ -193,7 +193,7 @@ class MainActivity : BaseActivity() {
|
||||
val refreshToken = user?.refreshToken
|
||||
val clientId = user?.clientId.orEmpty()
|
||||
val clientSecret = user?.clientSecret.orEmpty()
|
||||
val api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
|
||||
val account = api.verifyCredentials()
|
||||
addUser(db, account, domain, accessToken = accessToken, refreshToken = refreshToken, clientId = clientId, clientSecret = clientSecret)
|
||||
@ -221,7 +221,7 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
db.userDao().deActivateActiveUsers()
|
||||
db.userDao().activateUser(profile.identifier.toString())
|
||||
apiHolder.setDomainToCurrentUser(db)
|
||||
apiHolder.setToCurrentUser()
|
||||
val intent = Intent(this, MainActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
|
@ -332,7 +332,7 @@ class PostCreationActivity : BaseActivity() {
|
||||
|
||||
val description = data.imageDescription?.let { MultipartBody.Part.createFormData("description", it) }
|
||||
|
||||
val api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
val inter = api.mediaUpload(description, requestBody.parts[0])
|
||||
|
||||
postSub = inter
|
||||
@ -375,7 +375,7 @@ class PostCreationActivity : BaseActivity() {
|
||||
enableButton(false)
|
||||
lifecycleScope.launchWhenCreated {
|
||||
try {
|
||||
val api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
|
||||
api.postStatus(
|
||||
statusText = description,
|
||||
|
@ -17,7 +17,6 @@ import com.h.pixeldroid.R
|
||||
import com.h.pixeldroid.utils.api.PixelfedAPI
|
||||
import com.h.pixeldroid.utils.api.objects.Account.Companion.openAccountFromId
|
||||
import com.h.pixeldroid.utils.api.objects.Mention
|
||||
import com.h.pixeldroid.utils.db.AppDatabase
|
||||
import com.h.pixeldroid.utils.di.PixelfedAPIHolder
|
||||
import java.net.URI
|
||||
import java.net.URISyntaxException
|
||||
@ -55,7 +54,6 @@ fun parseHTMLText(
|
||||
apiHolder: PixelfedAPIHolder,
|
||||
context: Context,
|
||||
lifecycleScope: LifecycleCoroutineScope,
|
||||
db: AppDatabase
|
||||
) : Spanned {
|
||||
//Convert text to spannable
|
||||
val content = fromHtml(text)
|
||||
@ -108,7 +106,7 @@ fun parseHTMLText(
|
||||
Log.e("MENTION", "CLICKED")
|
||||
//Retrieve the account for the given profile
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
openAccountFromId(accountId, api, context)
|
||||
}
|
||||
}
|
||||
|
@ -107,12 +107,11 @@ class PostActivity : BaseActivity() {
|
||||
|
||||
itemBinding.user.text = commentUsername
|
||||
itemBinding.commentText.text = parseHTMLText(
|
||||
commentContent,
|
||||
mentions,
|
||||
apiHolder,
|
||||
context,
|
||||
lifecycleScope,
|
||||
db
|
||||
commentContent,
|
||||
mentions,
|
||||
apiHolder,
|
||||
context,
|
||||
lifecycleScope
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class ReportActivity : BaseActivity() {
|
||||
|
||||
binding.textInputLayout.editText?.isEnabled = false
|
||||
|
||||
val api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
|
||||
lifecycleScope.launchWhenCreated {
|
||||
try {
|
||||
|
@ -180,19 +180,17 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||
private fun setDescription(
|
||||
apiHolder: PixelfedAPIHolder,
|
||||
lifecycleScope: LifecycleCoroutineScope,
|
||||
db: AppDatabase
|
||||
) {
|
||||
binding.description.apply {
|
||||
if (status?.content.isNullOrBlank()) {
|
||||
visibility = View.GONE
|
||||
} else {
|
||||
text = parseHTMLText(
|
||||
status?.content.orEmpty(),
|
||||
status?.mentions,
|
||||
apiHolder,
|
||||
binding.root.context,
|
||||
lifecycleScope,
|
||||
db
|
||||
status?.content.orEmpty(),
|
||||
status?.mentions,
|
||||
apiHolder,
|
||||
binding.root.context,
|
||||
lifecycleScope
|
||||
)
|
||||
movementMethod = LinkMovementMethod.getInstance()
|
||||
}
|
||||
@ -206,14 +204,14 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||
isActivity: Boolean
|
||||
){
|
||||
//Set the special HTML text
|
||||
setDescription(apiHolder, lifecycleScope, db)
|
||||
setDescription(apiHolder, lifecycleScope)
|
||||
|
||||
//Activate onclickListeners
|
||||
activateLiker(
|
||||
apiHolder, status?.favourited ?: false, lifecycleScope, db
|
||||
apiHolder, status?.favourited ?: false, lifecycleScope
|
||||
)
|
||||
activateReblogger(
|
||||
apiHolder, status?.reblogged ?: false, lifecycleScope, db
|
||||
apiHolder, status?.reblogged ?: false, lifecycleScope
|
||||
)
|
||||
|
||||
if(isActivity){
|
||||
@ -240,7 +238,6 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||
apiHolder: PixelfedAPIHolder,
|
||||
isReblogged: Boolean,
|
||||
lifecycleScope: LifecycleCoroutineScope,
|
||||
db: AppDatabase
|
||||
) {
|
||||
binding.reblogger.apply {
|
||||
//Set initial button state
|
||||
@ -249,7 +246,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||
//Activate the button
|
||||
setEventListener { _, buttonState ->
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
if (buttonState) {
|
||||
// Button is active
|
||||
undoReblogPost(api)
|
||||
@ -386,7 +383,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||
db.homePostDao().delete(id, user.user_id, user.instance_uri)
|
||||
db.publicPostDao().delete(id, user.user_id, user.instance_uri)
|
||||
try {
|
||||
val api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
api.deleteStatus(id)
|
||||
binding.root.visibility = View.GONE
|
||||
} catch (exception: HttpException) {
|
||||
@ -434,7 +431,6 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||
apiHolder: PixelfedAPIHolder,
|
||||
isLiked: Boolean,
|
||||
lifecycleScope: LifecycleCoroutineScope,
|
||||
db: AppDatabase
|
||||
) {
|
||||
|
||||
binding.liker.apply {
|
||||
@ -444,7 +440,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||
//Activate the liker
|
||||
setEventListener { _, buttonState ->
|
||||
lifecycleScope.launchWhenCreated {
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
if (buttonState) {
|
||||
// Button is active, unlike
|
||||
unLikePostCall(api)
|
||||
@ -466,7 +462,7 @@ class StatusViewHolder(val binding: PostFragmentBinding) : RecyclerView.ViewHold
|
||||
if(binding.sensitiveWarning.visibility == View.GONE) {
|
||||
//Check for double click
|
||||
if(clicked) {
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
if (binding.liker.isChecked) {
|
||||
// Button is active, unlike
|
||||
binding.liker.isChecked = false
|
||||
|
@ -30,7 +30,6 @@ import com.h.pixeldroid.profile.ProfileActivity
|
||||
import com.h.pixeldroid.utils.api.objects.Account
|
||||
import com.h.pixeldroid.utils.api.objects.Notification
|
||||
import com.h.pixeldroid.utils.api.objects.Status
|
||||
import com.h.pixeldroid.utils.db.AppDatabase
|
||||
import com.h.pixeldroid.utils.di.PixelfedAPIHolder
|
||||
|
||||
|
||||
@ -41,7 +40,7 @@ class NotificationsFragment : CachedFeedFragment<Notification>() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
adapter = NotificationsAdapter(apiHolder, db)
|
||||
adapter = NotificationsAdapter(apiHolder)
|
||||
}
|
||||
|
||||
@ExperimentalPagingApi
|
||||
@ -166,7 +165,6 @@ class NotificationsFragment : CachedFeedFragment<Notification>() {
|
||||
notification: Notification?,
|
||||
api: PixelfedAPIHolder,
|
||||
lifecycleScope: LifecycleCoroutineScope,
|
||||
db: AppDatabase
|
||||
) {
|
||||
|
||||
this.notification = notification
|
||||
@ -203,12 +201,11 @@ class NotificationsFragment : CachedFeedFragment<Notification>() {
|
||||
//Convert HTML to clickable text
|
||||
postDescription.text =
|
||||
parseHTMLText(
|
||||
notification?.status?.content ?: "",
|
||||
notification?.status?.mentions,
|
||||
api,
|
||||
itemView.context,
|
||||
lifecycleScope,
|
||||
db
|
||||
notification?.status?.content ?: "",
|
||||
notification?.status?.mentions,
|
||||
api,
|
||||
itemView.context,
|
||||
lifecycleScope
|
||||
)
|
||||
}
|
||||
|
||||
@ -225,7 +222,6 @@ class NotificationsFragment : CachedFeedFragment<Notification>() {
|
||||
|
||||
inner class NotificationsAdapter(
|
||||
private val apiHolder: PixelfedAPIHolder,
|
||||
private val db: AppDatabase
|
||||
) : PagingDataAdapter<Notification, RecyclerView.ViewHolder>(
|
||||
object : DiffUtil.ItemCallback<Notification>() {
|
||||
override fun areItemsTheSame(
|
||||
@ -255,10 +251,9 @@ class NotificationsFragment : CachedFeedFragment<Notification>() {
|
||||
val uiModel = getItem(position)
|
||||
uiModel.let {
|
||||
(holder as NotificationViewHolder).bind(
|
||||
it,
|
||||
apiHolder,
|
||||
lifecycleScope,
|
||||
db
|
||||
it,
|
||||
apiHolder,
|
||||
lifecycleScope
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class NotificationsRemoteMediator @Inject constructor(
|
||||
try {
|
||||
val user = db.userDao().getActiveUser()
|
||||
?: return MediatorResult.Error(NullPointerException("No active user exists"))
|
||||
val api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
|
||||
val apiResponse = api.notifications(
|
||||
max_id = max_id,
|
||||
|
@ -43,7 +43,7 @@ class HomeFeedRemoteMediator @Inject constructor(
|
||||
try {
|
||||
val user = db.userDao().getActiveUser()
|
||||
?: return MediatorResult.Error(NullPointerException("No active user exists"))
|
||||
val api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
|
||||
val apiResponse = api.timelineHome(
|
||||
max_id= max_id,
|
||||
|
@ -58,7 +58,7 @@ class PublicFeedRemoteMediator @Inject constructor(
|
||||
try {
|
||||
val user = db.userDao().getActiveUser()
|
||||
?: return MediatorResult.Error(NullPointerException("No active user exists"))
|
||||
val api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
|
||||
val apiResponse = api.timelinePublic(
|
||||
max_id = max_id,
|
||||
|
@ -54,7 +54,7 @@ class AccountListFragment : UncachedFeedFragment<Account>() {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
viewModel = ViewModelProvider(this, ViewModelFactory(
|
||||
FollowersContentRepository(
|
||||
apiHolder.setDomainToCurrentUser(db),
|
||||
apiHolder.setToCurrentUser(),
|
||||
id,
|
||||
following
|
||||
)
|
||||
|
@ -39,7 +39,7 @@ class SearchAccountFragment : UncachedFeedFragment<Account>() {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
viewModel = ViewModelProvider(this, ViewModelFactory(
|
||||
SearchContentRepository<Account>(
|
||||
apiHolder.setDomainToCurrentUser(db),
|
||||
apiHolder.setToCurrentUser(),
|
||||
Results.SearchType.accounts,
|
||||
query
|
||||
)
|
||||
|
@ -46,7 +46,7 @@ class SearchHashtagFragment : UncachedFeedFragment<Tag>() {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
viewModel = ViewModelProvider(this, ViewModelFactory(
|
||||
SearchContentRepository<Tag>(
|
||||
apiHolder.setDomainToCurrentUser(db),
|
||||
apiHolder.setToCurrentUser(),
|
||||
Results.SearchType.hashtags,
|
||||
query
|
||||
)
|
||||
|
@ -43,7 +43,7 @@ class SearchPostsFragment : UncachedFeedFragment<Status>() {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
viewModel = ViewModelProvider(this, ViewModelFactory(
|
||||
SearchContentRepository<Status>(
|
||||
apiHolder.setDomainToCurrentUser(db),
|
||||
apiHolder.setToCurrentUser(),
|
||||
Results.SearchType.statuses,
|
||||
query
|
||||
)
|
||||
|
@ -73,7 +73,7 @@ class ProfileActivity : BaseActivity() {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
viewModel = ViewModelProvider(this, ProfileViewModelFactory(
|
||||
ProfileContentRepository(
|
||||
apiHolder.setDomainToCurrentUser(db),
|
||||
apiHolder.setToCurrentUser(),
|
||||
accountId
|
||||
)
|
||||
)
|
||||
@ -119,7 +119,7 @@ class ProfileActivity : BaseActivity() {
|
||||
setViews(account)
|
||||
} else {
|
||||
lifecycleScope.launchWhenResumed {
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
val myAccount: Account = try {
|
||||
api.verifyCredentials()
|
||||
} catch (exception: IOException) {
|
||||
@ -158,10 +158,9 @@ class ProfileActivity : BaseActivity() {
|
||||
)
|
||||
|
||||
binding.descriptionTextView.text = parseHTMLText(
|
||||
account.note ?: "", emptyList(), apiHolder,
|
||||
applicationContext,
|
||||
lifecycleScope,
|
||||
db
|
||||
account.note ?: "", emptyList(), apiHolder,
|
||||
applicationContext,
|
||||
lifecycleScope
|
||||
)
|
||||
|
||||
val displayName = account.getDisplayName()
|
||||
@ -232,7 +231,7 @@ class ProfileActivity : BaseActivity() {
|
||||
// Get relationship between the two users (credential and this) and set followButton accordingly
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
val relationship = api.checkRelationships(
|
||||
listOf(account.id.orEmpty())
|
||||
).firstOrNull()
|
||||
@ -266,7 +265,7 @@ class ProfileActivity : BaseActivity() {
|
||||
setOnClickListener {
|
||||
lifecycleScope.launchWhenResumed {
|
||||
try {
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
val rel = api.follow(account.id.orEmpty())
|
||||
if(rel.following == true) setOnClickUnfollow(account, rel.requested == true)
|
||||
else setOnClickFollow(account)
|
||||
@ -297,7 +296,7 @@ class ProfileActivity : BaseActivity() {
|
||||
fun unfollow() {
|
||||
lifecycleScope.launchWhenResumed {
|
||||
try {
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
val api: PixelfedAPI = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
val rel = api.unfollow(account.id.orEmpty())
|
||||
if(rel.following == false && rel.requested == false) setOnClickFollow(account)
|
||||
else setOnClickUnfollow(account, rel.requested == true)
|
||||
|
@ -59,7 +59,7 @@ class SearchDiscoverFragment : BaseFragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
api = apiHolder.api ?: apiHolder.setDomainToCurrentUser(db)
|
||||
api = apiHolder.api ?: apiHolder.setToCurrentUser()
|
||||
|
||||
getDiscover()
|
||||
|
||||
|
@ -67,7 +67,7 @@ class TokenAuthenticator(val user: UserDatabaseEntity, val db: AppDatabase, val
|
||||
newAccessToken.refresh_token,
|
||||
user.user_id, user.instance_uri
|
||||
)
|
||||
apiHolder.setDomainToCurrentUser(db)
|
||||
apiHolder.setToCurrentUser()
|
||||
}
|
||||
|
||||
// Add new header to rejected request and retry it
|
||||
@ -77,18 +77,17 @@ class TokenAuthenticator(val user: UserDatabaseEntity, val db: AppDatabase, val
|
||||
}
|
||||
}
|
||||
|
||||
class PixelfedAPIHolder(db: AppDatabase?){
|
||||
class PixelfedAPIHolder(private val db: AppDatabase){
|
||||
private val intermediate: Retrofit.Builder = Retrofit.Builder()
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
|
||||
var api: PixelfedAPI? =
|
||||
db?.userDao()?.getActiveUser()?.let {
|
||||
setDomainToCurrentUser(db, it)
|
||||
db.userDao().getActiveUser()?.let {
|
||||
setToCurrentUser(it)
|
||||
}
|
||||
|
||||
fun setDomainToCurrentUser(
|
||||
db: AppDatabase,
|
||||
fun setToCurrentUser(
|
||||
user: UserDatabaseEntity = db.userDao().getActiveUser()!!
|
||||
): PixelfedAPI {
|
||||
val newAPI = intermediate
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.h.pixeldroid.postCreation.SquareLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
<com.h.pixeldroid.postCreation.SquareLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:foreground="?selectableItemBackground"
|
||||
|
15
build.gradle
15
build.gradle
@ -1,18 +1,10 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.4.31'
|
||||
ext.kotlin_version = '1.4.32'
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
jcenter {
|
||||
content {
|
||||
// org.jetbrains.trove4j is only available in JCenter
|
||||
//TODO remove JCenter repo:
|
||||
// see issue https://gitlab.shinice.net/pixeldroid/PixelDroid/-/issues/278
|
||||
includeGroup("org.jetbrains.trove4j")
|
||||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
||||
@ -34,11 +26,6 @@ allprojects {
|
||||
//TODO remove JCenter repo:
|
||||
// see issue https://gitlab.shinice.net/pixeldroid/PixelDroid/-/issues/278
|
||||
includeGroup("info.androidhive")
|
||||
|
||||
// org.jetbrains.trove4j is only available in JCenter
|
||||
//TODO remove JCenter repo:
|
||||
// see issue https://gitlab.shinice.net/pixeldroid/PixelDroid/-/issues/278
|
||||
includeGroup("org.jetbrains.trove4j")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Fri Aug 21 12:53:39 CEST 2020
|
||||
#Tue Apr 20 12:38:34 CEST 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
|
||||
|
Loading…
x
Reference in New Issue
Block a user