mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
Fixed: Bottom sheet cannot be dragged when expanded
This commit is contained in:
@@ -115,7 +115,6 @@ import com.itsaky.androidide.services.LogReceiver;
|
||||
import com.itsaky.androidide.shell.ShellServer;
|
||||
import com.itsaky.androidide.utils.DialogUtils;
|
||||
import com.itsaky.androidide.utils.EditorActivityActions;
|
||||
import com.itsaky.androidide.utils.EditorBottomSheetBehavior;
|
||||
import com.itsaky.androidide.utils.ILogger;
|
||||
import com.itsaky.androidide.utils.InstallationResultHandler;
|
||||
import com.itsaky.androidide.utils.IntentUtils;
|
||||
@@ -178,7 +177,7 @@ public class EditorActivity extends IDEActivity
|
||||
private ProgressSheet mSearchingProgress;
|
||||
private AlertDialog mFindInProjectDialog;
|
||||
private ActivityResultLauncher<Intent> mUIDesignerLauncher;
|
||||
private EditorBottomSheetBehavior<? extends View> mEditorBottomSheet;
|
||||
private BottomSheetBehavior<? extends View> mEditorBottomSheet;
|
||||
private EditorViewModel mViewModel;
|
||||
private final ServiceConnection mGradleServiceConnection =
|
||||
new ServiceConnection() {
|
||||
@@ -1195,10 +1194,7 @@ public class EditorActivity extends IDEActivity
|
||||
}
|
||||
|
||||
private void setupBottomSheet() {
|
||||
mEditorBottomSheet =
|
||||
(EditorBottomSheetBehavior<? extends View>)
|
||||
EditorBottomSheetBehavior.from(mBinding.bottomSheet);
|
||||
mEditorBottomSheet.setBinding(mBinding.bottomSheet.binding.pager);
|
||||
mEditorBottomSheet = BottomSheetBehavior.from(mBinding.bottomSheet);
|
||||
mEditorBottomSheet.addBottomSheetCallback(
|
||||
new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
@@ -1221,13 +1217,6 @@ public class EditorActivity extends IDEActivity
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.bottomSheet.binding.headerContainer.setOnClickListener(
|
||||
v -> {
|
||||
if (mEditorBottomSheet.getState() != BottomSheetBehavior.STATE_EXPANDED) {
|
||||
mEditorBottomSheet.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}
|
||||
});
|
||||
|
||||
final var observer =
|
||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* This file is part of AndroidIDE.
|
||||
*
|
||||
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* AndroidIDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.itsaky.androidide.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
public class EditorBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
|
||||
|
||||
private View pager;
|
||||
|
||||
public EditorBottomSheetBehavior(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
}
|
||||
|
||||
public void setBinding(View pager) {
|
||||
this.pager = pager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(
|
||||
@NonNull CoordinatorLayout parent, @NonNull V child, @NonNull MotionEvent event) {
|
||||
if (pager != null) {
|
||||
final var rect = getPagerRect();
|
||||
if (rect.contains(event.getX(), event.getY())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.onInterceptTouchEvent(parent, child, event);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private RectF getPagerRect() {
|
||||
final var rect = new RectF();
|
||||
rect.left = pager.getX();
|
||||
rect.top = pager.getY();
|
||||
rect.right = rect.left + pager.getWidth();
|
||||
rect.bottom = rect.top + pager.getHeight();
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import androidx.transition.Slide
|
||||
import androidx.transition.TransitionManager
|
||||
import com.blankj.utilcode.util.KeyboardUtils
|
||||
import com.blankj.utilcode.util.ThreadUtils.runOnUiThread
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
|
||||
import com.google.android.material.tabs.TabLayout.Tab
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
@@ -152,6 +153,13 @@ constructor(
|
||||
}
|
||||
(fragment as ShareableOutputFragment).clearOutput()
|
||||
}
|
||||
|
||||
binding.headerContainer.setOnClickListener {
|
||||
val sheet = BottomSheetBehavior.from(this)
|
||||
if (sheet.state != BottomSheetBehavior.STATE_EXPANDED) {
|
||||
sheet.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
android:layout_height="match_parent"
|
||||
app:behavior_hideable="false"
|
||||
app:behavior_peekHeight="@dimen/editor_sheet_peek_height"
|
||||
app:layout_behavior="com.itsaky.androidide.utils.EditorBottomSheetBehavior" />
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
|
||||
|
||||
<include
|
||||
android:id="@+id/diagnosticInfo"
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user