MOBILE-4074 configs: Add default zoom level
parent
a8220cb894
commit
a7f2016f9f
|
@ -76,9 +76,10 @@
|
|||
"password": "moodle"
|
||||
}
|
||||
},
|
||||
"defaultZoomLevel": "none",
|
||||
"zoomlevels": {
|
||||
"normal": 100,
|
||||
"low": 110,
|
||||
"none": 100,
|
||||
"medium": 110,
|
||||
"high": 120
|
||||
},
|
||||
"customurlscheme": "moodlemobile",
|
||||
|
|
|
@ -41,7 +41,7 @@ export class CoreSettingsGeneralPage {
|
|||
languages: { code: string; name: string }[] = [];
|
||||
selectedLanguage = '';
|
||||
zoomLevels: { value: CoreZoomLevel; style: number; selected: boolean }[] = [];
|
||||
selectedZoomLevel = CoreZoomLevel.NORMAL;
|
||||
selectedZoomLevel = CoreZoomLevel.NONE;
|
||||
richTextEditor = true;
|
||||
debugDisplay = false;
|
||||
analyticsSupported = false;
|
||||
|
|
|
@ -50,8 +50,8 @@ export const enum CoreColorScheme {
|
|||
* Constants to define zoom levels.
|
||||
*/
|
||||
export const enum CoreZoomLevel {
|
||||
NORMAL = 'normal',
|
||||
LOW = 'low',
|
||||
NONE = 'none',
|
||||
MEDIUM = 'medium',
|
||||
HIGH = 'high',
|
||||
}
|
||||
|
||||
|
@ -303,13 +303,13 @@ export class CoreSettingsHelperProvider {
|
|||
}
|
||||
|
||||
// Reset the value to solve edge cases.
|
||||
CoreConfig.set(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.NORMAL);
|
||||
CoreConfig.set(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.NONE);
|
||||
|
||||
if (fontSize < 100) {
|
||||
if (fontSize > 90) {
|
||||
CoreConfig.set(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.HIGH);
|
||||
} else if (fontSize > 70) {
|
||||
CoreConfig.set(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.LOW);
|
||||
CoreConfig.set(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.MEDIUM);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ export class CoreSettingsHelperProvider {
|
|||
* @return The saved zoom Level option.
|
||||
*/
|
||||
async getZoomLevel(): Promise<CoreZoomLevel> {
|
||||
return CoreConfig.get(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.NORMAL);
|
||||
return CoreConfig.get(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreConstants.CONFIG.defaultZoomLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@ import { CoreLoginHelper } from '@features/login/services/login-helper';
|
|||
import { CoreSites } from './sites';
|
||||
import { CoreUtils, PromiseDefer } from './utils/utils';
|
||||
import { CoreApp } from './app';
|
||||
import { CoreZoomLevel } from '@features/settings/services/settings-helper';
|
||||
|
||||
const VERSION_APPLIED = 'version_applied';
|
||||
|
||||
|
@ -71,6 +72,10 @@ export class CoreUpdateManagerProvider {
|
|||
promises.push(CoreH5P.h5pPlayer.deleteAllContentIndexes());
|
||||
}
|
||||
|
||||
if (versionCode >= 41000 && versionApplied < 41000 && versionApplied > 0) {
|
||||
promises.push(this.upgradeFontSizeNames());
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
|
||||
|
@ -121,6 +126,19 @@ export class CoreUpdateManagerProvider {
|
|||
});
|
||||
}
|
||||
|
||||
protected async upgradeFontSizeNames(): Promise<void> {
|
||||
const storedFontSizeName = await CoreConfig.get(CoreConstants.SETTINGS_ZOOM_LEVEL);
|
||||
switch (storedFontSizeName) {
|
||||
case 'low':
|
||||
await CoreConfig.set(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.NONE);
|
||||
break;
|
||||
|
||||
case 'normal':
|
||||
await CoreConfig.set(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.MEDIUM);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const CoreUpdateManager = makeSingleton(CoreUpdateManagerProvider);
|
||||
|
|
|
@ -1792,12 +1792,12 @@ export class CoreDomUtilsProvider {
|
|||
|
||||
const { waitForDismissCompleted, ...popoverOptions } = options;
|
||||
const popover = await PopoverController.create(popoverOptions);
|
||||
const zoomLevel = await CoreConfig.get(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreZoomLevel.NORMAL);
|
||||
const zoomLevel = await CoreConfig.get(CoreConstants.SETTINGS_ZOOM_LEVEL, CoreConstants.CONFIG.defaultZoomLevel);
|
||||
|
||||
await popover.present();
|
||||
|
||||
// Fix popover position if zoom is applied.
|
||||
if (zoomLevel !== CoreZoomLevel.NORMAL) {
|
||||
if (zoomLevel !== CoreZoomLevel.NONE) {
|
||||
switch (getMode()) {
|
||||
case 'ios':
|
||||
fixIOSPopoverPosition(popover, options.event);
|
||||
|
|
|
@ -39,6 +39,7 @@ export interface EnvironmentConfig {
|
|||
wsservice: string;
|
||||
demo_sites: Record<string, CoreSitesDemoSiteData>;
|
||||
zoomlevels: Record<CoreZoomLevel, number>;
|
||||
defaultZoomLevel?: CoreZoomLevel; // Set the default zoom level of the app.
|
||||
customurlscheme: string;
|
||||
siteurl: string;
|
||||
sitename: string;
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
This files describes API changes in the Moodle Mobile app,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 4.0.1 ===
|
||||
|
||||
- Zoom levels changed from "normal / low / high" to " none / medium / high".
|
||||
|
||||
=== 4.0.0 ===
|
||||
|
||||
- The versioncode in moodle.config.json has changed from 4 digits to 5 digits to match the actual value for the stores: the 4.0.0 version's versioncode is now 40000 instead of 4000. If you maintain a Moodle plugin with mobile support and you use the versioncode that is sent in every request, you might need to check if this change will affect your code.
|
||||
|
|
Loading…
Reference in New Issue