-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/accessibility
- Loading branch information
Showing
50 changed files
with
1,530 additions
and
249 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
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,15 @@ | ||
package org.openedx.app | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import org.openedx.core.BaseViewModel | ||
|
||
class MainViewModel: BaseViewModel() { | ||
private val _isBottomBarEnabled = MutableLiveData(true) | ||
val isBottomBarEnabled: LiveData<Boolean> | ||
get() = _isBottomBarEnabled | ||
|
||
fun enableBottomBar(enable: Boolean) { | ||
_isBottomBarEnabled.value = enable | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
app/src/main/java/org/openedx/app/data/networking/AppUpgradeInterceptor.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,44 @@ | ||
package org.openedx.app.data.networking | ||
|
||
import kotlinx.coroutines.runBlocking | ||
import okhttp3.Interceptor | ||
import okhttp3.Response | ||
import org.openedx.app.BuildConfig | ||
import org.openedx.core.system.notifier.AppUpgradeEvent | ||
import org.openedx.core.system.notifier.AppUpgradeNotifier | ||
import org.openedx.core.utils.TimeUtils | ||
import java.util.Date | ||
|
||
class AppUpgradeInterceptor( | ||
private val appUpgradeNotifier: AppUpgradeNotifier | ||
) : Interceptor { | ||
override fun intercept(chain: Interceptor.Chain): Response { | ||
val response = chain.proceed(chain.request()) | ||
val responseCode = response.code | ||
val latestAppVersion = response.header(HEADER_APP_LATEST_VERSION) ?: "" | ||
val lastSupportedDateString = response.header(HEADER_APP_VERSION_LAST_SUPPORTED_DATE) ?: "" | ||
val lastSupportedDateTime = TimeUtils.iso8601WithTimeZoneToDate(lastSupportedDateString)?.time ?: 0L | ||
runBlocking { | ||
when { | ||
responseCode == 426 -> { | ||
appUpgradeNotifier.send(AppUpgradeEvent.UpgradeRequiredEvent) | ||
} | ||
|
||
BuildConfig.VERSION_NAME != latestAppVersion && lastSupportedDateTime > Date().time -> { | ||
appUpgradeNotifier.send(AppUpgradeEvent.UpgradeRecommendedEvent(latestAppVersion)) | ||
} | ||
|
||
latestAppVersion.isNotEmpty() && BuildConfig.VERSION_NAME != latestAppVersion && lastSupportedDateTime < Date().time -> { | ||
appUpgradeNotifier.send(AppUpgradeEvent.UpgradeRequiredEvent) | ||
} | ||
} | ||
} | ||
return response | ||
} | ||
|
||
companion object { | ||
const val HEADER_APP_LATEST_VERSION = "EDX-APP-LATEST-VERSION" | ||
const val HEADER_APP_VERSION_LAST_SUPPORTED_DATE = "EDX-APP-VERSION-LAST-SUPPORTED-DATE" | ||
} | ||
} | ||
|
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
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
Oops, something went wrong.