├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ ├── License.txt
│ └── xposed_init
│ ├── java
│ ├── com
│ │ └── android
│ │ │ └── wallpaper
│ │ │ ├── asset
│ │ │ ├── Asset.java
│ │ │ ├── BitmapUtils.java
│ │ │ ├── BuiltInWallpaperAsset.java
│ │ │ ├── ContentUriAsset.java
│ │ │ ├── CropRectRotator.java
│ │ │ ├── CurrentWallpaperAssetVN.kt
│ │ │ ├── CurrentWallpaperAssetVNLoader.java
│ │ │ ├── FileAsset.java
│ │ │ ├── LiveWallpaperThumbAsset.java
│ │ │ ├── LiveWallpaperThumbAssetLoader.java
│ │ │ ├── StreamableAsset.java
│ │ │ └── WallpaperGlideModule.java
│ │ │ ├── model
│ │ │ ├── ImageWallpaperInfo.java
│ │ │ ├── LiveWallpaperInfo.java
│ │ │ └── WallpaperInfo.java
│ │ │ ├── module
│ │ │ ├── BitmapCropper.java
│ │ │ ├── WallpaperPersister.java
│ │ │ └── WallpaperSetter.java
│ │ │ ├── picker
│ │ │ ├── AppbarFragment.java
│ │ │ ├── BasePreviewActivity.java
│ │ │ ├── BottomActionBarFragment.java
│ │ │ ├── FragmentTransactionChecker.java
│ │ │ ├── ImagePreviewFragment.java
│ │ │ ├── LoadWallpaperErrorDialogFragment.java
│ │ │ ├── PreviewFragment.java
│ │ │ ├── SetWallpaperDialogFragment.java
│ │ │ ├── SetWallpaperErrorDialogFragment.java
│ │ │ └── TouchForwardingLayout.java
│ │ │ ├── util
│ │ │ ├── BitmapTransformer.java
│ │ │ ├── ScreenSizeCalculator.java
│ │ │ ├── TaskRunner.java
│ │ │ ├── TimeUtils.java
│ │ │ └── WallpaperCropUtils.java
│ │ │ └── widget
│ │ │ ├── BottomActionBar.java
│ │ │ ├── LockScreenPreviewer.java
│ │ │ ├── PageIndicator.java
│ │ │ ├── PreviewPager.java
│ │ │ └── WallpaperColorsLoader.java
│ └── me
│ │ └── ranko
│ │ └── autodark
│ │ ├── AutoDarkApplication.java
│ │ ├── Constant.java
│ │ ├── Exception
│ │ └── CommandExecuteError.java
│ │ ├── Utils
│ │ ├── CircularAnimationUtil.kt
│ │ ├── DarkLocationUtil.kt
│ │ ├── DarkTimeUtil.kt
│ │ ├── FileUtil.kt
│ │ ├── ShellJobUtil.kt
│ │ └── ViewUtil.kt
│ │ ├── asset
│ │ ├── BuiltInWallpaperAssetLoader.kt
│ │ └── FileAssetLoader.kt
│ │ ├── core
│ │ ├── DarkModeSettings.kt
│ │ ├── DebugTree.kt
│ │ ├── LoadStatus.kt
│ │ ├── ReleaseTree.kt
│ │ ├── ShizukuApi.kt
│ │ ├── WallpaperSetterBinder.kt
│ │ └── WallpaperSetterConnection.kt
│ │ ├── model
│ │ ├── BaseBlockableApplication.kt
│ │ ├── Blockable.kt
│ │ ├── BlockableApplication.kt
│ │ ├── BuiltInWallpaperInfo.kt
│ │ ├── CroppedWallpaperInfo.kt
│ │ ├── DarkWallpaperInfo.kt
│ │ ├── PersistableWallpaper.kt
│ │ ├── SystemWallpaperInfo.kt
│ │ └── Wallpaper.kt
│ │ ├── receivers
│ │ ├── BlockListReceiver.kt
│ │ ├── DarkModeAlarmReceiver.kt
│ │ └── InputMethodReceiver.kt
│ │ ├── services
│ │ ├── DarkLiveWallpaperService.kt
│ │ ├── DarkModeTileService.kt
│ │ └── RotationListenerService.kt
│ │ ├── ui
│ │ ├── AboutFragment.kt
│ │ ├── ActivationScopeDialog.kt
│ │ ├── ApplicationIconLoader.kt
│ │ ├── BaseListActivity.kt
│ │ ├── BindingAdapters.kt
│ │ ├── BlockListActivity.kt
│ │ ├── BlockListAdapter.kt
│ │ ├── BlockListEditDialog.kt
│ │ ├── BlockListViewModel.kt
│ │ ├── DarkWallpaperFragment.kt
│ │ ├── DarkWallpaperHelper.kt
│ │ ├── DarkWallpaperPermissionFragment.kt
│ │ ├── DarkWallpaperPickerActivity.kt
│ │ ├── DarkWallpaperPickerViewModel.kt
│ │ ├── LicenseActivity.kt
│ │ ├── LiveWallpaperAdapter.kt
│ │ ├── MainActivity.kt
│ │ ├── MainFragment.kt
│ │ ├── MainViewModel.kt
│ │ ├── ManagerAppListAdapter.kt
│ │ ├── PermissionActivity.kt
│ │ ├── PermissionViewModel.kt
│ │ ├── Preference
│ │ │ ├── DarkDisplayPreference.java
│ │ │ └── DarkSwitchPreference.java
│ │ ├── ShizukuViewModel.kt
│ │ ├── StandalonePreviewActivity.kt
│ │ ├── WallpaperCategoryDialog.kt
│ │ └── widget
│ │ │ ├── CheckedImageView.java
│ │ │ ├── ExpandableLayout.java
│ │ │ ├── MaterialCircleIconView.java
│ │ │ ├── MeasuredViewPager.java
│ │ │ ├── PermissionLayout.java
│ │ │ ├── WallpaperPreviewLayout.java
│ │ │ └── XposedManagerView.java
│ │ └── xposed
│ │ ├── ATMHooker.kt
│ │ ├── IMEHooker.kt
│ │ └── XCore.kt
│ └── res
│ ├── anim
│ ├── do_not_move.xml
│ ├── fade_in.xml
│ ├── fade_out.xml
│ ├── item_shift_vertical.xml
│ ├── major_a_b_dot_01_animation.xml
│ ├── major_a_b_dot_animation.xml
│ ├── major_b_a_dot_01_animation.xml
│ ├── major_b_a_dot_animation.xml
│ ├── major_b_c_dot_01_animation.xml
│ ├── major_b_c_dot_animation.xml
│ ├── major_c_b_dot_01_animation.xml
│ ├── major_c_b_dot_animation.xml
│ ├── minor_a_b_dot_02_animation.xml
│ ├── minor_b_a_dot_02_animation.xml
│ ├── minor_b_c_dot_02_animation.xml
│ ├── minor_c_b_dot_02_animation.xml
│ └── rotate_infinite.xml
│ ├── color
│ ├── bottom_action_button_color_tint.xml
│ └── indicator_arrow_color.xml
│ ├── drawable-nodpi
│ └── kyaru.webp
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── btn_expand_material_anim_24dp.xml
│ ├── card_btn_background.xml
│ ├── ic_adb.xml
│ ├── ic_arrow_back.xml
│ ├── ic_arrow_back_24px.xml
│ ├── ic_arrow_forward_24px.xml
│ ├── ic_attention.xml
│ ├── ic_auto_dark.xml
│ ├── ic_clear_anim.xml
│ ├── ic_close_gm2_24px.xml
│ ├── ic_code.xml
│ ├── ic_dark_theme.xml
│ ├── ic_delete.xml
│ ├── ic_done_gm2_24px.xml
│ ├── ic_expand_less_24dp.xml
│ ├── ic_expand_less_to_more_animation_24dp.xml
│ ├── ic_expand_more_24dp.xml
│ ├── ic_expand_more_to_less_animation_24dp.xml
│ ├── ic_extension.xml
│ ├── ic_grant.xml
│ ├── ic_home_24px.xml
│ ├── ic_info_gm2_24px.xml
│ ├── ic_keyboard.xml
│ ├── ic_launcher_background.xml
│ ├── ic_lock_outline_24px.xml
│ ├── ic_more.xml
│ ├── ic_off.xml
│ ├── ic_off_to_on_anim.xml
│ ├── ic_off_to_share_anim.xml
│ ├── ic_on.xml
│ ├── ic_on_to_off_anim.xml
│ ├── ic_on_to_share_anim.xml
│ ├── ic_pan_zoom_24dp.xml
│ ├── ic_restart.xml
│ ├── ic_root.xml
│ ├── ic_save.xml
│ ├── ic_send.xml
│ ├── ic_share_to_off_anim.xml
│ ├── ic_share_to_on_anim.xml
│ ├── ic_shizuku.xml
│ ├── ic_smartphone_24px.xml
│ ├── ic_undraw_moonlight.xml
│ ├── major_a_b.xml
│ ├── major_a_b_animation.xml
│ ├── major_b_a.xml
│ ├── major_b_a_animation.xml
│ ├── major_b_c.xml
│ ├── major_b_c_animation.xml
│ ├── major_c_b.xml
│ ├── major_c_b_animation.xml
│ ├── material_button_outline_background.xml
│ ├── material_button_outline_background_dark.xml
│ ├── material_button_outline_foreground.xml
│ ├── minor_a_b.xml
│ ├── minor_a_b_animation.xml
│ ├── minor_b_a.xml
│ ├── minor_b_a_animation.xml
│ ├── minor_b_c.xml
│ ├── minor_b_c_animation.xml
│ ├── minor_c_b.xml
│ ├── minor_c_b_animation.xml
│ ├── shape_btn_background.xml
│ └── shape_circle_icon_background.xml
│ ├── layout-land
│ ├── appbar_main.xml
│ └── content_main_scroll.xml
│ ├── layout
│ ├── activity_block_list.xml
│ ├── activity_main.xml
│ ├── activity_permission.xml
│ ├── activity_preview.xml
│ ├── appbar_main.xml
│ ├── bottom_actions_layout.xml
│ ├── card_wallpaper.xml
│ ├── content_main_scroll.xml
│ ├── content_permission_scroll.xml
│ ├── content_permission_shizuku_card.xml
│ ├── dialog_activation_scope.xml
│ ├── dialog_bottom_resstricted.xml
│ ├── dialog_edit_package.xml
│ ├── dialog_set_wallpaper.xml
│ ├── dialog_wallpaper_choose_category.xml
│ ├── fragment_dark_wallpaper.xml
│ ├── fragment_dark_wallpaper_permission.xml
│ ├── fragment_image_preview_v2.xml
│ ├── full_preview_tabs.xml
│ ├── grid_item_live_wallpaper.xml
│ ├── item_block_list.xml
│ ├── item_block_list_minimum.xml
│ ├── item_license.xml
│ ├── item_manager_lsp.xml
│ ├── license_activity.xml
│ ├── lock_screen_preview.xml
│ ├── preview_pager.xml
│ ├── preview_wallpaper.xml
│ ├── recycler_live_wallpaper.xml
│ ├── section_header.xml
│ ├── widget_permission.xml
│ └── widget_xposed_manager.xml
│ ├── menu
│ ├── menu_block_list.xml
│ └── menu_dark_wallpaper.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-de
│ └── strings.xml
│ ├── values-land-night
│ └── colors.xml
│ ├── values-land
│ ├── colors.xml
│ └── dimens.xml
│ ├── values-night
│ ├── colors.xml
│ └── styles.xml
│ ├── values-pl
│ └── strings.xml
│ ├── values-zh-rCN
│ └── strings.xml
│ ├── values
│ ├── arrays.xml
│ ├── attrs.xml
│ ├── colors.xml
│ ├── colors_material.xml
│ ├── dimens.xml
│ ├── ids.xml
│ ├── strings.xml
│ ├── strings_no_translate.xml
│ └── styles.xml
│ └── xml
│ ├── preferences_about.xml
│ └── preferences_main.xml
├── build.gradle
├── fastlane
└── metadata
│ └── android
│ ├── en-US
│ ├── full_description.txt
│ ├── images
│ │ ├── featureGraphic.png
│ │ ├── icon.png
│ │ └── phoneScreenshots
│ │ │ ├── Screenshot_1.png
│ │ │ ├── Screenshot_2.png
│ │ │ ├── Screenshot_3.png
│ │ │ ├── Screenshot_4.png
│ │ │ └── Screenshot_5.png
│ ├── short_description.txt
│ └── title.txt
│ └── zh-CN
│ ├── full_description.txt
│ ├── short_description.txt.txt
│ └── title.txt
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── hidden-api-dark
├── .gitignore
├── build.gradle
└── src
│ └── main
│ └── java
│ └── android
│ ├── annotation
│ ├── NonNull.java
│ └── Nullable.java
│ ├── app
│ └── IWallpaperManager.java
│ ├── content
│ ├── ComponentName.java
│ └── pm
│ │ ├── BaseParceledListSlice.java
│ │ ├── IPackageManager.java
│ │ ├── PackageInfo.java
│ │ └── ParceledListSlice.java
│ └── os
│ ├── Binder.java
│ ├── IBinder.java
│ ├── IInterface.java
│ ├── Parcel.java
│ ├── RemoteException.java
│ └── SystemProperties.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | .idea/
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | .cxx
10 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "Shizuku-API"]
2 | path = Shizuku-API
3 | url = https://github.com/0ranko0P/Shizuku-API
4 | branch = nopublish
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 0ranko0P
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Auto Dark
2 | ======
3 | [][project_link]
4 |
5 | A small Android app to let you schedule dark mode On/Off.
6 |
7 | This app need to modify system secure settings, permission ``` android.permission.WRITE_SECURE_SETTINGS``` are required.
8 |
9 | Available on [F-Droid][fdroid_link]
10 |
11 | [ ][fdroid_link]
12 |
13 | ## Requirements
14 | AOSP Andorid 10 like system.
15 |
16 | OEM builds are not supported e.g. Flyme,
17 | they already have this function or not compatible with their theme engine.
18 |
19 | ## Screenshots
20 |
21 |
22 |
23 |
24 |
25 | >
26 |
27 | # License
28 |
29 | MIT License
30 |
31 | Copyright (c) 2019 0ranko0P
32 |
33 | Permission is hereby granted, free of charge, to any person obtaining a copy
34 | of this software and associated documentation files (the "Software"), to deal
35 | in the Software without restriction, including without limitation the rights
36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37 | copies of the Software, and to permit persons to whom the Software is
38 | furnished to do so, subject to the following conditions:
39 |
40 | The above copyright notice and this permission notice shall be included in all
41 | copies or substantial portions of the Software.
42 |
43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
49 | SOFTWARE.
50 |
51 | [project_link]: https://github.com/0ranko0P/AutoDark
52 | [fdroid_link]: https://f-droid.org/packages/me.ranko.autodark
53 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | /debug
3 | /release
4 | /src/androidTest
5 | /src/test
6 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
23 | -keep class me.ranko.autodark.xposed.XCore
24 | -keep class me.ranko.autodark.AutoDarkApplication
25 |
26 | -keepclassmembers class me.ranko.autodark.AutoDarkApplication {
27 | private boolean isXposed;
28 | }
29 |
30 | -keep class * extends com.bumptech.glide.module.AppGlideModule {
31 | (...);
32 | }
33 |
34 | -keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
35 | **[] $VALUES;
36 | public *;
37 | }
38 |
39 | -keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
40 | *** rewind();
41 | }
--------------------------------------------------------------------------------
/app/src/main/assets/xposed_init:
--------------------------------------------------------------------------------
1 | me.ranko.autodark.xposed.XCore
--------------------------------------------------------------------------------
/app/src/main/java/com/android/wallpaper/asset/CropRectRotator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.android.wallpaper.asset;
17 |
18 | import android.graphics.Point;
19 | import android.graphics.Rect;
20 | import android.media.ExifInterface;
21 |
22 | import timber.log.Timber;
23 |
24 | /**
25 | * Rotates crop rectangles for bitmap region operations on rotated images (i.e., with non-normal
26 | * EXIF orientation).
27 | */
28 | public final class CropRectRotator {
29 | /**
30 | * Rotates and returns a new crop Rect which is adjusted for the provided EXIF orientation value.
31 | */
32 | public static Rect rotateCropRectForExifOrientation(Point dimensions, Rect srcRect,
33 | int exifOrientation) {
34 |
35 | switch (exifOrientation) {
36 | case ExifInterface.ORIENTATION_NORMAL:
37 | return new Rect(srcRect);
38 | case ExifInterface.ORIENTATION_ROTATE_90:
39 | return new Rect(srcRect.top, dimensions.x - srcRect.right, srcRect.bottom,
40 | dimensions.x - srcRect.left);
41 | case ExifInterface.ORIENTATION_ROTATE_180:
42 | return new Rect(dimensions.x - srcRect.right, dimensions.y - srcRect.bottom,
43 | dimensions.x - srcRect.left, dimensions.y - srcRect.top);
44 | case ExifInterface.ORIENTATION_ROTATE_270:
45 | return new Rect(dimensions.y - srcRect.bottom, srcRect.left, dimensions.y - srcRect.top,
46 | srcRect.right);
47 | default:
48 | Timber.w("Unsupported EXIF orientation %s", exifOrientation);
49 | return new Rect(srcRect);
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/android/wallpaper/model/ImageWallpaperInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.wallpaper.model;
18 |
19 | import android.content.Context;
20 | import android.net.Uri;
21 | import android.os.Parcel;
22 | import android.os.Parcelable;
23 |
24 | import com.android.wallpaper.asset.Asset;
25 | import com.android.wallpaper.asset.ContentUriAsset;
26 |
27 | import org.jetbrains.annotations.NotNull;
28 |
29 | /**
30 | * Represents a wallpaper image from the system's image picker.
31 | */
32 | public final class ImageWallpaperInfo extends WallpaperInfo {
33 |
34 | public static final Parcelable.Creator CREATOR =
35 | new Parcelable.Creator() {
36 | @Override
37 | public ImageWallpaperInfo createFromParcel(Parcel in) {
38 | return new ImageWallpaperInfo(in);
39 | }
40 |
41 | @Override
42 | public ImageWallpaperInfo[] newArray(int size) {
43 | return new ImageWallpaperInfo[size];
44 | }
45 | };
46 |
47 | private final Uri mUri;
48 | private ContentUriAsset mAsset;
49 |
50 | public ImageWallpaperInfo(Uri uri) {
51 | mUri = uri;
52 | }
53 |
54 | protected ImageWallpaperInfo(Parcel in) {
55 | mUri = Uri.parse(in.readString());
56 | }
57 |
58 | @Override
59 | public Asset getAsset(Context context) {
60 | if (mAsset == null) {
61 | mAsset = new ContentUriAsset(context, mUri);
62 | }
63 | return mAsset;
64 | }
65 |
66 | @Override
67 | public Asset getThumbAsset(Context context) {
68 | return getAsset(context);
69 | }
70 |
71 | public Uri getUri() {
72 | return mUri;
73 | }
74 |
75 | @Override
76 | public @NotNull String getWallpaperId() {
77 | throw new UnsupportedOperationException();
78 | }
79 |
80 | @Override
81 | public void writeToParcel(Parcel parcel, int i) {
82 | parcel.writeString(mUri.toString());
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/android/wallpaper/model/WallpaperInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.android.wallpaper.model;
17 |
18 | import android.content.Context;
19 | import android.net.Uri;
20 | import android.os.Parcelable;
21 |
22 | import androidx.annotation.NonNull;
23 |
24 | import com.android.wallpaper.asset.Asset;
25 |
26 | /**
27 | * Interface for wallpaper info model.
28 | */
29 | public abstract class WallpaperInfo implements Parcelable {
30 |
31 | /**
32 | * @param context
33 | * @return The title for this wallpaper, if applicable (as in a wallpaper "app" or live
34 | * wallpaper), or null if not applicable.
35 | */
36 | public String getTitle(Context context) {
37 | return null;
38 | }
39 |
40 | /** Returns the URI corresponding to the wallpaper, or null if none exists. */
41 | public Uri getUri() {
42 | return null;
43 | }
44 |
45 | @Override
46 | public int describeContents() {
47 | return 0;
48 | }
49 |
50 | /**
51 | * @param context The client application's context.
52 | * @return The {@link Asset} representing the wallpaper image.
53 | */
54 | public abstract Asset getAsset(Context context);
55 |
56 | /**
57 | * @param context The client application's context.
58 | * @return The {@link Asset} representing the wallpaper's thumbnail.
59 | */
60 | public abstract Asset getThumbAsset(Context context);
61 |
62 | /**
63 | * @return the {@link android.app.WallpaperInfo} associated with this wallpaper, which is
64 | * generally present for live wallpapers, or null if there is none.
65 | */
66 | public android.app.WallpaperInfo getWallpaperComponent() {
67 | return null;
68 | }
69 |
70 | /**
71 | * Returns the ID of this wallpaper.
72 | */
73 | @NonNull
74 | public abstract String getWallpaperId();
75 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/android/wallpaper/picker/BasePreviewActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2017 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.android.wallpaper.picker;
17 |
18 | import android.content.pm.ActivityInfo;
19 | import android.graphics.PixelFormat;
20 | import android.os.Bundle;
21 |
22 | import androidx.annotation.Nullable;
23 | import androidx.appcompat.app.AppCompatActivity;
24 |
25 | /**
26 | * Abstract base class for a wallpaper full-screen preview activity.
27 | */
28 | public abstract class BasePreviewActivity extends AppCompatActivity implements FragmentTransactionChecker {
29 |
30 | private boolean mIsSafeToCommitFragmentTransaction;
31 |
32 | @Override
33 | protected void onCreate(@Nullable Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | getWindow().setColorMode(ActivityInfo.COLOR_MODE_WIDE_COLOR_GAMUT);
36 | getWindow().setFormat(PixelFormat.TRANSLUCENT);
37 | setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
38 | }
39 |
40 | @Override
41 | protected void onResume() {
42 | super.onResume();
43 | mIsSafeToCommitFragmentTransaction = true;
44 | }
45 |
46 | @Override
47 | protected void onPause() {
48 | super.onPause();
49 | mIsSafeToCommitFragmentTransaction = false;
50 | }
51 |
52 | @Override
53 | public boolean isSafeToCommitFragmentTransaction() {
54 | return mIsSafeToCommitFragmentTransaction;
55 | }
56 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/android/wallpaper/picker/FragmentTransactionChecker.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.android.wallpaper.picker;
17 |
18 | /**
19 | * An interface for a class to keep track of whether fragment transactions are safe to commit given
20 | * the activity's current lifecycle state.
21 | */
22 | public interface FragmentTransactionChecker {
23 | /**
24 | * Checks if the fragment transactions are safe to commit
25 | *
26 | * @return {@code true} if it is safe; {@code false} otherwise.
27 | */
28 | boolean isSafeToCommitFragmentTransaction();
29 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/android/wallpaper/picker/TouchForwardingLayout.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.android.wallpaper.picker;
17 |
18 | import android.content.Context;
19 | import android.util.AttributeSet;
20 | import android.view.MotionEvent;
21 | import android.view.View;
22 | import android.widget.FrameLayout;
23 |
24 | /** A frame layout that listens to touch events and routes them to another view. */
25 | public final class TouchForwardingLayout extends FrameLayout {
26 |
27 | private View mView;
28 | private boolean mForwardingEnabled;
29 |
30 | public TouchForwardingLayout(Context context, AttributeSet attrs) {
31 | super(context, attrs);
32 | }
33 |
34 | @Override
35 | public boolean dispatchTouchEvent(MotionEvent ev) {
36 | if (mView != null && mForwardingEnabled) {
37 | mView.dispatchTouchEvent(ev);
38 | }
39 | return true;
40 | }
41 |
42 | /** Set the view that the touch events are routed to */
43 | public void setTargetView(View view) {
44 | mView = view;
45 | }
46 |
47 | public void setForwardingEnabled(boolean forwardingEnabled) {
48 | mForwardingEnabled = forwardingEnabled;
49 | }
50 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/android/wallpaper/util/TaskRunner.java:
--------------------------------------------------------------------------------
1 | package com.android.wallpaper.util;
2 |
3 | import android.os.Handler;
4 | import android.os.Looper;
5 |
6 | import java.util.concurrent.Callable;
7 | import java.util.concurrent.ExecutorService;
8 | import java.util.concurrent.Executors;
9 | import java.util.concurrent.SynchronousQueue;
10 | import java.util.concurrent.ThreadPoolExecutor;
11 | import java.util.concurrent.TimeUnit;
12 |
13 | public final class TaskRunner {
14 |
15 | private static TaskRunner INSTANCE;
16 |
17 | private final ExecutorService executor = Executors.newSingleThreadExecutor();
18 |
19 | private final ExecutorService ioExecutor = new ThreadPoolExecutor(
20 | 2,
21 | 6,
22 | 60L,
23 | TimeUnit.SECONDS,
24 | new SynchronousQueue<>());
25 |
26 | private final Handler handler = new Handler(Looper.getMainLooper());
27 |
28 | private TaskRunner() {
29 | }
30 |
31 | public static TaskRunner getINSTANCE() {
32 | if (INSTANCE == null) {
33 | synchronized (TaskRunner.class) {
34 | if (INSTANCE == null) INSTANCE = new TaskRunner();
35 | }
36 | }
37 | return INSTANCE;
38 | }
39 |
40 | public interface Callback {
41 | void onComplete(R result);
42 |
43 | void onError(Exception e);
44 | }
45 |
46 | public void executeIOAsync(Callable callable, Callback callback) {
47 | _executeAsync(ioExecutor, callable, callback);
48 | }
49 |
50 | public void executeAsync(Callable callable, Callback callback) {
51 | _executeAsync(executor, callable, callback);
52 | }
53 |
54 | private void _executeAsync(ExecutorService executor, Callable callable, Callback callback) {
55 | if (executor.isShutdown()) {
56 | throw new IllegalStateException();
57 | }
58 |
59 | executor.execute(() -> {
60 | try {
61 | R result = callable.call();
62 | handler.post(() -> callback.onComplete(result));
63 | } catch (Exception e) {
64 | handler.post(() -> callback.onError(e));
65 | }
66 | });
67 | }
68 |
69 | public static void shutdown() {
70 | if (INSTANCE != null) {
71 | INSTANCE.executor.shutdown();
72 | INSTANCE.ioExecutor.shutdown();
73 | INSTANCE = null;
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/AutoDarkApplication.java:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark;
2 |
3 | import android.app.Application;
4 | import android.content.ComponentName;
5 | import android.content.Context;
6 | import android.content.pm.PackageManager;
7 | import android.os.Build;
8 |
9 | import android.Manifest;
10 |
11 | import androidx.core.content.ContextCompat;
12 |
13 | import org.lsposed.hiddenapibypass.HiddenApiBypass;
14 |
15 | import me.ranko.autodark.core.DebugTree;
16 | import me.ranko.autodark.core.ReleaseTree;
17 | import me.ranko.autodark.services.DarkModeTileService;
18 | import rikka.sui.Sui;
19 | import timber.log.Timber;
20 |
21 | public final class AutoDarkApplication extends Application {
22 |
23 | public static final boolean isSui = Sui.init(BuildConfig.APPLICATION_ID);
24 |
25 | @Override
26 | protected void attachBaseContext(Context base) {
27 | super.attachBaseContext(base);
28 | HiddenApiBypass.addHiddenApiExemptions("L");
29 | }
30 |
31 | @Override
32 | public void onCreate() {
33 | super.onCreate();
34 | if (BuildConfig.DEBUG) {
35 | Timber.plant(new DebugTree());
36 | } else {
37 | Timber.plant(ReleaseTree.INSTANCE);
38 | }
39 |
40 | DarkModeTileService.setUp(this);
41 | }
42 |
43 | public static boolean isOnePlus() {
44 | return Build.BRAND.toUpperCase().contains(Constant.BRAND_ONE_PLUS);
45 | }
46 |
47 | public static boolean checkSecurePermission(Context context) {
48 | return ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_SECURE_SETTINGS) == PackageManager.PERMISSION_GRANTED;
49 | }
50 |
51 | public static boolean isLineageOS() {
52 | return Build.DISPLAY.startsWith("lineage");
53 | }
54 |
55 | public static boolean isComponentEnabled(Context context, Class> target) {
56 | ComponentName component = new ComponentName(context, target);
57 | int status = context.getPackageManager().getComponentEnabledSetting(component);
58 | return status != PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
59 | }
60 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/Constant.java:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark;
2 |
3 | import android.Manifest;
4 |
5 | import java.io.File;
6 | import java.nio.file.Path;
7 | import java.nio.file.Paths;
8 |
9 | public final class Constant {
10 |
11 | public static final String ANDROID_PACKAGE = "android";
12 |
13 | /**
14 | * Available when internal storage is encrypted
15 | * SystemServer can initialize block list here
16 | * */
17 | public static final String APP_DATA_DIR = "/data/user_de/0/" + BuildConfig.APPLICATION_ID;
18 |
19 | public static final Path BLOCK_LIST_PATH = Paths.get(APP_DATA_DIR + File.separator + "block.txt");
20 |
21 | public static final Path BLOCK_LIST_INPUT_METHOD_CONFIG_PATH = Paths.get( APP_DATA_DIR + File.separator + "hookIME");
22 |
23 | public static final String PERMISSION_RECEIVE_DARK_BROADCAST = "me.ranko0p.permission.RECEIVE_DARK_BROADCAST";
24 | public static final String PERMISSION_SEND_DARK_BROADCAST = "me.ranko0p.permission.SEND_DARK_BROADCAST";
25 |
26 | public static final String BRAND_ONE_PLUS = "OnePlus".toUpperCase();
27 |
28 | public static final String SP_KEY_MASTER_SWITCH = "switch";
29 |
30 | public static final String SP_AUTO_TIME_SUNRISE = "sunrise";
31 | public static final String SP_AUTO_TIME_SUNSET = "sunset";
32 |
33 | public static final String SP_RESTRICTED_SILENCE = "silence";
34 |
35 | public static final String COMMAND_GRANT_PM = "pm grant " + BuildConfig.APPLICATION_ID + " " + Manifest.permission.WRITE_SECURE_SETTINGS;
36 | public static final String COMMAND_GRANT_ADB = "adb -d shell " + COMMAND_GRANT_PM;
37 |
38 | /**
39 | * Force-dark mode.
40 | *
41 | * Return null when force-dark is untouched.
42 | *
43 | **/
44 | public static final String SYSTEM_PROP_FORCE_DARK = "debug.hwui.force_dark";
45 |
46 | public static final String SYSTEM_PROP_HOOK_INPUT_METHOD = "debug.hwui.hook_ime";
47 |
48 | public static final String SYSTEM_SECURE_PROP_DARK_MODE = "ui_night_mode";
49 |
50 | public static final String COMMAND_SET_FORCE_DARK_ON = "setprop " + SYSTEM_PROP_FORCE_DARK + " true";
51 | public static final String COMMAND_SET_FORCE_DARK_OFF = "setprop " + SYSTEM_PROP_FORCE_DARK + " false";
52 | }
53 |
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/Exception/CommandExecuteError.java:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.Exception;
2 |
3 | /**
4 | * Signals that an error occurred during execute command.
5 | *
6 | * @author 0ranko0P
7 | * @see Runtime#exec(String)
8 | */
9 | public final class CommandExecuteError extends Exception {
10 | static final long serialVersionUID = -418375825643090127L;
11 |
12 | /**
13 | * Constructs an {@code CommandExecuteError} with {@code null}
14 | * as its error detail message.
15 | */
16 | public CommandExecuteError() {
17 | super();
18 | }
19 |
20 | /**
21 | * Constructs a new CommandExecuteError with the specified detail message. The
22 | * cause is not initialized, and may subsequently be initialized by
23 | * a call to {@link #initCause}.
24 | *
25 | * @param message the detail message. The detail message is saved for
26 | * later retrieval by the {@link #getMessage()} method.
27 | */
28 | public CommandExecuteError(String message) {
29 | super(message);
30 | }
31 |
32 | /**
33 | * Constructs an {@code CommandExecuteError} with the specified detail message
34 | * and cause.
35 | *
36 | * Note that the detail message associated with {@code cause} is
37 | * not automatically incorporated into this exception's detail
38 | * message.
39 | *
40 | * @param message
41 | * The detail message (which is saved for later retrieval
42 | * by the {@link #getMessage()} method)
43 | *
44 | * @param cause
45 | * The cause (which is saved for later retrieval by the
46 | * {@link #getCause()} method). (A null value is permitted,
47 | * and indicates that the cause is nonexistent or unknown.)
48 | *
49 | */
50 | public CommandExecuteError(String message, Throwable cause) {
51 | super(message, cause);
52 | }
53 |
54 | /**
55 | * Constructs an {@code CommandExecuteError} with the specified cause and a
56 | * detail message of {@code (cause==null ? null : cause.toString())}
57 | * (which typically contains the class and detail message of {@code cause}).
58 | * This constructor is useful for IO exceptions that are little more
59 | * than wrappers for other throwables.
60 | *
61 | * @param cause
62 | * The cause (which is saved for later retrieval by the
63 | * {@link #getCause()} method). (A null value is permitted,
64 | * and indicates that the cause is nonexistent or unknown.)
65 | *
66 | */
67 | public CommandExecuteError(Throwable cause) {
68 | super(cause);
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/Utils/CircularAnimationUtil.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.Utils
2 |
3 | import android.animation.Animator
4 | import android.view.View
5 | import android.view.ViewAnimationUtils
6 | import androidx.annotation.Size
7 | import kotlin.math.max
8 |
9 | /**
10 | * Util to create circular animation
11 | *
12 | * @link https://developer.android.com/training/animation/reveal-or-hide-view.html#Reveal
13 | * */
14 | object CircularAnimationUtil {
15 |
16 | /**
17 | * Build circular Animator with a view
18 | *
19 | * @param startView circle animate starts from this view's center
20 | * @param target circle animate perform on this view, will automatic set visibility
21 | */
22 | @JvmStatic
23 | fun buildAnimator(startView: View, target: View, targetRadius:Float = 0f): Animator {
24 | return buildAnimator(getViewCenterCoordinate(startView), target, targetRadius)
25 | }
26 |
27 | /**
28 | * Build circular animator with coordinates
29 | *
30 | * @param coordinates The X,Y coordinate that circle animate starts
31 | * @param target The view that Animator will perform on
32 | *
33 | * @return In/Out circular animator depends on target view's visibility
34 | *
35 | * @see ViewAnimationUtils.createCircularReveal
36 | */
37 | @JvmStatic
38 | fun buildAnimator(@Size(2) coordinates: IntArray, target: View, targetRadius:Float = 0f): Animator {
39 | // is in/out animation
40 | val aType = target.visibility == View.VISIBLE
41 |
42 | val radius = max(target.width, target.height).toFloat()
43 | val start = if (aType) radius else targetRadius
44 | val end = if (aType) targetRadius else radius
45 |
46 | return ViewAnimationUtils.createCircularReveal(
47 | target,
48 | coordinates[0],
49 | coordinates[1],
50 | start,
51 | end
52 | )
53 | }
54 |
55 | @JvmStatic
56 | fun getViewCenterCoordinate(view: View): IntArray {
57 | val cx = view.x + view.width / 2
58 | val cy = view.y + view.height / 2
59 | return intArrayOf(cx.toInt(), cy.toInt())
60 | }
61 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/Utils/ViewUtil.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.Utils
2 |
3 | import android.content.Context
4 | import android.content.res.Configuration
5 | import android.graphics.Paint
6 | import android.text.SpannableString
7 | import android.text.style.ForegroundColorSpan
8 | import android.view.MenuItem
9 | import android.view.Window
10 | import android.view.WindowManager
11 | import android.widget.TextView
12 | import androidx.annotation.ColorInt
13 |
14 | /**
15 | * Simple view util
16 | *
17 | * @author 0ranko0P
18 | * */
19 | object ViewUtil {
20 | fun isLandscape(context: Context) =
21 | context.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
22 |
23 | fun setImmersiveNavBar(window: Window) {
24 | window.setFlags(
25 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
26 | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
27 | )
28 | }
29 |
30 | /**
31 | * Applies a strike-through font style on a TextView
32 | *
33 | * @param textView The target textView
34 | * @param enabled Apply strike style or not
35 | *
36 | * @see TextView.setPaintFlags
37 | * @see Paint.STRIKE_THRU_TEXT_FLAG
38 | * */
39 | fun setStrikeFontStyle(textView: TextView, enabled: Boolean) {
40 | textView.paintFlags = if (enabled) {
41 | textView.paintFlags.or(Paint.STRIKE_THRU_TEXT_FLAG)
42 | } else {
43 | textView.paintFlags.and(Paint.STRIKE_THRU_TEXT_FLAG.inv())
44 | }
45 | }
46 |
47 | fun setMenuItemTitleColor(item: MenuItem, @ColorInt color: Int, title: CharSequence = item.title) {
48 | val spannable = SpannableString(title)
49 | spannable.setSpan(ForegroundColorSpan(color), 0, title.length, 0)
50 | item.title = spannable
51 | }
52 |
53 | fun getAttrColor(context: Context, attr: Int): Int {
54 | val ta = context.obtainStyledAttributes(intArrayOf(attr))
55 | val colorAccent = ta.getColor(0, 0)
56 | ta.recycle()
57 | return colorAccent
58 | }
59 |
60 | @Suppress("DEPRECATION")
61 | fun getRotation(context: Context): Int {
62 | val window = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
63 | return window.defaultDisplay.rotation
64 | }
65 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/asset/BuiltInWallpaperAssetLoader.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.asset
2 |
3 | import android.graphics.Bitmap
4 | import com.android.wallpaper.asset.BuiltInWallpaperAsset
5 | import com.bumptech.glide.Priority
6 | import com.bumptech.glide.load.DataSource
7 | import com.bumptech.glide.load.Options
8 | import com.bumptech.glide.load.data.DataFetcher
9 | import com.bumptech.glide.load.model.ModelLoader
10 | import com.bumptech.glide.load.model.ModelLoaderFactory
11 | import com.bumptech.glide.load.model.MultiModelLoaderFactory
12 | import com.bumptech.glide.signature.ObjectKey
13 | import java.io.IOException
14 |
15 | class BuiltInWallpaperAssetLoader : ModelLoader {
16 |
17 | override fun buildLoadData(model: BuiltInWallpaperAsset, width: Int, height: Int, options: Options): ModelLoader.LoadData {
18 | return ModelLoader.LoadData(ObjectKey(model), BuiltInWallpaperAssetDataFetcher(model, width, height))
19 | }
20 |
21 | override fun handles(model: BuiltInWallpaperAsset): Boolean = true
22 |
23 | class BuiltInWallpaperAssetDataFetcher(private val asset: BuiltInWallpaperAsset,
24 | private val width: Int,
25 | private val height: Int) : DataFetcher {
26 |
27 | override fun loadData(priority: Priority, callback: DataFetcher.DataCallback) {
28 | return try {
29 | callback.onDataReady(asset.decodeBitmap(width, height))
30 | } catch (e: IOException) {
31 | callback.onLoadFailed(e)
32 | }
33 | }
34 |
35 | override fun getDataClass(): Class = Bitmap::class.java
36 |
37 | override fun getDataSource(): DataSource = DataSource.LOCAL
38 |
39 | override fun cancel() {
40 | // no-op
41 | }
42 |
43 | override fun cleanup() {
44 | // no-op
45 | }
46 | }
47 |
48 | class BuiltInWallpaperAssetLoaderFactory : ModelLoaderFactory {
49 |
50 | override fun build(multiFactory: MultiModelLoaderFactory): ModelLoader {
51 | return BuiltInWallpaperAssetLoader()
52 | }
53 |
54 | override fun teardown() {
55 | // no-op
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/asset/FileAssetLoader.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.asset
2 |
3 | import android.graphics.Bitmap
4 | import com.android.wallpaper.asset.FileAsset
5 | import com.bumptech.glide.Priority
6 | import com.bumptech.glide.load.DataSource
7 | import com.bumptech.glide.load.Options
8 | import com.bumptech.glide.load.data.DataFetcher
9 | import com.bumptech.glide.load.model.ModelLoader
10 | import com.bumptech.glide.load.model.ModelLoaderFactory
11 | import com.bumptech.glide.load.model.MultiModelLoaderFactory
12 | import com.bumptech.glide.signature.ObjectKey
13 | import java.io.IOException
14 |
15 | class FileAssetLoader : ModelLoader {
16 |
17 | override fun buildLoadData(model: FileAsset, width: Int, height: Int, options: Options): ModelLoader.LoadData {
18 | return ModelLoader.LoadData(ObjectKey(model), FileDescriptorDataFetcher(model, width, height))
19 | }
20 |
21 | override fun handles(model: FileAsset): Boolean = true
22 |
23 | class FileDescriptorDataFetcher(private val asset: FileAsset,
24 | private val width: Int,
25 | private val height: Int) : DataFetcher {
26 |
27 | override fun loadData(priority: Priority, callback: DataFetcher.DataCallback) {
28 | return try {
29 | callback.onDataReady(asset.decodeBitmap(width, height))
30 | } catch (e: IOException) {
31 | callback.onLoadFailed(e)
32 | }
33 | }
34 |
35 | override fun getDataClass(): Class = Bitmap::class.java
36 |
37 | override fun cleanup() {
38 | asset.recycle()
39 | }
40 |
41 | override fun getDataSource(): DataSource = DataSource.LOCAL
42 |
43 | override fun cancel() {
44 | // no-op
45 | }
46 | }
47 |
48 | class FileDescriptorAssetLoaderFactory : ModelLoaderFactory {
49 |
50 | override fun build(multiFactory: MultiModelLoaderFactory): ModelLoader {
51 | return FileAssetLoader()
52 | }
53 |
54 | override fun teardown() {
55 | // no-op
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/core/DebugTree.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.core
2 |
3 | import timber.log.Timber
4 |
5 | open class DebugTree : Timber.DebugTree() {
6 | override fun createStackElementTag(element: StackTraceElement): String? {
7 | return String.format("(%s:%s)#%s", element.fileName, element.lineNumber, element.methodName)
8 | }
9 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/core/LoadStatus.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.core
2 |
3 | import androidx.annotation.IntDef
4 | import me.ranko.autodark.core.LoadStatus.Companion.FAILED
5 | import me.ranko.autodark.core.LoadStatus.Companion.START
6 | import me.ranko.autodark.core.LoadStatus.Companion.SUCCEED
7 |
8 | @Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.TYPE)
9 | @IntDef(START, SUCCEED, FAILED)
10 | @Retention(AnnotationRetention.SOURCE)
11 | annotation class LoadStatus {
12 | companion object {
13 | const val START = 0x001A
14 | const val FAILED = START.shl(1)
15 | const val SUCCEED = FAILED.shl(1)
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/core/ReleaseTree.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.core
2 |
3 | import android.util.Log
4 | import timber.log.Timber
5 |
6 | object ReleaseTree : Timber.DebugTree() {
7 |
8 | override fun isLoggable(tag: String?, priority: Int): Boolean {
9 | return priority >= Log.INFO
10 | }
11 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/core/WallpaperSetterBinder.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.core
2 |
3 | import android.os.Binder
4 |
5 | abstract class WallpaperSetterBinder : Binder() {
6 |
7 | interface WallpaperSetterServiceCallback {
8 | fun onReadyToSet()
9 |
10 | fun onServiceFailure(e: Exception)
11 | }
12 |
13 | abstract fun start(callback: WallpaperSetterServiceCallback)
14 |
15 | abstract fun destroy()
16 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/core/WallpaperSetterConnection.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.core
2 |
3 | import android.content.ComponentName
4 | import android.content.Context
5 | import android.content.ServiceConnection
6 | import android.os.IBinder
7 | import com.android.wallpaper.asset.StreamableAsset
8 | import com.android.wallpaper.model.LiveWallpaperInfo
9 | import com.android.wallpaper.model.WallpaperInfo
10 | import com.android.wallpaper.module.WallpaperPersister
11 | import com.android.wallpaper.module.WallpaperSetter
12 |
13 | class WallpaperSetterConnection(
14 | private val context: Context,
15 | private val wallpapers: Pair,
16 | private val callback: WallpaperPersister.SetWallpaperCallback,
17 | private val setter: WallpaperSetter
18 | ) : ServiceConnection, WallpaperSetterBinder.WallpaperSetterServiceCallback,
19 | WallpaperPersister.SetWallpaperCallback {
20 |
21 | private var binder: WallpaperSetterBinder? = null
22 |
23 | constructor(
24 | context: Context,
25 | wallpaper: LiveWallpaperInfo,
26 | callback: WallpaperPersister.SetWallpaperCallback,
27 | setter: WallpaperSetter
28 | ) : this(context, Pair(wallpaper, null), callback, setter)
29 |
30 | override fun onServiceConnected(name: ComponentName, service: IBinder) {
31 | binder = (service as WallpaperSetterBinder)
32 | binder!!.start(this)
33 | }
34 |
35 | override fun onServiceDisconnected(name: ComponentName) {
36 | // no-op
37 | }
38 |
39 | override fun onReadyToSet() {
40 | val home = wallpapers.first
41 | if (home is LiveWallpaperInfo) {
42 | setter.setCurrentLiveWallpaper(home, this)
43 | } else {
44 | val lockAsset: StreamableAsset? = wallpapers.second?.getAsset(context)?.let {
45 | it as StreamableAsset
46 | }
47 | setter.setDarkWallpapers(home.getAsset(context) as StreamableAsset, lockAsset, this)
48 | }
49 | }
50 |
51 | override fun onServiceFailure(e: Exception) {
52 | this.onError(e)
53 | }
54 |
55 | override fun onSuccess(id: String) {
56 | callback.onSuccess(id)
57 | destroy()
58 | }
59 |
60 | override fun onError(e: java.lang.Exception?) {
61 | callback.onError(e)
62 | destroy()
63 | }
64 |
65 | private fun destroy() {
66 | context.unbindService(this)
67 | binder!!.destroy()
68 | binder = null
69 | }
70 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/model/BaseBlockableApplication.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.model
2 |
3 | class BaseBlockableApplication(private val packageName: String) : Blockable {
4 |
5 | constructor(blockable: Blockable):this(blockable.getPackageName())
6 |
7 | override fun getPackageName(): String = packageName
8 |
9 | override fun isPrimaryUser(): Boolean = false
10 |
11 | override fun equals(other: Any?): Boolean {
12 | if (this === other) return true
13 | return other is Blockable && packageName == other.getPackageName()
14 | }
15 |
16 | override fun hashCode(): Int = packageName.hashCode()
17 |
18 | override fun toString(): String = packageName
19 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/model/Blockable.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.model
2 |
3 | interface Blockable {
4 | fun getPackageName(): String
5 |
6 | fun isPrimaryUser(): Boolean
7 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/model/BlockableApplication.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.model
2 |
3 | import android.content.pm.ApplicationInfo
4 | import android.os.Process
5 | import android.os.UserHandle
6 |
7 | class BlockableApplication(
8 | app: ApplicationInfo,
9 | val user: UserHandle? = null,
10 | val userId: Int = Process.ROOT_UID,
11 | ) : ApplicationInfo(app), Blockable {
12 |
13 | override fun getPackageName(): String = packageName
14 |
15 | override fun isPrimaryUser(): Boolean = user == null || userId == Process.ROOT_UID
16 |
17 | fun isSysApp(): Boolean = flags.and(FLAG_SYSTEM) != 0
18 |
19 | override fun equals(other: Any?): Boolean {
20 | if (this === other) return true
21 | return other is Blockable && packageName == other.getPackageName()
22 | }
23 |
24 | override fun hashCode(): Int = packageName.hashCode()
25 |
26 | override fun toString(): String = packageName
27 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/model/BuiltInWallpaperInfo.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.model
2 |
3 | import android.app.WallpaperManager
4 | import android.content.Context
5 | import android.graphics.drawable.BitmapDrawable
6 | import androidx.annotation.WorkerThread
7 | import com.android.wallpaper.asset.Asset
8 | import com.android.wallpaper.asset.BuiltInWallpaperAsset
9 | import com.android.wallpaper.asset.BuiltInWallpaperAsset.BUILT_IN_WALLPAPER_ID
10 | import com.android.wallpaper.module.WallpaperPersister.DEFAULT_COMPRESS_FORMAT
11 | import com.android.wallpaper.module.WallpaperPersister.DEFAULT_COMPRESS_QUALITY
12 | import kotlinx.coroutines.yield
13 | import java.io.File
14 | import java.io.FileOutputStream
15 | import java.io.IOException
16 |
17 | class BuiltInWallpaperInfo : SystemWallpaperInfo(WallpaperManager.FLAG_SYSTEM, BUILT_IN_WALLPAPER_ID) {
18 |
19 | override fun getAsset(context: Context): Asset {
20 | if (mAsset == null) {
21 | mAsset = BuiltInWallpaperAsset(context)
22 | }
23 | return mAsset!!
24 | }
25 |
26 | @WorkerThread
27 | @Throws(IOException::class)
28 | override suspend fun persist(context: Context) {
29 | val outFile = PersistableWallpaper.getWallpaperFile(context, wallpaperId)
30 | export(context, outFile)
31 | }
32 |
33 | @WorkerThread
34 | @Throws(IOException::class)
35 | override suspend fun export(context: Context, outFile: File) {
36 | val manager = WallpaperManager.getInstance(context)
37 | val bitmap = (manager.getBuiltInDrawable(which) as BitmapDrawable).bitmap
38 | manager.forgetLoadedWallpaper()
39 | yield()
40 | FileOutputStream(outFile).use { outStream ->
41 | bitmap.compress(DEFAULT_COMPRESS_FORMAT, DEFAULT_COMPRESS_QUALITY, outStream)
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/model/DarkWallpaperInfo.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.model
2 |
3 | import android.content.Context
4 | import android.os.Parcel
5 | import android.os.Parcelable
6 | import com.android.wallpaper.asset.Asset
7 | import com.android.wallpaper.asset.FileAsset
8 | import com.android.wallpaper.model.WallpaperInfo
9 |
10 | /**
11 | * Represents a wallpaper in storage and it's ready for the dark mode.
12 | * */
13 | class DarkWallpaperInfo(private val id: String) : WallpaperInfo() {
14 |
15 | companion object CREATOR : Parcelable.Creator {
16 | override fun createFromParcel(parcel: Parcel): DarkWallpaperInfo {
17 | return DarkWallpaperInfo(parcel)
18 | }
19 |
20 | override fun newArray(size: Int): Array {
21 | return arrayOfNulls(size)
22 | }
23 | }
24 |
25 | private var mAsset: FileAsset? = null
26 |
27 | constructor(parcel: Parcel) : this(parcel.readString()!!)
28 |
29 | override fun getAsset(context: Context): Asset {
30 | if (mAsset == null) {
31 | mAsset = FileAsset(PersistableWallpaper.getWallpaperFile(context, id))
32 | }
33 | return mAsset!!
34 | }
35 |
36 | override fun getWallpaperId(): String = id
37 |
38 | override fun getThumbAsset(context: Context): Asset? = null
39 |
40 | override fun writeToParcel(dest: Parcel, flags: Int) {
41 | dest.writeString(id)
42 | }
43 |
44 | override fun equals(other: Any?): Boolean {
45 | if (this === other) return true
46 | return (other is DarkWallpaperInfo && id == other.id)
47 | }
48 |
49 | override fun hashCode(): Int = id.hashCode()
50 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/model/PersistableWallpaper.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.model
2 |
3 | import android.content.Context
4 | import androidx.annotation.WorkerThread
5 | import java.io.File
6 | import java.io.IOException
7 |
8 | interface PersistableWallpaper {
9 |
10 | companion object {
11 | private const val DEFAULT_WALLPAPER_FOLDER = "Wallpapers"
12 |
13 | fun getWallpaperFile(context: Context, id: String): File {
14 | return File(context.getFileStreamPath(DEFAULT_WALLPAPER_FOLDER), id)
15 | }
16 | }
17 |
18 | /**
19 | * Persist this wallpaper to storage
20 | * */
21 | @WorkerThread
22 | @Throws(IOException::class)
23 | suspend fun persist(context: Context)
24 |
25 | /**
26 | * @return **true** If this Persistable haven't save to storage yet.
27 | * */
28 | fun isNew(context: Context): Boolean
29 |
30 | /**
31 | * Delete from storage
32 | * */
33 | fun delete(context: Context): Boolean
34 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/model/Wallpaper.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.model
2 |
3 | import com.android.wallpaper.model.LiveWallpaperInfo
4 | import org.json.JSONObject
5 |
6 | /**
7 | * Wallpaper details can be persisted
8 | * */
9 | class Wallpaper private constructor(
10 | val liveWallpaper: Boolean,
11 |
12 | /**
13 | * ID of persisted wallpaper image
14 | *
15 | * Depends on wallpaper type, for normal wallpaper it's a bitmap hashcode,
16 | * for LiveWallpaper it's a ComponentName
17 | *
18 | * @see [com.android.wallpaper.asset.BitmapUtils]
19 | * @see [android.app.WallpaperManager.getWallpaperId]
20 | * @see [android.content.ComponentName]
21 | * */
22 | val id: String
23 | ) {
24 |
25 | fun toJsonString(): String = JSONObject().put("live", liveWallpaper).put("id", id).toString()
26 |
27 | override fun toString(): String = "Wallpaper(liveWallpaper=$liveWallpaper, id='$id')"
28 |
29 | companion object {
30 | @JvmStatic
31 | fun fromLiveWallpaper(liveWallpaper: LiveWallpaperInfo): Wallpaper {
32 | return Wallpaper(true, liveWallpaper.toJsonString())
33 | }
34 |
35 | @JvmStatic
36 | fun fromBitmap(bitmapId: String): Wallpaper = Wallpaper(false, bitmapId)
37 |
38 | @JvmStatic
39 | fun fromJson(json: String): Wallpaper {
40 | val jsonObj = JSONObject(json)
41 | val liveWallpaper = jsonObj.getBoolean("live")
42 | val id = jsonObj.getString("id")
43 | return Wallpaper(liveWallpaper, id)
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/receivers/DarkModeAlarmReceiver.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.receivers
2 |
3 | import android.content.BroadcastReceiver
4 | import android.content.Context
5 | import android.content.Intent
6 | import kotlinx.coroutines.CoroutineScope
7 | import kotlinx.coroutines.Dispatchers
8 | import kotlinx.coroutines.launch
9 | import me.ranko.autodark.Constant
10 | import me.ranko.autodark.Utils.FileUtil
11 | import me.ranko.autodark.core.DarkModeSettings
12 | import java.nio.file.Files
13 |
14 | /**
15 | * Receive dark mode job at scheduled time
16 | *
17 | * Control logic is in [DarkModeSettings]
18 | *
19 | * @see DarkModeSettings.onBoot
20 | * @see DarkModeSettings.onAlarm
21 | *
22 | * @author 0ranko0P
23 | * */
24 | class DarkModeAlarmReceiver : BroadcastReceiver() {
25 |
26 | override fun onReceive(context: Context, intent: Intent) {
27 | DarkModeSettings.getInstance(context).run {
28 | if (intent.action.equals(Intent.ACTION_BOOT_COMPLETED)) {
29 | onBoot()
30 | } else {
31 | onAlarm(intent)
32 | }
33 | }
34 |
35 | if (Files.exists(Constant.BLOCK_LIST_PATH)) {
36 | CoroutineScope(Dispatchers.IO).launch {
37 | val list = FileUtil.readList(Constant.BLOCK_LIST_PATH)
38 | if (list != null && list.isNotEmpty()) {
39 | BlockListReceiver.sendNewList(context, list as ArrayList)
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/ui/ActivationScopeDialog.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.ui
2 |
3 | import android.app.Dialog
4 | import android.content.pm.ActivityInfo
5 | import android.os.Bundle
6 | import android.view.View
7 | import android.view.ViewGroup
8 | import com.android.wallpaper.util.ScreenSizeCalculator
9 | import com.google.android.material.bottomsheet.BottomSheetDialog
10 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment
11 | import com.google.android.material.button.MaterialButton
12 | import me.ranko.autodark.R
13 | import me.ranko.autodark.ui.widget.XposedManagerView
14 |
15 | class ActivationScopeDialog : BottomSheetDialogFragment() {
16 |
17 | private lateinit var managerView: XposedManagerView
18 |
19 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
20 | val dialog = BottomSheetDialog(requireContext(), R.style.AppTheme_BottomSheetDialogDayNight)
21 | dialog.setContentView(R.layout.dialog_activation_scope)
22 | dialog.setOnShowListener {
23 | val activity = requireActivity()
24 | val savedOrientation = activity.requestedOrientation
25 | activity.requestedOrientation =
26 | ActivityInfo.SCREEN_ORIENTATION_LOCKED.or(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
27 |
28 | val root = dialog.findViewById(R.id.title)!!.parent as View
29 | val xposedContainer: ViewGroup = root.findViewById(R.id.container)
30 | managerView = XposedManagerView(requireActivity(), xposedContainer)
31 | root.findViewById(R.id.button).setOnClickListener {
32 | dismiss()
33 | activity.requestedOrientation = savedOrientation
34 | }
35 |
36 | val screenSize = ScreenSizeCalculator.getInstance().getScreenSize(requireActivity())
37 | dialog.behavior.peekHeight = screenSize.y
38 | }
39 | return dialog
40 | }
41 |
42 | override fun onDestroyView() {
43 | super.onDestroyView()
44 | managerView.destroy()
45 | }
46 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/ui/ApplicationIconLoader.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.ui
2 |
3 | import android.content.Context
4 | import android.content.pm.PackageManager
5 | import android.graphics.drawable.Drawable
6 | import com.bumptech.glide.Priority
7 | import com.bumptech.glide.load.DataSource
8 | import com.bumptech.glide.load.Options
9 | import com.bumptech.glide.load.data.DataFetcher
10 | import com.bumptech.glide.load.model.ModelLoader
11 | import com.bumptech.glide.load.model.ModelLoaderFactory
12 | import com.bumptech.glide.load.model.MultiModelLoaderFactory
13 | import com.bumptech.glide.signature.ObjectKey
14 | import me.ranko.autodark.model.BlockableApplication
15 |
16 | class ApplicationIconLoader(val packageManager: PackageManager) : ModelLoader {
17 |
18 | override fun buildLoadData(model: BlockableApplication, width: Int, height: Int, options: Options): ModelLoader.LoadData {
19 | return ModelLoader.LoadData(ObjectKey(model), ApplicationIconDataFetcher(packageManager, model))
20 | }
21 |
22 | override fun handles(model: BlockableApplication): Boolean = true
23 |
24 | class ApplicationIconDataFetcher(private val packageManager: PackageManager,
25 | private val app: BlockableApplication): DataFetcher {
26 | override fun loadData(priority: Priority, callback: DataFetcher.DataCallback) {
27 | val icon = packageManager.getApplicationIcon(app)
28 | if (app.isPrimaryUser()) {
29 | callback.onDataReady(icon)
30 | } else {
31 | callback.onDataReady(packageManager.getUserBadgedIcon(icon, app.user!!))
32 | }
33 | }
34 |
35 | override fun cleanup() {
36 | // no-op
37 | }
38 |
39 | override fun cancel() {
40 | // no-op
41 | }
42 |
43 | override fun getDataClass(): Class = Drawable::class.java
44 |
45 | override fun getDataSource(): DataSource = DataSource.LOCAL
46 | }
47 |
48 | class ApplicationIconFactory(context: Context): ModelLoaderFactory {
49 |
50 | private val packageManager: PackageManager = context.applicationContext.packageManager
51 |
52 | override fun build(multiFactory: MultiModelLoaderFactory): ModelLoader {
53 | return ApplicationIconLoader(packageManager)
54 | }
55 |
56 | override fun teardown() {
57 | // no-op
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/ui/BaseListActivity.kt:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.ui
2 |
3 | import android.os.Build
4 | import android.os.Bundle
5 | import android.view.View
6 | import androidx.appcompat.app.AppCompatActivity
7 | import androidx.core.view.OnApplyWindowInsetsListener
8 | import androidx.core.view.ViewCompat
9 | import androidx.core.view.WindowInsetsCompat
10 | import androidx.core.view.updatePadding
11 | import me.ranko.autodark.Utils.ViewUtil
12 |
13 | abstract class BaseListActivity : AppCompatActivity(), OnApplyWindowInsetsListener {
14 |
15 | protected var bottomNavHeight = 0
16 | protected var statusBarHeight = 0
17 |
18 | protected val isLandScape by lazy(LazyThreadSafetyMode.NONE) {
19 | ViewUtil.isLandscape(this) // avoid null resource
20 | }
21 |
22 | override fun onCreate(savedInstanceState: Bundle?) {
23 | super.onCreate(savedInstanceState)
24 | if (isLandScape.not()) {
25 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
26 | window.setDecorFitsSystemWindows(false)
27 | } else {
28 | getRootView().systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE.or(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
29 | }
30 | }
31 | ViewCompat.setOnApplyWindowInsetsListener(window!!.decorView.rootView, this)
32 | }
33 |
34 | override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat? {
35 | v.setOnApplyWindowInsetsListener(null)
36 | val systemBarInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars())
37 | bottomNavHeight = systemBarInsets.bottom
38 | statusBarHeight = systemBarInsets.top
39 | if (isLandScape.not()) {
40 | applyInsetsToListPadding(statusBarHeight, bottomNavHeight)
41 | }
42 | return WindowInsetsCompat.CONSUMED
43 | }
44 |
45 | open fun applyInsetsToListPadding(top: Int, bottom: Int) {
46 | getAppbar()?.updatePadding(top = top)
47 | getListView()?.apply {
48 | updatePadding(top = paddingTop + top, bottom = paddingBottom + bottom)
49 | }
50 | }
51 |
52 | abstract fun getAppbar(): View?
53 |
54 | abstract fun getRootView(): View
55 |
56 | abstract fun getListView(): View?
57 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/ui/Preference/DarkSwitchPreference.java:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.ui.Preference;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 |
7 | import androidx.preference.PreferenceViewHolder;
8 | import androidx.preference.SwitchPreference;
9 |
10 | public class DarkSwitchPreference extends SwitchPreference {
11 |
12 | private View switchView;
13 | private boolean isSwitchable;
14 |
15 | public DarkSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
16 | super(context, attrs, defStyleAttr, defStyleRes);
17 | }
18 |
19 | public DarkSwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
20 | super(context, attrs, defStyleAttr);
21 | }
22 |
23 | public DarkSwitchPreference(Context context, AttributeSet attrs) {
24 | super(context, attrs);
25 | }
26 |
27 | public DarkSwitchPreference(Context context) {
28 | super(context);
29 | }
30 |
31 | @Override
32 | public void onBindViewHolder(PreferenceViewHolder holder) {
33 | super.onBindViewHolder(holder);
34 | switchView = holder.findViewById(android.R.id.switch_widget);
35 | if (!isSwitchable) {
36 | switchView.setVisibility(View.GONE);
37 | }
38 | }
39 |
40 | public boolean isSwitchable() {
41 | return isSwitchable;
42 | }
43 |
44 | public void setSwitchable(boolean switchable) {
45 | isSwitchable = switchable;
46 | if (switchView != null) {
47 | switchView.setVisibility(switchable ? View.VISIBLE : View.INVISIBLE);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/ui/widget/CheckedImageView.java:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.ui.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.Checkable;
6 | import android.widget.ImageView;
7 |
8 | import androidx.annotation.Nullable;
9 |
10 | /**
11 | * CheckedImageView
12 | *
13 | * From https://github.com/RikkaApps/Shizuku commit 6615c55fee84558faceae352e0480365cbd1f172
14 | * */
15 | public class CheckedImageView extends ImageView implements Checkable {
16 |
17 | private boolean mChecked = true;
18 |
19 | private static final int[] CHECKED_STATE_SET = {
20 | android.R.attr.state_checked
21 | };
22 |
23 | public CheckedImageView(Context context) {
24 | super(context);
25 | }
26 |
27 | public CheckedImageView(Context context, @Nullable AttributeSet attrs) {
28 | super(context, attrs);
29 | }
30 |
31 | public CheckedImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
32 | super(context, attrs, defStyleAttr);
33 | }
34 |
35 | public CheckedImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
36 | super(context, attrs, defStyleAttr, defStyleRes);
37 | }
38 |
39 | @Override
40 | public void setChecked(boolean checked) {
41 | if (mChecked != checked) {
42 | mChecked = checked;
43 | refreshDrawableState();
44 | }
45 | }
46 |
47 | @Override
48 | public boolean isChecked() {
49 | return mChecked;
50 | }
51 |
52 | @Override
53 | public void toggle() {
54 | setChecked(!mChecked);
55 | }
56 |
57 | @Override
58 | public int[] onCreateDrawableState(int extraSpace) {
59 | final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
60 | if (isChecked()) {
61 | mergeDrawableStates(drawableState, CHECKED_STATE_SET);
62 | }
63 | return drawableState;
64 | }
65 | }
--------------------------------------------------------------------------------
/app/src/main/java/me/ranko/autodark/ui/widget/MeasuredViewPager.java:
--------------------------------------------------------------------------------
1 | package me.ranko.autodark.ui.widget;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.viewpager.widget.ViewPager;
10 |
11 | public final class MeasuredViewPager extends ViewPager {
12 |
13 | public MeasuredViewPager(@NonNull Context context) {
14 | this(context, null);
15 | }
16 |
17 | public MeasuredViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
18 | super(context, attrs);
19 | }
20 |
21 | @Override
22 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
23 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
24 | int height = 0;
25 | int childWidthSpec = MeasureSpec.makeMeasureSpec(
26 | Math.max(0, MeasureSpec.getSize(widthMeasureSpec) -
27 | getPaddingLeft() - getPaddingRight()),
28 | MeasureSpec.getMode(widthMeasureSpec)
29 | );
30 | for (int i = 0; i < getChildCount(); i++) {
31 | View child = getChildAt(i);
32 | child.measure(childWidthSpec, MeasureSpec.UNSPECIFIED);
33 | int h = child.getMeasuredHeight();
34 | if (h > height) height = h;
35 | }
36 |
37 | if (height != 0) {
38 | heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
39 | }
40 |
41 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
42 | }
43 | }
--------------------------------------------------------------------------------
/app/src/main/res/anim/do_not_move.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_in.xml:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/fade_out.xml:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/item_shift_vertical.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/major_a_b_dot_01_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/major_a_b_dot_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/major_b_a_dot_01_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/major_b_a_dot_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/major_b_c_dot_01_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/major_b_c_dot_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/major_c_b_dot_01_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/major_c_b_dot_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/minor_a_b_dot_02_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/minor_b_a_dot_02_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/minor_b_c_dot_02_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/minor_c_b_dot_02_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/rotate_infinite.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/color/bottom_action_button_color_tint.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
21 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/color/indicator_arrow_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
21 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-nodpi/kyaru.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/drawable-nodpi/kyaru.webp
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/btn_expand_material_anim_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
14 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/card_btn_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | -
10 |
11 |
12 |
13 | -
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_adb.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_back.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_back_24px.xml:
--------------------------------------------------------------------------------
1 |
16 |
21 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_arrow_forward_24px.xml:
--------------------------------------------------------------------------------
1 |
16 |
21 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_attention.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_auto_dark.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_clear_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
17 |
23 |
24 |
25 |
26 |
27 |
34 |
35 |
36 |
37 |
38 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_close_gm2_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_code.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_dark_theme.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
23 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_delete.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_done_gm2_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_expand_less_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_expand_less_to_more_animation_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_expand_more_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_expand_more_to_less_animation_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_extension.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_grant.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_home_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_info_gm2_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_keyboard.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_lock_outline_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_more.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_off.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_on.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_pan_zoom_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_restart.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_root.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_save.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_shizuku.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
16 |
20 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_smartphone_24px.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/major_a_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
25 |
29 |
31 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/major_a_b_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
23 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/major_b_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
25 |
29 |
31 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/major_b_a_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
23 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/major_b_c.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
25 |
29 |
31 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/major_b_c_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
23 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/major_c_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
25 |
29 |
31 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/major_c_b_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
23 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/material_button_outline_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/material_button_outline_background_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/material_button_outline_foreground.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/minor_a_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
24 |
28 |
30 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/minor_a_b_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/minor_b_a.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
24 |
28 |
30 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/minor_b_a_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/minor_b_c.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
24 |
28 |
30 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/minor_b_c_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/minor_c_b.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
24 |
28 |
30 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/minor_c_b_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_btn_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_circle_icon_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/appbar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
20 |
21 |
29 |
30 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/content_main_scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
20 |
21 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
11 |
12 |
13 |
18 |
19 |
21 |
22 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_permission.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
20 |
21 |
24 |
25 |
28 |
29 |
30 |
31 |
37 |
38 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_preview.xml:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/appbar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/card_wallpaper.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main_scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_permission_shizuku_card.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
26 |
27 |
33 |
34 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_activation_scope.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
29 |
30 |
36 |
37 |
44 |
45 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_edit_package.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_set_wallpaper.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
28 |
29 |
34 |
35 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_wallpaper_choose_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
21 |
22 |
29 |
30 |
31 |
37 |
38 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/full_preview_tabs.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
30 |
31 |
36 |
37 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_block_list_minimum.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_license.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
10 |
11 |
12 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/license_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
18 |
19 |
26 |
27 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/preview_wallpaper.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recycler_live_wallpaper.xml:
--------------------------------------------------------------------------------
1 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/section_header.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
24 |
33 |
34 |
40 |
41 |
42 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_block_list.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
12 |
13 |
19 |
20 |
21 |
26 |
27 |
32 |
33 |
38 |
39 |
40 |
45 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_dark_wallpaper.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-land-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @color/dark_blue_gray
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values-land/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | @color/material_white_1000
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 256dp
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #BB86FC
4 | #3700B3
5 | #03DAC6
6 | #121212
7 | #E0181B20
8 | @color/appbar_background
9 | @color/material_grey_200
10 | @color/dark_blue_gray
11 | @color/dark_blue_gray
12 | @color/white_54_alpha
13 |
14 | @color/material_black_1000
15 | @color/white_54_alpha
16 | @color/google_grey900
17 | @color/full_preview_tab_unselected_text_color
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
13 |
14 |
18 |
19 |
22 |
23 |
26 |
27 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - android
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.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 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC6
6 | #BDBDBD
7 | @color/white_88_alpha
8 | @color/google_blue_50
9 | @color/material_white_1000
10 | @color/material_grey_600
11 | #516200EE
12 |
13 | #1A73E8
14 | #E8F0FE
15 |
16 | #202124
17 | #181B20
18 |
19 | #8AFFFFFF
20 | #E0FFFFFF
21 |
22 | #2d2d2d
23 | @color/material_white_1000
24 | @color/material_grey_700
25 |
26 |
27 | #99000000
28 | @color/translucent_black_60_alpha
29 |
30 | #F5F5F5
31 | #8C000000
32 |
33 | #32000000
34 | @android:color/darker_gray
35 | @color/fullscreen_preview_background
36 | @color/material_white_1000
37 |
38 | #DE000000
39 | #B0000000
40 | @android:color/transparent
41 |
42 | #43000000
43 | @color/translucent_black
44 |
--------------------------------------------------------------------------------
/app/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings_no_translate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | %1$s (%2$d )
4 | AutoDark
5 | https://github.com/0ranko0P/AutoDark
6 | https://github.com/0ranko0P/AutoDark/issues
7 | ranko0p@outlook.com
8 |
9 | Atrate, Frauhottelmann, Ranko0P
10 | prefAbout
11 | prefTime
12 | \n----------------
13 | Apache 2.0
14 | https://www.apache.org/licenses/LICENSE-2.0.txt
15 | %1$s : %2$s .
16 | Shizuku
17 | Sui
18 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preferences_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
10 |
11 |
14 |
17 |
18 |
19 |
22 |
23 |
27 |
28 |
31 |
32 |
33 |
34 |
38 |
39 |
40 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preferences_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
12 |
13 |
18 |
19 |
26 |
27 |
32 |
33 |
34 |
35 |
42 |
43 |
49 |
50 |
51 |
54 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext {
5 | ver_appcompat = '1.4.1'
6 | ver_activity = '1.4.0'
7 | ver_core = '1.7.0'
8 | ver_glide = '4.12.0'
9 | ver_gradle = '7.0.4'
10 | ver_hiddenapi = '4.2'
11 | ver_leak = "2.8.1"
12 | ver_license ="1.0.0"
13 | ver_lifecycle_extensions = "2.4.0"
14 | ver_kotlin = '1.6.10'
15 | ver_kotlin_coroutines = "1.6.0"
16 | ver_material = "1.5.0"
17 | ver_navigation = '2.1.0-beta02'
18 | ver_preference = "1.2.0-rc01"
19 | ver_rikka_design = "3.1.8"
20 | ver_sunrise_cal = "1.2"
21 | ver_timber = "5.0.1"
22 | ver_junit = "4.13.2"
23 | ver_xposed = "82"
24 |
25 | // Shizuku manifest
26 | apply from: 'Shizuku-API/manifest.gradle'
27 | }
28 |
29 | repositories {
30 | google()
31 | jcenter()
32 | }
33 |
34 | dependencies {
35 | classpath "com.android.tools.build:gradle:$ver_gradle"
36 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$ver_kotlin"
37 | // NOTE: Do not place your application dependencies here; they belong
38 | // in the individual module build.gradle files
39 | }
40 | }
41 |
42 | allprojects {
43 | repositories {
44 | google()
45 | jcenter()
46 | maven { url 'https://jitpack.io' }
47 | }
48 | }
49 |
50 | task clean(type: Delete) {
51 | delete rootProject.buildDir
52 | }
53 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/full_description.txt:
--------------------------------------------------------------------------------
1 | A small app to let you schedule dark mode.
2 |
3 | System requirements
4 | * At least Android 10.
5 | * OEM builds are not supported e.g. Flyme.
6 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/featureGraphic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/fastlane/metadata/android/en-US/images/featureGraphic.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/fastlane/metadata/android/en-US/images/icon.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_1.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_2.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_3.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_4.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/fastlane/metadata/android/en-US/images/phoneScreenshots/Screenshot_5.png
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/short_description.txt:
--------------------------------------------------------------------------------
1 | Utility to schedule system dark mode.
2 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/en-US/title.txt:
--------------------------------------------------------------------------------
1 | AutoDark
2 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/zh-CN/full_description.txt:
--------------------------------------------------------------------------------
1 | 一个帮你自动设定暗黑模式的小应用
2 |
3 | 系统要求
4 | * 最低版本Android 10.
5 | * 不支持订制系统,比如Flyme.
6 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/zh-CN/short_description.txt.txt:
--------------------------------------------------------------------------------
1 | 自动设定暗黑模式的工具.
2 |
--------------------------------------------------------------------------------
/fastlane/metadata/android/zh-CN/title.txt:
--------------------------------------------------------------------------------
1 | AutoDark
2 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 | # Enable more aggressive optimizations
23 | android.enableR8.fullMode=true
24 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0ranko0P/AutoDark/c59bae15f3e89b5f768d71d937539b498f405e9a/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 03 19:44:38 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
7 | # Remove this if not building on fdroid
8 | distributionSha256Sum=0e46229820205440b48a5501122002842b82886e76af35f0f3a069243dca4b3c
9 |
--------------------------------------------------------------------------------
/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 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
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 Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/hidden-api-dark/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/hidden-api-dark/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | sourceCompatibility = "1.8"
4 | targetCompatibility = "1.8"
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/annotation/NonNull.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package android.annotation;
17 |
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.Target;
20 |
21 | import static java.lang.annotation.ElementType.FIELD;
22 | import static java.lang.annotation.ElementType.METHOD;
23 | import static java.lang.annotation.ElementType.PARAMETER;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * Denotes that a parameter, field or method return value can never be null.
28 | *
29 | * This is a marker annotation and it has no specific attributes.
30 | *
31 | * @paramDoc This value must never be {@code null}.
32 | * @returnDoc This value will never be {@code null}.
33 | * @hide
34 | */
35 | @Retention(SOURCE)
36 | @Target({METHOD, PARAMETER, FIELD})
37 | public @interface NonNull {
38 | }
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/annotation/Nullable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package android.annotation;
17 |
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.Target;
20 |
21 | import static java.lang.annotation.ElementType.FIELD;
22 | import static java.lang.annotation.ElementType.METHOD;
23 | import static java.lang.annotation.ElementType.PARAMETER;
24 | import static java.lang.annotation.RetentionPolicy.SOURCE;
25 |
26 | /**
27 | * Denotes that a parameter, field or method return value can be null.
28 | *
29 | * When decorating a method call parameter, this denotes that the parameter can
30 | * legitimately be null and the method will gracefully deal with it. Typically
31 | * used on optional parameters.
32 | *
33 | * When decorating a method, this denotes the method might legitimately return
34 | * null.
35 | *
36 | * This is a marker annotation and it has no specific attributes.
37 | *
38 | * @paramDoc This value may be {@code null}.
39 | * @returnDoc This value may be {@code null}.
40 | */
41 | @Retention(SOURCE)
42 | @Target({METHOD, PARAMETER, FIELD})
43 | public @interface Nullable {
44 | }
45 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/app/IWallpaperManager.java:
--------------------------------------------------------------------------------
1 | package android.app;
2 |
3 | import android.os.Binder;
4 | import android.os.IBinder;
5 | import android.content.ComponentName;
6 | import android.os.IInterface;
7 |
8 | public interface IWallpaperManager extends IInterface {
9 |
10 | // SecurityException
11 | void setWallpaperComponent(ComponentName name);
12 |
13 | abstract class Stub extends Binder implements IWallpaperManager {
14 |
15 | public static IWallpaperManager asInterface(IBinder obj) {
16 | throw new UnsupportedOperationException();
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/content/ComponentName.java:
--------------------------------------------------------------------------------
1 | package android.content;
2 |
3 | import android.annotation.NonNull;
4 |
5 | @SuppressWarnings("ParcelCreator")
6 | public final class ComponentName {
7 |
8 | public ComponentName(@NonNull String pkg, @NonNull String cls) {
9 | throw new RuntimeException("STUB");
10 | }
11 |
12 | public @NonNull String getPackageName() {
13 | throw new RuntimeException("STUB");
14 | }
15 |
16 | public @NonNull String getClassName() {
17 | throw new RuntimeException("STUB");
18 | }
19 | }
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/content/pm/BaseParceledListSlice.java:
--------------------------------------------------------------------------------
1 | package android.content.pm;
2 |
3 | import java.util.List;
4 |
5 | abstract class BaseParceledListSlice {
6 |
7 | public List getList() {
8 | throw new RuntimeException("STUB");
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/content/pm/IPackageManager.java:
--------------------------------------------------------------------------------
1 | package android.content.pm;
2 |
3 | import android.os.Binder;
4 | import android.os.IBinder;
5 | import android.os.IInterface;
6 | import android.os.RemoteException;
7 |
8 | public interface IPackageManager extends IInterface {
9 |
10 | PackageInfo getPackageInfo(String packageName, int flags, int userId)
11 | throws RemoteException;
12 |
13 | int getPackageUid(String packageName, int userId)
14 | throws RemoteException;
15 |
16 | int getPackageUid(String packageName, int flags, int userId)
17 | throws RemoteException;
18 |
19 | String[] getPackagesForUid(int uid)
20 | throws RemoteException;
21 |
22 | ParceledListSlice getInstalledPackages(int flags, int userId) throws RemoteException;
23 |
24 | ParceledListSlice getInstalledApplications(int flags, int userId)
25 | throws RemoteException;
26 |
27 | int getUidForSharedUser(String sharedUserName)
28 | throws RemoteException;
29 |
30 | void grantRuntimePermission(String packageName, String permissionName, int userId)
31 | throws RemoteException;
32 |
33 | void revokeRuntimePermission(String packageName, String permissionName, int userId)
34 | throws RemoteException;
35 |
36 | int getPermissionFlags(String permissionName, String packageName, int userId)
37 | throws RemoteException;
38 |
39 | void updatePermissionFlags(String permissionName, String packageName, int flagMask, int flagValues, int userId)
40 | throws RemoteException;
41 |
42 | void updatePermissionFlags(String permissionName, String packageName, int flagMask, int flagValues, boolean checkAdjustPolicyFlagPermission, int userId)
43 | throws RemoteException;
44 |
45 | int checkPermission(String permName, String pkgName, int userId)
46 | throws RemoteException;
47 |
48 | int checkUidPermission(String permName, int uid)
49 | throws RemoteException;
50 |
51 | abstract class Stub extends Binder implements IPackageManager {
52 |
53 | public static IPackageManager asInterface(IBinder obj) {
54 | throw new UnsupportedOperationException();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/content/pm/PackageInfo.java:
--------------------------------------------------------------------------------
1 | package android.content.pm;
2 |
3 | public class PackageInfo {
4 |
5 | public String overlayTarget;
6 | }
7 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/content/pm/ParceledListSlice.java:
--------------------------------------------------------------------------------
1 | package android.content.pm;
2 |
3 | public class ParceledListSlice extends BaseParceledListSlice {
4 | }
5 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/os/Binder.java:
--------------------------------------------------------------------------------
1 | package android.os;
2 |
3 | import android.annotation.NonNull;
4 | import android.annotation.Nullable;
5 |
6 | import java.io.FileDescriptor;
7 |
8 | public class Binder implements IBinder {
9 |
10 | @Override
11 | public boolean transact(int code, @NonNull Parcel data, Parcel reply, int flags) {
12 | throw new RuntimeException("STUB");
13 | }
14 |
15 | @Override
16 | public String getInterfaceDescriptor() {
17 | throw new RuntimeException("STUB");
18 | }
19 |
20 | public boolean pingBinder() {
21 | throw new RuntimeException("STUB");
22 | }
23 |
24 | @Override
25 | public boolean isBinderAlive() {
26 | throw new RuntimeException("STUB");
27 | }
28 |
29 | @Override
30 | public IInterface queryLocalInterface(@NonNull String descriptor) {
31 | throw new RuntimeException("STUB");
32 | }
33 |
34 | @Override
35 | public void dump(@NonNull FileDescriptor fd, String[] args) {
36 | throw new RuntimeException("STUB");
37 | }
38 |
39 | @Override
40 | public void dumpAsync(@NonNull FileDescriptor fd, String[] args) {
41 | throw new RuntimeException("STUB");
42 | }
43 |
44 | @Override
45 | public void linkToDeath(@NonNull DeathRecipient recipient, int flags) {
46 | throw new RuntimeException("STUB");
47 | }
48 |
49 | @Override
50 | public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags) {
51 | throw new RuntimeException("STUB");
52 | }
53 |
54 | protected boolean onTransact(int code, @NonNull Parcel data, @Nullable Parcel reply,
55 | int flags) throws RemoteException {
56 | throw new RuntimeException("STUB");
57 | }
58 |
59 | public static native int getCallingPid();
60 |
61 | public static native int getCallingUid();
62 | }
63 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/os/IBinder.java:
--------------------------------------------------------------------------------
1 | package android.os;
2 |
3 | import android.annotation.NonNull;
4 | import android.annotation.Nullable;
5 |
6 | import java.io.FileDescriptor;
7 |
8 | public interface IBinder {
9 |
10 | boolean transact(int code, @NonNull Parcel data, @Nullable Parcel reply, int flags);
11 |
12 | @Nullable
13 | String getInterfaceDescriptor();
14 |
15 | boolean pingBinder();
16 |
17 | boolean isBinderAlive();
18 |
19 | @Nullable
20 | IInterface queryLocalInterface(@NonNull String descriptor);
21 |
22 | void dump(@NonNull FileDescriptor fd, @Nullable String[] args);
23 |
24 | void dumpAsync(@NonNull FileDescriptor fd, @Nullable String[] args);
25 |
26 | void linkToDeath(@NonNull DeathRecipient recipient, int flags);
27 |
28 | boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags);
29 |
30 | interface DeathRecipient {
31 | void binderDied();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/os/IInterface.java:
--------------------------------------------------------------------------------
1 | package android.os;
2 |
3 | public interface IInterface {
4 |
5 | IBinder asBinder();
6 | }
7 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/os/Parcel.java:
--------------------------------------------------------------------------------
1 | package android.os;
2 |
3 | import android.annotation.Nullable;
4 |
5 | public final class Parcel {
6 |
7 | public final int readInt() {
8 | throw new RuntimeException("STUB");
9 | }
10 |
11 | public final long readLong() {
12 | throw new RuntimeException("STUB");
13 | }
14 |
15 | public final float readFloat() {
16 | throw new RuntimeException("STUB");
17 | }
18 |
19 | public final double readDouble() {
20 | throw new RuntimeException("STUB");
21 | }
22 |
23 | @Nullable
24 | public final String readString() {
25 | throw new RuntimeException("STUB");
26 | }
27 |
28 | public final boolean readBoolean() {
29 | throw new RuntimeException("STUB");
30 | }
31 |
32 | public final void writeInt(int val) {
33 | throw new RuntimeException("STUB");
34 | }
35 |
36 | public final void writeLong(long val) {
37 | throw new RuntimeException("STUB");
38 | }
39 |
40 | public final void writeFloat(float val) {
41 | throw new RuntimeException("STUB");
42 | }
43 |
44 | public final void writeDouble(double val) {
45 | throw new RuntimeException("STUB");
46 | }
47 |
48 | public final void writeString(@Nullable String val) {
49 | throw new RuntimeException("STUB");
50 | }
51 |
52 | public final void writeBoolean(boolean val) {
53 | throw new RuntimeException("STUB");
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/os/RemoteException.java:
--------------------------------------------------------------------------------
1 | package android.os;
2 |
3 | public class RemoteException extends Exception {
4 |
5 | public RemoteException(String message) {
6 | throw new RuntimeException("STUB");
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/hidden-api-dark/src/main/java/android/os/SystemProperties.java:
--------------------------------------------------------------------------------
1 | package android.os;
2 |
3 | public class SystemProperties {
4 |
5 | public static String get(String key) {
6 | throw new RuntimeException("STUB");
7 | }
8 |
9 | public static String get(String key, String def) {
10 | throw new RuntimeException("STUB");
11 | }
12 |
13 | public static int getInt(String key, int def) {
14 | throw new RuntimeException("STUB");
15 | }
16 |
17 | public static long getLong(String key, long def) {
18 | throw new RuntimeException("STUB");
19 | }
20 |
21 | public static boolean getBoolean(String key, boolean def) {
22 | throw new RuntimeException("STUB");
23 | }
24 |
25 | public static void set(String key, String val) {
26 | throw new RuntimeException("STUB");
27 | }
28 |
29 | public static void addChangeCallback(Runnable callback) {
30 | throw new RuntimeException("STUB");
31 | }
32 |
33 | public static void reportSyspropChanged() {
34 | throw new RuntimeException("STUB");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | include ':aidl'
3 | project(':aidl').projectDir = new File('Shizuku-API/aidl')
4 | include ':hidden-api-stub'
5 | project(':hidden-api-stub').projectDir = new File('Shizuku-API/hidden-api-stub')
6 | include ':hidden-api-dark'
7 | include ':shared'
8 | project(':shared').projectDir = new File('Shizuku-API/shared')
9 | include ':api'
10 | project(':api').projectDir = new File('Shizuku-API/api')
11 | include ':provider'
12 | project(':provider').projectDir = new File('Shizuku-API/provider')
13 | rootProject.name='AutoDark'
14 |
--------------------------------------------------------------------------------