Compare commits

..

No commits in common. "359dec2ca018c6c0296b8a7132999e7fc0a95307" and "212d259a3395a31b2c671411212daf064b796a53" have entirely different histories.

8 changed files with 39 additions and 86 deletions
.gitea/workflows
CHANGELOG.md
androidApp/src
main/java/bou/amine/apps/readerforselfossv2/android/fragments
test/kotlin/bou/amine/apps/readerforselfossv2/tests/repository
fastlane/metadata/android/en-US/changelogs
shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2

@ -10,44 +10,30 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Check android app changes"
id: check-android-changes
uses: tj-actions/changed-files@v45
with:
files: |
androidApp/src/**
- name: Fetch tags
if: steps.check-android-changes.outputs.any_modified == 'true'
run: git fetch --tags -p
- uses: actions/setup-java@v4
if: steps.check-android-changes.outputs.any_modified == 'true'
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- uses: gradle/actions/setup-gradle@v3
if: steps.check-android-changes.outputs.any_modified == 'true'
- uses: android-actions/setup-android@v3
if: steps.check-android-changes.outputs.any_modified == 'true'
- name: Configure gradle...
if: steps.check-android-changes.outputs.any_modified == 'true'
run: mkdir -p ~/.gradle && echo "org.gradle.daemon=false\nignoreGitVersion=true" >> ~/.gradle/gradle.properties
- name: Build and test
if: steps.check-android-changes.outputs.any_modified == 'true'
run: ./gradlew build -x testReleaseUnitTest -x testDebugUnitTest -x testGithubConfigReleaseUnitTest -x testGithubConfigDebugUnitTest # These tests will be done
# TESTS ARE RUN LOCALLY
# - uses: KengoTODA/actions-setup-docker-compose@v1
# with:
# version: "2.23.3"
- uses: KengoTODA/actions-setup-docker-compose@v1
with:
version: "2.23.3"
# TESTS ARE RUN LOCALLY
# - name: run selfoss
# run: |
# docker compose -f .gitea/workflows/assets/docker-compose.yml up -d
- name: coverage
if: steps.check-android-changes.outputs.any_modified == 'true'
run: |
./gradlew :koverHtmlReport
- uses: actions/upload-artifact@v3
if: steps.check-android-changes.outputs.any_modified == 'true'
with:
name: coverage
path: build/reports/kover/html

@ -29,16 +29,7 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Check translations changes"
id: check-translations-changes
uses: tj-actions/changed-files@v45
with:
files: |
androidApp/src/main/res/values/strings.xml
- name: upload translation sources
if: steps.check-api-changes.outputs.any_modified == 'true'
uses: crowdin/github-action@v2
with:
config: './.gitea/workflows/assets/crowdin.yml'
@ -51,10 +42,8 @@ jobs:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: wait
if: steps.check-api-changes.outputs.any_modified == 'true'
run: sleep 10s
- name: download translations
if: steps.check-api-changes.outputs.any_modified == 'true'
uses: crowdin/github-action@v2
with:
config: './.gitea/workflows/assets/crowdin.yml'
@ -67,18 +56,17 @@ jobs:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: Check for uncommitted changes
if: steps.check-api-changes.outputs.any_modified == 'true'
id: check-changes
uses: mskri/check-uncommitted-changes-action@v1.0.1
- name: Commit Changes
if: steps.check-api-changes.outputs.any_modified == 'true' && steps.check-changes.outputs.changes != ''
if: steps.check-changes.outputs.changes != ''
run: |
git config --global user.email aminecmi+giteadrone@pm.me
git config --global user.name giteadrone
git add ./androidApp/src/main/res/*
git commit -m "translation: translation files"
- name: Push changes
if: steps.check-api-changes.outputs.any_modified == 'true' && steps.check-changes.outputs.changes != ''
if: steps.check-changes.outputs.changes != ''
uses: appleboy/git-push-action@v1.0.0
with:
author_name: giteadrone

@ -1,14 +1,3 @@
**v125030711
- Merge pull request 'fix: initial status loading issues.' (#192) from connectivity into master
- chore: check changes for translations and android.
- fix: initial status loading issues.
- Merge pull request 'chore: new connectivity dep. Closes #84.' (#189) from connectivity into master
- chore: new connectivity dep. Closes #84.
- Changelog for v125030681
--------------------------------------------------------------------
**v125030681
- chore: do not send reports on simulators.

@ -170,7 +170,7 @@ class ArticleFragment :
private fun handleContent() {
if (contentText.isEmptyOrNullOrNullString()) {
if (connectivityService.isNetworkAvailable() && url.isUrlValid()) {
if (connectivityService.isNetworkAvailable() == true && url.isUrlValid()) {
getContentFromMercury(url!!)
}
} else {

@ -55,7 +55,7 @@ class RepositoryTest {
private val connectivityService = mockk<ConnectivityService>()
private lateinit var repository: Repository
private fun initializeRepository(isNetworkAvailable: Boolean = true) {
private fun initializeRepository(isNetworkAvailable: Boolean? = true) {
every { connectivityService.isNetworkAvailable() } returns isNetworkAvailable
repository = Repository(api, appSettingsService, connectivityService, db)

@ -1,8 +0,0 @@
**v125030711**
- Merge pull request 'fix: initial status loading issues.' (#192) from connectivity into master
- chore: check changes for translations and android.
- fix: initial status loading issues.
- Merge pull request 'chore: new connectivity dep. Closes #84.' (#189) from connectivity into master
- chore: new connectivity dep. Closes #84.
- Changelog for v125030681

@ -63,7 +63,7 @@ class Repository(
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
var fetchedItems: StatusAndData<List<SelfossModel.Item>> = StatusAndData.error()
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
fetchedItems =
api.getItems(
displayedItems.type,
@ -102,7 +102,7 @@ class Repository(
suspend fun getOlderItems(): ArrayList<SelfossModel.Item> {
var fetchedItems: StatusAndData<List<SelfossModel.Item>> = StatusAndData.error()
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
val offset = items.size
fetchedItems =
api.getItems(
@ -122,7 +122,7 @@ class Repository(
}
private suspend fun getMaxItemsForBackground(itemType: ItemType): List<SelfossModel.Item> {
return if (connectivityService.isNetworkAvailable()) {
return if (connectivityService.isNetworkAvailable() == true) {
val items =
api.getItems(
itemType.type,
@ -146,7 +146,7 @@ class Repository(
@Suppress("detekt:ForbiddenComment")
suspend fun reloadBadges(): Boolean {
var success = false
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
val response = api.stats()
if (response.success && response.data != null) {
_badgeUnread.value = response.data.unread ?: 0
@ -168,7 +168,7 @@ class Repository(
suspend fun getTags(): List<SelfossModel.Tag> {
val isDatabaseEnabled =
appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
return if (connectivityService.isNetworkAvailable() && !fetchedTags) {
return if (connectivityService.isNetworkAvailable() == true && !fetchedTags) {
val apiTags = api.tags()
if (apiTags.success && apiTags.data != null && isDatabaseEnabled) {
resetDBTagsWithData(apiTags.data)
@ -185,7 +185,7 @@ class Repository(
}
suspend fun getSpouts(): Map<String, SelfossModel.Spout> =
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
val spouts = api.spouts()
if (spouts.success && spouts.data != null) {
spouts.data
@ -201,7 +201,7 @@ class Repository(
val isDatabaseEnabled =
appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
val shouldFetch = if (!appSettingsService.isUpdateSourcesEnabled()) !fetchedSources else true
if (shouldFetch && connectivityService.isNetworkAvailable()) {
if (shouldFetch && connectivityService.isNetworkAvailable() == true) {
if (appSettingsService.getPublicAccess()) {
val apiSources = api.sourcesStats()
if (apiSources.success && apiSources.data != null) {
@ -223,7 +223,7 @@ class Repository(
val isDatabaseEnabled =
appSettingsService.isItemCachingEnabled() || !appSettingsService.isUpdateSourcesEnabled()
val shouldFetch = if (!appSettingsService.isUpdateSourcesEnabled()) !fetchedSources else true
if (shouldFetch && connectivityService.isNetworkAvailable()) {
if (shouldFetch && connectivityService.isNetworkAvailable() == true) {
val apiSources = api.sourcesDetailed()
if (apiSources.success && apiSources.data != null) {
fetchedSources = true
@ -248,7 +248,7 @@ class Repository(
}
private suspend fun markAsReadById(id: Int): Boolean =
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
api.markAsRead(id.toString()).isSuccess
} else {
insertDBAction(id.toString(), read = true)
@ -265,7 +265,7 @@ class Repository(
}
private suspend fun unmarkAsReadById(id: Int): Boolean =
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
api.unmarkAsRead(id.toString()).isSuccess
} else {
insertDBAction(id.toString(), unread = true)
@ -282,7 +282,7 @@ class Repository(
}
private suspend fun starrById(id: Int): Boolean =
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
api.starr(id.toString()).isSuccess
} else {
insertDBAction(id.toString(), starred = true)
@ -299,7 +299,7 @@ class Repository(
}
private suspend fun unstarrById(id: Int): Boolean =
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
api.unstarr(id.toString()).isSuccess
} else {
insertDBAction(id.toString(), starred = true)
@ -309,7 +309,9 @@ class Repository(
suspend fun markAllAsRead(items: ArrayList<SelfossModel.Item>): Boolean {
var success = false
if (connectivityService.isNetworkAvailable() && api.markAllAsRead(items.map { it.id.toString() }).isSuccess
if (connectivityService.isNetworkAvailable() != null &&
connectivityService.isNetworkAvailable()!! &&
api.markAllAsRead(items.map { it.id.toString() }).isSuccess
) {
success = true
for (item in items) {
@ -370,7 +372,7 @@ class Repository(
tags: String,
): Boolean {
var response = false
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
response = api
.createSourceForVersion(
title,
@ -391,7 +393,7 @@ class Repository(
tags: String,
): Boolean {
var response = false
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
response = api.updateSourceForVersion(id, title, url, spout, tags).isSuccess == true
}
@ -403,13 +405,13 @@ class Repository(
title: String,
): Boolean {
var success = false
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
val response = api.deleteSource(id)
success = response.isSuccess
}
// We filter on success or if the network isn't available
if (success || !connectivityService.isNetworkAvailable()) {
if (success || !(connectivityService.isNetworkAvailable() == true)) {
items = ArrayList(items.filter { it.sourcetitle != title })
setReaderItems(items)
db.itemsQueries.deleteItemsWhereSource(title)
@ -419,7 +421,7 @@ class Repository(
}
suspend fun updateRemote(): Boolean =
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
api.update().data.equals("finished")
} else {
false
@ -427,7 +429,7 @@ class Repository(
suspend fun login(): Boolean {
var result = false
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
try {
val response = api.login()
result = response.isSuccess == true
@ -440,7 +442,7 @@ class Repository(
suspend fun checkIfFetchFails(): Boolean {
var fetchFailed = true
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
try {
// Trying to fetch one item, and check someone is trying to use the app with
// a random rss feed, that would throw a NoTransformationFoundException
@ -454,7 +456,7 @@ class Repository(
}
suspend fun logout() {
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
try {
val response = api.logout()
if (!response.isSuccess) {
@ -482,7 +484,7 @@ class Repository(
suspend fun updateApiInformation() {
val apiMajorVersion = appSettingsService.getApiVersion()
if (connectivityService.isNetworkAvailable()) {
if (connectivityService.isNetworkAvailable() == true) {
val fetchedInformation = api.apiInformation()
if (fetchedInformation.success && fetchedInformation.data != null) {
if (fetchedInformation.data.getApiMajorVersion() != apiMajorVersion) {

@ -10,7 +10,7 @@ import kotlinx.coroutines.launch
class ConnectivityService {
private val _networkAvailableProvider = MutableSharedFlow<Boolean>()
val networkAvailableProvider = _networkAvailableProvider.asSharedFlow()
private var currentStatus = true
private var currentStatus: Boolean? = null
private lateinit var connectivity: Connectivity
fun start() {
@ -20,27 +20,23 @@ class ConnectivityService {
connectivity.statusUpdates.collect { status ->
when (status) {
is Connectivity.Status.Connected -> {
if (!currentStatus) {
currentStatus = true
_networkAvailableProvider.emit(true)
}
currentStatus = true
_networkAvailableProvider.emit(true)
}
is Connectivity.Status.Disconnected -> {
if (currentStatus) {
currentStatus = false
_networkAvailableProvider.emit(false)
}
currentStatus = false
_networkAvailableProvider.emit(false)
}
}
}
}
}
fun isNetworkAvailable(): Boolean = currentStatus
fun isNetworkAvailable(): Boolean? = currentStatus
fun stop() {
currentStatus = true
currentStatus = null
connectivity.stop()
}
}