Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #148

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

test #148

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# FloatWindow 安卓任意界面悬浮窗
[![](https://jitpack.io/v/yhaolpz/FloatWindow.svg)](https://jitpack.io/#yhaolpz/FloatWindow)
[![](https://jitpack.io/v/PBK-B/FloatWindow.svg)](https://jitpack.io/#PBK-B/FloatWindow)


![悬浮按钮图](https://raw.githubusercontent.com/yhaolpz/FixedFloatWindow/master/slide.gif)
Expand Down Expand Up @@ -30,19 +30,19 @@
第 1 步、在工程的 build.gradle 中添加:

```
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```
第 2 步、在应用的 build.gradle 中添加:

```
dependencies {
compile 'com.github.yhaolpz:FloatWindow:1.0.9'
}
dependencies {
implementation 'com.github.PBK-B:FloatWindow:1.0.9'
}
```

使用:
Expand Down Expand Up @@ -176,6 +176,16 @@ setMoveStyle 方法可设置动画效果,只在 MoveType.slide 或 MoveType.ba

本人已尽量去兼容更多机型,但经济有限,如果你想帮助此库,提 Issues 标出当前版本不适配的机型即可,感谢~

### 新增功能
1, setFlags (可修复悬浮窗 TextEdit 不可弹出输入法)
```java
// 使悬浮窗获取焦点
FloatWindow.get().updateFlags(WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);

// 使悬浮窗失去焦点
FloatWindow.get().updateFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

```

**更新日志**
--
Expand Down
10 changes: 5 additions & 5 deletions floatwindow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

}

Expand All @@ -25,14 +25,14 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestCompile('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
implementation 'androidx.appcompat:appcompat:1.0.0'
testCompile 'junit:junit:4.12'
}

// JitPack Maven
apply plugin: 'com.github.dcendents.android-maven'
// apply plugin: 'com.github.dcendents.android-maven'
// Your Group
group='com.github.yhaolpz'
// group='com.github.yhaolpz'
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.example.fixedfloatwindow;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.RequiresApi;

import androidx.annotation.RequiresApi;

import java.util.ArrayList;
import java.util.List;
Expand Down
12 changes: 12 additions & 0 deletions floatwindow/src/main/java/com/yhao/floatwindow/FloatPhone.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public void setGravity(int gravity, int xOffset, int yOffset) {
mLayoutParams.y = mY = yOffset;
}

@Override
void setFlags(int flags) {
super.setFlags(flags);
mLayoutParams.flags = flags;
}

@Override
public void init() {
Expand Down Expand Up @@ -143,6 +148,13 @@ void updateY(int y) {
mWindowManager.updateViewLayout(mView, mLayoutParams);
}

@Override
void updateFlags(int flags) {
if (isRemove) return;
mLayoutParams.flags = flags;
mWindowManager.updateViewLayout(mView, mLayoutParams);
}

@Override
int getX() {
return mX;
Expand Down
4 changes: 4 additions & 0 deletions floatwindow/src/main/java/com/yhao/floatwindow/FloatView.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ void updateX(int x) {
void updateY(int y) {
}

void setFlags(int flags) {}

void updateFlags(int flags) {}

int getX() {
return 0;
}
Expand Down
15 changes: 11 additions & 4 deletions floatwindow/src/main/java/com/yhao/floatwindow/FloatWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import android.animation.TimeInterpolator;
import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.LayoutRes;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -61,6 +62,7 @@ public static class B {
int mWidth = ViewGroup.LayoutParams.WRAP_CONTENT;
int mHeight = ViewGroup.LayoutParams.WRAP_CONTENT;
int gravity = Gravity.TOP | Gravity.START;
int mFlags;
int xOffset;
int yOffset;
boolean mShow = true;
Expand Down Expand Up @@ -110,6 +112,11 @@ public B setWidth(@Screen.screenType int screenType, float ratio) {
return this;
}

public B setFlags(int flags) {
mFlags = flags;
return this;
}


public B setHeight(@Screen.screenType int screenType, float ratio) {
mHeight = (int) ((screenType == Screen.width ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public abstract class IFloatWindow {

public abstract void updateY(@Screen.screenType int screenType,float ratio);

public abstract void updateFlags(int flags);

public abstract View getView();

abstract void dismiss();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private IFloatWindowImpl() {
mFloatView.setSize(mB.mWidth, mB.mHeight);
mFloatView.setGravity(mB.gravity, mB.xOffset, mB.yOffset);
mFloatView.setView(mB.mView);
mFloatView.setFlags(mB.mFlags);
mFloatLifecycle = new FloatLifecycle(mB.mApplicationContext, mB.mShow, mB.mActivities, new LifecycleListener() {
@Override
public void onShow() {
Expand Down Expand Up @@ -110,6 +111,7 @@ public void hide() {

@Override
public boolean isShowing() {
if(mB == null) return false;
return isShow;
}

Expand Down Expand Up @@ -156,6 +158,11 @@ public void updateY(int screenType, float ratio) {

}

@Override
public void updateFlags(int flags) {
mFloatView.updateFlags(flags);
}

@Override
public int getX() {
return mFloatView.getX();
Expand Down
3 changes: 2 additions & 1 deletion floatwindow/src/main/java/com/yhao/floatwindow/MoveType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.yhao.floatwindow;

import android.support.annotation.IntDef;

import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import android.os.Binder;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.RequiresApi;
import android.view.View;
import android.view.WindowManager;

import androidx.annotation.RequiresApi;

import java.lang.reflect.Method;

/**
Expand Down
3 changes: 2 additions & 1 deletion floatwindow/src/main/java/com/yhao/floatwindow/Screen.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.yhao.floatwindow;

import android.support.annotation.IntDef;

import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
1 change: 0 additions & 1 deletion floatwindow/src/main/java/com/yhao/floatwindow/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.graphics.Rect;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.RequiresApi;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
Expand Down