Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc3055f1c9 | ||
|
|
25a1eac43b | ||
|
|
ff30e7f6a4 | ||
|
|
3fcc01597d | ||
|
|
cbc4a662e6 | ||
|
|
5aa0513324 | ||
|
|
4d1f142f9c | ||
|
|
e9c8f9432f | ||
|
|
56c375f344 | ||
|
|
5b165a2339 | ||
|
|
bfd3c711ab | ||
|
|
4627e284fa |
No files matched your search
+4
-4
@@ -143,8 +143,8 @@ android {
|
||||
applicationId "io.lbry.browser"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1303
|
||||
versionName "0.13.3"
|
||||
versionCode 1402
|
||||
versionName "0.14.2"
|
||||
missingDimensionStrategy 'react-native-camera', 'general'
|
||||
multiDexEnabled true
|
||||
}
|
||||
@@ -210,8 +210,8 @@ dependencies {
|
||||
implementation 'com.facebook.fresco:animated-gif:1.10.0'
|
||||
implementation 'com.google.firebase:firebase-messaging:20.1.0'
|
||||
|
||||
__32bitImplementation files('libs/lbrysdk-0.62.0-release__arm.aar')
|
||||
__64bitImplementation files('libs/lbrysdk-0.62.0-release__arm64.aar')
|
||||
__32bitImplementation files('libs/lbrysdk-0.67.1-release__arm.aar')
|
||||
__64bitImplementation files('libs/lbrysdk-0.67.1-release__arm64.aar')
|
||||
|
||||
if (enableHermes) {
|
||||
def hermesPath = "../../node_modules/hermes-engine/android/";
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,10 +12,6 @@ import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
|
||||
import io.lbry.browser.receivers.NotificationDeletedReceiver;
|
||||
import io.lbry.lbrysdk.LbrynetService;
|
||||
|
||||
|
||||
@@ -116,7 +116,8 @@ public class LbrynetMessagingService extends FirebaseMessagingService {
|
||||
} else {
|
||||
if (!MainActivity.isServiceRunning(this, LbrynetService.class) &&
|
||||
contentTitle != null &&
|
||||
channelUrl != null
|
||||
channelUrl != null &&
|
||||
!url.startsWith("lbry://?") /* not a special url */
|
||||
) {
|
||||
// only enter lite mode when contentTitle and channelUrl are set (and the service isn't running yet)
|
||||
// cold start
|
||||
|
||||
@@ -2,7 +2,10 @@ package io.lbry.browser;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@@ -18,15 +21,16 @@ import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.Manifest;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.Settings;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.NotificationManagerCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import android.telephony.SmsMessage;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.azendoo.reactnativesnackbar.SnackbarPackage;
|
||||
@@ -40,13 +44,10 @@ import com.facebook.react.bridge.Arguments;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.bridge.ReadableNativeArray;
|
||||
import com.facebook.react.bridge.ReadableNativeMap;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
import com.facebook.react.modules.core.PermissionAwareActivity;
|
||||
import com.facebook.react.modules.core.PermissionListener;
|
||||
import com.facebook.react.shell.MainReactPackage;
|
||||
import com.facebook.react.ReactRootView;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
|
||||
@@ -57,23 +58,19 @@ import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
|
||||
import com.swmansion.reanimated.ReanimatedPackage;
|
||||
import com.RNFetchBlob.RNFetchBlobPackage;
|
||||
|
||||
import io.lbry.browser.reactmodules.UtilityModule;
|
||||
import io.lbry.browser.reactpackages.LbryReactPackage;
|
||||
import io.lbry.browser.reactmodules.BackgroundMediaModule;
|
||||
import io.lbry.lbrysdk.LbrynetService;
|
||||
import io.lbry.lbrysdk.ServiceHelper;
|
||||
import io.lbry.lbrysdk.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.net.ConnectException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONArray;
|
||||
@@ -83,52 +80,35 @@ import org.reactnative.camera.RNCameraPackage;
|
||||
public class MainActivity extends FragmentActivity implements DefaultHardwareBackBtnHandler, PermissionAwareActivity {
|
||||
|
||||
private static Activity currentActivity = null;
|
||||
|
||||
private static final int OVERLAY_PERMISSION_REQ_CODE = 101;
|
||||
|
||||
private static final int STORAGE_PERMISSION_REQ_CODE = 201;
|
||||
|
||||
private static final int PHONE_STATE_PERMISSION_REQ_CODE = 202;
|
||||
|
||||
private static final int RECEIVE_SMS_PERMISSION_REQ_CODE = 203;
|
||||
|
||||
public static final int DOCUMENT_PICKER_RESULT_CODE = 301;
|
||||
public static final String SHARED_PREFERENCES_NAME = "LBRY";
|
||||
public static final String SALT_KEY = "salt";
|
||||
public static final String DEVICE_ID_KEY = "deviceId";
|
||||
public static final String SOURCE_NOTIFICATION_ID_KEY = "sourceNotificationId";
|
||||
public static final String SETTING_KEEP_DAEMON_RUNNING = "keepDaemonRunning";
|
||||
public static List<Integer> downloadNotificationIds = new ArrayList<Integer>();
|
||||
|
||||
private BroadcastReceiver notificationsReceiver;
|
||||
|
||||
private BroadcastReceiver smsReceiver;
|
||||
|
||||
private BroadcastReceiver stopServiceReceiver;
|
||||
|
||||
private BroadcastReceiver serviceActionsReceiver;
|
||||
private BroadcastReceiver downloadEventReceiver;
|
||||
|
||||
private FirebaseAnalytics firebaseAnalytics;
|
||||
|
||||
private ReactRootView mReactRootView;
|
||||
|
||||
private ReactInstanceManager mReactInstanceManager;
|
||||
|
||||
public static final String SHARED_PREFERENCES_NAME = "LBRY";
|
||||
|
||||
public static final String SALT_KEY = "salt";
|
||||
|
||||
public static final String DEVICE_ID_KEY = "deviceId";
|
||||
|
||||
public static final String SOURCE_NOTIFICATION_ID_KEY = "sourceNotificationId";
|
||||
|
||||
public static final String SETTING_KEEP_DAEMON_RUNNING = "keepDaemonRunning";
|
||||
|
||||
public static List<Integer> downloadNotificationIds = new ArrayList<Integer>();
|
||||
|
||||
/**
|
||||
* Flag which indicates whether or not the service is running. Will be updated in the
|
||||
* onResume method.
|
||||
*/
|
||||
private boolean serviceRunning;
|
||||
|
||||
private CheckSdkReadyTask checkSdkReadyTask;
|
||||
private boolean receivedStopService;
|
||||
|
||||
private PermissionListener permissionListener;
|
||||
public static boolean lbrySdkReady;
|
||||
|
||||
protected String getMainComponentName() {
|
||||
return "LBRYApp";
|
||||
@@ -145,7 +125,7 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
SoLoader.init(this, false);
|
||||
|
||||
// Register the stop service receiver (so that we close the activity if the user requests the service to stop)
|
||||
registerStopReceiver();
|
||||
registerServiceActionsReceiver();
|
||||
|
||||
// Register SMS receiver for handling verification texts
|
||||
registerSmsReceiver();
|
||||
@@ -153,20 +133,16 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
// Register the receiver to emit download events
|
||||
registerDownloadEventReceiver();
|
||||
|
||||
// Start the daemon service if it is not started
|
||||
// Start the sdk service if it is not started
|
||||
// Check the dht setting
|
||||
SharedPreferences sp = getSharedPreferences(MainActivity.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
LbrynetService.setDHTEnabled(sp.getBoolean(UtilityModule.DHT_ENABLED, false));
|
||||
serviceRunning = isServiceRunning(this, LbrynetService.class);
|
||||
if (!serviceRunning) {
|
||||
CurrentLaunchTiming.setColdStart(true);
|
||||
ServiceHelper.start(this, "", LbrynetService.class, "lbrynetservice");
|
||||
}
|
||||
|
||||
if (LbrynetService.serviceInstance != null) {
|
||||
// TODO: Add a broadcast receiver to listen for the service started event, so that we can set this properly
|
||||
Context context = getApplicationContext();
|
||||
Intent contextIntent = new Intent(context, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, contextIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
LbrynetService.serviceInstance.setPendingContextIntent(pendingIntent);
|
||||
}
|
||||
checkSdkReady();
|
||||
|
||||
checkNotificationOpenIntent(getIntent());
|
||||
|
||||
@@ -198,6 +174,22 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
setContentView(mReactRootView);
|
||||
}
|
||||
|
||||
private void checkSdkReady() {
|
||||
if (!lbrySdkReady) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (checkSdkReadyTask != null && checkSdkReadyTask.getStatus() != AsyncTask.Status.FINISHED) {
|
||||
// task already running
|
||||
return;
|
||||
}
|
||||
checkSdkReadyTask = new CheckSdkReadyTask();
|
||||
checkSdkReadyTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNotificationOpenIntent(Intent intent) {
|
||||
if (intent != null) {
|
||||
String notificationName = intent.getStringExtra("notification_name");
|
||||
@@ -271,17 +263,53 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
registerReceiver(downloadEventReceiver, intentFilter);
|
||||
}
|
||||
|
||||
private void registerStopReceiver() {
|
||||
private void registerServiceActionsReceiver() {
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(LbrynetService.LBRY_SDK_SERVICE_STARTED);
|
||||
intentFilter.addAction(LbrynetService.ACTION_STOP_SERVICE);
|
||||
stopServiceReceiver = new BroadcastReceiver() {
|
||||
serviceActionsReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MainActivity.this.receivedStopService = true;
|
||||
MainActivity.this.finish();
|
||||
String action = intent.getAction();
|
||||
if (LbrynetService.ACTION_STOP_SERVICE.equals(action)) {
|
||||
MainActivity.this.receivedStopService = true;
|
||||
MainActivity.this.finish();
|
||||
} else if (LbrynetService.LBRY_SDK_SERVICE_STARTED.equals(action)) {
|
||||
// Rebuild the service notification
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Notification svcNotification = buildServiceNotification();
|
||||
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(1, svcNotification);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
};
|
||||
registerReceiver(stopServiceReceiver, intentFilter);
|
||||
registerReceiver(serviceActionsReceiver, intentFilter);
|
||||
}
|
||||
|
||||
private Notification buildServiceNotification() {
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, LbrynetService.NOTIFICATION_CHANNEL_ID);
|
||||
Intent contextIntent = new Intent(this, MainActivity.class);
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, contextIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
Intent stopIntent = new Intent(LbrynetService.ACTION_STOP_SERVICE);
|
||||
PendingIntent stopPendingIntent = PendingIntent.getBroadcast(this, 0, stopIntent, 0);
|
||||
|
||||
String serviceDescription = "The LBRY service is running in the background.";
|
||||
Notification notification = builder.setColor(ContextCompat.getColor(this, R.color.lbryGreen))
|
||||
.setContentIntent(pendingIntent)
|
||||
.setContentText(serviceDescription)
|
||||
.setGroup(LbrynetService.GROUP_SERVICE)
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setSmallIcon(R.drawable.ic_lbry)
|
||||
.setOngoing(true)
|
||||
.addAction(android.R.drawable.ic_menu_close_clear_cancel, "Stop", stopPendingIntent)
|
||||
.build();
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
private void registerNotificationsReceiver() {
|
||||
@@ -472,10 +500,13 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
super.onResume();
|
||||
|
||||
SharedPreferences sp = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
LbrynetService.setDHTEnabled(sp.getBoolean(UtilityModule.DHT_ENABLED, false));
|
||||
|
||||
serviceRunning = isServiceRunning(this, LbrynetService.class);
|
||||
if (!serviceRunning) {
|
||||
ServiceHelper.start(this, "", LbrynetService.class, "lbrynetservice");
|
||||
}
|
||||
checkSdkReady();
|
||||
|
||||
if (mReactInstanceManager != null) {
|
||||
mReactInstanceManager.onHostResume(this, this);
|
||||
@@ -509,9 +540,9 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
downloadEventReceiver = null;
|
||||
}
|
||||
|
||||
if (stopServiceReceiver != null) {
|
||||
unregisterReceiver(stopServiceReceiver);
|
||||
stopServiceReceiver = null;
|
||||
if (serviceActionsReceiver != null) {
|
||||
unregisterReceiver(serviceActionsReceiver);
|
||||
serviceActionsReceiver = null;
|
||||
}
|
||||
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
|
||||
@@ -679,7 +710,6 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public static String getRealPathFromURI_API19(final Context context, final Uri uri) {
|
||||
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
|
||||
// DocumentProvider
|
||||
@@ -830,6 +860,51 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
|
||||
public static boolean isGooglePhotosUri(Uri uri) {
|
||||
return "com.google.android.apps.photos.content".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
private class CheckSdkReadyTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
public Boolean doInBackground(Void... params) {
|
||||
boolean sdkReady = false;
|
||||
try {
|
||||
String response = Utils.sdkCall("status");
|
||||
if (response != null) {
|
||||
JSONObject result = new JSONObject(response);
|
||||
JSONObject status = result.getJSONObject("result");
|
||||
|
||||
// send status response for splash page updates
|
||||
WritableMap sdkStatus = JSONObjectToMap(status);
|
||||
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
|
||||
if (reactContext != null) {
|
||||
WritableMap evtParams = Arguments.createMap();
|
||||
evtParams.putMap("status", sdkStatus);
|
||||
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onSdkStatusResponse", evtParams);
|
||||
}
|
||||
|
||||
JSONObject startupStatus = status.getJSONObject("startup_status");
|
||||
sdkReady = startupStatus.has("stream_manager") && startupStatus.has("wallet") &&
|
||||
startupStatus.getBoolean("stream_manager") && startupStatus.getBoolean("wallet") &&
|
||||
(status.getJSONObject("wallet").getLong("blocks_behind") <= 0);
|
||||
}
|
||||
} catch (ConnectException ex) {
|
||||
// pass
|
||||
} catch (JSONException ex) {
|
||||
// pass
|
||||
}
|
||||
|
||||
return sdkReady;
|
||||
}
|
||||
protected void onPostExecute(Boolean sdkReady) {
|
||||
lbrySdkReady = sdkReady;
|
||||
ReactContext reactContext = mReactInstanceManager.getCurrentReactContext();
|
||||
if (sdkReady && reactContext != null) {
|
||||
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onSdkReady", null);
|
||||
}
|
||||
|
||||
if (!sdkReady) {
|
||||
checkSdkReady();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LaunchTiming {
|
||||
private Date start;
|
||||
|
||||
@@ -77,8 +77,8 @@ public class FirebaseModule extends ReactContextBaseJavaModule {
|
||||
@ReactMethod
|
||||
public void logException(boolean fatal, String message, String error) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("message", message);
|
||||
bundle.putString("error", error);
|
||||
bundle.putString("exception_message", message);
|
||||
bundle.putString("exception_error", error);
|
||||
if (firebaseAnalytics != null) {
|
||||
firebaseAnalytics.logEvent(fatal ? "reactjs_exception" : "reactjs_warning", bundle);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,12 @@ import android.view.WindowManager;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.io.File;
|
||||
@@ -34,6 +36,7 @@ import java.io.Closeable;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
@@ -56,6 +59,7 @@ public class UtilityModule extends ReactContextBaseJavaModule {
|
||||
|
||||
public static final String ACTION_NOTIFICATION_LATER = "io.lbry.browser.ACTION_NOTIFICATION_LATER";
|
||||
|
||||
// Setting keys from React Native
|
||||
public static final String RECEIVE_SUBSCRIPTION_NOTIFICATIONS = "receiveSubscriptionNotifications";
|
||||
|
||||
public static final String RECEIVE_REWARD_NOTIFICATIONS = "receiveRewardNotifications";
|
||||
@@ -64,6 +68,8 @@ public class UtilityModule extends ReactContextBaseJavaModule {
|
||||
|
||||
public static final String RECEIVE_CREATOR_NOTIFICATIONS = "receiveCreatorNotifications";
|
||||
|
||||
public static final String DHT_ENABLED = "dhtEnabled";
|
||||
|
||||
// the last language set to be loaded
|
||||
private static final String LANGUAGE_SETTING_KEY = "language";
|
||||
|
||||
@@ -90,6 +96,7 @@ public class UtilityModule extends ReactContextBaseJavaModule {
|
||||
public Map<String, Object> getConstants() {
|
||||
final Map<String, Object> constants = MapBuilder.newHashMap();
|
||||
constants.put("language", language);
|
||||
constants.put("dhtEnabled", LbrynetService.isDHTEnabled());
|
||||
return constants;
|
||||
}
|
||||
|
||||
@@ -419,13 +426,44 @@ public class UtilityModule extends ReactContextBaseJavaModule {
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setNativeBooleanSetting(String key, boolean value) {
|
||||
public void setNativeBooleanSetting(String key, final boolean value) {
|
||||
if (context != null) {
|
||||
SharedPreferences sp = context.getSharedPreferences(MainActivity.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = sp.edit();
|
||||
editor.putBoolean(key, value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
if (DHT_ENABLED.equalsIgnoreCase(key)) {
|
||||
(new AsyncTask<Void, Void, Void>() {
|
||||
protected Void doInBackground(Void... params) {
|
||||
String fileContent = value ? "on" : "off";
|
||||
String path = String.format("%s/%s", Utils.getAppInternalStorageDir(context), "dht");
|
||||
PrintStream out = null;
|
||||
try {
|
||||
out = new PrintStream(new FileOutputStream(path));
|
||||
out.print(fileContent);
|
||||
} catch (Exception ex) {
|
||||
// pass
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void getNativeBooleanSetting(String key, boolean defaultValue, Promise promise) {
|
||||
if (context != null) {
|
||||
SharedPreferences sp = context.getSharedPreferences(MainActivity.SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
|
||||
promise.resolve(sp.getBoolean(key, defaultValue));
|
||||
} else {
|
||||
promise.resolve(null);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
@@ -483,6 +521,15 @@ public class UtilityModule extends ReactContextBaseJavaModule {
|
||||
promise.resolve(platform);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void checkSdkReady() {
|
||||
// check that the sdk ready when the service is already running so that we can send the ready event
|
||||
ReactContext reactContext = (ReactContext) context;
|
||||
if (MainActivity.lbrySdkReady && reactContext != null) {
|
||||
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onSdkReady", null);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void log(String tag, String message) {
|
||||
android.util.Log.d(tag, message);
|
||||
|
||||
Reference in new issue
Block a user