altosdroid: fix side-to-side scrolling in map tab
authorMike Beattie <mike@ethernal.org>
Fri, 8 Mar 2013 06:41:32 +0000 (19:41 +1300)
committerMike Beattie <mike@ethernal.org>
Fri, 8 Mar 2013 06:41:32 +0000 (19:41 +1300)
Signed-off-by: Mike Beattie <mike@ethernal.org>
altosdroid/res/layout/altosdroid.xml
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java [new file with mode: 0644]

index ce812414232ad42d681478dd78c2a98fb219317e..364f6ba6d62677b370c0b1eef289ee8f949064b8 100644 (file)
                                android:layout_height="0dp"
                                android:layout_weight="0" />
 
-                       <android.support.v4.view.ViewPager
+                       <org.altusmetrum.AltosDroid.AltosViewPager
                                android:id="@+id/pager"
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
index 63043abd503468e9e1730cf5ebbcd0290f45a8c8..c9ce46a0d0c8487c075d6c95e6a8b6a845e32657 100644 (file)
@@ -80,7 +80,7 @@ public class AltosDroid extends FragmentActivity {
 
        // Tabs
        TabHost     mTabHost;
-       ViewPager   mViewPager;
+       AltosViewPager   mViewPager;
        TabsAdapter mTabsAdapter;
        ArrayList<AltosDroidTab> mTabs = new ArrayList<AltosDroidTab>();
 
@@ -272,7 +272,7 @@ public class AltosDroid extends FragmentActivity {
                mTabHost = (TabHost)findViewById(android.R.id.tabhost);
                mTabHost.setup();
 
-               mViewPager = (ViewPager)findViewById(R.id.pager);
+               mViewPager = (AltosViewPager)findViewById(R.id.pager);
                mViewPager.setOffscreenPageLimit(4);
 
                mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java
new file mode 100644 (file)
index 0000000..ebddc26
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2013 Mike Beattie <mike@ethernal.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosDroid;
+
+import android.content.Context;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class AltosViewPager extends ViewPager {
+
+    public AltosViewPager(Context context) {
+        super(context);
+    }
+
+    public AltosViewPager(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
+        if(v.getClass().getPackage().getName().startsWith("maps.")){
+            return true;
+        }
+        return super.canScroll(v, checkV, dx, x, y);
+    }
+
+}
\ No newline at end of file