Merge pull request #1362 from dpalou/MOBILE-2431

Mobile 2431
main
Juan Leyva 2018-06-21 14:37:23 +02:00 committed by GitHub
commit 87bd44b3d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 32 additions and 8 deletions

View File

@ -104,7 +104,7 @@
</plugin>
<plugin name="cordova-plugin-device" spec="1.1.6" />
<plugin name="cordova-plugin-globalization" spec="1.0.7" />
<plugin name="cordova-plugin-inappbrowser" spec="1.7.1" />
<plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
<plugin name="cordova-plugin-network-information" spec="1.3.3" />
<plugin name="cordova-plugin-statusbar" spec="2.2.3" />
<plugin name="cordova-plugin-whitelist" spec="1.3.2" />

View File

@ -292,9 +292,9 @@ var templatesSrc = [
'./src/components/**/*.html',
'./src/core/**/components/**/*.html',
'./src/core/**/component/**/*.html',
// Only some addon components are injected to compile to decrease load time. Copy only the ones that are needed.
'./src/addon/mod/assign/components/**/*.html',
'./src/addon/mod/workshop/components/**/*.html'
// Copy all addon components because any component can be injected using extraImports.
'./src/addon/**/components/**/*.html',
'./src/addon/**/component/**/*.html'
],
templatesDest = './www/templates';

View File

@ -20,7 +20,7 @@ import { AddonModWorkshopAssessmentStrategyComponentBase } from '../../../classe
*/
@Component({
selector: 'addon-mod-workshop-assessment-strategy-accumulative',
templateUrl: 'accumulative.html',
templateUrl: 'addon-mod-workshop-assessment-strategy-accumulative.html',
})
export class AddonModWorkshopAssessmentStrategyAccumulativeComponent extends AddonModWorkshopAssessmentStrategyComponentBase {
}

View File

@ -20,7 +20,7 @@ import { AddonModWorkshopAssessmentStrategyComponentBase } from '../../../classe
*/
@Component({
selector: 'addon-mod-workshop-assessment-strategy-comments',
templateUrl: 'comments.html',
templateUrl: 'addon-mod-workshop-assessment-strategy-comments.html',
})
export class AddonModWorkshopAssessmentStrategyCommentsComponent extends AddonModWorkshopAssessmentStrategyComponentBase {
}

View File

@ -20,7 +20,7 @@ import { AddonModWorkshopAssessmentStrategyComponentBase } from '../../../classe
*/
@Component({
selector: 'addon-mod-workshop-assessment-strategy-numerrors',
templateUrl: 'numerrors.html',
templateUrl: 'addon-mod-workshop-assessment-strategy-numerrors.html',
})
export class AddonModWorkshopAssessmentStrategyNumErrorsComponent extends AddonModWorkshopAssessmentStrategyComponentBase {
}

View File

@ -20,7 +20,7 @@ import { AddonModWorkshopAssessmentStrategyComponentBase } from '../../../classe
*/
@Component({
selector: 'addon-mod-workshop-assessment-strategy-rubric',
templateUrl: 'rubric.html',
templateUrl: 'addon-mod-workshop-assessment-strategy-rubric.html',
})
export class AddonModWorkshopAssessmentStrategyRubricComponent extends AddonModWorkshopAssessmentStrategyComponentBase {
}

View File

@ -756,17 +756,41 @@ export class CoreUtilsProvider {
this.iabInstance = this.iab.create(url, '_blank', options);
if (this.appProvider.isDesktop() || this.appProvider.isMobile()) {
let loadStopSubscription;
const loadStartUrls = [];
// Trigger global events when a url is loaded or the window is closed. This is to make it work like in Ionic 1.
const loadStartSubscription = this.iabInstance.on('loadstart').subscribe((event) => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
this.zone.run(() => {
// Store the last loaded URLs (max 10).
loadStartUrls.push(event.url);
if (loadStartUrls.length > 10) {
loadStartUrls.shift();
}
this.eventsProvider.trigger(CoreEventsProvider.IAB_LOAD_START, event);
});
});
if (this.platform.is('android')) {
// Load stop is needed with InAppBrowser v3. Custom URL schemes no longer trigger load start, simulate it.
loadStopSubscription = this.iabInstance.on('loadstop').subscribe((event) => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
this.zone.run(() => {
if (loadStartUrls.indexOf(event.url) == -1) {
// The URL was stopped but not started, probably a custom URL scheme.
this.eventsProvider.trigger(CoreEventsProvider.IAB_LOAD_START, event);
}
});
});
}
const exitSubscription = this.iabInstance.on('exit').subscribe((event) => {
// Execute the callback in the Angular zone, so change detection doesn't stop working.
this.zone.run(() => {
loadStartSubscription.unsubscribe();
loadStopSubscription && loadStopSubscription.unsubscribe();
exitSubscription.unsubscribe();
this.eventsProvider.trigger(CoreEventsProvider.IAB_EXIT, event);
});