Skip to content

Commit

Permalink
Minor review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PavloNetrebchuk committed Oct 30, 2023
1 parent 5405108 commit 551553e
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.openedx.app.data.networking

import android.content.Context
import okhttp3.Interceptor
import okhttp3.Response
import org.openedx.app.BuildConfig
import org.openedx.core.data.storage.CorePreferences
import org.openedx.core.BuildConfig.ACCESS_TOKEN_TYPE
import org.openedx.core.data.storage.CorePreferences

class HeadersInterceptor(private val preferencesManager: CorePreferences) : Interceptor {
class HeadersInterceptor(private val context: Context, private val preferencesManager: CorePreferences) : Interceptor {

override fun intercept(chain: Interceptor.Chain): Response = chain.run {
proceed(
Expand All @@ -19,12 +20,10 @@ class HeadersInterceptor(private val preferencesManager: CorePreferences) : Inte
}

addHeader("Accept", "application/json")
//TODO
addHeader(
"User-Agent", System.getProperty("http.agent") + " " +
// context.getString(org.openedx.core.R.string.app_name) + "/" +
"edX" + "/" +
"org.edx.mobile" + "/" +
"User-Agent", System.getProperty("http.agent") + " " +
context.getString(org.openedx.core.R.string.app_name) + "/" +
BuildConfig.APPLICATION_ID + "/" +
BuildConfig.VERSION_NAME
)
}.build()
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/org/openedx/app/di/NetworkingModule.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.openedx.app.di

import org.openedx.auth.data.api.AuthApi
import org.openedx.core.data.api.CookiesApi
import org.openedx.core.data.api.CourseApi
import org.openedx.discussion.data.api.DiscussionApi
import org.openedx.app.data.networking.HandleErrorInterceptor
import org.openedx.app.data.networking.HeadersInterceptor
import org.openedx.app.data.networking.OauthRefreshTokenAuthenticator
import org.openedx.profile.data.api.ProfileApi
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.koin.dsl.module
import org.openedx.app.data.networking.AppUpgradeInterceptor
import org.openedx.app.data.networking.HandleErrorInterceptor
import org.openedx.app.data.networking.HeadersInterceptor
import org.openedx.app.data.networking.OauthRefreshTokenAuthenticator
import org.openedx.auth.data.api.AuthApi
import org.openedx.core.BuildConfig
import org.openedx.core.data.api.CookiesApi
import org.openedx.core.data.api.CourseApi
import org.openedx.discussion.data.api.DiscussionApi
import org.openedx.profile.data.api.ProfileApi
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit
Expand All @@ -25,7 +25,7 @@ val networkingModule = module {
OkHttpClient.Builder().apply {
writeTimeout(60, TimeUnit.SECONDS)
readTimeout(60, TimeUnit.SECONDS)
addInterceptor(HeadersInterceptor(get()))
addInterceptor(HeadersInterceptor(get(), get()))
if (BuildConfig.DEBUG) {
addNetworkInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/openedx/app/di/ScreenModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.openedx.auth.presentation.restore.RestorePasswordViewModel
import org.openedx.auth.presentation.signin.SignInViewModel
import org.openedx.auth.presentation.signup.SignUpViewModel
import org.openedx.core.Validator
import org.openedx.core.presentation.dialog.select_bottom.SelectDialogViewModel
import org.openedx.core.presentation.dialog.selectorbottomsheet.SelectDialogViewModel
import org.openedx.course.data.repository.CourseRepository
import org.openedx.course.domain.interactor.CourseInteractor
import org.openedx.course.presentation.container.CourseContainerViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RestorePasswordViewModel(
val uiMessage: LiveData<UIMessage>
get() = _uiMessage

private val _appUpgradeEvent = SingleEventLiveData<AppUpgradeEvent>()
private val _appUpgradeEvent = MutableLiveData<AppUpgradeEvent>()
val appUpgradeEventUIState: LiveData<AppUpgradeEvent>
get() = _appUpgradeEvent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SignInViewModel(
val loginSuccess: LiveData<Boolean>
get() = _loginSuccess

private val _appUpgradeEvent = SingleEventLiveData<AppUpgradeEvent>()
private val _appUpgradeEvent = MutableLiveData<AppUpgradeEvent>()
val appUpgradeEvent: LiveData<AppUpgradeEvent>
get() = _appUpgradeEvent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SignUpViewModel(
val validationError: LiveData<Boolean>
get() = _validationError

private val _appUpgradeEvent = SingleEventLiveData<AppUpgradeEvent>()
private val _appUpgradeEvent = MutableLiveData<AppUpgradeEvent>()
val appUpgradeEvent: LiveData<AppUpgradeEvent>
get() = _appUpgradeEvent

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openedx.core.presentation.dialog.app_upgrade
package org.openedx.core.presentation.dialog.appupgrade

import android.graphics.drawable.ColorDrawable
import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openedx.core.presentation.dialog.select_bottom
package org.openedx.core.presentation.dialog.selectorbottomsheet

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openedx.core.presentation.dialog.select_bottom
package org.openedx.core.presentation.dialog.selectorbottomsheet

import androidx.lifecycle.viewModelScope
import org.openedx.core.BaseViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,6 @@ fun AppUpgradeRequiredContent(
textAlign = TextAlign.Center,
style = MaterialTheme.appTypography.bodyMedium
)
// IconText(
// text = stringResource(R.string.core_why_do_you_need_update),
// painter = painterResource(id = R.drawable.core_ic_question),
// textStyle = MaterialTheme.appTypography.labelLarge,
// color = MaterialTheme.appColors.primary,
// onClick = {}
// )
}
AppUpgradeRequiredButtons(
showAccountSettingsButton = showAccountSettingsButton,
Expand Down
13 changes: 0 additions & 13 deletions core/src/main/res/drawable/core_ic_question.xml

This file was deleted.

1 change: 0 additions & 1 deletion core/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<string name="core_account_settings">Налаштування аккаунту</string>
<string name="core_app_update_required_title">Необхідне оновлення додатку</string>
<string name="core_app_update_required_description">Ця версія додатка %1$s застаріла. Щоб продовжити навчання та отримати останні можливості та виправлення, будь ласка, оновіть до останньої версії.</string>
<string name="core_why_do_you_need_update">Чому мені потрібно оновити?</string>
<string name="core_version">Версія: %1$s</string>
<string name="core_up_to_date">Оновлено</string>
<string name="core_tap_to_update_to_version">Натисніть, щоб оновити до версії %1$s</string>
Expand Down
1 change: 0 additions & 1 deletion core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<string name="core_account_settings">Account Settings</string>
<string name="core_app_update_required_title">App Update Required</string>
<string name="core_app_update_required_description">This version of the OpenEdX app is out-of-date. To continue learning and get the latest features and fixes, please upgrade to the latest version.</string>
<string name="core_why_do_you_need_update">Why do I need to update?</string>
<string name="core_version">Version: %1$s</string>
<string name="core_up_to_date">Up-to-date</string>
<string name="core_tap_to_update_to_version">Tap to update to version %1$s</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@ import androidx.compose.ui.Modifier
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.media3.cast.CastPlayer
import androidx.media3.cast.SessionAvailabilityListener
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
import androidx.media3.common.Player
import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.ExoPlayer
import androidx.window.layout.WindowMetricsCalculator
import com.google.android.gms.cast.framework.CastContext
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import org.openedx.core.extension.computeWindowSizeClasses
import org.openedx.core.extension.dpToPixel
import org.openedx.core.extension.objectToString
import org.openedx.core.extension.stringToObject
import org.openedx.core.presentation.dialog.select_bottom.SelectBottomDialogFragment
import org.openedx.core.presentation.dialog.selectorbottomsheet.SelectBottomDialogFragment
import org.openedx.core.presentation.global.viewBinding
import org.openedx.core.ui.WindowSize
import org.openedx.core.ui.theme.OpenEdXTheme
Expand All @@ -45,7 +41,6 @@ import org.openedx.course.presentation.CourseRouter
import org.openedx.course.presentation.ui.ConnectionErrorView
import org.openedx.course.presentation.ui.VideoSubtitles
import org.openedx.course.presentation.ui.VideoTitle
import java.util.concurrent.Executors
import kotlin.math.roundToInt

class VideoUnitFragment : Fragment(R.layout.fragment_video_unit) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.koin.core.parameter.parametersOf
import org.openedx.core.extension.computeWindowSizeClasses
import org.openedx.core.extension.objectToString
import org.openedx.core.extension.stringToObject
import org.openedx.core.presentation.dialog.select_bottom.SelectBottomDialogFragment
import org.openedx.core.presentation.dialog.selectorbottomsheet.SelectBottomDialogFragment
import org.openedx.core.ui.WindowSize
import org.openedx.core.ui.theme.OpenEdXTheme
import org.openedx.core.ui.theme.appColors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import org.koin.androidx.viewmodel.ext.android.viewModel
import org.openedx.core.UIMessage
import org.openedx.core.domain.model.Course
import org.openedx.core.domain.model.Media
import org.openedx.core.presentation.dialog.app_upgrade.AppUpgradeDialogFragment
import org.openedx.core.presentation.dialog.appupgrade.AppUpgradeDialogFragment
import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRecommendedBox
import org.openedx.core.system.notifier.AppUpgradeEvent
import org.openedx.core.ui.*
Expand Down

0 comments on commit 551553e

Please sign in to comment.