Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 50 additions & 32 deletions OpenEdXMobile/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,64 @@
android:supportsRtl="${supportsRtl}"
android:theme="@style/AppTheme">

<activity
android:name="sa.gov.moe.etraining.authentication.SSOAuthActivity"
android:label="@string/app_name"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.Launch">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<data android:scheme="edx" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>

<activity
android:name="sa.gov.moe.etraining.view.SplashActivity"
android:label="@string/app_shortcut_name"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<intent-filter>
<data android:scheme="edx" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<!--<intent-filter>-->
<!--<action android:name="android.intent.action.MAIN" />-->
<!--<category android:name="android.intent.category.LAUNCHER" />-->
<!--</intent-filter>-->

<!--<intent-filter>-->
<!--<data android:scheme="edx" android:host="open" />-->
<!--<action android:name="android.intent.action.VIEW" />-->
<!--<category android:name="android.intent.category.DEFAULT" />-->
<!--<category android:name="android.intent.category.BROWSABLE" />-->
<!--</intent-filter>-->
</activity>

<activity
android:name="sa.gov.moe.etraining.view.LaunchActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.Launch" />

<activity
android:name="sa.gov.moe.etraining.view.DiscoveryLaunchActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name="sa.gov.moe.etraining.view.LoginActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:windowSoftInputMode="adjustNothing"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
android:name="sa.gov.moe.etraining.view.RegisterActivity"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
Expand All @@ -85,7 +103,7 @@
<activity
android:name="sa.gov.moe.etraining.view.AccountActivity"
android:label="@string/title_account"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
Expand Down Expand Up @@ -150,7 +168,7 @@
<activity
android:name=".view.WebViewFindCoursesActivity"
android:label="@string/label_discover"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
Expand All @@ -161,13 +179,13 @@
<activity
android:name="sa.gov.moe.etraining.view.CourseInfoActivity"
android:label="@string/label_discover"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
android:name="sa.gov.moe.etraining.view.CourseDetailActivity"
android:label="@string/label_find_courses"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
Expand All @@ -178,7 +196,7 @@
<activity
android:name=".view.NativeFindCoursesActivity"
android:label="@string/label_find_courses"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
Expand All @@ -189,60 +207,60 @@
<activity
android:name="sa.gov.moe.etraining.view.CertificateActivity"
android:label="@string/tab_label_certificate"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar"/>

<activity
android:name="sa.gov.moe.etraining.view.SettingsActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
android:name="sa.gov.moe.etraining.view.ShowAboutPageActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
android:name="sa.gov.moe.etraining.view.ShowFAQPageActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
android:name="sa.gov.moe.etraining.view.ShowContactsPageActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
android:name=".profiles.UserProfileActivity"
android:label="@string/profile_title"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
android:name=".view.EditUserProfileActivity"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar" />

<activity
android:name=".view.FormFieldActivity"
android:label=""
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar"
android:windowSoftInputMode="adjustResize" />

<activity
android:name=".view.CropImageActivity"
android:label=""
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".whatsnew.WhatsNewActivity"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar" />

<activity
Expand All @@ -252,7 +270,7 @@

<activity
android:name=".view.dialog.WebViewActivity"
android:screenOrientation="portrait"
android:screenOrientation="unspecified"
android:theme="@style/AppTheme.NoActionBar.TranslucentStatusBar">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
Expand Down
17 changes: 14 additions & 3 deletions OpenEdXMobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import org.edx.builder.TaskHelper

buildscript {
repositories {
// google()
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
Expand Down Expand Up @@ -138,6 +139,16 @@ dependencies {
compile 'com.squareup.phrase:phrase:1.1.0'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'

// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
// compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.10'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
// compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient-android
// compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5.1'



/* Exclude dependencies defined statically at the top-
* level, to prevent them from being resolved to the
* latest version as a result of dynamic version
Expand Down Expand Up @@ -267,12 +278,12 @@ android {
applicationId "sa.gov.moe.etraining"
// minimum version is Android 4.1
minSdkVersion 16
targetSdkVersion 21
targetSdkVersion 28

// versionCode getVersionCode()
versionCode 2150101
versionCode 2150102
// versionCode getVersionCode()
versionName "2.15.01.01"
versionName "2.15.01.02"

renderscriptTargetApi 22
renderscriptSupportModeEnabled true
Expand Down
17 changes: 10 additions & 7 deletions OpenEdXMobile/default_config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
API_HOST_URL: 'https://edxmoe.ilearnme.com'
ENVIRONMENT_DISPLAY_NAME: 'edxmoe.ilearnme.com'
API_HOST_URL: 'https://etraining.moe.gov.sa'
ENVIRONMENT_DISPLAY_NAME: 'etraining.moe.gov.sa'
PLATFORM_NAME: 'MOE'
PLATFORM_DESTINATION_NAME: 'edxmoe.ilearnme.com'
FEEDBACK_EMAIL_ADDRESS: 'info@raccoongang.com'
OAUTH_ENFORCE_SECURE: true
PLATFORM_DESTINATION_NAME: 'etraining.moe.gov.sa'
FEEDBACK_EMAIL_ADDRESS: 'support@ilearn.ws'
#OAUTH_ENFORCE_SECURE: true
PUSH_NOTIFICATIONS: true
USER_PROFILES_ENABLED: true
DEBUG: true
OAUTH_CLIENT_ID: '0d7d01a1f2a866866285'
OAUTH_CLIENT_ID: '2c03c507cadfe54ac028' # PROD
#ENABLE_MOBILE_REST_API: true
MY_VIDEOS_ENABLED: true
DISCUSSIONS_ENABLED: true
COURSE_VIDEOS_ENABLED: true
COURSE_ENROLLMENT : { TYPE : 'native', SEARCH_BAR_ENABLED : true }
COURSE_ENROLLMENT : { TYPE : 'native', SEARCH_BAR_ENABLED : true }
SSO_AUTH_URL: 'https://etraining.moe.gov.sa/oauth2/authorize/?scope=openid+profile+email+permissions&state=xyz&redirect_uri=https://etraining.moe.gov.sa/api/mobile/v0.5/?app=android&response_type=code&client_id=2c03c507cadfe54ac028'
ACCESS_TOKEN_REQUEST_URL: 'https://etraining.moe.gov.sa/oauth2/access_token'
ACCESS_TOKEN_REQUEST_DATA: 'client_id=2c03c507cadfe54ac028&client_secret=b20556f9854dda7cdb29c45aee9c1d01bcc0331e&grant_type=authorization_code&code='
31 changes: 31 additions & 0 deletions OpenEdXMobile/res/layout/sso_login_activity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<WebView
android:id="@+id/login_web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />


<FrameLayout
android:id="@+id/progress_frame"
android:layout_width="match_parent"
android:layout_height="0dp"
style="@style/edX.Widget"
android:contentDescription="@string/login_btn"
android:focusable="true">

<include
android:id="@+id/progress"
layout="@layout/button_progress_indicator" />
</FrameLayout>
</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package sa.gov.moe.etraining

public interface OkHttpClientProvider
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.os.Bundle;
import android.support.annotation.NonNull;

import com.google.android.gms.auth.api.Auth;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.inject.Inject;
Expand Down Expand Up @@ -96,6 +97,11 @@ public AuthResponse logInUsingGoogle(String accessToken) throws Exception {
return finishSocialLogIn(accessToken, LoginPrefs.AuthBackend.GOOGLE);
}

@NonNull
public AuthResponse logInUsingMoe(String accessToken, AuthResponse responseObject) throws Exception {
return finishOauthlLogIn(accessToken, responseObject, LoginPrefs.AuthBackend.MOE);
}

@NonNull
private AuthResponse finishSocialLogIn(@NonNull String accessToken, @NonNull LoginPrefs.AuthBackend authBackend) throws Exception {
final String backend = ApiConstants.getOAuthGroupIdForAuthBackend(authBackend);
Expand All @@ -115,6 +121,28 @@ private AuthResponse finishSocialLogIn(@NonNull String accessToken, @NonNull Log
return data;
}

@NonNull
private AuthResponse finishOauthlLogIn(@NonNull String accessToken, AuthResponse responseObject, @NonNull LoginPrefs.AuthBackend authBackend) throws Exception {
final String backend = ApiConstants.getOAuthGroupIdForAuthBackend(authBackend);
// final Response<AuthResponse> response = loginService.exchangeAccessToken(accessToken, config.getOAuthClientId(), backend).execute();


// if (response.code() == HttpURLConnection.HTTP_UNAUTHORIZED) {
//// TODO: Introduce a more explicit error code to indicate that an account is not linked.
// throw new AccountNotLinkedException();
// }
// if (!response.isSuccessful()) {
// throw new HttpStatusException(response);
// }
final AuthResponse data = responseObject;
// if (data.error != null && data.error.equals(Integer.toString(HttpURLConnection.HTTP_UNAUTHORIZED))) {
// throw new AccountNotLinkedException();
// }
finishLogIn(data, authBackend, "");
return data;
}


private void finishLogIn(@NonNull AuthResponse response, @NonNull LoginPrefs.AuthBackend authBackend, @NonNull String usernameUsedToLogIn) throws Exception {
loginPrefs.storeAuthTokenResponse(response, authBackend);
try {
Expand Down
Loading