8

I'm having an issue with some android devices when changing the font-size display setting through configuration.

In web browser my app is simple ignoring this. This is true for some other mobiles too.

But with some specific mobiles (like Motorola G or X) changing this config also affects my Phonegap app.

I don't know how to avoid this to make the app look consistent

edrian
  • 4,501
  • 5
  • 31
  • 35
  • You are ignoring basic UX rules if you override the user's font size settings. – stark Nov 18 '14 at 21:40
  • Well thats true, but even in native android apps you have the choice to decide that using sp or dp font values. And also when running app on browser it is behaving like I want. Is when running inside Cordova App when I have the problem – edrian Nov 19 '14 at 11:30
  • I mean, the main problem is because soem phone manufacterers decide to take account of user display settings and others doesn't. So my app ends up with visual inconsistency across devices. @stark – edrian Nov 19 '14 at 12:03

2 Answers2

16

I've found a solution using this cordova plugin: com.phonegap.plugin.mobile-accessibility

You have to follow installation instructions for the plugin, and then you can use it inside Ionic app. You only have to ensure to call its functions after Cordova 'deviceready' callback (accesed by $ionicPlatform.ready in the example below):

angular.module('app').controller('IndexController', function ($ionicPlatform, $window) {

    $ionicPlatform.ready(function(){
        if($window.MobileAccessibility){
            $window.MobileAccessibility.usePreferredTextZoom(false);
        }
    });
});
edrian
  • 4,501
  • 5
  • 31
  • 35
4

For anyone using Ionic. Documentation is here.

Install

$ ionic cordova plugin add phonegap-plugin-mobile-accessibility
$ npm install --save @ionic-native/mobile-accessibility

Add to module, i.e. app.module.ts

import { MobileAccessibility } from 'ionic-native';


@NgModule({
    providers:[MobileAccessibility]
});

In app.component.ts

constructor( mobileAccessibility: MobileAccessibility, platform: Platform) {

    platform
      .ready()
      .then(()=>{
          mobileAccessibility.usePreferredTextZoom(false);
      });

}
Abdullah Rasheed
  • 3,562
  • 4
  • 33
  • 51