Skip to content

Commit

Permalink
Merge pull request #128 from XMRig-for-Android/issue-125-Move_UI_to_w…
Browse files Browse the repository at this point in the history
…ix_s_RNUILIb

Full UI Refactor
  • Loading branch information
garrylachman authored Apr 26, 2022
2 parents d4e85b0 + 2a19fcd commit 3dcb3d4
Show file tree
Hide file tree
Showing 87 changed files with 5,523 additions and 25,024 deletions.
53 changes: 44 additions & 9 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ apply plugin: "com.android.application"
apply plugin: 'kotlin-android'
apply plugin: 'kotlinx-serialization'

import com.android.build.OutputFile

Properties props = new Properties()
props.load(new FileInputStream("$project.rootDir/../version.properties"))
props.each { prop ->
Expand Down Expand Up @@ -101,7 +103,7 @@ apply from: "../../node_modules/react-native/react.gradle"
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = true
def enableSeparateBuildPerCPUArchitecture = false

/**
* Run Proguard to shrink the Java bytecode in release builds.
Expand Down Expand Up @@ -131,7 +133,10 @@ def useIntlJsc = true
*/
def enableHermes = true;

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

android {
ndkVersion rootProject.ext.ndkVersion
Expand All @@ -144,6 +149,7 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode project.ext.get("versionCode")
versionName project.ext.get("versionName")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
Expand All @@ -157,7 +163,7 @@ android {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "arm64-v8a", "x86_64", "x86"
include (*reactNativeArchitectures())
}
}
/*signingConfigs {
Expand All @@ -184,11 +190,12 @@ android {
buildTypes {
debug {
//signingConfig signingConfigs.debug
if (nativeArchitectures) {
ndk {
abiFilters nativeArchitectures.split(',')
}
//if (nativeArchitectures) {
ndk {
//abiFilters nativeArchitectures.split(',')
abiFilters (*reactNativeArchitectures())
}
//}
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
release {
Expand All @@ -209,7 +216,7 @@ android {
// https://developer.android.com/studio/build/configure-apk-splits.html
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
def versionCodes = ["armeabi-v7a": 1, "arm64-v8a": 3, "x86": 2, "x86_64": 4]
def abi = output.getFilter(com.android.build.OutputFile.ABI)
def abi = output.getFilter(OutputFile.ABI)
if (abi != null && defaultConfig.versionCode != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
Expand All @@ -222,7 +229,8 @@ android {

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

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation project(':react-native-splash-screen')
Expand All @@ -233,6 +241,9 @@ dependencies {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
/*implementation("com.facebook.react:hermes-engine:+") { // From node_modules
exclude group:'com.facebook.fbjni'
}*/
} else {
implementation jscFlavor
}
Expand Down Expand Up @@ -274,6 +285,22 @@ configurations {
compile.exclude group: "junit", module: "junit"
}

if (isNewArchitectureEnabled()) {
// If new architecture is enabled, we let you build RN from source
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
// This will be applied to all the imported transtitive dependency.
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute(module("com.facebook.react:react-native"))
.using(project(":ReactAndroid"))
.because("On New Architecture we're building React Native from source")
substitute(module("com.facebook.react:hermes-engine"))
.using(project(":ReactAndroid:hermes-engine"))
.because("On New Architecture we're building Hermes from source")
}
}
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
Expand All @@ -283,3 +310,11 @@ task copyDownloadableDepsToLibs(type: Copy) {

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

def isNewArchitectureEnabled() {
// To opt-in for the New Architecture, you can either:
// - Set `newArchEnabled` to true inside the `gradle.properties` file
// - Invoke gradle with `-newArchEnabled=true`
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}
3 changes: 3 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ com.xmrigforandroid.data.serialization.Configuration
}

-keep public class com.horcrux.svg.** {*;}

-keep class com.swmansion.reanimated.** { *; }
-keep class com.facebook.react.turbomodule.** { *; }
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@

<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:label="@string/app_name"
android:launchMode="singleTop"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;

import com.facebook.react.bridge.JSIModulePackage;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;

import java.util.List;

public class MainApplication extends Application implements ReactApplication {
Expand Down Expand Up @@ -36,6 +39,11 @@ protected List<ReactPackage> getPackages() {
protected String getJSMainModuleName() {
return "index";
}

@Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage();
}
};

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onCreate() {

Intent notificationIntent = new Intent(this, MiningService.class);
PendingIntent pendingIntent =
PendingIntent.getActivity(this, 0, notificationIntent, 0);
PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_MUTABLE);

notificationbuilder =
new Notification.Builder(this, NOTIFICATION_CHANNEL_ID)
Expand Down
23 changes: 14 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 29
buildToolsVersion = "31.0.0"
minSdkVersion = 26
compileSdkVersion = 31
targetSdkVersion = 30
ndkVersion = "21.1.6352462"
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
kotlinVersion = '1.5.0'
}
repositories {
Expand All @@ -15,8 +15,9 @@ buildscript {
mavenCentral()
}
dependencies {
classpath('com.android.tools.build:gradle:7.0.3')
classpath('com.android.tools.build:gradle:7.0.4')
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
classpath("de.undercouch:gradle-download-task:4.1.2")
classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")


Expand All @@ -43,11 +44,15 @@ allprojects {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

google()
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
jcenter()
google()
maven { url 'https://www.jitpack.io' }
mavenCentral()

}
}
6 changes: 4 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

org.gradle.jvmargs=-Xmx4608m
android.bundle.enableUncompressedNativeLibs=false
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
android.bundle.enableUncompressedNativeLibs=false
newArchEnabled=false
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
Loading

0 comments on commit 3dcb3d4

Please sign in to comment.