Small fixes
This commit is contained in:
parent
cf943edc98
commit
f3f2345371
2 changed files with 60 additions and 67 deletions
|
@ -12,7 +12,6 @@ import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
|
||||||
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.view.ViewTreeObserver.OnScrollChangedListener;
|
import android.view.ViewTreeObserver.OnScrollChangedListener;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
@ -44,9 +43,9 @@ import net.osmand.plus.onlinerouting.OnlineRoutingFactory;
|
||||||
import net.osmand.plus.onlinerouting.OnlineRoutingHelper;
|
import net.osmand.plus.onlinerouting.OnlineRoutingHelper;
|
||||||
import net.osmand.plus.onlinerouting.OnlineRoutingUtils;
|
import net.osmand.plus.onlinerouting.OnlineRoutingUtils;
|
||||||
import net.osmand.plus.onlinerouting.VehicleType;
|
import net.osmand.plus.onlinerouting.VehicleType;
|
||||||
import net.osmand.plus.onlinerouting.ui.OnlineRoutingCard.OnTextChangedListener;
|
|
||||||
import net.osmand.plus.onlinerouting.engine.EngineType;
|
import net.osmand.plus.onlinerouting.engine.EngineType;
|
||||||
import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine;
|
import net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine;
|
||||||
|
import net.osmand.plus.onlinerouting.ui.OnlineRoutingCard.OnTextChangedListener;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -703,90 +702,85 @@ public class OnlineRoutingEngineFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showShadowBelowButtons() {
|
private void showShadowBelowButtons() {
|
||||||
if (onScroll != null) {
|
scrollView.getViewTreeObserver().addOnScrollChangedListener(getShowShadowOnScrollListener());
|
||||||
scrollView.getViewTreeObserver().addOnScrollChangedListener(onScroll);
|
|
||||||
} else {
|
|
||||||
initShowShadowOnScrollListener();
|
|
||||||
showShadowBelowButtons();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showButtonsAboveKeyboard() {
|
private void showButtonsAboveKeyboard() {
|
||||||
if (onGlobalLayout != null) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
view.getViewTreeObserver().addOnGlobalLayoutListener(getShowButtonsOnGlobalListener());
|
||||||
view.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayout);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
initShowButtonsOnGlobalListener();
|
|
||||||
showButtonsAboveKeyboard();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initShowShadowOnScrollListener() {
|
private OnScrollChangedListener getShowShadowOnScrollListener() {
|
||||||
onScroll = new OnScrollChangedListener() {
|
if (onScroll == null) {
|
||||||
@Override
|
onScroll = new OnScrollChangedListener() {
|
||||||
public void onScrollChanged() {
|
@Override
|
||||||
boolean scrollToBottomAvailable = scrollView.canScrollVertically(1);
|
public void onScrollChanged() {
|
||||||
if (scrollToBottomAvailable) {
|
boolean scrollToBottomAvailable = scrollView.canScrollVertically(1);
|
||||||
showShadowButton();
|
if (scrollToBottomAvailable) {
|
||||||
} else {
|
showShadowButton();
|
||||||
hideShadowButton();
|
} else {
|
||||||
|
hideShadowButton();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
return onScroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initShowButtonsOnGlobalListener() {
|
private OnGlobalLayoutListener getShowButtonsOnGlobalListener() {
|
||||||
onGlobalLayout = new ViewTreeObserver.OnGlobalLayoutListener() {
|
if (onGlobalLayout == null) {
|
||||||
private int layoutHeightPrevious;
|
onGlobalLayout = new OnGlobalLayoutListener() {
|
||||||
private int layoutHeightMin;
|
private int layoutHeightPrevious;
|
||||||
|
private int layoutHeightMin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGlobalLayout() {
|
public void onGlobalLayout() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
} else {
|
} else {
|
||||||
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||||
}
|
|
||||||
|
|
||||||
Rect visibleDisplayFrame = new Rect();
|
|
||||||
view.getWindowVisibleDisplayFrame(visibleDisplayFrame);
|
|
||||||
int layoutHeight = visibleDisplayFrame.bottom;
|
|
||||||
|
|
||||||
if (layoutHeight < layoutHeightPrevious) {
|
|
||||||
isKeyboardShown = true;
|
|
||||||
layoutHeightMin = layoutHeight;
|
|
||||||
} else {
|
|
||||||
isKeyboardShown = layoutHeight == layoutHeightMin;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layoutHeight != layoutHeightPrevious) {
|
|
||||||
FrameLayout.LayoutParams rootViewLayout = (FrameLayout.LayoutParams) view.getLayoutParams();
|
|
||||||
rootViewLayout.height = layoutHeight;
|
|
||||||
view.requestLayout();
|
|
||||||
layoutHeightPrevious = layoutHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
view.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
view.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayout);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
}
|
Rect visibleDisplayFrame = new Rect();
|
||||||
};
|
view.getWindowVisibleDisplayFrame(visibleDisplayFrame);
|
||||||
|
int layoutHeight = visibleDisplayFrame.bottom;
|
||||||
|
|
||||||
|
if (layoutHeight < layoutHeightPrevious) {
|
||||||
|
isKeyboardShown = true;
|
||||||
|
layoutHeightMin = layoutHeight;
|
||||||
|
} else {
|
||||||
|
isKeyboardShown = layoutHeight == layoutHeightMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (layoutHeight != layoutHeightPrevious) {
|
||||||
|
FrameLayout.LayoutParams rootViewLayout = (FrameLayout.LayoutParams) view.getLayoutParams();
|
||||||
|
rootViewLayout.height = layoutHeight;
|
||||||
|
view.requestLayout();
|
||||||
|
layoutHeightPrevious = layoutHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
view.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
view.getViewTreeObserver().addOnGlobalLayoutListener(getShowButtonsOnGlobalListener());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return onGlobalLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeOnScrollListener() {
|
private void removeOnScrollListener() {
|
||||||
scrollView.getViewTreeObserver().removeOnScrollChangedListener(onScroll);
|
scrollView.getViewTreeObserver().removeOnScrollChangedListener(getShowShadowOnScrollListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeOnGlobalLayoutListener() {
|
private void removeOnGlobalLayoutListener() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||||
view.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayout);
|
view.getViewTreeObserver().removeOnGlobalLayoutListener(getShowButtonsOnGlobalListener());
|
||||||
} else {
|
} else {
|
||||||
view.getViewTreeObserver().removeGlobalOnLayoutListener(onGlobalLayout);
|
view.getViewTreeObserver().removeGlobalOnLayoutListener(getShowButtonsOnGlobalListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,5 +29,4 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes {
|
||||||
int paddingH = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin);
|
int paddingH = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin);
|
||||||
inputLayout.setPadding(0, paddingH, 0, paddingH);
|
inputLayout.setPadding(0, paddingH, 0, paddingH);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue