-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (OONI Run v2): Add support for updated badge (#727)
## Proposed Changes - Introduce `AvailableUpdatesViewModel` to store cancelled updates across the application instance. - Show the `updated` badge based on the availability of the descriptor in `AvailableUpdatesViewModel` |.|.| |-|-| | ![Screenshot_20240508_090940](https://github.com/ooni/probe-android/assets/17911892/fffe9487-5836-4742-a571-d8530ed3d647) | ![Screenshot_20240508_090952](https://github.com/ooni/probe-android/assets/17911892/c4b990ed-8cdc-4635-a637-6349a71e9356) |
- Loading branch information
Showing
15 changed files
with
282 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...g/openobservatory/ooniprobe/activity/reviewdescriptorupdates/AvailableUpdatesViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.openobservatory.ooniprobe.activity.reviewdescriptorupdates | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.google.gson.Gson | ||
import org.openobservatory.ooniprobe.model.database.ITestDescriptor | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class AvailableUpdatesViewModel @Inject() constructor(var gson: Gson) : ViewModel() { | ||
var descriptors: MutableLiveData<List<ITestDescriptor>> = MutableLiveData() | ||
var descriptorString: MutableLiveData<String> = MutableLiveData() | ||
|
||
fun setDescriptorsWith(descriptorJson: String) { | ||
descriptorString.value = descriptorJson | ||
descriptors.value = gson.fromJson(descriptorJson, Array<ITestDescriptor>::class.java).toList() | ||
} | ||
|
||
fun getUpdatedDescriptor(runId: Long): String { | ||
return gson.toJson(arrayOf(descriptors.value?.find { it.runId == runId })) | ||
} | ||
} |
Oops, something went wrong.