Merge remote-tracking branch 'origin/master' into edit-publish

This commit is contained in:
Akinwale Ariwodola 2019-08-25 17:19:21 +01:00
commit 8e7275c0ca
2 changed files with 22 additions and 3 deletions

View file

@ -412,4 +412,14 @@ public final class Utils {
}
return new SecretKeySpec(rsaDecrypt(Base64.decode(base64Key, Base64.DEFAULT), keyStore), "AES");
}
public static String capitalizeAndStrip(String text) {
String[] parts = text.split(" ");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < parts.length; i++) {
sb.append(parts[i].substring(0, 1).toUpperCase()).append(parts[i].substring(1));
}
return sb.toString();
}
}

View file

@ -1,9 +1,11 @@
package io.lbry.browser.reactmodules;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
@ -12,6 +14,7 @@ import com.google.firebase.analytics.FirebaseAnalytics;
import io.lbry.browser.BuildConfig;
import io.lbry.browser.MainActivity;
import io.lbry.browser.Utils;
import java.util.HashMap;
import java.util.Map;
@ -36,10 +39,16 @@ public class FirebaseModule extends ReactContextBaseJavaModule {
}
@ReactMethod
public void setCurrentScreen(String name) {
if (firebaseAnalytics != null) {
firebaseAnalytics.setCurrentScreen(MainActivity.getActivity(), name, null);
public void setCurrentScreen(String name, final Promise promise) {
final Activity activity = getCurrentActivity();
if (activity != null && firebaseAnalytics != null) {
activity.runOnUiThread(new Runnable() {
public void run() {
firebaseAnalytics.setCurrentScreen(activity, name, Utils.capitalizeAndStrip(name));
}
});
}
promise.resolve(true);
}
@ReactMethod