-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Android support topbar title font scaling #7904
Open
mika-lindell
wants to merge
13
commits into
wix:master
Choose a base branch
from
mika-lindell:android-support-topbar-title-font-scaling
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1d75ac2
Add button to push view with font scaling title
mika-lindell b0fea38
Add test for allowFontScaling
mika-lindell f8687a3
Add allowFontScaling-option for topbar title
mika-lindell b277359
Add allowFontScaling
mika-lindell 8257460
Move allowFontScaling tests with similar tests
mika-lindell 12ad730
Update tests for allowFontScaling
mika-lindell d26e968
Revert unintended changes
mika-lindell 4e43acf
Fix typo
mika-lindell d05c0b8
Refactor for better support to changing allowFontScaling via title op…
mika-lindell 6d25449
Revert TitleSubTitleLayoutTest.kt
mika-lindell 4c2ce13
Add new line in the end
mika-lindell 8a45324
Merge branch 'master' into android-support-topbar-title-font-scaling
mika-lindell f6d87f4
Merge remote-tracking branch 'upstream/master' into android-support-t…
mika-lindell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package com.reactnativenavigation.views | |
|
||
import android.app.Activity | ||
import android.graphics.Color | ||
import android.util.TypedValue | ||
import android.view.Gravity | ||
import android.view.View | ||
import android.view.ViewGroup | ||
|
@@ -23,12 +24,14 @@ import org.assertj.core.api.AssertionsForInterfaceTypes.assertThat | |
import org.junit.Test | ||
import org.mockito.Mockito | ||
import org.mockito.Mockito.times | ||
import org.robolectric.annotation.Config | ||
import kotlin.math.roundToInt | ||
import kotlin.test.assertFalse | ||
|
||
private const val UUT_WIDTH = 1000 | ||
private const val UUT_HEIGHT = 100 | ||
|
||
@Config(sdk = [30]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. textSizeUnit is not available before api level 30 |
||
class TitleAndButtonsContainerTest : BaseTest() { | ||
lateinit var uut: TitleAndButtonsContainer | ||
private lateinit var activity: Activity | ||
|
@@ -448,7 +451,25 @@ class TitleAndButtonsContainerTest : BaseTest() { | |
assertThat(getTitleSubtitleView().getSubTitleTxtView().currentTextColor).isEqualTo(Color.YELLOW) | ||
} | ||
|
||
@Test | ||
fun `setTitleAllowFontScaling - when using default value, should have font size units set to DIP`() { | ||
assertThat(getTitleSubtitleView().getTitleTxtView().textSizeUnit).isEqualTo(TypedValue.COMPLEX_UNIT_DIP) | ||
} | ||
|
||
@Test | ||
fun `setTitleAllowFontScaling - when set to true, should set font size units to SP`() { | ||
assertThat(getTitleSubtitleView().getTitleTxtView().textSizeUnit).isEqualTo(TypedValue.COMPLEX_UNIT_DIP) | ||
uut.setTitleAllowFontScaling(true) | ||
assertThat(getTitleSubtitleView().getTitleTxtView().textSizeUnit).isEqualTo(TypedValue.COMPLEX_UNIT_SP) | ||
} | ||
|
||
@Test | ||
fun `setTitleAllowFontScaling - when set to false, should set font size units to DIP`() { | ||
uut.setTitleAllowFontScaling(true) | ||
assertThat(getTitleSubtitleView().getTitleTxtView().textSizeUnit).isEqualTo(TypedValue.COMPLEX_UNIT_SP) | ||
uut.setTitleAllowFontScaling(false) | ||
assertThat(getTitleSubtitleView().getTitleTxtView().textSizeUnit).isEqualTo(TypedValue.COMPLEX_UNIT_DIP) | ||
} | ||
|
||
@Test | ||
fun getTitle_returnCurrentTextInTitleTextView() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For it to make sense from the perspective of options, I didn't find a way to set units without setting font size. Using titleTextView.textSize returns scaled font size, so need to have the absolute font size somewhere