package io.keybase.ossifrage;

import android.annotation.TargetApi;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactRootView;

import java.io.File;
import java.io.IOException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;

import go.keybase.Keybase;

import static go.keybase.Keybase.initOnce;
import static go.keybase.Keybase.logSend;

public class MainActivity extends ReactActivity {
    private static final String TAG = MainActivity.class.getName();
    private File logFile;

    @Override
    @TargetApi(Build.VERSION_CODES.KITKAT)
    protected void onCreate(Bundle savedInstanceState) {
        logFile = this.getFileStreamPath("android.log");
        initOnce(this.getFilesDir().getPath(), logFile.getAbsolutePath(), "staging", false);

        try {
            Keybase.setGlobalExternalKeyStore(new KeyStore(this, getSharedPreferences("KeyStore", MODE_PRIVATE)));
        } catch (KeyStoreException | CertificateException | IOException | NoSuchAlgorithmException e) {
            e.printStackTrace();
        }

        super.onCreate(savedInstanceState);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (BuildConfig.DEBUG && keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            try {
                final String id = logSend(logFile.getAbsolutePath());
                Log.d(TAG, "LOG id is: " + id);
            } catch (Exception e) {
                Log.d(TAG, "Error in log sending:", e);
            }
            return super.onKeyUp(KeyEvent.KEYCODE_MENU, null);
        }
        return super.onKeyUp(keyCode, event);
    }

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "Keybase";
    }
}

@@ -950,159 +950,8 @@
 ) %7B%0A
-        logFile = this.getFileStreamPath(%22android.log%22);%0A        initOnce(this.getFilesDir().getPath(), logFile.getAbsolutePath(), %22staging%22, false);%0A%0A
     
@@ -1219,24 +1219,175 @@
 %0A        %7D%0A%0A
+        logFile = this.getFileStreamPath(%22android.log%22);%0A        initOnce(this.getFilesDir().getPath(), logFile.getAbsolutePath(), %22staging%22, false);%0A%0A
         supe

Fix Android secret store initialization