diff --git a/src/main/java/io/lbry/browser/Utils.java b/src/main/java/io/lbry/browser/Utils.java index f7b9f2f4..e86f078f 100644 --- a/src/main/java/io/lbry/browser/Utils.java +++ b/src/main/java/io/lbry/browser/Utils.java @@ -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(); + } } diff --git a/src/main/java/io/lbry/browser/reactmodules/FirebaseModule.java b/src/main/java/io/lbry/browser/reactmodules/FirebaseModule.java index ae467244..38839a45 100644 --- a/src/main/java/io/lbry/browser/reactmodules/FirebaseModule.java +++ b/src/main/java/io/lbry/browser/reactmodules/FirebaseModule.java @@ -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