// Path: src/tk/eatheat/omnisnitch/ui/BitmapFilter.java
// @SuppressLint("NewApi")
// public class BitmapFilter {
//     private static BitmapFilter mSingleton;
// 
//     private Map<String, Bitmap> mGlowCache;
//     private RenderScript mRS;
//     private Allocation mBlurInputAllocation;
//     private Allocation mBlurOutputAllocation;
//     private ScriptIntrinsicBlur mBlurScript;
// 
//     public static BitmapFilter getSingleton() {
//         if (mSingleton == null) {
//             mSingleton = new BitmapFilter();
//         }
// 
//         return mSingleton;
//     }
// 
//     private BitmapFilter() {
//         mGlowCache = new HashMap<String, Bitmap>();
//     }
// 
//     /**
//      * Blurs a bitmap. There's no caching on this one.
//      *
//      * @param src The bitmap to blur
//      * @return A blurred bitmap
//      */
//     public Bitmap getBlur(Context context, Bitmap src, float radius) {
//         if (android.os.Build.VERSION.SDK_INT >= 17) {
//             if (mRS == null) {
//                 mRS = RenderScript.create(context);
//             }
// 
//             if (mBlurScript == null) {
//                 mBlurScript = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS));
//             }
// 
//             if (mBlurInputAllocation == null) {
//                 mBlurInputAllocation = Allocation.createFromBitmap(mRS, src,
//                         Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE);
//                 mBlurScript.setInput(mBlurInputAllocation);
//             } else {
//                 mBlurInputAllocation.copyFrom(src);
//             }
// 
//             if (mBlurOutputAllocation == null) {
//                 mBlurOutputAllocation = Allocation.createTyped(mRS, mBlurInputAllocation.getType());
//             }
// 
//             mBlurScript.setRadius(radius);
//             mBlurScript.forEach(mBlurOutputAllocation);
//             mBlurOutputAllocation.copyTo(src);
//         }
// 
//         return src;
//     }
// 
//     /**
//      * Returns a glowed image of the provided icon. If the
//      * provided name is already in the cache, the cached image
//      * will be returned. Otherwise, the bitmap will be glowed and
//      * cached under the provided name
//      *
//      * @param name The name of the bitmap - if name == null dont cache
//      * @param src  The bitmap of the icon itself
//      * @return Glowed bitmap
//      */
//     public Bitmap getGlow(String name, int glowColor, Bitmap src) {
//         if (name != null && mGlowCache.containsKey(name)) {
//             return mGlowCache.get(name);
//         } else {
//             // An added margin to the initial image
//             int margin = 0;
//             int halfMargin = margin / 2;
// 
//             // The glow radius
//             int glowRadius = 12;
// 
//             // Extract the alpha from the source image
//             Bitmap alpha = src.extractAlpha();
// 
//             // The output bitmap (with the icon + glow)
//             Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin,
//                     src.getHeight() + margin, Bitmap.Config.ARGB_8888);
// 
//             // The canvas to paint on the image
//             Canvas canvas = new Canvas(bmp);
// 
//             Paint paint = new Paint();
//             paint.setColor(glowColor);
// 
//             // Outer glow
//             ColorFilter emphasize = new LightingColorFilter(glowColor, 1);
//             paint.setColorFilter(emphasize);
//             canvas.drawBitmap(src, halfMargin, halfMargin, paint);
//             paint.setColorFilter(null);
//             paint.setMaskFilter(new BlurMaskFilter(glowRadius, Blur.OUTER));
//             canvas.drawBitmap(alpha, halfMargin, halfMargin, paint);
// 
//             if(name!=null){
//                 // Cache icon
//                 mGlowCache.put(name, bmp);
//             }
// 
//             return bmp;
//         }
//     }
// }


import java.util.Iterator;
import java.util.List;
import tk.eatheat.omnisnitch.ui.BitmapFilter;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
        String[] splitParts = buttonString.split(",");
        boolean[] buttons = new boolean[splitParts.length];
        for(int i = 0; i < splitParts.length; i++){
            if (splitParts[i].equals("0")){
                buttons[i]=false;
            } else if (splitParts[i].equals("1")){
                buttons[i]=true;
            }
        }
        return buttons;
    }
    
    public static String buttonArrayToString(boolean[] buttons){
        String buttonString = "";
        for(int i = 0; i < buttons.length; i++){
            boolean value = buttons[i];
            if (value){
                buttonString = buttonString + "1,";
            } else {
                buttonString = buttonString + "0,";
            }
        }
        if(buttonString.length() > 0){
            buttonString = buttonString.substring(0, buttonString.length() - 1);
        }
        return buttonString;
    }
    
    public static Bitmap getGlow(Resources resources, String name, int color, Drawable image) {
        Bitmap b = ((BitmapDrawable) image).getBitmap();
// Path: src/tk/eatheat/omnisnitch/ui/BitmapFilter.java
// @SuppressLint("NewApi")
// public class BitmapFilter {
//     private static BitmapFilter mSingleton;
// 
//     private Map<String, Bitmap> mGlowCache;
//     private RenderScript mRS;
//     private Allocation mBlurInputAllocation;
//     private Allocation mBlurOutputAllocation;
//     private ScriptIntrinsicBlur mBlurScript;
// 
//     public static BitmapFilter getSingleton() {
//         if (mSingleton == null) {
//             mSingleton = new BitmapFilter();
//         }
// 
//         return mSingleton;
//     }
// 
//     private BitmapFilter() {
//         mGlowCache = new HashMap<String, Bitmap>();
//     }
// 
//     /**
//      * Blurs a bitmap. There's no caching on this one.
//      *
//      * @param src The bitmap to blur
//      * @return A blurred bitmap
//      */
//     public Bitmap getBlur(Context context, Bitmap src, float radius) {
//         if (android.os.Build.VERSION.SDK_INT >= 17) {
//             if (mRS == null) {
//                 mRS = RenderScript.create(context);
//             }
// 
//             if (mBlurScript == null) {
//                 mBlurScript = ScriptIntrinsicBlur.create(mRS, Element.U8_4(mRS));
//             }
// 
//             if (mBlurInputAllocation == null) {
//                 mBlurInputAllocation = Allocation.createFromBitmap(mRS, src,
//                         Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_GRAPHICS_TEXTURE);
//                 mBlurScript.setInput(mBlurInputAllocation);
//             } else {
//                 mBlurInputAllocation.copyFrom(src);
//             }
// 
//             if (mBlurOutputAllocation == null) {
//                 mBlurOutputAllocation = Allocation.createTyped(mRS, mBlurInputAllocation.getType());
//             }
// 
//             mBlurScript.setRadius(radius);
//             mBlurScript.forEach(mBlurOutputAllocation);
//             mBlurOutputAllocation.copyTo(src);
//         }
// 
//         return src;
//     }
// 
//     /**
//      * Returns a glowed image of the provided icon. If the
//      * provided name is already in the cache, the cached image
//      * will be returned. Otherwise, the bitmap will be glowed and
//      * cached under the provided name
//      *
//      * @param name The name of the bitmap - if name == null dont cache
//      * @param src  The bitmap of the icon itself
//      * @return Glowed bitmap
//      */
//     public Bitmap getGlow(String name, int glowColor, Bitmap src) {
//         if (name != null && mGlowCache.containsKey(name)) {
//             return mGlowCache.get(name);
//         } else {
//             // An added margin to the initial image
//             int margin = 0;
//             int halfMargin = margin / 2;
// 
//             // The glow radius
//             int glowRadius = 12;
// 
//             // Extract the alpha from the source image
//             Bitmap alpha = src.extractAlpha();
// 
//             // The output bitmap (with the icon + glow)
//             Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin,
//                     src.getHeight() + margin, Bitmap.Config.ARGB_8888);
// 
//             // The canvas to paint on the image
//             Canvas canvas = new Canvas(bmp);
// 
//             Paint paint = new Paint();
//             paint.setColor(glowColor);
// 
//             // Outer glow
//             ColorFilter emphasize = new LightingColorFilter(glowColor, 1);
//             paint.setColorFilter(emphasize);
//             canvas.drawBitmap(src, halfMargin, halfMargin, paint);
//             paint.setColorFilter(null);
//             paint.setMaskFilter(new BlurMaskFilter(glowRadius, Blur.OUTER));
//             canvas.drawBitmap(alpha, halfMargin, halfMargin, paint);
// 
//             if(name!=null){
//                 // Cache icon
//                 mGlowCache.put(name, bmp);
//             }
// 
//             return bmp;
//         }
//     }
// }


// Path: src/tk/eatheat/omnisnitch/Utils.java
import java.util.Iterator;
import java.util.List;
import tk.eatheat.omnisnitch.ui.BitmapFilter;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

        String[] splitParts = buttonString.split(",");
        boolean[] buttons = new boolean[splitParts.length];
        for(int i = 0; i < splitParts.length; i++){
            if (splitParts[i].equals("0")){
                buttons[i]=false;
            } else if (splitParts[i].equals("1")){
                buttons[i]=true;
            }
        }
        return buttons;
    }
    
    public static String buttonArrayToString(boolean[] buttons){
        String buttonString = "";
        for(int i = 0; i < buttons.length; i++){
            boolean value = buttons[i];
            if (value){
                buttonString = buttonString + "1,";
            } else {
                buttonString = buttonString + "0,";
            }
        }
        if(buttonString.length() > 0){
            buttonString = buttonString.substring(0, buttonString.length() - 1);
        }
        return buttonString;
    }
    
    public static Bitmap getGlow(Resources resources, String name, int color, Drawable image) {
        Bitmap b = ((BitmapDrawable) image).getBitmap();
        return BitmapFilter.getSingleton().getGlow(name, color, b);