<NME> QRUtils.java
<BEF> ADDFILE
<MSG> cleanup keystore, use context instead of activity (too limited)

<DFF> @@ -0,0 +1,87 @@
+package com.breadwallet.tools.qrcode;
+
+import android.graphics.Bitmap;
+
+import com.google.zxing.BarcodeFormat;
+import com.google.zxing.EncodeHintType;
+import com.google.zxing.MultiFormatWriter;
+import com.google.zxing.WriterException;
+import com.google.zxing.common.BitMatrix;
+
+import java.util.EnumMap;
+import java.util.Map;
+
+import static android.graphics.Color.BLACK;
+import static android.graphics.Color.WHITE;
+
+/**
+ * BreadWallet
+ * <p/>
+ * Created by Mihail Gutan on <mihail@breadwallet.com> 3/10/17.
+ * Copyright (c) 2017 breadwallet LLC
+ * <p/>
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * <p/>
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * <p/>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+public class QRUtils {
+
+
+    public static Bitmap encodeAsBitmap(String content, int dimension) throws WriterException {
+
+        if (content == null) {
+            return null;
+        }
+        Map<EncodeHintType, Object> hints = null;
+        String encoding = guessAppropriateEncoding(content);
+        hints = new EnumMap<>(EncodeHintType.class);
+        if (encoding != null) {
+            hints.put(EncodeHintType.CHARACTER_SET, encoding);
+        }
+        hints.put(EncodeHintType.MARGIN, 1);
+        BitMatrix result;
+        try {
+            result = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, dimension, dimension, hints);
+        } catch (IllegalArgumentException iae) {
+            // Unsupported format
+            return null;
+        }
+        int width = result.getWidth();
+        int height = result.getHeight();
+        int[] pixels = new int[width * height];
+        for (int y = 0; y < height; y++) {
+            int offset = y * width;
+            for (int x = 0; x < width; x++) {
+                pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;
+            }
+        }
+
+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
+        return bitmap;
+    }
+
+    private static String guessAppropriateEncoding(CharSequence contents) {
+        // Very crude at the moment
+        for (int i = 0; i < contents.length(); i++) {
+            if (contents.charAt(i) > 0xFF) {
+                return "UTF-8";
+            }
+        }
+        return null;
+    }
+}

{'commit': 'diff --git a/app/src/main/java/com/breadwallet/presenter/activities/BreadActivity.java b/app/src/main/java/com/breadwallet/presenter/activities/BreadActivity.java\nindex 6c8b052cb..564153c0e 100644\n--- a/app/src/main/java/com/breadwallet/presenter/activities/BreadActivity.java\n+++ b/app/src/main/java/com/breadwallet/presenter/activities/BreadActivity.java\n@@ -53,7 +53,6 @@ import static com.breadwallet.tools.util.BRConstants.PLATFORM_ON;\n public class BreadActivity extends AppCompatActivity implements Observer {\n     private static final String TAG = BreadActivity.class.getName();\n \n-    public static BreadActivity app;\n     private LinearLayout sendButton;\n     private LinearLayout receiveButton;\n     private LinearLayout menuButton;\n@@ -205,14 +204,12 @@ public class BreadActivity extends AppCompatActivity implements Observer {\n     @Override\n     protected void onRestart() {\n         super.onRestart();\n-        app = this;\n     }\n \n     @Override\n     protected void onResume() {\n         super.onResume();\n         appInBackground = false;\n-        app = this;\n \n //        new Thread(new Runnable() {\n //            @Override\n@@ -247,7 +244,7 @@ public class BreadActivity extends AppCompatActivity implements Observer {\n //            @Override\n //            public void run() {\n //                if (SharedPreferencesManager.getPhraseWroteDown(app)) return;\n-//                long balance = CurrencyManager.getInstance(app).getBALANCE();\n+//                long balance = CurrencyManager.getInstance(app).getBalance();\n //                int limit = SharedPreferencesManager.getLimit(app);\n //                if (balance > limit)\n //                    BRWalletManager.getInstance(app).animateSavePhraseFlow();\ndiff --git a/app/src/main/java/com/breadwallet/presenter/activities/IntroActivity.java b/app/src/main/java/com/breadwallet/presenter/activities/IntroActivity.java\nindex 3fb57143b..c441afb65 100644\n--- a/app/src/main/java/com/breadwallet/presenter/activities/IntroActivity.java\n+++ b/app/src/main/java/com/breadwallet/presenter/activities/IntroActivity.java\n@@ -23,6 +23,8 @@ import com.breadwallet.tools.util.BRConstants;\n import com.breadwallet.wallet.BRWalletManager;\n import com.google.firebase.crash.FirebaseCrash;\n \n+import static com.breadwallet.presenter.activities.MainActivity.app;\n+\n \n /**\n  * BreadWallet\n@@ -51,7 +53,6 @@ import com.google.firebase.crash.FirebaseCrash;\n \n public class IntroActivity extends FragmentActivity {\n     private static final String TAG = IntroActivity.class.getName();\n-    public static IntroActivity app;\n     public Button newWalletButton;\n     public Button recoverWalletButton;\n \n@@ -65,7 +66,6 @@ public class IntroActivity extends FragmentActivity {\n     @Override\n     protected void onRestart() {\n         super.onRestart();  // Always call the superclass method first\n-        app = this;\n     }\n \n     @Override\n@@ -76,8 +76,6 @@ public class IntroActivity extends FragmentActivity {\n         recoverWalletButton = (Button) findViewById(R.id.button_recover_wallet);\n         setListeners();\n \n-        app = this;\n-\n         if (!BuildConfig.DEBUG && KeyStoreManager.AUTH_DURATION_SEC != 300) {\n             Log.e(TAG, "onCreate: KeyStoreManager.AUTH_DURATION_SEC != 300");\n             RuntimeException ex = new RuntimeException("AUTH_DURATION_SEC should be 300");\n@@ -143,7 +141,6 @@ public class IntroActivity extends FragmentActivity {\n     @Override\n     protected void onResume() {\n         super.onResume();\n-        app = this;\n \n     }\n \n@@ -226,7 +223,7 @@ public class IntroActivity extends FragmentActivity {\n             //Device passcode/password should be enabled for the app to work\n             ((BreadWalletApp) getApplication()).showDeviceNotSecuredWarning(this);\n         } else {\n-            if (!m.noWallet(app)) {\n+            if (!m.noWallet(this)) {\n                 BRWalletManager.getInstance(this).startBreadActivity(this);\n             }\n \ndiff --git a/app/src/main/java/com/breadwallet/presenter/activities/MainActivity.java b/app/src/main/java/com/breadwallet/presenter/activities/MainActivity.java\nindex f8693ea21..f68b1051e 100644\n--- a/app/src/main/java/com/breadwallet/presenter/activities/MainActivity.java\n+++ b/app/src/main/java/com/breadwallet/presenter/activities/MainActivity.java\n@@ -50,7 +50,6 @@ import com.breadwallet.tools.security.KeyStoreManager;\n import com.breadwallet.tools.util.Utils;\n import com.breadwallet.wallet.BRPeerManager;\n import com.breadwallet.wallet.BRWalletManager;\n-import com.google.firebase.crash.FirebaseCrash;\n import com.platform.APIClient;\n import com.platform.middlewares.plugins.CameraPlugin;\n import com.platform.middlewares.plugins.GeoLocationPlugin;\n@@ -293,7 +292,7 @@ public class MainActivity extends FragmentActivity implements Observer {\n     }\n \n     private void checkDeviceRooted() {\n-        final boolean hasBitcoin = BRWalletManager.getInstance(this).getBALANCE() > 0;\n+        final boolean hasBitcoin = BRWalletManager.getInstance(this).getBalance() > 0;\n         boolean isDebuggable = 0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE);\n         if (RootHelper.isDeviceRooted() && !isDebuggable) {\n \n@@ -375,7 +374,7 @@ public class MainActivity extends FragmentActivity implements Observer {\n             @Override\n             public void run() {\n                 if (SharedPreferencesManager.getPhraseWroteDown(app)) return;\n-                long balance = BRWalletManager.getInstance(app).getBALANCE();\n+                long balance = BRWalletManager.getInstance(app).getBalance();\n                 int limit = SharedPreferencesManager.getLimit(app);\n                 if (balance > limit)\n                     BRWalletManager.getInstance(app).animateSavePhraseFlow();\ndiff --git a/app/src/main/java/com/breadwallet/presenter/activities/PhraseFlowActivity.java b/app/src/main/java/com/breadwallet/presenter/activities/PhraseFlowActivity.java\nindex d05d04cb5..4053187bb 100644\n--- a/app/src/main/java/com/breadwallet/presenter/activities/PhraseFlowActivity.java\n+++ b/app/src/main/java/com/breadwallet/presenter/activities/PhraseFlowActivity.java\n@@ -176,7 +176,7 @@ public class PhraseFlowActivity extends Activity {\n //            animateSlide(fragmentPhraseFlow3, fragmentPhraseFlow2, IntroActivity.LEFT);\n //            fragmentPhraseFlow2.setPhrase(fragmentPhraseFlow3.getPhrase());\n //        } else {\n-//            if (CurrencyManager.getInstance(this).getBALANCE() > SharedPreferencesManager.getLimit(this)\n+//            if (CurrencyManager.getInstance(this).getBalance() > SharedPreferencesManager.getLimit(this)\n //                    && !SharedPreferencesManager.getPhraseWroteDown(this)) {\n //                super.onBackPressed();\n //            } else {\ndiff --git a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentPhraseFlow1.java b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentPhraseFlow1.java\nindex 5f75bbe87..7dcbe6fa8 100644\n--- a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentPhraseFlow1.java\n+++ b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentPhraseFlow1.java\n@@ -2,32 +2,21 @@\n package com.breadwallet.presenter.fragments;\n \n import android.app.Fragment;\n-import android.content.Context;\n-import android.content.Intent;\n-import android.content.pm.PackageInfo;\n-import android.content.pm.PackageManager;\n import android.graphics.Typeface;\n-import android.os.Build;\n import android.os.Bundle;\n import android.view.LayoutInflater;\n import android.view.MotionEvent;\n import android.view.View;\n import android.view.ViewGroup;\n-import android.view.inputmethod.InputMethodManager;\n import android.widget.Button;\n import android.widget.TextView;\n \n import com.breadwallet.BreadWalletApp;\n import com.breadwallet.R;\n-import com.breadwallet.presenter.activities.IntroActivity;\n-import com.breadwallet.presenter.activities.MainActivity;\n import com.breadwallet.presenter.activities.PhraseFlowActivity;\n-import com.breadwallet.tools.adapter.MiddleViewAdapter;\n import com.breadwallet.tools.animation.BRAnimator;\n-import com.breadwallet.tools.manager.CurrencyManager;\n import com.breadwallet.tools.manager.SharedPreferencesManager;\n import com.breadwallet.tools.security.KeyStoreManager;\n-import com.breadwallet.tools.security.PostAuthenticationProcessor;\n import com.breadwallet.tools.util.BRConstants;\n import com.breadwallet.tools.util.BRStringFormatter;\n import com.breadwallet.wallet.BRWalletManager;\n@@ -98,7 +87,7 @@ public class FragmentPhraseFlow1 extends Fragment {\n                 return true;\n             }\n         });\n-        if (BRWalletManager.getInstance(getActivity()).getBALANCE() > limit\n+        if (BRWalletManager.getInstance(getActivity()).getBalance() > limit\n                 && !SharedPreferencesManager.getPhraseWroteDown(getActivity())) {\n             TextView title = (TextView) rootView.findViewById(R.id.warning_flow);\n             TextView textFlow1 = (TextView) rootView.findViewById(R.id.textFlow1);\ndiff --git a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentPhraseFlow3.java b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentPhraseFlow3.java\nindex d359c4ae0..bce1ca315 100644\n--- a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentPhraseFlow3.java\n+++ b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentPhraseFlow3.java\n@@ -111,7 +111,7 @@ public class FragmentPhraseFlow3 extends Fragment {\n //                return true;\n //            }\n //        });\n-//        if (CurrencyManager.getInstance(getActivity()).getBALANCE() > SharedPreferencesManager.getLimit(getActivity())) {\n+//        if (CurrencyManager.getInstance(getActivity()).getBalance() > SharedPreferencesManager.getLimit(getActivity())) {\n //            skipButton.setVisibility(View.GONE);\n //        }\n //        skipButton.setOnClickListener(new View.OnClickListener() {\ndiff --git a/app/src/main/java/com/breadwallet/tools/manager/CurrencyManager.java b/app/src/main/java/com/breadwallet/tools/manager/CurrencyManager.java\nindex 2be8c1029..b5bf67d91 100644\n--- a/app/src/main/java/com/breadwallet/tools/manager/CurrencyManager.java\n+++ b/app/src/main/java/com/breadwallet/tools/manager/CurrencyManager.java\n@@ -77,11 +77,6 @@ public class CurrencyManager  {\n         return instance;\n     }\n \n-\n-\n-\n-\n-\n     private Set<CurrencyEntity> getCurrencies(Activity context) {\n         Set<CurrencyEntity> set = new LinkedHashSet<>();\n         if (((BreadWalletApp) ctx.getApplication()).hasInternetAccess()) {\ndiff --git a/app/src/main/java/com/breadwallet/tools/manager/SharedPreferencesManager.java b/app/src/main/java/com/breadwallet/tools/manager/SharedPreferencesManager.java\nindex e48389aef..c740c7411 100644\n--- a/app/src/main/java/com/breadwallet/tools/manager/SharedPreferencesManager.java\n+++ b/app/src/main/java/com/breadwallet/tools/manager/SharedPreferencesManager.java\n@@ -60,12 +60,12 @@ public class SharedPreferencesManager {\n     public static final String TAG = SharedPreferencesManager.class.getName();\n \n \n-    public static String getIso(Activity context) {\n+    public static String getIso(Context context) {\n         SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         return settingsToGet.getString(BRConstants.CURRENT_CURRENCY, Currency.getInstance(Locale.getDefault()).getCurrencyCode());\n     }\n \n-    public static void putIso(Activity context, String code) {\n+    public static void putIso(Context context, String code) {\n         SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         SharedPreferences.Editor editor = settings.edit();\n         editor.putString(BRConstants.CURRENT_CURRENCY, code.equalsIgnoreCase(Locale.getDefault().getISO3Language()) ? null : code);\n@@ -73,25 +73,25 @@ public class SharedPreferencesManager {\n \n     }\n \n-    public static float getRate(Activity context) {\n+    public static float getRate(Context context) {\n         SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         return settingsToGet.getFloat(BRConstants.RATE, 1);\n     }\n \n-    public static void putRate(Activity context, float rate) {\n+    public static void putRate(Context context, float rate) {\n         SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         SharedPreferences.Editor editor = settings.edit();\n         editor.putFloat(BRConstants.RATE, rate);\n         editor.apply();\n     }\n \n-    public static boolean getPhraseWroteDown(Activity context) {\n+    public static boolean getPhraseWroteDown(Context context) {\n         SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getBoolean(BRConstants.PHRASE_WRITTEN, false);\n \n     }\n \n-    public static void putPhraseWroteDown(Activity context, boolean check) {\n+    public static void putPhraseWroteDown(Context context, boolean check) {\n         SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putBoolean(BRConstants.PHRASE_WRITTEN, check);\n@@ -103,87 +103,87 @@ public class SharedPreferencesManager {\n         return settings.getInt(BRConstants.POSITION, 0);\n     }\n \n-    public static void putCurrencyListPosition(Activity context, int lastItemsPosition) {\n+    public static void putCurrencyListPosition(Context context, int lastItemsPosition) {\n         SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         SharedPreferences.Editor editor = settings.edit();\n         editor.putInt(BRConstants.POSITION, lastItemsPosition);\n         editor.apply();\n     }\n \n-    public static String getReceiveAddress(Activity context) {\n+    public static String getReceiveAddress(Context context) {\n         SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getString(BRConstants.RECEIVE_ADDRESS, "");\n     }\n \n-    public static void putReceiveAddress(Activity ctx, String tmpAddr) {\n+    public static void putReceiveAddress(Context ctx, String tmpAddr) {\n         SharedPreferences.Editor editor = ctx.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE).edit();\n         editor.putString(BRConstants.RECEIVE_ADDRESS, tmpAddr);\n         editor.apply();\n     }\n \n-    public static String getFirstAddress(Activity context) {\n+    public static String getFirstAddress(Context context) {\n         SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getString(BRConstants.FIRST_ADDRESS, "");\n     }\n \n-    public static void putFirstAddress(Activity context, String firstAddress) {\n+    public static void putFirstAddress(Context context, String firstAddress) {\n         SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putString(BRConstants.FIRST_ADDRESS, firstAddress);\n         editor.apply();\n     }\n \n-    public static long getFeePerKb(Activity context) {\n+    public static long getFeePerKb(Context context) {\n         SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getLong(BRConstants.FEE_KB_PREFS, 0);\n     }\n \n-    public static void putFeePerKb(Activity context, long fee) {\n+    public static void putFeePerKb(Context context, long fee) {\n         SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putLong(BRConstants.FEE_KB_PREFS, fee);\n         editor.apply();\n     }\n \n-    public static long getSecureTime(Activity activity) {\n+    public static long getSecureTime(Context activity) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getLong(BRConstants.SECURE_TIME_PREFS, System.currentTimeMillis() / 1000);\n     }\n \n     //secure time from the server\n-    public static void putSecureTime(Activity activity, long date) {\n+    public static void putSecureTime(Context activity, long date) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putLong(BRConstants.SECURE_TIME_PREFS, date);\n         editor.apply();\n     }\n \n-    public static long getPhraseWarningTime(Activity activity) {\n+    public static long getPhraseWarningTime(Context activity) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getLong(BRConstants.PHRASE_WARNING_TIME, 0);\n     }\n \n \n-    public static void putPhraseWarningTime(Activity activity, long phraseWarningTime) {\n+    public static void putPhraseWarningTime(Context activity, long phraseWarningTime) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putLong(BRConstants.PHRASE_WARNING_TIME, phraseWarningTime);\n         editor.apply();\n     }\n \n-    public static int getLimit(Activity activity) {\n+    public static int getLimit(Context activity) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getInt(BRConstants.LIMIT_PREFS, BRConstants.HUNDRED_BITS);\n     }\n \n-    public static void putLimit(Activity activity, int limit) {\n+    public static void putLimit(Context activity, int limit) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putInt(BRConstants.LIMIT_PREFS, limit);\n         editor.apply();\n     }\n \n-    public static List<Integer> getBitIdNonces(Activity activity, String key) {\n+    public static List<Integer> getBitIdNonces(Context activity, String key) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         String result = prefs.getString(key, null);\n         List<Integer> list = new ArrayList<>();\n@@ -201,7 +201,7 @@ public class SharedPreferencesManager {\n         return list;\n     }\n \n-    public static void putBitIdNonces(Activity activity, List<Integer> nonces, String key) {\n+    public static void putBitIdNonces(Context activity, List<Integer> nonces, String key) {\n         JSONArray arr = new JSONArray();\n         arr.put(nonces);\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n@@ -210,36 +210,36 @@ public class SharedPreferencesManager {\n         editor.apply();\n     }\n \n-    public static boolean getAllowSpend(Activity activity) {\n+    public static boolean getAllowSpend(Context activity) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getBoolean(BRConstants.ALLOW_SPEND, true);\n     }\n \n-    public static void putAllowSpend(Activity activity, boolean allow) {\n+    public static void putAllowSpend(Context activity, boolean allow) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putBoolean(BRConstants.ALLOW_SPEND, allow);\n         editor.apply();\n     }\n \n-    public static boolean getFeatureEnabled(Activity activity, String feature) {\n+    public static boolean getFeatureEnabled(Context activity, String feature) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getBoolean(feature, false);\n     }\n \n-    public static void putFeatureEnabled(Activity activity, boolean enabled, String feature) {\n+    public static void putFeatureEnabled(Context activity, boolean enabled, String feature) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putBoolean(feature, enabled);\n         editor.apply();\n     }\n \n-    public static boolean getGeoPermissionsRequested(Activity activity) {\n+    public static boolean getGeoPermissionsRequested(Context activity) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         return prefs.getBoolean(GEO_PERMISSIONS_REQUESTED, false);\n     }\n \n-    public static void putGeoPermissionsRequested(Activity activity, boolean requested) {\n+    public static void putGeoPermissionsRequested(Context activity, boolean requested) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.putBoolean(GEO_PERMISSIONS_REQUESTED, requested);\n@@ -248,7 +248,7 @@ public class SharedPreferencesManager {\n \n \n     @SuppressWarnings("unchecked")\n-    public static Set<CurrencyEntity> getExchangeRates(Activity context) {\n+    public static Set<CurrencyEntity> getExchangeRates(Context context) {\n         SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n \n         byte[] bytes = prefs.getString(BRConstants.EXCHANGE_RATES, "{}").getBytes();\n@@ -269,7 +269,7 @@ public class SharedPreferencesManager {\n         return result;\n     }\n \n-    public static void putExchangeRates(Activity activity, Set<CurrencyEntity> rates) {\n+    public static void putExchangeRates(Context activity, Set<CurrencyEntity> rates) {\n         SharedPreferences prefs = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE);\n         SharedPreferences.Editor editor = prefs.edit();\n         editor.remove(BRConstants.EXCHANGE_RATES);\n@@ -297,12 +297,12 @@ public class SharedPreferencesManager {\n     }\n \n \n-    public static int getStartHeight(Activity context) {\n+    public static int getStartHeight(Context context) {\n         SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         return settingsToGet.getInt(BRConstants.START_HEIGHT, 0);\n     }\n \n-    public static void putStartHeight(Activity context, int startHeight) {\n+    public static void putStartHeight(Context context, int startHeight) {\n         if (context == null) return;\n         SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         SharedPreferences.Editor editor = settings.edit();\n@@ -310,12 +310,12 @@ public class SharedPreferencesManager {\n         editor.apply();\n     }\n \n-    public static int getLastBlockHeight(Activity context) {\n+    public static int getLastBlockHeight(Context context) {\n         SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         return settingsToGet.getInt(BRConstants.LAST_BLOCK_HEIGHT, 0);\n     }\n \n-    public static void putLastBlockHeight(Activity context, int lastHeight) {\n+    public static void putLastBlockHeight(Context context, int lastHeight) {\n         if (context == null) return;\n         SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         SharedPreferences.Editor editor = settings.edit();\n@@ -323,12 +323,12 @@ public class SharedPreferencesManager {\n         editor.apply();\n     }\n \n-    public static boolean getTipsShown(Activity context) {\n+    public static boolean getTipsShown(Context context) {\n         SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         return settingsToGet.getBoolean(BRConstants.TIPS_SHOWN, false);\n     }\n \n-    public static void putTipsShown(Activity context, boolean tipsShown) {\n+    public static void putTipsShown(Context context, boolean tipsShown) {\n         if (context == null) return;\n         SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         SharedPreferences.Editor editor = settings.edit();\n@@ -336,12 +336,12 @@ public class SharedPreferencesManager {\n         editor.apply();\n     }\n \n-    public static int getCurrencyUnit(Activity context) {\n+    public static int getCurrencyUnit(Context context) {\n         SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         return settingsToGet.getInt(BRConstants.CURRENT_UNIT, BRConstants.CURRENT_UNIT_BITS);\n     }\n \n-    public static void putCurrencyUnit(Activity context, int unit) {\n+    public static void putCurrencyUnit(Context context, int unit) {\n         if (context == null) return;\n         SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         SharedPreferences.Editor editor = settings.edit();\n@@ -349,14 +349,14 @@ public class SharedPreferencesManager {\n         editor.apply();\n     }\n \n-    public static String getDeviceId(Activity context) {\n+    public static String getDeviceId(Context context) {\n         SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         String deviceId = settingsToGet.getString(BRConstants.USER_ID, "");\n         if (deviceId.isEmpty()) setDeviceId(context, UUID.randomUUID().toString());\n         return (settingsToGet.getString(BRConstants.USER_ID, ""));\n     }\n \n-    private static void setDeviceId(Activity context, String uuid) {\n+    private static void setDeviceId(Context context, String uuid) {\n         if (context == null) return;\n         SharedPreferences settings = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);\n         SharedPreferences.Editor editor = settings.edit();\n@@ -364,7 +364,7 @@ public class SharedPreferencesManager {\n         editor.apply();\n     }\n \n-    public static void clearAllPrefs(Activity activity) {\n+    public static void clearAllPrefs(Context activity) {\n         SharedPreferences.Editor editor = activity.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE).edit();\n         editor.clear();\n         editor.apply();\ndiff --git a/app/src/main/java/com/breadwallet/tools/qrcode/QRUtils.java b/app/src/main/java/com/breadwallet/tools/qrcode/QRUtils.java\nnew file mode 100644\nindex 000000000..66eeb5134\n--- /dev/null\n+++ b/app/src/main/java/com/breadwallet/tools/qrcode/QRUtils.java\n@@ -0,0 +1,87 @@\n+package com.breadwallet.tools.qrcode;\n+\n+import android.graphics.Bitmap;\n+\n+import com.google.zxing.BarcodeFormat;\n+import com.google.zxing.EncodeHintType;\n+import com.google.zxing.MultiFormatWriter;\n+import com.google.zxing.WriterException;\n+import com.google.zxing.common.BitMatrix;\n+\n+import java.util.EnumMap;\n+import java.util.Map;\n+\n+import static android.graphics.Color.BLACK;\n+import static android.graphics.Color.WHITE;\n+\n+/**\n+ * BreadWallet\n+ * <p/>\n+ * Created by Mihail Gutan on <mihail@breadwallet.com> 3/10/17.\n+ * Copyright (c) 2017 breadwallet LLC\n+ * <p/>\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the "Software"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ * <p/>\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ * <p/>\n+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+public class QRUtils {\n+\n+\n+    public static Bitmap encodeAsBitmap(String content, int dimension) throws WriterException {\n+\n+        if (content == null) {\n+            return null;\n+        }\n+        Map<EncodeHintType, Object> hints = null;\n+        String encoding = guessAppropriateEncoding(content);\n+        hints = new EnumMap<>(EncodeHintType.class);\n+        if (encoding != null) {\n+            hints.put(EncodeHintType.CHARACTER_SET, encoding);\n+        }\n+        hints.put(EncodeHintType.MARGIN, 1);\n+        BitMatrix result;\n+        try {\n+            result = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, dimension, dimension, hints);\n+        } catch (IllegalArgumentException iae) {\n+            // Unsupported format\n+            return null;\n+        }\n+        int width = result.getWidth();\n+        int height = result.getHeight();\n+        int[] pixels = new int[width * height];\n+        for (int y = 0; y < height; y++) {\n+            int offset = y * width;\n+            for (int x = 0; x < width; x++) {\n+                pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;\n+            }\n+        }\n+\n+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);\n+        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);\n+        return bitmap;\n+    }\n+\n+    private static String guessAppropriateEncoding(CharSequence contents) {\n+        // Very crude at the moment\n+        for (int i = 0; i < contents.length(); i++) {\n+            if (contents.charAt(i) > 0xFF) {\n+                return "UTF-8";\n+            }\n+        }\n+        return null;\n+    }\n+}\ndiff --git a/app/src/main/java/com/breadwallet/tools/security/KeyStoreManager.java b/app/src/main/java/com/breadwallet/tools/security/KeyStoreManager.java\nindex ea974bed1..faa80094c 100644\n--- a/app/src/main/java/com/breadwallet/tools/security/KeyStoreManager.java\n+++ b/app/src/main/java/com/breadwallet/tools/security/KeyStoreManager.java\n@@ -149,7 +149,7 @@ public class KeyStoreManager {\n \n     private static android.app.AlertDialog dialog;\n \n-    private static boolean _setData(Activity context, byte[] data, String alias, String alias_file, String alias_iv, int request_code, boolean auth_required) throws BRKeystoreErrorException {\n+    private static boolean _setData(Context context, byte[] data, String alias, String alias_file, String alias_iv, int request_code, boolean auth_required) throws BRKeystoreErrorException {\n //        Log.e(TAG, "_setData: " + alias);\n         if (alias.equals(alias_file) || alias.equals(alias_iv) || alias_file.equals(alias_iv)) {\n             RuntimeException ex = new IllegalArgumentException("mistake in parameters!");\n@@ -216,7 +216,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    private static byte[] _getData(final Activity context, String alias, String alias_file, String alias_iv, int request_code)\n+    private static byte[] _getData(final Context context, String alias, String alias_file, String alias_iv, int request_code)\n             throws BRKeystoreErrorException {\n //        Log.e(TAG, "_getData: " + alias);\n \n@@ -267,7 +267,7 @@ public class KeyStoreManager {\n                 throw new BRKeystoreErrorException(e.getMessage());\n             } else if (e instanceof KeyPermanentlyInvalidatedException) {\n                 FirebaseCrash.report(new RuntimeException("KeyStore Error, Your Breadwallet encrypted data was recently invalidated because you disabled your Android lock screen. Please input your phrase to recover your Breadwallet now."));\n-                showKeyStoreDialog("KeyStore Error", "Your Breadwallet encrypted data was recently invalidated because you " +\n+                showKeyStoreDialog(context,"KeyStore Error", "Your Breadwallet encrypted data was recently invalidated because you " +\n                                 "disabled your Android lock screen. Please input your phrase to recover your Breadwallet now.", context.getString(R.string.ok), null,\n                         new DialogInterface.OnClickListener() {\n                             public void onClick(DialogInterface dialog, int which) {\n@@ -317,35 +317,36 @@ public class KeyStoreManager {\n         return filesDirectory + File.separator + fileName;\n     }\n \n-    private static void showKeyStoreFailedToLoad(final Activity context) {\n-        showKeyStoreDialog("KeyStore Error", "Failed to load KeyStore. Please try again later or enter your phrase to recover your Breadwallet now.", "recover now", "try later",\n-                context instanceof IntroActivity ?\n-                        new DialogInterface.OnClickListener() {\n-                            public void onClick(DialogInterface dialog, int which) {\n-                                if (BRAnimator.checkTheMultipressingAvailability()) {\n-//                                    ((IntroActivity) context).showRecoverWalletFragment();\n-                                }\n-                            }\n-                        } : null, new DialogInterface.OnClickListener() {\n-                    public void onClick(DialogInterface dialog, int which) {\n-                        context.finish();\n-                    }\n-                },\n-                null);\n+    private static void showKeyStoreFailedToLoad(final Context context) {\n+        //todo finish\n+//        showKeyStoreDialog(context,"KeyStore Error", "Failed to load KeyStore. Please try again later or enter your phrase to recover your Breadwallet now.", "recover now", "try later",\n+//                context instanceof IntroActivity ?\n+//                        new DialogInterface.OnClickListener() {\n+//                            public void onClick(DialogInterface dialog, int which) {\n+//                                if (BRAnimator.checkTheMultipressingAvailability()) {\n+////                                    ((IntroActivity) context).showRecoverWalletFragment();\n+//                                }\n+//                            }\n+//                        } : null, new DialogInterface.OnClickListener() {\n+//                    public void onClick(DialogInterface dialog, int which) {\n+//                        context.finish();\n+//                    }\n+//                },\n+//                null);\n     }\n \n-    public static boolean putKeyStorePhrase(byte[] strToStore, Activity context, int requestCode) throws BRKeystoreErrorException {\n+    public static boolean putKeyStorePhrase(byte[] strToStore, Context context, int requestCode) throws BRKeystoreErrorException {\n         AliasObject obj = aliasObjectMap.get(PHRASE_ALIAS);\n         return !(strToStore == null || strToStore.length == 0) && _setData(context, strToStore, obj.alias, obj.datafileName, obj.ivFileName, requestCode, true);\n     }\n \n-    public static byte[] getKeyStorePhrase(final Activity context, int requestCode)\n+    public static byte[] getKeyStorePhrase(final Context context, int requestCode)\n             throws BRKeystoreErrorException {\n         AliasObject obj = aliasObjectMap.get(PHRASE_ALIAS);\n         return _getData(context, obj.alias, obj.datafileName, obj.ivFileName, requestCode);\n     }\n \n-    public static boolean putKeyStoreCanary(String strToStore, Activity context, int requestCode) throws BRKeystoreErrorException {\n+    public static boolean putKeyStoreCanary(String strToStore, Context context, int requestCode) throws BRKeystoreErrorException {\n         if (strToStore == null || strToStore.isEmpty()) return false;\n         AliasObject obj = aliasObjectMap.get(CANARY_ALIAS);\n         byte[] strBytes = new byte[0];\n@@ -357,7 +358,7 @@ public class KeyStoreManager {\n         return strBytes.length != 0 && _setData(context, strBytes, obj.alias, obj.datafileName, obj.ivFileName, requestCode, true);\n     }\n \n-    public static String getKeyStoreCanary(final Activity context, int requestCode)\n+    public static String getKeyStoreCanary(final Context context, int requestCode)\n             throws BRKeystoreErrorException {\n         AliasObject obj = aliasObjectMap.get(CANARY_ALIAS);\n         byte[] data = _getData(context, obj.alias, obj.datafileName, obj.ivFileName, requestCode);\n@@ -370,7 +371,7 @@ public class KeyStoreManager {\n         return result;\n     }\n \n-    public static boolean putMasterPublicKey(byte[] masterPubKey, Activity context) {\n+    public static boolean putMasterPublicKey(byte[] masterPubKey, Context context) {\n         AliasObject obj = aliasObjectMap.get(PUB_KEY_ALIAS);\n         try {\n             return masterPubKey != null && masterPubKey.length != 0 && _setData(context, masterPubKey, obj.alias, obj.datafileName, obj.ivFileName, 0, false);\n@@ -380,7 +381,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static byte[] getMasterPublicKey(final Activity context) {\n+    public static byte[] getMasterPublicKey(final Context context) {\n         byte[] result = new byte[0];\n         AliasObject obj = aliasObjectMap.get(PUB_KEY_ALIAS);\n         try {\n@@ -391,7 +392,7 @@ public class KeyStoreManager {\n         return result;\n     }\n \n-    public static boolean putAuthKey(byte[] authKey, Activity context) {\n+    public static boolean putAuthKey(byte[] authKey, Context context) {\n         AliasObject obj = aliasObjectMap.get(AUTH_KEY_ALIAS);\n         try {\n             return authKey != null && authKey.length != 0 && _setData(context, authKey, obj.alias, obj.datafileName, obj.ivFileName, 0, false);\n@@ -401,7 +402,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static byte[] getAuthKey(final Activity context) {\n+    public static byte[] getAuthKey(final Context context) {\n         AliasObject obj = aliasObjectMap.get(AUTH_KEY_ALIAS);\n         byte[] result = new byte[0];\n         try {\n@@ -412,7 +413,7 @@ public class KeyStoreManager {\n         return result;\n     }\n \n-    public static boolean putToken(byte[] token, Activity context) {\n+    public static boolean putToken(byte[] token, Context context) {\n         AliasObject obj = aliasObjectMap.get(TOKEN_ALIAS);\n         try {\n             return token != null && token.length != 0 && _setData(context, token, obj.alias, obj.datafileName, obj.ivFileName, 0, false);\n@@ -422,7 +423,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static byte[] getToken(final Activity context) {\n+    public static byte[] getToken(final Context context) {\n         AliasObject obj = aliasObjectMap.get(TOKEN_ALIAS);\n         byte[] result = new byte[0];\n         try {\n@@ -433,7 +434,7 @@ public class KeyStoreManager {\n         return result;\n     }\n \n-    public static boolean putWalletCreationTime(int creationTime, Activity context) {\n+    public static boolean putWalletCreationTime(int creationTime, Context context) {\n         AliasObject obj = aliasObjectMap.get(WALLET_CREATION_TIME_ALIAS);\n         byte[] bytesToStore = TypesConverter.intToBytes(creationTime);\n         try {\n@@ -444,7 +445,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static int getWalletCreationTime(final Activity context) {\n+    public static int getWalletCreationTime(final Context context) {\n         AliasObject obj = aliasObjectMap.get(WALLET_CREATION_TIME_ALIAS);\n         byte[] result = new byte[0];\n         try {\n@@ -455,7 +456,7 @@ public class KeyStoreManager {\n         return result.length > 0 ? TypesConverter.bytesToInt(result) : 0;\n     }\n \n-    public static boolean putPassCode(String passcode, Activity context) {\n+    public static boolean putPassCode(String passcode, Context context) {\n         Log.e(TAG, "putPassCode: " + passcode);\n         AliasObject obj = aliasObjectMap.get(PASS_CODE_ALIAS);\n         byte[] bytesToStore = passcode.getBytes();\n@@ -467,7 +468,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static String getPassCode(final Activity context) {\n+    public static String getPassCode(final Context context) {\n         AliasObject obj = aliasObjectMap.get(PASS_CODE_ALIAS);\n         byte[] result = new byte[0];\n         try {\n@@ -494,7 +495,7 @@ public class KeyStoreManager {\n         return passCode;\n     }\n \n-    public static boolean putFailCount(int failCount, Activity context) {\n+    public static boolean putFailCount(int failCount, Context context) {\n         AliasObject obj = aliasObjectMap.get(FAIL_COUNT_ALIAS);\n         if (failCount >= 3) {\n             long time = SharedPreferencesManager.getSecureTime(context);\n@@ -509,7 +510,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static int getFailCount(final Activity context) {\n+    public static int getFailCount(final Context context) {\n         AliasObject obj = aliasObjectMap.get(FAIL_COUNT_ALIAS);\n         byte[] result = new byte[0];\n         try {\n@@ -521,7 +522,7 @@ public class KeyStoreManager {\n         return result.length > 0 ? TypesConverter.bytesToInt(result) : 0;\n     }\n \n-    public static boolean putSpendLimit(long spendLimit, Activity context) {\n+    public static boolean putSpendLimit(long spendLimit, Context context) {\n         AliasObject obj = aliasObjectMap.get(SPEND_LIMIT_ALIAS);\n         byte[] bytesToStore = TypesConverter.long2byteArray(spendLimit);\n         try {\n@@ -532,7 +533,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static long getSpendLimit(final Activity context) {\n+    public static long getSpendLimit(final Context context) {\n         AliasObject obj = aliasObjectMap.get(SPEND_LIMIT_ALIAS);\n         byte[] result = new byte[0];\n         try {\n@@ -544,7 +545,7 @@ public class KeyStoreManager {\n         return result.length > 0 ? TypesConverter.byteArray2long(result) : 0;\n     }\n \n-    public static boolean putFailTimeStamp(long spendLimit, Activity context) {\n+    public static boolean putFailTimeStamp(long spendLimit, Context context) {\n         AliasObject obj = aliasObjectMap.get(FAIL_TIMESTAMP_ALIAS);\n         byte[] bytesToStore = TypesConverter.long2byteArray(spendLimit);\n         try {\n@@ -555,7 +556,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static long getFailTimeStamp(final Activity context) {\n+    public static long getFailTimeStamp(final Context context) {\n         AliasObject obj = aliasObjectMap.get(FAIL_TIMESTAMP_ALIAS);\n         byte[] result = new byte[0];\n         try {\n@@ -567,7 +568,7 @@ public class KeyStoreManager {\n         return result.length > 0 ? TypesConverter.byteArray2long(result) : 0;\n     }\n \n-    public static boolean putLastPasscodeUsedTime(long time, Activity context) {\n+    public static boolean putLastPasscodeUsedTime(long time, Context context) {\n         AliasObject obj = aliasObjectMap.get(PASS_TIME_ALIAS);\n         byte[] bytesToStore = TypesConverter.long2byteArray(time);\n         try {\n@@ -578,7 +579,7 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static long getLastPasscodeUsedTime(final Activity context) {\n+    public static long getLastPasscodeUsedTime(final Context context) {\n         AliasObject obj = aliasObjectMap.get(PASS_TIME_ALIAS);\n         byte[] result = new byte[0];\n         try {\n@@ -589,11 +590,11 @@ public class KeyStoreManager {\n         return result.length > 0 ? TypesConverter.byteArray2long(result) : 0;\n     }\n \n-    public static boolean phraseIsValid(String insertedPhrase, Activity activity) {\n+    public static boolean phraseIsValid(String insertedPhrase, Context activity) {\n         String normalizedPhrase = Normalizer.normalize(insertedPhrase.trim(), Normalizer.Form.NFKD);\n-        if (!BRWalletManager.getInstance(activity).validatePhrase(activity, normalizedPhrase))\n+        if (!BRWalletManager.getInstance().validatePhrase(activity, normalizedPhrase))\n             return false;\n-        BRWalletManager m = BRWalletManager.getInstance(activity);\n+        BRWalletManager m = BRWalletManager.getInstance();\n         byte[] rawPhrase = normalizedPhrase.getBytes();\n         byte[] bytePhrase = TypesConverter.getNullTerminatedPhrase(rawPhrase);\n         byte[] pubKey = m.getMasterPubKey(bytePhrase);\n@@ -612,7 +613,7 @@ public class KeyStoreManager {\n                 removeAliasAndFiles(keyStore.aliases().nextElement(), context);\n                 count++;\n             }\n-//            Assert.assertEquals(count, 11);\n+            Assert.assertEquals(count, 11);\n \n         } catch (NoSuchAlgorithmException e) {\n             e.printStackTrace();\n@@ -644,17 +645,17 @@ public class KeyStoreManager {\n \n     }\n \n-    public static void showAuthenticationScreen(Activity context, int requestCode) {\n+    public static void showAuthenticationScreen(Context context, int requestCode) {\n         // Create the Confirm Credentials screen. You can customize the title and description. Or\n         // we will provide a generic one for you if you leave it null\n         KeyguardManager mKeyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);\n         Intent intent = mKeyguardManager.createConfirmDeviceCredentialIntent(context.getString(R.string.auth_required), context.getString(R.string.auth_message));\n         if (intent != null) {\n-            context.startActivityForResult(intent, requestCode);\n+            ((Activity)context).startActivityForResult(intent, requestCode);\n         } else {\n             Log.e(TAG, "showAuthenticationScreen: failed to create intent for auth");\n             FirebaseCrash.report(new RuntimeException("showAuthenticationScreen: failed to create intent for auth"));\n-            context.finish();\n+            ((Activity)context).finish();\n         }\n     }\n \n@@ -699,16 +700,14 @@ public class KeyStoreManager {\n         return false;\n     }\n \n-    public static void showKeyStoreDialog(final String title, final String message, final String posButton, final String negButton,\n+    public static void showKeyStoreDialog(Context app,final String title, final String message, final String posButton, final String negButton,\n                                           final DialogInterface.OnClickListener posButtonListener,\n                                           final DialogInterface.OnClickListener negButtonListener,\n                                           final DialogInterface.OnDismissListener dismissListener) {\n-        Activity app = MainActivity.app;\n-        if (app == null) app = IntroActivity.app;\n         if (app == null) {\n             return;\n         }\n-        final Activity finalApp = app;\n+        final Activity finalApp = (Activity) app;\n         if (finalApp != null)\n             finalApp.runOnUiThread(new Runnable() {\n                 @Override\ndiff --git a/app/src/main/java/com/breadwallet/tools/security/PostAuthenticationProcessor.java b/app/src/main/java/com/breadwallet/tools/security/PostAuthenticationProcessor.java\nindex 09d627577..a1c9916cd 100644\n--- a/app/src/main/java/com/breadwallet/tools/security/PostAuthenticationProcessor.java\n+++ b/app/src/main/java/com/breadwallet/tools/security/PostAuthenticationProcessor.java\n@@ -271,7 +271,7 @@ public class PostAuthenticationProcessor {\n             m.wipeKeyStore(app);\n             m.wipeWalletButKeystore(app);\n             BRAnimator.resetFragmentAnimator();\n-            KeyStoreManager.showKeyStoreDialog("Keystore invalidated", "Disable lock screen and all fingerprints, and re-enable to continue.", app.getString(R.string.ok), null,\n+            KeyStoreManager.showKeyStoreDialog(app, "Keystore invalidated", "Disable lock screen and all fingerprints, and re-enable to continue.", app.getString(R.string.ok), null,\n                     new DialogInterface.OnClickListener() {\n                         public void onClick(DialogInterface dialog, int which) {\n                             dialog.cancel();\ndiff --git a/app/src/main/java/com/breadwallet/tools/util/BRStringFormatter.java b/app/src/main/java/com/breadwallet/tools/util/BRStringFormatter.java\nindex cf0f8ee52..609dec274 100644\n--- a/app/src/main/java/com/breadwallet/tools/util/BRStringFormatter.java\n+++ b/app/src/main/java/com/breadwallet/tools/util/BRStringFormatter.java\n@@ -1,7 +1,6 @@\n package com.breadwallet.tools.util;\n \n import android.app.Activity;\n-import android.util.Log;\n \n import com.breadwallet.presenter.activities.MainActivity;\n import com.breadwallet.tools.manager.CurrencyManager;\n@@ -75,10 +74,10 @@ public class BRStringFormatter {\n         CurrencyManager cm = CurrencyManager.getInstance(ctx);\n         String iso = SharedPreferencesManager.getIso(ctx);\n         double rate = SharedPreferencesManager.getRate(ctx);\n-        long exchange = BRWalletManager.getInstance(ctx).localAmount(BRWalletManager.getInstance(ctx).getBALANCE(),\n+        long exchange = BRWalletManager.getInstance(ctx).localAmount(BRWalletManager.getInstance(ctx).getBalance(),\n                 new BigDecimal(String.valueOf(rate)).multiply(new BigDecimal("100")).doubleValue());\n \n-        return getFormattedCurrencyString("BTC", BRWalletManager.getInstance(ctx).getBALANCE()) + " (" +\n+        return getFormattedCurrencyString("BTC", BRWalletManager.getInstance(ctx).getBalance()) + " (" +\n                 getFormattedCurrencyString(iso, exchange) + ")";\n     }\n \ndiff --git a/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java b/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java\nindex 68d141580..d9d308b9f 100644\n--- a/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java\n+++ b/app/src/main/java/com/breadwallet/wallet/BRWalletManager.java\n@@ -24,7 +24,6 @@ import android.widget.Toast;\n import com.breadwallet.R;\n import com.breadwallet.BreadWalletApp;\n import com.breadwallet.exceptions.BRKeystoreErrorException;\n-import com.breadwallet.presenter.activities.BreadActivity;\n import com.breadwallet.presenter.activities.IntroActivity;\n import com.breadwallet.presenter.activities.MainActivity;\n import com.breadwallet.presenter.activities.PhraseFlowActivity;\n@@ -38,8 +37,7 @@ import com.breadwallet.presenter.entities.PaymentRequestEntity;\n import com.breadwallet.presenter.entities.TransactionListItem;\n import com.breadwallet.presenter.fragments.FragmentScanResult;\n import com.breadwallet.presenter.fragments.FragmentSettingsAll;\n-import com.breadwallet.presenter.fragments.MainFragmentQR;\n-import com.breadwallet.presenter.fragments.PasswordDialogFragment;\n+import com.breadwallet.tools.qrcode.QRUtils;\n import com.breadwallet.tools.threads.PaymentProtocolPostPaymentTask;\n import com.breadwallet.tools.util.BRConstants;\n import com.breadwallet.tools.manager.BRNotificationManager;\n@@ -48,7 +46,6 @@ import com.breadwallet.tools.manager.CurrencyManager;\n import com.breadwallet.tools.manager.SharedPreferencesManager;\n import com.breadwallet.tools.util.TypesConverter;\n import com.breadwallet.tools.util.WordsReader;\n-import com.breadwallet.tools.adapter.CustomPagerAdapter;\n import com.breadwallet.tools.animation.BRAnimator;\n import com.breadwallet.tools.animation.SpringAnimator;\n import com.breadwallet.tools.security.KeyStoreManager;\n@@ -61,13 +58,11 @@ import com.google.zxing.EncodeHintType;\n import com.google.zxing.MultiFormatWriter;\n import com.google.zxing.WriterException;\n import com.google.zxing.common.BitMatrix;\n-import com.jniwrappers.BRKey;\n \n import junit.framework.Assert;\n \n import java.io.IOException;\n import java.math.BigDecimal;\n-import java.security.Key;\n import java.security.SecureRandom;\n import java.util.EnumMap;\n import java.util.List;\n@@ -76,6 +71,7 @@ import java.util.Map;\n import java.util.Observable;\n \n import static com.breadwallet.presenter.activities.MainActivity.app;\n+import static com.breadwallet.tools.qrcode.QRUtils.encodeAsBitmap;\n \n /**\n  * BreadWallet\n@@ -106,20 +102,21 @@ public class BRWalletManager extends Observable {\n     private static final String TAG = BRWalletManager.class.getName();\n \n     private static BRWalletManager instance;\n-    private static Activity ctx;\n     private static final int WHITE = 0xFFFFFFFF;\n     private static final int BLACK = 0xFF000000;\n \n-    private long BALANCE = 0;\n+    private long balance = 0;\n \n     public void setBalance(long balance) {\n-        BALANCE = balance;\n+        this.balance = balance;\n         setChanged();\n         notifyObservers();\n+        refreshAddress();\n+        FragmentSettingsAll.refreshTransactions(ctx);\n     }\n \n-    public long getBALANCE() {\n-        return BALANCE;\n+    public long getBalance() {\n+        return balance;\n     }\n \n     private static int messageId = 0;\n@@ -127,15 +124,14 @@ public class BRWalletManager extends Observable {\n     private BRWalletManager() {\n     }\n \n-    public static BRWalletManager getInstance(Activity context) {\n-        ctx = context;\n+    public static BRWalletManager getInstance() {\n         if (instance == null) {\n             instance = new BRWalletManager();\n         }\n         return instance;\n     }\n \n-    public boolean generateRandomSeed() {\n+    public boolean generateRandomSeed(Context ctx) {\n         SecureRandom sr = new SecureRandom();\n         String[] words = new String[0];\n         List<String> list;\n@@ -175,7 +171,7 @@ public class BRWalletManager extends Observable {\n         KeyStoreManager.putAuthKey(authKey, ctx);\n         KeyStoreManager.putWalletCreationTime((int) (System.currentTimeMillis() / 1000), ctx);\n         byte[] strBytes = TypesConverter.getNullTerminatedPhrase(strPhrase);\n-        byte[] pubKey = BRWalletManager.getInstance(ctx).getMasterPubKey(strBytes);\n+        byte[] pubKey = BRWalletManager.getInstance().getMasterPubKey(strBytes);\n         KeyStoreManager.putMasterPublicKey(pubKey, ctx);\n \n         return true;\n@@ -190,7 +186,7 @@ public class BRWalletManager extends Observable {\n     /**\n      * true if keychain is available and we know that no wallet exists on it\n      */\n-    public boolean noWallet(Activity ctx) {\n+    public boolean noWallet(Context ctx) {\n         byte[] pubkey = KeyStoreManager.getMasterPublicKey(ctx);\n \n         if (pubkey == null || pubkey.length == 0) {\n@@ -223,19 +219,18 @@ public class BRWalletManager extends Observable {\n     }\n \n     public static void refreshAddress() {\n-        if (ctx == null) ctx = app;\n-        if (ctx != null) {\n-            MainFragmentQR mainFragmentQR = CustomPagerAdapter.adapter == null ? null : CustomPagerAdapter.adapter.mainFragmentQR;\n-            String tmpAddr = getReceiveAddress();\n-            if (tmpAddr == null || tmpAddr.isEmpty()) return;\n-            SharedPreferencesManager.putReceiveAddress(ctx, tmpAddr);\n-            if (mainFragmentQR == null) return;\n-            mainFragmentQR.refreshAddress(tmpAddr);\n-        } else {\n-            RuntimeException ex = new NullPointerException("Cannot be null");\n-            FirebaseCrash.report(ex);\n-            throw ex;\n-        }\n+//        if (ctx != null) {\n+//            MainFragmentQR mainFragmentQR = CustomPagerAdapter.adapter == null ? null : CustomPagerAdapter.adapter.mainFragmentQR;\n+//            String tmpAddr = getReceiveAddress();\n+//            if (tmpAddr == null || tmpAddr.isEmpty()) return;\n+//            SharedPreferencesManager.putReceiveAddress(ctx, tmpAddr);\n+//            if (mainFragmentQR == null) return;\n+//            mainFragmentQR.refreshAddress(tmpAddr);\n+//        } else {\n+//            RuntimeException ex = new NullPointerException("Cannot be null");\n+//            FirebaseCrash.report(ex);\n+//            throw ex;\n+//        }\n     }\n \n     public void wipeWalletButKeystore(final Activity activity) {\n@@ -255,18 +250,18 @@ public class BRWalletManager extends Observable {\n         SharedPreferencesManager.clearAllPrefs(activity);\n     }\n \n-    public boolean confirmSweep(final Activity activity, final String privKey) {\n-        if (activity == null) return false;\n+    public boolean confirmSweep(final Activity ctx, final String privKey) {\n+        if (ctx == null) return false;\n         if (isValidBitcoinBIP38Key(privKey)) {\n             Log.d(TAG, "isValidBitcoinBIP38Key true");\n-            activity.runOnUiThread(new Runnable() {\n+            ctx.runOnUiThread(new Runnable() {\n                 @Override\n                 public void run() {\n \n-                    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);\n+                    final AlertDialog.Builder builder = new AlertDialog.Builder(ctx);\n //                    builder.setTitle("password protected key");\n \n-                    final View input = activity.getLayoutInflater().inflate(R.layout.view_bip38password_dialog, null);\n+                    final View input = ctx.getLayoutInflater().inflate(R.layout.view_bip38password_dialog, null);\n                     // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text\n                     builder.setView(input);\n \n@@ -284,11 +279,11 @@ public class BRWalletManager extends Observable {\n                     builder.setPositiveButton(ctx.getString(R.string.ok), new DialogInterface.OnClickListener() {\n                         @Override\n                         public void onClick(DialogInterface dialog, int which) {\n-                            if (!((BreadWalletApp) activity.getApplication()).hasInternetAccess()) {\n+                            if (!((BreadWalletApp) ctx.getApplication()).hasInternetAccess()) {\n                                 ctx.runOnUiThread(new Runnable() {\n                                     @Override\n                                     public void run() {\n-                                        ((BreadWalletApp) activity.getApplication()).showCustomDialog(activity.getString(R.string.warning),\n+                                        ((BreadWalletApp) ctx.getApplication()).showCustomDialog(activity.getString(R.string.warning),\n                                                 activity.getString(R.string.not_connected), activity.getString(R.string.ok));\n                                     }\n                                 });\n@@ -310,9 +305,9 @@ public class BRWalletManager extends Observable {\n \n                             if (decryptedKey.equals("")) {\n                                 SpringAnimator.showAnimation(input);\n-                                confirmSweep(activity, privKey);\n+                                confirmSweep(ctx, privKey);\n                             } else {\n-                                confirmSweep(activity, decryptedKey);\n+                                confirmSweep(ctx, decryptedKey);\n                             }\n \n                         }\n@@ -330,7 +325,7 @@ public class BRWalletManager extends Observable {\n             return true;\n         } else if (isValidBitcoinPrivateKey(privKey)) {\n             Log.d(TAG, "isValidBitcoinPrivateKey true");\n-            new ImportPrivKeyTask(activity).execute(privKey);\n+            new ImportPrivKeyTask(ctx).execute(privKey);\n             return true;\n         } else {\n             Log.e(TAG, "confirmSweep: !isValidBitcoinPrivateKey && !isValidBitcoinBIP38Key");\n@@ -338,7 +333,7 @@ public class BRWalletManager extends Observable {\n         }\n     }\n \n-    public static void showWritePhraseDialog(final boolean firstTime) {\n+    public static void showWritePhraseDialog(Activity ctx, final boolean firstTime) {\n \n         if (ctx == null) ctx = app;\n         if (ctx != null) {\n@@ -351,7 +346,7 @@ public class BRWalletManager extends Observable {\n                     long lastMessageShow = SharedPreferencesManager.getPhraseWarningTime(ctx);\n                     if (lastMessageShow == 0 || (!firstTime && lastMessageShow > (now - 36 * 60 * 60)))\n                         return;//36 * 60 * 60//\n-                    if (BRWalletManager.getInstance(ctx).getBALANCE() > SharedPreferencesManager.getLimit(ctx)) {\n+                    if (BRWalletManager.getInstance(ctx).getBalance() > SharedPreferencesManager.getLimit(ctx)) {\n //                        getInstance(ctx).animateSavePhraseFlow();\n                         return;\n                     }\n@@ -396,40 +391,26 @@ public class BRWalletManager extends Observable {\n     public static void publishCallback(final String message, int error) {\n         PaymentProtocolPostPaymentTask.waiting = false;\n         if (error != 0) {\n-            ctx.runOnUiThread(new Runnable() {\n-                @Override\n-                public void run() {\n-                    if (!PaymentProtocolPostPaymentTask.waiting && !PaymentProtocolPostPaymentTask.sent) {\n-\n-                        if (PaymentProtocolPostPaymentTask.pendingErrorMessages.get(PaymentProtocolPostPaymentTask.MESSAGE) != null) {\n-                            ((BreadWalletApp) ctx.getApplication()).\n-                                    showCustomDialog(PaymentProtocolPostPaymentTask.pendingErrorMessages.get(PaymentProtocolPostPaymentTask.TITLE),\n-                                            PaymentProtocolPostPaymentTask.pendingErrorMessages.get(PaymentProtocolPostPaymentTask.MESSAGE), ctx.getString(R.string.ok));\n-                            PaymentProtocolPostPaymentTask.pendingErrorMessages = null;\n-                        } else {\n-                            ((BreadWalletApp) ctx.getApplication()).showCustomToast(ctx, message,\n-                                    MainActivity.screenParametersPoint.y / 2, Toast.LENGTH_LONG, 1);\n-                        }\n-                    }\n+            if (!PaymentProtocolPostPaymentTask.waiting && !PaymentProtocolPostPaymentTask.sent) {\n+                if (PaymentProtocolPostPaymentTask.pendingErrorMessages.get(PaymentProtocolPostPaymentTask.MESSAGE) != null) {\n+                    ((BreadWalletApp) ctx.getApplication()).\n+                            showCustomDialog(PaymentProtocolPostPaymentTask.pendingErrorMessages.get(PaymentProtocolPostPaymentTask.TITLE),\n+                                    PaymentProtocolPostPaymentTask.pendingErrorMessages.get(PaymentProtocolPostPaymentTask.MESSAGE), ctx.getString(R.string.ok));\n+                    PaymentProtocolPostPaymentTask.pendingErrorMessages = null;\n+                } else {\n+                    ((BreadWalletApp) ctx.getApplication()).showCustomToast(ctx, message,\n+                            MainActivity.screenParametersPoint.y / 2, Toast.LENGTH_LONG, 1);\n                 }\n-            });\n+            }\n         } else {\n             PaymentProtocolPostPaymentTask.sent = true;\n         }\n     }\n \n     public static void onBalanceChanged(final long balance) {\n-\n         Log.d(TAG, "onBalanceChanged:  " + balance);\n         if (ctx == null) ctx = app;\n-        ctx.runOnUiThread(new Runnable() {\n-            @Override\n-            public void run() {\n-                BRWalletManager.getInstance(ctx).setBalance(balance);\n-                refreshAddress();\n-                FragmentSettingsAll.refreshTransactions(ctx);\n-            }\n-        });\n+        BRWalletManager.getInstance(ctx).setBalance(balance);\n \n     }\n \n@@ -656,7 +637,7 @@ public class BRWalletManager extends Observable {\n                     return;\n                 }\n                 feeForTx = m.feeForTransaction(request.addresses[0], maxAmountDouble);\n-                feeForTx += (getBALANCE() - request.amount) % 100;\n+                feeForTx += (getBalance() - request.amount) % 100;\n             }\n             final long total = request.amount + feeForTx;\n             final String message = certification + allAddresses.toString() + "\\n\\n" + "amount: " + BRStringFormatter.getFormattedCurrencyString("BTC", request.amount)\n@@ -762,7 +743,7 @@ public class BRWalletManager extends Observable {\n         byte[] tmpTx = m.tryTransaction(addressHolder, bigDecimalAmount.longValue());\n         long feeForTx = m.feeForTransaction(addressHolder, bigDecimalAmount.longValue());\n \n-        if (tmpTx == null && bigDecimalAmount.longValue() <= getBALANCE() && bigDecimalAmount.longValue() > 0) {\n+        if (tmpTx == null && bigDecimalAmount.longValue() <= getBalance() && bigDecimalAmount.longValue() > 0) {\n             final long maxAmountDouble = m.getMaxOutputAmount();\n             if (maxAmountDouble == -1) {\n                 RuntimeException ex = new RuntimeException("getMaxOutputAmount is -1, meaning _wallet is NULL");\n@@ -820,7 +801,7 @@ public class BRWalletManager extends Observable {\n             alert.show();\n             alert.getButton(AlertDialog.BUTTON_POSITIVE).setAllCaps(false);\n             return;\n-        } else if (tmpTx == null && bigDecimalAmount.longValue() >= getBALANCE() && bigDecimalAmount.longValue() > 0) {\n+        } else if (tmpTx == null && bigDecimalAmount.longValue() >= getBalance() && bigDecimalAmount.longValue() > 0) {\n \n             FragmentScanResult.address = addressHolder;\n             if (!BreadWalletApp.unlocked) {\n@@ -837,8 +818,8 @@ public class BRWalletManager extends Observable {\n         }\n         PostAuthenticationProcessor.getInstance().setTmpTx(tmpTx);\n         Log.d(TAG, "pay: feeForTx: " + feeForTx + ", amountAsDouble: " + bigDecimalAmount.longValue() +\n-                ", CurrencyManager.getInstance(this).getBALANCE(): " + getBALANCE());\n-        if ((feeForTx != 0 && bigDecimalAmount.longValue() + feeForTx < getBALANCE()) || (isAmountRequested && !BreadWalletApp.unlocked)) {\n+                ", CurrencyManager.getInstance(this).getBalance(): " + getBalance());\n+        if ((feeForTx != 0 && bigDecimalAmount.longValue() + feeForTx < getBalance()) || (isAmountRequested && !BreadWalletApp.unlocked)) {\n             Log.d(TAG, "pay: SUCCESS: going to confirmPay");\n             confirmPay(new PaymentRequestEntity(new String[]{addressHolder}, bigDecimalAmount.longValue(), cn, tmpTx, isAmountRequested));\n         } else {\n@@ -932,9 +913,8 @@ public class BRWalletManager extends Observable {\n             }).start();\n     }\n \n-    public void generateQR(String bitcoinURL, ImageView qrcode) {\n+    public void generateQR(Activity app,String bitcoinURL, ImageView qrcode) {\n         if (qrcode == null || bitcoinURL == null || bitcoinURL.isEmpty()) return;\n-        if (ctx == null) ctx = app;\n         WindowManager manager = (WindowManager) ctx.getSystemService(Activity.WINDOW_SERVICE);\n         Display display = manager.getDefaultDisplay();\n         Point point = new Point();\n@@ -945,7 +925,7 @@ public class BRWalletManager extends Observable {\n         smallerDimension = (int) (smallerDimension * 0.7f);\n         Bitmap bitmap = null;\n         try {\n-            bitmap = encodeAsBitmap(bitcoinURL, smallerDimension);\n+            bitmap = QRUtils.encodeAsBitmap(bitcoinURL, smallerDimension);\n         } catch (WriterException e) {\n             e.printStackTrace();\n         }\n@@ -955,50 +935,6 @@ public class BRWalletManager extends Observable {\n \n     }\n \n-    private Bitmap encodeAsBitmap(String content, int dimension) throws WriterException {\n-\n-        if (content == null) {\n-            return null;\n-        }\n-        Map<EncodeHintType, Object> hints = null;\n-        String encoding = guessAppropriateEncoding(content);\n-        hints = new EnumMap<>(EncodeHintType.class);\n-        if (encoding != null) {\n-            hints.put(EncodeHintType.CHARACTER_SET, encoding);\n-        }\n-        hints.put(EncodeHintType.MARGIN, 1);\n-        BitMatrix result;\n-        try {\n-            result = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, dimension, dimension, hints);\n-        } catch (IllegalArgumentException iae) {\n-            // Unsupported format\n-            return null;\n-        }\n-        int width = result.getWidth();\n-        int height = result.getHeight();\n-        int[] pixels = new int[width * height];\n-        for (int y = 0; y < height; y++) {\n-            int offset = y * width;\n-            for (int x = 0; x < width; x++) {\n-                pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;\n-            }\n-        }\n-\n-        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);\n-        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);\n-        return bitmap;\n-    }\n-\n-    private static String guessAppropriateEncoding(CharSequence contents) {\n-        // Very crude at the moment\n-        for (int i = 0; i < contents.length(); i++) {\n-            if (contents.charAt(i) > 0xFF) {\n-                return "UTF-8";\n-            }\n-        }\n-        return null;\n-    }\n-\n     public void offerToChangeTheAmount(Activity app, String title) {\n \n         new AlertDialog.Builder(app)\n@@ -1019,19 +955,19 @@ public class BRWalletManager extends Observable {\n                 .show();\n     }\n \n-    public void animateSavePhraseFlow() {\n-        PhraseFlowActivity.screenParametersPoint = IntroActivity.screenParametersPoint;\n-        if (PhraseFlowActivity.screenParametersPoint == null ||\n-                PhraseFlowActivity.screenParametersPoint.y == 0 ||\n-                PhraseFlowActivity.screenParametersPoint.x == 0)\n-            PhraseFlowActivity.screenParametersPoint = MainActivity.screenParametersPoint;\n-        Intent intent;\n-        intent = new Intent(ctx, PhraseFlowActivity.class);\n-        ctx.startActivity(intent);\n-        if (!ctx.isDestroyed()) {\n-            ctx.finish();\n-        }\n-    }\n+//    public void animateSavePhraseFlow() {\n+//        PhraseFlowActivity.screenParametersPoint = IntroActivity.screenParametersPoint;\n+//        if (PhraseFlowActivity.screenParametersPoint == null ||\n+//                PhraseFlowActivity.screenParametersPoint.y == 0 ||\n+//                PhraseFlowActivity.screenParametersPoint.x == 0)\n+//            PhraseFlowActivity.screenParametersPoint = MainActivity.screenParametersPoint;\n+//        Intent intent;\n+//        intent = new Intent(ctx, PhraseFlowActivity.class);\n+//        ctx.startActivity(intent);\n+//        if (!ctx.isDestroyed()) {\n+//            ctx.finish();\n+//        }\n+//    }\n \n     private static void showSpendNotAllowed(final MainActivity app) {\n         Log.d(TAG, "showSpendNotAllowed");\n', 'commit_subject': 'cleanup keystore, use context instead of activity (too limited)', 'repo_name': 'breadwallet/breadwallet-android', 'committer': {'name': 'Gutyn', 'email': '890e5834d074cef10299f00169972c87a1ea7f5a@gmail.com', 'time_sec': '1489193916', 'tz_offset': '-480', 'date': {'seconds': '1489193916'}}, 'commit_tree': 'bf8414457c9bac4165a781cd2c91260d823fcd94', 'commit_message': 'cleanup keystore, use context instead of activity (too limited)\n', 'language_name': 'Ruby', 'license': 'mit', 'hunks': '@@ -0,0 +1,87 @@\n+package com.breadwallet.tools.qrcode;\n+\n+import android.graphics.Bitmap;\n+\n+import com.google.zxing.BarcodeFormat;\n+import com.google.zxing.EncodeHintType;\n+import com.google.zxing.MultiFormatWriter;\n+import com.google.zxing.WriterException;\n+import com.google.zxing.common.BitMatrix;\n+\n+import java.util.EnumMap;\n+import java.util.Map;\n+\n+import static android.graphics.Color.BLACK;\n+import static android.graphics.Color.WHITE;\n+\n+/**\n+ * BreadWallet\n+ * <p/>\n+ * Created by Mihail Gutan on <mihail@breadwallet.com> 3/10/17.\n+ * Copyright (c) 2017 breadwallet LLC\n+ * <p/>\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the "Software"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ * <p/>\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ * <p/>\n+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+public class QRUtils {\n+\n+\n+    public static Bitmap encodeAsBitmap(String content, int dimension) throws WriterException {\n+\n+        if (content == null) {\n+            return null;\n+        }\n+        Map<EncodeHintType, Object> hints = null;\n+        String encoding = guessAppropriateEncoding(content);\n+        hints = new EnumMap<>(EncodeHintType.class);\n+        if (encoding != null) {\n+            hints.put(EncodeHintType.CHARACTER_SET, encoding);\n+        }\n+        hints.put(EncodeHintType.MARGIN, 1);\n+        BitMatrix result;\n+        try {\n+            result = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, dimension, dimension, hints);\n+        } catch (IllegalArgumentException iae) {\n+            // Unsupported format\n+            return null;\n+        }\n+        int width = result.getWidth();\n+        int height = result.getHeight();\n+        int[] pixels = new int[width * height];\n+        for (int y = 0; y < height; y++) {\n+            int offset = y * width;\n+            for (int x = 0; x < width; x++) {\n+                pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;\n+            }\n+        }\n+\n+        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);\n+        bitmap.setPixels(pixels, 0, width, 0, 0, width, height);\n+        return bitmap;\n+    }\n+\n+    private static String guessAppropriateEncoding(CharSequence contents) {\n+        // Very crude at the moment\n+        for (int i = 0; i < contents.length(); i++) {\n+            if (contents.charAt(i) > 0xFF) {\n+                return "UTF-8";\n+            }\n+        }\n+        return null;\n+    }\n+}\n', 'addition_count': 87, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/app/src/main/java/com/breadwallet/tools/qrcode/QRUtils.java', 'file_extension': '.java', 'before_file': 'ADDFILE', 'message': 'cleanup keystore, use context instead of activity (too limited)\n', 'author_name': 'Gutyn', 'lang': 'java'}