Skip to content

Commit

Permalink
fix: Disable font scaling on android for now
Browse files Browse the repository at this point in the history
This is just a short term hack. Real a11y support will be layered in later.
  • Loading branch information
NigelBreslaw authored and gitbutler-client committed Jul 20, 2024
1 parent ab3de29 commit cbec094
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.guardianghost

import android.app.Application
import android.content.res.Configuration
import android.util.DisplayMetrics
import android.view.WindowManager

import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
Expand Down Expand Up @@ -41,13 +43,23 @@ class MainApplication : Application(), ReactApplication {
override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
adjustFontScale(resources.configuration)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
ApplicationLifecycleDispatcher.onApplicationCreate(this)
}

private fun adjustFontScale(configuration: Configuration) {
configuration.fontScale = 1.0f
val metrics: DisplayMetrics = resources.displayMetrics
val wm = getSystemService(WINDOW_SERVICE) as WindowManager
wm.defaultDisplay.getMetrics(metrics)
metrics.scaledDensity = configuration.fontScale * metrics.density
baseContext.resources.updateConfiguration(configuration, metrics)
}

override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
Expand Down

0 comments on commit cbec094

Please sign in to comment.