MOBILE-2568 login: Display button to download Moodle Classic
parent
a3d2ad77ad
commit
3c44cee0ee
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Location } from '@angular/common';
|
||||
import { Platform } from 'ionic-angular';
|
||||
import { Platform, AlertController } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreConfigProvider } from '@providers/config';
|
||||
|
@ -83,7 +83,7 @@ export class CoreLoginHelperProvider {
|
|||
private eventsProvider: CoreEventsProvider, private appProvider: CoreAppProvider, private utils: CoreUtilsProvider,
|
||||
private urlUtils: CoreUrlUtilsProvider, private configProvider: CoreConfigProvider, private platform: Platform,
|
||||
private initDelegate: CoreInitDelegate, private sitePluginsProvider: CoreSitePluginsProvider,
|
||||
private location: Location) {
|
||||
private location: Location, private alertCtrl: AlertController) {
|
||||
this.logger = logger.getInstance('CoreLoginHelper');
|
||||
}
|
||||
|
||||
|
@ -924,6 +924,41 @@ export class CoreLoginHelperProvider {
|
|||
(!CoreConfigConstants.skipssoconfirmation || String(CoreConfigConstants.skipssoconfirmation) === 'false');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a modal warning the user that he should use the Classic app.
|
||||
*
|
||||
* @param {string} message The warning message.
|
||||
*/
|
||||
protected showLegacyNoticeModal(message: string): void {
|
||||
const isAndroid = this.platform.is('android'),
|
||||
isIOS = this.platform.is('ios'),
|
||||
buttons: any[] = [
|
||||
{
|
||||
text: this.translate.instant('core.ok'),
|
||||
role: 'cancel'
|
||||
}
|
||||
];
|
||||
|
||||
if (isAndroid || isIOS) {
|
||||
buttons.push({
|
||||
text: this.translate.instant('core.download'),
|
||||
handler: (): void => {
|
||||
const link = isAndroid ? 'market://details?id=com.moodle.classic' :
|
||||
'itms-apps://itunes.apple.com/app/id1403448117';
|
||||
|
||||
this.utils.openInBrowser(link);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const alert = this.alertCtrl.create({
|
||||
message: message,
|
||||
buttons: buttons
|
||||
});
|
||||
|
||||
alert.present();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called when site policy is not agreed. Reserved for core use.
|
||||
*
|
||||
|
@ -961,6 +996,8 @@ export class CoreLoginHelperProvider {
|
|||
treatUserTokenError(siteUrl: string, error: any): void {
|
||||
if (error.errorcode == 'forcepasswordchangenotice') {
|
||||
this.openChangePassword(siteUrl, error.error || error.message || error.body || error.content);
|
||||
} else if (error.errorcode == 'legacymoodleversion') {
|
||||
this.showLegacyNoticeModal(error.error);
|
||||
} else {
|
||||
this.domUtils.showErrorModal(error);
|
||||
}
|
||||
|
|
|
@ -494,9 +494,15 @@ export class CoreSitesProvider {
|
|||
return siteId;
|
||||
});
|
||||
} else if (result == this.LEGACY_APP_VERSION) {
|
||||
return Promise.reject(this.translate.instant('core.login.legacymoodleversion'));
|
||||
return Promise.reject({
|
||||
error: this.translate.instant('core.login.legacymoodleversion'),
|
||||
errorcode: 'legacymoodleversion'
|
||||
});
|
||||
} else {
|
||||
return Promise.reject(this.translate.instant('core.login.invalidmoodleversion'));
|
||||
return Promise.reject({
|
||||
error: this.translate.instant('core.login.invalidmoodleversion'),
|
||||
errorcode: 'invalidmoodleversion'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue