// Path: app/src/main/java/tw/fatminmin/xposed/minminguard/blocker/ViewBlocking.java
// public class ViewBlocking
// {
//     public static void removeAdView(String packageName, View view)
//     {
//         Util.notifyRemoveAdView(view.getContext(), packageName, 1);
//         removeAdView(packageName, view, true, 51);
//     }
// 
//     private static void removeAdView(final String packageName, final View view, final boolean first, final float heightLimit)
//     {
//         float adHeight = convertPixelsToDp(view.getHeight());
// 
//         if (first || (adHeight > 0 && adHeight <= heightLimit))
//         {
//             ViewGroup.LayoutParams params = view.getLayoutParams();
// 
//             if (params == null)
//                 params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
//             else
//                 params.height = 0;
// 
//             view.setLayoutParams(params);
//         }
// 
//         // preventing view not ready situation
//         view.post(new Runnable()
//         {
//             @Override
//             public void run()
//             {
//                 float adHeight = convertPixelsToDp(view.getHeight());
// 
//                 if (first || (adHeight > 0 && adHeight <= heightLimit))
//                 {
//                     ViewGroup.LayoutParams params = view.getLayoutParams();
// 
//                     if (params == null)
//                         params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
//                     else
//                         params.height = 0;
// 
//                     view.setLayoutParams(params);
//                 }
//             }
//         });
// 
//         if (view.getParent() != null && view.getParent() instanceof ViewGroup)
//         {
//             ViewGroup parent = (ViewGroup) view.getParent();
// 
//             removeAdView(packageName, parent, false, heightLimit);
//         }
//     }
// 
//     private static DisplayMetrics metrics = new DisplayMetrics();;
// 
//     private static float convertPixelsToDp(float px)
//     {
//         if(Main.resources != null)
//             metrics = Main.resources.getDisplayMetrics();
// 
//         return px / (metrics.densityDpi / 160f);
//     }
// }


import android.view.View;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LayoutInflated;
import tw.fatminmin.xposed.minminguard.blocker.ViewBlocking;
package tw.fatminmin.xposed.minminguard.blocker.custom_mod;


/**
 * Created by fatminmin on 2015/10/30.
 */
final class PeriodCalendar
{

    private static String pkgName = "com.popularapp.periodcalendar";

    private PeriodCalendar() throws InstantiationException
    {
        throw new InstantiationException("This class is not for instantiation");
    }

    //TODO Lets check if we are using an Xposed version that supports resource hooking
    public static void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam)
    {
        if (!resparam.packageName.equals(pkgName))
        {
            return;
        }

        resparam.res.hookLayout(pkgName, "layout", "native_ad", new XC_LayoutInflated()
        {

            @Override
            public void handleLayoutInflated(LayoutInflatedParam liparam)
            {

                View ad = liparam.view.findViewById(liparam.res.getIdentifier("native_layout", "id", pkgName));

// Path: app/src/main/java/tw/fatminmin/xposed/minminguard/blocker/ViewBlocking.java
// public class ViewBlocking
// {
//     public static void removeAdView(String packageName, View view)
//     {
//         Util.notifyRemoveAdView(view.getContext(), packageName, 1);
//         removeAdView(packageName, view, true, 51);
//     }
// 
//     private static void removeAdView(final String packageName, final View view, final boolean first, final float heightLimit)
//     {
//         float adHeight = convertPixelsToDp(view.getHeight());
// 
//         if (first || (adHeight > 0 && adHeight <= heightLimit))
//         {
//             ViewGroup.LayoutParams params = view.getLayoutParams();
// 
//             if (params == null)
//                 params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
//             else
//                 params.height = 0;
// 
//             view.setLayoutParams(params);
//         }
// 
//         // preventing view not ready situation
//         view.post(new Runnable()
//         {
//             @Override
//             public void run()
//             {
//                 float adHeight = convertPixelsToDp(view.getHeight());
// 
//                 if (first || (adHeight > 0 && adHeight <= heightLimit))
//                 {
//                     ViewGroup.LayoutParams params = view.getLayoutParams();
// 
//                     if (params == null)
//                         params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
//                     else
//                         params.height = 0;
// 
//                     view.setLayoutParams(params);
//                 }
//             }
//         });
// 
//         if (view.getParent() != null && view.getParent() instanceof ViewGroup)
//         {
//             ViewGroup parent = (ViewGroup) view.getParent();
// 
//             removeAdView(packageName, parent, false, heightLimit);
//         }
//     }
// 
//     private static DisplayMetrics metrics = new DisplayMetrics();;
// 
//     private static float convertPixelsToDp(float px)
//     {
//         if(Main.resources != null)
//             metrics = Main.resources.getDisplayMetrics();
// 
//         return px / (metrics.densityDpi / 160f);
//     }
// }


// Path: app/src/main/java/tw/fatminmin/xposed/minminguard/blocker/custom_mod/PeriodCalendar.java
import android.view.View;
import de.robv.android.xposed.callbacks.XC_InitPackageResources;
import de.robv.android.xposed.callbacks.XC_LayoutInflated;
import tw.fatminmin.xposed.minminguard.blocker.ViewBlocking;

package tw.fatminmin.xposed.minminguard.blocker.custom_mod;


/**
 * Created by fatminmin on 2015/10/30.
 */
final class PeriodCalendar
{

    private static String pkgName = "com.popularapp.periodcalendar";

    private PeriodCalendar() throws InstantiationException
    {
        throw new InstantiationException("This class is not for instantiation");
    }

    //TODO Lets check if we are using an Xposed version that supports resource hooking
    public static void handleInitPackageResources(XC_InitPackageResources.InitPackageResourcesParam resparam)
    {
        if (!resparam.packageName.equals(pkgName))
        {
            return;
        }

        resparam.res.hookLayout(pkgName, "layout", "native_ad", new XC_LayoutInflated()
        {

            @Override
            public void handleLayoutInflated(LayoutInflatedParam liparam)
            {

                View ad = liparam.view.findViewById(liparam.res.getIdentifier("native_layout", "id", pkgName));

                ViewBlocking.removeAdView(pkgName, ad);