Add support for granular conversation data changes.

This commit is contained in:
Greyson Parrelli
2021-08-30 15:08:38 -04:00
parent bca2205945
commit f5a6d61362
28 changed files with 502 additions and 162 deletions

View File

@@ -4,6 +4,7 @@ import android.app.Application
import org.signal.paging.PagedDataSource
import org.thoughtcrime.securesms.database.LogDatabase
import org.thoughtcrime.securesms.logsubmit.util.Scrubber
import java.lang.UnsupportedOperationException
/**
* Retrieves logs to show in the [SubmitDebugLogActivity].
@@ -16,7 +17,7 @@ class LogDataSource(
private val prefixLines: List<LogLine>,
private val untilTime: Long
) :
PagedDataSource<LogLine> {
PagedDataSource<Long, LogLine> {
val logDatabase = LogDatabase.getInstance(application)
@@ -35,6 +36,14 @@ class LogDataSource(
}
}
override fun load(key: Long?): LogLine? {
throw UnsupportedOperationException("Not implemented!")
}
override fun getKey(data: LogLine): Long {
return data.id
}
private fun convertToLogLine(raw: String): LogLine {
val scrubbed: String = Scrubber.scrub(raw).toString()
return SimpleLogLine(scrubbed, LogStyleParser.parseStyle(scrubbed), LogLine.Placeholder.NONE)

View File

@@ -24,7 +24,7 @@ public class SubmitDebugLogViewModel extends ViewModel {
private final SubmitDebugLogRepository repo;
private final MutableLiveData<Mode> mode;
private final ProxyPagingController pagingController;
private final ProxyPagingController<Long> pagingController;
private final List<LogLine> staticLines;
private final MediatorLiveData<List<LogLine>> lines;
private final long firstViewTime;
@@ -35,7 +35,7 @@ public class SubmitDebugLogViewModel extends ViewModel {
this.repo = new SubmitDebugLogRepository();
this.mode = new MutableLiveData<>();
this.trace = Tracer.getInstance().serialize();
this.pagingController = new ProxyPagingController();
this.pagingController = new ProxyPagingController<>();
this.firstViewTime = System.currentTimeMillis();
this.staticLines = new ArrayList<>();
this.lines = new MediatorLiveData<>();
@@ -51,7 +51,7 @@ public class SubmitDebugLogViewModel extends ViewModel {
.setStartIndex(0)
.build();
PagedData<LogLine> pagedData = PagedData.create(dataSource, config);
PagedData<Long, LogLine> pagedData = PagedData.create(dataSource, config);
ThreadUtil.runOnMain(() -> {
pagingController.set(pagedData.getController());