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

Update target and compile Android sdk versions to v29 #25488

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/react-native-aztec/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ List<String> dirs = [
'template'] // boilerplate code that is generated by the sample template process

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 29
}

compileOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.text.LineBreaker;
import android.os.Build;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.graphics.ColorUtils;
import androidx.core.util.Consumer;

Expand Down Expand Up @@ -369,13 +371,26 @@ private static int parseNumericFontWeight(String fontWeightString) {
@ReactProp(name = ViewProps.TEXT_ALIGN)
public void setTextAlign(ReactAztecText view, @Nullable String textAlign) {
if ("justify".equals(textAlign)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
view.setJustificationMode(Layout.JUSTIFICATION_MODE_INTER_WORD);
/*
JUSTIFICATION_MODE_XYZ constants were moved from Layout to LineBreaker in
SDK 29. The values of the constants haven't changed, but Lint is complaining that we
can't use constants which were introduced in SDK 29 on older version. Separating
the calls into two methods per SDK version annotated with RequiresApi was the
only way how to make lint happy.
*/
// Value is hardcoded because Lint is failing with a false positive "Unnecessary; SDK_INT is never < 21"
if (Build.VERSION.SDK_INT >= 29) {
setJustificationModeSdk29(view, LineBreaker.JUSTIFICATION_MODE_INTER_WORD);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
setJustificationModeSDK26(view, Layout.JUSTIFICATION_MODE_INTER_WORD);
}
view.setGravity(Gravity.START);
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
view.setJustificationMode(Layout.JUSTIFICATION_MODE_NONE);
// Value is hardcoded because Lint is failing with a false positive "Unnecessary; SDK_INT is never < 21"
if (Build.VERSION.SDK_INT >= 29) {
setJustificationModeSdk29(view, LineBreaker.JUSTIFICATION_MODE_NONE);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
setJustificationModeSDK26(view, Layout.JUSTIFICATION_MODE_NONE);
}

if (textAlign == null || "auto".equals(textAlign)) {
Expand All @@ -392,6 +407,17 @@ public void setTextAlign(ReactAztecText view, @Nullable String textAlign) {
}
}

@RequiresApi(api = Build.VERSION_CODES.O)
private void setJustificationModeSDK26(ReactAztecText view, int justificationModeInterWord) {
view.setJustificationMode(justificationModeInterWord);
}

// Value is hardcoded because Lint is failing with a false positive "Unnecessary; SDK_INT is never < 21"
@RequiresApi(api = 29)
private void setJustificationModeSdk29(ReactAztecText view, int justificationModeInterWord) {
view.setJustificationMode(justificationModeInterWord);
}

private void setLinkTextColor(ReactAztecText view, @Nullable Integer color) {
if (color != null && view.linkFormatter.getLinkStyle().getLinkColor() != color) {
view.setLinkFormatter(new LinkFormatter(view,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-bridge/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ def hermesPath = hermesOriginalPath;
def buildAssetsFolder = 'build/assets'

android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native-editor/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ buildscript {
ext {
gradlePluginVersion = '3.4.2'
kotlinVersion = '1.3.61'
buildToolsVersion = "28.0.3"
buildToolsVersion = "29.0.2"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
compileSdkVersion = 29
targetSdkVersion = 29
supportLibVersion = '28.0.0'
wordpressUtilsVersion = '1.22'
}
Expand Down