Skip to content
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
27 changes: 3 additions & 24 deletions lib/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ def safeExtGetFallbackLowerBound(prop, fallback) {
Math.max(safeExtGet(prop,fallback),fallback)
}

def DEFAULT_COMPILE_SDK_VERSION = 33
def DEFAULT_COMPILE_SDK_VERSION = 30
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 33
def DEFAULT_TARGET_SDK_VERSION = 30
def DEFAULT_KOTLIN_VERSION = "1.5.31"
def DEFAULT_KOTLIN_STDLIB = 'kotlin-stdlib-jdk8'
def kotlinVersion = safeExtGet("RNNKotlinVersion", DEFAULT_KOTLIN_VERSION)
def kotlinStdlib = safeExtGet('RNNKotlinStdlib',DEFAULT_KOTLIN_STDLIB )
def kotlinCoroutinesCore = safeExtGet('RNNKotlinCoroutinesCore', '1.5.2')
android {
compileSdkVersion safeExtGetFallbackLowerBound('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion = "33.0.0"

defaultConfig {
minSdkVersion safeExtGetFallbackLowerBound('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGetFallbackLowerBound('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
Expand Down Expand Up @@ -167,27 +167,6 @@ List reactNativeVersionComponents(rnPackageJsonFile) {
return reactNativeVersion.tokenize('-')[0].tokenize('.')
}

task installBuildToolsAndRenameD8IfNeeded {
def buildToolsVersion = android.getBuildToolsVersion()
def sdkDir = android.sdkDirectory
def buildToolsDir = new File(sdkDir, "/build-tools/" + buildToolsVersion)

if (!buildToolsDir.exists()) {
def command = sdkDir.absolutePath + "/cmdline-tools/latest/bin/sdkmanager build-tools;" + buildToolsVersion
command.execute().waitForProcessOutput(System.out, System.err)
}

def d8File = new File(buildToolsDir, "d8")
def dxFile = new File(buildToolsDir, "dx")
d8File.renameTo(dxFile)

def buildToolsLibDir = new File(buildToolsDir, "lib")
d8File = new File(buildToolsLibDir, "d8.jar")
dxFile = new File(buildToolsLibDir, "dx.jar")
d8File.renameTo(dxFile)
}
build.dependsOn installBuildToolsAndRenameD8IfNeeded

dependencies {

implementation "androidx.core:core-ktx:1.6.0"
Expand Down
6 changes: 2 additions & 4 deletions lib/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.reactnativenavigation">
package="com.reactnativenavigation">

<application
android:enableOnBackInvokedCallback="true">
<application>
<activity
android:name="com.facebook.react.devsupport.DevSettingsActivity"
android:exported="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.reactnativenavigation.viewcontrollers.modal.ModalStack;
import com.reactnativenavigation.viewcontrollers.navigator.Navigator;

import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -48,7 +47,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
);
navigator.bindViews();
getReactGateway().onActivityCreated(this);
setBackPressedCallback();
}

@Override
Expand Down Expand Up @@ -105,6 +103,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
getReactGateway().onActivityResult(this, requestCode, resultCode, data);
}

@Override
public void onBackPressed() {
getReactGateway().onBackPressed();
}

@Override
public boolean onKeyUp(final int keyCode, final KeyEvent event) {
return getReactGateway().onKeyUp(this, keyCode) || super.onKeyUp(keyCode, event);
Expand Down Expand Up @@ -149,14 +152,4 @@ protected void addDefaultSplashLayout() {
public void onCatalystInstanceDestroy() {
runOnUiThread(() -> navigator.destroyViews());
}

private void setBackPressedCallback() {
OnBackPressedCallback callback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
getReactGateway().onBackPressed();
}
};
getOnBackPressedDispatcher().addCallback(this, callback);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ open class ButtonPresenter(private val context: Context, private val button: But
private fun applyAccessibilityLabel(menuItem: MenuItem) {
if (button.accessibilityLabel.hasValue()) {
if (button.component.hasValue()) {
menuItem.actionView?.contentDescription = button.accessibilityLabel.get()
menuItem.actionView.contentDescription = button.accessibilityLabel.get()
} else {
MenuItemCompat.setContentDescription(menuItem, button.accessibilityLabel.get())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ open class BaseViewAnimator<T : View>(
private inner class AnimatorListener(private val startState: AnimationState, private val endVisibility: Int) : AnimatorListenerAdapter() {
var isCancelled = false

override fun onAnimationStart(animation: Animator) {
override fun onAnimationStart(animation: Animator?) {
view.resetViewProperties()
view.visibility = View.VISIBLE
animationState = startState
}

override fun onAnimationCancel(animation: Animator) {
override fun onAnimationCancel(animation: Animator?) {
isCancelled = true
}

override fun onAnimationEnd(animation: Animator) {
override fun onAnimationEnd(animation: Animator?) {
if (!isCancelled) {
animationState = AnimationState.Idle
view.visibility = endVisibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,17 @@ class IconBackgroundDrawable(
super.setBounds(r)
}

override fun onBoundsChange(bounds: Rect) {
backgroundRect = Rect((bounds.width() - backgroundWidth) / 2,
(bounds.height() - backgroundHeight) / 2,
bounds.width() - (bounds.width() - backgroundWidth) / 2,
bounds.height() - (bounds.height() - backgroundHeight) / 2)
bitmapRect = Rect((bounds.width() - bitmapWidth) / 2,
(bounds.height() - bitmapHeight) / 2,
bounds.width() - (bounds.width() - bitmapWidth) / 2,
bounds.height() - (bounds.height() - bitmapHeight) / 2)
override fun onBoundsChange(bounds: Rect?) {
if (bounds != null) {
backgroundRect = Rect((bounds.width() - backgroundWidth) / 2,
(bounds.height() - backgroundHeight) / 2,
bounds.width() - (bounds.width() - backgroundWidth) / 2,
bounds.height() - (bounds.height() - backgroundHeight) / 2)
bitmapRect = Rect((bounds.width() - bitmapWidth) / 2,
(bounds.height() - bitmapHeight) / 2,
bounds.width() - (bounds.width() - bitmapWidth) / 2,
bounds.height() - (bounds.height() - bitmapHeight) / 2)
}
super.onBoundsChange(bounds)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ public ReactGateway getReactGateway() {
public void setNavigator(Navigator navigator) {
this.navigator = navigator;
}

@Override
public void onBackPressed() {
super.onBackPressed();
}
}
4 changes: 2 additions & 2 deletions playground/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
kotlinVersion = "1.5.31"
RNNKotlinVersion = kotlinVersion
detoxKotlinVersion = kotlinVersion
compileSdkVersion = 33
buildToolsVersion = "31.0.0"
compileSdkVersion = 31
buildToolsVersion = "30.0.2"
minSdkVersion = 21
targetSdkVersion = 31
}
Expand Down