commit
41ebeb5b2c
|
@ -250,25 +250,30 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.selectedSection = newSection;
|
||||
this.data.section = this.selectedSection;
|
||||
|
||||
// Select next and previous sections to show the arrows.
|
||||
const i = this.sections.findIndex((value, index) => {
|
||||
return this.compareSections(value, this.selectedSection);
|
||||
});
|
||||
if (newSection.id != this.allSectionsId) {
|
||||
// Select next and previous sections to show the arrows.
|
||||
const i = this.sections.findIndex((value, index) => {
|
||||
return this.compareSections(value, this.selectedSection);
|
||||
});
|
||||
|
||||
let j;
|
||||
for (j = i - 1; j >= 1; j--) {
|
||||
if (this.sections[j].uservisible !== false && this.sections[j].hasContent) {
|
||||
break;
|
||||
let j;
|
||||
for (j = i - 1; j >= 1; j--) {
|
||||
if (this.sections[j].uservisible !== false && this.sections[j].hasContent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.previousSection = j >= 1 ? this.sections[j] : null;
|
||||
this.previousSection = j >= 1 ? this.sections[j] : null;
|
||||
|
||||
for (j = i + 1; j < this.sections.length; j++) {
|
||||
if (this.sections[j].uservisible !== false && this.sections[j].hasContent) {
|
||||
break;
|
||||
for (j = i + 1; j < this.sections.length; j++) {
|
||||
if (this.sections[j].uservisible !== false && this.sections[j].hasContent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.nextSection = j < this.sections.length ? this.sections[j] : null;
|
||||
} else {
|
||||
this.previousSection = null;
|
||||
this.nextSection = null;
|
||||
}
|
||||
this.nextSection = j < this.sections.length ? this.sections[j] : null;
|
||||
|
||||
if (this.moduleId && typeof previousValue == 'undefined') {
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -153,7 +153,7 @@ export class CoreCourseHelperProvider {
|
|||
}
|
||||
|
||||
// Check if the module is stealth.
|
||||
module.isStealth = !module.visibleoncoursepage || (module.visible && !section.visible);
|
||||
module.isStealth = module.visibleoncoursepage === 0 || (module.visible && !section.visible);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -539,6 +539,10 @@ export class CoreCourseHelperProvider {
|
|||
return this.downloadModuleWithMainFileIfNeeded(module, courseId, component, componentId, files, siteId)
|
||||
.then((result) => {
|
||||
if (result.path.indexOf('http') === 0) {
|
||||
/* In iOS, if we use the same URL in embedded browser and background download then the download only
|
||||
downloads a few bytes (cached ones). Add a hash to the URL so both URLs are different. */
|
||||
result.path = result.path + '#moodlemobile-embedded';
|
||||
|
||||
return this.utils.openOnlineFile(result.path).catch((error) => {
|
||||
// Error opening the file, some apps don't allow opening online files.
|
||||
if (!this.fileProvider.isAvailable()) {
|
||||
|
|
|
@ -20,9 +20,5 @@
|
|||
<p>{{ 'core.settings.total' | translate }}</p>
|
||||
<p item-end>{{ totalUsage | coreBytesToSize }}</p>
|
||||
</ion-item-divider>
|
||||
<ion-item-divider color="light" *ngIf="showFreeSpace">
|
||||
<p>{{ 'core.settings.estimatedfreespace' | translate }}</p>
|
||||
<p item-end>{{ freeSpace | coreBytesToSize }}</p>
|
||||
</ion-item-divider>
|
||||
</core-loading>
|
||||
</ion-content>
|
||||
|
|
|
@ -16,7 +16,6 @@ import { Component, } from '@angular/core';
|
|||
import { IonicPage } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreAppProvider } from '@providers/app';
|
||||
import { CoreFileProvider } from '@providers/file';
|
||||
import { CoreFilepoolProvider } from '@providers/filepool';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
import { CoreTextUtilsProvider } from '@providers/utils/text';
|
||||
|
@ -36,14 +35,11 @@ export class CoreSettingsSpaceUsagePage {
|
|||
sites = [];
|
||||
currentSiteId = '';
|
||||
totalUsage = 0;
|
||||
freeSpace = 0;
|
||||
showFreeSpace = true;
|
||||
|
||||
constructor(private fileProvider: CoreFileProvider, private filePoolProvider: CoreFilepoolProvider,
|
||||
constructor(private filePoolProvider: CoreFilepoolProvider,
|
||||
private sitesProvider: CoreSitesProvider, private textUtils: CoreTextUtilsProvider,
|
||||
private translate: TranslateService, private domUtils: CoreDomUtilsProvider, appProvider: CoreAppProvider) {
|
||||
this.currentSiteId = this.sitesProvider.getCurrentSiteId();
|
||||
this.showFreeSpace = !appProvider.isDesktop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,26 +87,7 @@ export class CoreSettingsSpaceUsagePage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Convenience function to calculate free space in the device.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
*/
|
||||
protected calculateFreeSpace(): Promise<any> {
|
||||
if (this.fileProvider.isAvailable()) {
|
||||
return this.fileProvider.calculateFreeSpace().then((freeSpace) => {
|
||||
this.freeSpace = freeSpace;
|
||||
}).catch(() => {
|
||||
this.freeSpace = 0;
|
||||
});
|
||||
} else {
|
||||
this.freeSpace = 0;
|
||||
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience function to calculate space usage and free space in the device.
|
||||
* Convenience function to calculate space usage.
|
||||
*
|
||||
* @return {Promise<any>} Resolved when done.
|
||||
*/
|
||||
|
@ -119,10 +96,6 @@ export class CoreSettingsSpaceUsagePage {
|
|||
this.calculateSizeUsage().then(() => this.calculateTotalUsage()),
|
||||
];
|
||||
|
||||
if (this.showFreeSpace) {
|
||||
promises.push(this.calculateFreeSpace());
|
||||
}
|
||||
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
|
@ -138,7 +111,7 @@ export class CoreSettingsSpaceUsagePage {
|
|||
}
|
||||
|
||||
/**
|
||||
* Convenience function to update site size, along with total usage and free space.
|
||||
* Convenience function to update site size, along with total usage.
|
||||
*
|
||||
* @param {any} site Site object with space usage.
|
||||
* @param {number} newUsage New space usage of the site in bytes.
|
||||
|
@ -147,7 +120,6 @@ export class CoreSettingsSpaceUsagePage {
|
|||
const oldUsage = site.spaceUsage;
|
||||
site.spaceUsage = newUsage;
|
||||
this.totalUsage -= oldUsage - newUsage;
|
||||
this.freeSpace += oldUsage - newUsage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<ion-item-divider color="light">
|
||||
<p>{{ 'core.settings.syncsettings' | translate }}</p>
|
||||
</ion-item-divider>
|
||||
<ion-item>
|
||||
<ion-item text-wrap>
|
||||
<ion-label>{{ 'core.settings.enablesyncwifi' | translate }}</ion-label>
|
||||
<ion-toggle item-end [(ngModel)]="syncOnlyOnWifi" (ngModelChange)="syncOnlyOnWifiChanged()">
|
||||
</ion-toggle>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<ion-item-divider color="light">
|
||||
<p>{{ 'core.settings.sites' | translate }}</p>
|
||||
</ion-item-divider>
|
||||
<ion-item *ngFor="let site of sites" [class.core-primary-item]="site.id == currentSiteId">
|
||||
<ion-item *ngFor="let site of sites" [class.core-primary-item]="site.id == currentSiteId" text-wrap>
|
||||
<h2><core-format-text [text]="site.siteName"></core-format-text></h2>
|
||||
<p>{{ site.fullName }}</p>
|
||||
<p>{{ site.siteUrl }}</p>
|
||||
|
|
|
@ -121,10 +121,10 @@ export class CoreSharedFilesListPage implements OnInit, OnDestroy {
|
|||
* Called when a file is renamed. Update the list.
|
||||
*
|
||||
* @param {number} index Position of the file.
|
||||
* @param {any} file New FileEntry.
|
||||
* @param {any} data Data containing the new FileEntry.
|
||||
*/
|
||||
fileRenamed(index: number, file: any): void {
|
||||
this.files[index] = file;
|
||||
fileRenamed(index: number, data: any): void {
|
||||
this.files[index] = data.file;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -146,7 +146,7 @@ export class CoreSiteHomeIndexComponent implements OnInit {
|
|||
|
||||
if (hasNewsItem && this.block && this.block.modules) {
|
||||
// Remove forum activity (news one only) to prevent duplicates.
|
||||
this.siteHomeProvider.getNewsForum(this.siteHomeId).then((forum) => {
|
||||
return this.siteHomeProvider.getNewsForum(this.siteHomeId).then((forum) => {
|
||||
// Search the module that belongs to site news.
|
||||
for (let i = 0; i < this.block.modules.length; i++) {
|
||||
const module = this.block.modules[i];
|
||||
|
|
|
@ -31,10 +31,7 @@
|
|||
</ion-item>
|
||||
<ion-item text-wrap *ngIf="user.address">
|
||||
<h2>{{ 'core.user.address' | translate}}</h2>
|
||||
<p><a *ngIf="isAndroid" href="geo:0,0?q={{user.encodedAddress}}" core-link auto-login="no">
|
||||
<core-format-text [text]="user.address"></core-format-text>
|
||||
</a>
|
||||
<a *ngIf="!isAndroid" href="http://maps.google.com?q={{user.encodedAddress}}" core-link auto-login="no">
|
||||
<p><a [href]="user.encodedAddress" core-link auto-login="no">
|
||||
<core-format-text [text]="user.address"></core-format-text>
|
||||
</a>
|
||||
</p>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { IonicPage, NavParams, Platform } from 'ionic-angular';
|
||||
import { CoreUserProvider } from '../../providers/user';
|
||||
import { CoreUserHelperProvider } from '../../providers/helper';
|
||||
|
@ -41,7 +42,7 @@ export class CoreUserAboutPage {
|
|||
title: string;
|
||||
|
||||
constructor(navParams: NavParams, private userProvider: CoreUserProvider, private userHelper: CoreUserHelperProvider,
|
||||
private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider,
|
||||
private domUtils: CoreDomUtilsProvider, private eventsProvider: CoreEventsProvider, private sanitizer: DomSanitizer,
|
||||
private sitesProvider: CoreSitesProvider, private platform: Platform) {
|
||||
|
||||
this.userId = navParams.get('userId');
|
||||
|
@ -68,7 +69,8 @@ export class CoreUserAboutPage {
|
|||
|
||||
if (user.address) {
|
||||
user.address = this.userHelper.formatAddress(user.address, user.city, user.country);
|
||||
user.encodedAddress = encodeURIComponent(user.address);
|
||||
user.encodedAddress = this.sanitizer.bypassSecurityTrustUrl(
|
||||
(this.isAndroid ? 'geo:0,0?q=' : 'http://maps.google.com?q=') + encodeURIComponent(user.address));
|
||||
}
|
||||
|
||||
this.hasContact = user.email || user.phone1 || user.phone2 || user.city || user.country || user.address;
|
||||
|
|
|
@ -56,6 +56,10 @@ export class CoreFileHelperProvider {
|
|||
}
|
||||
|
||||
if (url.indexOf('http') === 0) {
|
||||
/* In iOS, if we use the same URL in embedded browser and background download then the download only
|
||||
downloads a few bytes (cached ones). Add a hash to the URL so both URLs are different. */
|
||||
url = url + '#moodlemobile-embedded';
|
||||
|
||||
return this.utils.openOnlineFile(url).catch((error) => {
|
||||
// Error opening the file, some apps don't allow opening online files.
|
||||
if (!this.fileProvider.isAvailable()) {
|
||||
|
|
|
@ -360,12 +360,19 @@ export class CoreFileProvider {
|
|||
|
||||
/**
|
||||
* Calculate the free space in the disk.
|
||||
* Please notice that this function isn't reliable and it's not documented in the Cordova File plugin.
|
||||
*
|
||||
* @return {Promise<number>} Promise resolved with the estimated free space in bytes.
|
||||
*/
|
||||
calculateFreeSpace(): Promise<number> {
|
||||
return this.file.getFreeDiskSpace().then((size) => {
|
||||
return size; // GetFreeDiskSpace returns KB.
|
||||
if (this.platform.is('ios')) {
|
||||
// In iOS the size is in bytes.
|
||||
return Number(size);
|
||||
}
|
||||
|
||||
// The size is in KB, convert it to bytes.
|
||||
return Number(size) * 1024;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue