mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Move logging into a database.
This commit is contained in:
@@ -19,29 +19,19 @@ public class HelpViewModel extends ViewModel {
|
||||
|
||||
private static final int MINIMUM_PROBLEM_CHARS = 10;
|
||||
|
||||
private MutableLiveData<Boolean> problemMeetsLengthRequirements = new MutableLiveData<>();
|
||||
private MutableLiveData<Boolean> hasLines = new MutableLiveData<>(false);
|
||||
private MutableLiveData<Integer> categoryIndex = new MutableLiveData<>(0);
|
||||
private LiveData<Boolean> isFormValid = Transformations.map(new LiveDataPair<>(problemMeetsLengthRequirements, hasLines), this::transformValidationData);
|
||||
private final MutableLiveData<Boolean> problemMeetsLengthRequirements;
|
||||
private final MutableLiveData<Integer> categoryIndex;
|
||||
private final LiveData<Boolean> isFormValid;
|
||||
|
||||
private final SubmitDebugLogRepository submitDebugLogRepository;
|
||||
|
||||
private List<LogLine> logLines;
|
||||
|
||||
public HelpViewModel() {
|
||||
submitDebugLogRepository = new SubmitDebugLogRepository();
|
||||
submitDebugLogRepository = new SubmitDebugLogRepository();
|
||||
problemMeetsLengthRequirements = new MutableLiveData<>();
|
||||
categoryIndex = new MutableLiveData<>(0);
|
||||
|
||||
submitDebugLogRepository.getLogLines(lines -> {
|
||||
logLines = lines;
|
||||
hasLines.postValue(true);
|
||||
});
|
||||
|
||||
LiveData<Boolean> firstValid = LiveDataUtil.combineLatest(problemMeetsLengthRequirements, hasLines, (validLength, validLines) -> {
|
||||
return validLength == Boolean.TRUE && validLines == Boolean.TRUE;
|
||||
});
|
||||
|
||||
isFormValid = LiveDataUtil.combineLatest(firstValid, categoryIndex, (valid, index) -> {
|
||||
return valid == Boolean.TRUE && index > 0;
|
||||
isFormValid = LiveDataUtil.combineLatest(problemMeetsLengthRequirements, categoryIndex, (meetsLengthRequirements, index) -> {
|
||||
return meetsLengthRequirements == Boolean.TRUE && index > 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,7 +55,7 @@ public class HelpViewModel extends ViewModel {
|
||||
MutableLiveData<SubmitResult> resultLiveData = new MutableLiveData<>();
|
||||
|
||||
if (includeDebugLogs) {
|
||||
submitDebugLogRepository.submitLog(logLines, result -> resultLiveData.postValue(new SubmitResult(result, result.isPresent())));
|
||||
submitDebugLogRepository.buildAndSubmitLog(result -> resultLiveData.postValue(new SubmitResult(result, result.isPresent())));
|
||||
} else {
|
||||
resultLiveData.postValue(new SubmitResult(Optional.absent(), false));
|
||||
}
|
||||
@@ -73,10 +63,6 @@ public class HelpViewModel extends ViewModel {
|
||||
return resultLiveData;
|
||||
}
|
||||
|
||||
private boolean transformValidationData(Pair<Boolean, Boolean> validationData) {
|
||||
return validationData.first() == Boolean.TRUE && validationData.second() == Boolean.TRUE;
|
||||
}
|
||||
|
||||
static class SubmitResult {
|
||||
private final Optional<String> debugLogUrl;
|
||||
private final boolean isError;
|
||||
|
||||
Reference in New Issue
Block a user