use of org.edx.mobile.util.Config in project edx-app-android by edx.
the class LoginActivity method createView.
@NonNull
@Override
protected LoginPresenter.LoginViewInterface createView(@Nullable Bundle savedInstanceState) {
activityLoginBinding = DataBindingUtil.setContentView(this, R.layout.activity_login);
hideSoftKeypad();
socialLoginDelegate = new SocialLoginDelegate(this, savedInstanceState, this, environment.getConfig(), environment.getLoginPrefs());
activityLoginBinding.socialAuth.facebookButton.getRoot().setOnClickListener(socialLoginDelegate.createSocialButtonClickHandler(SocialFactory.SOCIAL_SOURCE_TYPE.TYPE_FACEBOOK));
activityLoginBinding.socialAuth.googleButton.getRoot().setOnClickListener(socialLoginDelegate.createSocialButtonClickHandler(SocialFactory.SOCIAL_SOURCE_TYPE.TYPE_GOOGLE));
activityLoginBinding.loginButtonLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Check for Validation˜
callServerForLogin();
}
});
activityLoginBinding.forgotPasswordTv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Calling help dialog
if (NetworkUtil.isConnected(LoginActivity.this)) {
showResetPasswordDialog();
} else {
showAlertDialog(getString(R.string.reset_no_network_title), getString(R.string.network_not_connected));
}
}
});
String platformName = environment.getConfig().getPlatformName();
CharSequence licenseText = ResourceUtil.getFormattedString(getResources(), R.string.licensing_agreement, "platform_name", platformName);
activityLoginBinding.endUserAgreementTv.setText(licenseText);
activityLoginBinding.endUserAgreementTv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showEulaDialog();
}
});
environment.getAnalyticsRegistry().trackScreenView(Analytics.Screens.LOGIN);
// enable login buttons at launch
tryToSetUIInteraction(true);
Config config = environment.getConfig();
setTitle(getString(R.string.login_title));
String envDisplayName = config.getEnvironmentDisplayName();
if (envDisplayName != null && envDisplayName.length() > 0) {
activityLoginBinding.versionEnvTv.setVisibility(View.VISIBLE);
String versionName = BuildConfig.VERSION_NAME;
String text = String.format("%s %s %s", getString(R.string.label_version), versionName, envDisplayName);
activityLoginBinding.versionEnvTv.setText(text);
}
return new LoginPresenter.LoginViewInterface() {
@Override
public void disableToolbarNavigation() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
}
}
@Override
public void setSocialLoginButtons(boolean googleEnabled, boolean facebookEnabled) {
if (!facebookEnabled && !googleEnabled) {
activityLoginBinding.panelLoginSocial.setVisibility(View.GONE);
} else if (!facebookEnabled) {
activityLoginBinding.socialAuth.facebookButton.getRoot().setVisibility(View.GONE);
} else if (!googleEnabled) {
activityLoginBinding.socialAuth.googleButton.getRoot().setVisibility(View.GONE);
}
}
};
}
use of org.edx.mobile.util.Config in project edx-app-android by edx.
the class CacheManager method convert.
/**
* Convert the response URL from the new formats used in the Retrofit implementation, to the
* previous formats used in the original Apache HTTP client implementation, which was what
* populated this cache.
*
* @param url The URL to convert.
* @return The converted URL.
*/
@NonNull
private String convert(@NonNull final String url) {
/* The course structure URL was stripped of it's non-definitive query parameters before
* being stored in the cache, to prevent it not becoming non-accessible after internal API
* changes on the query parameters. The course ID parameter was retained, but not URL-
* escaped.
*/
if (courseStructureGetUrlConversionPattern == null) {
final RoboInjector injector = RoboGuice.getInjector(context);
final Config config = injector.getInstance(Config.class);
String baseUrl = config.getApiHostURL();
if (!baseUrl.endsWith("/")) {
baseUrl += '/';
}
courseStructureGetUrlConversionPattern = Pattern.compile("^(" + baseUrl + "api/courses/v1/blocks/\\?)(?:[^=&;]+?=[^=&;]+?[&;])*?(course_id=)([^=&;]+)");
}
final Matcher urlMatcher = courseStructureGetUrlConversionPattern.matcher(url);
if (urlMatcher.matches()) {
final StringBuffer urlConversionBuffer = new StringBuffer(url.length());
urlMatcher.appendReplacement(urlConversionBuffer, "$1$2" + Uri.decode(urlMatcher.group(3)));
return urlConversionBuffer.toString();
}
return url;
}
use of org.edx.mobile.util.Config in project edx-app-android by edx.
the class BaseTestCase method setUp.
@Before
public void setUp() throws Exception {
context = RuntimeEnvironment.application;
config = new Config(generateConfigProperties());
module = new CustomGuiceModule();
glueInjections();
// Set time zone to a constant value to make time-based tests predictable
TimeZone.setDefault(TimeUtilsForTests.DEFAULT_TIME_ZONE);
print("Started Test Case: " + getClass().getName());
}
use of org.edx.mobile.util.Config in project edx-app-android by edx.
the class ConfigTests method testGoogleEmptyConfig.
@Test
public void testGoogleEmptyConfig() {
JsonObject googleConfig = new JsonObject();
JsonObject configBase = new JsonObject();
configBase.add(GOOGLE, googleConfig);
Config config = new Config(configBase);
assertFalse(config.getGoogleConfig().isEnabled());
}
use of org.edx.mobile.util.Config in project edx-app-android by edx.
the class ConfigTests method testEnrollmentNoConfig.
@Test
public void testEnrollmentNoConfig() {
JsonObject configBase = new JsonObject();
Config config = new Config(configBase);
assertFalse(config.getCourseDiscoveryConfig().isCourseDiscoveryEnabled());
assertFalse(config.getCourseDiscoveryConfig().isWebviewCourseDiscoveryEnabled());
assertNull(config.getCourseDiscoveryConfig().getCourseSearchUrl());
assertNull(config.getCourseDiscoveryConfig().getCourseInfoUrlTemplate());
}
Aggregations