From dd3eb56d1966446d47590eb3ab0e93de05d6bb06 Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Thu, 17 Aug 2023 17:51:55 +0530 Subject: [PATCH 1/8] feat: add support for providing alternate resource directory This change adds support for specifying an alternative resource directory, allowing resources to be overridden without needing to fork the repository. --- app/build.gradle | 31 +++++++++++++++++++++++++++++++ core/build.gradle | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index 831c836b8..2453704fd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,12 @@ +import org.yaml.snakeyaml.Yaml + +buildscript { + + dependencies { + classpath 'org.yaml:snakeyaml:1.33' + } +} + plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' @@ -6,6 +15,8 @@ plugins { id "com.google.firebase.crashlytics" } +def config = new Yaml().load(new File("config.yaml").newInputStream()) + android { compileSdk 34 @@ -35,6 +46,26 @@ android { dimension 'env' } } + sourceSets { + prod { + def envMap = config.environments.find { it.key == "PROD" } + if (envMap.value.RES_DIR) { + res.srcDirs = [envMap.value.RES_DIR] + } + } + develop { + def envMap = config.environments.find { it.key == "DEV" } + if (envMap.value.RES_DIR) { + res.srcDirs = [envMap.value.RES_DIR] + } + } + stage { + def envMap = config.environments.find { it.key == "STAGE" } + if (envMap.value.RES_DIR) { + res.srcDirs = [envMap.value.RES_DIR] + } + } + } buildTypes { release { diff --git a/core/build.gradle b/core/build.gradle index 6bce96edf..c44012a56 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -100,6 +100,27 @@ android { } } + sourceSets { + prod { + def envMap = config.environments.find { it.key == "PROD" } + if (envMap.value.RES_DIR) { + res.srcDirs = [envMap.value.RES_DIR] + } + } + develop { + def envMap = config.environments.find { it.key == "DEV" } + if (envMap.value.RES_DIR) { + res.srcDirs = [envMap.value.RES_DIR] + } + } + stage { + def envMap = config.environments.find { it.key == "STAGE" } + if (envMap.value.RES_DIR) { + res.srcDirs = [envMap.value.RES_DIR] + } + } + } + buildTypes { release { minifyEnabled true From 3bc8dfb5eeda589c0bc804fa7c033c09736c8c8e Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Mon, 21 Aug 2023 14:24:16 +0530 Subject: [PATCH 2/8] feat: Add support for specifying custom config file using environment This change makes it possible to specify an alternative location for the config.yaml file using an environment variable. This allows the developers to override all important data without messing up any files that can be committed to the repository. --- app/build.gradle | 3 ++- core/build.gradle | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2453704fd..1a8db2418 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,7 +15,8 @@ plugins { id "com.google.firebase.crashlytics" } -def config = new Yaml().load(new File("config.yaml").newInputStream()) +def config_file = System.getenv("OPENEDX_ANDROID_CFG_FILE") ?: "config.yaml" +def config = new Yaml().load(new File(config_file).newInputStream()) android { compileSdk 34 diff --git a/core/build.gradle b/core/build.gradle index c44012a56..82f95bf04 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -18,7 +18,8 @@ plugins { } -def config = new Yaml().load(new File("config.yaml").newInputStream()) +def config_file = System.getenv("OPENEDX_ANDROID_CFG_FILE") ?: "config.yaml" +def config = new Yaml().load(new File(config_file).newInputStream()) android { compileSdk 34 From 9f8c4f189bfc03a4b5e2c740dcafc283414e5e99 Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Mon, 21 Aug 2023 14:32:45 +0530 Subject: [PATCH 3/8] docs: Update documentation --- README.md | 7 +++++++ config.yaml | 3 +++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 392e6307e..8c63b881c 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,18 @@ Modern vision of the mobile application for the Open EdX platform from Raccoon G 3. Choose ``educationx-app-android``. 4. Configure the [config.yaml](config.yaml) with URLs and OAuth credentials for your Open edX instance. + You can customise the location of this file using the `OPENEDX_ANDROID_CFG_FILE` environment variable. 5. Select the build variant ``develop``, ``stage``, or ``prod``. 6. Click the **Run** button. +## Customising + +To customise assets used in the Android app, you can specify a resource override directory in +`RES_DIR` in the `config.yaml` file. Any assets in this directory will override assets of the +same name in this repository. + ## API plugin This project uses custom APIs to improve performance and reduce the number of requests to the server. diff --git a/config.yaml b/config.yaml index 09972a3b6..1d7c8a909 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,6 @@ environments: DEV: + # RES_DIR: /path/to/custom/resources URLS: API_HOST_URL: "https://dev-example.com/" privacyPolicy: "https://dev-example.com/privacy" @@ -13,6 +14,7 @@ environments: API_KEY: "" GCM_SENDER_ID: "" STAGE: + # RES_DIR: /path/to/custom/resources URLS: API_HOST_URL: "http://stage-example.com/" privacyPolicy: "http://stage-example.com/privacy" @@ -26,6 +28,7 @@ environments: API_KEY: "" GCM_SENDER_ID: "" PROD: + # RES_DIR: /path/to/custom/resources URLS: API_HOST_URL: "https://example.com/" privacyPolicy: "https://example.com/privacy" From a78857bb02a1fed434925a9017783e58e414ffd4 Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Tue, 5 Sep 2023 16:40:13 +0530 Subject: [PATCH 4/8] feat: Add support for specifying application id in the config file --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 1a8db2418..0fbf53ade 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,7 +22,7 @@ android { compileSdk 34 defaultConfig { - applicationId "org.openedx.app" + applicationId config?.application_id ?: "org.openedx.app" minSdk 24 targetSdk 34 versionCode 1 From 91df8544e30a0ea620b373000a882775c387a09f Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Tue, 5 Sep 2023 16:45:11 +0530 Subject: [PATCH 5/8] feat: Add support for browser-based logins For sites that only support logging in using a third-party login provider, allow logging in via a browser. This new flow will open a custom tab where a user can log in using the supported mechanisms of the site, then have the client id redirect back to to the app using a callback URL. The auth code returned by the callback URL can then be used instead of a username and password to log in. --- app/build.gradle | 2 + app/src/main/AndroidManifest.xml | 6 ++ .../main/java/org/openedx/app/AppActivity.kt | 16 ++++- auth/build.gradle | 1 + .../java/org/openedx/auth/data/api/AuthApi.kt | 11 ++++ .../auth/data/repository/AuthRepository.kt | 28 ++++++--- .../auth/domain/interactor/AuthInteractor.kt | 4 ++ .../presentation/signin/SignInFragment.kt | 58 ++++++++++++++++--- .../presentation/signin/SignInViewModel.kt | 27 ++++++++- core/build.gradle | 3 + .../java/org/openedx/core/ApiConstants.kt | 1 + 11 files changed, 141 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0fbf53ade..4ec379c43 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,9 +42,11 @@ android { } develop { dimension 'env' + applicationIdSuffix '.dev' } stage { dimension 'env' + applicationIdSuffix '.stage' } } sourceSets { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 086cf5a34..8e96e5412 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -35,6 +35,12 @@ + + + + + + { diff --git a/auth/src/main/java/org/openedx/auth/domain/interactor/AuthInteractor.kt b/auth/src/main/java/org/openedx/auth/domain/interactor/AuthInteractor.kt index 53d68fd22..c75e9ee1a 100644 --- a/auth/src/main/java/org/openedx/auth/domain/interactor/AuthInteractor.kt +++ b/auth/src/main/java/org/openedx/auth/domain/interactor/AuthInteractor.kt @@ -13,6 +13,10 @@ class AuthInteractor(private val repository: AuthRepository) { repository.login(username, password) } + suspend fun login(code: String) { + repository.login(code) + } + suspend fun getRegistrationFields(): List { return repository.getRegistrationFields() } diff --git a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt index 1f82823ac..1c54452ab 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt @@ -2,9 +2,12 @@ package org.openedx.auth.presentation.signin import android.content.res.Configuration.UI_MODE_NIGHT_NO import android.content.res.Configuration.UI_MODE_NIGHT_YES +import android.net.Uri import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup +import androidx.browser.customtabs.CustomTabsIntent import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.* @@ -42,6 +45,7 @@ import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel +import org.openedx.core.BuildConfig class SignInFragment : Fragment() { @@ -53,6 +57,10 @@ class SignInFragment : Fragment() { container: ViewGroup?, savedInstanceState: Bundle?, ) = ComposeView(requireContext()).apply { + val authCode = arguments?.getString("auth_code") + if (authCode is String) { + viewModel.login(authCode) + } setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) setContent { OpenEdXTheme { @@ -62,10 +70,12 @@ class SignInFragment : Fragment() { val uiMessage by viewModel.uiMessage.observeAsState() val loginSuccess by viewModel.loginSuccess.observeAsState(initial = false) + Log.d("TEST111", context.packageName) LoginScreen( windowSize = windowSize, showProgress = showProgress, uiMessage = uiMessage, + browserLogin = BuildConfig.BROWSER_LOGIN, onLoginClick = { login, password -> viewModel.login(login, password) }, @@ -76,6 +86,20 @@ class SignInFragment : Fragment() { onForgotPasswordClick = { viewModel.forgotPasswordClickedEvent() router.navigateToRestorePassword(parentFragmentManager) + }, + onLoginClickOauth = { + val uri = Uri.parse("${BuildConfig.BASE_URL}oauth2/authorize") + .buildUpon() + .appendQueryParameter("client_id", BuildConfig.CLIENT_ID) + .appendQueryParameter("redirect_uri", "${context.packageName}://oauth2Callback") + .appendQueryParameter("response_type", "code") + .build() + val intent = CustomTabsIntent.Builder() + .setUrlBarHidingEnabled(true) + .setShowTitle(true) + .build() + intent.launchUrl(context, uri) + } ) @@ -94,7 +118,9 @@ private fun LoginScreen( windowSize: WindowSize, showProgress: Boolean, uiMessage: UIMessage?, + browserLogin: Boolean, onLoginClick: (login: String, password: String) -> Unit, + onLoginClickOauth: () -> Unit, onRegisterClick: () -> Unit, onForgotPasswordClick: () -> Unit ) { @@ -187,13 +213,27 @@ private fun LoginScreen( style = MaterialTheme.appTypography.titleSmall ) Spacer(modifier = Modifier.height(24.dp)) - AuthForm( - buttonWidth, - showProgress, - onLoginClick, - onRegisterClick, - onForgotPasswordClick - ) + if (browserLogin) { + Column( + modifier = Modifier.fillMaxSize(), + verticalArrangement = Arrangement.SpaceAround, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + OpenEdXButton( + width = buttonWidth, + text = stringResource(id = R.string.auth_sign_in), + onClick = onLoginClickOauth, + ) + } + } else { + AuthForm( + buttonWidth, + showProgress, + onLoginClick, + onRegisterClick, + onForgotPasswordClick, + ) + } } } } @@ -334,9 +374,11 @@ private fun SignInScreenPreview() { windowSize = WindowSize(WindowType.Compact, WindowType.Compact), showProgress = false, uiMessage = null, + browserLogin = true, onLoginClick = { _, _ -> }, + onLoginClickOauth = {}, onRegisterClick = {}, onForgotPasswordClick = {} ) @@ -353,9 +395,11 @@ private fun SignInScreenTabletPreview() { windowSize = WindowSize(WindowType.Expanded, WindowType.Expanded), showProgress = false, uiMessage = null, + browserLogin = true, onLoginClick = { _, _ -> }, + onLoginClickOauth = {}, onRegisterClick = {}, onForgotPasswordClick = {} ) diff --git a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt index d9ca3bed5..d64a7a1e5 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt @@ -72,6 +72,30 @@ class SignInViewModel( } } + fun login(code: String) { + viewModelScope.launch { + try { + interactor.login(code) + _loginSuccess.value = true + setUserId() + analytics.userLoginEvent(LoginMethod.BROWSER.methodName) + } catch (e: Exception) { + if (e is EdxError.InvalidGrantException) { + _uiMessage.value = + UIMessage.SnackBarMessage(resourceManager.getString(CoreRes.string.core_error_invalid_grant)) + } else if (e.isInternetError()) { + _uiMessage.value = + UIMessage.SnackBarMessage(resourceManager.getString(CoreRes.string.core_error_no_connection)) + } else { + _uiMessage.value = + UIMessage.SnackBarMessage(resourceManager.getString(CoreRes.string.core_error_unknown_error)) + } + } + _showProgress.value = false + } + + } + fun signUpClickedEvent() { analytics.signUpClickedEvent() } @@ -91,6 +115,7 @@ private enum class LoginMethod(val methodName: String) { PASSWORD("Password"), FACEBOOK("Facebook"), GOOGLE("Google"), - MICROSOFT("Microsoft") + MICROSOFT("Microsoft"), + BROWSER("Browser"), } diff --git a/core/build.gradle b/core/build.gradle index 82f95bf04..4efa3df98 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -49,6 +49,7 @@ android { buildConfigField "String", "FIREBASE_PROJECT_ID", "\"${firebase.projectId}\"" buildConfigField "String", "FIREBASE_API_KEY", "\"${firebase.apiKey}\"" buildConfigField "String", "FIREBASE_GCM_SENDER_ID", "\"${firebase.gcmSenderId}\"" + buildConfigField "boolean", "BROWSER_LOGIN", "${ envMap.value.LOGIN_VIA_BROWSER }" resValue "string", "google_app_id", firebase.appId resValue "string", "platform_name", config.platformName resValue "string", "platform_full_name", config.platformFullName @@ -70,6 +71,7 @@ android { buildConfigField "String", "FIREBASE_PROJECT_ID", "\"${firebase.projectId}\"" buildConfigField "String", "FIREBASE_API_KEY", "\"${firebase.apiKey}\"" buildConfigField "String", "FIREBASE_GCM_SENDER_ID", "\"${firebase.gcmSenderId}\"" + buildConfigField "boolean", "BROWSER_LOGIN", "${ envMap.value.LOGIN_VIA_BROWSER }" resValue "string", "google_app_id", firebase.appId resValue "string", "platform_name", config.platformName resValue "string", "platform_full_name", config.platformFullName @@ -91,6 +93,7 @@ android { buildConfigField "String", "FIREBASE_PROJECT_ID", "\"${firebase.projectId}\"" buildConfigField "String", "FIREBASE_API_KEY", "\"${firebase.apiKey}\"" buildConfigField "String", "FIREBASE_GCM_SENDER_ID", "\"${firebase.gcmSenderId}\"" + buildConfigField "boolean", "BROWSER_LOGIN", "${ envMap.value.LOGIN_VIA_BROWSER }" resValue "string", "google_app_id", firebase.appId resValue "string", "platform_name", config.platformName resValue "string", "platform_full_name", config.platformFullName diff --git a/core/src/main/java/org/openedx/core/ApiConstants.kt b/core/src/main/java/org/openedx/core/ApiConstants.kt index 82486f593..948a1c40c 100644 --- a/core/src/main/java/org/openedx/core/ApiConstants.kt +++ b/core/src/main/java/org/openedx/core/ApiConstants.kt @@ -11,6 +11,7 @@ object ApiConstants { const val URL_PASSWORD_RESET = "/password_reset/" const val GRANT_TYPE_PASSWORD = "password" + const val GRANT_TYPE_CODE = "authorization_code" const val TOKEN_TYPE_REFRESH = "refresh_token" From c54b8975f7561fa123876fb194863c883d0c9407 Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Tue, 12 Sep 2023 19:44:23 +0530 Subject: [PATCH 6/8] temp: potential build fix --- build.gradle | 2 +- settings.gradle | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4cca63b16..420739fe7 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,7 @@ ext { firebase_version = "32.1.0" retrofit_version = '2.9.0' - logginginterceptor_version = '4.9.1' + logginginterceptor_version = '4.11.0' koin_version = '3.2.0' diff --git a/settings.gradle b/settings.gradle index 1bb570281..1a0980258 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,15 @@ pluginManagement { + buildscript { + repositories { + mavenCentral() + maven { + url = uri("https://storage.googleapis.com/r8-releases/raw") + } + } + dependencies { + classpath("com.android.tools:r8:8.2.24") + } + } repositories { gradlePluginPortal() google() From 44ffa162f9e96859bba51cbe245a669e9ba4fa54 Mon Sep 17 00:00:00 2001 From: Yusuf Musleh Date: Mon, 2 Oct 2023 14:01:21 +0300 Subject: [PATCH 7/8] fix: Add various configs to build prodRelease --- app/build.gradle | 9 +++++++++ app/proguard-rules.pro | 8 ++++++++ .../openedx/auth/presentation/signin/SignInFragment.kt | 5 ++--- core/proguard-rules.pro | 4 +++- course/proguard-rules.pro | 5 ++++- dashboard/proguard-rules.pro | 5 ++++- discussion/proguard-rules.pro | 5 ++++- profile/proguard-rules.pro | 5 ++++- 8 files changed, 38 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4ec379c43..e0b9a2188 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,6 +12,7 @@ plugins { id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' id 'kotlin-kapt' + id 'com.google.gms.google-services' id "com.google.firebase.crashlytics" } @@ -128,4 +129,12 @@ dependencies { testImplementation "io.mockk:mockk-android:$mockk_version" testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" + + // Import the Firebase BoM + implementation(platform("com.google.firebase:firebase-bom:32.2.3")) + + // When using the BoM, you don't specify versions in Firebase library dependencies + + // Add the dependency for the Firebase SDK for Google Analytics + implementation("com.google.firebase:firebase-analytics") } \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 49a1005fc..547b1e52c 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -61,6 +61,14 @@ -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation #===============/////GSON RULES \\\\\\\============ + +# Keep Data models from being obfuscated/minimized +-keep class org.openedx.auth.data.model.** { *; } +-keep class org.openedx.core.data.model.** { *; } +-keep class org.openedx.profile.data.model.** { *; } +-keep class org.openedx.profile.domain.model.** { *; } +-keep class org.openedx.discussion.data.model.** { *; } + ##---------------Begin: proguard configuration for Gson ---------- # Gson uses generic type information stored in a class file when working with fields. Proguard # removes such information by default, so configure it to keep all of it. diff --git a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt index 1c54452ab..92429d4e4 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt @@ -1,10 +1,10 @@ package org.openedx.auth.presentation.signin +import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.content.res.Configuration.UI_MODE_NIGHT_NO import android.content.res.Configuration.UI_MODE_NIGHT_YES import android.net.Uri import android.os.Bundle -import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup import androidx.browser.customtabs.CustomTabsIntent @@ -70,7 +70,6 @@ class SignInFragment : Fragment() { val uiMessage by viewModel.uiMessage.observeAsState() val loginSuccess by viewModel.loginSuccess.observeAsState(initial = false) - Log.d("TEST111", context.packageName) LoginScreen( windowSize = windowSize, showProgress = showProgress, @@ -98,8 +97,8 @@ class SignInFragment : Fragment() { .setUrlBarHidingEnabled(true) .setShowTitle(true) .build() + intent.intent.setFlags(FLAG_ACTIVITY_NEW_TASK); intent.launchUrl(context, uri) - } ) diff --git a/core/proguard-rules.pro b/core/proguard-rules.pro index 481bb4348..8dcc9ec0d 100644 --- a/core/proguard-rules.pro +++ b/core/proguard-rules.pro @@ -18,4 +18,6 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-dontwarn java.lang.invoke.StringConcatFactory diff --git a/course/proguard-rules.pro b/course/proguard-rules.pro index 481bb4348..3a6da835e 100644 --- a/course/proguard-rules.pro +++ b/course/proguard-rules.pro @@ -18,4 +18,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-dontwarn java.lang.invoke.StringConcatFactory +-dontwarn org.openedx.core.R$string diff --git a/dashboard/proguard-rules.pro b/dashboard/proguard-rules.pro index 481bb4348..3a6da835e 100644 --- a/dashboard/proguard-rules.pro +++ b/dashboard/proguard-rules.pro @@ -18,4 +18,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-dontwarn java.lang.invoke.StringConcatFactory +-dontwarn org.openedx.core.R$string diff --git a/discussion/proguard-rules.pro b/discussion/proguard-rules.pro index 481bb4348..71cd5111b 100644 --- a/discussion/proguard-rules.pro +++ b/discussion/proguard-rules.pro @@ -18,4 +18,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-dontwarn java.lang.invoke.StringConcatFactory +-dontwarn org.openedx.core.R$string \ No newline at end of file diff --git a/profile/proguard-rules.pro b/profile/proguard-rules.pro index 481bb4348..71cd5111b 100644 --- a/profile/proguard-rules.pro +++ b/profile/proguard-rules.pro @@ -18,4 +18,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-dontwarn java.lang.invoke.StringConcatFactory +-dontwarn org.openedx.core.R$string \ No newline at end of file From 3915e961b793847c8b7634680135953fb7daa1dd Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Thu, 12 Oct 2023 13:45:24 +0530 Subject: [PATCH 8/8] feat: logout via browser as well. --- profile/build.gradle | 1 + .../profile/presentation/profile/ProfileFragment.kt | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/profile/build.gradle b/profile/build.gradle index 1c3c6f301..9c8ad6ed1 100644 --- a/profile/build.gradle +++ b/profile/build.gradle @@ -55,6 +55,7 @@ android { dependencies { implementation project(path: ":core") + implementation 'androidx.browser:browser:1.6.0' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' diff --git a/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileFragment.kt index 96ee13059..3fe2ba3f0 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileFragment.kt @@ -2,9 +2,11 @@ package org.openedx.profile.presentation.profile import android.content.res.Configuration.UI_MODE_NIGHT_NO import android.content.res.Configuration.UI_MODE_NIGHT_YES +import android.net.Uri import android.os.Bundle import android.view.LayoutInflater import android.view.ViewGroup +import androidx.browser.customtabs.CustomTabsIntent import androidx.compose.foundation.* import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape @@ -41,6 +43,7 @@ import coil.compose.AsyncImage import coil.request.ImageRequest import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel +import org.openedx.core.BuildConfig import org.openedx.core.R import org.openedx.core.UIMessage import org.openedx.profile.domain.model.Account @@ -87,6 +90,16 @@ class ProfileFragment : Fragment() { appData = (requireActivity() as AppDataHolder).appData, refreshing = refreshing, logout = { + if (BuildConfig.BROWSER_LOGIN) { + val uri = Uri.parse("${BuildConfig.BASE_URL}logout") + .buildUpon() + .appendQueryParameter("next", "/custom-logout-page").build() + val intent = CustomTabsIntent.Builder() + .setUrlBarHidingEnabled(true) + .setShowTitle(true) + .build() + intent.launchUrl(context, uri) + } viewModel.logout() }, editAccountClicked = {