├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── activity_second.xml │ │ │ │ ├── activity_third.xml │ │ │ │ ├── layout_float_view.xml │ │ │ │ └── activity_main.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── zj │ │ │ │ └── sample │ │ │ │ ├── SecondActivity.kt │ │ │ │ ├── ThirdActivity.kt │ │ │ │ ├── widget │ │ │ │ └── FloatingBall.java │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── com │ │ └── zj │ │ └── sample │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── easyfloat ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ └── imuxuan.png │ │ │ ├── values │ │ │ │ └── ids.xml │ │ │ └── layout │ │ │ │ └── en_floating_view.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── zj │ │ │ └── easyfloat │ │ │ ├── floatingview │ │ │ ├── MagnetViewListener.java │ │ │ ├── EnFloatingView.java │ │ │ ├── utils │ │ │ │ ├── EnContext.java │ │ │ │ └── SystemUtils.java │ │ │ ├── IFloatingView.java │ │ │ ├── FloatingView.java │ │ │ └── FloatingMagnetView.java │ │ │ └── EasyFloat.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── zj │ │ └── floatlibrary │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md ├── publish-mavencentral.gradle └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /easyfloat/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /easyfloat/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':easyfloat' 2 | include ':app' 3 | rootProject.name = "EasyFloat" -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EasyFloat 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /easyfloat/src/main/res/drawable/imuxuan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/easyfloat/src/main/res/drawable/imuxuan.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /easyfloat/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RicardoJiang/EasyFloat/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /easyfloat/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue May 04 14:44:02 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | .idea/* -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /easyfloat/src/main/java/com/zj/easyfloat/floatingview/MagnetViewListener.java: -------------------------------------------------------------------------------- 1 | package com.zj.easyfloat.floatingview; 2 | 3 | /** 4 | * Created by liyunpeng on 17/11/29. 5 | */ 6 | public interface MagnetViewListener { 7 | 8 | void onRemove(FloatingMagnetView magnetView); 9 | 10 | void onClick(FloatingMagnetView magnetView); 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/zj/sample/SecondActivity.kt: -------------------------------------------------------------------------------- 1 | package com.zj.sample 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | 6 | class SecondActivity : AppCompatActivity() { 7 | override fun onCreate(savedInstanceState: Bundle?) { 8 | super.onCreate(savedInstanceState) 9 | setContentView(R.layout.activity_second) 10 | } 11 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zj/sample/ThirdActivity.kt: -------------------------------------------------------------------------------- 1 | package com.zj.sample 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | 6 | class ThirdActivity : AppCompatActivity() { 7 | override fun onCreate(savedInstanceState: Bundle?) { 8 | super.onCreate(savedInstanceState) 9 | setContentView(R.layout.activity_third) 10 | } 11 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /easyfloat/src/main/res/layout/en_floating_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_second.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_third.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/zj/sample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.zj.sample 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.zj.easyfloat", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /easyfloat/src/androidTest/java/com/zj/floatlibrary/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.zj.floatlibrary 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.zj.floatlibrary.test", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /easyfloat/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_float_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 19 | 20 | 26 | -------------------------------------------------------------------------------- /easyfloat/src/main/java/com/zj/easyfloat/floatingview/EnFloatingView.java: -------------------------------------------------------------------------------- 1 | package com.zj.easyfloat.floatingview; 2 | 3 | import android.content.Context; 4 | import android.widget.ImageView; 5 | 6 | import androidx.annotation.DrawableRes; 7 | import androidx.annotation.LayoutRes; 8 | import androidx.annotation.NonNull; 9 | 10 | import com.zj.easyfloat.R; 11 | 12 | /** 13 | * @ClassName EnFloatingView 14 | * @Description 悬浮窗 15 | * @Author Yunpeng Li 16 | * @Creation 2018/3/15 下午5:04 17 | * @Mender Yunpeng Li 18 | * @Modification 2018/3/15 下午5:04 19 | */ 20 | public class EnFloatingView extends FloatingMagnetView { 21 | 22 | private final ImageView mIcon; 23 | 24 | public EnFloatingView(@NonNull Context context) { 25 | this(context, R.layout.en_floating_view); 26 | } 27 | 28 | public EnFloatingView(@NonNull Context context, @LayoutRes int resource) { 29 | super(context, null); 30 | inflate(context, resource, this); 31 | mIcon = findViewById(R.id.icon); 32 | } 33 | 34 | public void setIconImage(@DrawableRes int resId){ 35 | mIcon.setImageResource(resId); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /easyfloat/src/main/java/com/zj/easyfloat/floatingview/utils/EnContext.java: -------------------------------------------------------------------------------- 1 | package com.zj.easyfloat.floatingview.utils; 2 | 3 | import android.app.Application; 4 | 5 | /** 6 | * Created by Yunpeng Li on 2018/11/8. 7 | */ 8 | public class EnContext { 9 | 10 | private static final Application INSTANCE; 11 | 12 | static { 13 | Application app = null; 14 | try { 15 | app = (Application) Class.forName("android.app.AppGlobals").getMethod("getInitialApplication").invoke(null); 16 | if (app == null) 17 | throw new IllegalStateException("Static initialization of Applications must be on main thread."); 18 | } catch (final Exception e) { 19 | e.printStackTrace(); 20 | try { 21 | app = (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null); 22 | } catch (final Exception ex) { 23 | e.printStackTrace(); 24 | } 25 | } finally { 26 | INSTANCE = app; 27 | } 28 | } 29 | 30 | public static Application get() { 31 | return INSTANCE; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /easyfloat/src/main/java/com/zj/easyfloat/floatingview/IFloatingView.java: -------------------------------------------------------------------------------- 1 | package com.zj.easyfloat.floatingview; 2 | 3 | import android.app.Activity; 4 | import android.view.ViewGroup; 5 | import android.widget.FrameLayout; 6 | 7 | import androidx.annotation.DrawableRes; 8 | import androidx.annotation.LayoutRes; 9 | 10 | 11 | /** 12 | * Created by Yunpeng Li on 2018/3/15. 13 | */ 14 | 15 | public interface IFloatingView { 16 | 17 | FloatingView remove(); 18 | 19 | FloatingView add(); 20 | 21 | FloatingView attach(Activity activity); 22 | 23 | FloatingView attach(FrameLayout container); 24 | 25 | FloatingView detach(Activity activity); 26 | 27 | FloatingView detach(FrameLayout container); 28 | 29 | FloatingMagnetView getView(); 30 | 31 | FloatingView icon(@DrawableRes int resId); 32 | 33 | FloatingView customView(FloatingMagnetView viewGroup); 34 | 35 | FloatingView customView(@LayoutRes int resource); 36 | 37 | FloatingView layoutParams(ViewGroup.LayoutParams params); 38 | 39 | FloatingView listener(MagnetViewListener magnetViewListener); 40 | 41 | FloatingView dragEnable(boolean dragEnable); 42 | 43 | FloatingView setAutoMoveToEdge(boolean autoMoveToEdge); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | useLocal=false -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 |