mirror of
https://github.com/Dark98/SliceBeam.git
synced 2026-07-03 00:38:53 +00:00
Fix unfold menus soft-lock after tab is switched to another
This commit is contained in:
+6
-2
@@ -12,7 +12,7 @@ android {
|
|||||||
applicationId "ru.ytkab0bp.slicebeam"
|
applicationId "ru.ytkab0bp.slicebeam"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 2
|
versionCode 3
|
||||||
versionName "0.1.0"
|
versionName "0.1.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
@@ -34,8 +34,12 @@ android {
|
|||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
buildConfigField "boolean", "IS_GOOGLE_PLAY", "true"
|
buildConfigField "boolean", "IS_GOOGLE_PLAY", "false"
|
||||||
buildConfigField "String", "COMMIT", "\"" + commit + "\""
|
buildConfigField "String", "COMMIT", "\"" + commit + "\""
|
||||||
|
ndk {
|
||||||
|
//noinspection ChromeOsAbiSupport
|
||||||
|
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
debug {
|
debug {
|
||||||
buildConfigField "boolean", "IS_GOOGLE_PLAY", "false"
|
buildConfigField "boolean", "IS_GOOGLE_PLAY", "false"
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public abstract class UnfoldMenu {
|
|||||||
protected BedFragment fragment;
|
protected BedFragment fragment;
|
||||||
|
|
||||||
private boolean isVisible;
|
private boolean isVisible;
|
||||||
|
private boolean isDismissing;
|
||||||
private SpringAnimation spring;
|
private SpringAnimation spring;
|
||||||
private DynamicAnimation.OnAnimationUpdateListener updateListener;
|
private DynamicAnimation.OnAnimationUpdateListener updateListener;
|
||||||
private FrameLayout containerLayout;
|
private FrameLayout containerLayout;
|
||||||
@@ -121,13 +122,21 @@ public abstract class UnfoldMenu {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
|
||||||
|
if (isVisible) {
|
||||||
|
onCreate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
|
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
onDestroy();
|
onDestroy();
|
||||||
isVisible = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -138,7 +147,6 @@ public abstract class UnfoldMenu {
|
|||||||
rootView.setTranslationX(fromTranslationX);
|
rootView.setTranslationX(fromTranslationX);
|
||||||
rootView.setTranslationY(fromTranslationY);
|
rootView.setTranslationY(fromTranslationY);
|
||||||
|
|
||||||
onCreate();
|
|
||||||
dimmView = new View(ctx);
|
dimmView = new View(ctx);
|
||||||
dimmView.setBackgroundColor(0x40000000);
|
dimmView.setBackgroundColor(0x40000000);
|
||||||
dimmView.setTranslationX(toTranslationX);
|
dimmView.setTranslationX(toTranslationX);
|
||||||
@@ -207,6 +215,10 @@ public abstract class UnfoldMenu {
|
|||||||
updateListener.onAnimationUpdate(spring, 1f, 0f);
|
updateListener.onAnimationUpdate(spring, 1f, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAttached() {
|
||||||
|
return rootView.getParent() != null && !isDismissing;
|
||||||
|
}
|
||||||
|
|
||||||
public void dismiss() {
|
public void dismiss() {
|
||||||
dismiss(false);
|
dismiss(false);
|
||||||
}
|
}
|
||||||
@@ -215,7 +227,9 @@ public abstract class UnfoldMenu {
|
|||||||
if (!isVisible) return;
|
if (!isVisible) return;
|
||||||
this.isVisible = false;
|
this.isVisible = false;
|
||||||
|
|
||||||
|
isDismissing = true;
|
||||||
onDestroy();
|
onDestroy();
|
||||||
|
isDismissing = false;
|
||||||
|
|
||||||
if (alphaOnly) {
|
if (alphaOnly) {
|
||||||
ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(150);
|
ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(150);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class SliceMenu extends ListBedMenu {
|
|||||||
protected List<SimpleRecyclerItem> onCreateItems(boolean portrait) {
|
protected List<SimpleRecyclerItem> onCreateItems(boolean portrait) {
|
||||||
lastUid = SliceBeam.CONFIG_UID;
|
lastUid = SliceBeam.CONFIG_UID;
|
||||||
List<SimpleRecyclerItem> items = new ArrayList<>(Arrays.asList(
|
List<SimpleRecyclerItem> items = new ArrayList<>(Arrays.asList(
|
||||||
new BedMenuItem(R.string.MenuSliceInfo, R.drawable.square_stack_up_outline_28).onClick(v -> fragment.showUnfoldMenu(new PrintInfoMenu(), v)),
|
new BedMenuItem(R.string.MenuSliceInfo, R.drawable.square_stack_up_outline_28).onClick(v -> fragment.showUnfoldMenu(new LayersMenu(), v)),
|
||||||
new BedMenuItem(R.string.MenuSliceExportToFile, R.drawable.folder_simple_arrow_right_outline_28).onClick(v -> {
|
new BedMenuItem(R.string.MenuSliceExportToFile, R.drawable.folder_simple_arrow_right_outline_28).onClick(v -> {
|
||||||
if (fragment.getContext() instanceof Activity) {
|
if (fragment.getContext() instanceof Activity) {
|
||||||
Activity act = (Activity) fragment.getContext();
|
Activity act = (Activity) fragment.getContext();
|
||||||
@@ -176,7 +176,7 @@ public class SliceMenu extends ListBedMenu {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static class PrintInfoMenu extends UnfoldMenu {
|
private final static class LayersMenu extends UnfoldMenu {
|
||||||
private PositionScrollView fromTrack, toTrack;
|
private PositionScrollView fromTrack, toTrack;
|
||||||
private TextView title;
|
private TextView title;
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,10 @@ public class BedFragment extends Fragment {
|
|||||||
public void showUnfoldMenu(UnfoldMenu menu, View from) {
|
public void showUnfoldMenu(UnfoldMenu menu, View from) {
|
||||||
if (currentUnfoldMenu != null) return;
|
if (currentUnfoldMenu != null) return;
|
||||||
|
|
||||||
menu.setOnDismiss(()-> currentUnfoldMenu = null);
|
menu.setOnDismiss(()-> {
|
||||||
|
if (menu.isAttached()) return;
|
||||||
|
currentUnfoldMenu = null;
|
||||||
|
});
|
||||||
currentUnfoldMenu = menu;
|
currentUnfoldMenu = menu;
|
||||||
menu.show(from, this);
|
menu.show(from, this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user