Skip to content

Commit 6d0df38

Browse files
committed
fix: merge resolving conflicts
1 parent 2655766 commit 6d0df38

File tree

6 files changed

+113
-117
lines changed

6 files changed

+113
-117
lines changed

app/src/main/java/org/openedx/app/di/ScreenModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ val screenModule = module {
118118
get(),
119119
get(),
120120
get(),
121+
get(),
122+
get(),
123+
get(),
121124
courseId,
122125
infoType,
123126
authCode,

auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt

Lines changed: 87 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ import org.openedx.core.ui.HorizontalLine
7171
import org.openedx.core.ui.HyperlinkText
7272
import org.openedx.core.ui.OpenEdXButton
7373
import org.openedx.core.ui.OpenEdXOutlinedButton
74-
import org.openedx.core.ui.WindowSize
75-
import org.openedx.core.ui.WindowType
7674
import org.openedx.core.ui.displayCutoutForLandscape
7775
import org.openedx.core.ui.noRippleClickable
7876
import org.openedx.core.ui.theme.OpenEdXTheme
@@ -235,109 +233,109 @@ private fun AuthForm(
235233
var isPasswordError by rememberSaveable { mutableStateOf(false) }
236234

237235
if (state.isLoginRegistrationFormEnabled) {
238-
Column(horizontalAlignment = Alignment.CenterHorizontally) {
239-
if (!state.isBrowserLoginEnabled) {
240-
LoginTextField(
241-
modifier = Modifier
242-
.fillMaxWidth(),
243-
title = stringResource(id = R.string.auth_email_username),
244-
description = stringResource(id = R.string.auth_enter_email_username),
245-
onValueChanged = {
246-
login = it
247-
isEmailError = false
248-
},
249-
isError = isEmailError,
250-
errorMessages = stringResource(id = R.string.auth_error_empty_username_email)
251-
)
236+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
237+
if (!state.isBrowserLoginEnabled) {
238+
LoginTextField(
239+
modifier = Modifier
240+
.fillMaxWidth(),
241+
title = stringResource(id = R.string.auth_email_username),
242+
description = stringResource(id = R.string.auth_enter_email_username),
243+
onValueChanged = {
244+
login = it
245+
isEmailError = false
246+
},
247+
isError = isEmailError,
248+
errorMessages = stringResource(id = R.string.auth_error_empty_username_email)
249+
)
252250

253-
Spacer(modifier = Modifier.height(18.dp))
254-
PasswordTextField(
255-
modifier = Modifier
256-
.fillMaxWidth(),
257-
onValueChanged = {
258-
password = it
259-
isPasswordError = false
260-
},
261-
onPressDone = {
262-
keyboardController?.hide()
263-
if (password.isNotEmpty()) {
264-
onEvent(AuthEvent.SignIn(login = login, password = password))
265-
} else {
266-
isEmailError = login.isEmpty()
267-
isPasswordError = password.isEmpty()
268-
}
269-
},
270-
isError = isPasswordError,
271-
)
272-
} else {
273-
Spacer(modifier = Modifier.height(40.dp))
274-
}
251+
Spacer(modifier = Modifier.height(18.dp))
252+
PasswordTextField(
253+
modifier = Modifier
254+
.fillMaxWidth(),
255+
onValueChanged = {
256+
password = it
257+
isPasswordError = false
258+
},
259+
onPressDone = {
260+
keyboardController?.hide()
261+
if (password.isNotEmpty()) {
262+
onEvent(AuthEvent.SignIn(login = login, password = password))
263+
} else {
264+
isEmailError = login.isEmpty()
265+
isPasswordError = password.isEmpty()
266+
}
267+
},
268+
isError = isPasswordError,
269+
)
270+
} else {
271+
Spacer(modifier = Modifier.height(40.dp))
272+
}
275273

276-
Row(
277-
Modifier
278-
.fillMaxWidth()
279-
.padding(top = 20.dp, bottom = 36.dp)
280-
) {
281-
if (state.isLogistrationEnabled.not()) {
282-
if (!state.isBrowserLoginEnabled) {
283-
if (state.isLogistrationEnabled.not() && state.isRegistrationEnabled) {
274+
Row(
275+
Modifier
276+
.fillMaxWidth()
277+
.padding(top = 20.dp, bottom = 36.dp)
278+
) {
279+
if (state.isLogistrationEnabled.not()) {
280+
if (!state.isBrowserLoginEnabled) {
281+
if (state.isLogistrationEnabled.not() && state.isRegistrationEnabled) {
282+
Text(
283+
modifier = Modifier
284+
.testTag("txt_register")
285+
.noRippleClickable {
286+
onEvent(AuthEvent.RegisterClick)
287+
},
288+
text = stringResource(id = coreR.string.core_register),
289+
color = MaterialTheme.appColors.primary,
290+
style = MaterialTheme.appTypography.labelLarge
291+
)
292+
}
293+
Spacer(modifier = Modifier.weight(1f))
284294
Text(
285295
modifier = Modifier
286-
.testTag("txt_register")
296+
.testTag("txt_forgot_password")
287297
.noRippleClickable {
288-
onEvent(AuthEvent.RegisterClick)
298+
onEvent(AuthEvent.ForgotPasswordClick)
289299
},
290-
text = stringResource(id = coreR.string.core_register),
291-
color = MaterialTheme.appColors.primary,
300+
text = stringResource(id = R.string.auth_forgot_password),
301+
color = MaterialTheme.appColors.infoVariant,
292302
style = MaterialTheme.appTypography.labelLarge
293303
)
294304
}
295-
Spacer(modifier = Modifier.weight(1f))
296-
Text(
297-
modifier = Modifier
298-
.testTag("txt_forgot_password")
299-
.noRippleClickable {
300-
onEvent(AuthEvent.ForgotPasswordClick)
301-
},
302-
text = stringResource(id = R.string.auth_forgot_password),
303-
color = MaterialTheme.appColors.infoVariant,
304-
style = MaterialTheme.appTypography.labelLarge
305-
)
306305
}
307306
}
308-
}
309307

310308

311-
if (state.showProgress) {
312-
CircularProgressIndicator(color = MaterialTheme.appColors.primary)
313-
} else {
314-
OpenEdXButton(
315-
modifier = buttonWidth.testTag("btn_sign_in"),
316-
text = stringResource(id = coreR.string.core_sign_in),
317-
textColor = MaterialTheme.appColors.primaryButtonText,
318-
backgroundColor = MaterialTheme.appColors.secondaryButtonBackground,
319-
onClick = {
320-
if (state.isBrowserLoginEnabled) {
321-
onEvent(AuthEvent.SignInBrowser)
322-
} else {
323-
keyboardController?.hide()
324-
if (login.isNotEmpty() && password.isNotEmpty()) {
325-
onEvent(AuthEvent.SignIn(login = login, password = password))
309+
if (state.showProgress) {
310+
CircularProgressIndicator(color = MaterialTheme.appColors.primary)
311+
} else {
312+
OpenEdXButton(
313+
modifier = buttonWidth.testTag("btn_sign_in"),
314+
text = stringResource(id = coreR.string.core_sign_in),
315+
textColor = MaterialTheme.appColors.primaryButtonText,
316+
backgroundColor = MaterialTheme.appColors.secondaryButtonBackground,
317+
onClick = {
318+
if (state.isBrowserLoginEnabled) {
319+
onEvent(AuthEvent.SignInBrowser)
326320
} else {
327-
isEmailError = login.isEmpty()
328-
isPasswordError = password.isEmpty()
321+
keyboardController?.hide()
322+
if (login.isNotEmpty() && password.isNotEmpty()) {
323+
onEvent(AuthEvent.SignIn(login = login, password = password))
324+
} else {
325+
isEmailError = login.isEmpty()
326+
isPasswordError = password.isEmpty()
327+
}
329328
}
330329
}
331-
}
332-
)
333-
}
334-
if (state.isSocialAuthEnabled) {
335-
SocialAuthView(
336-
modifier = buttonWidth,
337-
isGoogleAuthEnabled = state.isGoogleAuthEnabled,
338-
isFacebookAuthEnabled = state.isFacebookAuthEnabled,
339-
isMicrosoftAuthEnabled = state.isMicrosoftAuthEnabled,
340-
isSignIn = true,
330+
)
331+
}
332+
if (state.isSocialAuthEnabled) {
333+
SocialAuthView(
334+
modifier = buttonWidth,
335+
isGoogleAuthEnabled = state.isGoogleAuthEnabled,
336+
isFacebookAuthEnabled = state.isFacebookAuthEnabled,
337+
isMicrosoftAuthEnabled = state.isMicrosoftAuthEnabled,
338+
isSignIn = true,
341339
) {
342340
keyboardController?.hide()
343341
onEvent(AuthEvent.SocialSignIn(it))

core/src/main/java/org/openedx/core/config/Config.kt

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ import com.google.gson.JsonParser
88
import org.openedx.core.domain.model.AgreementUrls
99
import java.io.InputStreamReader
1010

11-
@Suppress("TooManyFunctions")
1211
class Config(context: Context) {
1312

1413
private var configProperties: JsonObject = try {
1514
val inputStream = context.assets.open("config/config.json")
16-
val config = JsonParser.parseReader(InputStreamReader(inputStream))
15+
val config = Gson().fromJson(InputStreamReader(inputStream), JsonObject::class.java)
1716
config.asJsonObject
1817
} catch (e: Exception) {
19-
e.printStackTrace()
2018
JsonObject()
2119
}
2220

@@ -112,12 +110,18 @@ class Config(context: Context) {
112110
return getObjectOrNewInstance(UI_COMPONENTS, UIConfig::class.java)
113111
}
114112

113+
fun isBrowserLoginEnabled(): Boolean {
114+
return getBoolean(BROWSER_LOGIN, false)
115+
}
116+
117+
fun isBrowserRegistrationEnabled(): Boolean {
118+
return getBoolean(BROWSER_REGISTRATION, false)
119+
}
120+
115121
fun isRegistrationEnabled(): Boolean {
116122
return getBoolean(REGISTRATION_ENABLED, true)
117123
}
118124

119-
fun isBrowserLoginEnabled(): Boolean {
120-
return getBoolean(BROWSER_LOGIN, false)
121125
fun isLoginRegistrationEnabled(): Boolean {
122126
return getBoolean(LOGIN_REGISTRATION_ENABLED, true)
123127
}
@@ -135,14 +139,6 @@ class Config(context: Context) {
135139
return element?.asJsonObject?.get(key)?.asString ?: defaultValue
136140
}
137141

138-
fun isCourseNestedListEnabled(): Boolean {
139-
return getBoolean(COURSE_NESTED_LIST_ENABLED, false)
140-
}
141-
142-
fun isBrowserRegistrationEnabled(): Boolean {
143-
return getBoolean(BROWSER_REGISTRATION, false)
144-
}
145-
146142
private fun getString(key: String, defaultValue: String = ""): String {
147143
val element = getObject(key)
148144
return if (element != null) {
@@ -166,15 +162,13 @@ class Config(context: Context) {
166162
try {
167163
cls.getDeclaredConstructor().newInstance()
168164
} catch (e: InstantiationException) {
169-
throw ConfigParsingException(e)
165+
throw RuntimeException(e)
170166
} catch (e: IllegalAccessException) {
171-
throw ConfigParsingException(e)
167+
throw RuntimeException(e)
172168
}
173169
}
174170
}
175171

176-
class ConfigParsingException(cause: Throwable) : Exception(cause)
177-
178172
private fun getObject(key: String): JsonElement? {
179173
return configProperties.get(key)
180174
}
@@ -202,9 +196,9 @@ class Config(context: Context) {
202196
private const val GOOGLE = "GOOGLE"
203197
private const val MICROSOFT = "MICROSOFT"
204198
private const val PRE_LOGIN_EXPERIENCE_ENABLED = "PRE_LOGIN_EXPERIENCE_ENABLED"
205-
private const val REGISTRATION_ENABLED = "REGISTRATION_ENABLED"
206199
private const val BROWSER_LOGIN = "BROWSER_LOGIN"
207200
private const val BROWSER_REGISTRATION = "BROWSER_REGISTRATION"
201+
private const val REGISTRATION_ENABLED = "REGISTRATION_ENABLED"
208202
private const val DISCOVERY = "DISCOVERY"
209203
private const val PROGRAM = "PROGRAM"
210204
private const val DASHBOARD = "DASHBOARD"
@@ -217,4 +211,4 @@ class Config(context: Context) {
217211
NATIVE,
218212
WEBVIEW
219213
}
220-
}
214+
}

core/src/main/java/org/openedx/core/presentation/global/webview/SSOWebContentFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import androidx.fragment.app.setFragmentResult
1111
import org.koin.android.ext.android.inject
1212
import org.openedx.core.config.Config
1313
import org.openedx.core.ui.SSOWebContentScreen
14-
import org.openedx.core.ui.rememberWindowSize
14+
import org.openedx.foundation.presentation.rememberWindowSize
1515
import org.openedx.core.ui.theme.OpenEdXTheme
1616

1717
class SSOWebContentFragment : Fragment() {

core/src/main/java/org/openedx/core/ui/SSOWebContentScreen.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import androidx.compose.ui.unit.dp
2929
import androidx.compose.ui.viewinterop.AndroidView
3030
import androidx.compose.ui.zIndex
3131
import org.openedx.core.ui.theme.appColors
32+
import org.openedx.foundation.presentation.WindowSize
33+
import org.openedx.foundation.presentation.windowSizeValue
3234

3335

3436
@OptIn(ExperimentalComposeUiApi::class)
@@ -50,11 +52,10 @@ fun SSOWebContentScreen(
5052
)
5153
val screenWidth by remember(key1 = windowSize) {
5254
mutableStateOf(
53-
windowSize.windowSizeValue(
54-
expanded = Modifier.widthIn(Dp.Unspecified, 560.dp),
55-
compact = Modifier.fillMaxWidth(),
56-
57-
)
55+
windowSize.windowSizeValue(
56+
expanded = Modifier.widthIn(Dp.Unspecified, 560.dp),
57+
compact = Modifier.fillMaxWidth(),
58+
)
5859
)
5960
}
6061

default_config/dev/config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ URI_SCHEME: ''
77
FEEDBACK_EMAIL_ADDRESS: '[email protected]'
88
FAQ_URL: ''
99
OAUTH_CLIENT_ID: 'OAUTH_CLIENT_ID'
10-
LOGIN_REGISTRATION_ENABLED: true
11-
SAML_SSO_LOGIN_ENABLED: false
12-
SAML_SSO_DEFAULT_LOGIN_BUTTON: false
10+
LOGIN_REGISTRATION_ENABLED: false
11+
SAML_SSO_LOGIN_ENABLED: true
12+
SAML_SSO_DEFAULT_LOGIN_BUTTON: true
1313

1414
SSO_BUTTON_TITLE:
1515
AR: "الدخول عبر SSO"

0 commit comments

Comments
 (0)