Merge branch 'design' of github.com:osmandapp/Osmand into design
This commit is contained in:
commit
84a0ae6062
5 changed files with 112 additions and 3 deletions
|
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -47,6 +48,7 @@ import gnu.trove.map.hash.TLongObjectHashMap;
|
||||||
|
|
||||||
public class GeoIntentActivity extends OsmandListActivity {
|
public class GeoIntentActivity extends OsmandListActivity {
|
||||||
|
|
||||||
|
private static final String TAG = "GeoIntentActivity";
|
||||||
private ProgressDialog progressDlg;
|
private ProgressDialog progressDlg;
|
||||||
private LatLon location;
|
private LatLon location;
|
||||||
|
|
||||||
|
@ -114,8 +116,10 @@ public class GeoIntentActivity extends OsmandListActivity {
|
||||||
while (getMyApplication().isApplicationInitializing()) {
|
while (getMyApplication().isApplicationInitializing()) {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
|
Log.v(TAG, "intent.getData()" + intent.getData());
|
||||||
return extract(intent.getData()).execute();
|
return extract(intent.getData()).execute();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.view.ViewGroup;
|
||||||
import net.osmand.plus.OsmAndAppCustomization;
|
import net.osmand.plus.OsmAndAppCustomization;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.widgets.InterceptorFrameLayout;
|
||||||
import net.osmand.plus.widgets.tools.SwipeDismissTouchListener;
|
import net.osmand.plus.widgets.tools.SwipeDismissTouchListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,8 +49,15 @@ public abstract class DashBaseFragment extends Fragment {
|
||||||
final public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
final public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
View childView = initView(inflater, container, savedInstanceState);
|
View childView = initView(inflater, container, savedInstanceState);
|
||||||
|
ViewGroup.LayoutParams layoutParams =
|
||||||
|
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
|
||||||
|
InterceptorFrameLayout frameLayout = new InterceptorFrameLayout(getActivity());
|
||||||
|
frameLayout.setLayoutParams(layoutParams);
|
||||||
|
frameLayout.addView(childView);
|
||||||
if (isDismissAllowed()) {
|
if (isDismissAllowed()) {
|
||||||
childView.setOnTouchListener(new SwipeDismissTouchListener(childView, null,
|
SwipeDismissTouchListener listener = new SwipeDismissTouchListener(childView, null,
|
||||||
new SwipeDismissTouchListener.DismissCallbacks() {
|
new SwipeDismissTouchListener.DismissCallbacks() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canDismiss(Object token) {
|
public boolean canDismiss(Object token) {
|
||||||
|
@ -64,13 +72,16 @@ public abstract class DashBaseFragment extends Fragment {
|
||||||
// TODO show settings card
|
// TODO show settings card
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
frameLayout.setOnTouchListener(listener);
|
||||||
|
frameLayout.setListener(listener);
|
||||||
if (getDismissCallback() == null) {
|
if (getDismissCallback() == null) {
|
||||||
defaultDismissListener = new DefaultDismissListener(getParentView(), dashboard, getTag(),
|
defaultDismissListener = new DefaultDismissListener(getParentView(), dashboard, getTag(),
|
||||||
childView);
|
childView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return childView;
|
|
||||||
|
return frameLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract View initView(LayoutInflater inflater, @Nullable ViewGroup container,
|
public abstract View initView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
|
|
|
@ -161,6 +161,7 @@ public class RegionAddressRepositoryBinary implements RegionAddressRepository {
|
||||||
public synchronized List<MapObject> searchMapObjectsByName(String name, ResultMatcher<MapObject> resultMatcher) {
|
public synchronized List<MapObject> searchMapObjectsByName(String name, ResultMatcher<MapObject> resultMatcher) {
|
||||||
SearchRequest<MapObject> req = BinaryMapIndexReader.buildAddressByNameRequest(resultMatcher, name);
|
SearchRequest<MapObject> req = BinaryMapIndexReader.buildAddressByNameRequest(resultMatcher, name);
|
||||||
try {
|
try {
|
||||||
|
log.debug("file=" + file + "; req=" + req);
|
||||||
file.searchAddressDataByName(req);
|
file.searchAddressDataByName(req);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Disk operation failed", e); //$NON-NLS-1$
|
log.error("Disk operation failed", e); //$NON-NLS-1$
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
package net.osmand.plus.widgets;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
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;
|
||||||
|
|
||||||
|
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) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterceptorFrameLayout(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
ViewConfiguration vc = ViewConfiguration.get(context);
|
||||||
|
mTouchSlop = vc.getScaledTouchSlop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterceptorFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
ViewConfiguration vc = ViewConfiguration.get(context);
|
||||||
|
mTouchSlop = vc.getScaledTouchSlop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
public InterceptorFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
ViewConfiguration vc = ViewConfiguration.get(context);
|
||||||
|
mTouchSlop = vc.getScaledTouchSlop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListener(SwipeDismissTouchListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
mShown = false;
|
||||||
|
mDownX = ev.getRawX();
|
||||||
|
listener.onTouch(this, ev);
|
||||||
|
return false;
|
||||||
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
if (mIsScrolling) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int xDiff = calculateDistanceX(ev);
|
||||||
|
if (xDiff > mTouchSlop) {
|
||||||
|
mIsScrolling = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int calculateDistanceX(MotionEvent ev) {
|
||||||
|
return (int) (ev.getRawX() - mDownX);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import android.app.ListActivity;
|
||||||
import android.app.ListFragment;
|
import android.app.ListFragment;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v4.view.ViewPropertyAnimatorListener;
|
import android.support.v4.view.ViewPropertyAnimatorListener;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.VelocityTracker;
|
import android.view.VelocityTracker;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -38,6 +39,7 @@ import android.widget.ListView;
|
||||||
* android.view.ViewPropertyAnimator}.</p>
|
* android.view.ViewPropertyAnimator}.</p>
|
||||||
*/
|
*/
|
||||||
public class SwipeDismissTouchListener implements View.OnTouchListener {
|
public class SwipeDismissTouchListener implements View.OnTouchListener {
|
||||||
|
private static final String TAG = "SwipeDismissTouchListener";
|
||||||
// Cached ViewConfiguration and system-wide constant values
|
// Cached ViewConfiguration and system-wide constant values
|
||||||
private int mSlop;
|
private int mSlop;
|
||||||
private int mMinFlingVelocity;
|
private int mMinFlingVelocity;
|
||||||
|
@ -100,6 +102,7 @@ public class SwipeDismissTouchListener implements View.OnTouchListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||||
|
Log.v(TAG, "onTouch(" + "view=" + view + ", motionEvent=" + motionEvent + ")");
|
||||||
// offset because the view is translated during swipe
|
// offset because the view is translated during swipe
|
||||||
motionEvent.offsetLocation(mTranslationX, 0);
|
motionEvent.offsetLocation(mTranslationX, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue