Swipe fix and Card for card options

This commit is contained in:
GaidamakUA 2015-08-06 08:23:35 +03:00
parent b7ee59a9a0
commit f3812b1653
8 changed files with 123 additions and 25 deletions

View file

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" >
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<Switch
android:id="@+id/check_item"
@ -13,4 +10,4 @@
android:focusable="false"
android:gravity="center_vertical"/>
</RelativeLayout>
</merge>

View file

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBox
android:id="@+id/check_item"
@ -16,4 +13,4 @@
android:focusable="false"
android:gravity="center_vertical" />
</RelativeLayout>
</merge>

View file

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_card"
android:layout_marginTop="@dimen/dash_margin"
android:layout_marginBottom="@dimen/dash_margin"
android:layout_marginLeft="@dimen/dash_margin_h"
android:layout_marginRight="@dimen/dash_margin_h"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Options"
android:textColor="?android:textColorPrimary"
android:textSize="20sp"
android:paddingBottom="10dp"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:paddingTop="8dp"
osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/list_header_height"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
style="@style/DashboardSubHeader"
android:text="Remove permanently"
osmand:typeface="@string/font_roboto_medium"/>
<include
layout="@layout/check_item_rel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/list_header_height"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
style="@style/DashboardSubHeader"
android:text="# of rows"
osmand:typeface="@string/font_roboto_medium"/>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:entries="@array/numbers_from_1_to_10">
</Spinner>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="@dimen/list_header_height"
android:orientation="horizontal">
<Button
android:id="@+id/positive_button"
style="@style/DashboardGeneralButton"
android:layout_width="0dp"
android:gravity="center"
android:layout_weight="1"
android:text="@string/shared_string_ok"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<Button
android:id="@+id/negative_button"
style="@style/DashboardGeneralButton"
android:layout_width="0dp"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="UNDO" />
</LinearLayout>
</LinearLayout>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_card"

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="numbers_from_1_to_10">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
</string-array>
</resources>

View file

@ -11,6 +11,7 @@ import android.support.v4.view.ViewCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
@ -49,13 +50,17 @@ public abstract class DashBaseFragment extends Fragment {
final public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View childView = initView(inflater, container, savedInstanceState);
ViewGroup.LayoutParams layoutParams =
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams layoutParams =
new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
InterceptorFrameLayout frameLayout = new InterceptorFrameLayout(getActivity());
frameLayout.setLayoutParams(layoutParams);
frameLayout.addView(childView);
FrameLayout.LayoutParams childLayoutParams =
new FrameLayout.LayoutParams(
(ViewGroup.MarginLayoutParams) childView.getLayoutParams());
frameLayout.addView(childView, childLayoutParams);
if (isDismissAllowed()) {
SwipeDismissTouchListener listener = new SwipeDismissTouchListener(childView, null,
new SwipeDismissTouchListener.DismissCallbacks() {

View file

@ -5,7 +5,6 @@ import android.content.Context;
import android.os.Build;
import android.support.v4.view.MotionEventCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.FrameLayout;
@ -16,11 +15,9 @@ import net.osmand.plus.widgets.tools.SwipeDismissTouchListener;
* Created by GaidamakUA on 8/5/15.
*/
public class InterceptorFrameLayout extends FrameLayout {
private static final String TAG = "InterceptorFrameLayout";
private int mTouchSlop;
private boolean mIsScrolling;
private float mDownX;
private boolean mShown;
private SwipeDismissTouchListener listener;
public InterceptorFrameLayout(Context context) {
@ -52,19 +49,15 @@ public class InterceptorFrameLayout extends FrameLayout {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
Log.v(TAG, "onInterceptTouchEvent(" + "ev=" + ev + ")");
final int action = MotionEventCompat.getActionMasked(ev);
// Always handle the case of the touch gesture being complete.
if (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP) {
// Release the scroll.
mIsScrolling = false;
return false; // Do not intercept touch event, let the child handle it
return false;
}
switch (action) {
case MotionEvent.ACTION_DOWN:
mShown = false;
mDownX = ev.getRawX();
listener.onTouch(this, ev);
return false;

View file

@ -4,7 +4,6 @@ import android.app.ListActivity;
import android.app.ListFragment;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.util.Log;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@ -102,7 +101,6 @@ public class SwipeDismissTouchListener implements View.OnTouchListener {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Log.v(TAG, "onTouch(" + "view=" + view + ", motionEvent=" + motionEvent + ")");
// offset because the view is translated during swipe
motionEvent.offsetLocation(mTranslationX, 0);