request camera permissions from webview #3003

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Roman Volosovskyi 2018-02-17 13:05:03 +08:00 committed by Julien Eluard
parent efb8c3cdf2
commit aa02547815
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
3 changed files with 1146 additions and 116 deletions

View File

@ -6,7 +6,9 @@ import android.app.ActivityManager;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnClickListener;
import android.content.pm.PackageManager;
import android.os.Looper;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.content.Intent;
import android.content.SharedPreferences;
@ -19,7 +21,10 @@ import com.testfairy.TestFairy;
import java.util.Properties;
public class MainActivity extends ReactActivity {
public class MainActivity extends ReactActivity
implements ActivityCompat.OnRequestPermissionsResultCallback{
private static final int PERMISSION_REQUEST_CAMERA = 0;
private static void registerUncaughtExceptionHandler(final Context context) {
final Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
@ -170,4 +175,12 @@ public class MainActivity extends ReactActivity {
editor.putBoolean(REJECTED_ROOTED_NOTIFICATION, true);
editor.commit();
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// Permission has been granted. Start camera preview Activity.
com.github.alinz.reactnativewebviewbridge.WebViewBridgeManager.grantAccess(requestCode);
}
}
}

1245
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,7 @@
"react-native-tcp": "3.3.0",
"react-native-udp": "2.2.1",
"react-native-vector-icons": "4.4.2",
"react-native-webview-bridge": "github:status-im/react-native-webview-bridge#react-native-0.49",
"react-native-webview-bridge": "github:status-im/react-native-webview-bridge#feature/camera-permissions",
"readable-stream": "1.1.14",
"realm": "2.0.7",
"stream-browserify": "1.0.0",