-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* App update header parsing logic * Added dialog with a recommendation to update the application * Added AppUpgradeRecommendedBox and AppUpgradeRequiredScreen * Minor code style changes * Added app version item in profile * Fixed logout logic * Added upgrade required screen to sign in, sign up and restore password fragment * jUnit test fixes * Minor code style changes * Fixed dialogs bugs, minor code refactoring * Minor review changes
- Loading branch information
1 parent
3170de0
commit 166a1ee
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.