Skip to content

Commit

Permalink
Merge pull request #47105 from m4gr3d/fix_permissions_result_callback…
Browse files Browse the repository at this point in the history
…_3_x

[3.x] Fix onMainRequestPermissionsResult callback for Android plugins.
  • Loading branch information
akien-mga authored Mar 17, 2021
2 parents 3ed72c3 + 14e7f6f commit 7f2107e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.os.Bundle;
import android.view.KeyEvent;

import androidx.annotation.CallSuper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
Expand Down Expand Up @@ -70,6 +71,26 @@ public void onNewIntent(Intent intent) {
}
}

@CallSuper
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (godotFragment != null) {
godotFragment.onActivityResult(requestCode, resultCode, data);
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}

@CallSuper
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (godotFragment != null) {
godotFragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
} else {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}

@Override
public void onBackPressed() {
if (godotFragment != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,10 @@ public void onDetach() {
godotHost = null;
}

@CallSuper
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (result_callback != null) {
result_callback.callback(requestCode, resultCode, data);
result_callback = null;
Expand All @@ -303,8 +305,10 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}

@CallSuper
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
for (int i = 0; i < singleton_count; i++) {
singletons[i].onMainRequestPermissionsResult(requestCode, permissions, grantResults);
}
Expand Down

0 comments on commit 7f2107e

Please sign in to comment.