mobile/android/base/widget/GeckoViewFlipper.java

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

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

mercurial