package com.urbanairship.richpush.sample;

import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.widget.SlidingPaneLayout;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.MotionEvent;

/**
 * Sliding pane layout that only allows
 * sliding if the slide gesture originates from a gutter
 * 
 */
public class CustomSlidingPaneLayout extends SlidingPaneLayout {

    public static int DEFAULT_GUTTER_SIZE_DP = 32;

    float gutter;
    boolean ignoreEvents = false;

    public CustomSlidingPaneLayout(Context context) {
        this(context, null);
    }

    public CustomSlidingPaneLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CustomSlidingPaneLayout(Context context, AttributeSet attrs,
            int defStyle) {
        super(context, attrs, defStyle);

        DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        gutter = DEFAULT_GUTTER_SIZE_DP * (metrics.densityDpi / 160f);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        int action = MotionEventCompat.getActionMasked(ev);

        switch(action) {
        case MotionEvent.ACTION_DOWN:
            if (ev.getX() > gutter && !isOpen()) {
                ignoreEvents = true;
                return false;
            }
            break;

        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            if (ignoreEvents) {
                ignoreEvents = false;
                return false;
            }
            break;
        }

        return !ignoreEvents && super.onInterceptTouchEvent(ev);
    }
}

@@ -449,16 +449,72 @@
 yout %7B%0A%0A
+    private static int MEDIUM_DENSITY_SCREEN_DPI = 160;%0A
     publ
@@ -1101,12 +1101,41 @@
 i / 
-160f
+(float) MEDIUM_DENSITY_SCREEN_DPI
 );%0A 

Move medium screen density to a constant