-
Notifications
You must be signed in to change notification settings - Fork 111
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
[container-gen] Custom Android permissions configuration for native components #606
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,16 +15,22 @@ | |
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
import android.os.Bundle; | ||
import android.support.annotation.NonNull; | ||
import android.support.v4.app.ActivityCompat; | ||
import android.view.KeyEvent; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
|
||
public class ElectrodeMiniAppActivity extends Activity implements ElectrodeReactActivityDelegate.BackKeyHandler { | ||
import com.facebook.react.modules.core.PermissionAwareActivity; | ||
import com.facebook.react.modules.core.PermissionListener; | ||
|
||
public class ElectrodeMiniAppActivity extends Activity implements ElectrodeReactActivityDelegate.BackKeyHandler, PermissionAwareActivity { | ||
|
||
private static final String INITIAL_PROPS = "props"; | ||
private ElectrodeReactActivityDelegate mReactActivityDelegate; | ||
private PermissionListener mPermissionListener; | ||
|
||
/** | ||
* Method that helps to pass bundle to react native side. | ||
|
@@ -111,4 +117,25 @@ public boolean onKeyUp(int keyCode, KeyEvent event) { | |
public void onBackKey() { | ||
finish(); | ||
} | ||
|
||
@Override | ||
public int checkPermission(String permission, int pid, int uid) { | ||
return PackageManager.PERMISSION_GRANTED; | ||
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. This method is supposed to return |
||
} | ||
|
||
@Override | ||
public int checkSelfPermission(String permission) { | ||
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. Should be okay to remove this method as it's returning default int value (there is no logic involved) |
||
return PackageManager.PERMISSION_GRANTED; | ||
} | ||
|
||
@Override | ||
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. please add @RequiresApi(api = Build.VERSION_CODES.M) to avoid lint warning |
||
public void requestPermissions(String[] permissions, int requestCode, PermissionListener listener) { | ||
mPermissionListener = listener; | ||
ActivityCompat.requestPermissions(this, permissions, requestCode); | ||
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. Please call mReactActivityDelegate. requestPermissions() as the delegate now extends the ReactActivityDelegate. |
||
} | ||
|
||
@Override | ||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | ||
mPermissionListener.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
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. Please call mReactActivityDelegate. onRequestPermissionsResult() as the delegate now extends the ReactActivityDelegate. |
||
} | ||
} |
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.
Should be okay to remove this method as it's returning default int value (there is no logic involved)