Merge branch 'hide_self_report' into 'master'

Hide self report

See merge request pixeldroid/PixelDroid!268
This commit is contained in:
Matthieu 2020-12-19 21:19:27 +01:00
commit c6958a705b
7 changed files with 19 additions and 14 deletions

View File

@ -79,7 +79,7 @@ dependencies {
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2' implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.2' implementation 'androidx.navigation:navigation-ui-ktx:2.3.2'
implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha10' implementation 'androidx.paging:paging-runtime-ktx:3.0.0-alpha11'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0' implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0' implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
@ -87,16 +87,16 @@ dependencies {
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-beta12' def cameraX_version = '1.0.0-rc01'
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-alpha19' implementation 'androidx.camera:camera-view:1.0.0-alpha20'
def room_version = "2.3.0-alpha03" def room_version = "2.3.0-alpha04"
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"

View File

@ -15,7 +15,6 @@ import android.view.ViewGroup
import android.widget.* import android.widget.*
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.LifecycleCoroutineScope
import androidx.paging.RemoteMediator
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import at.connyduck.sparkbutton.SparkButton import at.connyduck.sparkbutton.SparkButton
@ -27,8 +26,6 @@ import com.h.pixeldroid.R
import com.h.pixeldroid.ReportActivity import com.h.pixeldroid.ReportActivity
import com.h.pixeldroid.api.PixelfedAPI import com.h.pixeldroid.api.PixelfedAPI
import com.h.pixeldroid.db.AppDatabase import com.h.pixeldroid.db.AppDatabase
import com.h.pixeldroid.db.entities.HomeStatusDatabaseEntity
import com.h.pixeldroid.db.entities.PublicFeedStatusDatabaseEntity
import com.h.pixeldroid.objects.Attachment import com.h.pixeldroid.objects.Attachment
import com.h.pixeldroid.objects.Context import com.h.pixeldroid.objects.Context
import com.h.pixeldroid.objects.Status import com.h.pixeldroid.objects.Status
@ -440,8 +437,10 @@ class StatusViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
menu.setGroupVisible(R.id.post_more_group_picture, false) menu.setGroupVisible(R.id.post_more_group_picture, false)
} }
if(status?.account?.id == db.userDao().getActiveUser()!!.user_id){ if(status?.account?.id == db.userDao().getActiveUser()!!.user_id){
//make sure to enable deleting post if it's the user's // Enable deleting post if it's the user's
menu.setGroupVisible(R.id.post_more_menu_group_delete, true) menu.setGroupVisible(R.id.post_more_menu_group_delete, true)
// And disable reporting your own post (just delete it if you don't like it :P)
menu.setGroupVisible(R.id.post_more_menu_group_report, false)
} }
show() show()
} }

View File

@ -38,6 +38,7 @@ open class CachedFeedFragment<T: FeedContentDatabase> : BaseFragment() {
private var job: Job? = null private var job: Job? = null
@ExperimentalPagingApi
internal fun launch() { internal fun launch() {
// Make sure we cancel the previous job before creating a new one // Make sure we cancel the previous job before creating a new one
job?.cancel() job?.cancel()

View File

@ -37,6 +37,7 @@ class FeedContentRepository<T: FeedContentDatabase> @ExperimentalPagingApi
* [FeedContentDatabase], exposed as a stream of data that will emit * [FeedContentDatabase], exposed as a stream of data that will emit
* every time we get more data from the network. * every time we get more data from the network.
*/ */
@ExperimentalPagingApi
fun stream(): Flow<PagingData<T>> { fun stream(): Flow<PagingData<T>> {
val pagingSourceFactory = { val pagingSourceFactory = {

View File

@ -30,6 +30,7 @@ class FeedViewModel<T: FeedContentDatabase>(private val repository: FeedContentR
private var currentResult: Flow<PagingData<T>>? = null private var currentResult: Flow<PagingData<T>>? = null
@ExperimentalPagingApi
fun flow(): Flow<PagingData<T>> { fun flow(): Flow<PagingData<T>> {
val lastResult = currentResult val lastResult = currentResult
if (lastResult != null) { if (lastResult != null) {

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/post_more_menu_report" <group android:id="@+id/post_more_menu_group_report">
android:title="@string/report" /> <item android:id="@+id/post_more_menu_report"
android:title="@string/report" />
</group>
<item android:id="@+id/post_more_menu_share_link" <item android:id="@+id/post_more_menu_share_link"
android:title="@string/share_link" /> android:title="@string/share_link" />

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.4.20' ext.kotlin_version = '1.4.21'
repositories { repositories {
google() google()
jcenter() jcenter()