mobile/android/base/widget/GeckoViewFlipper.java

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 package org.mozilla.gecko.widget;
     8 import org.mozilla.gecko.animation.ViewHelper;
    10 import android.content.Context;
    11 import android.graphics.Rect;
    12 import android.os.Build;
    13 import android.view.MotionEvent;
    14 import android.widget.ViewFlipper;
    15 import android.util.Log;
    16 import android.util.AttributeSet;
    18 /* This extends the normal ViewFlipper only to fix bug 956075 on < 3.0 devices.
    19  * i.e. It ignores touch events on the ViewFlipper when its hidden. */
    21 public class GeckoViewFlipper extends ViewFlipper {
    22     private static final String LOGTAG = "GeckoViewFlipper";
    23     private Rect mRect = new Rect();
    25     public GeckoViewFlipper(Context context) {
    26         super(context);
    27     }
    29     public GeckoViewFlipper(Context context, AttributeSet attrs) {
    30         super(context, attrs);
    31     }
    33     @Override
    34     public boolean dispatchTouchEvent(MotionEvent ev) {
    35         if (Build.VERSION.SDK_INT < 11) {
    36             // Fix bug 956075. Don't allow touching this View if its hidden.
    37             getHitRect(mRect);
    38             mRect.offset((int) ViewHelper.getTranslationX(this), (int) ViewHelper.getTranslationY(this));
    40             if (!mRect.contains((int) ev.getX(), (int) ev.getY())) {
    41                 return false;
    42             }
    43         }
    45         return super.dispatchTouchEvent(ev);
    46     }
    47 }

mercurial