mirror of
https://github.com/react/react-native.git
synced 2026-10-18 04:45:15 +08:00
Summary: This moves into open source the PermissionsModule and the activity and listener interfaces necessary to make permissions work. It also moves the PermissionsExample into the UIExplorer. In order to make this work, the device has to be Android M and above, and the target sdk of the app has to be 23+, so I changed the uiexplorer manifest to target that API. This has the unfortunate consequence that people testing on devices with API 23+ will have to enable the `draw over other apps` setting that react needs for RedBoxing. The app will automatically send the user to that screen, so enabling the setting and resuming the app should be trivial. For testing, try requesting permission for a permission that is currently revoked. If a permission is granted, it can be revoked via adb (`adb shell pm revoke com.your.app android.permission.PERMISSION_NAME`), and then requested. Reviewed By: bestander Differential Revision: D3431324 fbshipit-source-id: 8cbaea676d2b5727cb5191cdb77a02e213bf9ba3
131 lines
5.6 KiB
Java
131 lines
5.6 KiB
Java
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
package com.facebook.react.shell;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
import com.facebook.react.ReactPackage;
|
|
import com.facebook.react.bridge.JavaScriptModule;
|
|
import com.facebook.react.bridge.NativeModule;
|
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
import com.facebook.react.modules.appstate.AppStateModule;
|
|
import com.facebook.react.modules.camera.CameraRollManager;
|
|
import com.facebook.react.modules.camera.ImageEditingManager;
|
|
import com.facebook.react.modules.camera.ImageStoreManager;
|
|
import com.facebook.react.modules.clipboard.ClipboardModule;
|
|
import com.facebook.react.modules.datepicker.DatePickerDialogModule;
|
|
import com.facebook.react.modules.dialog.DialogModule;
|
|
import com.facebook.react.modules.fresco.FrescoModule;
|
|
import com.facebook.react.modules.image.ImageLoaderModule;
|
|
import com.facebook.react.modules.intent.IntentModule;
|
|
import com.facebook.react.modules.location.LocationModule;
|
|
import com.facebook.react.modules.netinfo.NetInfoModule;
|
|
import com.facebook.react.modules.network.NetworkingModule;
|
|
import com.facebook.react.modules.permissions.PermissionsModule;
|
|
import com.facebook.react.modules.statusbar.StatusBarModule;
|
|
import com.facebook.react.modules.storage.AsyncStorageModule;
|
|
import com.facebook.react.modules.timepicker.TimePickerDialogModule;
|
|
import com.facebook.react.modules.toast.ToastModule;
|
|
import com.facebook.react.modules.vibration.VibrationModule;
|
|
import com.facebook.react.modules.websocket.WebSocketModule;
|
|
import com.facebook.react.uimanager.ViewManager;
|
|
import com.facebook.react.views.art.ARTRenderableViewManager;
|
|
import com.facebook.react.views.art.ARTSurfaceViewManager;
|
|
import com.facebook.react.views.drawer.ReactDrawerLayoutManager;
|
|
import com.facebook.react.views.image.ReactImageManager;
|
|
import com.facebook.react.views.modal.ReactModalHostManager;
|
|
import com.facebook.react.views.picker.ReactDialogPickerManager;
|
|
import com.facebook.react.views.picker.ReactDropdownPickerManager;
|
|
import com.facebook.react.views.progressbar.ReactProgressBarViewManager;
|
|
import com.facebook.react.views.recyclerview.RecyclerViewBackedScrollViewManager;
|
|
import com.facebook.react.views.scroll.ReactHorizontalScrollViewManager;
|
|
import com.facebook.react.views.scroll.ReactScrollViewManager;
|
|
import com.facebook.react.views.slider.ReactSliderManager;
|
|
import com.facebook.react.views.swiperefresh.SwipeRefreshLayoutManager;
|
|
import com.facebook.react.views.switchview.ReactSwitchManager;
|
|
import com.facebook.react.views.text.ReactRawTextManager;
|
|
import com.facebook.react.views.text.ReactTextViewManager;
|
|
import com.facebook.react.views.text.ReactVirtualTextViewManager;
|
|
import com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageViewManager;
|
|
import com.facebook.react.views.textinput.ReactTextInputManager;
|
|
import com.facebook.react.views.toolbar.ReactToolbarManager;
|
|
import com.facebook.react.views.view.ReactViewManager;
|
|
import com.facebook.react.views.viewpager.ReactViewPagerManager;
|
|
import com.facebook.react.views.webview.ReactWebViewManager;
|
|
|
|
/**
|
|
* Package defining basic modules and view managers.
|
|
*/
|
|
public class MainReactPackage implements ReactPackage {
|
|
|
|
@Override
|
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
return Arrays.<NativeModule>asList(
|
|
new AppStateModule(reactContext),
|
|
new AsyncStorageModule(reactContext),
|
|
new CameraRollManager(reactContext),
|
|
new ClipboardModule(reactContext),
|
|
new DatePickerDialogModule(reactContext),
|
|
new DialogModule(reactContext),
|
|
new FrescoModule(reactContext),
|
|
new ImageEditingManager(reactContext),
|
|
new ImageLoaderModule(reactContext),
|
|
new ImageStoreManager(reactContext),
|
|
new IntentModule(reactContext),
|
|
new LocationModule(reactContext),
|
|
new NetworkingModule(reactContext),
|
|
new NetInfoModule(reactContext),
|
|
new PermissionsModule(reactContext),
|
|
new StatusBarModule(reactContext),
|
|
new TimePickerDialogModule(reactContext),
|
|
new ToastModule(reactContext),
|
|
new VibrationModule(reactContext),
|
|
new WebSocketModule(reactContext)
|
|
);
|
|
}
|
|
|
|
@Override
|
|
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
return Collections.emptyList();
|
|
}
|
|
|
|
@Override
|
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
return Arrays.<ViewManager>asList(
|
|
ARTRenderableViewManager.createARTGroupViewManager(),
|
|
ARTRenderableViewManager.createARTShapeViewManager(),
|
|
ARTRenderableViewManager.createARTTextViewManager(),
|
|
new ARTSurfaceViewManager(),
|
|
new ReactDialogPickerManager(),
|
|
new ReactDrawerLayoutManager(),
|
|
new ReactDropdownPickerManager(),
|
|
new ReactHorizontalScrollViewManager(),
|
|
new ReactImageManager(),
|
|
new ReactModalHostManager(reactContext),
|
|
new ReactProgressBarViewManager(),
|
|
new ReactRawTextManager(),
|
|
new ReactScrollViewManager(),
|
|
new ReactSliderManager(),
|
|
new ReactSwitchManager(),
|
|
new FrescoBasedReactTextInlineImageViewManager(),
|
|
new ReactTextInputManager(),
|
|
new ReactTextViewManager(),
|
|
new ReactToolbarManager(),
|
|
new ReactViewManager(),
|
|
new ReactViewPagerManager(),
|
|
new ReactVirtualTextViewManager(),
|
|
new ReactWebViewManager(),
|
|
new RecyclerViewBackedScrollViewManager(),
|
|
new SwipeRefreshLayoutManager());
|
|
}
|
|
}
|