Skip to content

Commit eded43a

Browse files
committed
configure image picker
1 parent 58ae479 commit eded43a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+7076
-0
lines changed

example/android/app/build.gradle

+218
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
apply plugin: "com.android.application"
2+
3+
import com.android.build.OutputFile
4+
5+
/**
6+
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7+
* and bundleReleaseJsAndAssets).
8+
* These basically call `react-native bundle` with the correct arguments during the Android build
9+
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10+
* bundle directly from the development server. Below you can see all the possible configurations
11+
* and their defaults. If you decide to add a configuration block, make sure to add it before the
12+
* `apply from: "../../node_modules/react-native/react.gradle"` line.
13+
*
14+
* project.ext.react = [
15+
* // the name of the generated asset file containing your JS bundle
16+
* bundleAssetName: "index.android.bundle",
17+
*
18+
* // the entry file for bundle generation
19+
* entryFile: "index.android.js",
20+
*
21+
* // https://reactnative.dev/docs/performance#enable-the-ram-format
22+
* bundleCommand: "ram-bundle",
23+
*
24+
* // whether to bundle JS and assets in debug mode
25+
* bundleInDebug: false,
26+
*
27+
* // whether to bundle JS and assets in release mode
28+
* bundleInRelease: true,
29+
*
30+
* // whether to bundle JS and assets in another build variant (if configured).
31+
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32+
* // The configuration property can be in the following formats
33+
* // 'bundleIn${productFlavor}${buildType}'
34+
* // 'bundleIn${buildType}'
35+
* // bundleInFreeDebug: true,
36+
* // bundleInPaidRelease: true,
37+
* // bundleInBeta: true,
38+
*
39+
* // whether to disable dev mode in custom build variants (by default only disabled in release)
40+
* // for TiktokExample: to disable dev mode in the staging build type (if configured)
41+
* devDisabledInStaging: true,
42+
* // The configuration property can be in the following formats
43+
* // 'devDisabledIn${productFlavor}${buildType}'
44+
* // 'devDisabledIn${buildType}'
45+
*
46+
* // the root of your project, i.e. where "package.json" lives
47+
* root: "../../",
48+
*
49+
* // where to put the JS bundle asset in debug mode
50+
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51+
*
52+
* // where to put the JS bundle asset in release mode
53+
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54+
*
55+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
56+
* // require('./image.png')), in debug mode
57+
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58+
*
59+
* // where to put drawable resources / React Native assets, e.g. the ones you use via
60+
* // require('./image.png')), in release mode
61+
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62+
*
63+
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64+
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65+
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
66+
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67+
* // for TiktokExample, you might want to remove it from here.
68+
* inputExcludes: ["android/**", "ios/**"],
69+
*
70+
* // override which node gets called and with what additional arguments
71+
* nodeExecutableAndArgs: ["node"],
72+
*
73+
* // supply additional arguments to the packager
74+
* extraPackagerArgs: []
75+
* ]
76+
*/
77+
78+
project.ext.react = [
79+
enableHermes: false, // clean and rebuild if changing
80+
entryFile: "index.tsx",
81+
]
82+
83+
apply from: "../../node_modules/react-native/react.gradle"
84+
85+
/**
86+
* Set this to true to create two separate APKs instead of one:
87+
* - An APK that only works on ARM devices
88+
* - An APK that only works on x86 devices
89+
* The advantage is the size of the APK is reduced by about 4MB.
90+
* Upload all the APKs to the Play Store and people will download
91+
* the correct one based on the CPU architecture of their device.
92+
*/
93+
def enableSeparateBuildPerCPUArchitecture = false
94+
95+
/**
96+
* Run Proguard to shrink the Java bytecode in release builds.
97+
*/
98+
def enableProguardInReleaseBuilds = false
99+
100+
/**
101+
* The preferred build flavor of JavaScriptCore.
102+
*
103+
* For TiktokExample, to use the international variant, you can use:
104+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105+
*
106+
* The international variant includes ICU i18n library and necessary data
107+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108+
* give correct results when using with locales other than en-US. Note that
109+
* this variant is about 6MiB larger per architecture than default.
110+
*/
111+
def jscFlavor = 'org.webkit:android-jsc:+'
112+
113+
/**
114+
* Whether to enable the Hermes VM.
115+
*
116+
* This should be set on project.ext.react and mirrored here. If it is not set
117+
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118+
* and the benefits of using Hermes will therefore be sharply reduced.
119+
*/
120+
def enableHermes = project.ext.react.get("enableHermes", false);
121+
122+
android {
123+
compileSdkVersion rootProject.ext.compileSdkVersion
124+
125+
compileOptions {
126+
sourceCompatibility JavaVersion.VERSION_1_8
127+
targetCompatibility JavaVersion.VERSION_1_8
128+
}
129+
130+
defaultConfig {
131+
applicationId "com.example.flytrendy"
132+
minSdkVersion rootProject.ext.minSdkVersion
133+
targetSdkVersion rootProject.ext.targetSdkVersion
134+
versionCode 1
135+
versionName "1.0"
136+
vectorDrawables.useSupportLibrary = true
137+
}
138+
splits {
139+
abi {
140+
reset()
141+
enable enableSeparateBuildPerCPUArchitecture
142+
universalApk false // If true, also generate a universal APK
143+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
144+
}
145+
}
146+
signingConfigs {
147+
debug {
148+
storeFile file('debug.keystore')
149+
storePassword 'android'
150+
keyAlias 'androiddebugkey'
151+
keyPassword 'android'
152+
}
153+
}
154+
buildTypes {
155+
debug {
156+
signingConfig signingConfigs.debug
157+
}
158+
release {
159+
// Caution! In production, you need to generate your own keystore file.
160+
// see https://reactnative.dev/docs/signed-apk-android.
161+
signingConfig signingConfigs.debug
162+
minifyEnabled enableProguardInReleaseBuilds
163+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
164+
}
165+
}
166+
// applicationVariants are e.g. debug, release
167+
applicationVariants.all { variant ->
168+
variant.outputs.each { output ->
169+
// For each separate APK per architecture, set a unique version code as described here:
170+
// https://developer.android.com/studio/build/configure-apk-splits.html
171+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
172+
def abi = output.getFilter(OutputFile.ABI)
173+
if (abi != null) { // null for the universal-debug, universal-release variants
174+
output.versionCodeOverride =
175+
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
176+
}
177+
178+
}
179+
}
180+
}
181+
182+
dependencies {
183+
implementation fileTree(dir: "libs", include: ["*.jar"])
184+
//noinspection GradleDynamicVersion
185+
implementation "com.facebook.react:react-native:+" // From node_modules
186+
187+
188+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
189+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
190+
exclude group:'com.facebook.fbjni'
191+
}
192+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
193+
exclude group:'com.facebook.flipper'
194+
exclude group:'com.squareup.okhttp3', module:'okhttp'
195+
}
196+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
197+
exclude group:'com.facebook.flipper'
198+
}
199+
200+
if (enableHermes) {
201+
def hermesPath = "../../node_modules/hermes-engine/android/";
202+
debugImplementation files(hermesPath + "hermes-debug.aar")
203+
releaseImplementation files(hermesPath + "hermes-release.aar")
204+
} else {
205+
implementation jscFlavor
206+
}
207+
208+
implementation project(':reactnativetiktok')
209+
}
210+
211+
// Run this once to be able to run the application with BUCK
212+
// puts all compile dependencies into folder libs for BUCK to use
213+
task copyDownloadableDepsToLibs(type: Copy) {
214+
from configurations.compile
215+
into 'libs'
216+
}
217+
218+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/android/app/debug.keystore

2.2 KB
Binary file not shown.
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6+
7+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
8+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5+
* directory of this source tree.
6+
*/
7+
package com.example.flytrendy;
8+
9+
import android.content.Context;
10+
import com.facebook.flipper.android.AndroidFlipperClient;
11+
import com.facebook.flipper.android.utils.FlipperUtils;
12+
import com.facebook.flipper.core.FlipperClient;
13+
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14+
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15+
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16+
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17+
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18+
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19+
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20+
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21+
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22+
import com.facebook.react.ReactInstanceManager;
23+
import com.facebook.react.bridge.ReactContext;
24+
import com.facebook.react.modules.network.NetworkingModule;
25+
import okhttp3.OkHttpClient;
26+
27+
public class ReactNativeFlipper {
28+
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29+
if (FlipperUtils.shouldEnableFlipper(context)) {
30+
final FlipperClient client = AndroidFlipperClient.getInstance(context);
31+
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
32+
client.addPlugin(new ReactFlipperPlugin());
33+
client.addPlugin(new DatabasesFlipperPlugin(context));
34+
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
35+
client.addPlugin(CrashReporterPlugin.getInstance());
36+
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
37+
NetworkingModule.setCustomClientBuilder(
38+
new NetworkingModule.CustomClientBuilder() {
39+
@Override
40+
public void apply(OkHttpClient.Builder builder) {
41+
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
42+
}
43+
});
44+
client.addPlugin(networkFlipperPlugin);
45+
client.start();
46+
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
47+
// Hence we run if after all native modules have been initialized
48+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
49+
if (reactContext == null) {
50+
reactInstanceManager.addReactInstanceEventListener(
51+
new ReactInstanceManager.ReactInstanceEventListener() {
52+
@Override
53+
public void onReactContextInitialized(ReactContext reactContext) {
54+
reactInstanceManager.removeReactInstanceEventListener(this);
55+
reactContext.runOnNativeModulesQueueThread(
56+
new Runnable() {
57+
@Override
58+
public void run() {
59+
client.addPlugin(new FrescoFlipperPlugin());
60+
}
61+
});
62+
}
63+
});
64+
} else {
65+
client.addPlugin(new FrescoFlipperPlugin());
66+
}
67+
}
68+
}
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.example.flytrendy">
3+
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
<application
7+
android:name=".MainApplication"
8+
android:label="@string/app_name"
9+
android:icon="@mipmap/ic_launcher"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:allowBackup="false"
12+
android:theme="@style/AppTheme">
13+
<activity
14+
android:name=".MainActivity"
15+
android:label="@string/app_name"
16+
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
17+
android:launchMode="singleTask"
18+
android:windowSoftInputMode="adjustResize">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
<category android:name="android.intent.category.LAUNCHER" />
22+
</intent-filter>
23+
</activity>
24+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
25+
</application>
26+
27+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.example.flytrendy;
2+
3+
import com.facebook.react.ReactActivity;
4+
5+
public class MainActivity extends ReactActivity {
6+
7+
/**
8+
* Returns the name of the main component registered from JavaScript. This is used to schedule
9+
* rendering of the component.
10+
*/
11+
@Override
12+
protected String getMainComponentName() {
13+
return "TiktokExample";
14+
}
15+
}

0 commit comments

Comments
 (0)