Merge pull request #2022 from marxjohnson/MOBILE-3100_integration
MOBILE-3100 accessibility: Add font size options in general settingsmain
commit
011c74f9be
|
@ -1787,6 +1787,8 @@
|
||||||
"core.settings.errorsyncsite": "Error synchronising site data. Please check your Internet connection and try again.",
|
"core.settings.errorsyncsite": "Error synchronising site data. Please check your Internet connection and try again.",
|
||||||
"core.settings.estimatedfreespace": "Estimated free space",
|
"core.settings.estimatedfreespace": "Estimated free space",
|
||||||
"core.settings.filesystemroot": "File system root",
|
"core.settings.filesystemroot": "File system root",
|
||||||
|
"core.settings.fontsize": "Text size",
|
||||||
|
"core.settings.fontsizecharacter": "A",
|
||||||
"core.settings.general": "General",
|
"core.settings.general": "General",
|
||||||
"core.settings.language": "Language",
|
"core.settings.language": "Language",
|
||||||
"core.settings.license": "Licence",
|
"core.settings.license": "Licence",
|
||||||
|
|
|
@ -68,6 +68,11 @@
|
||||||
"password": "moodle"
|
"password": "moodle"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"font_sizes": [
|
||||||
|
62.5,
|
||||||
|
75.89,
|
||||||
|
93.75
|
||||||
|
],
|
||||||
"customurlscheme": "moodlemobile",
|
"customurlscheme": "moodlemobile",
|
||||||
"siteurl": "",
|
"siteurl": "",
|
||||||
"sitename": "",
|
"sitename": "",
|
||||||
|
|
|
@ -35,6 +35,7 @@ export class CoreConstants {
|
||||||
static SETTINGS_DEBUG_DISPLAY = 'CoreSettingsDebugDisplay';
|
static SETTINGS_DEBUG_DISPLAY = 'CoreSettingsDebugDisplay';
|
||||||
static SETTINGS_REPORT_IN_BACKGROUND = 'CoreSettingsReportInBackground'; // @deprecated since 3.5.0
|
static SETTINGS_REPORT_IN_BACKGROUND = 'CoreSettingsReportInBackground'; // @deprecated since 3.5.0
|
||||||
static SETTINGS_SEND_ON_ENTER = 'CoreSettingsSendOnEnter';
|
static SETTINGS_SEND_ON_ENTER = 'CoreSettingsSendOnEnter';
|
||||||
|
static SETTINGS_FONT_SIZE = 'CoreSettingsFontSize';
|
||||||
|
|
||||||
// WS constants.
|
// WS constants.
|
||||||
static WS_TIMEOUT = 30000;
|
static WS_TIMEOUT = 30000;
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
"errorsyncsite": "Error synchronising site data. Please check your Internet connection and try again.",
|
"errorsyncsite": "Error synchronising site data. Please check your Internet connection and try again.",
|
||||||
"estimatedfreespace": "Estimated free space",
|
"estimatedfreespace": "Estimated free space",
|
||||||
"filesystemroot": "File system root",
|
"filesystemroot": "File system root",
|
||||||
|
"fontsize": "Text size",
|
||||||
|
"fontsizecharacter": "A",
|
||||||
"general": "General",
|
"general": "General",
|
||||||
"language": "Language",
|
"language": "Language",
|
||||||
"license": "Licence",
|
"license": "Licence",
|
||||||
|
@ -54,4 +56,4 @@
|
||||||
"versioncode": "Version code",
|
"versioncode": "Version code",
|
||||||
"versionname": "Version name",
|
"versionname": "Version name",
|
||||||
"wificonnection": "Wi-Fi connection"
|
"wificonnection": "Wi-Fi connection"
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,16 @@
|
||||||
<ion-option *ngFor="let entry of languages" [value]="entry.code">{{ entry.name }}</ion-option>
|
<ion-option *ngFor="let entry of languages" [value]="entry.code">{{ entry.name }}</ion-option>
|
||||||
</ion-select>
|
</ion-select>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
<ion-item text-wrap class="core-settings-general-font-size">
|
||||||
|
<ion-label><h2>{{ 'core.settings.fontsize' | translate }}</h2></ion-label>
|
||||||
|
<ion-segment [(ngModel)]="selectedFontSize" (ngModelChange)="fontSizeChanged()" color="primary" item-content>
|
||||||
|
<ion-segment-button *ngFor="let fontSize of fontSizes" value="{{ fontSize.size }}" [ngStyle]="{'font-size.px': fontSize.style}">
|
||||||
|
{{ 'core.settings.fontsizecharacter' | translate }}<!--
|
||||||
|
Empty element styled with the largest font size, so all buttons share a common baseline.
|
||||||
|
--><span [ngStyle]="{'font-size.px': fontSizes[fontSizes.length - 1].style}"></span>
|
||||||
|
</ion-segment-button>
|
||||||
|
</ion-segment>
|
||||||
|
</ion-item>
|
||||||
<ion-item text-wrap *ngIf="rteSupported">
|
<ion-item text-wrap *ngIf="rteSupported">
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<h2>{{ 'core.settings.enablerichtexteditor' | translate }}</h2>
|
<h2>{{ 'core.settings.enablerichtexteditor' | translate }}</h2>
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Component, } from '@angular/core';
|
import { Component, ViewChild } from '@angular/core';
|
||||||
import { IonicPage } from 'ionic-angular';
|
import { IonicPage, Segment } from 'ionic-angular';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreConstants } from '@core/constants';
|
import { CoreConstants } from '@core/constants';
|
||||||
import { CoreConfigProvider } from '@providers/config';
|
import { CoreConfigProvider } from '@providers/config';
|
||||||
|
@ -36,6 +36,8 @@ export class CoreSettingsGeneralPage {
|
||||||
|
|
||||||
languages = [];
|
languages = [];
|
||||||
selectedLanguage: string;
|
selectedLanguage: string;
|
||||||
|
fontSizes = [];
|
||||||
|
selectedFontSize: string;
|
||||||
rteSupported: boolean;
|
rteSupported: boolean;
|
||||||
richTextEditor: boolean;
|
richTextEditor: boolean;
|
||||||
debugDisplay: boolean;
|
debugDisplay: boolean;
|
||||||
|
@ -63,6 +65,24 @@ export class CoreSettingsGeneralPage {
|
||||||
this.selectedLanguage = currentLanguage;
|
this.selectedLanguage = currentLanguage;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.configProvider.get(CoreConstants.SETTINGS_FONT_SIZE, CoreConfigConstants.font_sizes[0]).then((fontSize) => {
|
||||||
|
this.selectedFontSize = fontSize;
|
||||||
|
this.fontSizes = CoreConfigConstants.font_sizes.map((size) => {
|
||||||
|
return {
|
||||||
|
size: size,
|
||||||
|
// Absolute pixel size based on 1.4rem body text when this size is selected.
|
||||||
|
style: Math.round(size * 16 * 1.4 / 100),
|
||||||
|
selected: size === this.selectedFontSize
|
||||||
|
};
|
||||||
|
});
|
||||||
|
// Workaround for segment control bug https://github.com/ionic-team/ionic/issues/6923, fixed in Ionic 4 only.
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this.segment) {
|
||||||
|
this.segment.ngAfterContentInit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.rteSupported = this.domUtils.isRichTextEditorSupported();
|
this.rteSupported = this.domUtils.isRichTextEditorSupported();
|
||||||
if (this.rteSupported) {
|
if (this.rteSupported) {
|
||||||
this.configProvider.get(CoreConstants.SETTINGS_RICH_TEXT_EDITOR, true).then((richTextEditorEnabled) => {
|
this.configProvider.get(CoreConstants.SETTINGS_RICH_TEXT_EDITOR, true).then((richTextEditorEnabled) => {
|
||||||
|
@ -75,6 +95,9 @@ export class CoreSettingsGeneralPage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewChild(Segment)
|
||||||
|
private segment: Segment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a new language is selected.
|
* Called when a new language is selected.
|
||||||
*/
|
*/
|
||||||
|
@ -84,6 +107,19 @@ export class CoreSettingsGeneralPage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a new font size is selected.
|
||||||
|
*/
|
||||||
|
fontSizeChanged(): void {
|
||||||
|
this.fontSizes = this.fontSizes.map((fontSize) => {
|
||||||
|
fontSize.selected = fontSize.size === this.selectedFontSize;
|
||||||
|
|
||||||
|
return fontSize;
|
||||||
|
});
|
||||||
|
document.documentElement.style.fontSize = this.selectedFontSize + '%';
|
||||||
|
this.configProvider.set(CoreConstants.SETTINGS_FONT_SIZE, this.selectedFontSize);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the rich text editor is enabled or disabled.
|
* Called when the rich text editor is enabled or disabled.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreTextUtilsProvider } from './text';
|
import { CoreTextUtilsProvider } from './text';
|
||||||
import { CoreAppProvider } from '../app';
|
import { CoreAppProvider } from '../app';
|
||||||
import { CoreConfigProvider } from '../config';
|
import { CoreConfigProvider } from '../config';
|
||||||
|
import { CoreConfigConstants } from '../../configconstants';
|
||||||
import { CoreUrlUtilsProvider } from './url';
|
import { CoreUrlUtilsProvider } from './url';
|
||||||
import { CoreFileProvider } from '@providers/file';
|
import { CoreFileProvider } from '@providers/file';
|
||||||
import { CoreConstants } from '@core/constants';
|
import { CoreConstants } from '@core/constants';
|
||||||
|
@ -74,6 +75,10 @@ export class CoreDomUtilsProvider {
|
||||||
configProvider.get(CoreConstants.SETTINGS_DEBUG_DISPLAY, false).then((debugDisplay) => {
|
configProvider.get(CoreConstants.SETTINGS_DEBUG_DISPLAY, false).then((debugDisplay) => {
|
||||||
this.debugDisplay = !!debugDisplay;
|
this.debugDisplay = !!debugDisplay;
|
||||||
});
|
});
|
||||||
|
// Set the font size based on user preference.
|
||||||
|
configProvider.get(CoreConstants.SETTINGS_FONT_SIZE, CoreConfigConstants.font_sizes[0]).then((fontSize) => {
|
||||||
|
document.documentElement.style.fontSize = fontSize + '%';
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue