<commit_before>package co.fixt.react.digits; 

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;

import com.digits.sdk.android.AuthCallback;
import com.digits.sdk.android.Digits;
import com.digits.sdk.android.DigitsException;
import com.digits.sdk.android.DigitsOAuthSigning;
import com.digits.sdk.android.DigitsSession;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;

import com.twitter.sdk.android.core.TwitterAuthConfig;
import com.twitter.sdk.android.core.TwitterAuthToken;
import com.twitter.sdk.android.core.TwitterCore;

import io.fabric.sdk.android.Fabric;

import java.util.Map;

public final class RNDigits extends ReactContextBaseJavaModule {
  // Note: Your consumer key and secret should be obfuscated in your source code before shipping.
  private static final String FABRIC_KEY = "io.fabric.ApiKey";
  private static final String FABRIC_SECRET = "io.fabric.ApiSecret";
  private static final String TAG = "RNDigits";
  private ReactApplicationContext mContext;

  public RNDigits(ReactApplicationContext reactContext) {
    super(reactContext);
    mContext = reactContext;
  }

  @Override
  public String getName() {
    return "RNDigits";
  }

  @ReactMethod
  public void logout() {
    Digits.getSessionManager().clearActiveSession(); 
  }

  @ReactMethod
  public void view(final Callback cb) {
    TwitterAuthConfig authConfig = getTwitterConfig();
    Fabric.with(mContext, new TwitterCore(authConfig), new Digits());

    AuthCallback callback = new AuthCallback() {
      @Override
      public void success(DigitsSession session, String phoneNumber){
        WritableMap auth = Arguments.createMap();

        Digits digits = Digits.getInstance();

        TwitterAuthConfig config = digits.getAuthConfig();
        auth.putString("consumerKey", config.getConsumerKey());
        auth.putString("consumerSecret", config.getConsumerSecret());

        TwitterAuthToken token = (TwitterAuthToken)session.getAuthToken();

        auth.putString("authToken", token.token);
        auth.putString("authTokenSecret", token.secret);

        Long id = session.getId();
        auth.putString("userId", String.valueOf(id));
        auth.putString("phoneNumber", session.getPhoneNumber());

        cb.invoke(null, auth);
      }

      @Override
      public void failure(DigitsException error) {
        cb.invoke(error.getLocalizedMessage(), null);
      }
    };  

    Digits.authenticate(callback);
  }

  private TwitterAuthConfig getTwitterConfig() {
    String key = getMetaData(FABRIC_KEY);
    String secret = getMetaData(FABRIC_SECRET);

    return new TwitterAuthConfig(key, secret);
  }
  
  private String getMetaData(String name) {
    try {
      ApplicationInfo ai = mContext.getPackageManager().getApplicationInfo(
        mContext.getPackageName(),
        PackageManager.GET_META_DATA
      );

      Bundle metaData = ai.metaData;
      if(metaData == null) {
        Log.w(TAG, "metaData is null. Unable to get meta data for " + name);
      } else {
        String value = metaData.getString(name);
        return value;
      }
    } catch (PackageManager.NameNotFoundException e) {
      e.printStackTrace();
    }
    return null; 
  }
}

<commit_msg>adds code to use custom theme<commit_after>package co.fixt.react.digits; 

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;

import com.digits.sdk.android.AuthCallback;
import com.digits.sdk.android.Digits;
import com.digits.sdk.android.DigitsException;
import com.digits.sdk.android.DigitsOAuthSigning;
import com.digits.sdk.android.DigitsSession;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableMap;

import com.twitter.sdk.android.core.TwitterAuthConfig;
import com.twitter.sdk.android.core.TwitterAuthToken;
import com.twitter.sdk.android.core.TwitterCore;

import io.fabric.sdk.android.Fabric;

import java.util.Map;

public final class RNDigits extends ReactContextBaseJavaModule {
  // Note: Your consumer key and secret should be obfuscated in your source code before shipping.
  private static final String FABRIC_KEY = "io.fabric.ApiKey";
  private static final String FABRIC_SECRET = "io.fabric.ApiSecret";
  private static final String TAG = "RNDigits";
  private ReactApplicationContext mContext;

  public RNDigits(ReactApplicationContext reactContext) {
    super(reactContext);
    mContext = reactContext;
  }

  @Override
  public String getName() {
    return "RNDigits";
  }

  @ReactMethod
  public void logout() {
    Digits.getSessionManager().clearActiveSession(); 
  }

  @ReactMethod
  public void view(final Callback cb) {
    TwitterAuthConfig authConfig = getTwitterConfig();
    Fabric.with(mContext, new TwitterCore(authConfig), new Digits());

    AuthCallback callback = new AuthCallback() {
      @Override
      public void success(DigitsSession session, String phoneNumber){
        WritableMap auth = Arguments.createMap();

        Digits digits = Digits.getInstance();

        TwitterAuthConfig config = digits.getAuthConfig();
        auth.putString("consumerKey", config.getConsumerKey());
        auth.putString("consumerSecret", config.getConsumerSecret());

        TwitterAuthToken token = (TwitterAuthToken)session.getAuthToken();

        auth.putString("authToken", token.token);
        auth.putString("authTokenSecret", token.secret);

        Long id = session.getId();
        auth.putString("userId", String.valueOf(id));
        auth.putString("phoneNumber", session.getPhoneNumber());

        cb.invoke(null, auth);
      }

      @Override
      public void failure(DigitsException error) {
        cb.invoke(error.getLocalizedMessage(), null);
      }
    };  

    int themeId = mContext.getResources().getIdentifier("CustomDigitsTheme", "style", mContext.getPackageName());
    Digits.authenticate(callback, themeId);
  }

  private TwitterAuthConfig getTwitterConfig() {
    String key = getMetaData(FABRIC_KEY);
    String secret = getMetaData(FABRIC_SECRET);

    return new TwitterAuthConfig(key, secret);
  }
  
  private String getMetaData(String name) {
    try {
      ApplicationInfo ai = mContext.getPackageManager().getApplicationInfo(
        mContext.getPackageName(),
        PackageManager.GET_META_DATA
      );

      Bundle metaData = ai.metaData;
      if(metaData == null) {
        Log.w(TAG, "metaData is null. Unable to get meta data for " + name);
      } else {
        String value = metaData.getString(name);
        return value;
      }
    } catch (PackageManager.NameNotFoundException e) {
      e.printStackTrace();
    }
    return null; 
  }
}


{'fraction_non_alphanumeric': 0.10272565401999727, 'fraction_numerical': 0.0, 'mean_word_length': 3.8357615894039734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4597393', 'n_tokens_mistral': 2140, 'n_tokens_neox': 2086, 'n_words': 443}