[IMPROVEMENT] Ease white labelling for Android (#2685)

* improve white labelling for Android

* Move application ID to gradle properties

* Fix CI

* Point foss sufix to main app

* Use npx on android-whitelabel script

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Graham Smith 2020-12-04 16:17:29 +00:00 committed by GitHub
parent 2403eb3857
commit 2d6572d709
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 92 additions and 76 deletions

View File

@ -151,6 +151,9 @@ jobs:
echo -e "android.useAndroidX=true" >> ./gradle.properties echo -e "android.useAndroidX=true" >> ./gradle.properties
echo -e "android.enableJetifier=true" >> ./gradle.properties echo -e "android.enableJetifier=true" >> ./gradle.properties
echo -e "FLIPPER_VERSION=0.51.0" >> ./gradle.properties echo -e "FLIPPER_VERSION=0.51.0" >> ./gradle.properties
echo -e "APPLICATION_ID=chat.rocket.reactnative" >> ./gradle.properties
echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties
echo -e "BugsnagAPIKey=$BUGSNAG_KEY" >> ./gradle.properties
if [[ $KEYSTORE ]]; then if [[ $KEYSTORE ]]; then
echo $KEYSTORE_BASE64 | base64 --decode > ./app/$KEYSTORE echo $KEYSTORE_BASE64 | base64 --decode > ./app/$KEYSTORE
@ -159,9 +162,6 @@ jobs:
echo -e "KEY_ALIAS=$KEY_ALIAS" >> ./gradle.properties echo -e "KEY_ALIAS=$KEY_ALIAS" >> ./gradle.properties
echo -e "KEY_PASSWORD=$KEYSTORE_PASSWORD" >> ./gradle.properties echo -e "KEY_PASSWORD=$KEYSTORE_PASSWORD" >> ./gradle.properties
fi fi
echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties
echo -e "BugsnagAPIKey=$BUGSNAG_KEY" >> ./gradle.properties
working_directory: android working_directory: android
- run: - run:
@ -246,6 +246,7 @@ jobs:
echo -e "android.enableJetifier=true" >> ./gradle.properties echo -e "android.enableJetifier=true" >> ./gradle.properties
echo -e "FLIPPER_VERSION=0.51.0" >> ./gradle.properties echo -e "FLIPPER_VERSION=0.51.0" >> ./gradle.properties
echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties
echo -e "APPLICATION_ID=chat.rocket.android" >> ./gradle.properties
if [[ $KEYSTORE ]]; then if [[ $KEYSTORE ]]; then
echo $KEYSTORE_BASE64 | base64 --decode > ./app/$KEYSTORE echo $KEYSTORE_BASE64 | base64 --decode > ./app/$KEYSTORE

View File

@ -140,7 +140,7 @@ android {
} }
defaultConfig { defaultConfig {
applicationId "chat.rocket.reactnative" applicationId APPLICATION_ID
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode VERSIONCODE as Integer versionCode VERSIONCODE as Integer
@ -196,7 +196,7 @@ android {
flavorDimensions "type" flavorDimensions "type"
productFlavors { productFlavors {
foss { foss {
applicationId "chat.rocket.android" applicationId APPLICATION_ID
dimension = "type" dimension = "type"
buildConfigField "boolean", "FDROID_BUILD", "true" buildConfigField "boolean", "FDROID_BUILD", "true"
} }

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools">
package="chat.rocket.reactnative">
<application <application
android:name=".MainDebugApplication" android:name="chat.rocket.reactnative.MainDebugApplication"
tools:ignore="GoogleAppIndexingWarning" tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:name" tools:replace="android:name"
tools:targetApi="28" tools:targetApi="28"

View File

@ -1,66 +1,78 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="chat.rocket.reactnative"> package="chat.rocket.reactnative">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application <application
android:name=".MainApplication" android:name="chat.rocket.reactnative.MainApplication"
android:label="@string/app_name" android:allowBackup="false"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme" android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true" android:requestLegacyExternalStorage="true"
android:requestLegacyExternalStorage="true" android:supportsRtl="true"
android:allowBackup="false" android:theme="@style/AppTheme"
tools:replace="android:allowBackup" tools:replace="android:allowBackup">
> <activity
<activity android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity" android:theme="@style/BootTheme">
android:theme="@style/BootTheme"> <intent-filter>
<intent-filter> <action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
</intent-filter> </activity>
</activity> <activity
<activity android:name="chat.rocket.reactnative.MainActivity"
android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:label="@string/app_name" android:exported="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:label="@string/app_name"
android:launchMode="singleTask" android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize" android:windowSoftInputMode="adjustResize">
android:exported="true"> <intent-filter>
<intent-filter> <action android:name="android.intent.action.DOWNLOAD_COMPLETE" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/> </intent-filter>
</intent-filter> <intent-filter android:label="@string/app_name">
<intent-filter android:label="@string/app_name"> <action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="go.rocket.chat" />
<data android:scheme="https" android:host="jitsi.rocket.chat" /> <data
<data android:scheme="rocketchat" android:host="room" /> android:host="go.rocket.chat"
<data android:scheme="rocketchat" android:host="auth" /> android:scheme="https" />
<data android:scheme="rocketchat" android:host="jitsi.rocket.chat" /> <data
</intent-filter> android:host="jitsi.rocket.chat"
</activity> android:scheme="https" />
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /> <data
<activity android:host="room"
android:noHistory="true" android:scheme="rocketchat" />
android:name=".share.ShareActivity" <data
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:host="auth"
android:label="@string/share_extension_name" android:scheme="rocketchat" />
android:screenOrientation="portrait" <data
android:theme="@style/AppTheme" > android:host="jitsi.rocket.chat"
<intent-filter> android:scheme="rocketchat" />
<action android:name="android.intent.action.SEND" /> </intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" /> </activity>
<category android:name="android.intent.category.DEFAULT" /> <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<data android:mimeType="*/*" /> <activity
</intent-filter> android:name="chat.rocket.reactnative.share.ShareActivity"
</activity> android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
</application> android:label="@string/share_extension_name"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
</application>
</manifest> </manifest>

View File

@ -19,6 +19,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import chat.rocket.reactnative.generated.BasePackageList; import chat.rocket.reactnative.generated.BasePackageList;
import chat.rocket.reactnative.networking.SSLPinningPackage;
public class MainApplication extends Application implements ReactApplication { public class MainApplication extends Application implements ReactApplication {

View File

@ -1,4 +1,4 @@
package chat.rocket.reactnative; package chat.rocket.reactnative.networking;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;

View File

@ -1,4 +1,4 @@
package chat.rocket.reactnative; package chat.rocket.reactnative.networking;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;

View File

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools">
package="chat.rocket.reactnative">
<application <application
android:name=".MainPlayApplication" android:name="chat.rocket.reactnative.MainPlayApplication"
android:label="@string/app_name" android:label="@string/app_name"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"
@ -12,11 +11,11 @@
tools:replace="android:name" tools:replace="android:name"
> >
<receiver <receiver
android:name=".ReplyBroadcast" android:name="chat.rocket.reactnative.ReplyBroadcast"
android:enabled="true" android:enabled="true"
android:exported="false" /> android:exported="false" />
<receiver <receiver
android:name=".DismissNotification" android:name="chat.rocket.reactnative.DismissNotification"
android:enabled="true" android:enabled="true"
android:exported="false" > android:exported="false" >
</receiver> </receiver>

View File

@ -29,6 +29,9 @@ android.enableJetifier=true
# Version of flipper SDK to use with React Native # Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.51.0 FLIPPER_VERSION=0.51.0
# Application ID
APPLICATION_ID=chat.rocket.reactnative
# App properties # App properties
VERSIONCODE=999999999 VERSIONCODE=999999999
BugsnagAPIKey="" BugsnagAPIKey=""

View File

@ -10,6 +10,7 @@
"ci": "npm run precommit && codecov", "ci": "npm run precommit && codecov",
"ios": "npx react-native run-ios", "ios": "npx react-native run-ios",
"android": "npx react-native run-android --variant=playDebug", "android": "npx react-native run-android --variant=playDebug",
"android-whitelabel": "npx react-native run-android --main-activity chat.rocket.reactnative.MainActivity --variant=playDebug --appId",
"log-android": "react-native log-android", "log-android": "react-native log-android",
"snyk-protect": "snyk protect", "snyk-protect": "snyk protect",
"precommit": "eslint . && jest", "precommit": "eslint . && jest",