commit
7613e087f6
11 changed files with 114 additions and 35 deletions
32
OsmAnd/res/drawable/shadow.xml
Normal file
32
OsmAnd/res/drawable/shadow.xml
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item>
|
||||
<shape
|
||||
android:dither="true"
|
||||
android:shape="rectangle">
|
||||
|
||||
<gradient
|
||||
android:angle="90"
|
||||
android:startColor="#1A000000"
|
||||
android:centerColor="#00FFFFFF"
|
||||
android:endColor="#00FFFFFF" />
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<shape
|
||||
android:dither="true"
|
||||
android:shape="rectangle">
|
||||
|
||||
<gradient
|
||||
android:angle="90"
|
||||
android:startColor="#0D000000"
|
||||
android:centerColor="#00FFFFFF"
|
||||
android:endColor="#00FFFFFF" />
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
|
@ -38,9 +38,9 @@
|
|||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light"
|
||||
android:background="@drawable/shadow"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include layout="@layout/bottom_buttons" />
|
||||
|
|
|
@ -33,9 +33,9 @@
|
|||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light"
|
||||
android:background="@drawable/shadow"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/shadow" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -128,9 +128,9 @@
|
|||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
||||
android:background="@drawable/shadow" />
|
||||
|
||||
<include
|
||||
layout="@layout/bottom_buttons"
|
||||
|
|
|
@ -98,9 +98,9 @@
|
|||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
||||
android:background="@drawable/shadow" />
|
||||
|
||||
<include
|
||||
layout="@layout/bottom_buttons"
|
||||
|
|
|
@ -591,9 +591,9 @@
|
|||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
||||
android:background="@drawable/shadow" />
|
||||
|
||||
<include
|
||||
layout="@layout/route_info_menu_control_buttons"
|
||||
|
|
|
@ -129,9 +129,9 @@
|
|||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light" />
|
||||
android:background="@drawable/shadow" />
|
||||
|
||||
<include
|
||||
layout="@layout/bottom_buttons"
|
||||
|
|
|
@ -423,7 +423,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
|
||||
private LayerDrawable createBackgroundDrawable(@NonNull Context ctx, @DrawableRes int shadowDrawableResId) {
|
||||
Drawable shadowDrawable = ContextCompat.getDrawable(ctx, shadowDrawableResId);
|
||||
Drawable[] layers = new Drawable[] {shadowDrawable, getColoredBg(ctx)};
|
||||
Drawable[] layers = new Drawable[]{shadowDrawable, getColoredBg(ctx)};
|
||||
return new LayerDrawable(layers);
|
||||
}
|
||||
|
||||
|
@ -434,6 +434,21 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
return !app.getSettings().isLightContent();
|
||||
}
|
||||
|
||||
private void showShadowButton() {
|
||||
buttonsShadow.setVisibility(View.VISIBLE);
|
||||
buttonsShadow.animate()
|
||||
.alpha(0.8f)
|
||||
.setDuration(200)
|
||||
.setListener(null);
|
||||
}
|
||||
|
||||
private void hideShadowButton() {
|
||||
buttonsShadow.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(200);
|
||||
|
||||
}
|
||||
|
||||
private void setupScrollShadow(View view) {
|
||||
final View scrollView;
|
||||
if (useScrollableItemsContainer()) {
|
||||
|
@ -446,7 +461,11 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
@Override
|
||||
public void onScrollChanged() {
|
||||
boolean scrollToBottomAvailable = scrollView.canScrollVertically(1);
|
||||
AndroidUiHelper.updateVisibility(buttonsShadow, scrollToBottomAvailable);
|
||||
if (scrollToBottomAvailable) {
|
||||
showShadowButton();
|
||||
} else {
|
||||
hideShadowButton();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package net.osmand.plus.routepreparationmenu;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
@ -16,6 +19,7 @@ import android.view.ViewGroup.MarginLayoutParams;
|
|||
import android.view.ViewTreeObserver.OnScrollChangedListener;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -84,6 +88,8 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
|||
|
||||
private GPXFile gpxFile;
|
||||
|
||||
private View buttonsShadow;
|
||||
|
||||
private boolean editingTrack;
|
||||
private boolean selectingTrack;
|
||||
private int menuTitleHeight;
|
||||
|
@ -146,6 +152,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
|||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (view != null) {
|
||||
ImageButton closeButton = view.findViewById(R.id.close_button);
|
||||
buttonsShadow = view.findViewById(R.id.buttons_shadow);
|
||||
closeButton.setImageDrawable(getContentIcon(AndroidUtils.getNavigationIconResId(app)));
|
||||
closeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -172,6 +179,22 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
|||
return view;
|
||||
}
|
||||
|
||||
private void showShadowButton() {
|
||||
buttonsShadow.setVisibility(View.VISIBLE);
|
||||
buttonsShadow.animate()
|
||||
.alpha(0.8f)
|
||||
.setDuration(200)
|
||||
.setListener(null);
|
||||
}
|
||||
|
||||
private void hideShadowButton() {
|
||||
buttonsShadow.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void setupCards() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
|
@ -593,20 +616,16 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
|||
}
|
||||
|
||||
private void setupScrollShadow() {
|
||||
int shadowIconId = isNightMode() ? R.drawable.bg_contextmenu_shadow : R.drawable.bg_contextmenu_shadow;
|
||||
final Drawable shadowIcon = app.getUIUtilities().getIcon(shadowIconId);
|
||||
|
||||
final View scrollView = getBottomScrollView();
|
||||
final FrameLayout bottomContainer = getBottomContainer();
|
||||
scrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {
|
||||
|
||||
@Override
|
||||
public void onScrollChanged() {
|
||||
int scrollY = scrollView.getScrollY();
|
||||
if (scrollY <= 0 && bottomContainer.getForeground() != null) {
|
||||
bottomContainer.setForeground(null);
|
||||
} else if (scrollY > 0 && bottomContainer.getForeground() == null) {
|
||||
bottomContainer.setForeground(shadowIcon);
|
||||
boolean scrollToBottomAvailable = scrollView.canScrollVertically(1);
|
||||
if (scrollToBottomAvailable) {
|
||||
showShadowButton();
|
||||
} else {
|
||||
hideShadowButton();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -475,24 +475,33 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
AndroidUiHelper.updateVisibility(saveButton, true);
|
||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
|
||||
}
|
||||
private void showShadowButton() {
|
||||
buttonsShadow.setVisibility(View.VISIBLE);
|
||||
buttonsShadow.animate()
|
||||
.alpha(0.8f)
|
||||
.setDuration(200)
|
||||
.setListener(null);
|
||||
}
|
||||
|
||||
private void hideShadowButton() {
|
||||
buttonsShadow.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(200);
|
||||
|
||||
}
|
||||
|
||||
private void setupScrollShadow() {
|
||||
int shadowIconId = isNightMode() ? R.drawable.bg_contextmenu_shadow : R.drawable.bg_contextmenu_shadow;
|
||||
final Drawable shadowIcon = app.getUIUtilities().getIcon(shadowIconId);
|
||||
|
||||
final View scrollView = getBottomScrollView();
|
||||
final FrameLayout bottomContainer = getBottomContainer();
|
||||
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
|
||||
|
||||
@Override
|
||||
public void onScrollChanged() {
|
||||
int scrollY = scrollView.getScrollY();
|
||||
if (scrollY <= 0 && bottomContainer.getForeground() != null) {
|
||||
bottomContainer.setForeground(null);
|
||||
} else if (scrollY > 0 && bottomContainer.getForeground() == null) {
|
||||
bottomContainer.setForeground(shadowIcon);
|
||||
boolean scrollToBottomAvailable = scrollView.canScrollVertically(1);
|
||||
if (scrollToBottomAvailable) {
|
||||
showShadowButton();
|
||||
} else {
|
||||
hideShadowButton();
|
||||
}
|
||||
updateButtonsShadow();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue