├── settings.gradle
├── app
├── src
│ └── main
│ │ ├── assets
│ │ └── xposed_init
│ │ ├── res
│ │ ├── drawable
│ │ │ ├── movable_done.png
│ │ │ ├── blacklist_add.png
│ │ │ ├── blacklist_help.png
│ │ │ ├── movable_corner.png
│ │ │ ├── blacklist_cancel.png
│ │ │ ├── blacklist_search.png
│ │ │ ├── movable_overflow.png
│ │ │ ├── movable_quadrant.png
│ │ │ ├── movable_title_max.png
│ │ │ ├── movable_title_min.png
│ │ │ ├── movable_title_close.png
│ │ │ ├── movable_title_more.png
│ │ │ ├── movable_title_max_old.png
│ │ │ ├── movable_title_min_old.png
│ │ │ ├── movable_title_more_old.png
│ │ │ ├── multiwindow_tray_close.png
│ │ │ ├── multiwindow_tray_reset.png
│ │ │ ├── multiwindow_tray_swap.png
│ │ │ ├── movable_title_close_old.png
│ │ │ ├── movable_title_max_ssnjr.png
│ │ │ ├── movable_title_min_ssnjr.png
│ │ │ ├── movable_title_more_ssnjr.png
│ │ │ ├── multiwindow_tray_recents.png
│ │ │ ├── movable_title_close_ssnjr.png
│ │ │ ├── round_rect.xml
│ │ │ └── bg_card_ui.xml
│ │ ├── drawable-hdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_launcher.png
│ │ ├── values
│ │ │ ├── styles.xml
│ │ │ └── arrays.xml
│ │ ├── layout
│ │ │ ├── view_statusbar_taskbar_holder.xml
│ │ │ ├── dialog_number_picker.xml
│ │ │ ├── view_statusbar_taskbar_icon.xml
│ │ │ ├── floatdot_submenu_item.xml
│ │ │ ├── activity_viewpager.xml
│ │ │ ├── pref_seekbar.xml
│ │ │ ├── dialog_blacklist.xml
│ │ │ ├── floatdot_launcher_menuitem.xml
│ │ │ ├── dialog_floatdot.xml
│ │ │ ├── multiwindow_recents_item.xml
│ │ │ ├── movable_dialog_transparency.xml
│ │ │ ├── view_app_list.xml
│ │ │ ├── view_package_list.xml
│ │ │ ├── dialog_colorpicker.xml
│ │ │ ├── dialog_titlebar_icon_theme_chooser.xml
│ │ │ ├── activity_testing.xml
│ │ │ └── movable_window.xml
│ │ ├── menu
│ │ │ └── launcher_popupmenu.xml
│ │ └── xml
│ │ │ ├── pref_moving.xml
│ │ │ ├── pref_movable_titlebar_others.xml
│ │ │ ├── pref_floatdot.xml
│ │ │ ├── pref_general.xml
│ │ │ └── pref_behavior.xml
│ │ ├── java
│ │ └── com
│ │ │ └── zst
│ │ │ └── xposed
│ │ │ └── halo
│ │ │ └── floatingwindow3
│ │ │ ├── floatdot
│ │ │ ├── XHFWInterface.aidl
│ │ │ ├── BootReceiver.java
│ │ │ └── CallReceiver.java
│ │ │ ├── prefs
│ │ │ ├── WidgetWindowAlphaPicker.java
│ │ │ ├── WidgetBackgroundDimPicker.java
│ │ │ ├── IntListPreference.java
│ │ │ ├── FloatDotFragment.java
│ │ │ ├── MovingFragment.java
│ │ │ ├── adapters
│ │ │ │ ├── PageAdapter.java
│ │ │ │ ├── PackageNameAdapter.java
│ │ │ │ └── AppAdapter.java
│ │ │ ├── WidgetNumberPicker.java
│ │ │ ├── OverlayFragment.java
│ │ │ ├── colorpicker
│ │ │ │ ├── ColorSettingsDialog.java
│ │ │ │ ├── AlphaPatternDrawable.java
│ │ │ │ └── ColorPanelView.java
│ │ │ ├── ColorPicker.java
│ │ │ ├── WidgetFloatPercentage.java
│ │ │ ├── BehaviorFragment.java
│ │ │ ├── FloatDotActivity.java
│ │ │ ├── MaximizedActivity.java
│ │ │ ├── BlacklistActivity.java
│ │ │ ├── WhitelistActivity.java
│ │ │ ├── MainFragment.java
│ │ │ ├── WidgetGravityChooser.java
│ │ │ └── LauncherListActivity.java
│ │ │ ├── TestingSettingHook.java
│ │ │ ├── RightResizable.java
│ │ │ ├── OutlineRightResizable.java
│ │ │ ├── Movable.java
│ │ │ ├── MainPreference.java
│ │ │ ├── OutlineLeftResizable.java
│ │ │ ├── Resizable.java
│ │ │ ├── Compatibility.java
│ │ │ ├── MainXposed.java
│ │ │ ├── SystemUIOutliner.java
│ │ │ └── AeroSnap.java
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── .idea
├── inspectionProfiles
│ ├── profiles_settings.xml
│ └── Project_Default.xml
└── libraries
│ ├── api_82.xml
│ ├── support_annotations_23_3_0.xml
│ ├── support_v13_23_3_0.xml
│ └── support_v4_23_3_0.xml
└── .gitignore
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/assets/xposed_init:
--------------------------------------------------------------------------------
1 | com.zst.xposed.halo.floatingwindow3.MainXposed
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/blacklist_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/blacklist_add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/blacklist_help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/blacklist_help.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_corner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_corner.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/blacklist_cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/blacklist_cancel.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/blacklist_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/blacklist_search.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_overflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_overflow.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_quadrant.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_quadrant.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_max.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_max.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_min.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_min.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_more.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_max_old.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_max_old.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_min_old.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_min_old.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_more_old.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_more_old.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/multiwindow_tray_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/multiwindow_tray_close.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/multiwindow_tray_reset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/multiwindow_tray_reset.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/multiwindow_tray_swap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/multiwindow_tray_swap.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_close_old.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_close_old.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_max_ssnjr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_max_ssnjr.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_min_ssnjr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_min_ssnjr.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_more_ssnjr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_more_ssnjr.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/multiwindow_tray_recents.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/multiwindow_tray_recents.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/movable_title_close_ssnjr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shooash/XHFW3/HEAD/app/src/main/res/drawable/movable_title_close_ssnjr.png
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/libraries/api_82.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/round_rect.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/floatdot/XHFWInterface.aidl:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.floatdot;
2 |
3 | interface XHFWInterface {
4 | // Window management
5 | void bringToFront(int taskId);
6 | void toggleDragger(boolean show);
7 | void removeAppTask(int taskId, int flags);
8 | int getLastTaskId();
9 | int[] getCurrentFloatdotCoordinates();
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/floatdot/BootReceiver.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.floatdot;
2 | import android.content.*;
3 |
4 | public class BootReceiver extends BroadcastReceiver {
5 | @Override
6 | public void onReceive(Context context, Intent intent) {
7 | Intent startServiceIntent = new Intent(context, XHFWService.class);
8 | context.startService(startServiceIntent);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/floatdot/CallReceiver.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.floatdot;
2 | import android.content.*;
3 |
4 | public class CallReceiver extends BroadcastReceiver {
5 | @Override
6 | public void onReceive(Context context, Intent intent) {
7 | Intent startServiceIntent = new Intent(context, XHFWService.class);
8 | context.startService(startServiceIntent);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_statusbar_taskbar_holder.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/support_annotations_23_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 |
6 | # Files for the Dalvik VM
7 | *.dex
8 |
9 | # Java class files
10 | *.class
11 |
12 |
13 | # Generated files
14 | bin/
15 | gen/
16 |
17 | # Gradle files
18 | .gradle/
19 | build/
20 |
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | #AIDE
37 | .classpath
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_number_picker.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_statusbar_taskbar_icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_card_ui.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | -
15 |
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/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 C:\tools\adt-bundle-windows-x86_64-20131030\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/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion '23.0.3'
6 | defaultConfig {
7 | applicationId "com.zst.xposed.halo.floatingwindow3"
8 | minSdkVersion 17
9 | targetSdkVersion 21
10 | versionCode 318
11 | versionName "3.18"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | zipAlignEnabled false
18 | }
19 | }
20 | productFlavors {
21 | }
22 | }
23 |
24 | dependencies {
25 | compile 'com.android.support:support-v13:23.3.0'
26 | provided 'de.robv.android.xposed:api:82'
27 | }
28 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v13_23_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/launcher_popupmenu.xml:
--------------------------------------------------------------------------------
1 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/WidgetWindowAlphaPicker.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.WindowManager;
6 | import android.widget.SeekBar;
7 |
8 | public class WidgetWindowAlphaPicker extends WidgetFloatPercentage {
9 |
10 | public WidgetWindowAlphaPicker(Context context, AttributeSet attrs) {
11 | super(context, attrs);
12 | }
13 |
14 | @Override
15 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
16 | super.onProgressChanged(seekBar, progress, fromUser);
17 | int realValue = progress + Math.round((mMin * 100));
18 | if (getDialog() != null) {
19 | WindowManager.LayoutParams lp = getDialog().getWindow().getAttributes();
20 | lp.alpha = 0.01f * realValue;
21 | getDialog().getWindow().setAttributes(lp);
22 | }
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/WidgetBackgroundDimPicker.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.WindowManager;
6 | import android.widget.SeekBar;
7 |
8 | public class WidgetBackgroundDimPicker extends WidgetFloatPercentage {
9 |
10 | public WidgetBackgroundDimPicker(Context context, AttributeSet attrs) {
11 | super(context, attrs);
12 | }
13 |
14 | @Override
15 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
16 | super.onProgressChanged(seekBar, progress, fromUser);
17 | int realValue = progress + Math.round((mMin * 100));
18 | if (getDialog() != null) {
19 | WindowManager.LayoutParams lp = getDialog().getWindow().getAttributes();
20 | lp.dimAmount = 0.01f * realValue;
21 | getDialog().getWindow().setAttributes(lp);
22 | }
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/.idea/libraries/support_v4_23_3_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/TestingSettingHook.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 | import com.zst.xposed.halo.floatingwindow3.Common;
4 |
5 | import de.robv.android.xposed.XC_MethodHook;
6 | import de.robv.android.xposed.XposedBridge;
7 | import de.robv.android.xposed.XposedHelpers;
8 | import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
9 |
10 | public class TestingSettingHook {
11 |
12 | public static void handleLoadPackage(LoadPackageParam lpp) {
13 | if (lpp.packageName.equals(Common.THIS_MOD_PACKAGE_NAME)) {
14 | Class> hookClass = XposedHelpers.findClass("com.zst.xposed.halo.floatingwindow3.MainPreference",
15 | lpp.classLoader);
16 | XposedBridge.hookAllMethods(hookClass, "testSettings", new XC_MethodHook() {
17 | @Override
18 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
19 | param.args[0] = false;
20 | }
21 | });
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/IntListPreference.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import android.content.Context;
4 | import android.preference.ListPreference;
5 | import android.util.AttributeSet;
6 |
7 | public class IntListPreference extends ListPreference
8 | {
9 | public IntListPreference(Context context, AttributeSet attrs) {
10 | super(context, attrs);
11 | }
12 |
13 | public IntListPreference(Context context) {
14 | super(context);
15 | }
16 |
17 | @Override
18 | protected boolean persistString(String value) {
19 | if(value == null) {
20 | return false;
21 | } else {
22 | return persistInt(Integer.valueOf(value));
23 | }
24 | }
25 |
26 | @Override
27 | protected String getPersistedString(String defaultReturnValue) {
28 | if(getSharedPreferences().contains(getKey())) {
29 | int intValue = getPersistedInt(0);
30 | return String.valueOf(intValue);
31 | } else {
32 | return defaultReturnValue;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/floatdot_submenu_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_moving.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
11 |
19 |
20 |
21 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_viewpager.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
26 |
27 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/FloatDotFragment.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.preference.Preference;
8 | import android.preference.PreferenceActivity;
9 | import android.preference.PreferenceFragment;
10 |
11 | import com.zst.xposed.halo.floatingwindow3.Common;
12 | import com.zst.xposed.halo.floatingwindow3.R;
13 |
14 | public class FloatDotFragment extends PreferenceFragment {
15 |
16 | static FloatDotFragment mInstance;
17 | SharedPreferences mPref;
18 |
19 | public static FloatDotFragment getInstance() {
20 | if (mInstance == null) {
21 | mInstance = new FloatDotFragment();
22 | }
23 | return mInstance;
24 | }
25 | @Override
26 | @SuppressWarnings("deprecation")
27 | @SuppressLint("WorldReadableFiles")
28 | public void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | getPreferenceManager().setSharedPreferencesName(Common.PREFERENCE_MAIN_FILE);
31 | getPreferenceManager().setSharedPreferencesMode(PreferenceActivity.MODE_WORLD_READABLE);
32 | addPreferencesFromResource(R.xml.pref_floatdot);
33 |
34 | mPref = getActivity().getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
35 | PreferenceActivity.MODE_WORLD_READABLE);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/RightResizable.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 | import android.content.Context;
4 | import android.view.MotionEvent;
5 | import android.view.View;
6 | import android.view.Window;
7 | import android.view.WindowManager.LayoutParams;
8 |
9 | public class RightResizable implements View.OnTouchListener {
10 |
11 | final Window window;
12 | final Context context;
13 | final int minSize;
14 |
15 | LayoutParams param;
16 | int distance_from_left;
17 | int distance_from_top;
18 |
19 | public RightResizable(Window window) {
20 | this.window = window;
21 | this.context = window.getContext();
22 | // Convert 100dp to px equivalent from the context
23 | final float scale = window.getContext().getResources().getDisplayMetrics().density;
24 | minSize = (int) (100 * scale + 0.5f);
25 | }
26 |
27 | @Override
28 | public boolean onTouch(View v, MotionEvent event) {
29 | switch (event.getAction()) {
30 |
31 | case MotionEvent.ACTION_DOWN:
32 | param = window.getAttributes();
33 | distance_from_left = param.x;
34 | distance_from_top = param.y;
35 | MovableWindow.unsnap();
36 | break;
37 |
38 | case MotionEvent.ACTION_MOVE:
39 | final int newX = Math.round(event.getRawX());
40 | final int newY = Math.round(event.getRawY());
41 |
42 | int calculatedW = newX - distance_from_left;
43 | int calculatedH = newY - distance_from_top;
44 |
45 | if (calculatedW < minSize) {
46 | calculatedW = minSize;
47 | }
48 | if (calculatedH < minSize) {
49 | calculatedH = minSize;
50 | }
51 | MovableWindow.resize(calculatedW, calculatedH);
52 | break;
53 | }
54 | return false;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_movable_titlebar_others.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
12 |
13 |
14 |
19 |
20 |
28 |
29 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/MovingFragment.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.preference.Preference;
8 | import android.preference.PreferenceActivity;
9 | import android.preference.PreferenceFragment;
10 |
11 | import com.zst.xposed.halo.floatingwindow3.Common;
12 | import com.zst.xposed.halo.floatingwindow3.R;
13 |
14 | public class MovingFragment extends PreferenceFragment {
15 |
16 | static MovingFragment mInstance;
17 | SharedPreferences mPref;
18 |
19 | public static MovingFragment getInstance() {
20 | if (mInstance == null) {
21 | mInstance = new MovingFragment();
22 | }
23 | return mInstance;
24 | }
25 | @Override
26 | @SuppressWarnings("deprecation")
27 | @SuppressLint("WorldReadableFiles")
28 | public void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | getPreferenceManager().setSharedPreferencesName(Common.PREFERENCE_MAIN_FILE);
31 | getPreferenceManager().setSharedPreferencesMode(PreferenceActivity.MODE_WORLD_READABLE);
32 | addPreferencesFromResource(R.xml.pref_moving);
33 | // findPreference(Common.KEY_MOVABLE_WINDOW + "_titlebar_screen").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
34 | // @Override
35 | // public boolean onPreferenceClick(Preference preference) {
36 | // getActivity().startActivity(new Intent(getActivity(), TitleBarSettingsActivity.class));
37 | // return false;
38 | // }
39 | // });
40 | mPref = getActivity().getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
41 | PreferenceActivity.MODE_WORLD_READABLE);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/pref_seekbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
18 |
19 |
26 |
27 |
34 |
35 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_blacklist.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
18 |
19 |
20 |
21 |
31 |
32 |
33 |
34 |
40 |
41 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/adapters/PageAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs.adapters;
2 |
3 | import java.util.LinkedList;
4 |
5 | import android.annotation.SuppressLint;
6 | import android.app.Fragment;
7 | import android.app.FragmentManager;
8 | import android.os.Bundle;
9 | import android.support.v13.app.FragmentPagerAdapter;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 |
15 | public abstract class PageAdapter extends FragmentPagerAdapter {
16 | final LinkedList mFragmentPages;
17 |
18 | public PageAdapter(FragmentManager fm, LinkedList fragmentPages) {
19 | super(fm);
20 | mFragmentPages = fragmentPages;
21 | }
22 |
23 | @SuppressLint("ValidFragment")
24 | @Override
25 | public Fragment getItem(int position) {
26 | return new PageFragment() {
27 | @Override
28 | public View onCreateView(LayoutInflater inflater, ViewGroup c,
29 | Bundle savedInstanceState) {
30 | return makeView(inflater, c, getPosition());
31 | }
32 | }.setPosition(mFragmentPages.get(position));
33 | }
34 |
35 | public abstract View makeView(LayoutInflater inflater, ViewGroup container, int position);
36 |
37 | @Override
38 | public int getCount() {
39 | return mFragmentPages.size();
40 | }
41 |
42 |
43 | public static abstract class PageFragment extends Fragment {
44 | public static final String FRAGMENT_KEY_POSITION = "position";
45 |
46 | public PageFragment setPosition(int position) {
47 | // http://stackoverflow.com/questions/9245408
48 | Bundle args = new Bundle();
49 | args.putInt(FRAGMENT_KEY_POSITION, position);
50 | setArguments(args);
51 | return this;
52 | }
53 |
54 | public int getPosition() {
55 | return getArguments().getInt(FRAGMENT_KEY_POSITION, -1);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/floatdot_launcher_menuitem.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
26 |
27 |
42 |
43 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/WidgetNumberPicker.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import com.zst.xposed.halo.floatingwindow3.R;
4 |
5 | import android.content.Context;
6 | import android.content.DialogInterface;
7 | import android.content.SharedPreferences;
8 | import android.preference.DialogPreference;
9 | import android.util.AttributeSet;
10 | import android.view.View;
11 | import android.widget.NumberPicker;
12 |
13 | public class WidgetNumberPicker extends DialogPreference {
14 |
15 | private NumberPicker picker;
16 | int mDefaultValue;
17 | int mMinValue;
18 | int mMaxValue;
19 | SharedPreferences mPref;
20 |
21 | public WidgetNumberPicker(Context context, AttributeSet attrs) {
22 | super(context, attrs);
23 | setDialogLayoutResource(R.layout.dialog_number_picker);
24 | mDefaultValue = (Integer.parseInt(attrs.getAttributeValue(null, "defaultValue")));
25 | mMinValue = (Integer.parseInt(attrs.getAttributeValue(null, "minimum")));
26 | mMaxValue = (Integer.parseInt(attrs.getAttributeValue(null, "maximum")));
27 | }
28 |
29 | @Override
30 | protected View onCreateDialogView() {
31 | View view = super.onCreateDialogView();
32 | mPref = getPreferenceManager().getSharedPreferences();
33 | picker = (NumberPicker) view.findViewById(R.id.number_picker);
34 | picker.setMaxValue(mMaxValue);
35 | picker.setMinValue(mMinValue);
36 |
37 | return view;
38 | }
39 |
40 | @Override
41 | public void onDismiss(DialogInterface dialog) {
42 | super.onDismiss(dialog);
43 | }
44 |
45 | @Override
46 | protected void onBindDialogView(View view) {
47 | super.onBindDialogView(view);
48 | picker.setValue(mPref.getInt(getKey(), mDefaultValue));
49 | }
50 |
51 | @Override
52 | protected void onDialogClosed(boolean positiveResult) {
53 | super.onDialogClosed(positiveResult);
54 | if (positiveResult) {
55 | mPref.edit().putInt(getKey(), picker.getValue()).commit();
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_floatdot.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
20 |
21 |
28 |
29 |
30 |
31 |
35 |
36 |
44 |
45 |
53 |
54 |
55 |
56 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/multiwindow_recents_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
24 |
25 |
37 |
38 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/OutlineRightResizable.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 | import android.view.Window;
8 | import android.view.WindowManager.LayoutParams;
9 |
10 | public class OutlineRightResizable implements View.OnTouchListener {
11 |
12 | final Window window;
13 | final Context context;
14 | final int minSize;
15 |
16 | LayoutParams param;
17 | int distance_from_left;
18 | int distance_from_top;
19 | int calculatedW;
20 | int calculatedH;
21 |
22 | public OutlineRightResizable(Window window) {
23 | this.window = window;
24 | this.context = window.getContext();
25 | // Convert 100dp to px equivalent from the context
26 | final float scale = window.getContext().getResources().getDisplayMetrics().density;
27 | minSize = (int) (100 * scale + 0.5f);
28 | }
29 |
30 | @Override
31 | public boolean onTouch(View v, MotionEvent event) {
32 | switch (event.getAction()) {
33 |
34 | case MotionEvent.ACTION_DOWN:
35 | param = window.getAttributes();
36 | distance_from_left = param.x;
37 | distance_from_top = param.y;
38 | MovableWindow.unsnap();
39 | break;
40 |
41 | case MotionEvent.ACTION_MOVE:
42 | final int newX = Math.round(event.getRawX());
43 | final int newY = Math.round(event.getRawY());
44 |
45 | calculatedW = newX - distance_from_left;
46 | calculatedH = newY - distance_from_top;
47 |
48 | if (calculatedW < minSize) {
49 | calculatedW = minSize;
50 | }
51 | if (calculatedH < minSize) {
52 | calculatedH = minSize;
53 | }
54 | broadcast(true);
55 | break;
56 | case MotionEvent.ACTION_UP:
57 | broadcast(false);
58 | MovableWindow.resize(calculatedW, calculatedH);
59 | break;
60 | }
61 | return false;
62 | }
63 |
64 | private void broadcast(boolean show) {
65 | Intent i = new Intent(Common.SHOW_OUTLINE);
66 | if (show) {
67 | int[] array = { distance_from_left, distance_from_top, calculatedH, calculatedW };
68 | i.putExtra(Common.INTENT_APP_PARAMS, array);
69 | }
70 | context.sendBroadcast(i);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/movable_dialog_transparency.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
29 |
30 |
39 |
40 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/Movable.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 | import android.view.Gravity;
4 | import android.view.MotionEvent;
5 | import android.view.View;
6 | import android.view.Window;
7 | import android.view.WindowManager.LayoutParams;
8 | import java.util.logging.*;
9 |
10 | public class Movable implements View.OnTouchListener {
11 | final Window mWindow;
12 | final LayoutParams param;
13 | final boolean mReturn;
14 |
15 | private static Float screenX ;
16 | private static Float screenY ;
17 | private static Float viewX ;
18 | private static Float viewY ;
19 | private static Float leftFromScreen ;
20 | private static Float topFromScreen ;
21 | private View offsetView;
22 |
23 | public Movable(Window window, boolean return_value) {
24 | mWindow=window;
25 | param = mWindow.getAttributes();
26 | mReturn = return_value;
27 | }
28 |
29 | public Movable(Window window, View v){
30 | this(window, false);
31 | offsetView = v;
32 | }
33 |
34 | @Override
35 | public boolean onTouch(View v, MotionEvent event) {
36 | switch (event.getAction()){
37 | case MotionEvent.ACTION_DOWN:
38 | viewX = event.getX();
39 | viewY = event.getY();
40 | if (offsetView != null) {
41 | int[] location = {0,0};
42 | offsetView.getLocationInWindow(location);
43 | viewX = viewX + location[0];
44 | viewY = viewY + location[1];
45 | }
46 | break;
47 | case MotionEvent.ACTION_MOVE:
48 | screenX = event.getRawX();
49 | screenY = event.getRawY();
50 | leftFromScreen = (screenX - viewX);
51 | topFromScreen = (screenY - viewY);
52 | //mWindow.setGravity(Gravity.LEFT | Gravity.TOP);
53 | if(MovableWindow.mWindowHolder.isSnapped)
54 | MovableWindow.unsnap();
55 | else
56 | MovableWindow.move(leftFromScreen.intValue(),topFromScreen.intValue());
57 | break;
58 | }
59 | if (MovableWindow.mAeroSnap != null) {
60 | MovableWindow.mAeroSnap.dispatchTouchEvent(event);
61 | }
62 | return mReturn;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | - @string/option_movable_corner_nothing
7 | - @string/option_movable_corner_dnm
8 | - @string/option_movable_corner_dnm_wo_corners
9 | - @string/option_movable_corner_transparency
10 | - @string/option_movable_corner_close
11 | - @string/option_movable_corner_hide_app
12 | - @string/option_movable_corner_maximize
13 |
14 |
15 |
16 | - 0
17 | - 1
18 | - 5
19 | - 3
20 | - 2
21 | - 4
22 | - 6
23 |
24 |
25 |
26 |
27 | - @string/option_whiteblacklist_default
28 | - @string/option_whiteblacklist_always_only
29 | - @string/option_whiteblacklist_never_only
30 | - @string/option_whiteblacklist_never_all
31 |
32 |
33 |
34 | - 0
35 | - 1
36 | - 2
37 | - 3
38 |
39 |
40 |
41 | - @string/option_force_snap_default
42 | - @string/option_force_snap_halo_only
43 | - @string/option_force_snap_always
44 |
45 |
46 |
47 | - 0
48 | - 1
49 | - 2
50 |
51 |
52 |
53 | - Old and classic (0x2000)
54 | - New default / Android 5+ (0x2001)
55 | - Omni/SlimRom (0x3000)
56 |
57 |
58 |
59 | - 8192
60 | - 8193
61 | - 12288
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_floatdot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
15 |
22 |
27 |
33 |
39 |
46 |
51 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/OverlayFragment.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.preference.Preference;
8 | import android.preference.PreferenceActivity;
9 | import android.preference.PreferenceFragment;
10 |
11 | import com.zst.xposed.halo.floatingwindow3.Common;
12 | import com.zst.xposed.halo.floatingwindow3.R;
13 |
14 | public class OverlayFragment extends PreferenceFragment {
15 |
16 | static OverlayFragment mInstance;
17 | SharedPreferences mPref;
18 |
19 | public static OverlayFragment getInstance() {
20 | if (mInstance == null) {
21 | mInstance = new OverlayFragment();
22 | }
23 | return mInstance;
24 | }
25 | @Override
26 | @SuppressWarnings("deprecation")
27 | @SuppressLint("WorldReadableFiles")
28 | public void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | getPreferenceManager().setSharedPreferencesName(Common.PREFERENCE_MAIN_FILE);
31 | getPreferenceManager().setSharedPreferencesMode(PreferenceActivity.MODE_WORLD_READABLE);
32 | addPreferencesFromResource(R.xml.pref_overlay);
33 | findPreference("titlebar_theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
34 | @Override
35 | public boolean onPreferenceClick(Preference preference) {
36 | getActivity().startActivity(new Intent(getActivity(), TitleBarSettingsActivity.class));
37 | return false;
38 | }
39 | });
40 | findPreference("floatdot_theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
41 | @Override
42 | public boolean onPreferenceClick(Preference preference) {
43 | Intent intent = new Intent();
44 | intent.setClass(getActivity(), FloatDotActivity.class);
45 | startActivityForResult(intent, 0);
46 |
47 | return false;
48 | }
49 | });
50 | findPreference("launcher_list").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
51 | @Override
52 | public boolean onPreferenceClick(Preference preference) {
53 | getActivity().startActivity(new Intent(getActivity(), LauncherListActivity.class));
54 | return false;
55 | }
56 | });
57 | mPref = getActivity().getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
58 | PreferenceActivity.MODE_WORLD_READABLE);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_app_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
32 |
33 |
43 |
44 |
51 |
52 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/MainPreference.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 | import com.zst.xposed.halo.floatingwindow3.prefs.MainFragment;
4 |
5 | import android.app.Activity;
6 | import android.app.Fragment;
7 | import android.graphics.Color;
8 | import android.os.Bundle;
9 | import android.support.v13.app.FragmentPagerAdapter;
10 | import android.support.v4.view.PagerTabStrip;
11 | import android.support.v4.view.ViewPager;
12 | import com.zst.xposed.halo.floatingwindow3.prefs.*;
13 | import android.app.*;
14 | import android.graphics.drawable.*;
15 | import android.widget.*;
16 | import android.view.*;
17 |
18 | public class MainPreference extends Activity {
19 |
20 | @Override
21 | protected void onCreate(Bundle savedInstanceState) {
22 | super.onCreate(savedInstanceState);
23 |
24 | setContentView(R.layout.activity_viewpager);
25 |
26 | FragmentPagerAdapter adapter = new FragmentPagerAdapter(getFragmentManager()) {
27 | @Override
28 | public Fragment getItem(int position) {
29 | switch (position) {
30 | case 0:
31 | return MainFragment.getInstance();
32 | case 1:
33 | return MovingFragment.getInstance();
34 | case 2:
35 | return BehaviorFragment.getInstance();
36 | case 3:
37 | return OverlayFragment.getInstance();
38 | // case 2:
39 | // return TestingActivity.getInstance();
40 | }
41 | return new Fragment();
42 | }
43 |
44 | @Override
45 | public String getPageTitle(int pos) {
46 | switch (pos) {
47 | case 0:
48 | return getResources().getString(R.string.pref_main_top_title);
49 | case 1:
50 | return getResources().getString(R.string.pref_movable_top_title);
51 | case 2:
52 | return getResources().getString(R.string.pref_behavior_title);
53 | case 3:
54 | return getResources().getString(R.string.pref_overlay_title);
55 | // case 2:
56 | // return getResources().getString(R.string.pref_testing_top_title);
57 | }
58 | return "";
59 | }
60 |
61 | @Override
62 | public int getCount() {
63 | return 4;
64 | }
65 | };
66 | ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
67 | viewPager.setAdapter(adapter);
68 |
69 | PagerTabStrip pts = (PagerTabStrip) findViewById(R.id.pager_title_strip);
70 | pts.setTabIndicatorColor(0xFF333333);
71 | pts.setTextColor(0xFF111111);
72 | pts.setBackgroundColor(Color.TRANSPARENT);
73 |
74 | ActionBar bar = getActionBar();
75 | bar.setBackgroundDrawable(new ColorDrawable(0xFFAA0000));
76 |
77 |
78 | testSettings(true);
79 |
80 | }
81 |
82 | private void testSettings(boolean mVis){
83 | TextView notActiveTitle = (TextView) findViewById(R.id.notActiveTitle);
84 | notActiveTitle.setVisibility(mVis?View.VISIBLE:View.GONE);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_package_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
24 |
25 |
32 |
33 |
43 |
44 |
51 |
52 |
59 |
60 |
61 |
68 |
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/OutlineLeftResizable.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.util.DisplayMetrics;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.view.Window;
10 | import android.view.WindowManager.LayoutParams;
11 |
12 | public class OutlineLeftResizable implements View.OnTouchListener {
13 |
14 | Window window;
15 | Context context;
16 | LayoutParams param;
17 |
18 | final int minSize;
19 |
20 | int oldX, oldY, oldW, oldH;
21 | int futureX, futureW, futureH;
22 | int distance_from_top;
23 |
24 | public OutlineLeftResizable(Context context, Window window) {
25 | this.context = context;
26 | this.window = window;
27 | final float scale = context.getResources().getDisplayMetrics().density;
28 | minSize = (int) (100 * scale + 0.5f);
29 | }
30 |
31 | @Override
32 | public boolean onTouch(View v, MotionEvent event) {
33 | switch (event.getAction()) {
34 |
35 | case MotionEvent.ACTION_DOWN:
36 | MovableWindow.unsnap();
37 | param = window.getAttributes();
38 | oldX = Math.round(event.getRawX() - event.getX());
39 | oldY = Math.round(event.getRawY() - event.getY());
40 | oldW = param.width;
41 | oldH = param.height;
42 | distance_from_top = param.y;
43 | if (oldW == ViewGroup.LayoutParams.MATCH_PARENT
44 | || oldH == ViewGroup.LayoutParams.MATCH_PARENT) {
45 | DisplayMetrics metrics = context.getResources().getDisplayMetrics();
46 | oldW = (int) (metrics.widthPixels * 0.95f);
47 | oldH = (int) (metrics.heightPixels * 0.95f);
48 | }
49 | break;
50 |
51 | case MotionEvent.ACTION_MOVE:
52 | int newX = Math.round(event.getRawX());
53 | int newY = Math.round(event.getRawY());
54 |
55 | int calculatedW = oldW + (oldX - newX);
56 | int calculatedH = newY - distance_from_top;
57 |
58 | if (calculatedW > minSize) {
59 | futureW = calculatedW;
60 | futureX = newX;
61 | }
62 | if (calculatedH > minSize) {
63 | futureH = calculatedH;
64 | }
65 | broadcast(true);
66 | break;
67 | case MotionEvent.ACTION_UP:
68 | param.x = futureX;
69 | param.y = distance_from_top;
70 | param.width = futureW;
71 | param.height = futureH;
72 | broadcast(false);
73 | if(!MovableWindow.mWindowHolder.isSnapped&&!MovableWindow.mWindowHolder.isMaximized)
74 | MovableWindow.resize(param.x, param.y, param.width, param.height);
75 | break;
76 |
77 | }
78 | return false;
79 | }
80 |
81 | private void broadcast(boolean show) {
82 | Intent i = new Intent(Common.SHOW_OUTLINE);
83 | if (show) {
84 | int[] array = { futureX, distance_from_top, futureH, futureW };
85 | i.putExtra(Common.INTENT_APP_PARAMS, array);
86 | }
87 | context.sendBroadcast(i);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/Resizable.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 |
4 | import android.content.Context;
5 | import android.util.DisplayMetrics;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.view.Window;
10 | import android.view.WindowManager.LayoutParams;
11 |
12 | public class Resizable implements View.OnTouchListener {
13 |
14 | Window window;
15 | Context context;
16 | LayoutParams param;
17 | int oldX;
18 | int oldY;
19 | int oldW;
20 | int oldH;
21 | int distance_from_top;
22 | int minSize;
23 |
24 | public Resizable(Context context, Window window){
25 | this.context = context;
26 | this.window = window;
27 | // Convert 100dp to px equivalent from the context
28 | final float scale = context.getResources().getDisplayMetrics().density;
29 | minSize = (int) (100 * scale + 0.5f);
30 | }
31 |
32 |
33 | @Override
34 | public boolean onTouch(View v, MotionEvent event) {
35 | switch (event.getAction()){
36 |
37 | case MotionEvent.ACTION_DOWN:
38 | param = window.getAttributes();
39 | oldX = Math.round(event.getRawX() - event.getX());
40 | oldY = Math.round(event.getRawY() - event.getY());
41 | oldW = param.width;
42 | oldH = param.height;
43 | distance_from_top = param.y;
44 | if (oldW == ViewGroup.LayoutParams.MATCH_PARENT
45 | || oldH == ViewGroup.LayoutParams.MATCH_PARENT) {
46 | DisplayMetrics metrics = context.getResources().getDisplayMetrics();
47 | oldW = (int) (metrics.widthPixels * 0.95f);
48 | oldH = (int) (metrics.heightPixels * 0.95f);
49 | }
50 | MovableWindow.unsnap();
51 | return false;
52 |
53 | case MotionEvent.ACTION_MOVE:
54 | int newX = Math.round(event.getRawX());
55 | int newY = Math.round(event.getRawY());
56 |
57 | int calculatedW = oldW + (oldX - newX);
58 | int calculatedH = newY - distance_from_top;
59 |
60 | if (calculatedW > minSize){
61 | param.width = calculatedW;
62 | param.x = newX;
63 | }
64 | if(calculatedH > minSize){
65 | param.height = calculatedH;
66 | //Commented y because we never change it so no reason to reset it
67 | //param.y = distance_from_top;
68 | }
69 | MovableWindow.resize(param.x, param.y, param.width, param.height);
70 |
71 | //I split the if statements because if say the width is at it's minimum that shouldn't keep the height from adjusting
72 | //which may not be at it's minimum. Basically width and height should be independent
73 | return false;
74 | default:
75 | return false;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/colorpicker/ColorSettingsDialog.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs.colorpicker;
2 |
3 | import java.util.Locale;
4 |
5 | import com.zst.xposed.halo.floatingwindow3.R;
6 | import com.zst.xposed.halo.floatingwindow3.prefs.colorpicker.ColorPickerView.OnColorChangedListener;
7 |
8 | import android.app.AlertDialog;
9 | import android.content.Context;
10 | import android.graphics.Color;
11 | import android.graphics.PixelFormat;
12 | import android.view.LayoutInflater;
13 | import android.view.View;
14 | import android.widget.Button;
15 | import android.widget.EditText;
16 |
17 | public class ColorSettingsDialog extends AlertDialog implements
18 | ColorPickerView.OnColorChangedListener {
19 |
20 | private ColorPickerView mColorPicker;
21 |
22 | private ColorPanelView mOldColor;
23 | private ColorPanelView mNewColor;
24 | private EditText mHexColor;
25 | private Button mHexButton;
26 |
27 | private LayoutInflater mInflater;
28 | private OnColorChangedListener mListener;
29 |
30 | public ColorSettingsDialog(Context context, int initialColor, final String defColor) {
31 | super(context);
32 | getWindow().setFormat(PixelFormat.RGBA_8888);
33 | // To fight color banding.
34 | setUp(initialColor, defColor);
35 | }
36 |
37 | private void setUp(int color, final String defColor) {
38 | mInflater = (LayoutInflater) getContext()
39 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
40 |
41 | View layout = mInflater.inflate(R.layout.dialog_colorpicker, null);
42 |
43 | mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
44 | mOldColor = (ColorPanelView) layout.findViewById(R.id.old_color_panel);
45 | mNewColor = (ColorPanelView) layout.findViewById(R.id.new_color_panel);
46 | mHexColor = (EditText) layout.findViewById(R.id.current_hex_text);
47 |
48 | mColorPicker.setOnColorChangedListener(this);
49 | mOldColor.setColor(color);
50 | mColorPicker.setColor(color, true);
51 |
52 | mHexButton = (Button) layout.findViewById(R.id.color_apply);
53 | mHexButton.setOnClickListener(new View.OnClickListener(){
54 | @Override
55 | public void onClick(View v) {
56 | try{
57 | int color = Color.parseColor("#" + mHexColor.getText().toString());
58 | mColorPicker.setColor(color);
59 | colorChange(color);
60 | }catch(Exception e){
61 | mHexColor.setText("FFFFFF");
62 | }
63 | }
64 | });
65 |
66 | setView(layout);
67 | }
68 |
69 | @Override
70 | public void onColorChanged(int color) {
71 | colorChange(color);
72 | }
73 |
74 | private void colorChange(int color){
75 | mNewColor.setColor(color);
76 | mHexColor.setText(Integer.toHexString(color).toUpperCase(Locale.ENGLISH).substring(2));
77 | if (mListener != null) {
78 | mListener.onColorChanged(color);
79 | }
80 | }
81 |
82 | public void setAlphaSliderVisible(boolean visible) {
83 | mColorPicker.setAlphaSliderVisible(visible);
84 | }
85 |
86 | public String getColorString() {
87 | return Integer.toHexString(mColorPicker.getColor());
88 | }
89 |
90 | public int getColor() {
91 | return mColorPicker.getColor();
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/ColorPicker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 XuiMod
3 | * Copyright (C) 2012 The CyanogenMod Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.zst.xposed.halo.floatingwindow3.prefs;
19 |
20 |
21 | import com.zst.xposed.halo.floatingwindow3.R;
22 | import com.zst.xposed.halo.floatingwindow3.prefs.colorpicker.ColorSettingsDialog;
23 |
24 | import android.app.AlertDialog;
25 | import android.content.Context;
26 | import android.content.DialogInterface;
27 | import android.content.SharedPreferences;
28 | import android.content.res.Resources;
29 | import android.graphics.Color;
30 | import android.preference.Preference;
31 | import android.preference.Preference.OnPreferenceClickListener;
32 | import android.util.AttributeSet;
33 | import android.view.View;
34 | import android.widget.ImageView;
35 |
36 | public class ColorPicker extends Preference implements OnPreferenceClickListener {
37 |
38 | SharedPreferences mPref;
39 | ImageView mColorBox;
40 | Resources mRes;
41 | String mDefaultColor;
42 |
43 | public ColorPicker(Context context, AttributeSet attrs) {
44 | super(context, attrs);
45 |
46 | mDefaultColor = attrs.getAttributeValue(null, "defaultValue");
47 | }
48 |
49 | @Override
50 | protected void onBindView(View view) {
51 | super.onBindView(view);
52 | mColorBox = (ImageView) view.findViewById(android.R.id.icon);
53 | mPref = getPreferenceManager().getSharedPreferences();
54 | mRes = getContext().getResources();
55 | setOnPreferenceClickListener(this);
56 | refreshColorBox();
57 | }
58 |
59 | @Override
60 | public boolean onPreferenceClick(Preference arg0) {
61 | final ColorSettingsDialog d = new ColorSettingsDialog(getContext(), getColor(), mDefaultColor);
62 | final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
63 | @Override
64 | public void onClick(DialogInterface dialog, int which) {
65 | switch (which){
66 | case AlertDialog.BUTTON_POSITIVE:
67 | setColor(d.getColorString());
68 | break;
69 | case AlertDialog.BUTTON_NEUTRAL:
70 | setColor(mDefaultColor);
71 | break;
72 | }
73 | }
74 | };
75 | d.setButton(AlertDialog.BUTTON_POSITIVE, mRes.getString(android.R.string.ok), listener);
76 | d.setButton(AlertDialog.BUTTON_NEUTRAL, mRes.getString(R.string.default_value), listener);
77 | d.setButton(AlertDialog.BUTTON_NEGATIVE, mRes.getString(android.R.string.cancel), listener);
78 | d.show();
79 | return true;
80 | }
81 |
82 | public String getColorString() {
83 | return Integer.toHexString(getColor());
84 | }
85 |
86 | public int getColor() {
87 | String str = mPref.getString(getKey(), mDefaultColor);
88 | return Color.parseColor("#"+str);
89 | }
90 |
91 | private void refreshColorBox(){
92 | if (mColorBox != null) {
93 | mColorBox.setBackgroundColor(getColor());
94 | mColorBox.setVisibility(View.VISIBLE);
95 | }
96 | }
97 | public void setColor(String clr) {
98 | mPref.edit().putString(getKey(), clr).commit();
99 | refreshColorBox();
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_colorpicker.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
25 |
26 |
30 |
31 |
37 |
38 |
46 |
47 |
56 |
57 |
63 |
64 |
65 |
66 |
72 |
73 |
78 |
79 |
87 |
88 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_general.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | android:summary="@string/pref_window_top_summary"
7 | android:title="@string/pref_window_top_title" >
8 |
13 |
20 |
21 |
22 |
23 |
30 |
37 |
41 |
48 |
56 |
64 |
72 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/WidgetFloatPercentage.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import com.zst.xposed.halo.floatingwindow3.R;
4 |
5 | import android.app.AlertDialog;
6 | import android.content.Context;
7 | import android.content.DialogInterface;
8 | import android.content.SharedPreferences;
9 | import android.content.SharedPreferences.Editor;
10 | import android.os.Bundle;
11 | import android.preference.DialogPreference;
12 | import android.util.AttributeSet;
13 | import android.view.View;
14 | import android.widget.Button;
15 | import android.widget.LinearLayout;
16 | import android.widget.SeekBar;
17 | import android.widget.TextView;
18 |
19 | public class WidgetFloatPercentage extends DialogPreference implements
20 | SeekBar.OnSeekBarChangeListener {
21 |
22 | private TextView mFinalValue;
23 | private SeekBar mSeekBar;
24 | private TextView mValue;
25 |
26 | public Float mMin;
27 | public Float mMax;
28 | public Float mDefault;
29 |
30 | public WidgetFloatPercentage(Context context, AttributeSet attrs) {
31 | super(context, attrs);
32 |
33 | setDialogLayoutResource(R.layout.pref_seekbar);
34 | mDefault = Float.parseFloat(attrs.getAttributeValue(null, "defaultValue"));
35 | mMin = Float.parseFloat(attrs.getAttributeValue(null, "minimum"));
36 | mMax = Float.parseFloat(attrs.getAttributeValue(null, "maximum"));
37 | }
38 |
39 | @Override
40 | protected void onBindView(View view) {
41 | super.onBindView(view);
42 | mFinalValue = new TextView(getContext());
43 | mFinalValue.setTextSize(24);
44 | LinearLayout layout = (LinearLayout)view;
45 | layout.addView(mFinalValue, layout.getChildCount());
46 | updatePercentage();
47 | }
48 |
49 | @Override
50 | protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
51 | builder.setNeutralButton(R.string.default_value, new DialogInterface.OnClickListener() {
52 | @Override
53 | public void onClick(DialogInterface dialog, int which) {
54 | }
55 | });
56 | }
57 |
58 | @Override
59 | protected void onBindDialogView(View view) {
60 | super.onBindDialogView(view);
61 |
62 | mValue = (TextView) view.findViewById(R.id.value);
63 | mValue.setText("0%");
64 | mSeekBar = (SeekBar) view.findViewById(R.id.seekbar);
65 | mSeekBar.setOnSeekBarChangeListener(this);
66 | }
67 |
68 | @Override
69 | protected void showDialog(Bundle state) {
70 | super.showDialog(state);
71 |
72 | // can't use onPrepareDialogBuilder for this as we want the dialog
73 | // to be kept open on click
74 | AlertDialog d = (AlertDialog) getDialog();
75 | Button defaultsButton = d.getButton(DialogInterface.BUTTON_NEUTRAL);
76 | defaultsButton.setOnClickListener(new View.OnClickListener() {
77 | @Override
78 | public void onClick(View v) {
79 | int progress = Math.round((mDefault * 100) - (mMin * 100));
80 | mSeekBar.setProgress(progress);
81 | }
82 | });
83 |
84 | final SharedPreferences prefs = getSharedPreferences();
85 |
86 | float value = prefs.getFloat(getKey(), mDefault);
87 | value -= mMin;
88 | int max = Math.round((mMax * 100) - (mMin * 100));
89 | mSeekBar.setMax(max);
90 | mSeekBar.setProgress(Math.round(value * 100));
91 |
92 | }
93 |
94 | @Override
95 | protected void onDialogClosed(boolean positiveResult) {
96 | super.onDialogClosed(positiveResult);
97 |
98 | if (positiveResult) {
99 | int realValue = mSeekBar.getProgress() + Math.round((mMin * 100));
100 | Editor editor = getEditor();
101 | editor.putFloat(getKey(), (realValue * 0.01f));
102 | editor.commit();
103 | }
104 | updatePercentage();
105 | }
106 |
107 | @Override
108 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
109 | int realValue = progress + Math.round((mMin * 100));
110 | mValue.setText(realValue + "%");
111 | }
112 |
113 | @Override
114 | public void onStartTrackingTouch(SeekBar seekBar) {
115 | }
116 |
117 | @Override
118 | public void onStopTrackingTouch(SeekBar seekBar) {
119 | }
120 |
121 | private void updatePercentage() {
122 | float value = getSharedPreferences().getFloat(getKey(), mDefault);
123 | mFinalValue.setText(Math.round((value * 100)) + "%");
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/colorpicker/AlphaPatternDrawable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Daniel Nilsson
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.zst.xposed.halo.floatingwindow3.prefs.colorpicker;
18 |
19 |
20 | import android.graphics.*;
21 | import android.graphics.Bitmap.Config;
22 | import android.graphics.drawable.Drawable;
23 |
24 | /**
25 | * This drawable that draws a simple white and gray chessboard pattern.
26 | * It's pattern you will often see as a background behind a
27 | * partly transparent image in many applications.
28 | * @author Daniel Nilsson
29 | */
30 | public class AlphaPatternDrawable extends Drawable {
31 |
32 | private int mRectangleSize = 10;
33 |
34 | private Paint mPaint = new Paint();
35 | private Paint mPaintWhite = new Paint();
36 | private Paint mPaintGray = new Paint();
37 |
38 | private int numRectanglesHorizontal;
39 | private int numRectanglesVertical;
40 |
41 | /**
42 | * Bitmap in which the pattern will be cahched.
43 | */
44 | private Bitmap mBitmap;
45 |
46 | public AlphaPatternDrawable(int rectangleSize) {
47 | mRectangleSize = rectangleSize;
48 | mPaintWhite.setColor(0xffffffff);
49 | mPaintGray.setColor(0xffcbcbcb);
50 | }
51 |
52 | @Override
53 | public void draw(Canvas canvas) {
54 | canvas.drawBitmap(mBitmap, null, getBounds(), mPaint);
55 | }
56 |
57 | @Override
58 | public int getOpacity() {
59 | return 0;
60 | }
61 |
62 | @Override
63 | public void setAlpha(int alpha) {
64 | throw new UnsupportedOperationException("Alpha is not supported by this drawwable.");
65 | }
66 |
67 | @Override
68 | public void setColorFilter(ColorFilter cf) {
69 | throw new UnsupportedOperationException("ColorFilter is not supported by this drawwable.");
70 | }
71 |
72 | @Override
73 | protected void onBoundsChange(Rect bounds) {
74 | super.onBoundsChange(bounds);
75 |
76 | int height = bounds.height();
77 | int width = bounds.width();
78 |
79 | numRectanglesHorizontal = (int) Math.ceil((width / mRectangleSize));
80 | numRectanglesVertical = (int) Math.ceil(height / mRectangleSize);
81 |
82 | generatePatternBitmap();
83 | }
84 |
85 | /**
86 | * This will generate a bitmap with the pattern
87 | * as big as the rectangle we were allow to draw on.
88 | * We do this to chache the bitmap so we don't need to
89 | * recreate it each time draw() is called since it
90 | * takes a few milliseconds.
91 | */
92 | private void generatePatternBitmap(){
93 | if(getBounds().width() <= 0 || getBounds().height() <= 0){
94 | return;
95 | }
96 |
97 | mBitmap = Bitmap.createBitmap(getBounds().width(), getBounds().height(), Config.ARGB_8888);
98 | Canvas canvas = new Canvas(mBitmap);
99 |
100 | Rect r = new Rect();
101 | boolean verticalStartWhite = true;
102 | for (int i = 0; i <= numRectanglesVertical; i++) {
103 |
104 | boolean isWhite = verticalStartWhite;
105 | for (int j = 0; j <= numRectanglesHorizontal; j++) {
106 |
107 | r.top = i * mRectangleSize;
108 | r.left = j * mRectangleSize;
109 | r.bottom = r.top + mRectangleSize;
110 | r.right = r.left + mRectangleSize;
111 |
112 | canvas.drawRect(r, isWhite ? mPaintWhite : mPaintGray);
113 |
114 | isWhite = !isWhite;
115 | }
116 | verticalStartWhite = !verticalStartWhite;
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
24 |
27 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 |
45 |
46 |
47 |
50 |
51 |
52 |
53 |
54 |
57 |
58 |
59 |
60 |
61 |
64 |
65 |
66 |
67 |
68 |
71 |
72 |
73 |
74 |
75 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/BehaviorFragment.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.os.Bundle;
7 | import android.preference.Preference;
8 | import android.preference.PreferenceActivity;
9 | import android.preference.PreferenceFragment;
10 | import android.preference.Preference.OnPreferenceClickListener;
11 |
12 | import com.zst.xposed.halo.floatingwindow3.Common;
13 | import com.zst.xposed.halo.floatingwindow3.R;
14 | import android.app.*;
15 | import android.widget.*;
16 | import android.view.*;
17 |
18 | public class BehaviorFragment extends PreferenceFragment {
19 |
20 | static BehaviorFragment mInstance;
21 | SharedPreferences mPref;
22 |
23 | public static BehaviorFragment getInstance() {
24 | if (mInstance == null) {
25 | mInstance = new BehaviorFragment();
26 | }
27 | return mInstance;
28 | }
29 | @Override
30 | @SuppressWarnings("deprecation")
31 | @SuppressLint("WorldReadableFiles")
32 | public void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | getPreferenceManager().setSharedPreferencesName(Common.PREFERENCE_MAIN_FILE);
35 | getPreferenceManager().setSharedPreferencesMode(PreferenceActivity.MODE_WORLD_READABLE);
36 | addPreferencesFromResource(R.xml.pref_behavior);
37 | findPreference("window_whitelist").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
38 | @Override
39 | public boolean onPreferenceClick(Preference preference) {
40 | getActivity().startActivity(new Intent(getActivity(), WhitelistActivity.class));
41 | return false;
42 | }
43 | });
44 | findPreference("window_blacklist").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
45 | @Override
46 | public boolean onPreferenceClick(Preference preference) {
47 | getActivity().startActivity(new Intent(getActivity(), BlacklistActivity.class));
48 | return false;
49 | }
50 | });
51 | findPreference("window_maximized").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
52 | @Override
53 | public boolean onPreferenceClick(Preference preference) {
54 | getActivity().startActivity(new Intent(getActivity(), MaximizedActivity.class));
55 | return false;
56 | }
57 | });
58 | findPreference(Common.KEY_KEYBOARD_MODE).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
59 | @Override
60 | public boolean onPreferenceClick(Preference preference) {
61 | showKeyboardDialog();
62 | return true;
63 | }
64 | });
65 | mPref = getActivity().getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
66 | PreferenceActivity.MODE_WORLD_READABLE);
67 | }
68 |
69 | private void showKeyboardDialog() {
70 | final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
71 | final ListView modeList = new ListView(getActivity());
72 |
73 | builder.setView(modeList);
74 | builder.setTitle(R.string.pref_keyboard_title);
75 |
76 | final AlertDialog dialog = builder.create();
77 | final ArrayAdapter adapter = new ArrayAdapter(getActivity(),
78 | android.R.layout.simple_list_item_1, android.R.id.text1);
79 |
80 | adapter.add(getResources().getString(R.string.keyboard_default));
81 | adapter.add(getResources().getString(R.string.keyboard_pan));
82 | adapter.add(getResources().getString(R.string.keyboard_scale));
83 |
84 | modeList.setAdapter(adapter);
85 | modeList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
86 | @Override
87 | public void onItemClick(AdapterView> parent, View view, int pos, long id) {
88 | String title = ((TextView) view.findViewById(android.R.id.text1))
89 | .getText().toString();
90 | if (title.equals(getResources().getString(R.string.keyboard_default))) {
91 | mPref.edit().putInt(Common.KEY_KEYBOARD_MODE, 1).commit();
92 | } else if (title.equals(getResources().getString(R.string.keyboard_pan))) {
93 | mPref.edit().putInt(Common.KEY_KEYBOARD_MODE, 2).commit();
94 | } else if (title.equals(getResources().getString(R.string.keyboard_scale))) {
95 | mPref.edit().putInt(Common.KEY_KEYBOARD_MODE, 3).commit();
96 | }
97 | Toast.makeText(getActivity(), title, Toast.LENGTH_SHORT).show();
98 | dialog.dismiss();
99 | }
100 | });
101 | dialog.show();
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/Compatibility.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 | import android.view.Gravity;
4 |
5 | import java.util.ArrayList;
6 | import java.util.Arrays;
7 | import android.os.*;
8 | import de.robv.android.xposed.*;
9 |
10 | public class Compatibility
11 | {
12 |
13 |
14 | public static class Hooks{
15 | public static int ActivityRecord_Intent = 4;
16 | public static int ActivityRecord_ActivityInfo = 6;
17 | public static int ActivityRecord_ActivityStack = -1;
18 | public static int ActivityRecord_StackSupervisor = 13;
19 | public static int TaskRecord_Intent = 3;
20 | public static String ActivityRecord_TaskHistory = "mTaskHistory";
21 | public static String Internal_PhoneWindow = "com.android.internal.policy.PhoneWindow";
22 | public static Object getActivityRecord_ActivityStack(Object stackSupervisor){
23 | if(stackSupervisor==null) return null;
24 | Object activityStack = null;
25 | try{
26 | activityStack = XposedHelpers.callMethod(stackSupervisor, "getFocusedStack");
27 | } catch(Throwable e){
28 | XposedBridge.log(e);
29 | try{
30 | activityStack = XposedHelpers.getObjectField(stackSupervisor, "mFocusedStack");
31 | } catch(Throwable t){
32 | XposedBridge.log(t);
33 | }
34 | }
35 | return activityStack;
36 | }
37 |
38 | Hooks(){
39 | int SDK = (Build.VERSION.SDK_INT<17?17:Build.VERSION.SDK_INT);
40 | switch(SDK){
41 | case 17:
42 | ActivityRecord_Intent = 4;
43 | ActivityRecord_ActivityInfo = 6;
44 | ActivityRecord_ActivityStack = 1;
45 | ActivityRecord_StackSupervisor = -1;
46 | TaskRecord_Intent = 2;
47 | ActivityRecord_TaskHistory = "mHistory";
48 | Internal_PhoneWindow = "com.android.internal.policy.impl.PhoneWindow";
49 | break;
50 | case 18:
51 | ActivityRecord_Intent = 5;
52 | ActivityRecord_ActivityInfo = 7;
53 | ActivityRecord_ActivityStack = 1;
54 | ActivityRecord_StackSupervisor = -1;
55 | ActivityRecord_TaskHistory = "mHistory";
56 | Internal_PhoneWindow = "com.android.internal.policy.impl.PhoneWindow";
57 | break;
58 | case 19:
59 | case 20:
60 | case 21:
61 | ActivityRecord_Intent = 4;
62 | ActivityRecord_ActivityInfo = 6;
63 | ActivityRecord_ActivityStack = -1;
64 | ActivityRecord_StackSupervisor = 12;
65 | TaskRecord_Intent= 3;
66 | ActivityRecord_TaskHistory = "mTaskHistory";
67 | Internal_PhoneWindow = "com.android.internal.policy.impl.PhoneWindow";
68 | break;
69 | case 22:
70 | case 23:
71 | default:
72 | ActivityRecord_Intent = 4;
73 | ActivityRecord_ActivityInfo = 6;
74 | ActivityRecord_ActivityStack = -1;
75 | ActivityRecord_StackSupervisor = 13;
76 | TaskRecord_Intent = 3;
77 | ActivityRecord_TaskHistory = "mTaskHistory";
78 | Internal_PhoneWindow = "com.android.internal.policy.PhoneWindow";
79 | break;
80 | }
81 |
82 | }
83 | }
84 |
85 | public final class AeroSnap{
86 | public final static int SNAP_NONE = 0;
87 | public final static int SNAP_LEFT = 1;
88 | public final static int SNAP_TOP = 2;
89 | public final static int SNAP_RIGHT = 3;
90 | public final static int SNAP_BOTTOM = 4;
91 | //4WAYMOD snaps
92 | public final static int SNAP_TOPLEFT = 21;
93 | public final static int SNAP_TOPRIGHT = 23;
94 | public final static int SNAP_BOTTOMLEFT = 41;
95 | public final static int SNAP_BOTTOMRIGHT = 43;
96 | }
97 |
98 | //public final static int AeroSnapNone = 0;
99 |
100 | final static ArrayList snapSideReplaceTable = new ArrayList(Arrays.asList(AeroSnap.SNAP_TOPLEFT, AeroSnap.SNAP_TOP, AeroSnap.SNAP_TOPRIGHT,
101 | AeroSnap.SNAP_RIGHT,
102 | AeroSnap.SNAP_BOTTOMRIGHT, AeroSnap.SNAP_BOTTOM, AeroSnap.SNAP_BOTTOMLEFT,
103 | AeroSnap.SNAP_LEFT, AeroSnap.SNAP_NONE));
104 | final static ArrayList snapGravityReplaceTable = new ArrayList(Arrays.asList(Gravity.TOP | Gravity.LEFT, Gravity.TOP, Gravity.TOP | Gravity.RIGHT,
105 | Gravity.RIGHT,
106 | Gravity.BOTTOM | Gravity.RIGHT, Gravity.BOTTOM, Gravity.BOTTOM | Gravity.LEFT,
107 | Gravity.LEFT, 0));
108 |
109 | public static int snapGravityToSide(int snapGravity){
110 | int index = snapGravityReplaceTable.indexOf(snapGravity);
111 | if(index >=0) return snapSideReplaceTable.get(index);
112 | else return AeroSnap.SNAP_NONE;
113 | }
114 |
115 | public static int snapSideToGravity(int snapSide){
116 | int index = snapSideReplaceTable.indexOf(snapSide);
117 | if(index>=0) return snapGravityReplaceTable.get(index);
118 | else return 0;
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/colorpicker/ColorPanelView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 Daniel Nilsson
3 | * Copyright (C) 2012 THe CyanogenMod Project
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.zst.xposed.halo.floatingwindow3.prefs.colorpicker;
19 |
20 | import android.content.Context;
21 | import android.graphics.Canvas;
22 | import android.graphics.Paint;
23 | import android.graphics.RectF;
24 | import android.util.AttributeSet;
25 | import android.view.View;
26 |
27 | /**
28 | * This class draws a panel which which will be filled with a color which can be set.
29 | * It can be used to show the currently selected color which you will get from
30 | * the {@link ColorPickerView}.
31 | * @author Daniel Nilsson
32 | *
33 | */
34 | public class ColorPanelView extends View {
35 |
36 | /**
37 | * The width in pixels of the border
38 | * surrounding the color panel.
39 | */
40 | private final static float BORDER_WIDTH_PX = 1;
41 |
42 | private float mDensity = 1f;
43 |
44 | private int mBorderColor = 0xff6E6E6E;
45 | private int mColor = 0xff000000;
46 |
47 | private Paint mBorderPaint;
48 | private Paint mColorPaint;
49 |
50 | private RectF mDrawingRect;
51 | private RectF mColorRect;
52 |
53 | private AlphaPatternDrawable mAlphaPattern;
54 |
55 | public ColorPanelView(Context context){
56 | this(context, null);
57 | }
58 |
59 | public ColorPanelView(Context context, AttributeSet attrs){
60 | this(context, attrs, 0);
61 | }
62 |
63 | public ColorPanelView(Context context, AttributeSet attrs, int defStyle) {
64 | super(context, attrs, defStyle);
65 | init();
66 | }
67 |
68 | private void init(){
69 | mBorderPaint = new Paint();
70 | mColorPaint = new Paint();
71 | mDensity = getContext().getResources().getDisplayMetrics().density;
72 | }
73 |
74 |
75 | @Override
76 | protected void onDraw(Canvas canvas) {
77 |
78 | final RectF rect = mColorRect;
79 |
80 | if(BORDER_WIDTH_PX > 0){
81 | mBorderPaint.setColor(mBorderColor);
82 | canvas.drawRect(mDrawingRect, mBorderPaint);
83 | }
84 |
85 | if(mAlphaPattern != null){
86 | mAlphaPattern.draw(canvas);
87 | }
88 | mColorPaint.setColor(mColor);
89 | canvas.drawRect(rect, mColorPaint);
90 | }
91 |
92 | @Override
93 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
94 | int width = MeasureSpec.getSize(widthMeasureSpec);
95 | int height = MeasureSpec.getSize(heightMeasureSpec);
96 | setMeasuredDimension(width, height);
97 | }
98 |
99 | @Override
100 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
101 | super.onSizeChanged(w, h, oldw, oldh);
102 |
103 | mDrawingRect = new RectF();
104 | mDrawingRect.left = getPaddingLeft();
105 | mDrawingRect.right = w - getPaddingRight();
106 | mDrawingRect.top = getPaddingTop();
107 | mDrawingRect.bottom = h - getPaddingBottom();
108 | setUpColorRect();
109 | }
110 |
111 | private void setUpColorRect(){
112 | final RectF dRect = mDrawingRect;
113 | float left = dRect.left + BORDER_WIDTH_PX;
114 | float top = dRect.top + BORDER_WIDTH_PX;
115 | float bottom = dRect.bottom - BORDER_WIDTH_PX;
116 | float right = dRect.right - BORDER_WIDTH_PX;
117 |
118 | mColorRect = new RectF(left,top, right, bottom);
119 | mAlphaPattern = new AlphaPatternDrawable((int)(5 * mDensity));
120 | mAlphaPattern.setBounds(
121 | Math.round(mColorRect.left),
122 | Math.round(mColorRect.top),
123 | Math.round(mColorRect.right),
124 | Math.round(mColorRect.bottom)
125 | );
126 | }
127 |
128 | /**
129 | * Set the color that should be shown by this view.
130 | * @param color
131 | */
132 | public void setColor(int color){
133 | mColor = color;
134 | invalidate();
135 | }
136 |
137 | /**
138 | * Get the color currently show by this view.
139 | * @return
140 | */
141 | public int getColor(){
142 | return mColor;
143 | }
144 |
145 | /**
146 | * Set the color of the border surrounding the panel.
147 | * @param color
148 | */
149 | public void setBorderColor(int color){
150 | mBorderColor = color;
151 | invalidate();
152 | }
153 |
154 | /**
155 | * Get the color of the border surrounding the panel.
156 | */
157 | public int getBorderColor(){
158 | return mBorderColor;
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/adapters/PackageNameAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs.adapters;
2 |
3 | import java.util.Collections;
4 | import java.util.LinkedList;
5 | import java.util.List;
6 | import java.util.Set;
7 |
8 | import com.zst.xposed.halo.floatingwindow3.R;
9 |
10 | import android.content.Context;
11 | import android.content.Intent;
12 | import android.content.pm.ApplicationInfo;
13 | import android.content.pm.PackageInfo;
14 | import android.content.pm.PackageManager;
15 | import android.graphics.drawable.Drawable;
16 | import android.net.Uri;
17 | import android.os.Handler;
18 | import android.provider.Settings;
19 | import android.view.LayoutInflater;
20 | import android.view.View;
21 | import android.view.View.OnClickListener;
22 | import android.view.ViewGroup;
23 | import android.widget.BaseAdapter;
24 | import android.widget.ImageButton;
25 | import android.widget.ImageView;
26 | import android.widget.TextView;
27 | import android.widget.Toast;
28 |
29 | public abstract class PackageNameAdapter extends BaseAdapter {
30 |
31 | final Context mContext;
32 | final Handler mHandler;
33 | final PackageManager mPackageManager;
34 | final LayoutInflater mLayoutInflater;
35 |
36 | protected List mInstalledAppInfo;
37 | protected List mApps = new LinkedList();
38 |
39 | // temp. list holding the filtered items
40 |
41 | public PackageNameAdapter(Context ctx, Set app_array) {
42 | mContext = ctx;
43 | mHandler = new Handler();
44 | mPackageManager = ctx.getPackageManager();
45 | mLayoutInflater = (LayoutInflater) ctx
46 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
47 | update(app_array);
48 | }
49 |
50 | public void update(final Set app_array) {
51 | new Thread(new Runnable() {
52 | @Override
53 | public void run() {
54 | synchronized (mApps) {
55 | final List temp = new LinkedList();
56 | for (String pkg_name : app_array) {
57 | try {
58 | ApplicationInfo ai = mPackageManager.getApplicationInfo(pkg_name, 0);
59 | final PackageItem item = new PackageItem();
60 | item.title = ai.loadLabel(mPackageManager);
61 | item.icon = ai.loadIcon(mPackageManager);
62 | item.packageName = ai.packageName;
63 | final int index = Collections.binarySearch(temp, item);
64 | if (index < 0) {
65 | temp.add((-index - 1), item);
66 | } else {
67 | temp.add((index + 1), item);
68 | }
69 |
70 | } catch (Exception e) {
71 | }
72 | }
73 | mApps.clear();
74 | mHandler.post(new Runnable() {
75 | @Override
76 | public void run() {
77 | mApps = temp;
78 | notifyDataSetChanged();
79 | }
80 | });
81 | }
82 | }
83 | }).start();
84 | }
85 |
86 | @Override
87 | public int getCount() {
88 | return mApps.size();
89 | }
90 |
91 | @Override
92 | public PackageItem getItem(int position) {
93 | return mApps.get(position);
94 | }
95 |
96 | @Override
97 | public long getItemId(int position) {
98 | return mApps.get(position).hashCode();
99 | }
100 |
101 | @Override
102 | public View getView(int position, View convertView, ViewGroup parent) {
103 | ViewHolder holder;
104 | if (convertView != null) {
105 | holder = (ViewHolder) convertView.getTag();
106 | } else {
107 | convertView = mLayoutInflater.inflate(R.layout.view_package_list, parent, false);
108 | holder = new ViewHolder();
109 | holder.name = (TextView) convertView.findViewById(android.R.id.title);
110 | holder.icon = (ImageView) convertView.findViewById(android.R.id.icon);
111 | holder.pkg = (TextView) convertView.findViewById(android.R.id.message);
112 | holder.remove = (ImageButton) convertView.findViewById(R.id.removeButton);
113 | convertView.setTag(holder);
114 | }
115 | final PackageItem appInfo = getItem(position);
116 |
117 | holder.name.setText(appInfo.title);
118 | holder.pkg.setText(appInfo.packageName);
119 | holder.icon.setImageDrawable(appInfo.icon);
120 | holder.icon.setOnClickListener(new OnClickListener() {
121 | @Override
122 | public void onClick(View v) {
123 | try {
124 | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
125 | Uri.fromParts("package", appInfo.packageName, null));
126 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
127 | mContext.startActivity(intent);
128 | } catch (Exception e) {
129 | final String txt = mContext.getResources().getString(R.string.pref_blacklist_error)
130 | + appInfo.packageName + "\n" + e.toString();
131 | Toast.makeText(mContext, txt, Toast.LENGTH_LONG).show();
132 | e.printStackTrace();
133 | }
134 | }
135 | });
136 | holder.remove.setOnClickListener(new OnClickListener(){
137 | @Override
138 | public void onClick(View v) {
139 | onRemoveApp(appInfo.packageName);
140 | }
141 | });
142 | return convertView;
143 | }
144 |
145 | public abstract void onRemoveApp(String pkg);
146 |
147 | public class PackageItem implements Comparable {
148 | public CharSequence title;
149 | public String packageName;
150 | public Drawable icon;
151 |
152 | @Override
153 | public int compareTo(PackageItem another) {
154 | return this.title.toString().compareTo(another.title.toString());
155 | }
156 | }
157 |
158 | static class ViewHolder {
159 | TextView name;
160 | ImageView icon;
161 | TextView pkg;
162 | ImageButton remove;
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/FloatDotActivity.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 | import android.app.*;
3 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
4 | import android.content.*;
5 | import android.os.*;
6 | import com.zst.xposed.halo.floatingwindow3.*;
7 | import java.util.prefs.*;
8 | import android.widget.*;
9 | import android.graphics.*;
10 |
11 | public class FloatDotActivity extends Activity implements OnSharedPreferenceChangeListener
12 | {
13 | SharedPreferences mPref;
14 | //Context mContext;
15 | int[] mColors = new int[4];
16 | int mCircleDiameter;
17 | ImageView snapDragger;
18 | ImageView floatLauncher;
19 |
20 | @Override
21 | public void onCreate(Bundle savedInstanceState)
22 | {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.dialog_floatdot);
25 | snapDragger = (ImageView) findViewById(R.id.snapDragger);
26 | floatLauncher = (ImageView) findViewById(R.id.floatingLauncher);
27 | mPref = getSharedPreferences(Common.PREFERENCE_MAIN_FILE, MODE_WORLD_READABLE);
28 | updatePrefs();
29 | // getFragmentManager().beginTransaction().replace(R.id.floatDotPrefs,
30 | // new FloatDotFragment()).commit();
31 |
32 | }
33 |
34 | private void updatePrefs(){
35 | loadColors();
36 | mCircleDiameter=mPref.getInt(Common.KEY_FLOATDOT_SIZE, Common.DEFAULT_FLOATDOT_SIZE);
37 | snapDragger.setImageDrawable(Util.makeDoubleCircle(mColors[0], mColors[1], Util.realDp(mCircleDiameter, getApplicationContext()), Util.realDp(mCircleDiameter/4, getApplicationContext())));
38 | floatLauncher.setImageDrawable(Util.makeDoubleCircle(mColors[2], mColors[3], Util.realDp(mCircleDiameter, getApplicationContext()), Util.realDp(mCircleDiameter/4, getApplicationContext())));
39 | }
40 |
41 | private void loadColors(){
42 | mColors[0] = Color.parseColor("#" + mPref.getString(Common.KEY_FLOATDOT_COLOR_OUTER1, Common.DEFAULT_FLOATDOT_COLOR_OUTER1));
43 | if(mPref.getBoolean(Common.KEY_FLOATDOT_SINGLE_COLOR_SNAP, Common.DEFAULT_FLOATDOT_SINGLE_COLOR_SNAP))
44 | mColors[1] = mColors[0];
45 | else
46 | mColors[1] = Color.parseColor("#" + mPref.getString(Common.KEY_FLOATDOT_COLOR_INNER1, Common.DEFAULT_FLOATDOT_COLOR_INNER1));
47 | mColors[2] = Color.parseColor("#" + mPref.getString(Common.KEY_FLOATDOT_COLOR_OUTER2, Common.DEFAULT_FLOATDOT_COLOR_OUTER2));
48 | if(mPref.getBoolean(Common.KEY_FLOATDOT_SINGLE_COLOR_LAUNCHER, Common.DEFAULT_FLOATDOT_SINGLE_COLOR_LAUNCHER))
49 | mColors[3] = mColors[2];
50 | else
51 | mColors[3] = Color.parseColor("#" + mPref.getString(Common.KEY_FLOATDOT_COLOR_INNER2, Common.DEFAULT_FLOATDOT_COLOR_INNER2));
52 | }
53 |
54 | private void sendRefreshCommand(String key){
55 | int item = 0;
56 | int size = 0;
57 | float alpha = 0;
58 | String mColor = null;
59 | if(key.equals(Common.KEY_FLOATDOT_COLOR_OUTER1))
60 | item=0;
61 | else if(key.equals(Common.KEY_FLOATDOT_COLOR_INNER1))
62 | item=1;
63 | else if(key.equals(Common.KEY_FLOATDOT_COLOR_OUTER2))
64 | item=2;
65 | else if(key.equals(Common.KEY_FLOATDOT_COLOR_INNER2))
66 | item=3;
67 | else if(key.equals(Common.KEY_FLOATDOT_SINGLE_COLOR_SNAP)){
68 | item = 1;
69 | if(mPref.getBoolean(key, Common.DEFAULT_FLOATDOT_SINGLE_COLOR_SNAP))
70 | mColor = mPref.getString(Common.KEY_FLOATDOT_COLOR_OUTER1, Common.DEFAULT_FLOATDOT_COLOR_OUTER1);
71 | else
72 | mColor = mPref.getString(Common.KEY_FLOATDOT_COLOR_INNER1, Common.KEY_FLOATDOT_COLOR_INNER1);
73 | }
74 | else if(key.equals(Common.KEY_FLOATDOT_SINGLE_COLOR_LAUNCHER)){
75 | item = 3;
76 | if(mPref.getBoolean(key, Common.DEFAULT_FLOATDOT_SINGLE_COLOR_LAUNCHER))
77 | mColor = mPref.getString(Common.KEY_FLOATDOT_COLOR_OUTER2, Common.DEFAULT_FLOATDOT_COLOR_OUTER2);
78 | else
79 | mColor = mPref.getString(Common.KEY_FLOATDOT_COLOR_INNER2, Common.KEY_FLOATDOT_COLOR_INNER2);
80 | }
81 | else if(key.equals(Common.KEY_FLOATDOT_SIZE)){
82 | size = mPref.getInt(key, Common.DEFAULT_FLOATDOT_SIZE);
83 | }
84 | else if(key.equals(Common.KEY_FLOATDOT_ALPHA)){
85 | alpha = mPref.getFloat(key, Common.DEFAULT_FLOATDOT_ALPHA);
86 | }
87 | else return;
88 |
89 | if(mColor==null && size==0 && alpha == 0) mColor = mPref.getString(key, null);
90 | Intent mIntent = new Intent(Common.UPDATE_FLOATDOT_PARAMS);
91 | mIntent.putExtra("color", mColor);
92 | mIntent.putExtra("size", size);
93 | mIntent.putExtra("alpha", alpha);
94 | mIntent.putExtra("item", item);
95 | mIntent.setPackage(Common.THIS_MOD_PACKAGE_NAME);
96 | getApplicationContext().sendBroadcast(mIntent);
97 | }
98 |
99 | private void enableFloatDotLauncher(boolean enable){
100 | Intent mIntent = new Intent(Common.UPDATE_FLOATDOT_PARAMS);
101 | mIntent.putExtra(Common.KEY_FLOATDOT_LAUNCHER_ENABLED, enable);
102 | mIntent.setPackage(Common.THIS_MOD_PACKAGE_NAME);
103 | getApplicationContext().sendBroadcast(mIntent);
104 | }
105 |
106 | @Override
107 | public void onSharedPreferenceChanged(SharedPreferences p1, String key)
108 | {
109 | updatePrefs();
110 | if(key.equals(Common.KEY_FLOATDOT_LAUNCHER_ENABLED)){
111 | enableFloatDotLauncher(mPref.getBoolean(key, Common.DEFAULT_FLOATDOT_LAUNCHER_ENABLED));
112 | return;
113 | }
114 | sendRefreshCommand(key);
115 | }
116 |
117 | @Override
118 | protected void onResume() {
119 | super.onResume();
120 | mPref.registerOnSharedPreferenceChangeListener(this);
121 | }
122 |
123 | @Override
124 | protected void onPause() {
125 | super.onPause();
126 | mPref.unregisterOnSharedPreferenceChangeListener(this);
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/pref_behavior.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
10 |
14 |
18 |
25 |
30 |
37 |
38 |
39 |
43 |
48 |
54 |
60 |
65 |
66 |
67 |
72 |
80 |
86 |
91 |
96 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/MainXposed.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3;
2 |
3 | import de.robv.android.xposed.IXposedHookLoadPackage;
4 | import de.robv.android.xposed.IXposedHookZygoteInit;
5 | import de.robv.android.xposed.XSharedPreferences;
6 | import de.robv.android.xposed.XposedBridge;
7 | import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
8 | import static de.robv.android.xposed.XposedHelpers.*;
9 | import android.content.res.*;
10 | import java.util.*;
11 |
12 | public class MainXposed implements IXposedHookLoadPackage, IXposedHookZygoteInit {
13 |
14 | public static XModuleResources sModRes = null;
15 | public static XSharedPreferences mPref = null;
16 | public static XSharedPreferences mPackagesList = null;
17 | public static Compatibility.Hooks mCompatibility = new Compatibility.Hooks();
18 |
19 |
20 |
21 | @Override
22 | public void initZygote(StartupParam startupParam) throws Throwable {
23 | try{
24 | sModRes = XModuleResources.createInstance(startupParam.modulePath, null);
25 | }catch(Throwable t){
26 | XposedBridge.log("ModuleResources init failed");
27 | XposedBridge.log(t);
28 | }
29 | }
30 |
31 | @Override
32 | public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
33 | if(mPref==null)
34 | mPref = new XSharedPreferences(Common.THIS_MOD_PACKAGE_NAME, Common.PREFERENCE_MAIN_FILE);
35 | if(mPackagesList==null)
36 | mPackagesList = new XSharedPreferences(Common.THIS_MOD_PACKAGE_NAME, Common.PREFERENCE_PACKAGES_FILE);
37 | mPref.reload();
38 | mPackagesList.reload();
39 | if(!mPref.getBoolean(Common.KEY_MOVABLE_WINDOW, Common.DEFAULT_MOVABLE_WINDOW)) return;
40 |
41 | if(lpparam.packageName==null) return;
42 | XposedBridge.log("XHFW3 load package " + lpparam.packageName);
43 | if(lpparam.packageName.equals("android")){
44 | try {
45 | Class> classActivityRecord = findClass("com.android.server.am.ActivityRecord", lpparam.classLoader);
46 | if (classActivityRecord != null)
47 | SystemHooks.hookActivityRecord(classActivityRecord);
48 | Class> classTaskRecord = findClass("com.android.server.am.TaskRecord", lpparam.classLoader);
49 | if (classTaskRecord != null)
50 | SystemHooks.hookTaskRecord(classTaskRecord);
51 | else
52 | XposedBridge.log("Failed to get class TaskRecord");
53 | // Class> AMS = findClass("com.android.server.am.ActivityManagerService", lpparam.classLoader);
54 | // if(AMS!=null)
55 | // SystemHooks.hookAMS(AMS);
56 | }
57 | catch (Throwable e){
58 | XposedBridge.log("hookActivityRecord failed - Exception");
59 | XposedBridge.log(e);
60 | }
61 | try {
62 | Class> classWMS = findClass("com.android.server.wm.WindowManagerService", lpparam.classLoader);
63 | if(classWMS!=null)
64 | SystemHooks.removeAppStartingWindow(classWMS);
65 | } catch(ClassNotFoundError e){
66 | XposedBridge.log("Class com.android.server.wm.WindowManagerService not found in MainXposed");
67 | }catch (Throwable e){
68 | XposedBridge.log("removeAppStartingWindow failed - Exception");
69 | XposedBridge.log(e);
70 | }
71 | try{
72 | Class> classActivityStack = findClass("com.android.server.am.ActivityStack", lpparam.classLoader);
73 | if(classActivityStack!=null)
74 | SystemHooks.hookActivityStack(classActivityStack);
75 | } catch(ClassNotFoundError e){
76 | XposedBridge.log("Class com.android.server.am.ActivityStack not found in MainXposed");
77 | }catch (Throwable e){
78 | XposedBridge.log("hookActivityStack failed - Exception");
79 | XposedBridge.log(e);
80 | }
81 |
82 | } else if(!lpparam.packageName.startsWith("com.android.systemui")){
83 | try{
84 | MovableWindow.hookActivity(lpparam);
85 | } catch (Throwable t){
86 | XposedBridge.log("MovableWindow hook failed");
87 | XposedBridge.log(t);
88 | return;
89 | }
90 | try{
91 | Class> clsAT = findClass("android.app.ActivityThread", lpparam.classLoader);
92 | if(clsAT!=null){
93 | MovableWindow.fixExceptionWhenResuming(clsAT);
94 | }
95 | }catch(Throwable t){XposedBridge.log(t);}
96 |
97 | // XHFW
98 | TestingSettingHook.handleLoadPackage(lpparam);
99 | }
100 | else if(lpparam.packageName.equals("com.android.systemui")) {//TODO SHOULDN'T HOOK SYSTEMUI
101 | try{
102 | SystemUIOutliner.handleLoadPackage(lpparam);
103 | } catch(Exception e){
104 | XposedBridge.log("SystemUIOutliner exception in MainXposed");
105 | XposedBridge.log(e);
106 | } catch(Throwable t){
107 | XposedBridge.log(t);
108 | }
109 | // try{
110 | // Class> classRecentsApps = findClass("com.android.systemui.recents.RecentsActivity", lpparam.classLoader);
111 | // if(classRecentsApps!=null){
112 | // SystemHooks.hookRecents(classRecentsApps);
113 | // }
114 | // else {
115 | // XposedBridge.log("class Recents not found");
116 | // }
117 | // } catch (Throwable t){
118 | // XposedBridge.log("hookRecents failed");
119 | // XposedBridge.log(t);
120 | // }
121 | } //elseif
122 | }//handleLoadPackage
123 |
124 | public static boolean isBlacklisted(String pkg) {
125 | return Util.isFlag(mPackagesList.getInt(pkg, 0), Common.PACKAGE_BLACKLIST);
126 | }
127 |
128 | public static boolean isWhitelisted(String pkg) {
129 | return Util.isFlag(mPackagesList.getInt(pkg, 0), Common.PACKAGE_WHITELIST);
130 | }
131 |
132 | public static int getBlackWhiteListOption() {
133 | mPref.reload();
134 | return Integer.parseInt(mPref.getString(Common.KEY_WHITEBLACKLIST_OPTIONS, Common.DEFAULT_WHITEBLACKLIST_OPTIONS));
135 | }
136 |
137 | public static boolean isMaximizedlisted(String pkg) {
138 | return Util.isFlag(mPackagesList.getInt(pkg, 0), Common.PACKAGE_MAXIMIZE);
139 | }
140 |
141 | }
142 |
143 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_titlebar_icon_theme_chooser.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
25 |
26 |
45 |
46 |
60 |
61 |
75 |
76 |
90 |
91 |
105 |
106 |
116 |
117 |
118 |
119 |
124 |
125 |
131 |
132 |
141 |
142 |
149 |
150 |
151 |
152 |
153 |
154 |
160 |
161 |
162 |
163 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_testing.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
24 |
25 |
40 |
41 |
55 |
56 |
57 |
62 |
63 |
70 |
71 |
78 |
79 |
80 |
89 |
90 |
104 |
105 |
118 |
119 |
120 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/MaximizedActivity.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import java.util.Set;
4 |
5 | import com.zst.xposed.halo.floatingwindow3.Common;
6 | import com.zst.xposed.halo.floatingwindow3.R;
7 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.AppAdapter;
8 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.AppAdapter.AppItem;
9 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.PackageNameAdapter;
10 |
11 | import android.annotation.SuppressLint;
12 | import android.app.Activity;
13 | import android.app.AlertDialog;
14 | import android.app.Dialog;
15 | import android.content.DialogInterface;
16 | import android.content.SharedPreferences;
17 | import android.os.Bundle;
18 | import android.view.Menu;
19 | import android.view.MenuItem;
20 | import android.view.View;
21 | import android.view.View.OnClickListener;
22 | import android.view.Window;
23 | import android.widget.AdapterView;
24 | import android.widget.EditText;
25 | import android.widget.ImageButton;
26 | import android.widget.ListView;
27 | import android.widget.ProgressBar;
28 | import android.widget.AdapterView.OnItemClickListener;
29 | import java.util.*;
30 | import com.zst.xposed.halo.floatingwindow3.*;
31 |
32 | public class MaximizedActivity extends Activity {
33 |
34 | /* others */
35 | static final int ID_ADD = 1;
36 | static final int ID_HELP = 2;
37 | SharedPreferences mPref;
38 |
39 | /* main stuff */
40 | PackageNameAdapter mPkgAdapter;
41 | ListView mListView;
42 |
43 | /* app dialog stuff */
44 | AppAdapter dAdapter;
45 | Dialog dDialog;
46 | ProgressBar dProgressBar;
47 | ListView dListView;
48 | EditText dSearch;
49 | ImageButton dButton;
50 |
51 | @Override
52 | @SuppressLint("WorldReadableFiles")
53 | @SuppressWarnings("deprecation")
54 | protected void onCreate(Bundle savedInstanceState) {
55 | super.onCreate(savedInstanceState);
56 | showFirstTimeHelper(false);
57 | mPref = getSharedPreferences(Common.PREFERENCE_PACKAGES_FILE, MODE_WORLD_READABLE);
58 | loadBlacklist();
59 | initAppList();
60 | }
61 |
62 | @Override
63 | public void onPause() {
64 | super.onPause();
65 | // Avoid WindowLeaked Exception
66 | // http://publicstaticdroidmain.com/2012/01/avoiding-android-memory-leaks-part-1/
67 | if (dDialog != null && dDialog.isShowing()) {
68 | dDialog.dismiss();
69 | }
70 | }
71 |
72 | @Override
73 | public boolean onCreateOptionsMenu(Menu menu) {
74 | MenuItem help_item = menu.add(Menu.NONE, ID_HELP, 0, R.string.help);
75 | help_item.setIcon(R.drawable.blacklist_help);
76 | help_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
77 |
78 | MenuItem setting_item = menu.add(Menu.NONE, ID_ADD, 0, R.string.add);
79 | setting_item.setIcon(R.drawable.blacklist_add);
80 | setting_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
81 | return true;
82 | }
83 |
84 | @Override
85 | public boolean onOptionsItemSelected(MenuItem item) {
86 | switch (item.getItemId()) {
87 | case ID_ADD:
88 | dDialog.show();
89 | break;
90 | case ID_HELP:
91 | showFirstTimeHelper(true);
92 | break;
93 | }
94 | return false;
95 | }
96 |
97 | @SuppressWarnings("deprecation")
98 | @SuppressLint("WorldReadableFiles")
99 | private void showFirstTimeHelper(boolean force) {
100 | final SharedPreferences main = getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
101 | MODE_WORLD_READABLE);
102 | if (!main.contains(Common.KEY_MAXIMIZED_HELP) || force) {
103 | AlertDialog.Builder alert = new AlertDialog.Builder(this);
104 | alert.setMessage(R.string.pref_maximized_dialog);
105 | if (!force) {
106 | alert.setPositiveButton(R.string.close_once, null);
107 | alert.setNegativeButton(R.string.close_forever, new DialogInterface.OnClickListener() {
108 | @Override
109 | public void onClick(DialogInterface arg0, int arg1) {
110 | main.edit().putBoolean(Common.KEY_MAXIMIZED_HELP, true).commit();
111 | }
112 | });
113 | }
114 | alert.show();
115 | }
116 | }
117 |
118 | private void initAppList() {
119 | dDialog = new Dialog(this);
120 | dDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
121 | dDialog.setContentView(R.layout.dialog_blacklist);
122 |
123 | dProgressBar = (ProgressBar) dDialog.findViewById(R.id.progressBar1);
124 | dListView = (ListView) dDialog.findViewById(R.id.listView1);
125 | dSearch = (EditText) dDialog.findViewById(R.id.searchText);
126 | dButton = (ImageButton) dDialog.findViewById(R.id.searchButton);
127 |
128 | dAdapter = new AppAdapter(this, dProgressBar);
129 | dListView.setAdapter(dAdapter);
130 | dListView.setOnItemClickListener(new OnItemClickListener() {
131 | @Override
132 | public void onItemClick(AdapterView> v, View arg1, int pos, long arg3) {
133 | AppItem info = (AppItem) v.getItemAtPosition(pos);
134 | addApp(info.packageName);
135 | dDialog.dismiss();
136 | }
137 | });
138 | dButton.setOnClickListener(new OnClickListener(){
139 | @Override
140 | public void onClick(View v) {
141 | dAdapter.getFilter().filter(dSearch.getText().toString());
142 | }
143 | });
144 |
145 | dAdapter.update();
146 | }
147 |
148 | private void loadBlacklist() {
149 | mPkgAdapter = new PackageNameAdapter(this, getSetStrings()) {
150 | @Override
151 | public void onRemoveApp(String pkg) {
152 | removeApp(pkg);
153 | }
154 | };
155 | mListView = new ListView(this);
156 | mListView.setAdapter(mPkgAdapter);
157 | setContentView(mListView);
158 | }
159 |
160 | private Set getSetStrings() {
161 | Map pkgList = mPref.getAll();
162 | Set result = new HashSet();
163 | for(Map.Entry E : pkgList.entrySet()){
164 | if(E.getValue() instanceof Integer && Util.isFlag(E.getValue(), Common.PACKAGE_MAXIMIZE))
165 | result.add(E.getKey());
166 | }
167 | return result;
168 | }
169 |
170 | public void removeApp(String pkg) {
171 | mPref.edit().remove(pkg).commit();
172 | mPkgAdapter.update(getSetStrings());
173 | updateList();
174 | }
175 |
176 | public void addApp(String pkg) {
177 | int value = mPref.getInt(pkg, 0) | Common.PACKAGE_MAXIMIZE;
178 | mPref.edit().putInt(pkg, value).commit();
179 | updateList();
180 | }
181 |
182 | private void updateList() {
183 | mPkgAdapter.update(getSetStrings());
184 | }
185 |
186 | }
187 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/BlacklistActivity.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import java.util.Set;
4 |
5 | import com.zst.xposed.halo.floatingwindow3.Common;
6 | import com.zst.xposed.halo.floatingwindow3.R;
7 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.AppAdapter;
8 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.AppAdapter.AppItem;
9 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.PackageNameAdapter;
10 |
11 | import android.annotation.SuppressLint;
12 | import android.app.Activity;
13 | import android.app.AlertDialog;
14 | import android.app.Dialog;
15 | import android.content.DialogInterface;
16 | import android.content.SharedPreferences;
17 | import android.os.Bundle;
18 | import android.view.Menu;
19 | import android.view.MenuItem;
20 | import android.view.View;
21 | import android.view.View.OnClickListener;
22 | import android.view.Window;
23 | import android.widget.AdapterView;
24 | import android.widget.EditText;
25 | import android.widget.ImageButton;
26 | import android.widget.ListView;
27 | import android.widget.ProgressBar;
28 | import android.widget.AdapterView.OnItemClickListener;
29 | import java.util.*;
30 | import com.zst.xposed.halo.floatingwindow3.*;
31 |
32 | public class BlacklistActivity extends Activity {
33 |
34 | /* others */
35 | static final int ID_ADD = 1;
36 | static final int ID_HELP = 2;
37 | SharedPreferences mPref;
38 |
39 | /* main stuff */
40 | PackageNameAdapter mPkgAdapter;
41 | ListView mListView;
42 |
43 | /* app dialog stuff */
44 | AppAdapter dAdapter;
45 | Dialog dDialog;
46 | ProgressBar dProgressBar;
47 | ListView dListView;
48 | EditText dSearch;
49 | ImageButton dButton;
50 |
51 | @Override
52 | @SuppressLint("WorldReadableFiles")
53 | @SuppressWarnings("deprecation")
54 | protected void onCreate(Bundle savedInstanceState) {
55 | super.onCreate(savedInstanceState);
56 | showFirstTimeHelper(false);
57 | mPref = getSharedPreferences(Common.PREFERENCE_PACKAGES_FILE, MODE_WORLD_READABLE);
58 | loadBlacklist();
59 | initAppList();
60 | }
61 |
62 | @Override
63 | public void onPause() {
64 | super.onPause();
65 | // Avoid WindowLeaked Exception
66 | // http://publicstaticdroidmain.com/2012/01/avoiding-android-memory-leaks-part-1/
67 | if (dDialog != null && dDialog.isShowing()) {
68 | dDialog.dismiss();
69 | }
70 | }
71 |
72 | @Override
73 | public boolean onCreateOptionsMenu(Menu menu) {
74 | MenuItem help_item = menu.add(Menu.NONE, ID_HELP, 0, R.string.help);
75 | help_item.setIcon(R.drawable.blacklist_help);
76 | help_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
77 |
78 | MenuItem setting_item = menu.add(Menu.NONE, ID_ADD, 0, R.string.add);
79 | setting_item.setIcon(R.drawable.blacklist_add);
80 | setting_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
81 | return true;
82 | }
83 |
84 | @Override
85 | public boolean onOptionsItemSelected(MenuItem item) {
86 | switch (item.getItemId()) {
87 | case ID_ADD:
88 | dDialog.show();
89 | break;
90 | case ID_HELP:
91 | showFirstTimeHelper(true);
92 | break;
93 | }
94 | return false;
95 | }
96 |
97 | @SuppressWarnings("deprecation")
98 | @SuppressLint("WorldReadableFiles")
99 | private void showFirstTimeHelper(boolean force) {
100 | final SharedPreferences main = getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
101 | MODE_WORLD_READABLE);
102 | if (!main.contains(Common.KEY_BLACKLIST_HELP) || force) {
103 | AlertDialog.Builder alert = new AlertDialog.Builder(this);
104 | alert.setMessage(R.string.pref_blacklist_dialog);
105 | if (!force) {
106 | alert.setPositiveButton(R.string.close_once, null);
107 | alert.setNegativeButton(R.string.close_forever, new DialogInterface.OnClickListener() {
108 | @Override
109 | public void onClick(DialogInterface arg0, int arg1) {
110 | main.edit().putBoolean(Common.KEY_BLACKLIST_HELP, true).commit();
111 | }
112 | });
113 | }
114 | alert.show();
115 | }
116 | }
117 |
118 | private void initAppList() {
119 | dDialog = new Dialog(this);
120 | dDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
121 | dDialog.setContentView(R.layout.dialog_blacklist);
122 |
123 | dProgressBar = (ProgressBar) dDialog.findViewById(R.id.progressBar1);
124 | dListView = (ListView) dDialog.findViewById(R.id.listView1);
125 | dSearch = (EditText) dDialog.findViewById(R.id.searchText);
126 | dButton = (ImageButton) dDialog.findViewById(R.id.searchButton);
127 |
128 | dAdapter = new AppAdapter(this, dProgressBar);
129 | dListView.setAdapter(dAdapter);
130 | dListView.setOnItemClickListener(new OnItemClickListener() {
131 | @Override
132 | public void onItemClick(AdapterView> v, View arg1, int pos, long arg3) {
133 | AppItem info = (AppItem) v.getItemAtPosition(pos);
134 | addApp(info.packageName);
135 | dDialog.dismiss();
136 | }
137 | });
138 | dButton.setOnClickListener(new OnClickListener(){
139 | @Override
140 | public void onClick(View v) {
141 | dAdapter.getFilter().filter(dSearch.getText().toString());
142 | }
143 | });
144 |
145 | dAdapter.update();
146 | }
147 |
148 | private void loadBlacklist() {
149 | mPkgAdapter = new PackageNameAdapter(this, getSetStrings()) {
150 | @Override
151 | public void onRemoveApp(String pkg) {
152 | removeApp(pkg);
153 | }
154 | };
155 | mListView = new ListView(this);
156 | mListView.setAdapter(mPkgAdapter);
157 | setContentView(mListView);
158 | }
159 |
160 | private Set getSetStrings() {
161 | Map pkgList = mPref.getAll();
162 | Set result = new HashSet();
163 | for(Map.Entry E : pkgList.entrySet()){
164 |
165 | if(E.getValue() instanceof Integer && Util.isFlag(E.getValue(), Common.PACKAGE_BLACKLIST))
166 | result.add(E.getKey());
167 | }
168 | return result;
169 | }
170 |
171 | public void removeApp(String pkg) {
172 | mPref.edit().remove(pkg).commit();
173 | mPkgAdapter.update(getSetStrings());
174 | updateList();
175 | }
176 |
177 | public void addApp(String pkg) {
178 | int value = mPref.getInt(pkg, 0) | Common.PACKAGE_BLACKLIST;
179 | mPref.edit().putInt(pkg, value).commit();
180 | updateList();
181 | }
182 |
183 | private void updateList() {
184 | mPkgAdapter.update(getSetStrings());
185 | }
186 |
187 | }
188 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/WhitelistActivity.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import java.util.Set;
4 |
5 | import com.zst.xposed.halo.floatingwindow3.Common;
6 | import com.zst.xposed.halo.floatingwindow3.R;
7 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.AppAdapter.AppItem;
8 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.PackageNameAdapter;
9 |
10 | import android.annotation.SuppressLint;
11 | import android.app.Activity;
12 | import android.app.AlertDialog;
13 | import android.app.Dialog;
14 | import android.content.DialogInterface;
15 | import android.content.SharedPreferences;
16 | import android.os.Bundle;
17 | import android.view.Menu;
18 | import android.view.MenuItem;
19 | import android.view.View;
20 | import android.view.View.OnClickListener;
21 | import android.view.Window;
22 | import android.widget.AdapterView;
23 | import android.widget.EditText;
24 | import android.widget.ImageButton;
25 | import android.widget.ListView;
26 | import android.widget.ProgressBar;
27 | import android.widget.AdapterView.OnItemClickListener;
28 | import com.zst.xposed.halo.floatingwindow3.prefs.adapters.*;
29 | import java.util.*;
30 | import com.zst.xposed.halo.floatingwindow3.*;
31 |
32 | public class WhitelistActivity extends Activity {
33 |
34 | /* others */
35 | static final int ID_ADD = 1;
36 | static final int ID_HELP = 2;
37 | SharedPreferences mPref;
38 |
39 | /* main stuff */
40 | PackageNameAdapter mPkgAdapter;
41 | ListView mListView;
42 |
43 | /* app dialog stuff */
44 | com.zst.xposed.halo.floatingwindow3.prefs.adapters.AppAdapter dAdapter;
45 | Dialog dDialog;
46 | ProgressBar dProgressBar;
47 | ListView dListView;
48 | EditText dSearch;
49 | ImageButton dButton;
50 |
51 | @Override
52 | @SuppressWarnings("deprecation")
53 | @SuppressLint("WorldReadableFiles")
54 | protected void onCreate(Bundle savedInstanceState) {
55 | super.onCreate(savedInstanceState);
56 | showFirstTimeHelper(false);
57 | mPref = getSharedPreferences(Common.PREFERENCE_PACKAGES_FILE, MODE_WORLD_READABLE);
58 | loadBlacklist();
59 | initAppList();
60 | }
61 |
62 | @Override
63 | public void onPause() {
64 | super.onPause();
65 | // Avoid WindowLeaked Exception
66 | // http://publicstaticdroidmain.com/2012/01/avoiding-android-memory-leaks-part-1/
67 | if (dDialog != null && dDialog.isShowing()) {
68 | dDialog.dismiss();
69 | }
70 | }
71 |
72 | @Override
73 | public boolean onCreateOptionsMenu(Menu menu) {
74 | MenuItem help_item = menu.add(Menu.NONE, ID_HELP, 0, R.string.help);
75 | help_item.setIcon(R.drawable.blacklist_help);
76 | help_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
77 |
78 | MenuItem setting_item = menu.add(Menu.NONE, ID_ADD, 0, R.string.add);
79 | setting_item.setIcon(R.drawable.blacklist_add);
80 | setting_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
81 | return true;
82 | }
83 |
84 | @Override
85 | public boolean onOptionsItemSelected(MenuItem item) {
86 | switch (item.getItemId()) {
87 | case ID_ADD:
88 | dDialog.show();
89 | break;
90 | case ID_HELP:
91 | showFirstTimeHelper(true);
92 | break;
93 | }
94 | return false;
95 | }
96 |
97 | @SuppressWarnings("deprecation")
98 | @SuppressLint("WorldReadableFiles")
99 | private void showFirstTimeHelper(boolean force) {
100 | final SharedPreferences main = getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
101 | MODE_WORLD_READABLE);
102 | if (!main.contains(Common.KEY_BLACKLIST_HELP) || force) {
103 | AlertDialog.Builder alert = new AlertDialog.Builder(this);
104 | alert.setMessage(R.string.pref_whitelist_dialog);
105 | if (!force) {
106 | alert.setPositiveButton(R.string.close_once, null);
107 | alert.setNegativeButton(R.string.close_forever, new DialogInterface.OnClickListener() {
108 | @Override
109 | public void onClick(DialogInterface arg0, int arg1) {
110 | main.edit().putBoolean(Common.KEY_WHITELIST_HELP, true).commit();
111 | }
112 | });
113 | }
114 | alert.show();
115 | }
116 | }
117 |
118 | private void initAppList() {
119 | dDialog = new Dialog(this);
120 | dDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
121 | dDialog.setContentView(R.layout.dialog_blacklist);
122 |
123 | dProgressBar = (ProgressBar) dDialog.findViewById(R.id.progressBar1);
124 | dListView = (ListView) dDialog.findViewById(R.id.listView1);
125 | dSearch = (EditText) dDialog.findViewById(R.id.searchText);
126 | dButton = (ImageButton) dDialog.findViewById(R.id.searchButton);
127 |
128 | dAdapter = new AppAdapter(this, dProgressBar);
129 | dListView.setAdapter(dAdapter);
130 | dListView.setOnItemClickListener(new OnItemClickListener() {
131 | @Override
132 | public void onItemClick(AdapterView> v, View arg1, int pos, long arg3) {
133 | AppItem info = (AppItem) v.getItemAtPosition(pos);
134 | addApp(info.packageName);
135 | dDialog.dismiss();
136 | }
137 | });
138 | dButton.setOnClickListener(new OnClickListener(){
139 | @Override
140 | public void onClick(View v) {
141 | dAdapter.getFilter().filter(dSearch.getText().toString());
142 | }
143 | });
144 |
145 | dAdapter.update();
146 | }
147 |
148 | private void loadBlacklist() {
149 | mPkgAdapter = new PackageNameAdapter(this, getSetStrings()) {
150 | @Override
151 | public void onRemoveApp(String pkg) {
152 | removeApp(pkg);
153 | }
154 | };
155 | mListView = new ListView(this);
156 | mListView.setAdapter(mPkgAdapter);
157 | setContentView(mListView);
158 | }
159 |
160 | private Set getSetStrings() {
161 | Map pkgList = mPref.getAll();
162 | Set result = new HashSet();
163 | for(Map.Entry E : pkgList.entrySet()){
164 | if(E.getValue() instanceof Integer && Util.isFlag(E.getValue(), Common.PACKAGE_WHITELIST))
165 | result.add(E.getKey());
166 | }
167 | return result;
168 | }
169 |
170 | public void removeApp(String pkg) {
171 | mPref.edit().remove(pkg).commit();
172 | mPkgAdapter.update(getSetStrings());
173 | updateList();
174 | }
175 |
176 | public void addApp(String pkg) {
177 | int value = mPref.getInt(pkg, 0) | Common.PACKAGE_WHITELIST;
178 | mPref.edit().putInt(pkg, value).commit();
179 | updateList();
180 | }
181 |
182 | private void updateList() {
183 | mPkgAdapter.update(getSetStrings());
184 | }
185 |
186 | }
187 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/adapters/AppAdapter.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs.adapters;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collections;
5 | import java.util.LinkedList;
6 | import java.util.List;
7 | import java.util.Locale;
8 |
9 | import com.zst.xposed.halo.floatingwindow3.R;
10 |
11 | import android.content.Context;
12 | import android.content.pm.PackageInfo;
13 | import android.content.pm.PackageManager;
14 | import android.graphics.drawable.Drawable;
15 | import android.os.Handler;
16 | import android.text.TextUtils;
17 | import android.view.LayoutInflater;
18 | import android.view.View;
19 | import android.view.ViewGroup;
20 | import android.widget.BaseAdapter;
21 | import android.widget.Filter;
22 | import android.widget.Filterable;
23 | import android.widget.ImageView;
24 | import android.widget.TextView;
25 |
26 | public class AppAdapter extends BaseAdapter implements Filterable {
27 |
28 | final View mProgressBar;
29 | final Context mContext;
30 | final Handler mHandler;
31 | final PackageManager mPackageManager;
32 | final LayoutInflater mLayoutInflater;
33 |
34 | protected List mInstalledAppInfo;
35 | protected List mInstalledApps = new LinkedList();
36 | protected List mTemporarylist;
37 |
38 | // temp. list holding the filtered items
39 |
40 | public AppAdapter(Context context, View progress_bar) {
41 | mProgressBar = progress_bar;
42 | mContext = context;
43 | mHandler = new Handler();
44 | mPackageManager = mContext.getPackageManager();
45 | mLayoutInflater = (LayoutInflater) mContext
46 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
47 | mInstalledAppInfo = mPackageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
48 | mTemporarylist = mInstalledAppInfo;
49 | update();
50 | }
51 |
52 | public synchronized void update() {
53 | if (isUpdating == true) {
54 | return;
55 | }
56 | toggleProgressBarVisible(true);
57 | new Thread(new Runnable() {
58 | @Override
59 | public void run() {
60 | isUpdating = true;
61 | final List temp = new LinkedList();
62 | for (PackageInfo info : mTemporarylist) {
63 | final AppItem item = new AppItem();
64 | item.title = info.applicationInfo.loadLabel(mPackageManager);
65 | item.icon = info.applicationInfo.loadIcon(mPackageManager);
66 | item.packageName = info.packageName;
67 | final int index = Collections.binarySearch(temp, item);
68 | if (index < 0) {
69 | temp.add((-index - 1), item);
70 | } else {
71 | temp.add((index + 1), item);
72 | }
73 | }
74 | mHandler.post(new Runnable() {
75 | @Override
76 | public void run() {
77 | mInstalledApps = temp;
78 | notifyDataSetChanged();
79 | isUpdating = false;
80 | }
81 | });
82 | toggleProgressBarVisible(false);
83 | }
84 | }).start();
85 | }
86 |
87 | private void toggleProgressBarVisible(final boolean b) {
88 | mHandler.post(new Runnable() {
89 | @Override
90 | public void run() {
91 | if (mProgressBar != null) {
92 | mProgressBar.setVisibility(b ? View.VISIBLE : View.GONE);
93 | }
94 | }
95 | });
96 | }
97 |
98 | @Override
99 | public int getCount() {
100 | return mInstalledApps.size();
101 | }
102 |
103 | @Override
104 | public AppItem getItem(int position) {
105 | try {
106 | return mInstalledApps.get(position);
107 | }catch (Exception e){
108 | return new AppItem();
109 | }
110 | }
111 |
112 | @Override
113 | public long getItemId(int position) {
114 | return getItem(position).hashCode();
115 | }
116 |
117 | @Override
118 | public View getView(int position, View convertView, ViewGroup parent) {
119 | ViewHolder holder;
120 | if (convertView != null) {
121 | holder = (ViewHolder) convertView.getTag();
122 | } else {
123 | convertView = mLayoutInflater.inflate(R.layout.view_app_list, parent, false);
124 | holder = new ViewHolder();
125 | holder.name = (TextView) convertView.findViewById(android.R.id.title);
126 | holder.icon = (ImageView) convertView.findViewById(android.R.id.icon);
127 | holder.pkg = (TextView) convertView.findViewById(android.R.id.message);
128 | convertView.setTag(holder);
129 | }
130 | AppItem appInfo = getItem(position);
131 |
132 | holder.name.setText(appInfo.title);
133 | holder.pkg.setText(appInfo.packageName);
134 | holder.icon.setImageDrawable(appInfo.icon);
135 | return convertView;
136 | }
137 |
138 | boolean isFiltering;
139 | boolean isUpdating;
140 | @Override
141 | public Filter getFilter() {
142 | return new Filter() {
143 | @Override
144 | protected void publishResults(CharSequence constraint, FilterResults results) {
145 | }
146 |
147 | @Override
148 | protected FilterResults performFiltering(CharSequence constraint) {
149 | if (isFiltering || isUpdating) {
150 | return new FilterResults();
151 | }
152 |
153 | if (TextUtils.isEmpty(constraint)) {
154 | // No filter implemented we return all the list
155 | mTemporarylist = mInstalledAppInfo;
156 | update();
157 | return new FilterResults();
158 | }
159 |
160 | isFiltering = true;
161 | ArrayList FilteredList = new ArrayList();
162 | for (PackageInfo data : mInstalledAppInfo) {
163 | final String filterText = constraint.toString().toLowerCase(Locale.ENGLISH);
164 | try {
165 | if (data.applicationInfo.loadLabel(mPackageManager).toString()
166 | .toLowerCase(Locale.ENGLISH).contains(filterText)) {
167 | FilteredList.add(data);
168 | } else if (data.packageName.contains(filterText)) {
169 | FilteredList.add(data);
170 | }
171 | } catch (Exception e) {
172 | }
173 | }
174 | mTemporarylist = FilteredList;
175 | update();
176 | isFiltering = false;
177 | return new FilterResults();
178 | }
179 | };
180 | }
181 |
182 | public class AppItem implements Comparable {
183 | public CharSequence title;
184 | public String packageName;
185 | public Drawable icon;
186 |
187 | @Override
188 | public int compareTo(AppItem another) {
189 | return this.title.toString().compareTo(another.title.toString());
190 | }
191 | }
192 |
193 | static class ViewHolder {
194 | TextView name;
195 | ImageView icon;
196 | TextView pkg;
197 | }
198 | }
199 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/MainFragment.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import java.io.DataOutputStream;
4 |
5 | import android.annotation.SuppressLint;
6 | import android.app.AlertDialog;
7 | import android.content.DialogInterface;
8 | import android.content.Intent;
9 | import android.content.SharedPreferences;
10 | import android.os.Build;
11 | import android.os.Bundle;
12 | import android.preference.Preference.OnPreferenceClickListener;
13 | import android.preference.Preference;
14 | import android.preference.PreferenceActivity;
15 | import android.preference.PreferenceFragment;
16 | import android.view.View;
17 | import android.widget.AdapterView;
18 | import android.widget.ArrayAdapter;
19 | import android.widget.ListView;
20 | import android.widget.TextView;
21 | import android.widget.Toast;
22 |
23 | import com.zst.xposed.halo.floatingwindow3.Common;
24 | import com.zst.xposed.halo.floatingwindow3.R;
25 |
26 | public class MainFragment extends PreferenceFragment implements OnPreferenceClickListener {
27 |
28 | static MainFragment mInstance;
29 | SharedPreferences mPref;
30 |
31 | public static MainFragment getInstance() {
32 | if (mInstance == null) {
33 | mInstance = new MainFragment();
34 | }
35 | return mInstance;
36 | }
37 | @Override
38 | @SuppressWarnings("deprecation")
39 | @SuppressLint("WorldReadableFiles")
40 | public void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | getPreferenceManager().setSharedPreferencesName(Common.PREFERENCE_MAIN_FILE);
43 | getPreferenceManager().setSharedPreferencesMode(PreferenceActivity.MODE_WORLD_READABLE);
44 | addPreferencesFromResource(R.xml.pref_general);
45 | // findPreference(Common.KEY_KEYBOARD_MODE).setOnPreferenceClickListener(this);
46 | // findPreference(Common.KEY_RESTART_SYSTEMUI).setOnPreferenceClickListener(this);
47 | // findPreference(Common.KEY_STATUSBAR_TASKBAR_RESTART_SYSTEMUI).setOnPreferenceClickListener(this);
48 | // findPreference(Common.KEY_BLACKLIST_APPS).setOnPreferenceClickListener(this);
49 | // findPreference(Common.KEY_WHITELIST_APPS).setOnPreferenceClickListener(this);
50 | // findPreference(Common.KEY_STATUSBAR_TASKBAR_PINNED_APPS).setOnPreferenceClickListener(this);
51 | // if (Build.VERSION.SDK_INT >= 20) { // Lollipop
52 | // Preference p = findPreference("system_notif_top");
53 | // p.setEnabled(false);
54 | // p.setSummary(R.string.pref_systemui_top_summary_not_supported_lollipop);
55 | // }
56 | mPref = getActivity().getSharedPreferences(Common.PREFERENCE_MAIN_FILE,
57 | PreferenceActivity.MODE_WORLD_READABLE);
58 | }
59 |
60 | @Override
61 | public boolean onPreferenceClick(Preference p) {
62 | // String k = p.getKey();
63 | // if (k.equals(Common.KEY_KEYBOARD_MODE)) {
64 | // showKeyboardDialog();
65 | // return true;
66 | // } else if (k.equals(Common.KEY_RESTART_SYSTEMUI)
67 | // || k.equals(Common.KEY_STATUSBAR_TASKBAR_RESTART_SYSTEMUI)) {
68 | // showKillPackageDialog("com.android.systemui");
69 | // return true;
70 | // }else if (k.equals(Common.KEY_BLACKLIST_APPS)) {
71 | // showBlacklistActivity();
72 | // return true;
73 | // }else if (k.equals(Common.KEY_WHITELIST_APPS)) {
74 | // showWhitelistActivity();
75 | // return true;
76 | // }else if (k.equals(Common.KEY_STATUSBAR_TASKBAR_PINNED_APPS)) {
77 | // showStatusbarTaskbarPinAppActivity();
78 | // return true;
79 | // }
80 | return false;
81 | }
82 |
83 | private void showKeyboardDialog() {
84 | final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
85 | final ListView modeList = new ListView(getActivity());
86 |
87 | builder.setView(modeList);
88 | builder.setTitle(R.string.pref_keyboard_title);
89 |
90 | final AlertDialog dialog = builder.create();
91 | final ArrayAdapter adapter = new ArrayAdapter(getActivity(),
92 | android.R.layout.simple_list_item_1, android.R.id.text1);
93 |
94 | adapter.add(getResources().getString(R.string.keyboard_default));
95 | adapter.add(getResources().getString(R.string.keyboard_pan));
96 | adapter.add(getResources().getString(R.string.keyboard_scale));
97 |
98 | modeList.setAdapter(adapter);
99 | modeList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
100 | @Override
101 | public void onItemClick(AdapterView> parent, View view, int pos, long id) {
102 | String title = ((TextView) view.findViewById(android.R.id.text1))
103 | .getText().toString();
104 | if (title.equals(getResources().getString(R.string.keyboard_default))) {
105 | mPref.edit().putInt(Common.KEY_KEYBOARD_MODE, 1).commit();
106 | } else if (title.equals(getResources().getString(R.string.keyboard_pan))) {
107 | mPref.edit().putInt(Common.KEY_KEYBOARD_MODE, 2).commit();
108 | } else if (title.equals(getResources().getString(R.string.keyboard_scale))) {
109 | mPref.edit().putInt(Common.KEY_KEYBOARD_MODE, 3).commit();
110 | }
111 | Toast.makeText(getActivity(), title, Toast.LENGTH_SHORT).show();
112 | dialog.dismiss();
113 | }
114 | });
115 | dialog.show();
116 | }
117 |
118 | private void showKillPackageDialog(final String pkgToKill) {
119 | AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
120 | build.setMessage(R.string.pref_systemui_restart_title);
121 | build.setNegativeButton(android.R.string.cancel, null);
122 | build.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
123 | @Override
124 | public void onClick(DialogInterface dialog, int which) {
125 | killPackage(pkgToKill);
126 | }
127 | });
128 | build.show();
129 | }
130 |
131 | private void killPackage(final String pkgToKill) {
132 | new Thread(new Runnable() {
133 | @Override
134 | public void run() {
135 | try {
136 | Process su = Runtime.getRuntime().exec("su");
137 | if (su == null) return;
138 | DataOutputStream os = new DataOutputStream(su.getOutputStream());
139 | os.writeBytes("pkill " + pkgToKill + "\n");
140 | os.writeBytes("exit\n");
141 | su.waitFor();
142 | os.close();
143 | } catch (Throwable e) {
144 | e.printStackTrace();
145 | }
146 | }
147 | }).start();
148 | }
149 |
150 | // private void showStatusbarTaskbarPinAppActivity() {
151 | // startActivity(new Intent(getActivity(), StatusbarTaskbarPinAppActivity.class));
152 | // }
153 |
154 | private void showWhitelistActivity() {
155 | startActivity(new Intent(getActivity(), WhitelistActivity.class));
156 | }
157 |
158 | private void showBlacklistActivity() {
159 | startActivity(new Intent(getActivity(), BlacklistActivity.class));
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zst/xposed/halo/floatingwindow3/prefs/WidgetGravityChooser.java:
--------------------------------------------------------------------------------
1 | package com.zst.xposed.halo.floatingwindow3.prefs;
2 |
3 | import java.util.LinkedList;
4 | import java.util.List;
5 |
6 | import com.zst.xposed.halo.floatingwindow3.R;
7 | import com.zst.xposed.halo.floatingwindow3.Util;
8 |
9 | import android.app.AlertDialog;
10 | import android.content.Context;
11 | import android.content.SharedPreferences;
12 | import android.preference.DialogPreference;
13 | import android.util.AttributeSet;
14 | import android.view.Gravity;
15 | import android.view.MotionEvent;
16 | import android.view.View;
17 | import android.widget.Button;
18 | import android.widget.LinearLayout;
19 | import android.widget.ScrollView;
20 |
21 | public class WidgetGravityChooser extends DialogPreference {
22 |
23 | final static int COLOR_SELECTED = 0xffaaaaaa;
24 | final static int COLOR_UNSELECTED = 0xff444444;
25 |
26 | SharedPreferences mPref;
27 | int mOldGravity;
28 | int mNewGravity = -1;
29 |
30 | List