Skip to content

Commit

Permalink
Merge branch 'master' into support
Browse files Browse the repository at this point in the history
# Conflicts:
#	maven-upload.gradle
  • Loading branch information
mbacuiz committed Dec 24, 2020
2 parents 612df6b + a616dac commit 17af893
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 14 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Android稳定高效的浮层创建管理框架。
allprojects {
repositories {
maven { url 'https://www.jitpack.io' }
// 支持4.1.0及以后版本
// maven { url "https://gitee.com/goweii/maven-repository/raw/master/releases/" }
}
}
```
Expand Down Expand Up @@ -137,6 +139,11 @@ dependencies {

[点击查看详细更新说明](https://github.com/goweii/AnyLayer/releases)

### 4.1.1

- 修复物理返回键事件拦截问题
- 修复带输入框弹窗点击外部关闭需要2次才能触发的问题

### 4.1.0

- 适配分屏小窗和横竖屏切换
Expand Down
41 changes: 32 additions & 9 deletions anylayer/src/main/java/per/goweii/anylayer/ViewManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,15 @@ public void setOnKeyListener(@Nullable OnKeyListener onKeyListener) {
* 添加到父View
*/
private void onAttach() {
mParent.addView(mChild);
if (mOnKeyListener != null) {
mChild.setFocusable(true);
mChild.setFocusableInTouchMode(true);
mChild.requestFocus();
currentKeyView = mChild;
mLayerKeyListener = new LayerKeyListener();
findFocusViewAndBindKeyListener();
mLayerGlobalFocusChangeListener = new LayerGlobalFocusChangeListener();
mChild.getViewTreeObserver().addOnGlobalFocusChangeListener(mLayerGlobalFocusChangeListener);
mLayerKeyListener = new LayerKeyListener();
currentKeyView.setOnKeyListener(mLayerKeyListener);
}
mParent.addView(mChild);
if (mOnLifeListener != null) {
mOnLifeListener.onAttach();
}
Expand All @@ -129,17 +127,42 @@ private void onDetach() {
}
}

private void findFocusViewAndBindKeyListener() {
Utils.onViewLayout(mChild, new Runnable() {
@Override
public void run() {
currentKeyView = mChild.findFocus();
if (currentKeyView != null) {
currentKeyView.setOnKeyListener(mLayerKeyListener);
return;
}
mChild.requestFocus();
currentKeyView = mChild.findFocus();
if (currentKeyView != null) {
currentKeyView.setOnKeyListener(mLayerKeyListener);
}
}
});
}

private final class LayerGlobalFocusChangeListener implements ViewTreeObserver.OnGlobalFocusChangeListener {
@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
if (currentKeyView != null) {
currentKeyView.setOnKeyListener(null);
}
if (oldFocus != null) {
oldFocus.setOnKeyListener(null);
currentKeyView = mChild.findFocus();
if (currentKeyView != null) {
currentKeyView.setOnKeyListener(mLayerKeyListener);
return;
}
View rootFocus = mChild.getRootView().findFocus();
if (rootFocus != null) {
return;
}
if (newFocus != null) {
currentKeyView = newFocus;
mChild.requestFocus();
currentKeyView = mChild.findFocus();
if (currentKeyView != null) {
currentKeyView.setOnKeyListener(mLayerKeyListener);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,18 +380,18 @@ public void run() {

protected void initContainer() {
if (getConfig().mOutsideInterceptTouchEvent) {
getViewHolder().getChild().setClickable(true);
getViewHolder().getBackground().setClickable(true);
if (getConfig().mCancelableOnTouchOutside) {
getViewHolder().getChild().setOnClickListener(new View.OnClickListener() {
getViewHolder().getBackground().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
} else {
getViewHolder().getChild().setOnClickListener(null);
getViewHolder().getChild().setClickable(false);
getViewHolder().getBackground().setOnClickListener(null);
getViewHolder().getBackground().setClickable(false);
}
if (getConfig().mOutsideTouchedToDismiss || getConfig().mOutsideTouchedListener != null) {
getViewHolder().getChild().setOnTouchedListener(new ContainerLayout.OnTouchedListener() {
Expand Down
2 changes: 1 addition & 1 deletion maven-upload.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'maven'

group "per.goweii.anylayer"
version "4.1.0-support"
version "4.1.1-support"

uploadArchives {
repositories {
Expand Down

0 comments on commit 17af893

Please sign in to comment.