Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Migrate away from scaledDensity #5625

Closed
theMr17 opened this issue Dec 27, 2024 · 1 comment · Fixed by #5644
Closed

[Feature Request]: Migrate away from scaledDensity #5625

theMr17 opened this issue Dec 27, 2024 · 1 comment · Fixed by #5644
Assignees
Labels
enhancement End user-perceivable enhancements. good first issue This item is good for new contributors to make their pull request. Impact: Low Low perceived user impact (e.g. edge cases). Work: Low Solution is clear and broken into good-first-issue-sized chunks.

Comments

@theMr17
Copy link
Collaborator

theMr17 commented Dec 27, 2024

Is your feature request related to a problem? Please describe.

API 34 (introduced in #5604) deprecated scaledDensity: https://developer.android.com/reference/android/util/DisplayMetrics#scaledDensity.

Describe the solution you'd like

As described in the Android Developer documentation, the recommended solution here seems to be using the TypedValue.applyDimension() function. This ensures consistent handling of dimensions across different densities without relying on the deprecated property.

Describe alternatives you've considered

  • Continuing to use scaledDensity despite its deprecation, which would not be forward-compatible and could result in issues in future Android releases.
  • Writing custom logic to handle scaling, but this would require redundant calculations and could lead to inconsistencies compared to the standard Android implementation.

Additional context

No response

@theMr17 theMr17 added enhancement End user-perceivable enhancements. triage needed labels Dec 27, 2024
BenHenning added a commit that referenced this issue Dec 29, 2024
<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->
  
Fixes #5535

This PR updates all build and target SDKs for both Gradle and Bazel
builds to SDK 34 to comply with the latest Play Store requirements. The
key considerations for this upgrade include:

- **Font Scaling**: SDK 34 introduces support for font scaling up to
200% #5607.
- **`scaledDensity` Deprecation**: The scaledDensity property in the
DisplayMetrics class is now deprecated #5625.

Details about SDK 34 changes, potential issues, and mitigations can be
found in the #5535 issue thread.

## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

## For UI-specific PRs only
<!-- Delete these section if this PR does not include UI-related
changes. -->
If your PR includes UI-related changes, then:
- Add screenshots for portrait/landscape for both a tablet & phone of
the before & after UI changes
- For the screenshots above, include both English and pseudo-localized
(RTL) screenshots (see [RTL
guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines))
- Add a video showing the full UX flow with a screen reader enabled (see
[accessibility
guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide))
- For PRs introducing new UI elements or color changes, both light and
dark mode screenshots must be included
- Add a screenshot demonstrating that you ran affected Espresso tests
locally & that they're passing

---------

Co-authored-by: Ben Henning <[email protected]>
@theMr17 theMr17 added Impact: Low Low perceived user impact (e.g. edge cases). Work: Low Solution is clear and broken into good-first-issue-sized chunks. labels Jan 6, 2025
@adhiamboperes adhiamboperes added the good first issue This item is good for new contributors to make their pull request. label Jan 6, 2025
@whyash8
Copy link
Collaborator

whyash8 commented Jan 8, 2025

please assign me this issue @adhiamboperes

adhiamboperes added a commit that referenced this issue Jan 13, 2025
This PR updates the `FontScaleConfigurationUtil` class to remove the
usage of the deprecated `scaledDensity` property and replace it with
`TypedValue.applyDimension` for scaling font sizes. This change ensures
that the code adheres to modern Android API standards .

Fixes #5625: This issue was related to the usage of the deprecated
`scaledDensity` property

### Changes:
  **Removed deprecated `scaledDensity`:**
- Updated the `adjustFontScale` method to calculate the scaled density
using `TypedValue.applyDimension`.
- Applied the new scaled density without using the deprecated property.
## Essential Checklist
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [x] The PR title and explanation each start with "Fix #bugnum: " (If
this PR fixes part of an issue, prefix the title with "Fix part of
#bugnum: ...".)
- [ x] Any changes to
[scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets)
files have their rationale included in the PR explanation.
- [x ] The PR follows the [style
guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide).
- [ x] The PR does not contain any unnecessary code changes from Android
Studio
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)).
- [x ] The PR is made from a branch that's **not** called "develop" and
is up-to-date with "develop".
- [ x] The PR is **assigned** to the appropriate reviewers
([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)).

---------

Co-authored-by: Adhiambo Peres <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement End user-perceivable enhancements. good first issue This item is good for new contributors to make their pull request. Impact: Low Low perceived user impact (e.g. edge cases). Work: Low Solution is clear and broken into good-first-issue-sized chunks.
Development

Successfully merging a pull request may close this issue.

4 participants