Skip to content

Commit 3c3a264

Browse files
authored
docs: added twitter profile header example (#6)
1 parent 612b5d6 commit 3c3a264

File tree

107 files changed

+4269
-252
lines changed

Some content is hidden

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

107 files changed

+4269
-252
lines changed

example/android/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Android/IntelliJ
6+
#
7+
build/
8+
.idea
9+
.gradle
10+
local.properties
11+
*.iml
12+
*.hprof
13+
14+
# Bundle artifacts
15+
*.jsbundle

example/android/app/build.gradle

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
apply plugin: "com.android.application"
2+
apply plugin: "com.facebook.react"
3+
4+
import com.android.build.OutputFile
5+
6+
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
7+
def expoDebuggableVariants = ['debug']
8+
// Override `debuggableVariants` for expo-updates debugging
9+
if (System.getenv('EX_UPDATES_NATIVE_DEBUG') == "1") {
10+
react {
11+
expoDebuggableVariants = []
12+
}
13+
}
14+
15+
16+
/**
17+
* This is the configuration block to customize your React Native Android app.
18+
* By default you don't need to apply any configuration, just uncomment the lines you need.
19+
*/
20+
react {
21+
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
22+
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
23+
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
24+
debuggableVariants = expoDebuggableVariants
25+
26+
/* Folders */
27+
// The root of your project, i.e. where "package.json" lives. Default is '..'
28+
// root = file("../")
29+
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
30+
// reactNativeDir = file("../node_modules/react-native")
31+
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
32+
// codegenDir = file("../node_modules/react-native-codegen")
33+
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
34+
// cliFile = file("../node_modules/react-native/cli.js")
35+
36+
/* Variants */
37+
// The list of variants to that are debuggable. For those we're going to
38+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
39+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
40+
// debuggableVariants = ["liteDebug", "prodDebug"]
41+
42+
/* Bundling */
43+
// A list containing the node command and its flags. Default is just 'node'.
44+
// nodeExecutableAndArgs = ["node"]
45+
//
46+
// The command to run when bundling. By default is 'bundle'
47+
// bundleCommand = "ram-bundle"
48+
//
49+
// The path to the CLI configuration file. Default is empty.
50+
// bundleConfig = file(../rn-cli.config.js)
51+
//
52+
// The name of the generated asset file containing your JS bundle
53+
// bundleAssetName = "MyApplication.android.bundle"
54+
//
55+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
56+
// entryFile = file("../js/MyApplication.android.js")
57+
//
58+
// A list of extra flags to pass to the 'bundle' commands.
59+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
60+
// extraPackagerArgs = []
61+
62+
/* Hermes Commands */
63+
// The hermes compiler command to run. By default it is 'hermesc'
64+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
65+
//
66+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
67+
// hermesFlags = ["-O", "-output-source-map"]
68+
}
69+
70+
// Override `hermesEnabled` by `expo.jsEngine`
71+
ext {
72+
hermesEnabled = (findProperty('expo.jsEngine') ?: "hermes") == "hermes"
73+
}
74+
75+
/**
76+
* Set this to true to create four separate APKs instead of one,
77+
* one for each native architecture. This is useful if you don't
78+
* use App Bundles (https://developer.android.com/guide/app-bundle/)
79+
* and want to have separate APKs to upload to the Play Store.
80+
*/
81+
def enableSeparateBuildPerCPUArchitecture = false
82+
83+
/**
84+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
85+
*/
86+
def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean()
87+
88+
/**
89+
* The preferred build flavor of JavaScriptCore (JSC)
90+
*
91+
* For example, to use the international variant, you can use:
92+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
93+
*
94+
* The international variant includes ICU i18n library and necessary data
95+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
96+
* give correct results when using with locales other than en-US. Note that
97+
* this variant is about 6MiB larger per architecture than default.
98+
*/
99+
def jscFlavor = 'org.webkit:android-jsc:+'
100+
101+
/**
102+
* Private function to get the list of Native Architectures you want to build.
103+
* This reads the value from reactNativeArchitectures in your gradle.properties
104+
* file and works together with the --active-arch-only flag of react-native run-android.
105+
*/
106+
def reactNativeArchitectures() {
107+
def value = project.getProperties().get("reactNativeArchitectures")
108+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
109+
}
110+
111+
android {
112+
ndkVersion rootProject.ext.ndkVersion
113+
114+
compileSdkVersion rootProject.ext.compileSdkVersion
115+
116+
namespace 'com.rnh.example'
117+
defaultConfig {
118+
applicationId 'com.rnh.example'
119+
minSdkVersion rootProject.ext.minSdkVersion
120+
targetSdkVersion rootProject.ext.targetSdkVersion
121+
versionCode 1
122+
versionName "1.0.0"
123+
}
124+
125+
splits {
126+
abi {
127+
reset()
128+
enable enableSeparateBuildPerCPUArchitecture
129+
universalApk false // If true, also generate a universal APK
130+
include (*reactNativeArchitectures())
131+
}
132+
}
133+
signingConfigs {
134+
debug {
135+
storeFile file('debug.keystore')
136+
storePassword 'android'
137+
keyAlias 'androiddebugkey'
138+
keyPassword 'android'
139+
}
140+
}
141+
buildTypes {
142+
debug {
143+
signingConfig signingConfigs.debug
144+
}
145+
release {
146+
// Caution! In production, you need to generate your own keystore file.
147+
// see https://reactnative.dev/docs/signed-apk-android.
148+
signingConfig signingConfigs.debug
149+
minifyEnabled enableProguardInReleaseBuilds
150+
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
151+
}
152+
}
153+
154+
// applicationVariants are e.g. debug, release
155+
applicationVariants.all { variant ->
156+
variant.outputs.each { output ->
157+
// For each separate APK per architecture, set a unique version code as described here:
158+
// https://developer.android.com/studio/build/configure-apk-splits.html
159+
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
160+
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
161+
def abi = output.getFilter(OutputFile.ABI)
162+
if (abi != null) { // null for the universal-debug, universal-release variants
163+
output.versionCodeOverride =
164+
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
165+
}
166+
167+
}
168+
}
169+
}
170+
171+
// Apply static values from `gradle.properties` to the `android.packagingOptions`
172+
// Accepts values in comma delimited lists, example:
173+
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
174+
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
175+
// Split option: 'foo,bar' -> ['foo', 'bar']
176+
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
177+
// Trim all elements in place.
178+
for (i in 0..<options.size()) options[i] = options[i].trim();
179+
// `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
180+
options -= ""
181+
182+
if (options.length > 0) {
183+
println "android.packagingOptions.$prop += $options ($options.length)"
184+
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
185+
options.each {
186+
android.packagingOptions[prop] += it
187+
}
188+
}
189+
}
190+
191+
dependencies {
192+
// The version of react-native is set by the React Native Gradle Plugin
193+
implementation("com.facebook.react:react-android")
194+
195+
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
196+
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
197+
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
198+
def frescoVersion = rootProject.ext.frescoVersion
199+
200+
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
201+
if (isGifEnabled || isWebpEnabled) {
202+
implementation("com.facebook.fresco:fresco:${frescoVersion}")
203+
implementation("com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}")
204+
}
205+
206+
if (isGifEnabled) {
207+
// For animated gif support
208+
implementation("com.facebook.fresco:animated-gif:${frescoVersion}")
209+
}
210+
211+
if (isWebpEnabled) {
212+
// For webp support
213+
implementation("com.facebook.fresco:webpsupport:${frescoVersion}")
214+
if (isWebpAnimatedEnabled) {
215+
// Animated webp support
216+
implementation("com.facebook.fresco:animated-webp:${frescoVersion}")
217+
}
218+
}
219+
220+
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
221+
222+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
223+
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
224+
exclude group:'com.squareup.okhttp3', module:'okhttp'
225+
}
226+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
227+
228+
if (hermesEnabled.toBoolean()) {
229+
implementation("com.facebook.react:hermes-android")
230+
} else {
231+
implementation jscFlavor
232+
}
233+
}
234+
235+
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
236+
applyNativeModulesAppBuildGradle(project)

example/android/app/debug.keystore

2.2 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
# react-native-reanimated
11+
-keep class com.swmansion.reanimated.** { *; }
12+
-keep class com.facebook.react.turbomodule.** { *; }
13+
14+
# Add any project specific keep options here:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools">
3+
4+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5+
6+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
7+
</manifest>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and 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.rnh.example;
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.sharedpreferences.SharedPreferencesFlipperPlugin;
21+
import com.facebook.react.ReactInstanceEventListener;
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+
/**
28+
* Class responsible of loading Flipper inside your React Native application. This is the debug
29+
* flavor of it. Here you can add your own plugins and customize the Flipper setup.
30+
*/
31+
public class ReactNativeFlipper {
32+
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
33+
if (FlipperUtils.shouldEnableFlipper(context)) {
34+
final FlipperClient client = AndroidFlipperClient.getInstance(context);
35+
36+
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
37+
client.addPlugin(new DatabasesFlipperPlugin(context));
38+
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
39+
client.addPlugin(CrashReporterPlugin.getInstance());
40+
41+
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
42+
NetworkingModule.setCustomClientBuilder(
43+
new NetworkingModule.CustomClientBuilder() {
44+
@Override
45+
public void apply(OkHttpClient.Builder builder) {
46+
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
47+
}
48+
});
49+
client.addPlugin(networkFlipperPlugin);
50+
client.start();
51+
52+
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
53+
// Hence we run if after all native modules have been initialized
54+
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
55+
if (reactContext == null) {
56+
reactInstanceManager.addReactInstanceEventListener(
57+
new ReactInstanceEventListener() {
58+
@Override
59+
public void onReactContextInitialized(ReactContext reactContext) {
60+
reactInstanceManager.removeReactInstanceEventListener(this);
61+
reactContext.runOnNativeModulesQueueThread(
62+
new Runnable() {
63+
@Override
64+
public void run() {
65+
client.addPlugin(new FrescoFlipperPlugin());
66+
}
67+
});
68+
}
69+
});
70+
} else {
71+
client.addPlugin(new FrescoFlipperPlugin());
72+
}
73+
}
74+
}
75+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.rnh.example">
2+
<uses-permission android:name="android.permission.INTERNET"/>
3+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
4+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5+
<uses-permission android:name="android.permission.VIBRATE"/>
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
7+
<queries>
8+
<intent>
9+
<action android:name="android.intent.action.VIEW"/>
10+
<category android:name="android.intent.category.BROWSABLE"/>
11+
<data android:scheme="https"/>
12+
</intent>
13+
</queries>
14+
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
15+
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
16+
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="48.0.0"/>
17+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
18+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
19+
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@anonymous/example"/>
20+
<activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="unspecified">
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN"/>
23+
<category android:name="android.intent.category.LAUNCHER"/>
24+
</intent-filter>
25+
<intent-filter>
26+
<action android:name="android.intent.action.VIEW"/>
27+
<category android:name="android.intent.category.DEFAULT"/>
28+
<category android:name="android.intent.category.BROWSABLE"/>
29+
<data android:scheme="com.rnh.example"/>
30+
<data android:scheme="exp+example"/>
31+
</intent-filter>
32+
</activity>
33+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
34+
</application>
35+
</manifest>

0 commit comments

Comments
 (0)