├── app
├── .gitignore
├── release
│ ├── preview.png
│ └── output.json
├── src
│ ├── main
│ │ ├── ic_launcher-web.png
│ │ ├── res
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── wifi_on.png
│ │ │ │ ├── wifi_off.png
│ │ │ │ ├── guide_last.png
│ │ │ │ ├── brightness_off.png
│ │ │ │ ├── brightness_on.png
│ │ │ │ ├── close_unclick.png
│ │ │ │ ├── ic_onekeylock.png
│ │ │ │ ├── ic_visibility.png
│ │ │ │ ├── setting_wifi1.png
│ │ │ │ ├── setting_wifi2.png
│ │ │ │ ├── setting_wifi3.png
│ │ │ │ ├── setting_wifi4.png
│ │ │ │ ├── ic_visibility_off.png
│ │ │ │ ├── smartbar_delete.png
│ │ │ │ ├── drop_down_brightness.png
│ │ │ │ ├── system_setting_settings.png
│ │ │ │ └── navibar_icon_settings_highlight.png
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_apk_box.png
│ │ │ │ ├── ic_pdf_box.png
│ │ │ │ ├── ic_zip_box.png
│ │ │ │ ├── ic_excel_box.png
│ │ │ │ ├── ic_image_box.png
│ │ │ │ ├── ic_music_box.png
│ │ │ │ ├── ic_video_box.png
│ │ │ │ ├── ic_visibility.png
│ │ │ │ ├── ic_word_box.png
│ │ │ │ ├── ic_document_box.png
│ │ │ │ ├── ic_drawing_box.png
│ │ │ │ ├── ic_certificate_box.png
│ │ │ │ ├── ic_file_gray_116dp.png
│ │ │ │ ├── ic_powerpoint_box.png
│ │ │ │ ├── ic_visibility_off.png
│ │ │ │ └── ic_folder_gray_48dp.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── file_manager.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_visibility.png
│ │ │ │ └── ic_visibility_off.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_visibility.png
│ │ │ │ └── ic_visibility_off.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── ic_visibility.png
│ │ │ │ └── ic_visibility_off.png
│ │ │ ├── values-xhdpi
│ │ │ │ └── dimens.xml
│ │ │ ├── xml
│ │ │ │ ├── filepath.xml
│ │ │ │ └── lock.xml
│ │ │ ├── drawable
│ │ │ │ ├── border.xml
│ │ │ │ ├── app_visible_status.xml
│ │ │ │ ├── progress_thumb_drawable.xml
│ │ │ │ ├── border_half_white_1dp.xml
│ │ │ │ ├── app_item_final.xml
│ │ │ │ ├── ic_more_vert_black_24dp.xml
│ │ │ │ ├── app_item_normal.xml
│ │ │ │ ├── app_item_right.xml
│ │ │ │ ├── app_item_bottom.xml
│ │ │ │ └── progress_style.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── attrs.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── arrays.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── values-pl
│ │ │ │ ├── arrays.xml
│ │ │ │ └── strings.xml
│ │ │ ├── values-zh
│ │ │ │ ├── arrays.xml
│ │ │ │ └── strings.xml
│ │ │ ├── layout
│ │ │ │ ├── item_file.xml
│ │ │ │ ├── launcher_item.xml
│ │ │ │ ├── activity_file_manager.xml
│ │ │ │ ├── launcher_activity.xml
│ │ │ │ └── activity_setting.xml
│ │ │ └── values-ko
│ │ │ │ └── strings.xml
│ │ ├── java
│ │ │ └── cn
│ │ │ │ └── modificator
│ │ │ │ └── launcher
│ │ │ │ ├── App.java
│ │ │ │ ├── model
│ │ │ │ ├── AdminReceiver.java
│ │ │ │ ├── ObservableFloat.java
│ │ │ │ ├── HomeEntranceService.java
│ │ │ │ ├── AppDataCenter.java
│ │ │ │ └── WifiControl.java
│ │ │ │ ├── AppManagerFragment.java
│ │ │ │ ├── widgets
│ │ │ │ ├── ObserverFontTextView.java
│ │ │ │ ├── RatioImageView.java
│ │ │ │ └── BatteryView.java
│ │ │ │ ├── ftpservice
│ │ │ │ ├── FTPReceiver.java
│ │ │ │ └── FTPService.java
│ │ │ │ ├── AboutDialog.java
│ │ │ │ ├── Utils.java
│ │ │ │ ├── CrashDetailPage.java
│ │ │ │ ├── Config.java
│ │ │ │ ├── CrashCapture.java
│ │ │ │ ├── SettingFramgent.java
│ │ │ │ └── Launcher.java
│ │ └── AndroidManifest.xml
│ ├── libs
│ │ └── yotadevice_sdk-3.7.12.jar
│ ├── epd
│ │ └── AndroidManifest.xml
│ └── home
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── .gitignore
├── CHANGELOG.md
├── gradle.properties
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/release/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/release/preview.png
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/libs/yotadevice_sdk-3.7.12.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/libs/yotadevice_sdk-3.7.12.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/wifi_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/wifi_on.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_apk_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_apk_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_pdf_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_pdf_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_zip_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_zip_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/wifi_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/wifi_off.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_excel_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_excel_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_image_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_image_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_music_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_music_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_video_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_video_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_visibility.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_visibility.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_word_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_word_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_visibility.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-mdpi/ic_visibility.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/guide_last.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/guide_last.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/file_manager.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/mipmap-xhdpi/file_manager.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_document_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_document_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_drawing_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_drawing_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/brightness_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/brightness_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/brightness_on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/brightness_on.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/close_unclick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/close_unclick.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_onekeylock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/ic_onekeylock.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_visibility.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/ic_visibility.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/setting_wifi1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/setting_wifi1.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/setting_wifi2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/setting_wifi2.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/setting_wifi3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/setting_wifi3.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/setting_wifi4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/setting_wifi4.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_visibility.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xxhdpi/ic_visibility.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_certificate_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_certificate_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_file_gray_116dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_file_gray_116dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_powerpoint_box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_powerpoint_box.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_visibility_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_visibility_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_visibility_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-mdpi/ic_visibility_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_visibility_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/ic_visibility_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/smartbar_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/smartbar_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_visibility.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xxxhdpi/ic_visibility.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_folder_gray_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-hdpi/ic_folder_gray_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_visibility_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xxhdpi/ic_visibility_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_visibility_off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xxxhdpi/ic_visibility_off.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/drop_down_brightness.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/drop_down_brightness.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/system_setting_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/system_setting_settings.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/navibar_icon_settings_highlight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Modificator/E-Ink-Launcher/HEAD/app/src/main/res/drawable-xhdpi/navibar_icon_settings_highlight.png
--------------------------------------------------------------------------------
/app/src/main/res/values-xhdpi/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | - 14sp
4 | - 45dp
5 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/filepath.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":23,"versionName":"0.1.8.1","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Dec 28 21:12:43 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_visible_status.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/progress_thumb_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## E-Ink Launcher
2 |
3 | `E-Ink Launcher` is an Android launcher for Electronic paper book
4 |
5 | this verison is support end,new version in branch [master](https://github.com/Modificator/E-Ink-Launcher)
6 |
7 | join telegram group https://t.me/EInkLauncher
8 |
9 | 
10 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/lock.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/App.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.app.Application;
4 |
5 | public class App extends Application {
6 | @Override
7 | public void onCreate() {
8 | super.onCreate();
9 | CrashCapture.getInstance().init(this, 1, Launcher.class);
10 | }
11 |
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #ffffffff
7 | #000000
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/model/AdminReceiver.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.model;
2 |
3 | import android.app.admin.DeviceAdminReceiver;
4 |
5 | /**
6 | * Created by Modificator
7 | * time: 16/12/3.下午2:49
8 | * des:create file and achieve model
9 | */
10 |
11 | public class AdminReceiver extends DeviceAdminReceiver {
12 | }
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | *.apk
10 | projectFilesBackup
11 | /.idea/sonarlint/issuestore
12 | .idea
13 | config.gradle
14 | KeyStore.key
15 | release/output.json
16 | *__gen.go
17 | *__ignore.go
18 | *.swp
19 | *.swo
20 | ~i_*
21 | ig_*
22 | zzzig_*
23 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.1.8.6
2 | - fix custom wifi icon failed
3 | - one key lock crash
4 | ---------
5 |
6 | ## 0.1.8.5
7 | - fix no custom wifi icon crash
8 | ---------
9 |
10 | ## 0.1.8.4
11 | - fix some devices can not show full setting
12 | - lock screen icon name:`E-ink_Launcher.Lock.png`
13 | - wifi icon name:`E-ink_Launcher.WifiOn.png` `E-ink_Launcher.WifiOff.png`
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_half_white_1dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
7 | - 18sp
8 | - 55dp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_item_final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_more_vert_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_item_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
-
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_item_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
-
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values-pl/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - 2
5 | - 3
6 | - 4
7 | - 5
8 | - 6
9 | - 7
10 | - 8
11 | - 9
12 | - 10
13 |
14 |
15 | - 2 ikony
16 | - 3 ikony
17 | - 4 ikony
18 | - 5 ikon
19 | - 6 ikon
20 | - 7 ikon
21 | - 8 ikon
22 | - 9 ikon
23 | - 10 ikon
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/app_item_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
-
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/epd/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/AppManagerFragment.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.app.Fragment;
4 | import android.os.Bundle;
5 |
6 | import androidx.annotation.Nullable;
7 |
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | /**
13 | * Created by Modificator
14 | * time: 16/12/28.下午11:24
15 | * des:create file and achieve model
16 | */
17 |
18 | public class AppManagerFragment extends Fragment {
19 | @Nullable
20 | @Override
21 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
22 | return super.onCreateView(inflater, container, savedInstanceState);
23 | }
24 |
25 | @Override
26 | public void onActivityCreated(@Nullable Bundle savedInstanceState) {
27 | super.onActivityCreated(savedInstanceState);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - 2
5 | - 3
6 | - 4
7 | - 5
8 | - 6
9 | - 7
10 | - 8
11 | - 9
12 | - 10
13 |
14 |
15 | - 2个
16 | - 3个
17 | - 4个
18 | - 5个
19 | - 6个
20 | - 7个
21 | - 8个
22 | - 9个
23 | - 10个
24 |
25 |
26 | - 隐藏
27 | - 一行
28 | - 两行
29 | - 不限制
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - 2
5 | - 3
6 | - 4
7 | - 5
8 | - 6
9 | - 7
10 | - 8
11 | - 9
12 | - 10
13 |
14 |
15 | - 2 items
16 | - 3 items
17 | - 4 items
18 | - 5 items
19 | - 6 items
20 | - 7 items
21 | - 8 items
22 | - 9 items
23 | - 10 items
24 |
25 |
26 | - hide
27 | - 1 line
28 | - 2 line
29 | - no limit
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/progress_style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 |
9 |
10 |
11 |
12 | -
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | -
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/widgets/ObserverFontTextView.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.widgets;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.annotation.Nullable;
6 |
7 | import android.util.AttributeSet;
8 | import android.util.TypedValue;
9 | import android.widget.TextView;
10 |
11 | import java.util.Observable;
12 | import java.util.Observer;
13 |
14 | /**
15 | * Created by Modificator
16 | * time: 16/12/3.上午2:03
17 | * des:create file and achieve model
18 | */
19 |
20 | public class ObserverFontTextView extends TextView implements Observer {
21 | public ObserverFontTextView(Context context) {
22 | super(context);
23 | }
24 |
25 | public ObserverFontTextView(Context context, @Nullable AttributeSet attrs) {
26 | super(context, attrs);
27 | }
28 |
29 | public ObserverFontTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
30 | super(context, attrs, defStyleAttr);
31 | }
32 |
33 | @Override
34 | public void update(Observable o, Object arg) {
35 | setTextSize(TypedValue.COMPLEX_UNIT_SP, (Float) arg);
36 | // requestLayout();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ## Project-wide Gradle settings.
2 | #
3 | # For more details on how to configure your build environment visit
4 | # http://www.gradle.org/docs/current/userguide/build_environment.html
5 | #
6 | # Specifies the JVM arguments used for the daemon process.
7 | # The setting is particularly useful for tweaking memory settings.
8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m
9 | android.defaults.buildfeatures.buildconfig=true
10 | android.enableJetifier=true
11 | android.nonFinalResIds=false
12 | android.nonTransitiveRClass=false
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
15 | #
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 | #Fri Dec 16 23:55:35 CST 2016
21 | #systemProp.https.proxyPort=1080
22 | #systemProp.http.proxyHost=127.0.0.1
23 | #systemProp.https.proxyHost=127.0.0.1
24 | #systemProp.http.proxyPort=1080
25 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/ftpservice/FTPReceiver.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.ftpservice;
2 |
3 | /**
4 | * Created by yashwanthreddyg on 09-06-2016.
5 | */
6 |
7 | import android.content.BroadcastReceiver;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.util.Log;
11 |
12 | public class FTPReceiver extends BroadcastReceiver {
13 |
14 | static final String TAG = FTPReceiver.class.getSimpleName();
15 |
16 | @Override
17 | public void onReceive(Context context, Intent intent) {
18 | Log.v(TAG, "Received: " + intent.getAction());
19 |
20 | try {
21 | if (intent.getAction().equals(FTPService.ACTION_START_FTPSERVER)) {
22 | Intent serverService = new Intent(context, FTPService.class);
23 | if (!FTPService.isRunning()) {
24 | context.startService(serverService);
25 | }
26 | } else if (intent.getAction().equals(FTPService.ACTION_STOP_FTPSERVER)) {
27 | Intent serverService = new Intent(context, FTPService.class);
28 | context.stopService(serverService);
29 | }
30 | } catch (Exception e) {
31 | Log.e(TAG, "Failed to start/stop on intent " + e.getMessage());
32 | }
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/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 /home/mod/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | -keep public class cn.modificator.launcher.R$*{
20 | public static final int *;
21 | }
22 | #-keep class org.apache.** {*;}
23 | #-keep interface org.apache.** {*;}
24 | #-dontwarn org.apache.**
25 | #-dontwarn org.slf4j.**
26 |
27 | -keeppackagenames doNotKeepAThing
28 | -renamesourcefileattribute SourceFile
29 | -keepattributes LineNumberTable,SourceFile
30 |
31 | -repackageclasses ''
32 |
33 | -optimizationpasses 10
34 |
35 | -dontwarn org.slf4j.impl.StaticLoggerBinder
36 | -dontwarn org.slf4j.impl.StaticMDCBinder
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_file.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
23 |
24 |
32 |
33 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/home/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/model/ObservableFloat.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.model;
2 |
3 | import android.os.Parcel;
4 | import android.os.Parcelable;
5 |
6 | import java.io.Serializable;
7 | import java.util.Observable;
8 |
9 | /**
10 | * Created by Modificator
11 | * time: 16/12/3.上午2:00
12 | * des:create file and achieve model
13 | */
14 |
15 | public class ObservableFloat extends Observable implements Parcelable, Serializable {
16 | static final long serialVersionUID = 1L;
17 | private float mValue;
18 |
19 | public ObservableFloat(float mValue) {
20 | this.mValue = mValue;
21 | }
22 |
23 | public ObservableFloat() {
24 | }
25 |
26 | public float get() {
27 | return mValue;
28 | }
29 |
30 | public void set(float value) {
31 | if (mValue != value)
32 | this.mValue = value;
33 | notifyObservers(mValue);
34 | setChanged();
35 | }
36 |
37 | @Override
38 | public int describeContents() {
39 | return 0;
40 | }
41 |
42 | @Override
43 | public void writeToParcel(Parcel dest, int flags) {
44 | dest.writeFloat(mValue);
45 | }
46 |
47 | public static final Parcelable.Creator CREATOR
48 | = new Parcelable.Creator() {
49 |
50 | @Override
51 | public ObservableFloat createFromParcel(Parcel source) {
52 | return new ObservableFloat(source.readFloat());
53 | }
54 |
55 | @Override
56 | public ObservableFloat[] newArray(int size) {
57 | return new ObservableFloat[size];
58 | }
59 | };
60 | }
61 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
21 |
22 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/model/HomeEntranceService.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.model;
2 |
3 | import android.app.Notification;
4 | import android.app.NotificationChannel;
5 | import android.app.NotificationManager;
6 | import android.app.PendingIntent;
7 | import android.app.Service;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.os.Build;
11 | import android.os.IBinder;
12 |
13 | import cn.modificator.launcher.Launcher;
14 | import cn.modificator.launcher.R;
15 |
16 | public class HomeEntranceService extends Service {
17 |
18 | public static final String HomeEntranceChannelId = "Back to Launcher";
19 | public static final String HomeEntranceChannelName = "Back to Launcher Notification";
20 |
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 | if (Build.VERSION.SDK_INT>=26){
25 | NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
26 | if (nm != null) {
27 | nm.createNotificationChannel(new NotificationChannel(HomeEntranceChannelId,HomeEntranceChannelName,NotificationManager.IMPORTANCE_LOW));
28 | }
29 | }
30 |
31 | Notification.Builder builder;
32 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
33 | builder = new Notification.Builder(this,HomeEntranceChannelId);
34 | }else{
35 | builder = new Notification.Builder(this);
36 | }
37 |
38 | startForeground(1, builder
39 | .setWhen(System.currentTimeMillis())
40 | .setContentTitle(getString(R.string.notification_click_back_launcher))
41 | .setContentIntent(PendingIntent.getActivity(this,10,new Intent(this, Launcher.class),Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED))
42 | .setSmallIcon(R.mipmap.ic_launcher)
43 | .getNotification()
44 | );
45 | }
46 |
47 | @Override
48 | public int onStartCommand(Intent intent, int flags, int startId) {
49 | return START_STICKY;
50 | }
51 |
52 | @Override
53 | public IBinder onBind(Intent intent) {
54 | return null;
55 | }
56 |
57 | @Override
58 | public void onDestroy() {
59 | Intent thisService = new Intent(this,HomeEntranceService.class);
60 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
61 | startForegroundService(thisService);
62 | }else{
63 | startService(thisService);
64 | }
65 | super.onDestroy();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | //noinspection GradleDynamicVersion
2 | apply plugin: 'com.android.application'
3 | //apply plugin: 'com.jakewharton.hugo'
4 | apply from: '../config.gradle'
5 |
6 | android {
7 | namespace 'cn.modificator.launcher'
8 | signingConfigs {
9 | config {
10 | keyAlias release.keyAlias
11 | keyPassword release.keyPassword
12 | storeFile release.storeFile
13 | storePassword release.storePassword
14 | }
15 | }
16 | compileSdkVersion 31
17 | defaultConfig {
18 | applicationId "cn.modificator.launcher"
19 | minSdkVersion 14
20 | targetSdkVersion 31
21 | versionCode 30
22 | versionName "0.1.8.6"
23 | signingConfig signingConfigs.config
24 | }
25 | buildTypes {
26 | release {
27 | debuggable false
28 | zipAlignEnabled true
29 | minifyEnabled true
30 | shrinkResources true
31 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32 | signingConfig signingConfigs.config
33 | }
34 | debug {
35 | debuggable true
36 | zipAlignEnabled true
37 | minifyEnabled false
38 | shrinkResources false
39 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
40 | signingConfig signingConfigs.config
41 | }
42 | }
43 |
44 | flavorDimensions "screen"
45 | productFlavors {
46 | home{
47 | dimension "screen"
48 | }
49 | epd{
50 | dimension "screen"
51 | }
52 | }
53 | packagingOptions {
54 | jniLibs {
55 | excludes += ['META-INF/androidx*', 'META-INF/spring*', 'META-INF/proguard/*']
56 | }
57 | resources {
58 | excludes += ['proguard-project.txt', 'project.properties', 'META-INF/LICENSE.txt', 'META-INF/LICENSE', 'META-INF/NOTICE.txt', 'META-INF/NOTICE', 'META-INF/DEPENDENCIES.txt', 'META-INF/DEPENDENCIES', 'META-INF/androidx*', 'META-INF/spring*', 'META-INF/proguard/*']
59 | }
60 | }
61 | lint {
62 | abortOnError false
63 | checkReleaseBuilds false
64 | }
65 | }
66 |
67 | dependencies {
68 | // implementation fileTree(include: ['*.jar'], dir: 'libs')
69 | implementation 'androidx.core:core:1.7.0'
70 | implementation 'org.apache.ftpserver:ftplet-api:1.1.0'
71 | implementation 'org.apache.ftpserver:ftpserver-core:1.1.0'
72 | //can't connect http://fw.ydevices.com/maven
73 | // compileOnly files('src/libs/yotadevice_sdk-3.7.12.jar')
74 | }
75 | /*
76 | android.applicationVariants.all { variant ->
77 | variant.outputs.all {
78 | outputFileName = "E-Ink Launcher_${variant.versionName}.apk"
79 | }
80 | }*/
81 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/widgets/RatioImageView.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.widgets;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 |
9 | import cn.modificator.launcher.R;
10 |
11 | /**
12 | * Created by mod on 15-10-30.
13 | */
14 | public class RatioImageView extends ImageView {
15 |
16 | /**
17 | * 以哪边为参考,默认为宽
18 | */
19 | ReferenceType reference = ReferenceType.WIDTH;
20 | /**
21 | * 宽的比例
22 | */
23 | double ratioWidth = 1;
24 | /**
25 | * 高的比例
26 | */
27 | double ratioHeight = 1;
28 |
29 | public enum ReferenceType {
30 | WIDTH,
31 | ReferenceType, HEIGHT
32 | }
33 |
34 | public RatioImageView(Context context) {
35 | super(context);
36 | }
37 |
38 | public RatioImageView(Context context, AttributeSet attrs) {
39 | super(context, attrs);
40 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RatioLayout, 0, 0);
41 | //获取参考边
42 | reference = typedArray.getInt(R.styleable.RatioLayout_reference, 0) == 0 ? ReferenceType.WIDTH : ReferenceType.HEIGHT;
43 | //获取高比例
44 | ratioHeight = typedArray.getFloat(R.styleable.RatioLayout_ratioHeight, 1);
45 | //获取宽比例
46 | ratioWidth = typedArray.getFloat(R.styleable.RatioLayout_ratioWidth, 1);
47 | typedArray.recycle();
48 | }
49 |
50 | public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) {
51 | super(context, attrs, defStyleAttr);
52 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RatioLayout, defStyleAttr, 0);
53 | //获取参考边
54 | reference = typedArray.getInt(R.styleable.RatioLayout_reference, 0) == 0 ? ReferenceType.WIDTH : ReferenceType.HEIGHT;
55 | //获取高比例
56 | ratioHeight = typedArray.getFloat(R.styleable.RatioLayout_ratioHeight, 1);
57 | //获取宽比例
58 | ratioWidth = typedArray.getFloat(R.styleable.RatioLayout_ratioWidth, 1);
59 | typedArray.recycle();
60 | }
61 |
62 | @Override
63 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
64 | /**
65 | * 如果以宽慰基准边则宽不变,高按比例得出具体数值,反之亦然
66 | */
67 | setMeasuredDimension(View.getDefaultSize(0, reference == ReferenceType.WIDTH ? widthMeasureSpec :
68 | (int) (heightMeasureSpec / ratioHeight * ratioWidth)),
69 | View.getDefaultSize(0, reference == ReferenceType.HEIGHT ? heightMeasureSpec :
70 | (int) (widthMeasureSpec / ratioWidth * ratioHeight)));
71 |
72 | int childSpec = reference == ReferenceType.WIDTH ? getMeasuredWidth() : getMeasuredHeight();
73 | /**
74 | * 获取非基准边的尺寸
75 | */
76 | int measureSpec = reference == ReferenceType.HEIGHT ? View.MeasureSpec.makeMeasureSpec(
77 | (int) (childSpec / ratioHeight * ratioWidth), View.MeasureSpec.EXACTLY) :
78 | View.MeasureSpec.makeMeasureSpec(
79 | (int) (childSpec / ratioWidth * ratioHeight), View.MeasureSpec.EXACTLY);
80 |
81 | super.onMeasure(reference == ReferenceType.WIDTH ? widthMeasureSpec : measureSpec, reference == ReferenceType.HEIGHT ? heightMeasureSpec : measureSpec);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
29 |
30 |
34 |
35 |
38 |
41 |
42 |
43 |
44 |
45 |
48 |
49 |
50 |
54 |
55 |
56 |
57 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/values-ko/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 완료
4 | E-Ink Launcher
5 | 충전 중
6 | 충전 완료
7 | 과열
8 | 배터리 부족
9 | 전원 부족
10 | 모름
11 | 읭?
12 | 기본 경로
13 | 삭제
14 | 취소
15 | 닫기
16 | 확인
17 | 숨기기
18 | 패키지 이름: %s
19 | 제거
20 | 빈 디렉토리
21 | 종료
22 | 파일 탐색기
23 | 화면 잠금
24 | 상위 폴더
25 | 경로
26 | 기기 종료
27 | 앱 관리자
28 | 클라우드 관리자 - 꺼짐
29 | 클라우드 관리자 - 켜짐
30 | "클라우드 관리자
31 | — WiFi 연결 없음"
32 | 열
33 | 도움말 & 정보
34 | 구분선 숨김
35 | " 행 "
36 | 폰트 크기 설정
37 | 구분선 표시
38 | 기기
39 | WiFi 연결이 필요합니다!
40 | APK
41 | 압축 파일
42 | 인증서
43 | 디렉토리
44 | 파일
45 | 그림
46 | 스프레드시트
47 | 이미지
48 | 음악
49 | PDF 문서
50 | 프리젠테이션
51 | 비디오
52 | 문서
53 | WiFi 닫는 중
54 | WiFi 연결: %s
55 | WiFi 연결 중
56 | WiFi 연결 해제
57 | WiFi 연결 해제 중
58 | WiFi 꺼짐
59 | WiFi 켜짐
60 | WiFi 여는 중
61 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/AboutDialog.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.Context;
5 | import android.os.Build;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.LinearLayout;
9 | import android.widget.TextView;
10 |
11 | /**
12 | * Created by Modificator
13 | * time: 17/1/7.下午2:40
14 | * des:create file and achieve model
15 | */
16 |
17 | public class AboutDialog {
18 |
19 | Context context;
20 |
21 | private AboutDialog(Context context) {
22 | this.context = context;
23 | }
24 |
25 | public static AboutDialog getInstance(Context context) {
26 | return new AboutDialog(context);
27 | }
28 |
29 | private View initLayout() {
30 | LinearLayout root = new LinearLayout(context);
31 | int padding = Utils.dp2Px(context, 15);
32 | root.setPadding(padding, padding, padding, padding);
33 | root.setOrientation(LinearLayout.VERTICAL);
34 | root.setBackgroundColor(0xffffffff);
35 | TextView appName = new TextView(context);
36 | appName.setText("E-Ink Launcher");
37 | appName.setTextSize(30);
38 | root.addView(appName);
39 | View line = new View(context);
40 | line.setBackgroundColor(0xff000000);
41 | root.addView(line, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.dp2Px(context, 1)));
42 |
43 | TextView authorInfo = new TextView(context);
44 |
45 | authorInfo.setText(" Author:Modificator\n Email:yunshangcn@gmail.com\n Weibo: weibo.com/yunshangcn");
46 | authorInfo.setTextSize(18);
47 | authorInfo.setTextColor(0xff000000);
48 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
49 | authorInfo.setLineSpacing(authorInfo.getLineSpacingExtra(), 1.2f);
50 | }
51 | LinearLayout.LayoutParams authorInfoLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
52 | authorInfoLP.topMargin = Utils.dp2Px(context, 10);
53 | authorInfoLP.bottomMargin = Utils.dp2Px(context, 10);
54 | root.addView(authorInfo, authorInfoLP);
55 |
56 | line = new View(context);
57 | line.setBackgroundColor(0xff000000);
58 | root.addView(line, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.dp2Px(context, 1)));
59 |
60 | TextView thanksView = new TextView(context);
61 | thanksView.setText("Thanks:\nMaciej Haudek ");
62 | thanksView.setTextSize(15);
63 | thanksView.setPadding(0, Utils.dp2Px(context, 10), 0, Utils.dp2Px(context, 10));
64 | root.addView(thanksView);
65 |
66 | line = new View(context);
67 | line.setBackgroundColor(0xff000000);
68 | root.addView(line, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.dp2Px(context, 1)));
69 |
70 | TextView launcherInfo = new TextView(context);
71 | launcherInfo.setText("E-Ink Launcher 是作者君闲暇之作,JDR没桌面,又找不到\n自己满意的,果断自己动手写了一个。\n主要功能:\n1.当然是显示App了\n2.App展示密度调整\n3.App名称字体大小调整\n4.卸载/隐藏App\n5.一键锁屏\n6.一键开关WIFI\n7.可以换图标了,长按图标会出现包名,把图标重命名成包名+文件后缀,然后连接电脑放到 Documents/E-Ink Launcher/icon 下就可以了\nPS:图标长按有惊喜");
72 | launcherInfo.setTextColor(0xff000000);
73 | launcherInfo.setTextSize(14);
74 | root.addView(launcherInfo);
75 |
76 | return root;
77 | }
78 |
79 | public void show() {
80 | new AlertDialog.Builder(context)
81 | .setView(initLayout())
82 | .setPositiveButton(R.string.dialog_close, null)
83 | .show();
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/launcher_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
21 |
22 |
26 |
27 |
36 |
37 |
41 |
42 |
43 |
51 |
52 |
53 |
54 |
55 |
63 |
64 |
65 |
74 |
75 |
80 |
81 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/app/src/main/res/values-pl/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | E-Ink Launcher
4 | Menedżer plików
5 |
6 | Pusty folder
7 | Urządzenie
8 | Archiwum
9 | Certyfikat
10 | Folder
11 | Plik
12 | Rysunek
13 | Arkusz
14 | Obraz
15 | Muzyka
16 | Wideo
17 | PDF
18 | Prezentacja
19 | Dokument
20 | APK
21 |
22 | Menedżer chmury - wł.
23 | Menedżer chmury - wył.
24 | Menedżer chmury\n -- Brak WIFI
25 | Słaba bateria
26 | Pokaż siatkę
27 | Ukryj siatkę
28 | Ustaw rozmiar czcionki
29 | Zarządzanie aplikacjami
30 | Kolumny
31 | " Wiersze "
32 | Proszę włączyć Wlan!
33 | Gotowe
34 | Przegrzanie baterii
35 | Nieznany
36 | Ładowanie
37 | Niski poziom
38 | Pełna
39 | WTF?
40 |
41 | Anuluj
42 | Ukryj
43 | Odinstaluj
44 | Nazwa pakietu: %s
45 | Zamknij
46 |
47 | WiFi wył.
48 | Wyłączanie WiFi
49 | Włączanie WiFi
50 | WiFi wł.
51 | WiFi połączone:%s
52 | Łączenie WiFi
53 | WiFi wyłączone
54 | Rozłączanie WiFi
55 |
56 | Zablokuj ekran
57 |
58 |
59 | - Wyłącz
60 | - Uruchom ponownie
61 |
62 | 现在可以操作电源了哦~
63 | Pomoc i informacje
64 | Ścieżka
65 | Domyślna ścieżka
66 | Potwierdź
67 | Wyżej
68 | Zakończ
69 | Usuń
70 |
71 |
--------------------------------------------------------------------------------
/app/src/main/res/values-zh/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | E-Ink Launcher
4 | 文件浏览
5 |
6 | 空文件夹
7 | App安装包
8 | 压缩包
9 | 证书
10 | 文件夹
11 | 文件
12 | 照片
13 | 电子表格
14 | 图片
15 | 音乐
16 | PDF文档
17 | PPT 演示文档
18 | 视频
19 | Word文档
20 |
21 |
22 | 显示分隔线
23 | 隐藏分隔线
24 | 设置字体大小
25 | 管理应用
26 | 打开设备管理器
27 | 每列图标
28 | 大哥诶,麻烦先把WIFI连上吧
29 | 每行图标
30 | 电池过热
31 | 电池呢?
32 | 充电中
33 | 电量低
34 | 充满了
35 | WTF?
36 |
37 | 取消
38 | 隐藏
39 | 卸载
40 | 包名: %s
41 | 关闭
42 |
43 | WiFi 已关闭
44 | WiFi 正在关闭
45 | WiFi 正在开启
46 | WiFi 已开启
47 | WiFi 已连接:%s
48 | WiFi 连接中
49 | WiFi 已断开
50 | WiFi 断开中
51 |
52 | 一键锁屏
53 |
54 |
55 | - 关机
56 | - 重启
57 |
58 | 网络传书 (开)
59 | 网络传书 (关)
60 | 网络传书 (请连接WIFI)
61 | 帮助 & 关于
62 | 路径
63 | 设置默认路径
64 | 确认
65 | 上级目录
66 | 退出
67 | 删除
68 | 完成
69 | 现在可以操作电源了哦~
70 | 电量低
71 | 显示自定义图标
72 | 显示状态栏
73 | 显示WiFi名字
74 | 点击这里回到桌面
75 | App 名字
76 | 启动失败
77 | 打开设备管理器
78 | 请打开设备管理器并启用 E-Ink Launcher
79 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/Utils.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.Manifest;
4 | import android.app.Activity;
5 | import android.content.Context;
6 | import android.content.pm.PackageManager;
7 | import android.content.res.ColorStateList;
8 | import android.graphics.drawable.Drawable;
9 | import android.os.Build;
10 |
11 | import androidx.core.graphics.drawable.DrawableCompat;
12 |
13 | import java.io.File;
14 | import java.text.DecimalFormat;
15 | import java.util.ArrayList;
16 | import java.util.Arrays;
17 | import java.util.Calendar;
18 | import java.util.Collections;
19 | import java.util.List;
20 |
21 |
22 | /**
23 | * Created by mod on 16-5-6.
24 | */
25 | public class Utils {
26 |
27 | public static Drawable tintDrawable(Drawable drawable, ColorStateList colors) {
28 | final Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
29 | DrawableCompat.setTintList(wrappedDrawable, colors);
30 | return wrappedDrawable;
31 | }
32 |
33 | public static String getReadableFileSize(long size) {
34 | // if (size <= 0) return "0";
35 | // final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
36 | // int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
37 | // return new DecimalFormat("#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
38 | DecimalFormat formater = new DecimalFormat("####.00");
39 | if (size < 1024 * 0.8) {
40 | return size + "bytes";
41 | } else if (size < 1024 * 1024 * 0.8) {
42 | float kbsize = size / 1024f;
43 | return formater.format(kbsize) + "KB";
44 | } else if (size < 1024 * 1024 * 1024 * 0.8) {
45 | float mbsize = size / 1024f / 1024f;
46 | return formater.format(mbsize) + "MB";
47 | } else if (size < 1024 * 1024 * 1024 * 1024 * 0.8) {
48 | float gbsize = size / 1024f / 1024f / 1024f;
49 | return formater.format(gbsize) + "GB";
50 | } else {
51 | float tbsize = size / 1024f / 1024f / 1024f / 1024f;
52 | return formater.format(tbsize) + "TB";
53 | }
54 | }
55 |
56 | public static int dp2Px(Context context, float dp) {
57 | final float scale = context.getResources().getDisplayMetrics().density;
58 | return (int) (dp * scale + 0.5f);
59 | }
60 |
61 | public static String getAMPMCNString(int hours, int ampm) {
62 | if (ampm == Calendar.AM) {
63 | if (hours < 5) {
64 | return sAmPmCN[0];
65 | } else if (hours >= 5 && hours < 7) {
66 | return sAmPmCN[1];
67 | } else if (hours >= 7 && hours < 9) {
68 | return sAmPmCN[2];
69 | } else if (hours >= 9 && hours < 12) {
70 | return sAmPmCN[3];
71 | } else {
72 | return sAmPmCN[0];
73 | }
74 | } else {
75 | if (hours == 0) {
76 | return sAmPmCN[4];
77 | } else if (hours < 6) {
78 | return sAmPmCN[5];
79 | } else if (hours >= 6 && hours <= 9) {
80 | return sAmPmCN[6];
81 | } else if (hours > 9 && hours < 12) {
82 | return sAmPmCN[7];
83 | } else if (hours == 12) {
84 | return sAmPmCN[4];
85 | } else {
86 | return sAmPmCN[4];
87 | }
88 | }
89 | }
90 |
91 | private static final String[] sAmPmCN = new String[]{
92 | "凌晨", "黎明", "早晨", "上午", "中午", "下午", "晚上", "深夜"
93 | };
94 |
95 | public static void checkStroagePermission(Activity activity,Runnable next){
96 | String[] permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE};
97 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && activity.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE)== PackageManager.PERMISSION_DENIED) {
98 | activity.requestPermissions(permissions,10003);
99 | }else if(next!=null){
100 | next.run();
101 | }
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_file_manager.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
22 |
23 |
41 |
42 |
43 |
47 |
48 |
53 |
54 |
58 |
59 |
62 |
63 |
74 |
75 |
79 |
80 |
81 |
89 |
90 |
94 |
95 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/CrashDetailPage.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.graphics.Color;
7 | import android.graphics.Typeface;
8 | import android.os.Bundle;
9 | import android.text.SpannableString;
10 | import android.text.Spanned;
11 | import android.text.SpannedString;
12 | import android.text.style.AbsoluteSizeSpan;
13 | import android.text.style.StyleSpan;
14 | import android.view.Gravity;
15 | import android.view.View;
16 | import android.view.ViewGroup;
17 | import android.widget.LinearLayout;
18 | import android.widget.ScrollView;
19 | import android.widget.TextView;
20 |
21 | import java.io.File;
22 | import java.io.FileInputStream;
23 | import java.io.FileNotFoundException;
24 | import java.io.FileReader;
25 | import java.io.IOException;
26 | import java.io.InputStreamReader;
27 |
28 | import androidx.annotation.Nullable;
29 |
30 | public class CrashDetailPage extends Activity {
31 |
32 | private TextView btnReLaunch, tvContent;
33 | private Context mContext;
34 |
35 | @Override
36 | protected void onCreate(@Nullable Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | mContext = this;
39 | initViews();
40 | }
41 |
42 | private void initViews() {
43 | LinearLayout root = new LinearLayout(this);
44 | root.setOrientation(LinearLayout.VERTICAL);
45 | root.setBackgroundColor(Color.WHITE);
46 |
47 | ScrollView scrollView = new ScrollView(this);
48 | tvContent = new TextView(this);
49 | tvContent.setTextColor(Color.BLACK);
50 | tvContent.setTextSize(12);
51 |
52 | scrollView.addView(tvContent);
53 |
54 |
55 | root.addView(scrollView, new LinearLayout.LayoutParams(-1, -1, 1));
56 |
57 | btnReLaunch = new TextView(this);
58 | btnReLaunch.setText("Restart Launcher");
59 | btnReLaunch.setTextColor(Color.BLACK);
60 | btnReLaunch.setGravity(Gravity.CENTER);
61 |
62 | View divider = new View(this);
63 | divider.setBackgroundColor(Color.BLACK);
64 | root.addView(divider, new ViewGroup.LayoutParams(-1, 1));
65 | root.addView(btnReLaunch, new LinearLayout.LayoutParams(-1, Utils.dp2Px(this, 40)));
66 |
67 | setContentView(root);
68 | }
69 |
70 | private void fillErrorContent() {
71 | btnReLaunch.setOnClickListener(new View.OnClickListener() {
72 | @Override
73 | public void onClick(View v) {
74 | Intent intent = new Intent(mContext, Launcher.class);
75 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
76 | startActivity(intent);
77 | finish();
78 | }
79 | });
80 |
81 | tvContent.setText("");
82 | String title = "Oh! It's Crashed.";
83 | SpannableString titleSpan = new SpannableString(title);
84 | titleSpan.setSpan(new AbsoluteSizeSpan(25, true), 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
85 | tvContent.append(titleSpan);
86 | tvContent.append("\nーーーーーーーーーーーーーーーーーーーー\n");
87 | tvContent.append("Please screenshot and give me feedback.\n");
88 | tvContent.append("email : yunshangcn@gmail.com\n");
89 | tvContent.append("telegram : https://t.me/EInkLauncher\n");
90 | tvContent.append("github issues : https://github.com/Modificator/E-Ink-Launcher\n");
91 | tvContent.append("well it's already open source\n");
92 | tvContent.append("当然也可以在酷安应用页反馈\n");
93 | tvContent.append("Thanks.");
94 | tvContent.append("\nーーーーーーーーーーーーーーーーーーーー\n");
95 |
96 | if (getIntent().hasExtra("crashFile")) {
97 | String fileName = getIntent().getStringExtra("crashFile");
98 | File crashFile = new File(getExternalFilesDir("crash"), fileName);
99 | try {
100 | char[] readData = new char[(int) crashFile.length()];
101 | FileReader reader = new FileReader(crashFile);
102 | reader.read(readData);
103 | tvContent.append(new String(readData));
104 | reader.close();
105 | } catch (Throwable e) {
106 | e.printStackTrace();
107 | }
108 | }
109 | }
110 |
111 | @Override
112 | protected void onStart() {
113 | super.onStart();
114 | fillErrorContent();
115 |
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/widgets/BatteryView.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.widgets;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Path;
7 | import android.graphics.Rect;
8 | import android.graphics.RectF;
9 | import android.text.TextPaint;
10 | import android.util.AttributeSet;
11 | import android.util.Log;
12 | import android.view.View;
13 |
14 | /**
15 | * Created by mod on 16-4-25.
16 | */
17 |
18 | public class BatteryView extends View {
19 | Paint circlePaint;
20 | TextPaint textPaint;
21 | int maxProgress = 100;
22 | int progress = 0;
23 |
24 | public BatteryView(Context context) {
25 | super(context);
26 | init();
27 | }
28 |
29 | public BatteryView(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | init();
32 | }
33 |
34 | public BatteryView(Context context, AttributeSet attrs, int defStyleAttr) {
35 | super(context, attrs, defStyleAttr);
36 | init();
37 | }
38 |
39 | private void init() {
40 | circlePaint = new Paint();
41 | circlePaint.setStyle(Paint.Style.STROKE);
42 | circlePaint.setAntiAlias(true);
43 | textPaint = new TextPaint();
44 | textPaint.setColor(0xff000000);
45 | textPaint.setAntiAlias(true);
46 | }
47 |
48 | @Override
49 | protected void onDraw(Canvas canvas) {
50 | super.onDraw(canvas);
51 | int size = getWidth() > getHeight() ? getHeight() : getWidth();
52 | circlePaint.setStrokeWidth(size / 10);
53 | circlePaint.setColor(0xffcccccc);
54 | canvas.drawCircle(getWidth() / 2, getHeight() / 2, (size - circlePaint.getStrokeWidth()) / 2, circlePaint);
55 | RectF rectF = new RectF(
56 | (getWidth() - size + circlePaint.getStrokeWidth()) / 2,
57 | (getHeight() - size + circlePaint.getStrokeWidth()) / 2,
58 | (getWidth() - size - circlePaint.getStrokeWidth()) / 2 + size,
59 | (getHeight() - size - circlePaint.getStrokeWidth()) / 2 + size
60 | );
61 | circlePaint.setColor(0xff000000);
62 | canvas.drawArc(rectF, -90, progress * 1f / maxProgress * 360, false, circlePaint);
63 | textPaint.setTextSize(size / 2.8f);
64 | drawText(canvas);
65 | }
66 |
67 | private void drawText(Canvas canvas) {
68 | String showText = String.format("%02d", (int) Math.round(progress * 1f / maxProgress * 100));
69 | Rect rect = new Rect();
70 | textPaint.getTextBounds(showText, 0, showText.length(), rect);
71 | textPaint.setFakeBoldText(true);
72 | canvas.translate(getWidth() / 2f, getHeight() / 2f);
73 | canvas.drawText(showText,
74 | -(rect.right - rect.left) / 1.9f,
75 | (rect.bottom - rect.top) / 2f, textPaint);
76 | }
77 |
78 | public void setMaxProgress(int maxProgress) {
79 | this.maxProgress = maxProgress;
80 | invalidate();
81 | }
82 |
83 | public void setProgress(int progress) {
84 | this.progress = progress;
85 | invalidate();
86 | }
87 | /*private void drawChargeIcon(Canvas canvas) {
88 | Paint paint = new Paint();
89 | paint.setStyle(Paint.Style.FILL);
90 | paint.setColor(0xff000000);
91 | int size = getHeight();
92 | float margin = size * 0.2f;
93 | Path path = new Path();
94 | path.moveTo(size / 3f+margin, 0+margin);
95 | path.lineTo(size / 3f * 2-margin, 0+margin);
96 | path.lineTo(size * 0.45f, size * 0.45f);
97 | path.lineTo(size * 0.8f, size * 0.45f);
98 | path.lineTo(size * 0.25f, size);
99 | path.lineTo(size * 0.45f, size * 0.55f);
100 | path.lineTo(size * 0.25f, size * 0.55f);*//*
101 | path.moveTo(size / 3f, 0);
102 | path.lineTo(size / 3f * 2, 0);
103 | path.lineTo(size * 0.45f, size * 0.45f);
104 | path.lineTo(size * 0.8f, size * 0.45f);
105 | path.lineTo(size * 0.25f, size);
106 | path.lineTo(size * 0.45f, size * 0.55f);
107 | path.lineTo(size * 0.25f, size * 0.55f);*//*
108 | path.close();
109 | canvas.drawPath(path, paint);
110 |
111 | }*/
112 |
113 | @Override
114 | protected void onWindowVisibilityChanged(int visibility) {
115 | super.onWindowVisibilityChanged(visibility);
116 | if (visibility == VISIBLE) {
117 |
118 | } else {
119 |
120 | }
121 | }
122 |
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | E-Ink Launcher
3 | File Manager
4 |
5 | Empty directory
6 | Device
7 | Archive
8 | Certificate
9 | Directory
10 | File
11 | Picture
12 | Spreadsheet
13 | Image
14 | Music
15 | Video
16 | PDF document
17 | Presentation
18 | Document
19 | APK
20 |
21 | Cloud Manager - ON
22 | Cloud Manager - OFF
23 | Cloud Manager\n -- No WIFI connect
24 | Low power
25 | Show Divider
26 | Hide Divider
27 | Change Font Size
28 | Apps Manager
29 | Open Device Manager
30 | Column
31 | " Row "
32 | Please connect Wlan!
33 | Done
34 | Battery Overheat
35 | Unknown
36 | Charging
37 | Low Battery
38 | Full
39 | WTF?
40 |
41 | Cancel
42 | Hide
43 | Uninstall
44 | Package Name: %s
45 | Close
46 |
47 | WiFi OFF
48 | WiFi closing
49 | WiFi opening
50 | WiFi ON
51 | WiFi connected:%s
52 | WiFi connecting
53 | WiFi disconnected
54 | WiFi disconnecting
55 |
56 | Lock Screen
57 | Launch failed
58 | Please open Device Policy Manager and enable E-Ink Launcher
59 | Open Device Policy Manager
60 |
61 |
62 | - Power off
63 | - Reboot
64 |
65 | 现在可以操作电源了哦~
66 | 混淆有毛用啊,文件这么少,代码渣貌似也能增加难度,不想加固,加固有问题,大哥我这就署名有价值,反编译别把我名字去了- -
67 | 给点赏钱吧,支付鸨就行,账号是邮箱
68 | Help & About
69 | Path
70 | Default Path
71 | Confim
72 | Parent folder
73 | Exit
74 | Delete
75 | Show StatusBar
76 | Show Wifi Name
77 | Show custom icon
78 | Click here, back to Launcher
79 | App name
80 |
81 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/launcher_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
21 |
22 |
25 |
26 |
30 |
31 |
39 |
40 |
46 |
47 |
51 |
52 |
58 |
59 |
63 |
64 |
71 |
72 |
73 |
74 |
82 |
83 |
89 |
90 |
96 |
97 |
98 |
108 |
109 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/Config.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import java.util.HashSet;
7 | import java.util.Set;
8 |
9 | /**
10 | * Created by mod on 16-4-23.
11 | */
12 | public class Config {
13 | Context context;
14 | //列数
15 | public static int colNum = -1;
16 | //行数
17 | public static int rowNum = -1;
18 | public static float fontSize = -1;
19 | public static int appNameLines = Integer.MAX_VALUE;
20 | public static boolean hideDivider = false;
21 | public static boolean showStatusBar = false;
22 | public static boolean showCustomIcon = false;
23 | private String preferencesFileName = "launcherPropertyFile";
24 | private Set hideApps = new HashSet<>();
25 |
26 | public Config(Context context) {
27 | this.context = context;
28 | getCustomIconShowStatus();
29 | getDividerHideStatus();
30 | getStatusBarShowStatus();
31 | getAppNameLines();
32 | }
33 |
34 | public int getColNum() {
35 | if (colNum == -1) {
36 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
37 | colNum = preferences.getInt(Launcher.COL_NUM_KEY, 5);
38 | }
39 | return colNum;
40 | }
41 |
42 | public void setColNum(int colNum) {
43 | if (this.colNum == colNum)
44 | return;
45 | this.colNum = colNum;
46 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
47 | preferences.edit().putInt(Launcher.COL_NUM_KEY, colNum).apply();
48 |
49 | }
50 |
51 | public int getRowNum() {
52 | if (rowNum == -1) {
53 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
54 | rowNum = preferences.getInt(Launcher.ROW_NUM_KEY, 5);
55 | }
56 | return rowNum;
57 | }
58 |
59 | public void setRowNum(int rowNum) {
60 | if (this.rowNum == rowNum)
61 | return;
62 | this.rowNum = rowNum;
63 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
64 | preferences.edit().putInt(Launcher.ROW_NUM_KEY, rowNum).apply();
65 | }
66 |
67 | public void addHideApp(String packageName) {
68 | hideApps.add(packageName);
69 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
70 | preferences.edit().putStringSet(Launcher.HIDE_APPS_KEY, hideApps).apply();
71 | }
72 |
73 | public void removeHideApp(String packageName) {
74 | hideApps.remove(packageName);
75 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
76 | preferences.edit().putStringSet(Launcher.HIDE_APPS_KEY, hideApps).apply();
77 | }
78 |
79 | public void setHideApps(Set hideApps) {
80 | this.hideApps.clear();
81 | this.hideApps.addAll(hideApps);
82 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
83 | preferences.edit().putStringSet(Launcher.HIDE_APPS_KEY, this.hideApps).apply();
84 | }
85 |
86 | public Set getHideApps() {
87 | if (hideApps.isEmpty()) {
88 | hideApps.addAll(context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE).getStringSet(Launcher.HIDE_APPS_KEY, new HashSet()));
89 | }
90 | return hideApps;
91 | }
92 |
93 | public float getFontSize() {
94 | if (fontSize == -1) {
95 | fontSize = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE).getFloat(Launcher.LAUNCHER_FONT_SIZE, 14);
96 | }
97 | return fontSize;
98 | }
99 |
100 | public void saveFontSize() {
101 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
102 | preferences.edit().putFloat(Launcher.LAUNCHER_FONT_SIZE, fontSize).apply();
103 | }
104 |
105 | public boolean getDividerHideStatus() {
106 | return hideDivider = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE).getBoolean(Launcher.LAUNCHER_HIDE_DIVIDER, true);
107 | }
108 |
109 | public void setDividerHideStatus(boolean b) {
110 | hideDivider = b;
111 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
112 | preferences.edit().putBoolean(Launcher.LAUNCHER_HIDE_DIVIDER, b).apply();
113 | }
114 |
115 | public boolean getStatusBarShowStatus(){
116 | return showStatusBar = context.getSharedPreferences(preferencesFileName,Context.MODE_PRIVATE).getBoolean(Launcher.LAUNCHER_SHOW_STATUS_BAR,true);
117 | }
118 |
119 | public void setStatusBarShowStatus(boolean b){
120 | showStatusBar = b;
121 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
122 | preferences.edit().putBoolean(Launcher.LAUNCHER_SHOW_STATUS_BAR, b).apply();
123 | }
124 |
125 | public boolean getCustomIconShowStatus(){
126 | return showCustomIcon = context.getSharedPreferences(preferencesFileName,Context.MODE_PRIVATE).getBoolean(Launcher.LAUNCHER_SHOW_CUSTOM_ICON,false);
127 | }
128 |
129 | public void setCustomIconShowStatus(boolean b){
130 | showCustomIcon = b;
131 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
132 | preferences.edit().putBoolean(Launcher.LAUNCHER_SHOW_CUSTOM_ICON, b).apply();
133 | }
134 |
135 | public void setAppNameLines(int lineNum){
136 | appNameLines = lineNum;
137 | SharedPreferences preferences = context.getSharedPreferences(preferencesFileName, Context.MODE_PRIVATE);
138 | preferences.edit().putInt(Launcher.APP_NAME_SHOW_LINES, lineNum).apply();
139 | }
140 |
141 | public int getAppNameLines(){
142 | return appNameLines = context.getSharedPreferences(preferencesFileName,Context.MODE_PRIVATE).getInt(Launcher.APP_NAME_SHOW_LINES,Integer.MAX_VALUE);
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/model/AppDataCenter.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.model;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.pm.ActivityInfo;
6 | import android.content.pm.ResolveInfo;
7 | import android.util.Log;
8 | import android.widget.TextView;
9 |
10 | import java.util.ArrayList;
11 | import java.util.HashSet;
12 | import java.util.List;
13 | import java.util.Set;
14 |
15 | import cn.modificator.launcher.Config;
16 | import cn.modificator.launcher.R;
17 | import cn.modificator.launcher.widgets.EInkLauncherView;
18 |
19 | /**
20 | * Created by mod on 16-4-22.
21 | */
22 | public class AppDataCenter {
23 | Context mContext;
24 | private static List mApps;
25 | int pageIndex = 0;
26 | int pageCount = 1;
27 | //列数
28 | int colNum = 5;
29 | //行数
30 | int rowNum = 5;
31 | EInkLauncherView launcherView;
32 | TextView pageStatus;
33 | private Set hideApps = new HashSet<>();
34 |
35 | public static final String wifiPackageName = "E-ink_Launcher.WiFi";
36 | public static final String oneKeyLockPackageName = "E-ink_Launcher.Lock";
37 |
38 | public AppDataCenter(Context context) {
39 | this.mContext = context;
40 | mApps = new ArrayList<>();
41 | // loadApps();
42 | }
43 |
44 | public void setLauncherView(EInkLauncherView launcherView) {
45 | this.launcherView = launcherView;
46 | this.launcherView.setOnSingleAppHideChangeListener(new EInkLauncherView.OnSingleAppHideChange() {
47 | @Override
48 | public void change(String pkg) {
49 | // if (!hideApps.add(pkg))
50 | // hideApps.remove(pkg);
51 | refreshAppList();
52 | }
53 | });
54 | launcherView.setHideAppPkg(hideApps);
55 | setPageShow();
56 | }
57 |
58 | public void setPageStatus(TextView pageStatus) {
59 | this.pageStatus = pageStatus;
60 | pageStatus.setText((pageIndex + 1) + "/" + (pageCount + 1));
61 | }
62 |
63 | public void setHideApps(Set hideApps) {
64 | this.hideApps.clear();
65 | this.hideApps.addAll(hideApps);
66 | loadApps();
67 | }
68 |
69 | public Set getHideApps() {
70 | return hideApps;
71 | }
72 |
73 | private void loadApps() {
74 | Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
75 | mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
76 | if (launcherView != null) {
77 | // if (launcherView!=null&&!launcherView.getHideAppPkg().isEmpty()) {
78 | hideApps.clear();
79 | hideApps.addAll(launcherView.getHideAppPkg());
80 | }
81 | mApps.clear();
82 | for (ResolveInfo resolveInfo : mContext.getPackageManager().queryIntentActivities(mainIntent, 0)) {
83 | if ("cn.modificator.launcher.Launcher".equals(resolveInfo.activityInfo.name)) continue;
84 | if (!hideApps.contains(resolveInfo.activityInfo.packageName)) {
85 | mApps.add(resolveInfo);
86 | }
87 | }
88 | if (!hideApps.contains(oneKeyLockPackageName))
89 | mApps.add(createPowerIcon());
90 | if (!hideApps.contains(wifiPackageName))
91 | mApps.add(createWifiIcon());
92 | // mApps.addAll();
93 | updatePageCount();
94 | }
95 |
96 | private void loadAllApps() {
97 | Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
98 | mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
99 | mApps.clear();
100 | mApps.addAll(mContext.getPackageManager().queryIntentActivities(mainIntent, 0));
101 | mApps.add(createPowerIcon());
102 | mApps.add(createWifiIcon());
103 | launcherView.setHideAppPkg(hideApps);
104 | updatePageCount();
105 | }
106 |
107 | public void showNextPage() {
108 | if (pageIndex >= pageCount) return;
109 | pageIndex++;
110 | setPageShow();
111 | }
112 |
113 | public void showLastPage() {
114 | if (pageIndex <= 0) return;
115 | pageIndex--;
116 | setPageShow();
117 | }
118 |
119 | public void setColNum(int colNum) {
120 | this.colNum = colNum;
121 | updatePageCount();
122 | setPageShow();
123 | }
124 |
125 | public void setRowNum(int rowNum) {
126 | this.rowNum = rowNum;
127 | updatePageCount();
128 | setPageShow();
129 | }
130 |
131 | public void refreshAppList() {
132 | refreshAppList(false);
133 | }
134 |
135 | public void refreshAppList(boolean showAll) {
136 | if (showAll) loadAllApps();
137 | else loadApps();
138 | setPageShow();
139 | }
140 | /*
141 | public void addAppInfo(ResolveInfo info) {
142 | mApps.add(info);
143 | hideApps.add(info.activityInfo.packageName);
144 | updatePageCount();
145 | setPageShow();
146 | }
147 |
148 | public void removeAppInfo(ResolveInfo info) {
149 | mApps.remove(info);
150 | hideApps.remove(info.activityInfo.packageName);
151 | updatePageCount();
152 | setPageShow();
153 | }*/
154 |
155 | private void setPageShow() {
156 | int itemCount = colNum * rowNum;
157 | int pageStart = pageIndex * itemCount;
158 | int pageEnd = (pageStart + itemCount) > mApps.size() ? mApps.size() : (pageStart + itemCount);
159 | launcherView.setAppList(mApps.subList(pageStart, pageEnd));
160 | pageStatus.setText((pageIndex + 1) + "/" + (pageCount + 1));
161 | }
162 |
163 | private void updatePageCount() {
164 | // pageCount = (int) Math.ceil(mApps.size() * 1f / (colNum * rowNum));
165 | pageCount = mApps.size() / (colNum * rowNum) - (mApps.size() % (colNum * rowNum) == 0 ? 1 : 0);
166 | pageCount = pageCount < 0 ? 0 : pageCount;
167 | pageIndex = pageIndex > pageCount ? pageCount : pageIndex;
168 | }
169 |
170 | /* public boolean isHide(String pkg) {
171 | return hideApps.contains(pkg);
172 | }
173 |
174 | public void addHide(String pkg) {
175 | hideApps.add(pkg);
176 | }
177 |
178 | public void removeHide(String pkg) {
179 | hideApps.remove(pkg);
180 | }*/
181 |
182 | private ResolveInfo createWifiIcon(){
183 | ResolveInfo resolveInfo = new ResolveInfo();
184 | resolveInfo.icon = R.drawable.wifi_on;
185 | resolveInfo.activityInfo = new ActivityInfo();
186 | resolveInfo.activityInfo.packageName = wifiPackageName;
187 | return resolveInfo;
188 | }
189 |
190 | private ResolveInfo createPowerIcon(){
191 | ResolveInfo resolveInfo = new ResolveInfo();
192 | resolveInfo.icon = R.drawable.ic_onekeylock;
193 | resolveInfo.activityInfo = new ActivityInfo();
194 | resolveInfo.activityInfo.packageName =oneKeyLockPackageName;
195 | return resolveInfo;
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/CrashCapture.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.app.AlarmManager;
4 | import android.app.PendingIntent;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.pm.PackageInfo;
8 | import android.content.pm.PackageManager;
9 | import android.os.Build;
10 | import android.os.Environment;
11 | import android.os.Looper;
12 | import android.text.TextUtils;
13 | import android.util.Log;
14 | import android.widget.Toast;
15 |
16 | import java.io.File;
17 | import java.io.FileNotFoundException;
18 | import java.io.FileOutputStream;
19 | import java.io.IOException;
20 | import java.io.PrintWriter;
21 | import java.io.StringWriter;
22 | import java.io.Writer;
23 | import java.lang.reflect.Field;
24 | import java.text.SimpleDateFormat;
25 | import java.util.Arrays;
26 | import java.util.Date;
27 | import java.util.HashMap;
28 | import java.util.Map;
29 |
30 | public class CrashCapture implements Thread.UncaughtExceptionHandler {
31 | private static final String TAG = "CrashHandler";
32 | private Thread.UncaughtExceptionHandler mDefaultHandler;// 系统默认的UncaughtException处理类
33 | private static CrashCapture INSTANCE = new CrashCapture();// CrashHandler实例
34 | private Context mContext;// 程序的Context对象
35 | private Map info = new HashMap();// 用来存储设备信息和异常信息
36 | private SimpleDateFormat format = new SimpleDateFormat(
37 | "yyyy-MM-dd-HH-mm-ss");// 用于格式化日期,作为日志文件名的一部分
38 | //重启APP时间
39 | private long mRestartTime;
40 |
41 | // 重启后跳转的Activity
42 | private Class mRestartActivity;
43 |
44 | boolean isBackground = false;
45 |
46 | private String logFile;
47 |
48 | /**
49 | * 保证只有一个CrashHandler实例
50 | */
51 | private CrashCapture() {
52 |
53 | }
54 |
55 | /**
56 | * 获取CrashHandler实例 ,单例模式
57 | */
58 | public static CrashCapture getInstance() {
59 | return INSTANCE;
60 | }
61 |
62 | /**
63 | * 初始化
64 | *
65 | * @param context
66 | */
67 | public void init(Context context, long restartTime, Class restartActivity) {
68 | mContext = context;
69 | mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();// 获取系统默认的UncaughtException处理器
70 | mRestartTime = restartTime;
71 | mRestartActivity = restartActivity;
72 | Thread.setDefaultUncaughtExceptionHandler(this);// 设置该CrashHandler为程序的默认处理器
73 | }
74 |
75 | /**
76 | * 当UncaughtException发生时会转入该重写的方法来处理
77 | */
78 | @Override
79 | public void uncaughtException(Thread thread, Throwable ex) {
80 | ex.printStackTrace();
81 | if (!handleException(ex) && mDefaultHandler != null) {
82 | // 如果自定义的没有处理则让系统默认的异常处理器来处理
83 | mDefaultHandler.uncaughtException(thread, ex);
84 | } else {
85 | try {
86 | Thread.sleep(2000);// 如果处理了,让程序继续运行2秒再退出,保证文件保存并上传到服务器
87 | } catch (InterruptedException e) {
88 | e.printStackTrace();
89 | }
90 |
91 | Intent crashIntent = new Intent(mContext, CrashDetailPage.class);
92 | crashIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
93 | if (!TextUtils.isEmpty(logFile)) {
94 | crashIntent.putExtra("crashFile", logFile);
95 | }
96 | mContext.startActivity(crashIntent);
97 |
98 | /*if (!isBackground) {
99 | Intent intent = new Intent(mContext.getApplicationContext(), mRestartActivity);
100 | AlarmManager mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
101 | //重启应用,得使用PendingIntent
102 | PendingIntent restartIntent = PendingIntent.getActivity(
103 | mContext.getApplicationContext(), 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
104 | mAlarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + mRestartTime,
105 | restartIntent); // 重启应用
106 | }
107 | // 退出程序*/
108 |
109 | android.os.Process.killProcess(android.os.Process.myPid());
110 | System.exit(10);
111 |
112 | }
113 |
114 | }
115 |
116 | /**
117 | * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成.
118 | *
119 | * @param ex 异常信息
120 | * @return true 如果处理了该异常信息;否则返回false.
121 | */
122 | public boolean handleException(Throwable ex) {
123 | if (ex == null)
124 | return false;
125 | // 收集设备参数信息
126 | collectDeviceInfo(mContext);
127 | // 保存日志文件
128 | logFile = saveCrashInfo2File(ex);
129 | return true;
130 | }
131 |
132 | /**
133 | * 收集设备参数信息
134 | *
135 | * @param context
136 | */
137 | public void collectDeviceInfo(Context context) {
138 | try {
139 | PackageManager pm = context.getPackageManager();// 获得包管理器
140 | PackageInfo pi = pm.getPackageInfo(context.getPackageName(),
141 | PackageManager.GET_ACTIVITIES);// 得到该应用的信息,即主Activity
142 | if (pi != null) {
143 | String versionName = pi.versionName == null ? "null"
144 | : pi.versionName;
145 | String versionCode = pi.versionCode + "";
146 | info.put("versionName", versionName);
147 | info.put("versionCode", versionCode);
148 | }
149 | } catch (PackageManager.NameNotFoundException e) {
150 | e.printStackTrace();
151 | }
152 | info.put("osVersion", Build.VERSION.RELEASE);
153 | info.put("sdkCode", Build.VERSION.SDK_INT + "");
154 | info.put("FINGERPRINT", Build.FINGERPRINT);
155 | info.put("DISPLAY", Build.DISPLAY);
156 | /* Field[] fields = Build.class.getDeclaredFields();// 反射机制
157 | for (Field field : fields) {
158 | try {
159 | field.setAccessible(true);
160 | if (field.get("") instanceof String[]){
161 | info.put(field.getName(), Arrays.toString((String[])field.get("")));
162 | }else {
163 | info.put(field.getName(), field.get("").toString());
164 | }
165 | Log.d(TAG, field.getName() + ":" + field.get(""));
166 | } catch (IllegalArgumentException e) {
167 | e.printStackTrace();
168 | } catch (IllegalAccessException e) {
169 | e.printStackTrace();
170 | }
171 | }*/
172 | }
173 |
174 | private String saveCrashInfo2File(Throwable ex) {
175 | StringBuffer sb = new StringBuffer();
176 | for (Map.Entry entry : info.entrySet()) {
177 | String key = entry.getKey();
178 | String value = entry.getValue();
179 | sb.append(key + "=" + value + "\r\n");
180 | }
181 | Writer writer = new StringWriter();
182 | PrintWriter pw = new PrintWriter(writer);
183 | ex.printStackTrace(pw);
184 | Throwable cause = ex.getCause();
185 | // 循环着把所有的异常信息写入writer中
186 | while (cause != null) {
187 | cause.printStackTrace(pw);
188 | cause = cause.getCause();
189 | }
190 | pw.close();// 记得关闭
191 | String result = writer.toString();
192 | sb.append(result);
193 |
194 | // 保存文件
195 | long timetamp = System.currentTimeMillis();
196 | String time = format.format(new Date());
197 | String fileName = "crash-" + BuildConfig.VERSION_NAME + "-" + Build.DEVICE + "-" + Build.PRODUCT + "-" + Build.TYPE + "-" + time + "-" + System.currentTimeMillis() + ".log";
198 | if (Environment.getExternalStorageState().equals(
199 | Environment.MEDIA_MOUNTED)) {
200 | try {
201 | // File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "crash");
202 | File dir = mContext.getExternalFilesDir("crash");
203 | Log.i("CrashHandler", dir.toString());
204 | if (!dir.exists())
205 | dir.mkdir();
206 | FileOutputStream fos = new FileOutputStream(new File(dir,
207 | fileName));
208 | fos.write(sb.toString().getBytes());
209 | fos.close();
210 | return fileName;
211 | } catch (FileNotFoundException e) {
212 | e.printStackTrace();
213 | } catch (IOException e) {
214 | e.printStackTrace();
215 | }
216 | }
217 | return null;
218 | }
219 |
220 | }
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/model/WifiControl.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.model;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.IntentFilter;
7 | import android.net.ConnectivityManager;
8 | import android.net.NetworkInfo;
9 | import android.net.Uri;
10 | import android.net.wifi.WifiManager;
11 | import android.os.Parcelable;
12 | import android.provider.Settings;
13 |
14 | import android.text.TextUtils;
15 | import android.util.Log;
16 | import android.view.View;
17 |
18 | import java.io.File;
19 | import java.util.List;
20 |
21 | import cn.modificator.launcher.Config;
22 | import cn.modificator.launcher.R;
23 | import cn.modificator.launcher.widgets.ObserverFontTextView;
24 | import cn.modificator.launcher.widgets.RatioImageView;
25 |
26 | /**
27 | * Created by Modificator
28 | * time: 16/12/3.下午12:46
29 | * des:create file and achieve model
30 | */
31 |
32 | public class WifiControl {
33 | final String wifiOnResName = "E-ink_Launcher.WifiOn";
34 | final String wifiOffResName = "E-ink_Launcher.WifiOff";
35 |
36 | ObserverFontTextView appName;
37 | RatioImageView appImage;
38 | WifiStateReceiver wifiStateReceiver;
39 | WifiManager wifiManager;
40 | ConnectivityManager connManager;
41 | Context mContext;
42 | int showNameRes;
43 | int showIconRes;
44 | String connectWifiName;
45 | List iconReplacePkg;
46 | List iconReplaceFile;
47 |
48 | private static WifiControl instance;
49 |
50 | public static void init(Context context){
51 | instance = new WifiControl(context.getApplicationContext());
52 | }
53 |
54 | private WifiControl(Context context){
55 | mContext = context;
56 | wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
57 | connManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
58 | int wifiState = wifiManager.getWifiState();
59 | switch (wifiState) {
60 | case WifiManager.WIFI_STATE_DISABLED:
61 | showNameRes = R.string.wifi_status_off;
62 | showIconRes = R.drawable.wifi_off;
63 | break;
64 | case WifiManager.WIFI_STATE_DISABLING:
65 | showNameRes = R.string.wifi_status_closing;
66 | showIconRes = R.drawable.wifi_on;
67 | break;
68 | case WifiManager.WIFI_STATE_ENABLING:
69 | showNameRes = R.string.wifi_status_opening;
70 | showIconRes = R.drawable.wifi_off;
71 | break;
72 | case WifiManager.WIFI_STATE_ENABLED:
73 | showNameRes = R.string.wifi_status_on;
74 | showIconRes = R.drawable.wifi_on;
75 | break;
76 | }
77 |
78 | wifiStateReceiver = new WifiStateReceiver();
79 | IntentFilter filter = new IntentFilter();
80 | filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
81 | filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
82 | mContext.registerReceiver(wifiStateReceiver, filter);
83 | }
84 |
85 | public static void bind(View view, List iconReplacePkg, List iconReplaceFile){
86 | if (view==null){
87 | instance.appImage=null;
88 | instance.appName = null;
89 | return;
90 | }
91 | instance.iconReplacePkg = iconReplacePkg;
92 | instance.iconReplaceFile = iconReplaceFile;
93 | instance.appName = view.findViewById(R.id.appName);
94 | instance.appImage = view.findViewById(R.id.appImage);
95 | instance.updateStatus();
96 | }
97 |
98 | public static void reloadWifiName(){
99 | if (instance.showNameRes == R.string.wifi_status_connected && instance.connectWifiName!=null && instance.connectWifiName.contains("unknown ssid")){
100 | instance.connectWifiName = instance.wifiManager.getConnectionInfo().getSSID().replace("\"","");
101 | if (!TextUtils.isEmpty(instance.connectWifiName)){
102 | instance.connectWifiName = "\n"+instance.connectWifiName;
103 | }
104 | instance.updateStatus();
105 | }
106 | }
107 |
108 | private void updateStatus(){
109 | if (appName!=null) {
110 | appName.setText(mContext.getString(showNameRes, connectWifiName));
111 | String fileName = showIconRes == R.drawable.wifi_on ? wifiOnResName : wifiOffResName;
112 | int index = iconReplacePkg.indexOf(fileName);
113 | if (!Config.showCustomIcon && iconReplacePkg != null && index > 0) {
114 | appImage.setImageURI(Uri.fromFile(iconReplaceFile.get(index)));
115 | } else {
116 | appImage.setImageResource(showIconRes);
117 | }
118 | }
119 | }
120 |
121 |
122 | public static void onClickWifiItem(){
123 | int wifiApState = instance.wifiManager.getWifiState(); //获取wifi状态
124 |
125 | if (wifiApState == instance.wifiManager.WIFI_STATE_ENABLING || wifiApState == instance.wifiManager.WIFI_STATE_ENABLED)
126 | instance.wifiManager.setWifiEnabled(false);
127 | else
128 | instance.wifiManager.setWifiEnabled(true);
129 | }
130 |
131 | public static void onLongClickWifiItem(){
132 | Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
133 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
134 | instance.mContext.startActivity(intent);
135 | }
136 |
137 | class WifiStateReceiver extends BroadcastReceiver {
138 |
139 | @Override
140 | public void onReceive(Context context, Intent intent) {
141 | if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(intent.getAction())) {
142 | int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, 0);
143 | switch (wifiState) {
144 | case WifiManager.WIFI_STATE_DISABLED:
145 | showNameRes = R.string.wifi_status_off;
146 | showIconRes = R.drawable.wifi_off;
147 | break;
148 | case WifiManager.WIFI_STATE_DISABLING:
149 | showNameRes = R.string.wifi_status_closing;
150 | showIconRes = R.drawable.wifi_on;
151 | break;
152 | case WifiManager.WIFI_STATE_ENABLING:
153 | showNameRes = R.string.wifi_status_opening;
154 | showIconRes = R.drawable.wifi_off;
155 | break;
156 | case WifiManager.WIFI_STATE_ENABLED:
157 | showNameRes = R.string.wifi_status_on;
158 | showIconRes = R.drawable.wifi_on;
159 | break;
160 | }
161 | }
162 | if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
163 |
164 |
165 | Parcelable parcelableExtra = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
166 | if (null != parcelableExtra) {
167 | NetworkInfo networkInfo = (NetworkInfo) parcelableExtra;
168 | switch (networkInfo.getState()) {
169 | case CONNECTED:
170 | Log.e("APActivity", "CONNECTED");
171 | // appName.setSingleLine(false);
172 | String wifiName = "";
173 | if (networkInfo.getExtraInfo()!=null) {
174 | wifiName = networkInfo.getExtraInfo().replace("\"", "");
175 | }
176 | if (wifiName.isEmpty()){
177 | wifiName = wifiManager.getConnectionInfo().getSSID().replace("\"","");
178 | }
179 | if (!TextUtils.isEmpty(wifiName)){
180 | wifiName = "\n"+wifiName;
181 | }
182 | showNameRes= R.string.wifi_status_connected;
183 | connectWifiName = wifiName;
184 |
185 | break;
186 | case CONNECTING:
187 | Log.e("APActivity", "CONNECTING");
188 | showNameRes = R.string.wifi_status_connecting;
189 | break;
190 | case DISCONNECTED:
191 | Log.e("APActivity", "DISCONNECTED");
192 | showNameRes = R.string.wifi_status_disconnected;
193 | break;
194 | case DISCONNECTING:
195 | Log.e("APActivity", "DISCONNECTING");
196 | showNameRes = R.string.wifi_status_disconnecting;
197 | break;
198 | case SUSPENDED:
199 | Log.e("APActivity", "SUSPENDED");
200 | break;
201 | case UNKNOWN:
202 | Log.e("APActivity", "UNKNOWN");
203 | break;
204 | default:
205 | break;
206 | }
207 | }
208 | }
209 | updateStatus();
210 | }
211 | }
212 | }
213 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2018 Modificator
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/ftpservice/FTPService.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher.ftpservice;
2 |
3 | /**
4 | * Created by yashwanthreddyg on 09-06-2016.
5 | */
6 |
7 | import android.app.AlarmManager;
8 | import android.app.PendingIntent;
9 | import android.app.Service;
10 | import android.content.Context;
11 | import android.content.Intent;
12 | import android.content.SharedPreferences;
13 | import android.net.ConnectivityManager;
14 | import android.net.NetworkInfo;
15 | import android.net.wifi.WifiManager;
16 | import android.os.Environment;
17 | import android.os.IBinder;
18 | import android.os.SystemClock;
19 | import android.preference.PreferenceManager;
20 | import android.util.Log;
21 |
22 | import org.apache.ftpserver.ConnectionConfigFactory;
23 | import org.apache.ftpserver.FtpServer;
24 | import org.apache.ftpserver.FtpServerFactory;
25 | import org.apache.ftpserver.ftplet.Authority;
26 | import org.apache.ftpserver.ftplet.FtpException;
27 | import org.apache.ftpserver.listener.ListenerFactory;
28 | import org.apache.ftpserver.usermanager.impl.BaseUser;
29 | import org.apache.ftpserver.usermanager.impl.WritePermission;
30 |
31 | import java.io.IOException;
32 | import java.lang.reflect.Method;
33 | import java.net.DatagramSocket;
34 | import java.net.InetAddress;
35 | import java.net.NetworkInterface;
36 | import java.net.ServerSocket;
37 | import java.net.SocketException;
38 | import java.net.UnknownHostException;
39 | import java.util.ArrayList;
40 | import java.util.Collections;
41 | import java.util.Enumeration;
42 | import java.util.List;
43 |
44 | public class FTPService extends Service implements Runnable {
45 |
46 | public static final int DEFAULT_PORT = 2333;
47 | public static final String PORT_PREFERENCE_KEY = "ftpPort";
48 |
49 | // Service will (global) broadcast when server start/stop
50 | public static final String ACTION_STARTED = "cn.modificator.launcher.ftpservice.FTPReceiver.FTPSERVER_STARTED";
51 | public static final String ACTION_STOPPED = "cn.modificator.launcher.ftpservice.FTPReceiver.FTPSERVER_STOPPED";
52 | public static final String ACTION_FAILEDTOSTART = "cn.modificator.launcher.ftpservice.FTPReceiver.FTPSERVER_FAILEDTOSTART";
53 |
54 | // RequestStartStopReceiver listens for these actions to start/stop this server
55 | public static final String ACTION_START_FTPSERVER = "cn.modificator.launcher.ftpservice.FTPReceiver.ACTION_START_FTPSERVER";
56 | public static final String ACTION_STOP_FTPSERVER = "cn.modificator.launcher.ftpservice.FTPReceiver.ACTION_STOP_FTPSERVER";
57 |
58 | public static int getDefaultPortFromPreferences(SharedPreferences preferences) {
59 | try {
60 | return preferences.getInt(PORT_PREFERENCE_KEY, DEFAULT_PORT);
61 | } catch (ClassCastException ex) {
62 | Log.e("FtpService", "Default port preference is not an int. Resetting to default.");
63 | changeFTPServerPort(preferences, DEFAULT_PORT);
64 |
65 | return DEFAULT_PORT;
66 | }
67 | }
68 |
69 | public static void changeFTPServerPort(SharedPreferences preferences, int port) {
70 | preferences.edit()
71 | .putInt(PORT_PREFERENCE_KEY, port)
72 | .apply();
73 | }
74 |
75 | private static final String TAG = FTPService.class.getSimpleName();
76 | /**
77 | * TODO: 25/10/16 This is ugly
78 | */
79 | private static int port = 2333;
80 |
81 | private String username, password;
82 | private boolean isPasswordProtected = false;
83 | protected boolean shouldExit = false;
84 |
85 | private FtpServer server;
86 | protected static Thread serverThread = null;
87 |
88 | @Override
89 | public int onStartCommand(Intent intent, int flags, int startId) {
90 | shouldExit = false;
91 | int attempts = 10;
92 | while (serverThread != null) {
93 | if (attempts > 0) {
94 | attempts--;
95 | FTPService.sleepIgnoreInterupt(1000);
96 | } else {
97 | return START_STICKY;
98 | }
99 | }
100 |
101 | if (intent != null && intent.getStringExtra("username") != null && intent.getStringExtra("password") != null) {
102 | username = intent.getStringExtra("username");
103 | password = intent.getStringExtra("password");
104 | isPasswordProtected = true;
105 | }
106 | serverThread = new Thread(this);
107 | serverThread.start();
108 |
109 | return START_STICKY;
110 | }
111 |
112 |
113 | @Override
114 | public IBinder onBind(Intent intent) {
115 | return null;
116 | }
117 |
118 | @Override
119 | public void run() {
120 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
121 |
122 | FtpServerFactory serverFactory = new FtpServerFactory();
123 | ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
124 | connectionConfigFactory.setAnonymousLoginEnabled(true);
125 |
126 |
127 | serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
128 |
129 | String path = Environment.getExternalStorageDirectory().getAbsolutePath();
130 |
131 | BaseUser user = new BaseUser();
132 | if (!isPasswordProtected) {
133 | user.setName("anonymous");
134 | } else {
135 | user.setName(username);
136 | user.setPassword(password);
137 | }
138 |
139 | user.setHomeDirectory(path);
140 | List list = new ArrayList<>();
141 | list.add(new WritePermission());
142 | user.setAuthorities(list);
143 | try {
144 | serverFactory.getUserManager().save(user);
145 | } catch (FtpException e) {
146 | e.printStackTrace();
147 | }
148 | ListenerFactory fac = new ListenerFactory();
149 |
150 | port = getDefaultPortFromPreferences(preferences);
151 |
152 | fac.setPort(port);
153 |
154 | serverFactory.addListener("default", fac.createListener());
155 | try {
156 | server = serverFactory.createServer();
157 | server.start();
158 | sendBroadcast(new Intent(FTPService.ACTION_STARTED));
159 | } catch (Exception e) {
160 | e.printStackTrace();
161 | sendBroadcast(new Intent(FTPService.ACTION_FAILEDTOSTART));
162 | }
163 | }
164 |
165 | @Override
166 | public void onDestroy() {
167 | Log.i(TAG, "onDestroy() Stopping server");
168 | shouldExit = true;
169 | if (serverThread == null) {
170 | Log.w(TAG, "Stopping with null serverThread");
171 | return;
172 | }
173 | serverThread.interrupt();
174 | try {
175 | serverThread.join(10000); // wait 10 sec for server thread to finish
176 | } catch (InterruptedException e) {
177 | }
178 | if (serverThread.isAlive()) {
179 | Log.w(TAG, "Server thread failed to exit");
180 | } else {
181 | Log.d(TAG, "serverThread join()ed ok");
182 | serverThread = null;
183 | }
184 | if (server != null) {
185 | server.stop();
186 | sendBroadcast(new Intent(FTPService.ACTION_STOPPED));
187 | }
188 | Log.d(TAG, "FTPServerService.onDestroy() finished");
189 | }
190 |
191 | //Restart the service if the app is closed from the recent list
192 | @Override
193 | public void onTaskRemoved(Intent rootIntent) {
194 |
195 | super.onTaskRemoved(rootIntent);
196 |
197 | Intent restartService = new Intent(getApplicationContext(), this.getClass());
198 | restartService.setPackage(getPackageName());
199 | PendingIntent restartServicePI = PendingIntent.getService(
200 | getApplicationContext(), 1, restartService, PendingIntent.FLAG_ONE_SHOT);
201 | AlarmManager alarmService = (AlarmManager) getApplicationContext()
202 | .getSystemService(Context.ALARM_SERVICE);
203 | alarmService.set(AlarmManager.ELAPSED_REALTIME,
204 | SystemClock.elapsedRealtime() + 2000, restartServicePI);
205 | }
206 |
207 |
208 | public static boolean isRunning() {
209 | // return true if and only if a server Thread is running
210 | if (serverThread == null) {
211 | Log.d(TAG, "Server is not running (null serverThread)");
212 | return false;
213 | }
214 | if (!serverThread.isAlive()) {
215 | Log.d(TAG, "serverThread non-null but !isAlive()");
216 | } else {
217 | Log.d(TAG, "Server is alive");
218 | }
219 | return true;
220 | }
221 |
222 | public static void sleepIgnoreInterupt(long millis) {
223 | try {
224 | Thread.sleep(millis);
225 | } catch (InterruptedException ignored) {
226 | }
227 | }
228 |
229 |
230 | public static boolean isConnectedToLocalNetwork(Context context) {
231 | boolean connected = false;
232 | ConnectivityManager cm = (ConnectivityManager) context
233 | .getSystemService(Context.CONNECTIVITY_SERVICE);
234 | NetworkInfo ni = cm.getActiveNetworkInfo();
235 | connected = ni != null
236 | && ni.isConnected()
237 | && (ni.getType() & (ConnectivityManager.TYPE_WIFI | ConnectivityManager.TYPE_ETHERNET)) != 0;
238 | if (!connected) {
239 | Log.d(TAG, "isConnectedToLocalNetwork: see if it is an WIFI AP");
240 | WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
241 | try {
242 | Method method = wm.getClass().getDeclaredMethod("isWifiApEnabled");
243 | connected = (Boolean) method.invoke(wm);
244 | } catch (Exception e) {
245 | e.printStackTrace();
246 | }
247 | }
248 | if (!connected) {
249 | Log.d(TAG, "isConnectedToLocalNetwork: see if it is an USB AP");
250 | try {
251 | for (NetworkInterface netInterface : Collections.list(NetworkInterface
252 | .getNetworkInterfaces())) {
253 | if (netInterface.getDisplayName().startsWith("rndis")) {
254 | connected = true;
255 | }
256 | }
257 | } catch (SocketException e) {
258 | e.printStackTrace();
259 | }
260 | }
261 | return connected;
262 | }
263 |
264 |
265 | public static boolean isConnectedToWifi(Context context) {
266 |
267 | ConnectivityManager cm = (ConnectivityManager) context
268 | .getSystemService(Context.CONNECTIVITY_SERVICE);
269 | NetworkInfo ni = cm.getActiveNetworkInfo();
270 | return ni != null && ni.isConnected()
271 | && ni.getType() == ConnectivityManager.TYPE_WIFI;
272 | }
273 |
274 | public static InetAddress getLocalInetAddress(Context context) {
275 | if (!isConnectedToLocalNetwork(context)) {
276 | Log.e(TAG, "getLocalInetAddress called and no connection");
277 | return null;
278 | }
279 |
280 | if (isConnectedToWifi(context)) {
281 |
282 | WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
283 | int ipAddress = wm.getConnectionInfo().getIpAddress();
284 | if (ipAddress == 0)
285 | return null;
286 | return intToInet(ipAddress);
287 | }
288 |
289 | try {
290 | Enumeration netinterfaces = NetworkInterface
291 | .getNetworkInterfaces();
292 | while (netinterfaces.hasMoreElements()) {
293 | NetworkInterface netinterface = netinterfaces.nextElement();
294 | Enumeration adresses = netinterface.getInetAddresses();
295 | while (adresses.hasMoreElements()) {
296 | InetAddress address = adresses.nextElement();
297 | // this is the condition that sometimes gives problems
298 | if (!address.isLoopbackAddress()
299 | && !address.isLinkLocalAddress())
300 | return address;
301 | }
302 | }
303 | } catch (Exception e) {
304 | e.printStackTrace();
305 | }
306 | return null;
307 | }
308 |
309 | public static InetAddress intToInet(int value) {
310 | byte[] bytes = new byte[4];
311 | for (int i = 0; i < 4; i++) {
312 | bytes[i] = byteOfInt(value, i);
313 | }
314 | try {
315 | return InetAddress.getByAddress(bytes);
316 | } catch (UnknownHostException e) {
317 | // This only happens if the byte array has a bad length
318 | return null;
319 | }
320 | }
321 |
322 | public static byte byteOfInt(int value, int which) {
323 | int shift = which * 8;
324 | return (byte) (value >> shift);
325 | }
326 |
327 | public static int getPort() {
328 | return port;
329 | }
330 |
331 | public static boolean isPortAvailable(int port) {
332 |
333 | ServerSocket ss = null;
334 | DatagramSocket ds = null;
335 | try {
336 | ss = new ServerSocket(port);
337 | ss.setReuseAddress(true);
338 | ds = new DatagramSocket(port);
339 | ds.setReuseAddress(true);
340 | return true;
341 | } catch (IOException e) {
342 | } finally {
343 | if (ds != null) {
344 | ds.close();
345 | }
346 |
347 | if (ss != null) {
348 | try {
349 | ss.close();
350 | } catch (IOException e) {
351 | /* should not be thrown */
352 | }
353 | }
354 | }
355 |
356 | return false;
357 | }
358 | }
359 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/SettingFramgent.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.Manifest;
4 | import android.app.Fragment;
5 | import android.app.admin.DevicePolicyManager;
6 | import android.content.BroadcastReceiver;
7 | import android.content.ComponentName;
8 | import android.content.Context;
9 | import android.content.Intent;
10 | import android.content.IntentFilter;
11 | import android.net.ConnectivityManager;
12 | import android.net.NetworkInfo;
13 | import android.os.Build;
14 | import android.os.Bundle;
15 | import android.view.LayoutInflater;
16 | import android.view.MotionEvent;
17 | import android.view.View;
18 | import android.view.ViewGroup;
19 | import android.widget.AdapterView;
20 | import android.widget.SeekBar;
21 | import android.widget.Spinner;
22 | import android.widget.TextView;
23 | import android.widget.Toast;
24 |
25 | import androidx.annotation.NonNull;
26 |
27 | import java.util.Observable;
28 |
29 | import cn.modificator.launcher.ftpservice.FTPService;
30 | import cn.modificator.launcher.model.AdminReceiver;
31 | import cn.modificator.launcher.model.WifiControl;
32 |
33 | /**
34 | * Created by mod on 16-5-3.
35 | */
36 | public class SettingFramgent extends Fragment implements View.OnClickListener {
37 | Spinner col_num_spinner;
38 | Spinner row_num_spinner;
39 | Spinner appNameLinesSpinner;
40 | SeekBar font_control;
41 | View rootView;
42 | TextView hideDivider, ftpAddr, ftpStatus,showStatusBar,showCustomIcon;
43 |
44 | @Override
45 | public void onCreate(Bundle savedInstanceState) {
46 | super.onCreate(savedInstanceState);
47 | }
48 |
49 | @Override
50 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
51 | return inflater.inflate(R.layout.activity_setting, null);
52 | }
53 |
54 | @Override
55 | public void onActivityCreated(Bundle savedInstanceState) {
56 | super.onActivityCreated(savedInstanceState);
57 | rootView = getView();
58 | rootView.findViewById(R.id.toBack).setOnClickListener(this);
59 | rootView.findViewById(R.id.rootView).setOnClickListener(this);
60 | rootView.findViewById(R.id.deleteApp).setOnClickListener(this);
61 | rootView.findViewById(R.id.showWifiName).setOnClickListener(this);
62 | showStatusBar = rootView.findViewById(R.id.showStatusBar);
63 | showCustomIcon = rootView.findViewById(R.id.showCustomIcon);
64 | ftpStatus = rootView.findViewById(R.id.ftp_status);
65 | ftpAddr = rootView.findViewById(R.id.ftp_addr);
66 | hideDivider = rootView.findViewById(R.id.hideDivider);
67 | font_control = rootView.findViewById(R.id.font_control);
68 | col_num_spinner = rootView.findViewById(R.id.col_num_spinner);
69 | row_num_spinner = rootView.findViewById(R.id.row_num_spinner);
70 | appNameLinesSpinner = rootView.findViewById(R.id.appNameLine);
71 |
72 | showStatusBar.setOnClickListener(this);
73 | hideDivider.setOnClickListener(this);
74 | showCustomIcon.setOnClickListener(this);
75 | rootView.findViewById(R.id.openDeviceManager).setOnClickListener(this);
76 | showStatusBar.getPaint().setStrikeThruText(Config.showStatusBar);
77 | hideDivider.getPaint().setStrikeThruText(Config.hideDivider);
78 | row_num_spinner.setSelection(Config.rowNum - 2, false);
79 | font_control.setProgress((int) ((Config.fontSize - 10) * 10));
80 | showCustomIcon.getPaint().setStrikeThruText(Config.showCustomIcon);
81 |
82 | row_num_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
83 | @Override
84 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
85 | Intent intent = new Intent();
86 | intent.putExtra(Launcher.ROW_NUM_KEY, position + 2);
87 | intent.setAction(Launcher.LAUNCHER_ACTION);
88 | getActivity().sendBroadcast(intent);
89 | }
90 |
91 | @Override
92 | public void onNothingSelected(AdapterView> parent) {
93 |
94 | }
95 | });
96 | col_num_spinner.setSelection(Config.colNum - 2, false);
97 | col_num_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
98 | @Override
99 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
100 | Intent intent = new Intent();
101 | intent.putExtra(Launcher.COL_NUM_KEY, position + 2);
102 | intent.setAction(Launcher.LAUNCHER_ACTION);
103 | getActivity().sendBroadcast(intent);
104 | }
105 |
106 | @Override
107 | public void onNothingSelected(AdapterView> parent) {
108 |
109 | }
110 | });
111 | appNameLinesSpinner.setSelection(getAppLineSpinnerSelectPosition(),false);
112 | appNameLinesSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
113 | @Override
114 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
115 | Intent intent = new Intent();
116 | intent.putExtra(Launcher.APP_NAME_SHOW_LINES, position);
117 | intent.setAction(Launcher.LAUNCHER_ACTION);
118 | getActivity().sendBroadcast(intent);
119 | }
120 |
121 | @Override
122 | public void onNothingSelected(AdapterView> parent) {
123 |
124 | }
125 | });
126 | rootView.findViewById(R.id.btnHideFontControl).setOnClickListener(this);
127 | rootView.findViewById(R.id.changeFontSize).setOnClickListener(this);
128 | rootView.findViewById(R.id.helpAbout).setOnClickListener(this);
129 | rootView.findViewById(R.id.menu_ftp).setOnClickListener(this);
130 |
131 | font_control.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
132 | @Override
133 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
134 | if (fromUser) {
135 | Intent intent = new Intent();
136 | Config.fontSize = 10 + progress / 10f;
137 | intent.putExtra(Launcher.LAUNCHER_FONT_SIZE, 10 + progress / 10f);
138 | intent.setAction(Launcher.LAUNCHER_ACTION);
139 | getActivity().sendBroadcast(intent);
140 | }
141 | }
142 |
143 | @Override
144 | public void onStartTrackingTouch(SeekBar seekBar) {
145 | }
146 |
147 | @Override
148 | public void onStopTrackingTouch(SeekBar seekBar) {
149 | }
150 | });
151 |
152 | updateStatus();
153 | }
154 |
155 | private int getAppLineSpinnerSelectPosition(){
156 | if (Config.appNameLines<3)return Config.appNameLines;
157 | return 3;
158 | }
159 |
160 | @Override
161 | public void onClick(View v) {
162 | switch (v.getId()) {
163 | case R.id.toBack:
164 | case R.id.rootView:
165 | getActivity().onBackPressed();
166 | break;
167 | case R.id.deleteApp:
168 | Intent intent = new Intent();
169 | intent.putExtra(Launcher.DELETEAPP, true);
170 | intent.setAction(Launcher.LAUNCHER_ACTION);
171 | getActivity().sendBroadcast(intent);
172 | getActivity().onBackPressed();
173 | break;
174 | case R.id.showStatusBar:
175 | Config.showStatusBar = !Config.showStatusBar;
176 |
177 | intent = new Intent(Launcher.LAUNCHER_ACTION);
178 | intent.putExtra(Launcher.LAUNCHER_SHOW_STATUS_BAR,Config.showStatusBar);
179 | getActivity().sendBroadcast(intent);
180 | getActivity().onBackPressed();
181 | break;
182 | case R.id.helpAbout:
183 | AboutDialog.getInstance(getActivity()).show();
184 | break;
185 | case R.id.btnHideFontControl:
186 | rootView.findViewById(R.id.menuList).setVisibility(View.VISIBLE);
187 | rootView.findViewById(R.id.font_control_p).setVisibility(View.GONE);
188 | break;
189 | case R.id.changeFontSize:
190 | rootView.findViewById(R.id.menuList).setVisibility(View.GONE);
191 | rootView.findViewById(R.id.font_control_p).setVisibility(View.VISIBLE);
192 | break;
193 | case R.id.hideDivider:
194 | Config.hideDivider = !Config.hideDivider;
195 | hideDivider.setText(Config.hideDivider ? "显示分隔线" : "隐藏分隔线");
196 |
197 | intent = new Intent();
198 | intent.putExtra(Launcher.LAUNCHER_HIDE_DIVIDER, Config.hideDivider);
199 | intent.setAction(Launcher.LAUNCHER_ACTION);
200 | getActivity().sendBroadcast(intent);
201 | getActivity().onBackPressed();
202 | break;
203 | case R.id.menu_ftp:
204 | Utils.checkStroagePermission(getActivity(), new Runnable() {
205 | @Override
206 | public void run() {
207 | if (!FTPService.isRunning()) {
208 | if (FTPService.isConnectedToWifi(getActivity()))
209 | startServer();
210 | else
211 | Toast.makeText(getActivity(), "大哥诶,麻烦先把WIFI连上吧", Toast.LENGTH_SHORT).show();
212 | } else {
213 | stopServer();
214 | }
215 | }
216 | });
217 | break;
218 | case R.id.showWifiName:
219 | if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.O){
220 | requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION},10002);
221 | }
222 | break;
223 | case R.id.showCustomIcon:
224 | Utils.checkStroagePermission(getActivity(), new Runnable() {
225 | @Override
226 | public void run() {
227 | Config.showCustomIcon = !Config.showCustomIcon;
228 | Intent intent = new Intent(Launcher.LAUNCHER_ACTION);
229 | intent.putExtra(Launcher.LAUNCHER_SHOW_CUSTOM_ICON,Config.showCustomIcon);
230 | getActivity().sendBroadcast(intent);
231 | getActivity().onBackPressed();
232 | }
233 | });
234 | break;
235 | case R.id.openDeviceManager:
236 | startActivity(new Intent().setComponent(new ComponentName("com.android.settings", "com.android.settings.DeviceAdminSettings")));
237 | break;
238 | }
239 | }
240 |
241 | @Override
242 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
243 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
244 | if (requestCode==10002){
245 | WifiControl.reloadWifiName();
246 | getActivity().onBackPressed();
247 | }
248 | }
249 |
250 | @Override
251 | public void onResume() {
252 | super.onResume();
253 | updateStatus();
254 | IntentFilter wifiFilter = new IntentFilter();
255 | wifiFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
256 | getActivity().registerReceiver(mWifiReceiver, wifiFilter);
257 | IntentFilter ftpFilter = new IntentFilter();
258 | ftpFilter.addAction(FTPService.ACTION_STARTED);
259 | ftpFilter.addAction(FTPService.ACTION_STOPPED);
260 | ftpFilter.addAction(FTPService.ACTION_FAILEDTOSTART);
261 | getActivity().registerReceiver(ftpReceiver, ftpFilter);
262 | }
263 |
264 | @Override
265 | public void onPause() {
266 | super.onPause();
267 | getActivity().unregisterReceiver(mWifiReceiver);
268 | getActivity().unregisterReceiver(ftpReceiver);
269 | }
270 |
271 |
272 | /**
273 | * Sends a broadcast to start ftp server
274 | */
275 | private void startServer() {
276 | getActivity().sendBroadcast(new Intent(FTPService.ACTION_START_FTPSERVER));
277 | }
278 |
279 | /**
280 | * Sends a broadcast to stop ftp server
281 | */
282 | private void stopServer() {
283 | getActivity().sendBroadcast(new Intent(FTPService.ACTION_STOP_FTPSERVER));
284 | }
285 |
286 | /**
287 | * Update UI widgets based on connection status
288 | */
289 | private void updateStatus() {
290 | if (FTPService.isConnectedToWifi(getActivity())) {
291 | if (FTPService.isRunning()) {
292 | // ftpAddr.setText("网络传书 (开)");
293 | ftpStatus.setText(R.string.setting_cloud_manager_on);
294 | ftpAddr.setVisibility(View.VISIBLE);
295 | ftpAddr.setText(getFTPAddressString());
296 | } else {
297 | // ftpAddr.setText("网络传书 (关)");
298 | ftpStatus.setText(R.string.setting_cloud_manager_off);
299 | ftpAddr.setVisibility(View.GONE);
300 | }
301 | } else {
302 | // ftpAddr.setText("网络传书 (请连接WIFI)");
303 | ftpStatus.setText(R.string.setting_cloud_manager_wifi_off);
304 | ftpAddr.setVisibility(View.GONE);
305 | }
306 | }
307 |
308 | /**
309 | * @return address at which server is running
310 | */
311 | private String getFTPAddressString() {
312 | return "ftp://" + FTPService.getLocalInetAddress(getActivity()).getHostAddress() + ":" + FTPService.getPort();
313 | }
314 |
315 |
316 | private BroadcastReceiver mWifiReceiver = new BroadcastReceiver() {
317 |
318 | @Override
319 | public void onReceive(Context context, Intent intent) {
320 | ConnectivityManager conMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
321 | NetworkInfo netInfo = conMan.getActiveNetworkInfo();
322 | if (netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI) {
323 |
324 | } else {
325 | stopServer();
326 | }
327 | updateStatus();
328 | }
329 | };
330 | private BroadcastReceiver ftpReceiver = new BroadcastReceiver() {
331 | @Override
332 | public void onReceive(Context context, Intent intent) {
333 | String action = intent.getAction();
334 | updateStatus();
335 | if (action == FTPService.ACTION_STARTED) {
336 | // statusText.setText(getResources().getString(R.string.ftp_status_running));
337 | // warningText.setText("");
338 | // ftpAddrText.setText(getFTPAddressString());
339 | // ftpBtn.setText(getResources().getString(R.string.stop_ftp));
340 | } else if (action == FTPService.ACTION_FAILEDTOSTART) {
341 | // statusText.setText(getResources().getString(R.string.ftp_status_not_running));
342 | // warningText.setText("Oops! Something went wrong");
343 | // ftpAddrText.setText("");
344 | // ftpBtn.setText(getResources().getString(R.string.start_ftp));
345 | } else if (action == FTPService.ACTION_STOPPED) {
346 | // statusText.setText(getResources().getString(R.string.ftp_status_not_running));
347 | // ftpAddrText.setText("");
348 | // ftpBtn.setText(getResources().getString(R.string.start_ftp));
349 | }
350 | }
351 | };
352 | }
353 |
--------------------------------------------------------------------------------
/app/src/main/java/cn/modificator/launcher/Launcher.java:
--------------------------------------------------------------------------------
1 | package cn.modificator.launcher;
2 |
3 | import android.app.Activity;
4 | import android.app.AlertDialog;
5 | import android.app.admin.DevicePolicyManager;
6 | import android.content.BroadcastReceiver;
7 | import android.content.ComponentName;
8 | import android.content.Context;
9 | import android.content.DialogInterface;
10 | import android.content.Intent;
11 | import android.content.IntentFilter;
12 | import android.content.pm.ApplicationInfo;
13 | import android.content.pm.PackageInfo;
14 | import android.content.pm.PackageManager;
15 | import android.content.res.ColorStateList;
16 | import android.os.BatteryManager;
17 | import android.os.Build;
18 | import android.os.Bundle;
19 | import android.text.TextUtils;
20 | import android.text.format.DateFormat;
21 | import android.view.KeyEvent;
22 | import android.view.View;
23 | import android.view.WindowManager;
24 | import android.widget.ImageView;
25 | import android.widget.TextView;
26 |
27 | import java.io.File;
28 | import java.text.SimpleDateFormat;
29 | import java.util.Calendar;
30 | import java.util.Locale;
31 |
32 | import cn.modificator.launcher.ftpservice.FTPReceiver;
33 | import cn.modificator.launcher.ftpservice.FTPService;
34 | import cn.modificator.launcher.model.AdminReceiver;
35 | import cn.modificator.launcher.model.AppDataCenter;
36 | import cn.modificator.launcher.model.HomeEntranceService;
37 | import cn.modificator.launcher.model.WifiControl;
38 | import cn.modificator.launcher.widgets.BatteryView;
39 | import cn.modificator.launcher.widgets.EInkLauncherView;
40 |
41 | /**
42 | * Created by mod on 16-4-22.
43 | */
44 | public class Launcher extends Activity {
45 |
46 | public static final String ROW_NUM_KEY = "rowNumKey";
47 | public static final String COL_NUM_KEY = "colNumKey";
48 | public static final String APP_NAME_SHOW_LINES = "appNameShowLines";
49 | public static final String HIDE_APPS_KEY = "hideAppsKey";
50 | public static final String DELETEAPP = "deleteApp";
51 | public static final String LAUNCHER_SHOW_STATUS_BAR = "launcherShowStatusBar";
52 | public static final String LAUNCHER_SHOW_CUSTOM_ICON= "launcherShowCustomIcon";
53 | public static final String LAUNCHER_ACTION = "launcherReceiver";
54 | public static final String LAUNCHER_FONT_SIZE = "launcherFontSize";
55 | public static final String LAUNCHER_HIDE_DIVIDER = "launcherHideDivider";
56 |
57 | EInkLauncherView launcherView;
58 | AppDataCenter dataCenter = null;
59 | Config config;
60 | LauncherUpdateReceiver updateReceiver;
61 | TextView pageStatus;
62 | BatteryView batteryProgress;
63 | TextView batteryStatus, textClock;
64 |
65 | BroadcastReceiver timeListener;
66 | Calendar mCalendar;
67 |
68 | DevicePolicyManager policyManager;
69 | File iconFile;
70 | boolean isChina = true;
71 | FTPReceiver ftpReceiver = new FTPReceiver();
72 |
73 | @Override
74 | protected void onCreate(Bundle savedInstanceState) {
75 | super.onCreate(savedInstanceState);
76 | setContentView(R.layout.launcher_activity);
77 | config = new Config(this);
78 | WifiControl.init(this);
79 | toggleStatusBar();
80 | if (getExternalCacheDir() != null) {
81 | iconFile = new File(getExternalCacheDir().getParentFile().getParentFile().getParentFile().getParentFile(), "E-Ink Launcher" + File.separator + "icon");
82 | if (!iconFile.exists()) {
83 | iconFile.mkdir();
84 | }
85 | }
86 |
87 | isChina = getResources().getConfiguration().locale.getCountry().equals("CN");
88 |
89 | initView();
90 | checkLaunchHomeNotification();
91 | }
92 |
93 |
94 | private void initView() {
95 | policyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
96 | launcherView = findViewById(R.id.mList);
97 | pageStatus = findViewById(R.id.pageStatus);
98 | batteryProgress = findViewById(R.id.batteryProgress);
99 | batteryStatus = findViewById(R.id.batteryStatus);
100 | textClock = findViewById(R.id.textClock);
101 | (this.findViewById(R.id.toSetting)).setImageDrawable(Utils.tintDrawable(getResources().getDrawable(R.drawable.navibar_icon_settings_highlight), ColorStateList.valueOf(0xff000000)));
102 |
103 | // launcherView.setIconReplaceFile(Arrays.asList(iconFile.list()));
104 | launcherView.setHideAppPkg(config.getHideApps());
105 | launcherView.setHideDivider(config.getDividerHideStatus());
106 | launcherView.setFontSize(config.getFontSize());
107 |
108 | dataCenter = new AppDataCenter(this);
109 | dataCenter.setHideApps(config.getHideApps());
110 |
111 | dataCenter.setPageStatus(pageStatus);
112 | dataCenter.setLauncherView(launcherView);
113 | //加载之前保存的桌面数据
114 | updateColNum(config.getColNum());
115 | updateRowNum(config.getRowNum());
116 |
117 | findViewById(R.id.lastPage).setOnClickListener(new View.OnClickListener() {
118 | @Override
119 | public void onClick(View v) {
120 | dataCenter.showLastPage();
121 | }
122 | });
123 | findViewById(R.id.nextPage).setOnClickListener(new View.OnClickListener() {
124 | @Override
125 | public void onClick(View v) {
126 | dataCenter.showNextPage();
127 | }
128 | });
129 | findViewById(R.id.toSetting).setOnClickListener(new View.OnClickListener() {
130 | @Override
131 | public void onClick(View v) {
132 | getFragmentManager().beginTransaction()
133 | .replace(android.R.id.content, new SettingFramgent())
134 | .addToBackStack(null)
135 | .commit();
136 | }
137 | });
138 | findViewById(R.id.deleteFinish).setOnClickListener(new View.OnClickListener() {
139 | @Override
140 | public void onClick(View v) {
141 | launcherView.setDelete(false);
142 | dataCenter.refreshAppList();
143 | config.setHideApps(dataCenter.getHideApps());
144 | v.setVisibility(View.GONE);
145 | }
146 | });
147 | launcherView.setTouchListener(new EInkLauncherView.TouchListener() {
148 | @Override
149 | public void toNext() {
150 | dataCenter.showNextPage();
151 | }
152 |
153 | @Override
154 | public void toLast() {
155 | dataCenter.showLastPage();
156 | }
157 | });
158 | // android:format12Hour="yyyy-MM-dd aahh:mm EEEE"
159 | // android:format24Hour="yyyy-MM-dd aahh:mm EEEE"
160 |
161 | mCalendar = Calendar.getInstance();
162 |
163 | updateTimeShow();
164 |
165 | updateReceiver = new LauncherUpdateReceiver();
166 | IntentFilter filter = new IntentFilter();
167 | filter.addAction(LAUNCHER_ACTION);
168 | registerReceiver(updateReceiver, filter);
169 |
170 |
171 | IntentFilter appChangeFilter = new IntentFilter();
172 | appChangeFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
173 | appChangeFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
174 | appChangeFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
175 | appChangeFilter.addDataScheme("package");
176 | registerReceiver(appChangeReceiver, appChangeFilter);
177 |
178 | try {
179 | launcherView.setSystemApp(!isUserApp(getPackageManager().getPackageInfo(getPackageName(), 0)));
180 | } catch (PackageManager.NameNotFoundException e) {
181 | e.printStackTrace();
182 | }
183 | }
184 |
185 | private void updateRowNum(int rowNum) {
186 | launcherView.setRowNum(rowNum);
187 | dataCenter.setRowNum(rowNum);
188 | config.setRowNum(rowNum);
189 | }
190 |
191 | private void updateColNum(int colNum) {
192 | launcherView.setColNum(colNum);
193 | dataCenter.setColNum(colNum);
194 | config.setColNum(colNum);
195 | }
196 |
197 | @Override
198 | public boolean onKeyUp(int keyCode, KeyEvent event) {
199 | if (keyCode == KeyEvent.KEYCODE_PAGE_UP) {
200 | dataCenter.showLastPage();
201 | } else if (keyCode == KeyEvent.KEYCODE_PAGE_DOWN) {
202 | dataCenter.showNextPage();
203 | } else if (keyCode == KeyEvent.KEYCODE_BACK) {
204 | return true;
205 | }
206 | return super.onKeyUp(keyCode, event);
207 | }
208 |
209 | @Override
210 | protected void onResume() {
211 | super.onResume();
212 | IntentFilter batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
213 | registerReceiver(batteryLevelRcvr, batteryLevelFilter);
214 | timeListener = new BroadcastReceiver() {
215 | @Override
216 | public void onReceive(Context context, Intent intent) {
217 | updateTimeShow();
218 | }
219 | };
220 | updateTimeShow();
221 |
222 | registerReceiver(timeListener, new IntentFilter(Intent.ACTION_TIME_TICK));
223 | if (launcherView != null) launcherView.refreshReplaceIcon();
224 | detectionUSB();
225 |
226 | IntentFilter ftpIntentFilter = new IntentFilter(FTPService.ACTION_START_FTPSERVER);
227 | ftpIntentFilter.addAction(FTPService.ACTION_STOP_FTPSERVER);
228 | registerReceiver(ftpReceiver,ftpIntentFilter);
229 | }
230 |
231 | /**
232 | * 刷新时间显示
233 | */
234 | private void updateTimeShow() {
235 | if (textClock != null && mCalendar != null) {
236 | boolean is24Hour = DateFormat.is24HourFormat(this);
237 | mCalendar.setTimeInMillis(System.currentTimeMillis());
238 |
239 | StringBuilder timeFormatTextBuilder = new StringBuilder("yyyy-MM-dd ");
240 | if (!is24Hour && isChina) {
241 | timeFormatTextBuilder.append(Utils.getAMPMCNString(mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.AM_PM)));
242 | }
243 | if (is24Hour) {
244 | timeFormatTextBuilder.append("HH:mm");
245 | } else {
246 | timeFormatTextBuilder.append("hh:mm");
247 | }
248 | if (!is24Hour && !isChina) {
249 | timeFormatTextBuilder.append(" a");
250 | }
251 | timeFormatTextBuilder.append(" EEEE");
252 | textClock.setText(new SimpleDateFormat(timeFormatTextBuilder.toString(), Locale.getDefault()).format(mCalendar.getTime()));
253 | }
254 | }
255 |
256 | @Override
257 | protected void onPause() {
258 | super.onPause();
259 | unregisterReceiver(batteryLevelRcvr);
260 | unregisterReceiver(timeListener);
261 | unregisterReceiver(usbReceiver);
262 | unregisterReceiver(ftpReceiver);
263 | }
264 |
265 | @Override
266 | protected void onDestroy() {
267 | super.onDestroy();
268 | unregisterReceiver(updateReceiver);
269 | unregisterReceiver(appChangeReceiver);
270 | try {
271 | unregisterReceiver(usbReceiver);
272 | } catch (Throwable throwable) {
273 | throwable.printStackTrace();
274 | }
275 | }
276 |
277 |
278 | class LauncherUpdateReceiver extends BroadcastReceiver {
279 |
280 | @Override
281 | public void onReceive(Context context, Intent intent) {
282 | Bundle bundle = intent.getExtras();
283 | if (bundle.containsKey(ROW_NUM_KEY)) {
284 | updateRowNum(bundle.getInt(ROW_NUM_KEY));
285 | } else if (bundle.containsKey(COL_NUM_KEY)) {
286 | updateColNum(bundle.getInt(COL_NUM_KEY));
287 | } else if (bundle.containsKey(DELETEAPP)) {
288 | launcherView.setDelete(true);
289 |
290 | //显示所有App
291 | dataCenter.refreshAppList(true);
292 | findViewById(R.id.deleteFinish).setVisibility(View.VISIBLE);
293 | } else if (bundle.containsKey(LAUNCHER_FONT_SIZE)) {
294 | launcherView.setFontSize(bundle.getFloat(LAUNCHER_FONT_SIZE));
295 | } else if (bundle.containsKey(LAUNCHER_HIDE_DIVIDER)) {
296 | launcherView.setHideDivider(bundle.getBoolean(LAUNCHER_HIDE_DIVIDER));
297 | config.setDividerHideStatus(bundle.getBoolean(LAUNCHER_HIDE_DIVIDER));
298 | }else if (bundle.containsKey(LAUNCHER_SHOW_STATUS_BAR)){
299 | config.setStatusBarShowStatus(bundle.getBoolean(LAUNCHER_SHOW_STATUS_BAR));
300 | toggleStatusBar();
301 | }else if (bundle.containsKey(LAUNCHER_SHOW_CUSTOM_ICON)){
302 | config.setCustomIconShowStatus(bundle.getBoolean(LAUNCHER_SHOW_CUSTOM_ICON));
303 | launcherView.refreshReplaceIcon();
304 | }else if (bundle.containsKey(APP_NAME_SHOW_LINES)){
305 | int lines = bundle.getInt(APP_NAME_SHOW_LINES);
306 | if (lines==3)lines=Integer.MAX_VALUE;
307 | config.setAppNameLines(lines);
308 | launcherView.updateAppNameLines();
309 | }
310 | }
311 | }
312 |
313 | BroadcastReceiver appChangeReceiver = new BroadcastReceiver() {
314 | @Override
315 | public void onReceive(Context context, Intent intent) {
316 | dataCenter.refreshAppList(launcherView.isDelete());
317 | }
318 | };
319 | BroadcastReceiver batteryLevelRcvr = new BroadcastReceiver() {
320 | @Override
321 | public void onReceive(Context context, Intent intent) {
322 | int rawlevel = intent.getIntExtra("level", -1);
323 | int scale = intent.getIntExtra("scale", -1);
324 | int status = intent.getIntExtra("status", -1);
325 | int health = intent.getIntExtra("health", -1);
326 | int level = -1; // percentage, or -1 for unknown
327 | if (rawlevel >= 0 && scale > 0) {
328 | level = (rawlevel * 100) / scale;
329 | }
330 | batteryProgress.setProgress(level);
331 |
332 | batteryStatus.setVisibility(View.VISIBLE);
333 | if (BatteryManager.BATTERY_HEALTH_OVERHEAT == health) {
334 | batteryStatus.setText(R.string.battery_heat);
335 | } else {
336 | switch (status) {
337 | case BatteryManager.BATTERY_STATUS_UNKNOWN:
338 | batteryStatus.setText(R.string.battery_unknown);
339 | break;
340 | case BatteryManager.BATTERY_STATUS_CHARGING:
341 | batteryStatus.setText(R.string.battery_charging);
342 | /*if (level <= 33)
343 | sb.append(" is charging, battery level is low"
344 | + "[" + level + "]");
345 | else if (level <= 84)
346 | sb.append(" is charging." + "[" + level + "]");
347 | else
348 | sb.append(" will be fully charged.");*/
349 | break;
350 | case BatteryManager.BATTERY_STATUS_DISCHARGING:
351 | case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
352 | /*if (level == 0)
353 | sb.append(" needs charging right away.");
354 | else if (level > 0 && level <= 33)
355 | sb.append(" is about ready to be recharged, battery level is low"
356 | + "[" + level + "]");
357 | else
358 | sb.append("'s battery level is" + "[" + level + "]");*/
359 | if (level < 15) {
360 | batteryStatus.setText(R.string.battery_low);
361 | } else {
362 | batteryStatus.setVisibility(View.GONE);
363 | }
364 | break;
365 | case BatteryManager.BATTERY_STATUS_FULL:
366 | // sb.append(" is fully charged.");
367 | batteryStatus.setText(R.string.battery_full);
368 | break;
369 | default:
370 | // sb.append("'s battery is indescribable!");
371 | batteryStatus.setText(R.string.battery_wtf);
372 | break;
373 | }
374 | }
375 |
376 | }
377 | };
378 |
379 | private void detectionUSB() {
380 | IntentFilter usbFilter = new IntentFilter();
381 | usbFilter.addAction(Intent.ACTION_UMS_DISCONNECTED);
382 | usbFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
383 | usbFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
384 | usbFilter.addAction(Intent.ACTION_MEDIA_REMOVED);
385 | usbFilter.addDataScheme("file");
386 | registerReceiver(usbReceiver, usbFilter);
387 | }
388 |
389 | private BroadcastReceiver usbReceiver = new BroadcastReceiver() {
390 | @Override
391 | public void onReceive(Context context, Intent intent) {
392 | String action = intent.getAction();
393 | if (action.equals(Intent.ACTION_MEDIA_REMOVED)
394 | || action.equals(Intent.ACTION_MEDIA_UNMOUNTED)) {
395 | //设备卸载成功;
396 | } else if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
397 | //设备挂载成功
398 | launcherView.refreshReplaceIcon();
399 | }
400 | }
401 | };
402 |
403 | @Override
404 | public void onBackPressed() {
405 | if (getFragmentManager().getBackStackEntryCount() > 0) {
406 | super.onBackPressed();
407 | config.saveFontSize();
408 | }
409 | }
410 |
411 | @Override
412 | public boolean onKeyDown(int keyCode, KeyEvent event) {
413 | if (keyCode == KeyEvent.KEYCODE_BACK && getFragmentManager().getBackStackEntryCount() == 0) {
414 | return true;
415 | }
416 | return super.onKeyDown(keyCode, event);
417 | }
418 |
419 | public void lockScreen() {
420 | try {
421 | if (policyManager.isAdminActive(new ComponentName(this, AdminReceiver.class))) {
422 | policyManager.lockNow();
423 | } else {
424 | activeManage();
425 | }
426 | }catch (Exception e){
427 | openDevicePolicyManager();
428 | }
429 | }
430 |
431 | private void openDevicePolicyManager() {
432 | new AlertDialog.Builder(this)
433 | .setTitle(R.string.launch_failed)
434 | .setMessage(R.string.launch_devicemanager_failed)
435 | .setPositiveButton(R.string.launch_devicemanager, new DialogInterface.OnClickListener() {
436 | @Override
437 | public void onClick(DialogInterface dialog, int which) {
438 | try {
439 | Intent intent = Intent.parseUri("intent:#Intent;component=com.android.settings/.DeviceAdminSettings;end", Intent.URI_INTENT_SCHEME);
440 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
441 | startActivity(intent);
442 | } catch (Exception e) {
443 | e.printStackTrace();
444 | }
445 | }
446 | })
447 | .setNegativeButton(R.string.dialog_cancel, null).show();
448 | }
449 |
450 | private void activeManage() {
451 | Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
452 | intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, new ComponentName(this, AdminReceiver.class));
453 | intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "E-Ink Launcher 获取锁屏权限");
454 | startActivity(intent);
455 | // startActivityForResult(intent, 10001);
456 | }
457 |
458 | @Override
459 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
460 | super.onActivityResult(requestCode, resultCode, data);
461 | if (resultCode == RESULT_OK) {
462 | switch (requestCode) {
463 | case 10001:
464 | policyManager.lockNow();
465 | break;
466 | }
467 | }
468 | }
469 |
470 | public boolean isSystemApp(PackageInfo pInfo) {
471 | return ((pInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
472 | }
473 |
474 | public boolean isSystemUpdateApp(PackageInfo pInfo) {
475 | return ((pInfo.applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0);
476 | }
477 |
478 | public boolean isUserApp(PackageInfo pInfo) {
479 | return (!isSystemApp(pInfo) && !isSystemUpdateApp(pInfo));
480 | }
481 |
482 | public void toggleStatusBar(){
483 | int windowFlags= WindowManager.LayoutParams.FLAG_FULLSCREEN;
484 | if (Config.showStatusBar){
485 | getWindow().setFlags(windowFlags,windowFlags);
486 | }else{
487 | getWindow().clearFlags(windowFlags);
488 | }
489 | }
490 |
491 | private void checkLaunchHomeNotification(){
492 | if (!TextUtils.equals(Build.DEVICE,"virgo-perf1")){
493 | return;
494 | }
495 | Intent service = new Intent(this, HomeEntranceService.class);
496 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
497 | startForegroundService(service);
498 | }else{
499 | startService(service);
500 | }
501 | }
502 | }
503 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
221 |
222 |
231 |
232 |
239 |
240 |
250 |
251 |
263 |
264 |
265 |
276 |
277 |
278 |
284 |
285 |
290 |
291 |
298 |
299 |
304 |
305 |
312 |
313 |
314 |
319 |
320 |
325 |
326 |
330 |
331 |
337 |
338 |
345 |
346 |
347 |
351 |
352 |
353 |
354 |
359 |
360 |
365 |
366 |
370 |
371 |
377 |
378 |
385 |
386 |
390 |
391 |
392 |
397 |
398 |
403 |
404 |
408 |
409 |
415 |
416 |
423 |
424 |
428 |
429 |
430 |
435 |
436 |
444 |
445 |
446 |
450 |
451 |
459 |
460 |
464 |
465 |
473 |
474 |
478 |
479 |
487 |
488 |
492 |
493 |
498 |
499 |
506 |
507 |
508 |
509 |
510 |
514 |
515 |
524 |
525 |
529 |
530 |
538 |
539 |
543 |
544 |
549 |
550 |
557 |
558 |
559 |
560 |
561 |
562 |
566 |
567 |
573 |
574 |
575 |
586 |
587 |
594 |
595 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
--------------------------------------------------------------------------------