Skip to content

Commit 3dcb3d4

Browse files
authored
Merge pull request #128 from XMRig-for-Android/issue-125-Move_UI_to_wix_s_RNUILIb
Full UI Refactor
2 parents d4e85b0 + 2a19fcd commit 3dcb3d4

File tree

87 files changed

+5523
-25024
lines changed

Some content is hidden

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

87 files changed

+5523
-25024
lines changed

android/app/build.gradle

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ apply plugin: "com.android.application"
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlinx-serialization'
44

5+
import com.android.build.OutputFile
6+
57
Properties props = new Properties()
68
props.load(new FileInputStream("$project.rootDir/../version.properties"))
79
props.each { prop ->
@@ -101,7 +103,7 @@ apply from: "../../node_modules/react-native/react.gradle"
101103
* Upload all the APKs to the Play Store and people will download
102104
* the correct one based on the CPU architecture of their device.
103105
*/
104-
def enableSeparateBuildPerCPUArchitecture = true
106+
def enableSeparateBuildPerCPUArchitecture = false
105107

106108
/**
107109
* Run Proguard to shrink the Java bytecode in release builds.
@@ -131,7 +133,10 @@ def useIntlJsc = true
131133
*/
132134
def enableHermes = true;
133135

134-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
136+
def reactNativeArchitectures() {
137+
def value = project.getProperties().get("reactNativeArchitectures")
138+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
139+
}
135140

136141
android {
137142
ndkVersion rootProject.ext.ndkVersion
@@ -144,6 +149,7 @@ android {
144149
targetSdkVersion rootProject.ext.targetSdkVersion
145150
versionCode project.ext.get("versionCode")
146151
versionName project.ext.get("versionName")
152+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
147153
multiDexEnabled true
148154
vectorDrawables.useSupportLibrary = true
149155
}
@@ -157,7 +163,7 @@ android {
157163
reset()
158164
enable enableSeparateBuildPerCPUArchitecture
159165
universalApk false // If true, also generate a universal APK
160-
include "armeabi-v7a", "arm64-v8a", "x86_64", "x86"
166+
include (*reactNativeArchitectures())
161167
}
162168
}
163169
/*signingConfigs {
@@ -184,11 +190,12 @@ android {
184190
buildTypes {
185191
debug {
186192
//signingConfig signingConfigs.debug
187-
if (nativeArchitectures) {
188-
ndk {
189-
abiFilters nativeArchitectures.split(',')
190-
}
193+
//if (nativeArchitectures) {
194+
ndk {
195+
//abiFilters nativeArchitectures.split(',')
196+
abiFilters (*reactNativeArchitectures())
191197
}
198+
//}
192199
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
193200
}
194201
release {
@@ -209,7 +216,7 @@ android {
209216
// https://developer.android.com/studio/build/configure-apk-splits.html
210217
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
211218
def versionCodes = ["armeabi-v7a": 1, "arm64-v8a": 3, "x86": 2, "x86_64": 4]
212-
def abi = output.getFilter(com.android.build.OutputFile.ABI)
219+
def abi = output.getFilter(OutputFile.ABI)
213220
if (abi != null && defaultConfig.versionCode != null) { // null for the universal-debug, universal-release variants
214221
output.versionCodeOverride =
215222
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
@@ -222,7 +229,8 @@ android {
222229

223230
dependencies {
224231
implementation fileTree(dir: "libs", include: ["*.jar"])
225-
implementation "com.facebook.react:react-native:0.66.3" // From node_modules
232+
implementation "com.facebook.react:react-native:+" // From node_modules
233+
//implementation project(':ReactAndroid')
226234

227235
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
228236
implementation project(':react-native-splash-screen')
@@ -233,6 +241,9 @@ dependencies {
233241
def hermesPath = "../../node_modules/hermes-engine/android/";
234242
debugImplementation files(hermesPath + "hermes-debug.aar")
235243
releaseImplementation files(hermesPath + "hermes-release.aar")
244+
/*implementation("com.facebook.react:hermes-engine:+") { // From node_modules
245+
exclude group:'com.facebook.fbjni'
246+
}*/
236247
} else {
237248
implementation jscFlavor
238249
}
@@ -274,6 +285,22 @@ configurations {
274285
compile.exclude group: "junit", module: "junit"
275286
}
276287

288+
if (isNewArchitectureEnabled()) {
289+
// If new architecture is enabled, we let you build RN from source
290+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
291+
// This will be applied to all the imported transtitive dependency.
292+
configurations.all {
293+
resolutionStrategy.dependencySubstitution {
294+
substitute(module("com.facebook.react:react-native"))
295+
.using(project(":ReactAndroid"))
296+
.because("On New Architecture we're building React Native from source")
297+
substitute(module("com.facebook.react:hermes-engine"))
298+
.using(project(":ReactAndroid:hermes-engine"))
299+
.because("On New Architecture we're building Hermes from source")
300+
}
301+
}
302+
}
303+
277304
// Run this once to be able to run the application with BUCK
278305
// puts all compile dependencies into folder libs for BUCK to use
279306
task copyDownloadableDepsToLibs(type: Copy) {
@@ -283,3 +310,11 @@ task copyDownloadableDepsToLibs(type: Copy) {
283310

284311
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
285312
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
313+
314+
def isNewArchitectureEnabled() {
315+
// To opt-in for the New Architecture, you can either:
316+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
317+
// - Invoke gradle with `-newArchEnabled=true`
318+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
319+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
320+
}

android/app/proguard-rules.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ com.xmrigforandroid.data.serialization.Configuration
5050
}
5151

5252
-keep public class com.horcrux.svg.** {*;}
53+
54+
-keep class com.swmansion.reanimated.** { *; }
55+
-keep class com.facebook.react.turbomodule.** { *; }

android/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333

3434
<activity
3535
android:name=".MainActivity"
36-
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
36+
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
3737
android:label="@string/app_name"
3838
android:launchMode="singleTop"
39+
android:exported="true"
3940
android:windowSoftInputMode="adjustResize">
4041
<intent-filter>
4142
<action android:name="android.intent.action.MAIN" />

android/app/src/main/java/com/xmrigforandroid/MainApplication.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import com.facebook.react.ReactPackage;
99
import com.facebook.soloader.SoLoader;
1010

11+
import com.facebook.react.bridge.JSIModulePackage;
12+
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
13+
1114
import java.util.List;
1215

1316
public class MainApplication extends Application implements ReactApplication {
@@ -36,6 +39,11 @@ protected List<ReactPackage> getPackages() {
3639
protected String getJSMainModuleName() {
3740
return "index";
3841
}
42+
43+
@Override
44+
protected JSIModulePackage getJSIModulePackage() {
45+
return new ReanimatedJSIModulePackage();
46+
}
3947
};
4048

4149
@Override

android/app/src/main/java/com/xmrigforandroid/MiningService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void onCreate() {
4545

4646
Intent notificationIntent = new Intent(this, MiningService.class);
4747
PendingIntent pendingIntent =
48-
PendingIntent.getActivity(this, 0, notificationIntent, 0);
48+
PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_MUTABLE);
4949

5050
notificationbuilder =
5151
new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)

android/build.gradle

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "30.0.2"
6-
minSdkVersion = 29
5+
buildToolsVersion = "31.0.0"
6+
minSdkVersion = 26
77
compileSdkVersion = 31
8-
targetSdkVersion = 30
9-
ndkVersion = "21.1.6352462"
8+
targetSdkVersion = 31
9+
ndkVersion = "21.4.7075529"
1010
kotlinVersion = '1.5.0'
1111
}
1212
repositories {
@@ -15,8 +15,9 @@ buildscript {
1515
mavenCentral()
1616
}
1717
dependencies {
18-
classpath('com.android.tools.build:gradle:7.0.3')
18+
classpath('com.android.tools.build:gradle:7.0.4')
1919
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
20+
classpath("de.undercouch:gradle-download-task:4.1.2")
2021
classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
2122

2223

@@ -43,11 +44,15 @@ allprojects {
4344
// Android JSC is installed from npm
4445
url("$rootDir/../node_modules/jsc-android/dist")
4546
}
46-
47-
google()
47+
mavenCentral {
48+
// We don't want to fetch react-native from Maven Central as there are
49+
// older versions over there.
50+
content {
51+
excludeGroup "com.facebook.react"
52+
}
53+
}
4854
jcenter()
55+
google()
4956
maven { url 'https://www.jitpack.io' }
50-
mavenCentral()
51-
5257
}
5358
}

android/gradle.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,7 @@ android.useAndroidX=true
2424
# Automatically convert third-party libraries to use AndroidX
2525
android.enableJetifier=true
2626

27-
org.gradle.jvmargs=-Xmx4608m
28-
android.bundle.enableUncompressedNativeLibs=false
27+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
28+
android.bundle.enableUncompressedNativeLibs=false
29+
newArchEnabled=false
30+
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
44
zipStoreBase=GRADLE_USER_HOME
5-
zipStorePath=wrapper/dists
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)