Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade react-native to 0.73.4 #1996

Merged
merged 5 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"

apply plugin: "com.google.protobuf"

apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"

// LN address notifications
apply plugin: "com.google.gms.google-services"
Expand Down Expand Up @@ -94,6 +94,7 @@ def enableSeparateBuildPerCPUArchitecture = true
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")

android {
namespace "app.zeusln.zeus"
defaultConfig {
compileSdk rootProject.ext.compileSdkVersion
applicationId "app.zeusln.zeus"
Expand Down Expand Up @@ -179,10 +180,12 @@ android {
}

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.multidex:multidex:2.0.1'
implementation project(':react-native-randombytes')
implementation "com.facebook.react:react-native:0.70.6!!" // From node_modules
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public ListenableFuture<Result> startWork() {
writeLastScheduledSyncAttemptToDb();

// Hyperlog.i(TAG, "MainActivity.started = " + MainActivity.started);
if (persistentServicesEnabled || MainActivity.started) {
if (persistentServicesEnabled || MainActivity.Companion.getStarted()) {
// Hyperlog.i(TAG, "MainActivity is started or persistentServicesEnabled = " + persistentServicesEnabled + ", quitting job");
completer.set(Result.success());
return null;
Expand Down
12 changes: 6 additions & 6 deletions android/app/src/main/java/com/zeus/LndMobileTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ public void copyLndLog(String network, Promise promise) {
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TITLE, "lnd.log");
if (network == "testnet") {
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.INTENT_COPYLNDLOGTESTNET);
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.Companion.getINTENT_COPYLNDLOGTESTNET());
} else {
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.INTENT_COPYLNDLOG);
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.Companion.getINTENT_COPYLNDLOG());
}
promise.resolve(true);
}
Expand Down Expand Up @@ -268,14 +268,14 @@ private void readToEnd(BufferedReader buf, boolean emit) throws IOException {

@ReactMethod
public void saveChannelsBackup(String base64Backups, Promise promise) {
MainActivity.tmpChanBackup = Base64.decode(base64Backups, Base64.NO_WRAP);
MainActivity.Companion.setTmpChanBackup(Base64.decode(base64Backups, Base64.NO_WRAP));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");

Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TITLE, "zeus-channels-backup-" + dateFormat.format(new Date()) + ".bin");
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.INTENT_EXPORTCHANBACKUP);
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.Companion.getINTENT_EXPORTCHANBACKUP());
promise.resolve(true);
}

Expand All @@ -288,9 +288,9 @@ public void saveChannelBackupFile(String network, Promise promise) {
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TITLE, "zeus-channels-backup-" + dateFormat.format(new Date()) + ".bin");
if (network == "testnet") {
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.INTENT_EXPORTCHANBACKUPFILETESTNET);
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.Companion.getINTENT_EXPORTCHANBACKUPFILETESTNET());
} else {
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.INTENT_EXPORTCHANBACKUPFILE);
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.Companion.getINTENT_EXPORTCHANBACKUPFILE());
}
promise.resolve(true);
}
Expand Down
159 changes: 0 additions & 159 deletions android/app/src/main/java/com/zeus/MainActivity.java

This file was deleted.

129 changes: 129 additions & 0 deletions android/app/src/main/java/com/zeus/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package app.zeusln.zeus

import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
import dev.doubledot.doki.ui.DokiActivity
import java.io.ByteArrayInputStream
import java.io.File
import java.io.FileInputStream
import java.io.IOException
import java.io.InputStream
import java.lang.ref.WeakReference

class MainActivity : ReactActivity() {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "zeus"

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(null)
currentActivity = WeakReference(this@MainActivity)
started = true
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == INTENT_COPYLNDLOG && resultCode == RESULT_OK) {
val destUri = data!!.data
val sourceLocation = File("$filesDir/logs/bitcoin/mainnet/lnd.log")
try {
val `in`: InputStream = FileInputStream(sourceLocation)
val out = contentResolver.openOutputStream(destUri!!)
val buf = ByteArray(1024)
var len: Int
while (`in`.read(buf).also { len = it } > 0) {
out!!.write(buf, 0, len)
}
`in`.close()
out!!.close()
} catch (e: IOException) {
Toast.makeText(this, "Error " + e.message, Toast.LENGTH_LONG).show()
}
} else if (requestCode == INTENT_EXPORTCHANBACKUP && resultCode == RESULT_OK) {
val destUri = data!!.data
try {
val `in` = ByteArrayInputStream(tmpChanBackup)
val out = contentResolver.openOutputStream(destUri!!)
val buf = ByteArray(1024)
var len: Int
while (`in`.read(buf).also { len = it } > 0) {
out!!.write(buf, 0, len)
}
`in`.close()
out!!.close()
tmpChanBackup = ByteArray(0)
} catch (e: IOException) {
e.printStackTrace()
}
} else if (requestCode == INTENT_EXPORTCHANBACKUPFILE && resultCode == RESULT_OK) {
val destUri = data!!.data
val sourceLocation = File("$filesDir/data/chain/bitcoin/mainnet/channel.backup")
try {
val `in`: InputStream = FileInputStream(sourceLocation)
val out = contentResolver.openOutputStream(destUri!!)
val buf = ByteArray(1024)
var len: Int
while (`in`.read(buf).also { len = it } > 0) {
out!!.write(buf, 0, len)
}
`in`.close()
out!!.close()
} catch (e: IOException) {
Toast.makeText(this, "Error " + e.message, Toast.LENGTH_LONG).show()
}
} else if (requestCode == INTENT_EXPORTCHANBACKUPFILETESTNET && resultCode == RESULT_OK) {
val destUri = data!!.data
val sourceLocation = File("$filesDir/data/chain/bitcoin/testnet/channel.backup")
try {
val `in`: InputStream = FileInputStream(sourceLocation)
val out = contentResolver.openOutputStream(destUri!!)
val buf = ByteArray(1024)
var len: Int
while (`in`.read(buf).also { len = it } > 0) {
out!!.write(buf, 0, len)
}
`in`.close()
out!!.close()
} catch (e: IOException) {
Toast.makeText(this, "Error " + e.message, Toast.LENGTH_LONG).show()
}
}
}

fun showMsg() {
startActivity(Intent(this@MainActivity, DokiActivity::class.java))
}

companion object {
var TAG = "MainActivity"
var started = false
var INTENT_COPYLNDLOG = 100
var INTENT_EXPORTCHANBACKUP = 101
var INTENT_EXPORTCHANBACKUPFILE = 102
var INTENT_COPYLNDLOGTESTNET = 200
var INTENT_EXPORTCHANBACKUPFILETESTNET = 202
var tmpChanBackup: ByteArray = ByteArray(0)
var currentActivity: WeakReference<MainActivity>? = null
val activity: MainActivity?
get() = currentActivity!!.get()
}
}
Loading