├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── styles.xml │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── icon_suspend_hide_off.png │ │ │ ├── icon_suspend_hide_on.png │ │ │ ├── icon_suspend_menu_left.png │ │ │ └── icon_suspend_menu_right.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ └── layout │ │ │ ├── view_game_suspend_menu.xml │ │ │ ├── view_game_suspend_hide.xml │ │ │ ├── activity_main.xml │ │ │ └── view_game_suspend_remind.xml │ │ ├── java │ │ └── com │ │ │ └── toeii │ │ │ └── mhrfloatwindow │ │ │ ├── window │ │ │ ├── SkipActivity.java │ │ │ ├── Config.java │ │ │ ├── view │ │ │ │ ├── FloatWindowHideView.java │ │ │ │ ├── FloatWindowRemindView.java │ │ │ │ ├── FloatWindowMenuView.java │ │ │ │ └── FloatWindowMainView.java │ │ │ ├── SuspendMenuEntity.java │ │ │ └── FloatWindowManager.java │ │ │ ├── MainActivity.java │ │ │ └── ScreenUtils.java │ │ └── AndroidManifest.xml ├── build.gradle ├── proguard-rules.pro └── app.iml ├── settings.gradle ├── images ├── float_window.gif └── float_window_new.gif ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── FloatWindow.iml ├── gradlew.bat └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | FloatWindow -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /images/float_window.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/images/float_window.gif -------------------------------------------------------------------------------- /images/float_window_new.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/images/float_window_new.gif -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | GameSDK FloatWindow 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/icon_suspend_hide_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-xhdpi/icon_suspend_hide_off.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/icon_suspend_hide_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-xhdpi/icon_suspend_hide_on.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/icon_suspend_menu_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-xhdpi/icon_suspend_menu_left.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/icon_suspend_menu_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/toeii/FloatWindow/HEAD/app/src/main/res/mipmap-xhdpi/icon_suspend_menu_right.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri May 22 15:24:54 CST 2020 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-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | db_files 2 | .DS_Store 3 | /gen/ 4 | /bin/ 5 | build.properties 6 | local.properties 7 | .settings/* 8 | *.iml 9 | *.orig 10 | .idea/* 11 | obj/* 12 | out/* 13 | build/* 14 | .gradle/* 15 | proguard/* 16 | libs/android-support-v4.jar.properties 17 | /project.properties 18 | /gradle/ 19 | /gradlew 20 | /gradlew.bat 21 | /build/ 22 | /captures/ 23 | /bug/ 24 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # introduce 2 | - A floating window menu 3 | - Function: 4 | the menu control, 5 | turn to hide, 6 | sliding handle, 7 | timing close to the edge, 8 | transparent processing... 9 | - Support minSdkVersion 9+ 10 | - Out of the Service 11 | 12 | # 介绍 13 | - 该悬浮窗实现了久游悬浮窗的大部分效果。 14 | - 菜单检出、翻转显示隐藏、滑动处理、定时贴边以及透明化... 15 | - 最低兼容到2.3+ 16 | - 脱离Service 17 | 18 | # Demo 19 | ![after](https://github.com/toeii/FloatWindow/blob/master/images/float_window_new.gif) 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_game_suspend_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | 6 | defaultConfig { 7 | applicationId "com.toeii.mhrfloatwindow" 8 | minSdkVersion 9 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:23.1.0' 24 | } 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_game_suspend_hide.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/toeii/mhrfloatwindow/window/SkipActivity.java: -------------------------------------------------------------------------------- 1 | package com.toeii.mhrfloatwindow.window; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.RelativeLayout; 7 | 8 | import com.toeii.mhrfloatwindow.R; 9 | 10 | public class SkipActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | RelativeLayout relativeLayout = (RelativeLayout) findViewById(R.id.rl_layout); 17 | relativeLayout.setBackgroundColor(Color.BLUE); 18 | } 19 | 20 | @Override 21 | protected void onDestroy() { 22 | super.onDestroy(); 23 | FloatWindowManager.getInstance(this).showFloatWindow(this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /FloatWindow.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/toeii/mhrfloatwindow/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.toeii.mhrfloatwindow; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.view.Window; 6 | import android.view.WindowManager; 7 | 8 | import com.toeii.mhrfloatwindow.window.FloatWindowManager; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | FloatWindowManager.getInstance(this).showFloatWindow(this); 17 | } 18 | 19 | @Override 20 | protected void onPause() { 21 | super.onPause(); 22 | // FloatWindowManager.getInstance(this).removeMainWindow(); 23 | } 24 | 25 | @Override 26 | protected void onDestroy() { 27 | super.onDestroy(); 28 | FloatWindowManager.getInstance(this).destroyFloatWindow(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/toeii/mhrfloatwindow/window/Config.java: -------------------------------------------------------------------------------- 1 | package com.toeii.mhrfloatwindow.window; 2 | 3 | /** 4 | * 5 | * @version 1.0.0.0 6 | * @author toeii 7 | * @date 2016/9/6 8 | * @path https://github.com/toeii/FloatWindow 9 | * 10 | */ 11 | public class Config { 12 | 13 | //悬浮窗Key 14 | public static abstract class SuspendKey{ 15 | public final static String WEB_PATH = "web_path"; 16 | public final static String KEY_USER_ID= "key_user_id"; 17 | public final static String KEY_SERVER_STATE="key_server_state"; 18 | public final static String SP_CHOOSE = "choose"; 19 | public final static String FLOAT_WINDOW = "float_window"; 20 | } 21 | 22 | //悬浮窗服务状态 23 | public static abstract class SuspendServerState{ 24 | public final static int DEFAULT = 0; 25 | public final static int SHOW = 1; 26 | public final static int HIDE = 2; 27 | public final static int DESTROY = 3; 28 | } 29 | 30 | //悬浮窗菜单点击隐藏状态 31 | public static abstract class SuspendMenuOnClikHideState{ 32 | public final static int DEFAULT = 0; 33 | public final static int SHOW = 1; 34 | public final static int HIDE = 2; 35 | public final static int DESTROY = 3; 36 | } 37 | 38 | public static abstract class SuspendSkipType{ 39 | public final static int ALL_SKIP = -1; 40 | public final static int DEFAULT_SKIP = 0; 41 | public final static int APP_SKIP = 2; 42 | public final static int WEB_SKIP = 1; 43 | public final static int ACCOUNT_SKIP = 3; 44 | public final static int GIFT_SKIP = 4; 45 | public final static int CIRCLE_SKIP = 5; 46 | public final static int MHR_CHAT_SKIP = 6; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/toeii/mhrfloatwindow/window/view/FloatWindowHideView.java: -------------------------------------------------------------------------------- 1 | package com.toeii.mhrfloatwindow.window.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.graphics.drawable.Drawable; 6 | import android.view.Gravity; 7 | import android.view.LayoutInflater; 8 | import android.widget.RelativeLayout; 9 | import android.widget.TextView; 10 | 11 | import com.toeii.mhrfloatwindow.R; 12 | import com.toeii.mhrfloatwindow.ScreenUtils; 13 | 14 | /** 15 | * 隐藏窗 16 | * @version 1.0.0.0 17 | * @author toeii 18 | * @date 2016/9/6 19 | * @path https://github.com/toeii/FloatWindow 20 | * 21 | */ 22 | public class FloatWindowHideView extends RelativeLayout { 23 | 24 | private Context mContext; 25 | 26 | private TextView mHideSuspendTv; 27 | private RelativeLayout mHideSuspendRl; 28 | 29 | public FloatWindowHideView(Context context) { 30 | super(context); 31 | this.mContext = context; 32 | LayoutInflater.from(context).inflate(R.layout.view_game_suspend_hide, this); 33 | mHideSuspendRl = (RelativeLayout) findViewById(R.id.rl_suspend_hide); 34 | mHideSuspendTv = (TextView) findViewById(R.id.tv_suspend_hide); 35 | 36 | updateHideView(false); 37 | } 38 | 39 | public void updateHideView(boolean isCollsionWithRect){ 40 | Drawable drawable = null; 41 | if(isCollsionWithRect){ 42 | drawable = getResources().getDrawable(R.mipmap.icon_suspend_hide_on); 43 | mHideSuspendTv.setTextColor(Color.parseColor("#FFD800")); 44 | }else{ 45 | drawable = getResources().getDrawable(R.mipmap.icon_suspend_hide_off); 46 | mHideSuspendTv.setTextColor(Color.WHITE); 47 | } 48 | if(null != drawable){ 49 | drawable.setBounds(0, 0, ScreenUtils.dip2px(mContext, 30), ScreenUtils.dip2px(mContext, 30)); 50 | } 51 | mHideSuspendTv.setCompoundDrawables(null, drawable, null, null); 52 | mHideSuspendTv.setCompoundDrawablePadding(ScreenUtils.dip2px(mContext, 8)); 53 | mHideSuspendTv.setGravity(Gravity.CENTER); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/toeii/mhrfloatwindow/window/SuspendMenuEntity.java: -------------------------------------------------------------------------------- 1 | package com.toeii.mhrfloatwindow.window; 2 | 3 | import android.graphics.drawable.Drawable; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * 9 | * @version 1.0.0.0 10 | * @author toeii 11 | * @date 2016/9/6 12 | * @path https://github.com/toeii/FloatWindow 13 | * 14 | */ 15 | public class SuspendMenuEntity implements Serializable { 16 | 17 | private static final long serialVersionUID = 87573344585549130L; 18 | 19 | private String menuItemName; 20 | private int menuItemType; 21 | private String menuItemIcon; 22 | private Drawable menuItemLocalIcon; 23 | private String menuItemPath; 24 | private String menuItemParams; 25 | 26 | 27 | public SuspendMenuEntity() { 28 | 29 | } 30 | 31 | public Drawable getMenuItemLocalIcon() { 32 | return menuItemLocalIcon; 33 | } 34 | 35 | public void setMenuItemLocalIcon(Drawable menuItemLocalIcon) { 36 | this.menuItemLocalIcon = menuItemLocalIcon; 37 | } 38 | 39 | public int getMenuItemType() { 40 | return menuItemType; 41 | } 42 | 43 | public void setMenuItemType(int menuItemType) { 44 | this.menuItemType = menuItemType; 45 | } 46 | 47 | public String getMenuItemParams() { 48 | return menuItemParams; 49 | } 50 | 51 | public void setMenuItemParams(String menuItemParams) { 52 | this.menuItemParams = menuItemParams; 53 | } 54 | 55 | public String getMenuItemName() { 56 | return menuItemName; 57 | } 58 | 59 | public void setMenuItemName(String menuItemName) { 60 | this.menuItemName = menuItemName; 61 | } 62 | 63 | public String getMenuItemIcon() { 64 | return menuItemIcon; 65 | } 66 | 67 | public void setMenuItemIcon(String menuItemIcon) { 68 | this.menuItemIcon = menuItemIcon; 69 | } 70 | 71 | public String getMenuItemPath() { 72 | return menuItemPath; 73 | } 74 | 75 | public void setMenuItemPath(String menuItemPath) { 76 | this.menuItemPath = menuItemPath; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /app/src/main/java/com/toeii/mhrfloatwindow/window/view/FloatWindowRemindView.java: -------------------------------------------------------------------------------- 1 | package com.toeii.mhrfloatwindow.window.view; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.CheckBox; 9 | import android.widget.LinearLayout; 10 | 11 | import com.toeii.mhrfloatwindow.R; 12 | import com.toeii.mhrfloatwindow.window.Config; 13 | import com.toeii.mhrfloatwindow.window.FloatWindowManager; 14 | 15 | /** 16 | * 翻转提醒窗 17 | * @version 1.0.0.0 18 | * @author toeii 19 | * @date 2016/9/6 20 | * @path https://github.com/toeii/FloatWindow 21 | * 22 | */ 23 | public class FloatWindowRemindView extends LinearLayout { 24 | 25 | private SharedPreferences preferences; 26 | 27 | private FloatWindowManager floatWindowManager; 28 | 29 | public FloatWindowRemindView(final Context context) { 30 | super(context); 31 | preferences = context.getSharedPreferences(Config.SuspendKey.FLOAT_WINDOW, Context.MODE_PRIVATE); 32 | LayoutInflater.from(context).inflate(R.layout.view_game_suspend_remind, this); 33 | floatWindowManager = FloatWindowManager.getInstance(context); 34 | final CheckBox suspendRemindCb = (CheckBox) findViewById(R.id.cb_suspend_remindwindow); 35 | Button suspendRemindCancel = (Button) findViewById(R.id.btn_suspend_remind_cancel); 36 | Button suspendRemindHide = (Button) findViewById(R.id.btn_suspend_remind_hide); 37 | 38 | suspendRemindCancel.setOnClickListener(new OnClickListener() { 39 | 40 | @Override 41 | public void onClick(View v) { 42 | floatWindowManager.removeRemindWindow(); 43 | floatWindowManager.createMainWindow(context); 44 | if(null != floatWindowManager.getFloatWindowMainView()){ 45 | floatWindowManager.getFloatWindowMainView().suspendMoveEnd(); 46 | } 47 | } 48 | }); 49 | 50 | suspendRemindHide.setOnClickListener(new OnClickListener() { 51 | @Override 52 | public void onClick(View v) { 53 | SharedPreferences.Editor editor = preferences.edit(); 54 | if (suspendRemindCb.isChecked()) { 55 | editor.putBoolean(Config.SuspendKey.SP_CHOOSE, true); 56 | } else { 57 | editor.putBoolean(Config.SuspendKey.SP_CHOOSE, false); 58 | } 59 | editor.apply(); 60 | floatWindowManager.removeRemindWindow(); 61 | } 62 | }); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/toeii/mhrfloatwindow/ScreenUtils.java: -------------------------------------------------------------------------------- 1 | package com.toeii.mhrfloatwindow; 2 | 3 | import android.content.Context; 4 | import android.content.res.Configuration; 5 | import android.view.WindowManager; 6 | 7 | /** 8 | * 9 | * @version 1.0.0.0 10 | * @author toeii 11 | * @date 2016/9/6 12 | * @path https://github.com/toeii/FloatWindow 13 | * 14 | */ 15 | public class ScreenUtils { 16 | 17 | /** 18 | * 获取屏幕宽度 19 | * 20 | * @param context 21 | * @return 22 | */ 23 | public static int getScreenWidth(Context context) { 24 | return ((WindowManager) context 25 | .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() 26 | .getWidth(); 27 | } 28 | 29 | /** 30 | * 获取屏幕宽度 31 | * 32 | * @param context 33 | * @return 34 | */ 35 | public static int getScreenHeight(Context context) { 36 | return ((WindowManager) context 37 | .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() 38 | .getHeight(); 39 | } 40 | 41 | /** 42 | * 获得状态栏的高度 43 | * 44 | * @param context 45 | * @return 46 | */ 47 | public static int getStatusHeight(Context context) { 48 | 49 | int statusHeight = -1; 50 | try { 51 | Class clazz = Class.forName("com.android.internal.R$dimen"); 52 | Object object = clazz.newInstance(); 53 | int height = Integer.parseInt(clazz.getField("status_bar_height").get(object).toString()); 54 | statusHeight = context.getResources().getDimensionPixelSize(height); 55 | } catch (Exception e) { 56 | e.printStackTrace(); 57 | } 58 | return statusHeight; 59 | } 60 | 61 | public static int dip2px(Context context, float dpValue) { 62 | final float scale = context.getResources().getDisplayMetrics().density; 63 | return (int) (dpValue * scale + 0.5f); 64 | } 65 | 66 | public static int px2dip(Context context, float pxValue) { 67 | final float scale = context.getResources().getDisplayMetrics().density; 68 | return (int) (pxValue / scale + 0.5f); 69 | } 70 | 71 | public static boolean isScreenChange(Context context) { 72 | Configuration mConfiguration = context.getResources().getConfiguration(); 73 | int ori = mConfiguration.orientation; 74 | if (ori == Configuration.ORIENTATION_LANDSCAPE) { 75 | // 横屏 76 | return true; 77 | } else if (ori == Configuration.ORIENTATION_PORTRAIT) { 78 | // 竖屏 79 | return false; 80 | } 81 | // return AppConfig.mhrOrientation == MHROrientation.LANDSCAPE; 82 | return false; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 25 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_game_suspend_remind.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 29 | 30 | 36 | 37 | 45 | 46 | 55 | 56 | 57 | 64 | 65 |