From 777fb766de366527e12752d8be014db28a3e6c2d Mon Sep 17 00:00:00 2001 From: Artem Umerov Date: Mon, 30 Dec 2024 22:41:20 +0300 Subject: [PATCH] 78 78 --- app_fenrir/build.gradle | 2 +- .../res/drawable-v31/ic_launcher_dynamic.xml | 2 +- .../src/fenrir/res/drawable-v31/splash.xml | 2 +- app_fenrir/src/fenrir/res/drawable/client.xml | 2 +- .../src/fenrir/res/drawable/client_round.xml | 4 +- .../res/drawable/ic_launcher_foreground.xml | 2 +- .../res/drawable/ic_launcher_monochrome.xml | 2 +- app_fenrir/src/fenrir/res/drawable/splash.xml | 2 +- .../res/drawable-v31/ic_launcher_dynamic.xml | 2 +- .../src/kate/res/drawable-v31/splash.xml | 2 +- app_fenrir/src/kate/res/drawable/client.xml | 2 +- .../src/kate/res/drawable/client_round.xml | 4 +- .../res/drawable/ic_launcher_foreground.xml | 2 +- .../res/drawable/ic_launcher_monochrome.xml | 2 +- app_fenrir/src/kate/res/drawable/splash.xml | 2 +- app_fenrir/src/main/AndroidManifest.xml | 2 +- .../kotlin/dev/ragnarok/fenrir/Constants.kt | 4 +- .../fenrir/activity/AccountsActivity.kt | 10 +- .../fenrir/activity/AttachmentsActivity.kt | 4 +- .../fenrir/activity/AudioSelectActivity.kt | 6 +- .../ragnarok/fenrir/activity/ChatActivity.kt | 2 +- .../fenrir/activity/ChatActivityBubbles.kt | 2 +- .../fenrir/activity/CreatePinActivity.kt | 3 +- .../fenrir/activity/DualTabPhotoActivity.kt | 14 +- .../fenrir/activity/EnterPinActivity.kt | 3 +- .../activity/FileManagerSelectActivity.kt | 10 +- .../activity/LocalJsonToChatActivity.kt | 2 +- .../fenrir/activity/LottieActivity.kt | 2 +- .../ragnarok/fenrir/activity/MainActivity.kt | 73 +- .../fenrir/activity/NoMainActivity.kt | 24 +- .../activity/NotReadMessagesActivity.kt | 4 +- .../fenrir/activity/PhotoAlbumsActivity.kt | 4 +- .../fenrir/activity/PhotosActivity.kt | 4 +- .../fenrir/activity/PostCreateActivity.kt | 2 +- .../fenrir/activity/ProxyManagerActivity.kt | 4 +- .../activity/SendAttachmentsActivity.kt | 7 +- .../fenrir/activity/SinglePhotoActivity.kt | 7 +- .../fenrir/activity/SwipebleActivity.kt | 7 +- .../fenrir/activity/VideoPlayerActivity.kt | 18 + .../fenrir/activity/VideoSelectActivity.kt | 6 +- .../activity/gifpager/GifPagerActivity.kt | 7 +- .../activity/photopager/PhotoPagerActivity.kt | 7 +- .../fenrir/activity/qr/CameraScanActivity.kt | 126 +- .../selectprofiles/SelectProfilesActivity.kt | 21 +- .../ShortVideoPagerActivity.kt | 7 +- .../activity/storypager/StoryPagerActivity.kt | 7 +- .../fenrir/api/adapters/AbsDtoAdapter.kt | 2 +- .../fenrir/api/util/ProgressRequestBody.kt | 1 + .../fenrir/fragment/PreferencesFragment.kt | 14 +- .../fragment/accounts/AccountsFragment.kt | 6 +- .../AbsAttachmentsEditFragment.kt | 2 +- .../local/audioslocal/AudiosLocalPresenter.kt | 16 +- .../CommunityBlacklistFragment.kt | 12 +- .../fenrir/fragment/docs/DocsListPresenter.kt | 16 +- .../FriendsByPhonesFragment.kt | 4 +- .../sheet/AttachmentsBottomSheetAdapter.kt | 74 +- .../chat/sheet/MessageAttachmentsFragment.kt | 24 +- .../chat/sheet/MessageAttachmentsPresenter.kt | 17 +- .../fragment/videos/VideosListPresenter.kt | 16 +- .../videos/videoalbums/VideoAlbumsFragment.kt | 4 +- .../fenrir/fragment/wall/AbsWallPresenter.kt | 16 +- .../kotlin/dev/ragnarok/fenrir/place/Place.kt | 5 + .../dev/ragnarok/fenrir/place/PlaceFactory.kt | 22 +- .../fenrir/settings/theme/ThemesController.kt | 54 - .../ragnarok/fenrir/upload/IUploadManager.kt | 1 + .../fenrir/upload/UploadManagerImpl.kt | 41 +- .../kotlinx/serialization/msgpack/MsgPack.kt | 34 +- .../msgpack/MsgPackConfiguration.kt | 2 +- .../msgpack/MsgPackDynamicSerializer.kt | 14 +- .../MsgPackSerializationException.kt | 44 +- .../BaseMsgPackExtensionSerializer.kt | 7 +- .../DynamicMsgPackExtensionSerializer.kt | 6 +- .../msgpack/extensions/MsgPackExtension.kt | 2 +- .../extensions/MsgPackTimestampExtension.kt | 73 +- .../msgpack/internal/MsgPackDecoder.kt | 10 +- .../msgpack/internal/MsgPackEncoder.kt | 134 +- .../msgpack/internal/MsgPacker.kt | 119 +- .../msgpack/internal/MsgUnpacker.kt | 208 +- .../msgpack/stream/MsgPackDataBuffer.kt | 110 +- .../msgpack/types/MsgPackType.kt | 124 +- .../msgpack/utils/ByteArrayUtils.kt | 26 +- .../res/drawable-v31/ic_fenrir_dynamic2.xml | 2 +- .../res/drawable-v31/ic_valknut_dynamic.xml | 4 +- .../src/main/res/drawable/client_round_vk.xml | 4 +- .../drawable/hand_point_up_left_outline.xml | 12 + .../src/main/res/drawable/ic_fenrir_black.xml | 2 +- .../src/main/res/drawable/ic_fenrir_blue.xml | 2 +- .../ic_fenrir_dynamic2_monochrome.xml | 2 +- .../src/main/res/drawable/ic_fenrir_green.xml | 2 +- .../main/res/drawable/ic_fenrir_lineage.xml | 2 +- .../src/main/res/drawable/ic_fenrir_red.xml | 2 +- .../main/res/drawable/ic_fenrir_violet.xml | 2 +- .../src/main/res/drawable/ic_fenrir_white.xml | 2 +- .../main/res/drawable/ic_fenrir_yellow.xml | 4 +- .../src/main/res/drawable/ic_logo_vk.xml | 2 +- .../res/drawable/ic_logo_vk_monochrome.xml | 2 +- .../ic_valknut_dynamic_monochrome.xml | 2 +- app_fenrir/src/main/res/drawable/splash.xml | 12 - .../main/res/layout/activity_camera_scan.xml | 12 +- ...hoto.xml => activity_single_url_photo.xml} | 0 .../res/layout/message_attachments_entry.xml | 3 - .../src/main/res/values-night/styles.xml | 186 -- app_fenrir/src/main/res/values/styles.xml | 132 -- app_filegallery/build.gradle | 2 +- app_filegallery/src/main/AndroidManifest.xml | 2 +- .../filegallery/activity/CreatePinActivity.kt | 3 +- .../filegallery/activity/EnterPinActivity.kt | 3 +- .../activity/FileManagerSelectActivity.kt | 10 +- .../filegallery/activity/MainActivity.kt | 33 +- .../filegallery/activity/NoMainActivity.kt | 20 +- .../activity/VideoPlayerActivity.kt | 12 + .../activity/photopager/PhotoPagerActivity.kt | 8 +- .../activity/qr/CameraScanActivity.kt | 122 +- .../filegallery/api/adapters/AbsDtoAdapter.kt | 2 +- .../fragment/PreferencesFragment.kt | 10 +- .../filemanager/FileManagerPresenter.kt | 16 +- .../dev/ragnarok/filegallery/place/Place.kt | 5 + .../filegallery/place/PlaceFactory.kt | 8 +- .../settings/theme/ThemesController.kt | 54 - .../filegallery/upload/IUploadManager.kt | 1 + .../filegallery/upload/UploadManagerImpl.kt | 21 +- .../kotlinx/serialization/msgpack/MsgPack.kt | 34 +- .../msgpack/MsgPackConfiguration.kt | 2 +- .../msgpack/MsgPackDynamicSerializer.kt | 14 +- .../MsgPackSerializationException.kt | 44 +- .../BaseMsgPackExtensionSerializer.kt | 7 +- .../DynamicMsgPackExtensionSerializer.kt | 6 +- .../msgpack/extensions/MsgPackExtension.kt | 2 +- .../extensions/MsgPackTimestampExtension.kt | 73 +- .../msgpack/internal/MsgPackDecoder.kt | 10 +- .../msgpack/internal/MsgPackEncoder.kt | 134 +- .../msgpack/internal/MsgPacker.kt | 119 +- .../msgpack/internal/MsgUnpacker.kt | 208 +- .../msgpack/stream/MsgPackDataBuffer.kt | 110 +- .../msgpack/types/MsgPackType.kt | 124 +- .../msgpack/utils/ByteArrayUtils.kt | 26 +- .../src/main/res/drawable/client_round.xml | 4 +- .../drawable/hand_point_up_left_outline.xml | 12 + .../res/drawable/ic_launcher_foreground.xml | 2 +- .../res/drawable/ic_launcher_monochrome.xml | 2 +- .../src/main/res/drawable/splash.xml | 2 +- .../main/res/layout/activity_camera_scan.xml | 12 +- .../src/main/res/values-night/styles.xml | 162 -- .../src/main/res/values/styles.xml | 120 -- build.gradle | 10 +- camera2/build.gradle | 2 +- fenrir_common/build.gradle | 2 +- firebase-installations/build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- image/build.gradle | 2 +- libfenrir/build.gradle | 2 +- libfenrir/ffmpeg.sh | 3 +- .../jni/animation/libyuv/include/libyuv/row.h | 208 ++ .../animation/libyuv/include/libyuv/row_sve.h | 1735 +++++++++++++++++ .../animation/libyuv/include/libyuv/scale.h | 15 + .../libyuv/include/libyuv/scale_row.h | 54 +- .../jni/animation/libyuv/source/convert.cc | 20 + .../animation/libyuv/source/convert_argb.cc | 225 +++ .../libyuv/source/convert_from_argb.cc | 25 + .../libyuv/source/planar_functions.cc | 35 + .../jni/animation/libyuv/source/rotate.cc | 5 + .../animation/libyuv/source/rotate_argb.cc | 5 + .../jni/animation/libyuv/source/row_sme.cc | 939 ++++++++- .../jni/animation/libyuv/source/row_sve.cc | 1561 +-------------- .../main/jni/animation/libyuv/source/scale.cc | 59 + .../jni/animation/libyuv/source/scale_argb.cc | 28 + .../animation/libyuv/source/scale_common.cc | 15 + .../jni/animation/libyuv/source/scale_sme.cc | 264 +++ .../jni/animation/libyuv/source/scale_uv.cc | 10 + .../main/jni/animation/thorvg/inc/thorvg.h | 41 +- .../lottie/rapidjson/internal/strtod.h | 2 +- .../thorvg/src/loaders/lottie/thorvg_lottie.h | 4 +- .../src/loaders/lottie/tvgLottieAnimation.cpp | 20 +- .../src/loaders/lottie/tvgLottieBuilder.cpp | 237 ++- .../src/loaders/lottie/tvgLottieBuilder.h | 7 +- .../src/loaders/lottie/tvgLottieLoader.cpp | 6 +- .../src/loaders/lottie/tvgLottieModel.h | 86 +- .../src/loaders/lottie/tvgLottieParser.cpp | 128 +- .../src/loaders/lottie/tvgLottieParser.h | 3 + .../src/loaders/lottie/tvgLottieProperty.h | 4 +- .../thorvg/src/loaders/raw/tvgRawLoader.cpp | 8 - .../thorvg/src/loaders/svg/tvgSvgPath.cpp | 4 +- .../src/loaders/svg/tvgSvgSceneBuilder.cpp | 4 +- .../src/renderer/sw_engine/tvgSwCommon.h | 9 +- .../src/renderer/sw_engine/tvgSwFill.cpp | 33 +- .../src/renderer/sw_engine/tvgSwMath.cpp | 3 - .../renderer/sw_engine/tvgSwPostEffect.cpp | 127 ++ .../src/renderer/sw_engine/tvgSwRaster.cpp | 30 +- .../src/renderer/sw_engine/tvgSwRenderer.cpp | 32 +- .../src/renderer/sw_engine/tvgSwRle.cpp | 12 +- .../src/renderer/sw_engine/tvgSwShape.cpp | 12 - .../src/renderer/sw_engine/tvgSwStroke.cpp | 11 +- .../thorvg/src/renderer/tvgAccessor.cpp | 14 +- .../thorvg/src/renderer/tvgAnimation.cpp | 19 +- .../thorvg/src/renderer/tvgCanvas.cpp | 6 +- .../animation/thorvg/src/renderer/tvgCanvas.h | 9 +- .../animation/thorvg/src/renderer/tvgCommon.h | 5 +- .../animation/thorvg/src/renderer/tvgFill.cpp | 121 +- .../animation/thorvg/src/renderer/tvgFill.h | 143 +- .../thorvg/src/renderer/tvgGlCanvas.cpp | 36 +- .../thorvg/src/renderer/tvgIteratorAccessor.h | 2 +- .../thorvg/src/renderer/tvgPaint.cpp | 121 +- .../animation/thorvg/src/renderer/tvgPaint.h | 109 +- .../thorvg/src/renderer/tvgPicture.cpp | 138 +- .../thorvg/src/renderer/tvgPicture.h | 163 +- .../thorvg/src/renderer/tvgRender.cpp | 8 - .../animation/thorvg/src/renderer/tvgRender.h | 49 +- .../thorvg/src/renderer/tvgScene.cpp | 69 +- .../animation/thorvg/src/renderer/tvgScene.h | 82 +- .../thorvg/src/renderer/tvgShape.cpp | 176 +- .../animation/thorvg/src/renderer/tvgShape.h | 172 +- .../thorvg/src/renderer/tvgSwCanvas.cpp | 39 +- .../animation/thorvg/src/renderer/tvgText.cpp | 28 +- .../animation/thorvg/src/renderer/tvgText.h | 48 +- .../thorvg/src/renderer/tvgWgCanvas.cpp | 30 +- .../animation/thorvg/thorvg-1.0-pre8.tar.gz | Bin 639519 -> 0 bytes .../animation/thorvg/thorvg-1.0-pre9.tar.gz | Bin 0 -> 1349207 bytes .../jni/audio/taglib/mpeg/id3v2/id3v2tag.cpp | 40 +- .../jni/audio/taglib/toolkit/tbytevector.cpp | 55 +- .../main/jni/audio/taglib/toolkit/tutils.h | 7 +- material/build.gradle | 4 +- .../appbar/CollapsingToolbarLayout.java | 74 +- .../appbar/res-public/values/public.xml | 2 - .../material/appbar/res/values/attrs.xml | 48 - .../BottomSheetDragHandleView.java | 14 - .../bottomsheet/res/values/strings.xml | 1 - .../material/button/MaterialButton.java | 9 +- .../button/res-public/values/public.xml | 1 + .../material/button/res/values/styles.xml | 4 +- .../material/carousel/Arrangement.java | 3 + .../android/material/carousel/Carousel.java | 3 + .../carousel/CarouselLayoutManager.java | 8 + .../material/carousel/CarouselStrategy.java | 4 + .../material/carousel/KeylineState.java | 3 + .../material/carousel/KeylineStateList.java | 3 + .../google/android/material/chip/Chip.java | 2 + .../android/material/chip/ChipDrawable.java | 8 + .../dialog/res/values/themes_base.xml | 14 + .../FloatingToolbarLayout.java | 2 +- .../res-public/values/public.xml | 7 +- .../floatingtoolbar/res/values/attrs.xml | 5 +- .../floatingtoolbar/res/values/styles.xml | 83 +- .../floatingtoolbar/res/values/tokens.xml | 1 - .../android/material/motion/MotionUtils.java | 38 + .../motion/res-public/values/public.xml | 8 + .../material/motion/res/values/attrs.xml | 31 +- .../material/motion/res/values/styles.xml | 42 + .../material/motion/res/values/tokens.xml | 16 +- .../material/navigation/DividerMenuItem.java | 265 +++ .../navigation/NavigationBarDividerView.java | 129 ++ .../navigation/NavigationBarMenuBuilder.java | 18 +- .../navigation/NavigationBarMenuView.java | 44 +- .../res/layout/m3_navigation_menu_divider.xml | 25 + .../layout/m3_navigation_menu_subheader.xml | 2 +- .../material/navigation/res/values/dimens.xml | 4 +- .../NavigationRailMenuView.java | 3 +- .../navigationrail/NavigationRailView.java | 33 +- .../res-public/values/public.xml | 1 + .../navigationrail/res/values/attrs.xml | 2 + .../material/theme/res/values/themes_base.xml | 14 + picasso3/build.gradle | 2 +- preference/build.gradle | 2 +- recyclerview/build.gradle | 2 +- 263 files changed, 7647 insertions(+), 4724 deletions(-) create mode 100644 app_fenrir/src/main/res/drawable/hand_point_up_left_outline.xml delete mode 100644 app_fenrir/src/main/res/drawable/splash.xml rename app_fenrir/src/main/res/layout/{fragment_single_url_photo.xml => activity_single_url_photo.xml} (100%) create mode 100644 app_filegallery/src/main/res/drawable/hand_point_up_left_outline.xml create mode 100644 libfenrir/src/main/jni/animation/libyuv/include/libyuv/row_sve.h delete mode 100644 libfenrir/src/main/jni/animation/thorvg/thorvg-1.0-pre8.tar.gz create mode 100644 libfenrir/src/main/jni/animation/thorvg/thorvg-1.0-pre9.tar.gz create mode 100644 material/java/com/google/android/material/motion/res/values/styles.xml create mode 100644 material/java/com/google/android/material/navigation/DividerMenuItem.java create mode 100644 material/java/com/google/android/material/navigation/NavigationBarDividerView.java create mode 100644 material/java/com/google/android/material/navigation/res/layout/m3_navigation_menu_divider.xml diff --git a/app_fenrir/build.gradle b/app_fenrir/build.gradle index f4d1246cf..05ebd251c 100644 --- a/app_fenrir/build.gradle +++ b/app_fenrir/build.gradle @@ -5,7 +5,7 @@ plugins { } android { - namespace "dev.ragnarok.fenrir" + namespace = "dev.ragnarok.fenrir" buildFeatures { aidl = true buildConfig = true diff --git a/app_fenrir/src/fenrir/res/drawable-v31/ic_launcher_dynamic.xml b/app_fenrir/src/fenrir/res/drawable-v31/ic_launcher_dynamic.xml index e9f87cdc5..042a29e8a 100644 --- a/app_fenrir/src/fenrir/res/drawable-v31/ic_launcher_dynamic.xml +++ b/app_fenrir/src/fenrir/res/drawable-v31/ic_launcher_dynamic.xml @@ -7,7 +7,7 @@ android:viewportWidth="108" android:viewportHeight="108"> diff --git a/app_fenrir/src/fenrir/res/drawable/client_round.xml b/app_fenrir/src/fenrir/res/drawable/client_round.xml index 7405d50bc..590208878 100644 --- a/app_fenrir/src/fenrir/res/drawable/client_round.xml +++ b/app_fenrir/src/fenrir/res/drawable/client_round.xml @@ -8,9 +8,9 @@ + android:pathData="M1.5,18.001C1.5,8.886 8.886,1.5 17.998,1.5 27.114,1.5 34.5,8.886 34.5,18.001 34.5,27.114 27.114,34.5 17.998,34.5 8.886,34.5 1.5,27.114 1.5,18.001ZM1.5,18.001" /> diff --git a/app_fenrir/src/fenrir/res/drawable/ic_launcher_foreground.xml b/app_fenrir/src/fenrir/res/drawable/ic_launcher_foreground.xml index 216d00a5e..e4488d6ed 100644 --- a/app_fenrir/src/fenrir/res/drawable/ic_launcher_foreground.xml +++ b/app_fenrir/src/fenrir/res/drawable/ic_launcher_foreground.xml @@ -7,7 +7,7 @@ android:viewportWidth="108" android:viewportHeight="108"> diff --git a/app_fenrir/src/fenrir/res/drawable/splash.xml b/app_fenrir/src/fenrir/res/drawable/splash.xml index a933239bd..daa99889e 100644 --- a/app_fenrir/src/fenrir/res/drawable/splash.xml +++ b/app_fenrir/src/fenrir/res/drawable/splash.xml @@ -7,7 +7,7 @@ android:viewportWidth="108" android:viewportHeight="108"> diff --git a/app_fenrir/src/kate/res/drawable/client_round.xml b/app_fenrir/src/kate/res/drawable/client_round.xml index 0752f6a02..f909bb494 100644 --- a/app_fenrir/src/kate/res/drawable/client_round.xml +++ b/app_fenrir/src/kate/res/drawable/client_round.xml @@ -8,9 +8,9 @@ + android:pathData="M1.5,18.002C1.5,8.887 8.886,1.5 17.998,1.5 27.113,1.5 34.5,8.886 34.5,18.002 34.5,27.113 27.114,34.5 17.998,34.5 8.887,34.5 1.5,27.114 1.5,18.002ZM1.5,18.002" /> diff --git a/app_fenrir/src/kate/res/drawable/ic_launcher_foreground.xml b/app_fenrir/src/kate/res/drawable/ic_launcher_foreground.xml index 2ee2540fb..5049ffde7 100644 --- a/app_fenrir/src/kate/res/drawable/ic_launcher_foreground.xml +++ b/app_fenrir/src/kate/res/drawable/ic_launcher_foreground.xml @@ -7,7 +7,7 @@ android:viewportWidth="108" android:viewportHeight="108"> diff --git a/app_fenrir/src/kate/res/drawable/splash.xml b/app_fenrir/src/kate/res/drawable/splash.xml index 2cb1e7a4b..2c3c9ee22 100644 --- a/app_fenrir/src/kate/res/drawable/splash.xml +++ b/app_fenrir/src/kate/res/drawable/splash.xml @@ -7,7 +7,7 @@ android:viewportWidth="108" android:viewportHeight="108"> diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt index 135b640bd..5f0edaa93 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/Constants.kt @@ -18,8 +18,8 @@ object Constants { const val FILE_PROVIDER_AUTHORITY: String = "${BuildConfig.APPLICATION_ID}.file_provider" const val VK_ANDROID_APP_VERSION_NAME = "8.15" const val VK_ANDROID_APP_VERSION_CODE = 15271 - const val KATE_APP_VERSION_NAME = "118 lite" - const val KATE_APP_VERSION_CODE = 566 + const val KATE_APP_VERSION_NAME = "122 lite" + const val KATE_APP_VERSION_CODE = 580 const val IOS_APP_VERSION_CODE = 3893 diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AccountsActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AccountsActivity.kt index 30283fd55..453e01764 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AccountsActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AccountsActivity.kt @@ -17,7 +17,7 @@ class AccountsActivity : NoMainActivity(), PlaceProvider { if (savedInstanceState == null) { supportFragmentManager .beginTransaction() - .replace(getMainContainerViewId(), AccountsFragment()) + .replace(noMainContainerViewId, AccountsFragment()) .addToBackStack("accounts") .commit() } @@ -28,7 +28,7 @@ class AccountsActivity : NoMainActivity(), PlaceProvider { Place.PREFERENCES -> { supportFragmentManager .beginTransaction() - .replace(getMainContainerViewId(), newInstance(place.safeArguments())) + .replace(noMainContainerViewId, newInstance(place.safeArguments())) .addToBackStack("preferences") .commit() } @@ -36,7 +36,7 @@ class AccountsActivity : NoMainActivity(), PlaceProvider { Place.SETTINGS_THEME -> { supportFragmentManager .beginTransaction() - .replace(getMainContainerViewId(), ThemeFragment()) + .replace(noMainContainerViewId, ThemeFragment()) .addToBackStack("preferences_themes") .commit() } @@ -44,13 +44,13 @@ class AccountsActivity : NoMainActivity(), PlaceProvider { Place.SHORTCUTS -> { supportFragmentManager .beginTransaction() - .replace(getMainContainerViewId(), ShortcutsViewFragment()) + .replace(noMainContainerViewId, ShortcutsViewFragment()) .addToBackStack("shortcuts") .commit() } else -> { - CustomSnackbars.createCustomSnackbars(findViewById(getMainContainerViewId())) + CustomSnackbars.createCustomSnackbars(findViewById(noMainContainerViewId)) ?.coloredSnack(R.string.not_available, Color.RED)?.show() } } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AttachmentsActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AttachmentsActivity.kt index 951aeaa9d..9a194bf7e 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AttachmentsActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AttachmentsActivity.kt @@ -39,7 +39,7 @@ class AttachmentsActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter, R.anim.fragment_exit) - .replace(R.id.fragment, fragment ?: return) + .replace(noMainContainerViewId, fragment ?: return) .addToBackStack(null) .commit() } @@ -51,7 +51,7 @@ class AttachmentsActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(R.id.fragment, fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack("video_album") .commit() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AudioSelectActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AudioSelectActivity.kt index 7bd534a64..c1b4c85fd 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AudioSelectActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/AudioSelectActivity.kt @@ -25,7 +25,7 @@ class AudioSelectActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(getMainContainerViewId(), fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack("audio-select") .commit() } @@ -36,7 +36,7 @@ class AudioSelectActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(getMainContainerViewId(), singleTabSearchFragment) + .replace(noMainContainerViewId, singleTabSearchFragment) .addToBackStack("audio-search-select") .commit() } else if (place.type == Place.AUDIOS_IN_ALBUM) { @@ -44,7 +44,7 @@ class AudioSelectActivity : NoMainActivity(), PlaceProvider { .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) .replace( - getMainContainerViewId(), + noMainContainerViewId, AudiosFragment.newInstance(place.safeArguments(), true) ) .addToBackStack("audio-in_playlist-select") diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ChatActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ChatActivity.kt index 4ce49453f..e1b14e9fa 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ChatActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ChatActivity.kt @@ -187,7 +187,7 @@ class ChatActivity : NoMainActivity(), PlaceProvider, AppStyleable, ServiceConne R.anim.fragment_exit ) fragmentTransaction - .replace(R.id.fragment, fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack(null) .commitAllowingStateLoss() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ChatActivityBubbles.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ChatActivityBubbles.kt index 65cba8e6a..47afb91f7 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ChatActivityBubbles.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ChatActivityBubbles.kt @@ -197,7 +197,7 @@ class ChatActivityBubbles : NoMainActivity(), PlaceProvider, AppStyleable, Servi R.anim.fragment_exit ) fragmentTransaction - .replace(R.id.fragment, fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack(null) .commitAllowingStateLoss() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/CreatePinActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/CreatePinActivity.kt index e60b9b4c3..ef7108db7 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/CreatePinActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/CreatePinActivity.kt @@ -1,7 +1,6 @@ package dev.ragnarok.fenrir.activity import android.os.Bundle -import dev.ragnarok.fenrir.R import dev.ragnarok.fenrir.fragment.pin.createpin.CreatePinFragment class CreatePinActivity : NoMainActivity() { @@ -10,7 +9,7 @@ class CreatePinActivity : NoMainActivity() { if (savedInstanceState == null) { supportFragmentManager .beginTransaction() - .replace(R.id.fragment, CreatePinFragment.newInstance()) + .replace(noMainContainerViewId, CreatePinFragment.newInstance()) .commit() } } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/DualTabPhotoActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/DualTabPhotoActivity.kt index 8b556ed6c..c653ea767 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/DualTabPhotoActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/DualTabPhotoActivity.kt @@ -42,7 +42,7 @@ class DualTabPhotoActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(getMainContainerViewId(), fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack("dual-tab-photos") .commit() } @@ -63,15 +63,17 @@ class DualTabPhotoActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(R.id.fragment, fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack("vk-album-photos") .commit() } Place.VK_INTERNAL_PLAYER -> { - val intent = Intent(this, VideoPlayerActivity::class.java) - intent.putExtras(args) - startActivity(intent) + val videoActivity = VideoPlayerActivity.newInstance(this, args) + place.launchActivityForResult( + this, + videoActivity + ) } Place.SINGLE_PHOTO -> { @@ -85,7 +87,7 @@ class DualTabPhotoActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(R.id.fragment, localPhotosFragment) + .replace(noMainContainerViewId, localPhotosFragment) .addToBackStack("local-album-photos") .commit() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/EnterPinActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/EnterPinActivity.kt index 4e29a3821..31fa5e043 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/EnterPinActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/EnterPinActivity.kt @@ -3,7 +3,6 @@ package dev.ragnarok.fenrir.activity import android.content.Context import android.content.Intent import android.os.Bundle -import dev.ragnarok.fenrir.R import dev.ragnarok.fenrir.fragment.pin.enterpin.EnterPinFragment import dev.ragnarok.fenrir.util.Utils @@ -13,7 +12,7 @@ open class EnterPinActivity : NoMainActivity() { if (savedInstanceState == null) { supportFragmentManager .beginTransaction() - .replace(R.id.fragment, EnterPinFragment.newInstance()) + .replace(noMainContainerViewId, EnterPinFragment.newInstance()) .commit() } } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/FileManagerSelectActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/FileManagerSelectActivity.kt index 7812ac4d8..1d4a24af4 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/FileManagerSelectActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/FileManagerSelectActivity.kt @@ -4,7 +4,6 @@ import android.content.Context import android.content.Intent import android.os.Bundle import dev.ragnarok.fenrir.Extra -import dev.ragnarok.fenrir.R import dev.ragnarok.fenrir.activity.slidr.Slidr import dev.ragnarok.fenrir.activity.slidr.model.SlidrConfig import dev.ragnarok.fenrir.fragment.filemanagerselect.FileManagerSelectFragment @@ -33,18 +32,11 @@ class FileManagerSelectActivity : NoMainActivity() { fileManagerFragment.arguments = args supportFragmentManager .beginTransaction() - .replace(R.id.fragment, fileManagerFragment) + .replace(noMainContainerViewId, fileManagerFragment) .commit() } companion object { - fun makeFileManager(context: Context, path: String, ext: String?): Intent { - val intent = Intent(context, FileManagerSelectActivity::class.java) - intent.putExtra(Extra.PATH, path) - intent.putExtra(Extra.EXT, ext) - return intent - } - fun makeFileManager(context: Context, path: String, ext: String?, header: String?): Intent { val intent = Intent(context, FileManagerSelectActivity::class.java) intent.putExtra(Extra.PATH, path) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/LocalJsonToChatActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/LocalJsonToChatActivity.kt index da1b1804f..4957108ba 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/LocalJsonToChatActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/LocalJsonToChatActivity.kt @@ -119,7 +119,7 @@ class LocalJsonToChatActivity : NoMainActivity(), PlaceProvider, AppStyleable, S supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter, R.anim.fragment_exit) - .replace(getMainContainerViewId(), fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack("primary_local_chat") .commitAllowingStateLoss() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/LottieActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/LottieActivity.kt index e80f7c7f7..a886170fe 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/LottieActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/LottieActivity.kt @@ -106,7 +106,7 @@ class LottieActivity : AppCompatActivity() { fManager.launch( FileManagerSelectActivity.makeFileManager( this, Environment.getExternalStorageDirectory().absolutePath, - "dirs" + "dirs", null ) ) } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt index 4aee28b55..58112bbed 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/MainActivity.kt @@ -20,6 +20,8 @@ import android.view.animation.LinearInterpolator import android.view.inputmethod.InputMethodManager import androidx.activity.OnBackPressedCallback import androidx.activity.result.contract.ActivityResultContracts +import androidx.annotation.IdRes +import androidx.annotation.LayoutRes import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.core.view.WindowInsetsControllerCompat @@ -286,7 +288,31 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect supportFinishAfterTransition() } } - protected var mLayoutRes = if (Settings.get().main().isSnow_mode) snowLayout else normalLayout + + @get:LayoutRes + protected open val mainContentView: Int + get() = if (Settings.get().main().is_side_navigation) { + if (Settings.get().main().isSnow_mode) { + R.layout.activity_main_side_with_snow + } else { + R.layout.activity_main_side + } + } else { + if (Settings.get().main().isSnow_mode) { + R.layout.activity_main_with_snow + } else { + R.layout.activity_main + } + } + + @get:IdRes + protected open val mainContainerViewId: Int + get() = R.id.fragment + + @get:MainActivityTransforms + protected open val mainActivityTransform: Int + get() = MainActivityTransforms.MAIN + protected var mLastBackPressedTime: Long = 0 private val requestCreatePin = registerForActivityResult( @@ -343,19 +369,6 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect private var mTargetPage: Pair? = null private var resumed = false private var isZoomPhoto = false - private val snowLayout: Int - get() = if (Settings.get() - .main().is_side_navigation - ) R.layout.activity_main_side_with_snow else R.layout.activity_main_with_snow - private val normalLayout: Int - get() = if (Settings.get() - .main().is_side_navigation - ) R.layout.activity_main_side else R.layout.activity_main - - @MainActivityTransforms - protected open fun getMainActivityTransform(): Int { - return MainActivityTransforms.MAIN - } private fun postResume(action: Action) { if (resumed) { @@ -380,7 +393,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect override fun onCreate(savedInstanceState: Bundle?) { delegate.applyDayNight() - if (savedInstanceState == null && getMainActivityTransform() == MainActivityTransforms.MAIN) { + if (savedInstanceState == null && mainActivityTransform == MainActivityTransforms.MAIN) { nextRandom() } setTheme(currentStyle()) @@ -403,14 +416,14 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect .filter { it.first == mAccountId } .sharedFlowToMain { updateMessagesBagde(it.second) }) bindToAudioPlayService() - setContentView(mLayoutRes) + setContentView(mainContentView) mAccountId = Settings.get() .accounts() .current setStatusbarColored(true, Settings.get().ui().isDarkModeEnabled(this)) val mDrawerLayout = findViewById(R.id.my_drawer_layout) - mViewFragment = findViewById(R.id.fragment) + mViewFragment = findViewById(mainContainerViewId) val anim: ObjectAnimator if (mDrawerLayout != null && Settings.get().main().is_side_navigation) { navigationView?.setUp(mDrawerLayout) @@ -467,7 +480,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect startAccountsActivityZero() } } else { - if (getMainActivityTransform() == MainActivityTransforms.MAIN) { + if (mainActivityTransform == MainActivityTransforms.MAIN) { checkFCMRegistration(false) mCompositeJob.add(MusicPlaybackController.tracksExist.findAllAudios(this) .andThen( @@ -522,7 +535,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect } } if (supportFragmentManager.backStackEntryCount == 1 || supportFragmentManager.backStackEntryCount <= 0) { - if (getMainActivityTransform() != MainActivityTransforms.SWIPEBLE) { + if (mainActivityTransform != MainActivityTransforms.SWIPEBLE) { if (isFragmentWithoutNavigation) { openNavigationPage(AbsNavigationView.SECTION_ITEM_FEED, false) return @@ -760,7 +773,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect } } else { mToolbar?.setNavigationIcon(R.drawable.arrow_left) - if (getMainActivityTransform() != MainActivityTransforms.SWIPEBLE) { + if (mainActivityTransform != MainActivityTransforms.SWIPEBLE) { mToolbar?.setNavigationOnClickListener { openNavigationPage( AbsNavigationView.SECTION_ITEM_FEED, @@ -869,7 +882,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect Intent.ACTION_SEND_MULTIPLE == intent.action -> { val mime = intent.type - if (getMainActivityTransform() == MainActivityTransforms.MAIN && intent.extras != null && mime.nonNullNoEmpty() && isMimeAudio( + if (mainActivityTransform == MainActivityTransforms.MAIN && intent.extras != null && mime.nonNullNoEmpty() && isMimeAudio( mime ) && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true ) { @@ -924,7 +937,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect Intent.ACTION_VIEW == intent.action -> { val data = intent.data val mime = intent.type ?: "" - if (getMainActivityTransform() == MainActivityTransforms.MAIN && mime.nonNullNoEmpty() && isMimeAudio( + if (mainActivityTransform == MainActivityTransforms.MAIN && mime.nonNullNoEmpty() && isMimeAudio( mime ) ) { @@ -979,7 +992,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect attachToFront(chatFragment) } else { if (Settings.get() - .ui().swipes_chat_mode == SwipesChatMode.SLIDR && getMainActivityTransform() == MainActivityTransforms.MAIN + .ui().swipes_chat_mode == SwipesChatMode.SLIDR && mainActivityTransform == MainActivityTransforms.MAIN ) { val intent = Intent(this, ChatActivity::class.java) intent.action = ChatActivity.ACTION_OPEN_PLACE @@ -992,7 +1005,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect Utils.finishActivityImmediate(this) } } else if (Settings.get() - .ui().swipes_chat_mode == SwipesChatMode.SLIDR && getMainActivityTransform() != MainActivityTransforms.MAIN + .ui().swipes_chat_mode == SwipesChatMode.SLIDR && mainActivityTransform != MainActivityTransforms.MAIN ) { val chatFragment = newInstance(accountId, messagesOwnerId, peer) attachToFront(chatFragment) @@ -1214,7 +1227,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect } private val frontFragment: Fragment? - get() = supportFragmentManager.findFragmentById(R.id.fragment) + get() = supportFragmentManager.findFragmentById(mainContainerViewId) private val isChatFragment: Boolean get() = frontFragment is ChatFragment @@ -1292,7 +1305,7 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect R.anim.fragment_exit ) fragmentTransaction - .replace(R.id.fragment, fragment) + .replace(mainContainerViewId, fragment) .addToBackStack(null) .commitAllowingStateLoss() } @@ -1535,9 +1548,11 @@ open class MainActivity : AppCompatActivity(), NavigationDrawerCallbacks, OnSect } Place.VK_INTERNAL_PLAYER -> { - val intent = Intent(this, VideoPlayerActivity::class.java) - intent.putExtras(args) - startActivity(intent) + val videoActivity = VideoPlayerActivity.newInstance(this, args) + place.launchActivityForResult( + this, + videoActivity + ) } Place.LIKES_AND_COPIES -> attachToFront(LikesFragment.newInstance(args)) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/NoMainActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/NoMainActivity.kt index 4b41681ec..b54f46eb3 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/NoMainActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/NoMainActivity.kt @@ -29,6 +29,14 @@ abstract class NoMainActivity : AppCompatActivity() { return this is ChatActivity || this is LocalJsonToChatActivity || this is ChatActivityBubbles } + @get:LayoutRes + protected open val noMainContentView: Int + get() = R.layout.activity_no_main + + @get:IdRes + protected open val noMainContainerViewId: Int + get() = R.id.fragment + @Suppress("DEPRECATION") override fun onCreate(savedInstanceState: Bundle?) { setTheme(currentStyle()) @@ -36,7 +44,7 @@ abstract class NoMainActivity : AppCompatActivity() { Utils.registerColorsThorVG(this) super.onCreate(savedInstanceState) isZoomPhoto = Settings.get().main().isDo_zoom_photo - setContentView(getNoMainContentView()) + setContentView(noMainContentView) if (!hasVanillaIceCreamTarget()) { val w = window w.statusBarColor = CurrentTheme.getStatusBarColor(this) @@ -46,9 +54,7 @@ abstract class NoMainActivity : AppCompatActivity() { onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { override fun handleOnBackPressed() { val fm = supportFragmentManager - val front = fm.findFragmentById( - getMainContainerViewId() - ) + val front = fm.findFragmentById(noMainContainerViewId) if (front is BackPressCallback) { if (!(front as BackPressCallback).onBackPressed()) { return @@ -73,16 +79,6 @@ abstract class NoMainActivity : AppCompatActivity() { } else getInstance()?.dispatchTouchEvent(ev, this) == true || super.dispatchTouchEvent(ev) } - @LayoutRes - protected open fun getNoMainContentView(): Int { - return R.layout.activity_no_main - } - - @IdRes - protected open fun getMainContainerViewId(): Int { - return R.id.fragment - } - override fun setSupportActionBar(toolbar: Toolbar?) { super.setSupportActionBar(toolbar) mToolbar = toolbar diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/NotReadMessagesActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/NotReadMessagesActivity.kt index 688553c3a..307b13096 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/NotReadMessagesActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/NotReadMessagesActivity.kt @@ -40,7 +40,7 @@ class NotReadMessagesActivity : NoMainActivity(), PlaceProvider, AppStyleable { private val mOnBackStackChangedListener = FragmentManager.OnBackStackChangedListener { keyboardHide() } internal val frontFragment: Fragment? - get() = supportFragmentManager.findFragmentById(R.id.fragment) + get() = supportFragmentManager.findFragmentById(noMainContainerViewId) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -162,7 +162,7 @@ class NotReadMessagesActivity : NoMainActivity(), PlaceProvider, AppStyleable { R.anim.fragment_exit ) fragmentTransaction - .replace(R.id.fragment, fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack(null) .commitAllowingStateLoss() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PhotoAlbumsActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PhotoAlbumsActivity.kt index 266e160df..4ecc91128 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PhotoAlbumsActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PhotoAlbumsActivity.kt @@ -21,7 +21,7 @@ class PhotoAlbumsActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter, R.anim.fragment_exit) - .add(R.id.fragment, fragment) + .add(noMainContainerViewId, fragment) .addToBackStack(null) .commit() } @@ -33,7 +33,7 @@ class PhotoAlbumsActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(R.id.fragment, fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack("photos") .commit() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PhotosActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PhotosActivity.kt index c6ff72b79..95e025e47 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PhotosActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PhotosActivity.kt @@ -24,7 +24,7 @@ class PhotosActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter, R.anim.fragment_exit) - .replace(R.id.fragment, ignoredFragment) + .replace(noMainContainerViewId, ignoredFragment) .addToBackStack(null) .commit() } @@ -38,7 +38,7 @@ class PhotosActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(R.id.fragment, localPhotosFragment) + .replace(noMainContainerViewId, localPhotosFragment) .addToBackStack("photos") .commit() } else if (place.type == Place.SINGLE_PHOTO) { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PostCreateActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PostCreateActivity.kt index 1216b027c..0c53210bf 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PostCreateActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/PostCreateActivity.kt @@ -35,7 +35,7 @@ class PostCreateActivity : NoMainActivity() { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter, R.anim.fragment_exit) - .replace(getMainContainerViewId(), fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack(null) .commitAllowingStateLoss() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ProxyManagerActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ProxyManagerActivity.kt index d87199ca7..ae5a644fb 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ProxyManagerActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/ProxyManagerActivity.kt @@ -14,7 +14,7 @@ class ProxyManagerActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(getMainContainerViewId(), ProxyManagerFrgament.newInstance()) + .replace(noMainContainerViewId, ProxyManagerFrgament.newInstance()) .addToBackStack("proxy-manager") .commit() } @@ -25,7 +25,7 @@ class ProxyManagerActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(getMainContainerViewId(), AddProxyFragment.newInstance()) + .replace(noMainContainerViewId, AddProxyFragment.newInstance()) .addToBackStack("proxy-add") .commit() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SendAttachmentsActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SendAttachmentsActivity.kt index 670a5586d..4253b9805 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SendAttachmentsActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SendAttachmentsActivity.kt @@ -16,10 +16,9 @@ import dev.ragnarok.fenrir.util.ViewUtils * Отличие только в том, что этот активити может существовать в нескольких экземплярах */ class SendAttachmentsActivity : MainActivity() { - @MainActivityTransforms - override fun getMainActivityTransform(): Int { - return MainActivityTransforms.SEND_ATTACHMENTS - } + @get:MainActivityTransforms + override val mainActivityTransform: Int + get() = MainActivityTransforms.SEND_ATTACHMENTS override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SinglePhotoActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SinglePhotoActivity.kt index a666e253f..bb1b728e0 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SinglePhotoActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SinglePhotoActivity.kt @@ -62,10 +62,9 @@ class SinglePhotoActivity : NoMainActivity(), PlaceProvider, AppStyleable { private var mFullscreen = false private var mDownload: CircleCounterButton? = null - @LayoutRes - override fun getNoMainContentView(): Int { - return R.layout.fragment_single_url_photo - } + @get:LayoutRes + override val noMainContentView: Int + get() = R.layout.activity_single_url_photo @SuppressLint("ClickableViewAccessibility") override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SwipebleActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SwipebleActivity.kt index d7d6e1d99..2330f0bab 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SwipebleActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/SwipebleActivity.kt @@ -14,10 +14,9 @@ import dev.ragnarok.fenrir.util.ViewUtils * Отличие только в том, что этот активити может существовать в нескольких экземплярах */ class SwipebleActivity : MainActivity() { - @MainActivityTransforms - override fun getMainActivityTransform(): Int { - return MainActivityTransforms.SWIPEBLE - } + @get:MainActivityTransforms + override val mainActivityTransform: Int + get() = MainActivityTransforms.SWIPEBLE override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/VideoPlayerActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/VideoPlayerActivity.kt index c7b51731e..16c265535 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/VideoPlayerActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/VideoPlayerActivity.kt @@ -627,5 +627,23 @@ class VideoPlayerActivity : AppCompatActivity(), SurfaceHolder.Callback, const val EXTRA_VIDEO = "video" const val EXTRA_SIZE = "size" const val EXTRA_LOCAL = "local" + + fun newInstance(context: Context, args: Bundle): Intent { + val intent = Intent(context, VideoPlayerActivity::class.java) + intent.putExtras(args) + return intent + } + + fun buildArgs( + video: Video?, + @InternalVideoSize size: Int, + isLocal: Boolean + ): Bundle { + val args = Bundle() + args.putParcelable(EXTRA_VIDEO, video) + args.putInt(EXTRA_SIZE, size) + args.putBoolean(EXTRA_LOCAL, isLocal) + return args + } } } \ No newline at end of file diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/VideoSelectActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/VideoSelectActivity.kt index e1b6741b6..c9d3125dc 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/VideoSelectActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/VideoSelectActivity.kt @@ -31,7 +31,7 @@ class VideoSelectActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(getMainContainerViewId(), fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack("video-tabs") .commit() } @@ -43,7 +43,7 @@ class VideoSelectActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(getMainContainerViewId(), fragment) + .replace(noMainContainerViewId, fragment) .addToBackStack("video-album") .commit() } @@ -54,7 +54,7 @@ class VideoSelectActivity : NoMainActivity(), PlaceProvider { supportFragmentManager .beginTransaction() .setCustomAnimations(R.anim.fragment_enter_pop, R.anim.fragment_exit_pop) - .replace(getMainContainerViewId(), singleTabSearchFragment) + .replace(noMainContainerViewId, singleTabSearchFragment) .addToBackStack("video-search") .commit() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/gifpager/GifPagerActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/gifpager/GifPagerActivity.kt index 35048d04f..74537bb53 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/gifpager/GifPagerActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/gifpager/GifPagerActivity.kt @@ -51,10 +51,9 @@ class GifPagerActivity : AbsDocumentPreviewActivity private val bShowPhotosLine = Settings.get().main().isShow_photos_line private val mAdapterRecycler = ImageListAdapter() - @LayoutRes - override fun getNoMainContentView(): Int { - return R.layout.activity_photo_pager - } + @get:LayoutRes + override val noMainContentView: Int + get() = R.layout.activity_photo_pager override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/qr/CameraScanActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/qr/CameraScanActivity.kt index ccae60c68..b0d92842a 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/qr/CameraScanActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/qr/CameraScanActivity.kt @@ -4,6 +4,7 @@ import android.Manifest import android.annotation.SuppressLint import android.content.Context import android.content.Intent +import android.content.res.Configuration import android.graphics.Bitmap import android.graphics.Canvas import android.graphics.Color @@ -18,8 +19,11 @@ import android.util.ArrayMap import android.util.AttributeSet import android.util.Log import android.util.Size +import android.view.Display import android.view.MotionEvent import android.view.View +import android.view.WindowManager +import androidx.annotation.LayoutRes import androidx.camera.core.Camera import androidx.camera.core.CameraInfoUnavailableException import androidx.camera.core.CameraSelector @@ -35,6 +39,8 @@ import androidx.camera.core.resolutionselector.ResolutionStrategy import androidx.camera.lifecycle.ProcessCameraProvider import androidx.camera.view.PreviewView import androidx.core.content.ContextCompat +import androidx.core.view.WindowInsetsCompat +import androidx.core.view.WindowInsetsControllerCompat import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.zxing.BarcodeFormat import com.google.zxing.BinaryBitmap @@ -49,25 +55,38 @@ import com.google.zxing.ResultPointCallback import com.google.zxing.common.HybridBinarizer import dev.ragnarok.fenrir.Extra import dev.ragnarok.fenrir.R +import dev.ragnarok.fenrir.activity.ActivityFeatures import dev.ragnarok.fenrir.activity.NoMainActivity import dev.ragnarok.fenrir.activity.slidr.Slidr import dev.ragnarok.fenrir.activity.slidr.model.SlidrConfig +import dev.ragnarok.fenrir.listener.AppStyleable import dev.ragnarok.fenrir.nonNullNoEmpty import dev.ragnarok.fenrir.settings.CurrentTheme +import dev.ragnarok.fenrir.settings.CurrentTheme.getNavigationBarColor +import dev.ragnarok.fenrir.settings.CurrentTheme.getStatusBarColor +import dev.ragnarok.fenrir.settings.CurrentTheme.getStatusBarNonColored import dev.ragnarok.fenrir.toColor import dev.ragnarok.fenrir.util.AppPerms import dev.ragnarok.fenrir.util.AppPerms.requestPermissionsResultAbs import dev.ragnarok.fenrir.util.Utils +import dev.ragnarok.fenrir.util.Utils.hasVanillaIceCreamTarget +import dev.ragnarok.fenrir.util.coroutines.CancelableJob +import dev.ragnarok.fenrir.util.coroutines.CoroutinesUtils.delayTaskFlow +import dev.ragnarok.fenrir.util.coroutines.CoroutinesUtils.toMain import java.util.EnumSet -class CameraScanActivity : NoMainActivity() { - private lateinit var textureView: PreviewView +class CameraScanActivity : NoMainActivity(), AppStyleable { + private lateinit var viewFinder: PreviewView private var camera: Camera? = null private var finder: FinderView? = null private var flashButton: FloatingActionButton? = null private val reader: MultiFormatReader = MultiFormatReader() private var isFlash = false private var mYBuffer = ByteArray(0) + private var mDecorView: View? = null + private var mFocusView: View? = null + private var focusHideJob = CancelableJob() + private var imageAnalysisPointer: ImageAnalysis? = null inner class DecoderResultPointCallback : ResultPointCallback { override fun foundPossibleResultPoint(point: ResultPoint) { @@ -105,16 +124,25 @@ class CameraScanActivity : NoMainActivity() { ) } + override fun onDestroy() { + super.onDestroy() + focusHideJob.cancel() + } + + @get:LayoutRes + override val noMainContentView: Int + get() = R.layout.activity_camera_scan + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Slidr.attach( this, SlidrConfig.Builder().scrimColor(CurrentTheme.getColorBackground(this)).build() ) - setContentView(R.layout.activity_camera_scan) - textureView = findViewById(R.id.preview) + viewFinder = findViewById(R.id.preview) finder = findViewById(R.id.view_finder) flashButton = findViewById(R.id.flash_button) + mFocusView = findViewById(R.id.focus) updateFlashButton() flashButton?.setOnClickListener { @@ -130,6 +158,55 @@ class CameraScanActivity : NoMainActivity() { } else { requestCameraPermission.launch() } + + window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + mDecorView = window.decorView + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + mDecorView?.layoutParams = + WindowManager.LayoutParams(WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES) + } + + mDecorView?.let { + WindowInsetsControllerCompat(window, it).let { controller -> + controller.hide(WindowInsetsCompat.Type.statusBars()) + controller.systemBarsBehavior = + WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + } + } + } + + override fun onResume() { + super.onResume() + ActivityFeatures.Builder() + .begin() + .setHideNavigationMenu(true) + .setBarsColored(colored = false, invertIcons = false) + .build() + .apply(this) + } + + @Suppress("DEPRECATION") + private fun getScreenRotation(): Int { + try { + var currentDisplay: Display? = null + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + currentDisplay = display + } else { + val manager = getSystemService(WINDOW_SERVICE) as WindowManager? + if (manager != null) { + currentDisplay = manager.defaultDisplay + } + } + return currentDisplay?.rotation ?: -1 + } catch (e: Exception) { + e.printStackTrace() + return -1 + } + } + + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + imageAnalysisPointer?.targetRotation = getScreenRotation() } private fun detect(source: LuminanceSource): String? { @@ -198,8 +275,10 @@ class CameraScanActivity : NoMainActivity() { ) ).setAspectRatioStrategy(AspectRatioStrategy.RATIO_16_9_FALLBACK_AUTO_STRATEGY) .build() + val cameraSelector = + CameraSelector.Builder().requireLensFacing(CameraSelector.LENS_FACING_BACK).build() val preview = Preview.Builder().setResolutionSelector(resolution).build() - preview.surfaceProvider = textureView.surfaceProvider + preview.surfaceProvider = viewFinder.surfaceProvider val imageAnalysis = ImageAnalysis.Builder() .setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_YUV_420_888) .setResolutionSelector(resolution) @@ -247,6 +326,8 @@ class CameraScanActivity : NoMainActivity() { imageProxy.close() } + imageAnalysisPointer = imageAnalysis + // request a ProcessCameraProvider val cameraProviderFuture = ProcessCameraProvider.getInstance(this) @@ -255,9 +336,7 @@ class CameraScanActivity : NoMainActivity() { try { val cameraProvider = cameraProviderFuture.get() camera = cameraProvider.bindToLifecycle( - this, CameraSelector.Builder() - .requireLensFacing(CameraSelector.LENS_FACING_BACK) - .build(), + this, cameraSelector, imageAnalysis, preview ) } catch (e: Exception) { @@ -265,15 +344,23 @@ class CameraScanActivity : NoMainActivity() { } }, ContextCompat.getMainExecutor(this)) - textureView.setOnTouchListener { _, event -> + viewFinder.setOnTouchListener { _, event -> return@setOnTouchListener when (event.action) { MotionEvent.ACTION_DOWN -> { true } MotionEvent.ACTION_UP -> { + focusHideJob.cancel() + mFocusView?.visibility = View.VISIBLE + mFocusView?.x = event.x + mFocusView?.y = event.y + focusHideJob += delayTaskFlow(1000).toMain { + mFocusView?.visibility = View.GONE + } + val factory: MeteringPointFactory = SurfaceOrientedMeteringPointFactory( - textureView.width.toFloat(), textureView.height.toFloat() + viewFinder.width.toFloat(), viewFinder.height.toFloat() ) val autoFocusPoint = factory.createPoint(event.x, event.y) try { @@ -297,6 +384,25 @@ class CameraScanActivity : NoMainActivity() { } } + override fun hideMenu(hide: Boolean) {} + override fun openMenu(open: Boolean) {} + + @Suppress("DEPRECATION") + override fun setStatusbarColored(colored: Boolean, invertIcons: Boolean) { + val w = window + if (!hasVanillaIceCreamTarget()) { + w.statusBarColor = + if (colored) getStatusBarColor(this) else getStatusBarNonColored( + this + ) + w.navigationBarColor = + if (colored) getNavigationBarColor(this) else Color.BLACK + } + val ins = WindowInsetsControllerCompat(w, w.decorView) + ins.isAppearanceLightStatusBars = invertIcons + ins.isAppearanceLightNavigationBars = invertIcons + } + open class FinderView(context: Context, attrs: AttributeSet?) : View(context, attrs) { private val frame: Rect = Rect() diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/selectprofiles/SelectProfilesActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/selectprofiles/SelectProfilesActivity.kt index 84f566454..f4349a255 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/selectprofiles/SelectProfilesActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/selectprofiles/SelectProfilesActivity.kt @@ -3,6 +3,7 @@ package dev.ragnarok.fenrir.activity.selectprofiles import android.content.Context import android.content.Intent import android.os.Bundle +import androidx.annotation.LayoutRes import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dev.ragnarok.fenrir.Extra @@ -29,16 +30,21 @@ class SelectProfilesActivity : MainActivity(), SelectedProfilesAdapter.ActionLis private var mRecyclerView: RecyclerView? = null private var mProfilesAdapter: SelectedProfilesAdapter? = null - @MainActivityTransforms - override fun getMainActivityTransform(): Int { - return MainActivityTransforms.PROFILES - } + @get:MainActivityTransforms + override val mainActivityTransform: Int + get() = MainActivityTransforms.PROFILES + + @get:LayoutRes + override val mainContentView: Int + get() = if (Settings.get().main().is_side_navigation) { + R.layout.activity_main_with_profiles_selection_side + } else { + R.layout.activity_main_with_profiles_selection + } override fun onCreate(savedInstanceState: Bundle?) { - mLayoutRes = if (Settings.get() - .main().is_side_navigation - ) R.layout.activity_main_with_profiles_selection_side else R.layout.activity_main_with_profiles_selection super.onCreate(savedInstanceState) + mLastBackPressedTime = Long.MAX_VALUE - DOUBLE_BACK_PRESSED_TIMEOUT acceptableCriteria = intent.getParcelableExtraCompat(Extra.CRITERIA) if (savedInstanceState != null) { @@ -93,7 +99,6 @@ class SelectProfilesActivity : MainActivity(), SelectedProfilesAdapter.ActionLis private val TAG = SelectProfilesActivity::class.simpleName.orEmpty() private const val SAVE_SELECTED_OWNERS = "save_selected_owners" - fun createIntent( context: Context, initialPlace: Place, diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/shortvideopager/ShortVideoPagerActivity.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/shortvideopager/ShortVideoPagerActivity.kt index fdaea4111..6b7036c84 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/shortvideopager/ShortVideoPagerActivity.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/activity/shortvideopager/ShortVideoPagerActivity.kt @@ -85,10 +85,9 @@ class ShortVideoPagerActivity : BaseMvpActivity private var helpDisposable = CancelableJob() private var playDispose = CancelableJob() - @LayoutRes - override fun getNoMainContentView(): Int { - return R.layout.activity_story_pager - } + @get:LayoutRes + override val noMainContentView: Int + get() = R.layout.activity_story_pager override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/adapters/AbsDtoAdapter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/adapters/AbsDtoAdapter.kt index 0eee9ae0b..a0c4dda14 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/adapters/AbsDtoAdapter.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/adapters/AbsDtoAdapter.kt @@ -56,7 +56,7 @@ abstract class AbsDtoAdapter(name: String) : KSerializer { contract { returns(true) implies (element is JsonArray) } - return element is JsonArray && element.size > 0 + return element is JsonArray && element.isNotEmpty() } fun hasPrimitive(obj: JsonObject?, name: String): Boolean { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/util/ProgressRequestBody.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/util/ProgressRequestBody.kt index 66e009add..396746dc5 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/util/ProgressRequestBody.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/api/util/ProgressRequestBody.kt @@ -32,6 +32,7 @@ class ProgressRequestBody( uploaded += read.toLong() sink.write(buffer, 0, read) } + listener?.onProgressUpdate(100) } catch (e: Exception) { if (e is IOException) { throw e diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/PreferencesFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/PreferencesFragment.kt index 48efa6773..4d5acf9b9 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/PreferencesFragment.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/PreferencesFragment.kt @@ -1419,7 +1419,7 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "dirs" + "dirs", null ) ) true @@ -1438,7 +1438,7 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "dirs" + "dirs", null ) ) true @@ -1457,7 +1457,7 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "dirs" + "dirs", null ) ) true @@ -1476,7 +1476,7 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "dirs" + "dirs", null ) ) true @@ -1495,7 +1495,7 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "dirs" + "dirs", null ) ) true @@ -1867,7 +1867,7 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "dirs" + "dirs", null ) ) true @@ -2113,7 +2113,7 @@ class PreferencesFragment : AbsPreferencesFragment(), PreferencesAdapter.OnScree FileManagerSelectActivity.makeFileManager( requireActivity(), requireActivity().dataDir.absolutePath, - null + null, null ) ) } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsFragment.kt index 2c138ff6e..66ca5a535 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsFragment.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/accounts/AccountsFragment.kt @@ -355,7 +355,7 @@ class AccountsFragment : BaseMvpFragment(), IA FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "dirs" + "dirs", null ) ) } @@ -579,7 +579,7 @@ class AccountsFragment : BaseMvpFragment(), IA FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "json" + "json", null ) ) } @@ -589,7 +589,7 @@ class AccountsFragment : BaseMvpFragment(), IA FileManagerSelectActivity.makeFileManager( requireActivity(), Environment.getExternalStorageDirectory().absolutePath, - "json" + "json", null ) ) } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/absattachmentsedit/AbsAttachmentsEditFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/absattachmentsedit/AbsAttachmentsEditFragment.kt index 3bbd7ce9a..bc442ba5d 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/absattachmentsedit/AbsAttachmentsEditFragment.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/attachments/absattachmentsedit/AbsAttachmentsEditFragment.kt @@ -219,7 +219,7 @@ abstract class AbsAttachmentsEditFragment

, V override fun onDestroyView() { super.onDestroyView() - (mAdapter ?: return).cleanup() + mAdapter?.cleanup() } override fun updateProgressAtIndex(index: Int, progress: Int) { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/audio/local/audioslocal/AudiosLocalPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/audio/local/audioslocal/AudiosLocalPresenter.kt index a83737829..670a1a10d 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/audio/local/audioslocal/AudiosLocalPresenter.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/audio/local/audioslocal/AudiosLocalPresenter.kt @@ -318,16 +318,20 @@ class AudiosLocalPresenter(accountId: Long, savedInstanceState: Bundle?) : } private fun onUploadsAdded(added: List) { + var count = 0 + val cur = uploadsData.size for (u in added) { if (destination.compareTo(u.destination)) { - val index = uploadsData.size - uploadsData.add(u) - view?.notifyUploadItemsAdded( - index, - 1 - ) + val index = findIndexById(uploadsData, u.getObjectId()) + if (index == -1) { + uploadsData.add(u) + count++ + } } } + if (count > 0) { + view?.notifyUploadItemsAdded(cur, count) + } resolveUploadDataVisibility() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/communities/communitycontrol/communityblacklist/CommunityBlacklistFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/communities/communitycontrol/communityblacklist/CommunityBlacklistFragment.kt index d290e64e3..51b0c6b75 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/communities/communitycontrol/communityblacklist/CommunityBlacklistFragment.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/communities/communitycontrol/communityblacklist/CommunityBlacklistFragment.kt @@ -85,21 +85,15 @@ class CommunityBlacklistFragment : } override fun notifyDataSetChanged() { - if (mAdapter != null) { - (mAdapter ?: return).notifyDataSetChanged() - } + mAdapter?.notifyDataSetChanged() } override fun diplayData(data: List) { - if (mAdapter != null) { - (mAdapter ?: return).setData(data) - } + mAdapter?.setData(data) } override fun notifyItemRemoved(index: Int) { - if (mAdapter != null) { - (mAdapter ?: return).notifyItemRemoved(index) - } + mAdapter?.notifyItemRemoved(index) } override fun openBanEditor(accountId: Long, groupId: Long, banned: Banned) { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsListPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsListPresenter.kt index 848f4fcb6..1e929f380 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsListPresenter.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/docs/DocsListPresenter.kt @@ -202,16 +202,20 @@ class DocsListPresenter( } private fun onUploadsAdded(added: List) { + var count = 0 + val cur = uploadsData.size for (u in added) { if (destination.compareTo(u.destination)) { - val index = uploadsData.size - uploadsData.add(u) - view?.notifyUploadItemsAdded( - index, - 1 - ) + val index = findIndexById(uploadsData, u.getObjectId()) + if (index == -1) { + uploadsData.add(u) + count++ + } } } + if (count > 0) { + view?.notifyUploadItemsAdded(cur, count) + } resolveUploadDataVisibility() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/friends/friendsbyphones/FriendsByPhonesFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/friends/friendsbyphones/FriendsByPhonesFragment.kt index 34e7bfd46..bbb9532fd 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/friends/friendsbyphones/FriendsByPhonesFragment.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/friends/friendsbyphones/FriendsByPhonesFragment.kt @@ -66,7 +66,7 @@ class FriendsByPhonesFragment : BaseMvpFragment { - val precentText = upload.progress.toString() + "%" - holder.title.text = precentText + val percentText = upload.progress.toString() + "%" + holder.title.text = percentText } Upload.STATUS_CANCELLING -> holder.title.setText(R.string.cancelling) @@ -401,7 +401,7 @@ class AttachmentsBottomSheetAdapter( Upload.STATUS_ERROR -> { holder.title.setText(R.string.error) titleColor = ERROR_COLOR - holder.Retry.visibility = View.VISIBLE + holder.buttonRetry.visibility = View.VISIBLE } } holder.title.setTextColor(titleColor) @@ -419,8 +419,8 @@ class AttachmentsBottomSheetAdapter( fun changeUploadProgress(id: Int, progress: Int, smoothly: Boolean) { val holder = holders.findOneByEntityId(id) if (holder != null) { - val precentText = "$progress%" - holder.title.text = precentText + val percentText = "$progress%" + holder.title.text = percentText if (smoothly) { holder.progress.changePercentageSmoothly(progress) } else { @@ -431,7 +431,7 @@ class AttachmentsBottomSheetAdapter( private fun bindImageHolder(holder: EntryHolder, photo: Photo) { val url = photo.getUrlForSize(PhotoSize.Q, false) - holder.Retry.visibility = View.GONE + holder.buttonRetry.visibility = View.GONE holder.progress.visibility = View.INVISIBLE holder.tintView.visibility = View.GONE holder.title.setText(R.string.photo) @@ -470,9 +470,9 @@ class AttachmentsBottomSheetAdapter( RecyclerView.ViewHolder(itemView), IdentificableHolder { val image: ImageView = itemView.findViewById(R.id.image) val title: TextView = itemView.findViewById(R.id.title) - val buttomRemove: ViewGroup = itemView.findViewById(R.id.progress_root) + val buttonRemove: ViewGroup = itemView.findViewById(R.id.progress_root) val progress: CircleRoadProgress = itemView.findViewById(R.id.progress_view) - val Retry: ImageView = itemView.findViewById(R.id.retry_upload) + val buttonRetry: ImageView = itemView.findViewById(R.id.retry_upload) val tintView: View = itemView.findViewById(R.id.tint_view) override val holderId: Int get() = tintView.tag as Int @@ -492,4 +492,4 @@ class AttachmentsBottomSheetAdapter( private const val VTYPE_ENTRY = 1 } -} \ No newline at end of file +} diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/sheet/MessageAttachmentsFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/sheet/MessageAttachmentsFragment.kt index 40d1a4a37..120de7a2d 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/sheet/MessageAttachmentsFragment.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/sheet/MessageAttachmentsFragment.kt @@ -149,10 +149,10 @@ class MessageAttachmentsFragment : mEmptyView = view.findViewById(R.id.no_attachments_text) view.findViewById(R.id.button_send).setOnClickListener { parentFragmentManager.setFragmentResult(MESSAGE_CLOSE_ONLY, Bundle()) - (getDialog() ?: return@setOnClickListener).dismiss() + getDialog()?.dismiss() } view.findViewById(R.id.button_hide) - .setOnClickListener { (getDialog() ?: return@setOnClickListener).dismiss() } + .setOnClickListener { getDialog()?.dismiss() } view.findViewById(R.id.button_video).setOnClickListener { presenter?.fireButtonVideoClick() } @@ -212,16 +212,14 @@ class MessageAttachmentsFragment : } override fun displayAttachments(entries: List) { - if (mRecyclerView != null) { + mRecyclerView?.let { mAdapter = AttachmentsBottomSheetAdapter(entries, this) - (mRecyclerView ?: return).adapter = mAdapter + it.adapter = mAdapter } } override fun notifyDataAdded(positionStart: Int, count: Int) { - if (mAdapter != null) { - (mAdapter ?: return).notifyItemRangeInserted(positionStart + 1, count) - } + mAdapter?.notifyItemRangeInserted(positionStart + 1, count) } override fun addPhoto(accountId: Long, ownerId: Long) { @@ -236,9 +234,7 @@ class MessageAttachmentsFragment : } override fun notifyEntryRemoved(index: Int) { - if (mAdapter != null) { - (mAdapter ?: return).notifyItemRemoved(index + 1) - } + mAdapter?.notifyItemRemoved(index + 1) } override fun displaySelectUploadPhotoSizeDialog(photos: List) { @@ -295,15 +291,11 @@ class MessageAttachmentsFragment : } override fun changePercentageSmoothly(id: Int, progress: Int) { - if (mAdapter != null) { - (mAdapter ?: return).changeUploadProgress(id, progress, true) - } + mAdapter?.changeUploadProgress(id, progress, true) } override fun notifyItemChanged(index: Int) { - if (mAdapter != null) { - (mAdapter ?: return).notifyItemChanged(index + 1) - } + mAdapter?.notifyItemChanged(index + 1) } override fun setEmptyViewVisible(visible: Boolean) { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/sheet/MessageAttachmentsPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/sheet/MessageAttachmentsPresenter.kt index a73efe245..b2fd9b522 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/sheet/MessageAttachmentsPresenter.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/messages/chat/sheet/MessageAttachmentsPresenter.kt @@ -119,16 +119,17 @@ class MessageAttachmentsPresenter( for (i in uploads.indices.reversed()) { val upload = uploads[i] if (destination.compareTo(upload.destination)) { - val entry = AttachmentEntry(true, upload) - entries.add(0, entry) - count++ + val index = findUploadObjectIndex(upload.getObjectId()) + if (index == -1) { + val entry = AttachmentEntry(true, upload) + entries.add(0, entry) + count++ + } } } - val finalCount = count - view?.notifyDataAdded( - 0, - finalCount - ) + if (count > 0) { + view?.notifyDataAdded(0, count) + } resolveEmptyViewVisibility() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/VideosListPresenter.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/VideosListPresenter.kt index efba586f7..282ea561b 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/VideosListPresenter.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/VideosListPresenter.kt @@ -119,16 +119,20 @@ class VideosListPresenter( } private fun onUploadsAdded(added: List) { + var count = 0 + val cur = uploadsData.size for (u in added) { if (destination.compareTo(u.destination)) { - val index = uploadsData.size - uploadsData.add(u) - view?.notifyUploadItemsAdded( - index, - 1 - ) + val index = findIndexById(uploadsData, u.getObjectId()) + if (index == -1) { + uploadsData.add(u) + count++ + } } } + if (count > 0) { + view?.notifyUploadItemsAdded(cur, count) + } resolveUploadDataVisibility() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/videoalbums/VideoAlbumsFragment.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/videoalbums/VideoAlbumsFragment.kt index d6c493fb0..5be15b28e 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/videoalbums/VideoAlbumsFragment.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/fragment/videos/videoalbums/VideoAlbumsFragment.kt @@ -65,8 +65,8 @@ class VideoAlbumsFragment : BaseMvpFragment internal constructor( } private fun onUploadsAdded(added: List) { + var count = 0 + val cur = uploadsData.size for (u in added) { if (listOf(Method.STORY, Method.PHOTO_TO_PROFILE).contains(u.destination.method)) { - val index = uploadsData.size - uploadsData.add(u) - view?.notifyUploadItemsAdded( - index, - 1 - ) + val index = Utils.findIndexById(uploadsData, u.getObjectId()) + if (index == -1) { + uploadsData.add(u) + count++ + } } } + if (count > 0) { + view?.notifyUploadItemsAdded(cur, count) + } resolveUploadDataVisibility() } diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/place/Place.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/place/Place.kt index 6bfac19e6..26a38109c 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/place/Place.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/place/Place.kt @@ -80,6 +80,11 @@ open class Place : Parcelable { return this } + fun withParcelableArrayList(name: String, value: ArrayList?): Place { + prepareArguments().putParcelableArrayList(name, value) + return this + } + fun prepareArguments(): Bundle { if (args == null) { args = Bundle() diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/place/PlaceFactory.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/place/PlaceFactory.kt index 68a8ba5c5..fabd6241f 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/place/PlaceFactory.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/place/PlaceFactory.kt @@ -134,11 +134,10 @@ object PlaceFactory { groupId: Long, users: ArrayList? ): Place { - val place = Place(Place.COMMUNITY_MANAGER_ADD) + return Place(Place.COMMUNITY_MANAGER_ADD) .withLongExtra(Extra.ACCOUNT_ID, accountId) .withLongExtra(Extra.GROUP_ID, groupId) - place.prepareArguments().putParcelableArrayList(Extra.USERS, users) - return place + .withParcelableArrayList(Extra.USERS, users) } fun getTmpSourceGalleryPlace(accountId: Long, source: TmpSource, index: Int): Place { @@ -157,11 +156,10 @@ object PlaceFactory { } fun getCommunityAddBanPlace(accountId: Long, groupId: Long, users: ArrayList?): Place { - val place = Place(Place.COMMUNITY_ADD_BAN) + return Place(Place.COMMUNITY_ADD_BAN) .withLongExtra(Extra.ACCOUNT_ID, accountId) .withLongExtra(Extra.GROUP_ID, groupId) - place.prepareArguments().putParcelableArrayList(Extra.USERS, users) - return place + .withParcelableArrayList(Extra.USERS, users) } fun getCommunityBanEditPlace(accountId: Long, groupId: Long, banned: Banned?): Place { @@ -467,11 +465,13 @@ object PlaceFactory { @InternalVideoSize size: Int, isLocal: Boolean ): Place { - val place = Place(Place.VK_INTERNAL_PLAYER) - place.prepareArguments().putParcelable(VideoPlayerActivity.EXTRA_VIDEO, video) - place.prepareArguments().putInt(VideoPlayerActivity.EXTRA_SIZE, size) - place.prepareArguments().putBoolean(VideoPlayerActivity.EXTRA_LOCAL, isLocal) - return place + return Place(Place.VK_INTERNAL_PLAYER).setArguments( + VideoPlayerActivity.buildArgs( + video, + size, + isLocal + ) + ) } fun getResolveDomainPlace(aid: Long, url: String?, domain: String?): Place { diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/settings/theme/ThemesController.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/settings/theme/ThemesController.kt index a283b4b88..2c82ee119 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/settings/theme/ThemesController.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/settings/theme/ThemesController.kt @@ -104,24 +104,6 @@ object ThemesController { R.style.App_DayNight_Gray_Amoled, R.style.App_DayNight_Gray_MD1 ), - ThemeValue( - "blue_violet", - "#448AFF", - "#8500FF", - "Ice Violet", - R.style.App_DayNight_BlueViolet, - R.style.App_DayNight_BlueViolet_Amoled, - R.style.App_DayNight_BlueViolet_MD1 - ).toast("#4D7198", "#448AFF"), - ThemeValue( - "blue_yellow", - "#448AFF", - "#FFA726", - "Ice Fire", - R.style.App_DayNight_BlueYellow, - R.style.App_DayNight_BlueYellow_Amoled, - R.style.App_DayNight_BlueYellow_MD1 - ).toast("#4D7198", "#448AFF"), ThemeValue( "yellow_violet", "#FF9800", @@ -131,24 +113,6 @@ object ThemesController { R.style.App_DayNight_YellowViolet_Amoled, R.style.App_DayNight_YellowViolet_MD1 ), - ThemeValue( - "violet_yellow", - "#8500FF", - "#FF9800", - "Violet Fire", - R.style.App_DayNight_VioletYellow, - R.style.App_DayNight_VioletYellow_Amoled, - R.style.App_DayNight_VioletYellow_MD1 - ), - ThemeValue( - "violet_red", - "#9800FF", - "#F44336", - "Violet Red", - R.style.App_DayNight_VioletRed, - R.style.App_DayNight_VioletRed_Amoled, - R.style.App_DayNight_VioletRed_MD1 - ), ThemeValue( "red_violet", "#F44336", @@ -205,24 +169,6 @@ object ThemesController { R.style.App_DayNight_PinkGray_Amoled, R.style.App_DayNight_PinkGray_MD1 ), - ThemeValue( - "violet_green", - "#8500FF", - "#268000", - "Violet Green", - R.style.App_DayNight_VioletGreen, - R.style.App_DayNight_VioletGreen_Amoled, - R.style.App_DayNight_VioletGreen_MD1 - ), - ThemeValue( - "green_violet", - "#268000", - "#8500FF", - "Green Violet", - R.style.App_DayNight_GreenViolet, - R.style.App_DayNight_GreenViolet_Amoled, - R.style.App_DayNight_GreenViolet_MD1 - ), ThemeValue( "violet_ice", "#757AFF", diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/upload/IUploadManager.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/upload/IUploadManager.kt index bb0c7f125..2c10f48c6 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/upload/IUploadManager.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/upload/IUploadManager.kt @@ -10,6 +10,7 @@ interface IUploadManager { operator fun get(accountId: Long, @Method filters: List): Flow> fun enqueue(intents: List) fun cancel(id: Int) + fun retry(id: Int) fun cancelAll(accountId: Long, destination: UploadDestination) fun getCurrent(): Optional fun observeDeleting(includeCompleted: Boolean): Flow diff --git a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/upload/UploadManagerImpl.kt b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/upload/UploadManagerImpl.kt index 259147f6a..2b36428ad 100644 --- a/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/upload/UploadManagerImpl.kt +++ b/app_fenrir/src/main/kotlin/dev/ragnarok/fenrir/upload/UploadManagerImpl.kt @@ -155,11 +155,10 @@ class UploadManagerImpl( } val builder: NotificationCompat.Builder = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID) - builder.setContentTitle(context.getString(R.string.files_uploading_notification_title)) - .setSmallIcon(R.drawable.ic_notification_upload) - .setOngoing(true) - .setProgress(100, it.progress, false) - .build() + .setContentTitle(context.getString(R.string.files_uploading_notification_title) + " " + it.progress.toString() + "%") + .setSmallIcon(R.drawable.ic_notification_upload) + .setOngoing(true) + .setProgress(100, it.progress, false) if (AppPerms.hasNotificationPermissionSimple(context)) { notificationManager.notify(NotificationHelper.NOTIFICATION_UPLOAD, builder.build()) } @@ -228,12 +227,16 @@ class UploadManagerImpl( server, WeakProgressPublisher(first) ).catch { - onUploadFail(first, it) + if (isActive()) { + onUploadFail(first, it) + } }.collect { - onUploadComplete( - first, - it - ) + if (isActive()) { + onUploadComplete( + first, + it + ) + } } } ) @@ -257,8 +260,8 @@ class UploadManagerImpl( upload )] = result.server completeProcessor.myEmit(create(upload, result)) - startIfNotStartedInternal() } + startIfNotStartedInternal() } private fun onUploadFail(upload: Upload, t: Throwable) { @@ -284,13 +287,13 @@ class UploadManagerImpl( } upload.setStatus(Upload.STATUS_ERROR).errorText = errorMessage statusProcessor.myEmit(upload) - startIfNotStartedInternal() } + startIfNotStartedInternal() } override fun cancel(id: Int) { synchronized(this) { - if (current != null && (current ?: return@synchronized).getObjectId() == id) { + if (current?.getObjectId() == id) { compositeDisposable.clear() current = null } @@ -303,6 +306,18 @@ class UploadManagerImpl( } } + override fun retry(id: Int) { + synchronized(this) { + val index = findIndexById(queue, id) + if (index != -1) { + val upload = queue[index] + upload.setStatus(Upload.STATUS_QUEUE).errorText = null + statusProcessor.myEmit(upload) + startIfNotStarted() + } + } + } + override fun cancelAll(accountId: Long, destination: UploadDestination) { synchronized(this) { if (current != null && accountId == current?.accountId && destination.compareTo( diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPack.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPack.kt index 50baffd14..9707cdf9d 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPack.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPack.kt @@ -42,13 +42,16 @@ import okio.BufferedSource * * @see MsgPack.Default The instance using default configurations. */ -open class MsgPack @JvmOverloads constructor( +open class MsgPack +@JvmOverloads +constructor( private val configuration: MsgPackConfiguration = MsgPackConfiguration.default, - final override val serializersModule: SerializersModule = SerializersModule { - contextual(Any::class, MsgPackDynamicSerializer) - }, + final override val serializersModule: SerializersModule = + SerializersModule { + contextual(Any::class, MsgPackDynamicSerializer) + }, private val inlineEncoders: Map Encoder> = mapOf(), - private val inlineDecoders: Map Decoder> = mapOf() + private val inlineDecoders: Map Decoder> = mapOf(), ) : BinaryFormat { companion object Default : MsgPack() @@ -73,16 +76,17 @@ open class MsgPack @JvmOverloads constructor( final override fun decodeFromByteArray( deserializer: DeserializationStrategy, - bytes: ByteArray + bytes: ByteArray, ): T { - val decoder = MsgPackDecoder( - BasicMsgPackDecoder( - configuration, - serializersModule, - bytes.toMsgPackArrayBuffer(), - inlineDecoders = inlineDecoders + val decoder = + MsgPackDecoder( + BasicMsgPackDecoder( + configuration, + serializersModule, + bytes.toMsgPackArrayBuffer(), + inlineDecoders = inlineDecoders + ), ) - ) return decoder.decodeSerializableValue(deserializer) } @@ -111,7 +115,7 @@ open class MsgPack @JvmOverloads constructor( final override fun encodeToByteArray( serializer: SerializationStrategy, - value: T + value: T, ): ByteArray { val encoder = MsgPackEncoder( BasicMsgPackEncoder( @@ -127,7 +131,7 @@ open class MsgPack @JvmOverloads constructor( onSuccess = { return encoder.result.toByteArray() }, onFailure = { throw it - } + }, ) } diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPackConfiguration.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPackConfiguration.kt index 39ce0c8c8..40de30661 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPackConfiguration.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPackConfiguration.kt @@ -40,7 +40,7 @@ data class MsgPackConfiguration( * Encode enum values as Ints corresponding to their ordinal values * false by default */ - val ordinalEnums: Boolean = false + val ordinalEnums: Boolean = false, ) { companion object { val default: MsgPackConfiguration = MsgPackConfiguration() diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPackDynamicSerializer.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPackDynamicSerializer.kt index 81c1d4a61..0f8c5d5ef 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPackDynamicSerializer.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/MsgPackDynamicSerializer.kt @@ -19,7 +19,7 @@ import kotlinx.serialization.msgpack.types.MsgPackType import kotlinx.serialization.serializer open class MsgPackDynamicSerializer( - private val nullableSerializer: MsgPackNullableDynamicSerializer = MsgPackNullableDynamicSerializer + private val nullableSerializer: MsgPackNullableDynamicSerializer = MsgPackNullableDynamicSerializer, ) : KSerializer { companion object Default : MsgPackDynamicSerializer(MsgPackNullableDynamicSerializer) @@ -31,13 +31,16 @@ open class MsgPackDynamicSerializer( final override val descriptor: SerialDescriptor = buildSerialDescriptor("MsgPackDynamic", SerialKind.CONTEXTUAL) - final override fun serialize(encoder: Encoder, value: Any) { + final override fun serialize( + encoder: Encoder, + value: Any, + ) { nullableSerializer.serialize(encoder, value) } } open class MsgPackNullableDynamicSerializer( - private val dynamicMsgPackExtensionSerializer: DynamicMsgPackExtensionSerializer = DynamicMsgPackExtensionSerializer + private val dynamicMsgPackExtensionSerializer: DynamicMsgPackExtensionSerializer = DynamicMsgPackExtensionSerializer, ) : KSerializer { companion object Default : MsgPackNullableDynamicSerializer(DynamicMsgPackExtensionSerializer) @@ -97,7 +100,10 @@ open class MsgPackNullableDynamicSerializer( @OptIn(InternalSerializationApi::class) @Suppress("UNCHECKED_CAST") - final override fun serialize(encoder: Encoder, value: Any?) { + final override fun serialize( + encoder: Encoder, + value: Any?, + ) { if (value == null) encoder.encodeNull() when ((value ?: return)::class) { Boolean::class -> encoder.encodeBoolean(value as Boolean) diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/exceptions/MsgPackSerializationException.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/exceptions/MsgPackSerializationException.kt index 4de19ce52..86385def8 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/exceptions/MsgPackSerializationException.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/exceptions/MsgPackSerializationException.kt @@ -8,12 +8,14 @@ import kotlinx.serialization.msgpack.stream.MsgPackDataInputOkio import kotlinx.serialization.msgpack.stream.MsgPackDataOutputBuffer private fun ByteArray.toHex() = this.joinToString(separator = "") { it.toHex() } + private fun Byte.toHex() = toInt().and(0xff).toString(16).padStart(2, '0') + private fun MsgPackExtension.toInfoString() = "{type = $type, extTypeId = $extTypeId, data = ${data.toHex()}}" class MsgPackSerializationException private constructor( - override val message: String + override val message: String, ) : SerializationException() { companion object { private fun MsgPackDataInputBuffer.locationInfo(): String { @@ -25,11 +27,11 @@ class MsgPackSerializationException private constructor( ${ it.subList(0, currentIndex()).toByteArray().toHex() }[${peekSafely()}]${it.subList((currentIndex() + 1).coerceAtMost(it.size), it.size)} - ${(0 until currentIndex()).joinToString(separator = "") { " " }}} ^^ ${ - ((currentIndex() + 1) until it.size).joinToString( - separator = "" + ${ + (0 until currentIndex()).joinToString( + separator = "", ) { " " } - } + }} ^^ ${((currentIndex() + 1) until it.size).joinToString(separator = "") { " " }} """.trimIndent() } } @@ -40,36 +42,40 @@ class MsgPackSerializationException private constructor( private fun coreSerialization( buffer: MsgPackDataBuffer, locationInfo: String, - reason: String? = null + reason: String? = null, ): MsgPackSerializationException { val buf = (if (buffer is MsgPackDataInputOkio) buffer.currentIndex() .toString() + " pos" else buffer.toByteArray().toHex()) return MsgPackSerializationException( - "MsgPack Serialization failure while serializing: ${ - buf - }\nReason: $reason\nCurrent position:\n\n$locationInfo" + """ + MsgPack Serialization failure while serializing: $buf + Reason: $reason + Current position: + + $locationInfo + """.trimIndent(), ) } private fun extensionSerialization( extension: MsgPackExtension, - reason: String? = null + reason: String? = null, ): MsgPackSerializationException { return MsgPackSerializationException( - "MsgPack Serialization failure while serializing: ${extension.toInfoString()}\nReason: $reason" + "MsgPack Serialization failure while serializing: ${extension.toInfoString()}\nReason: $reason", ) } fun deserialization( buffer: MsgPackDataInputBuffer, - reason: String? = null + reason: String? = null, ): MsgPackSerializationException { return coreSerialization(buffer, buffer.locationInfo(), reason) } fun serialization( buffer: MsgPackDataOutputBuffer, - reason: String? = null + reason: String? = null, ): MsgPackSerializationException { return coreSerialization(buffer, buffer.locationInfo(), reason) } @@ -77,28 +83,28 @@ class MsgPackSerializationException private constructor( fun extensionSerializationWrongType( extension: MsgPackExtension, expectedType: Byte, - foundType: Byte + foundType: Byte, ): MsgPackSerializationException { return extensionSerialization( extension, - "Expected extension type ${expectedType.toHex()} but found ${foundType.toHex()}. Deserialized extension: $extension" + "Expected extension type ${expectedType.toHex()} but found ${foundType.toHex()}. Deserialized extension: $extension", ) } fun extensionDeserializationWrongType( extension: MsgPackExtension, expectedType: Byte, - foundType: Byte + foundType: Byte, ): MsgPackSerializationException { return extensionSerialization( extension, - "Expected extension type ${expectedType.toHex()} but found ${foundType.toHex()}. Serialized extension: $extension" + "Expected extension type ${expectedType.toHex()} but found ${foundType.toHex()}. Serialized extension: $extension", ) } fun genericExtensionError( extension: MsgPackExtension, - reason: String? = null + reason: String? = null, ): MsgPackSerializationException { return extensionSerialization(extension, reason) } @@ -118,7 +124,7 @@ class MsgPackSerializationException private constructor( fun strictTypeError( buffer: MsgPackDataInputBuffer, expectedType: String, - foundType: String + foundType: String, ): MsgPackSerializationException { return deserialization( buffer, diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/BaseMsgPackExtensionSerializer.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/BaseMsgPackExtensionSerializer.kt index f573f8349..05804e8cb 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/BaseMsgPackExtensionSerializer.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/BaseMsgPackExtensionSerializer.kt @@ -23,7 +23,10 @@ abstract class BaseMsgPackExtensionSerializer : KSerializer { final override val descriptor: SerialDescriptor = serializer.descriptor - override fun serialize(encoder: Encoder, value: T) { + override fun serialize( + encoder: Encoder, + value: T, + ) { val extension = serialize(value) if (checkTypeId && extension.extTypeId != extTypeId) { throw MsgPackSerializationException.extensionSerializationWrongType( @@ -36,7 +39,9 @@ abstract class BaseMsgPackExtensionSerializer : KSerializer { } abstract fun deserialize(extension: MsgPackExtension): T + abstract fun serialize(extension: T): MsgPackExtension + abstract val extTypeId: Byte internal open val checkTypeId: Boolean = true } diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/DynamicMsgPackExtensionSerializer.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/DynamicMsgPackExtensionSerializer.kt index a4725435e..fe753159e 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/DynamicMsgPackExtensionSerializer.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/DynamicMsgPackExtensionSerializer.kt @@ -5,6 +5,7 @@ import kotlin.reflect.KClass open class DynamicMsgPackExtensionSerializer : BaseMsgPackExtensionSerializer() { companion object Default : DynamicMsgPackExtensionSerializer() + private data class SerializerPair( val klass: KClass, val serializer: BaseMsgPackExtensionSerializer @@ -25,7 +26,10 @@ open class DynamicMsgPackExtensionSerializer : BaseMsgPackExtensionSerializer register(serializer: BaseMsgPackExtensionSerializer, klass: KClass) { + fun register( + serializer: BaseMsgPackExtensionSerializer, + klass: KClass, + ) { serializers[serializer.extTypeId] = SerializerPair(klass, serializer) } diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/MsgPackExtension.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/MsgPackExtension.kt index f65fcc7bc..0ce98de52 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/MsgPackExtension.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/MsgPackExtension.kt @@ -7,7 +7,7 @@ import kotlinx.serialization.msgpack.types.MsgPackType class MsgPackExtension( val type: Byte, val extTypeId: Byte, - val data: ByteArray + val data: ByteArray, ) { object Type { const val FIXEXT1 = MsgPackType.Ext.FIXEXT1 diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/MsgPackTimestampExtension.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/MsgPackTimestampExtension.kt index 3e61abe8b..a0c7d9e9a 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/MsgPackTimestampExtension.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/extensions/MsgPackTimestampExtension.kt @@ -12,6 +12,7 @@ sealed class MsgPackTimestamp { } data class T32(val seconds: Long) : MsgPackTimestamp() + data class T64(val seconds: Long, val nanoseconds: Int = 0) : MsgPackTimestamp() { init { if (nanoseconds > NANOSECONDS_MAX) { @@ -47,17 +48,19 @@ open class MsgPackTimestampExtensionSerializer : MsgPackExtension.Type.FIXEXT8 -> { // Working with Timestamp 64 - val nanoseconds = extension.data - .take(4) - .toByteArray() - .joinToNumber() - .shr(2) // Shift right by 2 to get 30-bit number - .toInt() - val seconds = extension.data[3].toLong().shl(62).ushr(30) + - extension.data - .takeLast(4) - .toByteArray() - .joinToNumber() + val nanoseconds = + extension.data + .take(4) + .toByteArray() + .joinToNumber() + .shr(2) // Shift right by 2 to get 30-bit number + .toInt() + val seconds = + extension.data[3].toLong().shl(62).ushr(30) + + extension.data + .takeLast(4) + .toByteArray() + .joinToNumber() return MsgPackTimestamp.T64(seconds, nanoseconds) } @@ -66,34 +69,37 @@ open class MsgPackTimestampExtensionSerializer : if (extension.data.size != TIMESTAMP_96_DATA_SIZE) { throw MsgPackSerializationException.genericExtensionError( extension, - "Error when parsing datetime. Expected data size of $TIMESTAMP_96_DATA_SIZE, but found ${extension.data.size}" + "Error when parsing datetime. Expected data size of $TIMESTAMP_96_DATA_SIZE, but found ${extension.data.size}", ) } - val nanoseconds = extension.data - .take(4) - .toByteArray() - .joinToNumber() - val seconds = extension.data - .takeLast(8) - .toByteArray() - .joinToNumber() + val nanoseconds = + extension.data + .take(4) + .toByteArray() + .joinToNumber() + val seconds = + extension.data + .takeLast(8) + .toByteArray() + .joinToNumber() return MsgPackTimestamp.T92(seconds, nanoseconds) } else -> throw MsgPackSerializationException.genericExtensionError( extension, - "Unsupported extension type for timestamp: ${extension.type}" + "Unsupported extension type for timestamp: ${extension.type}", ) } } final override fun serialize(extension: MsgPackTimestamp): MsgPackExtension { return when (extension) { - is MsgPackTimestamp.T32 -> MsgPackExtension( - MsgPackExtension.Type.FIXEXT4, - extTypeId, - extension.seconds.toInt().splitToByteArray() - ) + is MsgPackTimestamp.T32 -> + MsgPackExtension( + MsgPackExtension.Type.FIXEXT4, + extTypeId, + extension.seconds.toInt().splitToByteArray(), + ) is MsgPackTimestamp.T64 -> { val nanoseconds = extension.nanoseconds.shl(2).splitToByteArray() @@ -105,16 +111,17 @@ open class MsgPackTimestampExtensionSerializer : MsgPackExtension( MsgPackExtension.Type.FIXEXT8, extTypeId, - nanoseconds.take(3).toByteArray() + combinedByte + seconds.takeLast(4) + nanoseconds.take(3).toByteArray() + combinedByte + seconds.takeLast(4), ) } - is MsgPackTimestamp.T92 -> MsgPackExtension( - MsgPackExtension.Type.EXT8, - extTypeId, - extension.nanoseconds.toInt() - .splitToByteArray() + extension.seconds.splitToByteArray() - ) + is MsgPackTimestamp.T92 -> + MsgPackExtension( + MsgPackExtension.Type.EXT8, + extTypeId, + extension.nanoseconds.toInt() + .splitToByteArray() + extension.seconds.splitToByteArray(), + ) } } } diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPackDecoder.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPackDecoder.kt index 93d1bb317..2ae7cde8d 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPackDecoder.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPackDecoder.kt @@ -26,7 +26,7 @@ internal class BasicMsgPackDecoder( override val serializersModule: SerializersModule, val dataBuffer: MsgPackDataInputBuffer, private val msgUnpacker: MsgUnpacker = BasicMsgUnpacker(dataBuffer), - val inlineDecoders: Map Decoder> = mapOf() + val inlineDecoders: Map Decoder> = mapOf(), ) : AbstractDecoder(), MsgPackTypeDecoder { fun decodeMsgPackElement(): JsonElement = MsgPackTreeReader(this).read() fun getConfiguration(): MsgPackConfiguration { @@ -246,7 +246,7 @@ internal class BasicMsgPackDecoder( } internal class MsgPackDecoder( - private val basicMsgPackDecoder: BasicMsgPackDecoder + private val basicMsgPackDecoder: BasicMsgPackDecoder, ) : Decoder by basicMsgPackDecoder, CompositeDecoder by basicMsgPackDecoder, MsgPackTypeDecoder by basicMsgPackDecoder { override val serializersModule: SerializersModule = basicMsgPackDecoder.serializersModule @@ -255,7 +255,7 @@ internal class MsgPackDecoder( internal class ClassMsgPackDecoder( private val basicMsgPackDecoder: BasicMsgPackDecoder, private val configuration: MsgPackConfiguration, - private val size: Int + private val size: Int, ) : Decoder by basicMsgPackDecoder, CompositeDecoder by basicMsgPackDecoder, MsgPackTypeDecoder by basicMsgPackDecoder { override val serializersModule: SerializersModule = basicMsgPackDecoder.serializersModule @@ -277,7 +277,7 @@ internal class ClassMsgPackDecoder( } internal class ExtensionTypeDecoder( - private val basicMsgPackDecoder: BasicMsgPackDecoder + private val basicMsgPackDecoder: BasicMsgPackDecoder, ) : CompositeDecoder, AbstractDecoder(), MsgPackTypeDecoder by basicMsgPackDecoder { private val dataBuffer = basicMsgPackDecoder.dataBuffer var type: Byte? = null @@ -340,5 +340,5 @@ internal class ExtensionTypeDecoder( data class InlineDecoderHelper( val serializersModule: SerializersModule, - val inputBuffer: MsgPackDataInputBuffer + val inputBuffer: MsgPackDataInputBuffer, ) diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPackEncoder.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPackEncoder.kt index 3a31e6a36..904408fe0 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPackEncoder.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPackEncoder.kt @@ -22,7 +22,7 @@ internal class BasicMsgPackEncoder( override val serializersModule: SerializersModule, private val packer: MsgPacker = BasicMsgPacker(), compressed: Boolean, - val inlineEncoders: Map Encoder> = mapOf() + val inlineEncoders: Map Encoder> = mapOf(), ) : AbstractEncoder() { val result: MsgPackDataOutputBuffer = if (compressed) MsgPackDataOutputArrayBufferCompressed() else MsgPackDataOutputArrayBuffer() @@ -63,7 +63,10 @@ internal class BasicMsgPackEncoder( result.addAll(packer.packString(value, configuration.rawCompatibility)) } - override fun encodeEnum(enumDescriptor: SerialDescriptor, index: Int) { + override fun encodeEnum( + enumDescriptor: SerialDescriptor, + index: Int, + ) { if (configuration.ordinalEnums) { result.addAll(packer.packInt(index, configuration.strictTypeWriting)) } else { @@ -111,7 +114,7 @@ internal class BasicMsgPackEncoder( override fun beginCollection( descriptor: SerialDescriptor, - collectionSize: Int + collectionSize: Int, ): CompositeEncoder { when (descriptor.kind) { StructureKind.LIST -> @@ -166,7 +169,10 @@ internal class BasicMsgPackEncoder( return this } - override fun encodeSerializableValue(serializer: SerializationStrategy, value: T) { + override fun encodeSerializableValue( + serializer: SerializationStrategy, + value: T, + ) { if (serializer == ByteArraySerializer()) { encodeByteArray(value as ByteArray) } else { @@ -180,14 +186,14 @@ internal class BasicMsgPackEncoder( } internal class MsgPackEncoder( - private val basicMsgPackEncoder: BasicMsgPackEncoder + private val basicMsgPackEncoder: BasicMsgPackEncoder, ) : Encoder by basicMsgPackEncoder, CompositeEncoder by basicMsgPackEncoder { override val serializersModule: SerializersModule = basicMsgPackEncoder.serializersModule val result = basicMsgPackEncoder.result } internal class ExtensionTypeEncoder( - basicMsgPackEncoder: BasicMsgPackEncoder + basicMsgPackEncoder: BasicMsgPackEncoder, ) : AbstractEncoder() { override val serializersModule: SerializersModule = basicMsgPackEncoder.serializersModule val result = basicMsgPackEncoder.result @@ -212,25 +218,29 @@ internal class ExtensionTypeEncoder( bytesWritten += 1 } - override fun encodeSerializableValue(serializer: SerializationStrategy, value: T) { + override fun encodeSerializableValue( + serializer: SerializationStrategy, + value: T, + ) { val valueByteArray = value as ByteArray if (size == null) { size = valueByteArray.size - val maxSize = when (type) { - MsgPackType.Ext.EXT8 -> MsgPackType.Ext.MAX_EXT8_LENGTH - MsgPackType.Ext.EXT16 -> MsgPackType.Ext.MAX_EXT16_LENGTH - MsgPackType.Ext.EXT32 -> MsgPackType.Ext.MAX_EXT32_LENGTH - else -> throw MsgPackSerializationException.serialization( + val maxSize = + when (type) { + MsgPackType.Ext.EXT8 -> MsgPackType.Ext.MAX_EXT8_LENGTH + MsgPackType.Ext.EXT16 -> MsgPackType.Ext.MAX_EXT16_LENGTH + MsgPackType.Ext.EXT32 -> MsgPackType.Ext.MAX_EXT32_LENGTH + else -> throw MsgPackSerializationException.serialization( + result, + "Unexpected extension type: $type" + ) + }.toLong() + if ((size ?: return).toLong() > maxSize) { + throw MsgPackSerializationException.serialization( result, - "Unexpected extension type: $type" + "Size ($size) too long for extension type ($maxSize)!", ) - }.toLong() - if ((size - ?: return).toLong() > maxSize - ) throw MsgPackSerializationException.serialization( - result, - "Size ($size) too long for extension type ($maxSize)!" - ) + } result.addAll( when (type) { MsgPackType.Ext.EXT8 -> (size ?: return).toByte().splitToByteArray() @@ -240,76 +250,120 @@ internal class ExtensionTypeEncoder( result, "Unexpected extension type: $type" ) - } + }, ) result.add(typeId ?: return) } else { - if (valueByteArray.size != size) throw MsgPackSerializationException.serialization( - result, - "Invalid size for fixed size extension type! Expected $size but found ${valueByteArray.size}" - ) + if (valueByteArray.size != size) { + throw MsgPackSerializationException.serialization( + result, + "Invalid size for fixed size extension type! Expected $size but found ${valueByteArray.size}", + ) + } } result.addAll(valueByteArray) } } internal class MsgPackClassEncoder( - private val basicMsgPackEncoder: BasicMsgPackEncoder + private val basicMsgPackEncoder: BasicMsgPackEncoder, ) : Encoder by basicMsgPackEncoder, CompositeEncoder by basicMsgPackEncoder { override val serializersModule: SerializersModule = basicMsgPackEncoder.serializersModule val result = basicMsgPackEncoder.result - private fun encodeName(descriptor: SerialDescriptor, index: Int) { + private fun encodeName( + descriptor: SerialDescriptor, + index: Int, + ) { encodeString(descriptor.getElementName(index)) } - override fun encodeBooleanElement(descriptor: SerialDescriptor, index: Int, value: Boolean) { + override fun encodeBooleanElement( + descriptor: SerialDescriptor, + index: Int, + value: Boolean, + ) { encodeName(descriptor, index) encodeBoolean(value) } - override fun encodeByteElement(descriptor: SerialDescriptor, index: Int, value: Byte) { + override fun encodeByteElement( + descriptor: SerialDescriptor, + index: Int, + value: Byte, + ) { encodeName(descriptor, index) encodeByte(value) } - override fun encodeCharElement(descriptor: SerialDescriptor, index: Int, value: Char) { + override fun encodeCharElement( + descriptor: SerialDescriptor, + index: Int, + value: Char, + ) { encodeName(descriptor, index) encodeChar(value) } - override fun encodeDoubleElement(descriptor: SerialDescriptor, index: Int, value: Double) { + override fun encodeDoubleElement( + descriptor: SerialDescriptor, + index: Int, + value: Double, + ) { encodeName(descriptor, index) encodeDouble(value) } - override fun encodeFloatElement(descriptor: SerialDescriptor, index: Int, value: Float) { + override fun encodeFloatElement( + descriptor: SerialDescriptor, + index: Int, + value: Float, + ) { encodeName(descriptor, index) encodeFloat(value) } @ExperimentalSerializationApi - override fun encodeInlineElement(descriptor: SerialDescriptor, index: Int): Encoder { + override fun encodeInlineElement( + descriptor: SerialDescriptor, + index: Int, + ): Encoder { encodeName(descriptor, index) return basicMsgPackEncoder.encodeInline(descriptor) } - override fun encodeIntElement(descriptor: SerialDescriptor, index: Int, value: Int) { + override fun encodeIntElement( + descriptor: SerialDescriptor, + index: Int, + value: Int, + ) { encodeName(descriptor, index) encodeInt(value) } - override fun encodeLongElement(descriptor: SerialDescriptor, index: Int, value: Long) { + override fun encodeLongElement( + descriptor: SerialDescriptor, + index: Int, + value: Long, + ) { encodeName(descriptor, index) encodeLong(value) } - override fun encodeShortElement(descriptor: SerialDescriptor, index: Int, value: Short) { + override fun encodeShortElement( + descriptor: SerialDescriptor, + index: Int, + value: Short, + ) { encodeName(descriptor, index) encodeShort(value) } - override fun encodeStringElement(descriptor: SerialDescriptor, index: Int, value: String) { + override fun encodeStringElement( + descriptor: SerialDescriptor, + index: Int, + value: String, + ) { encodeName(descriptor, index) encodeString(value) } @@ -323,7 +377,7 @@ internal class MsgPackClassEncoder( descriptor: SerialDescriptor, index: Int, serializer: SerializationStrategy, - value: T? + value: T?, ) { encodeName(descriptor, index) encodeNullableSerializableValue(serializer, value) @@ -333,7 +387,7 @@ internal class MsgPackClassEncoder( descriptor: SerialDescriptor, index: Int, serializer: SerializationStrategy, - value: T + value: T, ) { encodeName(descriptor, index) encodeSerializableValue(serializer, value) @@ -342,5 +396,5 @@ internal class MsgPackClassEncoder( data class InlineEncoderHelper( val serializersModule: SerializersModule, - val outputBuffer: MsgPackDataOutputBuffer + val outputBuffer: MsgPackDataOutputBuffer, ) diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPacker.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPacker.kt index 941003366..21c78225a 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPacker.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgPacker.kt @@ -6,14 +6,38 @@ import kotlinx.serialization.msgpack.utils.splitToByteArray internal interface MsgPacker { fun packNull(): ByteArray + fun packBoolean(value: Boolean): ByteArray - fun packByte(value: Byte, strict: Boolean = false): ByteArray - fun packShort(value: Short, strict: Boolean = false): ByteArray - fun packInt(value: Int, strict: Boolean = false): ByteArray - fun packLong(value: Long, strict: Boolean = false): ByteArray + + fun packByte( + value: Byte, + strict: Boolean = false, + ): ByteArray + + fun packShort( + value: Short, + strict: Boolean = false, + ): ByteArray + + fun packInt( + value: Int, + strict: Boolean = false, + ): ByteArray + + fun packLong( + value: Long, + strict: Boolean = false, + ): ByteArray + fun packFloat(value: Float): ByteArray + fun packDouble(value: Double): ByteArray - fun packString(value: String, rawCompatibility: Boolean = false): ByteArray + + fun packString( + value: String, + rawCompatibility: Boolean = false, + ): ByteArray + fun packByteArray(value: ByteArray): ByteArray } @@ -26,7 +50,10 @@ internal class BasicMsgPacker : MsgPacker { return byteArrayOf(MsgPackType.Boolean(value)) } - override fun packByte(value: Byte, strict: Boolean): ByteArray { + override fun packByte( + value: Byte, + strict: Boolean, + ): ByteArray { return if (value >= MsgPackType.Int.MIN_NEGATIVE_SINGLE_BYTE) { byteArrayOf(value) } else { @@ -34,7 +61,10 @@ internal class BasicMsgPacker : MsgPacker { } } - override fun packShort(value: Short, strict: Boolean): ByteArray { + override fun packShort( + value: Short, + strict: Boolean, + ): ByteArray { return if (value in MsgPackType.Int.MIN_NEGATIVE_BYTE..Byte.MAX_VALUE && !strict) { packByte(value.toByte()) } else { @@ -56,7 +86,10 @@ internal class BasicMsgPacker : MsgPacker { } } - override fun packInt(value: Int, strict: Boolean): ByteArray { + override fun packInt( + value: Int, + strict: Boolean, + ): ByteArray { return if (value in Short.MIN_VALUE..Short.MAX_VALUE && !strict) { packShort(value.toShort()) } else { @@ -78,7 +111,10 @@ internal class BasicMsgPacker : MsgPacker { } } - override fun packLong(value: Long, strict: Boolean): ByteArray { + override fun packLong( + value: Long, + strict: Boolean, + ): ByteArray { return if (value in Int.MIN_VALUE..Int.MAX_VALUE && !strict) { packInt(value.toInt()) } else { @@ -108,46 +144,55 @@ internal class BasicMsgPacker : MsgPacker { return byteArrayOf(MsgPackType.Float.DOUBLE) + value.toRawBits().splitToByteArray() } - override fun packString(value: String, rawCompatibility: Boolean): ByteArray { + override fun packString( + value: String, + rawCompatibility: Boolean, + ): ByteArray { val bytes = value.encodeToByteArray() - val prefix = when { - bytes.size <= MsgPackType.String.MAX_FIXSTR_LENGTH -> { - byteArrayOf(MsgPackType.String.FIXSTR_SIZE_MASK.maskValue(bytes.size.toByte())) - } + val prefix = + when { + bytes.size <= MsgPackType.String.MAX_FIXSTR_LENGTH -> { + byteArrayOf(MsgPackType.String.FIXSTR_SIZE_MASK.maskValue(bytes.size.toByte())) + } - bytes.size <= MsgPackType.String.MAX_STR8_LENGTH && !rawCompatibility -> { - byteArrayOf(MsgPackType.String.STR8) + bytes.size.toByte().splitToByteArray() - } + bytes.size <= MsgPackType.String.MAX_STR8_LENGTH && !rawCompatibility -> { + byteArrayOf(MsgPackType.String.STR8) + bytes.size.toByte().splitToByteArray() + } - bytes.size <= MsgPackType.String.MAX_STR16_LENGTH -> { - byteArrayOf(MsgPackType.String.STR16) + bytes.size.toShort().splitToByteArray() - } + bytes.size <= MsgPackType.String.MAX_STR16_LENGTH -> { + byteArrayOf(MsgPackType.String.STR16) + bytes.size.toShort().splitToByteArray() + } - bytes.size <= MsgPackType.String.MAX_STR32_LENGTH -> { - byteArrayOf(MsgPackType.String.STR32) + bytes.size.splitToByteArray() - } + bytes.size <= MsgPackType.String.MAX_STR32_LENGTH -> { + byteArrayOf(MsgPackType.String.STR32) + bytes.size.splitToByteArray() + } - else -> throw MsgPackSerializationException.packingError("String too long. Byte size: ${bytes.size}. Max size: ${MsgPackType.String.MAX_STR32_LENGTH}") - } + else -> throw MsgPackSerializationException.packingError( + "String too long. Byte size: ${bytes.size}. Max size: ${MsgPackType.String.MAX_STR32_LENGTH}", + ) + } return prefix + bytes } override fun packByteArray(value: ByteArray): ByteArray { - val prefix = when { - value.size <= MsgPackType.Bin.MAX_BIN8_LENGTH -> { - byteArrayOf(MsgPackType.Bin.BIN8) + value.size.toByte().splitToByteArray() - } + val prefix = + when { + value.size <= MsgPackType.Bin.MAX_BIN8_LENGTH -> { + byteArrayOf(MsgPackType.Bin.BIN8) + value.size.toByte().splitToByteArray() + } - value.size <= MsgPackType.Bin.MAX_BIN16_LENGTH -> { - byteArrayOf(MsgPackType.Bin.BIN16) + value.size.toShort().splitToByteArray() - } + value.size <= MsgPackType.Bin.MAX_BIN16_LENGTH -> { + byteArrayOf(MsgPackType.Bin.BIN16) + value.size.toShort().splitToByteArray() + } - value.size <= MsgPackType.Bin.MAX_BIN32_LENGTH -> { - byteArrayOf(MsgPackType.Bin.BIN32) + value.size.splitToByteArray() - } + value.size <= MsgPackType.Bin.MAX_BIN32_LENGTH -> { + byteArrayOf(MsgPackType.Bin.BIN32) + value.size.splitToByteArray() + } - else -> throw MsgPackSerializationException.packingError("Byte array too long. Byte size: ${value.size}. Max size: ${MsgPackType.Bin.MAX_BIN32_LENGTH}") - } + else -> throw MsgPackSerializationException.packingError( + "Byte array too long. Byte size: ${value.size}. Max size: ${MsgPackType.Bin.MAX_BIN32_LENGTH}", + ) + } return prefix + value } } diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgUnpacker.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgUnpacker.kt index 6d1114776..c8b7ddd72 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgUnpacker.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/internal/MsgUnpacker.kt @@ -7,14 +7,35 @@ import kotlinx.serialization.msgpack.utils.joinToNumber internal interface MsgUnpacker { fun unpackNull() + fun unpackBoolean(): Boolean - fun unpackByte(strict: Boolean = false, preventOverflow: Boolean = false): Byte - fun unpackShort(strict: Boolean = false, preventOverflow: Boolean = false): Short - fun unpackInt(strict: Boolean = false, preventOverflow: Boolean = false): Int - fun unpackLong(strict: Boolean = false, preventOverflow: Boolean = false): Long + + fun unpackByte( + strict: Boolean = false, + preventOverflow: Boolean = false, + ): Byte + + fun unpackShort( + strict: Boolean = false, + preventOverflow: Boolean = false, + ): Short + + fun unpackInt( + strict: Boolean = false, + preventOverflow: Boolean = false, + ): Int + + fun unpackLong( + strict: Boolean = false, + preventOverflow: Boolean = false, + ): Long + fun unpackFloat(strict: Boolean = false): Float + fun unpackDouble(strict: Boolean = false): Double + fun unpackString(preventOverflow: Boolean = false): String + fun unpackByteArray(preventOverflow: Boolean = false): ByteArray } @@ -32,7 +53,10 @@ internal class BasicMsgUnpacker(private val dataBuffer: MsgPackDataInputBuffer) } } - override fun unpackByte(strict: Boolean, preventOverflow: Boolean): Byte { + override fun unpackByte( + strict: Boolean, + preventOverflow: Boolean, + ): Byte { // Check is it a single byte value val next = dataBuffer.peek() return when { @@ -57,14 +81,22 @@ internal class BasicMsgUnpacker(private val dataBuffer: MsgPackDataInputBuffer) } } - else -> if (strict) throw MsgPackSerializationException.deserialization( - dataBuffer, - "Expected byte type, but found $next" - ) else unpackNumber(preventOverflow).toByte() + else -> + if (strict) { + throw MsgPackSerializationException.deserialization( + dataBuffer, + "Expected byte type, but found $next", + ) + } else { + unpackNumber(preventOverflow).toByte() + } } } - override fun unpackShort(strict: Boolean, preventOverflow: Boolean): Short { + override fun unpackShort( + strict: Boolean, + preventOverflow: Boolean, + ): Short { val next = dataBuffer.peek() return when { MsgPackType.Int.isShort(next) -> { @@ -86,14 +118,22 @@ internal class BasicMsgUnpacker(private val dataBuffer: MsgPackDataInputBuffer) (dataBuffer.requireNextByte().toInt() and 0xff).toShort() } - else -> if (strict) throw MsgPackSerializationException.deserialization( - dataBuffer, - "Expected short type, but found $next" - ) else unpackNumber(preventOverflow).toShort() + else -> + if (strict) { + throw MsgPackSerializationException.deserialization( + dataBuffer, + "Expected short type, but found $next", + ) + } else { + unpackNumber(preventOverflow).toShort() + } } } - override fun unpackInt(strict: Boolean, preventOverflow: Boolean): Int { + override fun unpackInt( + strict: Boolean, + preventOverflow: Boolean, + ): Int { val next = dataBuffer.peek() return when { MsgPackType.Int.isInt(next) -> { @@ -115,14 +155,22 @@ internal class BasicMsgUnpacker(private val dataBuffer: MsgPackDataInputBuffer) dataBuffer.takeNext(2).joinToNumber() } - else -> if (strict) throw MsgPackSerializationException.deserialization( - dataBuffer, - "Expected int type, but found $next" - ) else unpackNumber(preventOverflow).toInt() + else -> + if (strict) { + throw MsgPackSerializationException.deserialization( + dataBuffer, + "Expected int type, but found $next", + ) + } else { + unpackNumber(preventOverflow).toInt() + } } } - override fun unpackLong(strict: Boolean, preventOverflow: Boolean): Long { + override fun unpackLong( + strict: Boolean, + preventOverflow: Boolean, + ): Long { val next = dataBuffer.peek() return when { MsgPackType.Int.isLong(next) -> { @@ -144,10 +192,15 @@ internal class BasicMsgUnpacker(private val dataBuffer: MsgPackDataInputBuffer) dataBuffer.takeNext(4).joinToNumber() } - else -> if (strict) throw MsgPackSerializationException.deserialization( - dataBuffer, - "Expected long type, but found $next" - ) else unpackNumber(preventOverflow).toLong() + else -> + if (strict) { + throw MsgPackSerializationException.deserialization( + dataBuffer, + "Expected long type, but found $next", + ) + } else { + unpackNumber(preventOverflow).toLong() + } } } @@ -158,10 +211,15 @@ internal class BasicMsgUnpacker(private val dataBuffer: MsgPackDataInputBuffer) Float.fromBits(dataBuffer.takeNext(4).joinToNumber()) } - else -> if (strict) throw MsgPackSerializationException.deserialization( - dataBuffer, - "Expected float type, but found $type" - ) else unpackNumber().toFloat() + else -> + if (strict) { + throw MsgPackSerializationException.deserialization( + dataBuffer, + "Expected float type, but found $type", + ) + } else { + unpackNumber().toFloat() + } } } @@ -172,70 +230,78 @@ internal class BasicMsgUnpacker(private val dataBuffer: MsgPackDataInputBuffer) Double.fromBits(dataBuffer.takeNext(8).joinToNumber()) } - else -> if (strict) throw MsgPackSerializationException.deserialization( - dataBuffer, - "Expected double type, but found $type" - ) else unpackNumber().toDouble() + else -> + if (strict) { + throw MsgPackSerializationException.deserialization( + dataBuffer, + "Expected double type, but found $type", + ) + } else { + unpackNumber().toDouble() + } } } override fun unpackString(preventOverflow: Boolean): String { val next = dataBuffer.requireNextByte() - val length = when { - MsgPackType.String.FIXSTR_SIZE_MASK.test(next) -> MsgPackType.String.FIXSTR_SIZE_MASK.unMaskValue( - next - ).toInt() + val length = + when { + MsgPackType.String.FIXSTR_SIZE_MASK.test(next) -> MsgPackType.String.FIXSTR_SIZE_MASK.unMaskValue( + next + ).toInt() - next == MsgPackType.String.STR8 -> dataBuffer.requireNextByte().toInt() and 0xff - next == MsgPackType.String.STR16 -> dataBuffer.takeNext(2).joinToNumber() - next == MsgPackType.String.STR32 -> { - if (preventOverflow) { - val number = dataBuffer.takeNext(4).joinToNumber() - if (number !in Int.MIN_VALUE..Int.MAX_VALUE) { - throw MsgPackSerializationException.overflowError(dataBuffer) + next == MsgPackType.String.STR8 -> dataBuffer.requireNextByte().toInt() and 0xff + next == MsgPackType.String.STR16 -> dataBuffer.takeNext(2).joinToNumber() + next == MsgPackType.String.STR32 -> { + if (preventOverflow) { + val number = dataBuffer.takeNext(4).joinToNumber() + if (number !in Int.MIN_VALUE..Int.MAX_VALUE) { + throw MsgPackSerializationException.overflowError(dataBuffer) + } else { + number.toInt() + } } else { - number.toInt() + dataBuffer.takeNext(4).joinToNumber() } - } else { - dataBuffer.takeNext(4).joinToNumber() } - } - else -> { - throw MsgPackSerializationException.deserialization( - dataBuffer, - "Expected string type, but found $next" - ) + else -> { + throw MsgPackSerializationException.deserialization( + dataBuffer, + "Expected string type, but found $next" + ) + } } - } if (length == 0) return "" return dataBuffer.takeNext(length).decodeToString() } override fun unpackByteArray(preventOverflow: Boolean): ByteArray { - val length = when (val next = dataBuffer.requireNextByte()) { - MsgPackType.Bin.BIN8 -> dataBuffer.requireNextByte().toInt() and 0xff - MsgPackType.Bin.BIN16 -> dataBuffer.takeNext(2).joinToNumber() - MsgPackType.Bin.BIN32 -> { - if (preventOverflow) { - val number = dataBuffer.takeNext(4).joinToNumber() - if (number !in Int.MIN_VALUE..Int.MAX_VALUE) { - throw MsgPackSerializationException.overflowError(dataBuffer) + val next = dataBuffer.requireNextByte() + val length = + when (next) { + MsgPackType.Bin.BIN8 -> dataBuffer.requireNextByte().toInt() and 0xff + MsgPackType.Bin.BIN16 -> dataBuffer.takeNext(2).joinToNumber() + MsgPackType.Bin.BIN32 -> { + if (preventOverflow) { + val number = dataBuffer.takeNext(4).joinToNumber() + if (number !in Int.MIN_VALUE..Int.MAX_VALUE) { + throw MsgPackSerializationException.overflowError(dataBuffer) + } else { + number.toInt() + } } else { - number.toInt() + dataBuffer.takeNext(4).joinToNumber() } - } else { - dataBuffer.takeNext(4).joinToNumber() } - } - else -> { - throw MsgPackSerializationException.deserialization( - dataBuffer, - "Expected binary type, but found $next" - ) + else -> { + throw MsgPackSerializationException.deserialization( + dataBuffer, + "Expected binary type, but found $next" + ) + } } - } if (length == 0) return byteArrayOf() return dataBuffer.takeNext(length) } diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/stream/MsgPackDataBuffer.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/stream/MsgPackDataBuffer.kt index 9d27da12c..150c226bc 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/stream/MsgPackDataBuffer.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/stream/MsgPackDataBuffer.kt @@ -3,10 +3,7 @@ package kotlinx.serialization.msgpack.stream import com.google.common.math.IntMath.mod import dev.ragnarok.fenrir.module.BufferWriteNative import okio.BufferedSource - -interface MsgPackDataBuffer { - fun toByteArray(): ByteArray -} +import kotlin.collections.isNotEmpty abstract class MsgPackDataOutputBuffer : MsgPackDataBuffer { abstract fun add(byte: Byte): Boolean @@ -26,44 +23,41 @@ abstract class MsgPackDataInputBuffer : MsgPackDataBuffer { abstract fun currentIndex(): Int } -class MsgPackDataOutputArrayBufferCompressed : MsgPackDataOutputBuffer() { - private val bytes = BufferWriteNative(8192) +interface MsgPackDataBuffer { + fun toByteArray(): ByteArray +} + +class MsgPackDataOutputArrayBuffer : MsgPackDataOutputBuffer() { + private val byteArrays = mutableListOf() + override fun add(byte: Byte): Boolean { - bytes.putChar(byte) - return true + return byteArrays.add(ByteArray(1) { byte }) } - override fun addAll(bytesList: List): Boolean { - bytes.putByteArray(bytesList.toByteArray()) + override fun addAll(bytes: List): Boolean { + if (bytes.isNotEmpty()) { + return byteArrays.add(bytes.toByteArray()) + } return true } - override fun addAll(bytesArray: ByteArray): Boolean { - bytes.putByteArray(bytesArray) + override fun addAll(bytes: ByteArray): Boolean { + if (bytes.isNotEmpty()) { + return byteArrays.add(bytes) + } return true } - override fun toByteArray() = bytes.compressLZ4Buffer() ?: ByteArray(0) -} - -class MsgPackDataOutputArrayBuffer : MsgPackDataOutputBuffer() { - private val bytes = ArrayList() - override fun add(byte: Byte): Boolean { - if (mod(bytes.size, 8192) == 0) { - bytes.ensureCapacity(bytes.size + 8192) + override fun toByteArray(): ByteArray { + val totalSize = byteArrays.sumOf { it.size } + val outputArray = ByteArray(totalSize) + var currentIndex = 0 + byteArrays.forEach { + it.copyInto(outputArray, currentIndex) + currentIndex += it.size } - return bytes.add(byte) - } - - override fun addAll(bytesList: List): Boolean { - val cap = bytes.size + bytesList.size - val res = ((cap + 8192 - 1) / 8192) * 8192 - bytes.ensureCapacity(res) - return bytes.addAll(bytesList) + return outputArray } - - override fun addAll(bytesArray: ByteArray) = addAll(bytesArray.toList()) - override fun toByteArray() = bytes.toByteArray() } class MsgPackDataInputArrayBuffer(private val byteArray: ByteArray) : MsgPackDataInputBuffer() { @@ -78,11 +72,14 @@ class MsgPackDataInputArrayBuffer(private val byteArray: ByteArray) : MsgPackDat } override fun peek(): Byte = byteArray.getOrNull(index) ?: throw Exception("End of stream") + override fun peekSafely(): Byte? = byteArray.getOrNull(index) // Increases index only if next byte is not null override fun nextByteOrNull(): Byte? = byteArray.getOrNull(index)?.also { index++ } + override fun requireNextByte(): Byte = nextByteOrNull() ?: throw Exception("End of stream") + override fun takeNext(next: Int): ByteArray { require(next > 0) { "Number of bytes to take must be greater than 0!" } val result = ByteArray(next) @@ -92,9 +89,54 @@ class MsgPackDataInputArrayBuffer(private val byteArray: ByteArray) : MsgPackDat return result } - override fun toByteArray(): ByteArray { - return byteArray + override fun toByteArray() = byteArray +} + +class MsgPackDataOutputArrayBufferCompressed : MsgPackDataOutputBuffer() { + private val bytes = BufferWriteNative(8192) + override fun add(byte: Byte): Boolean { + bytes.putChar(byte) + return true + } + + override fun addAll(bytesList: List): Boolean { + if (bytesList.isNotEmpty()) { + bytes.putByteArray(bytesList.toByteArray()) + } + return true + } + + override fun addAll(bytesArray: ByteArray): Boolean { + if (bytesArray.isNotEmpty()) { + bytes.putByteArray(bytesArray) + } + return true + } + + override fun toByteArray() = bytes.compressLZ4Buffer() ?: ByteArray(0) +} + +class MsgPackDataBufferedOutputArrayBuffer : MsgPackDataOutputBuffer() { + private val bytes = ArrayList() + override fun add(byte: Byte): Boolean { + if (mod(bytes.size, 8192) == 0) { + bytes.ensureCapacity(bytes.size + 8192) + } + return bytes.add(byte) + } + + override fun addAll(bytesList: List): Boolean { + if (bytesList.isEmpty()) { + return true + } + val cap = bytes.size + bytesList.size + val res = ((cap + 8192 - 1) / 8192) * 8192 + bytes.ensureCapacity(res) + return bytes.addAll(bytesList) } + + override fun addAll(bytesArray: ByteArray) = addAll(bytesArray.toList()) + override fun toByteArray() = bytes.toByteArray() } class MsgPackDataInputOkio(private val bufferedSource: BufferedSource) : MsgPackDataInputBuffer() { @@ -148,4 +190,4 @@ class MsgPackDataInputOkio(private val bufferedSource: BufferedSource) : MsgPack internal fun ByteArray.toMsgPackArrayBuffer() = MsgPackDataInputArrayBuffer(this) internal fun BufferedSource.toMsgPackBufferedSource() = MsgPackDataInputOkio(this) -//internal fun BufferedSource.toMsgPackBufferedSource() = MsgPackDataInputArrayBuffer(this.readByteArray()) \ No newline at end of file +//internal fun BufferedSource.toMsgPackBufferedSource() = MsgPackDataInputArrayBuffer(this.readByteArray()) diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/types/MsgPackType.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/types/MsgPackType.kt index a38f9c201..0cdfe4e29 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/types/MsgPackType.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/types/MsgPackType.kt @@ -3,14 +3,18 @@ package kotlinx.serialization.msgpack.types internal object MsgPackType { internal object Boolean { operator fun invoke(value: kotlin.Boolean) = if (value) TRUE else FALSE + const val TRUE = 0xc3.toByte() const val FALSE = 0xc2.toByte() } internal interface Mask { operator fun invoke(value: T) = maskValue(value) + fun maskValue(value: T): T + fun test(value: T): kotlin.Boolean + fun unMaskValue(value: T): T = maskValue(value) } @@ -24,17 +28,24 @@ internal object MsgPackType { const val UINT32 = 0xce.toByte() const val UINT64 = 0xcf.toByte() - val POSITIVE_FIXNUM_MASK = object : Mask { - private val mask = 0b01111111 - override fun maskValue(value: Byte): Byte = (mask and value.toInt()).toByte() - override fun test(value: Byte): kotlin.Boolean = (mask or value.toInt()) == mask - } - val NEGATIVE_FIXNUM_MASK = object : Mask { - private val mask = 0b11100000 - override fun maskValue(value: Byte): Byte = (mask or value.toInt()).toByte() - override fun test(value: Byte): kotlin.Boolean = (mask and value.toInt()) == mask - override fun unMaskValue(value: Byte): Byte = (mask xor value.toInt()).toByte() - } + val POSITIVE_FIXNUM_MASK = + object : Mask { + private val mask = 0b01111111 + + override fun maskValue(value: Byte): Byte = (mask and value.toInt()).toByte() + + override fun test(value: Byte): kotlin.Boolean = (mask or value.toInt()) == mask + } + val NEGATIVE_FIXNUM_MASK = + object : Mask { + private val mask = 0b11100000 + + override fun maskValue(value: Byte): Byte = (mask or value.toInt()).toByte() + + override fun test(value: Byte): kotlin.Boolean = (mask and value.toInt()) == mask + + override fun unMaskValue(value: Byte): Byte = (mask xor value.toInt()).toByte() + } const val MIN_NEGATIVE_SINGLE_BYTE = -32 const val MIN_NEGATIVE_BYTE = -127 const val MAX_UBYTE = 255 @@ -43,8 +54,11 @@ internal object MsgPackType { const val MAX_ULONG = -1 // Can't do it without unsigned types or BigInteger fun isByte(byte: Byte) = byte == INT8 || byte == UINT8 + fun isShort(byte: Byte) = byte == INT16 || byte == UINT16 + fun isInt(byte: Byte) = byte == INT32 || byte == UINT32 + fun isLong(byte: Byte) = byte == INT64 || byte == UINT64 } @@ -65,13 +79,19 @@ internal object MsgPackType { const val STR16 = 0xda.toByte() const val STR32 = 0xdb.toByte() - val FIXSTR_SIZE_MASK = object : Mask { - private val maskResult = 0b10100000 - private val mask = 0b11100000 - override fun maskValue(value: Byte): Byte = (maskResult or value.toInt()).toByte() - override fun test(value: Byte): kotlin.Boolean = (mask and value.toInt()) == maskResult - override fun unMaskValue(value: Byte): Byte = (maskResult xor value.toInt()).toByte() - } + val FIXSTR_SIZE_MASK = + object : Mask { + private val maskResult = 0b10100000 + private val mask = 0b11100000 + + override fun maskValue(value: Byte): Byte = (maskResult or value.toInt()).toByte() + + override fun test(value: Byte): kotlin.Boolean = + (mask and value.toInt()) == maskResult + + override fun unMaskValue(value: Byte): Byte = + (maskResult xor value.toInt()).toByte() + } const val MAX_FIXSTR_LENGTH = 31 const val MAX_STR8_LENGTH = Int.MAX_UBYTE const val MAX_STR16_LENGTH = Int.MAX_USHORT @@ -104,13 +124,19 @@ internal object MsgPackType { const val ARRAY16 = 0xdc.toByte() const val ARRAY32 = 0xdd.toByte() - val FIXARRAY_SIZE_MASK = object : Mask { - private val maskResult = 0b10010000 - private val mask = 0b11110000 - override fun maskValue(value: Byte): Byte = (maskResult or value.toInt()).toByte() - override fun test(value: Byte): kotlin.Boolean = (mask and value.toInt()) == maskResult - override fun unMaskValue(value: Byte): Byte = (maskResult xor value.toInt()).toByte() - } + val FIXARRAY_SIZE_MASK = + object : Mask { + private val maskResult = 0b10010000 + private val mask = 0b11110000 + + override fun maskValue(value: Byte): Byte = (maskResult or value.toInt()).toByte() + + override fun test(value: Byte): kotlin.Boolean = + (mask and value.toInt()) == maskResult + + override fun unMaskValue(value: Byte): Byte = + (maskResult xor value.toInt()).toByte() + } const val MAX_FIXARRAY_SIZE = 15 const val MAX_ARRAY16_LENGTH = Int.MAX_USHORT const val MAX_ARRAY32_LENGTH = Int.MAX_UINT @@ -126,13 +152,19 @@ internal object MsgPackType { const val MAP16 = 0xde.toByte() const val MAP32 = 0xdf.toByte() - val FIXMAP_SIZE_MASK = object : Mask { - private val maskResult = 0b10000000 - private val mask = 0b11110000 - override fun maskValue(value: Byte): Byte = (maskResult or value.toInt()).toByte() - override fun test(value: Byte): kotlin.Boolean = (mask and value.toInt()) == maskResult - override fun unMaskValue(value: Byte): Byte = (maskResult xor value.toInt()).toByte() - } + val FIXMAP_SIZE_MASK = + object : Mask { + private val maskResult = 0b10000000 + private val mask = 0b11110000 + + override fun maskValue(value: Byte): Byte = (maskResult or value.toInt()).toByte() + + override fun test(value: Byte): kotlin.Boolean = + (mask and value.toInt()) == maskResult + + override fun unMaskValue(value: Byte): Byte = + (maskResult xor value.toInt()).toByte() + } const val MAX_FIXMAP_SIZE = 15 const val MAX_MAP16_LENGTH = Int.MAX_USHORT const val MAX_MAP32_LENGTH = Int.MAX_UINT @@ -152,19 +184,21 @@ internal object MsgPackType { const val EXT16 = 0xc8.toByte() const val EXT32 = 0xc9.toByte() - val SIZES = hashMapOf( - FIXEXT1 to 1, - FIXEXT2 to 2, - FIXEXT4 to 4, - FIXEXT8 to 8, - FIXEXT16 to 16 - ) - - val SIZE_SIZE = hashMapOf( - EXT8 to 1, - EXT16 to 2, - EXT32 to 4 - ) + val SIZES = + hashMapOf( + FIXEXT1 to 1, + FIXEXT2 to 2, + FIXEXT4 to 4, + FIXEXT8 to 8, + FIXEXT16 to 16, + ) + + val SIZE_SIZE = + hashMapOf( + EXT8 to 1, + EXT16 to 2, + EXT32 to 4, + ) val TYPES = SIZES.keys + listOf(EXT8, EXT16, EXT32) diff --git a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/utils/ByteArrayUtils.kt b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/utils/ByteArrayUtils.kt index 4d2033704..410320bf0 100644 --- a/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/utils/ByteArrayUtils.kt +++ b/app_fenrir/src/main/kotlin/kotlinx/serialization/msgpack/utils/ByteArrayUtils.kt @@ -1,13 +1,14 @@ package kotlinx.serialization.msgpack.utils internal inline fun T.splitToByteArray(): ByteArray { - val byteCount = when (T::class) { - Byte::class -> 1 - Short::class -> 2 - Int::class -> 4 - Long::class -> 8 - else -> throw UnsupportedOperationException("Can't split number of type ${T::class} to bytes!") - } + val byteCount = + when (T::class) { + Byte::class -> 1 + Short::class -> 2 + Int::class -> 4 + Long::class -> 8 + else -> throw UnsupportedOperationException("Can't split number of type ${T::class} to bytes!") + } val result = ByteArray(byteCount) (byteCount - 1).downTo(0).forEach { @@ -17,11 +18,12 @@ internal inline fun T.splitToByteArray(): ByteArray { } internal inline fun ByteArray.joinToNumber(): T { - val number = mapIndexed { index, byte -> - (byte.toLong() and 0xff) shl (8 * (size - (index + 1))) - }.fold(0L) { acc, it -> - acc or it - } + val number = + mapIndexed { index, byte -> + (byte.toLong() and 0xff) shl (8 * (size - (index + 1))) + }.fold(0L) { acc, it -> + acc or it + } return when (T::class) { Byte::class -> number.toByte() Short::class -> number.toShort() diff --git a/app_fenrir/src/main/res/drawable-v31/ic_fenrir_dynamic2.xml b/app_fenrir/src/main/res/drawable-v31/ic_fenrir_dynamic2.xml index 5bf75c374..3ab403bd2 100644 --- a/app_fenrir/src/main/res/drawable-v31/ic_fenrir_dynamic2.xml +++ b/app_fenrir/src/main/res/drawable-v31/ic_fenrir_dynamic2.xml @@ -7,7 +7,7 @@ android:viewportWidth="108" android:viewportHeight="108"> - \ No newline at end of file + diff --git a/app_fenrir/src/main/res/drawable/client_round_vk.xml b/app_fenrir/src/main/res/drawable/client_round_vk.xml index 49f2bb83f..8388534b1 100644 --- a/app_fenrir/src/main/res/drawable/client_round_vk.xml +++ b/app_fenrir/src/main/res/drawable/client_round_vk.xml @@ -7,8 +7,8 @@ + android:pathData="M1.5,18.002C1.5,8.887 8.886,1.5 17.998,1.5 27.113,1.5 34.5,8.886 34.5,18.002 34.5,27.113 27.114,34.5 17.998,34.5 8.887,34.5 1.5,27.114 1.5,18.002ZM1.5,18.002" /> + android:pathData="M17.794,25.839C14.063,25.519 10.802,23.79 8.774,21.082 7.873,19.876 6.615,17.287 6.228,15.818 5.844,14.408 5.5,12.064 5.5,10.917V10h4.147v0.77c0,1.033 0.358,3.171 0.728,4.409 0.843,2.792 2.588,4.973 4.545,5.745L15.65,21.201 15.649,10h4.002v6.444l0.47,-0.102c1.175,-0.232 2.646,-1.295 3.631,-2.632 0.615,-0.831 1.629,-2.737 1.802,-3.404C25.626,10.014 25.71,10 27.584,10h1.96l-0.1,0.466c-0.544,2.561 -2.575,5.643 -4.645,7.041 -0.315,0.217 -0.573,0.42 -0.573,0.48 0,0.043 0.315,0.261 0.686,0.464 2.244,1.266 4.389,3.987 5.334,6.792L30.5,26 26.142,25.999 25.884,25.271c-0.586,-1.642 -2.188,-3.533 -3.631,-4.276 -0.628,-0.319 -2.131,-0.815 -2.488,-0.815 -0.055,0 -0.113,1.311 -0.113,2.911 0,2.677 -0.013,2.909 -0.244,2.893 -0.142,-0.014 -0.873,-0.072 -1.613,-0.145z" /> diff --git a/app_fenrir/src/main/res/drawable/hand_point_up_left_outline.xml b/app_fenrir/src/main/res/drawable/hand_point_up_left_outline.xml new file mode 100644 index 000000000..fdd0e060e --- /dev/null +++ b/app_fenrir/src/main/res/drawable/hand_point_up_left_outline.xml @@ -0,0 +1,12 @@ + + + + diff --git a/app_fenrir/src/main/res/drawable/ic_fenrir_black.xml b/app_fenrir/src/main/res/drawable/ic_fenrir_black.xml index 67f0cf38a..02e6a8934 100644 --- a/app_fenrir/src/main/res/drawable/ic_fenrir_black.xml +++ b/app_fenrir/src/main/res/drawable/ic_fenrir_black.xml @@ -7,7 +7,7 @@ android:viewportWidth="108" android:viewportHeight="108"> diff --git a/app_fenrir/src/main/res/drawable/ic_fenrir_green.xml b/app_fenrir/src/main/res/drawable/ic_fenrir_green.xml index d420bf8e8..a6c6be656 100644 --- a/app_fenrir/src/main/res/drawable/ic_fenrir_green.xml +++ b/app_fenrir/src/main/res/drawable/ic_fenrir_green.xml @@ -7,7 +7,7 @@ android:viewportWidth="108" android:viewportHeight="108"> - \ No newline at end of file + diff --git a/app_fenrir/src/main/res/drawable/ic_logo_vk.xml b/app_fenrir/src/main/res/drawable/ic_logo_vk.xml index 0d5834311..b5a75e218 100644 --- a/app_fenrir/src/main/res/drawable/ic_logo_vk.xml +++ b/app_fenrir/src/main/res/drawable/ic_logo_vk.xml @@ -7,6 +7,6 @@ android:viewportHeight="108"> diff --git a/app_fenrir/src/main/res/drawable/ic_logo_vk_monochrome.xml b/app_fenrir/src/main/res/drawable/ic_logo_vk_monochrome.xml index ca0fcf148..78bc80f5d 100644 --- a/app_fenrir/src/main/res/drawable/ic_logo_vk_monochrome.xml +++ b/app_fenrir/src/main/res/drawable/ic_logo_vk_monochrome.xml @@ -7,6 +7,6 @@ android:viewportHeight="64"> diff --git a/app_fenrir/src/main/res/drawable/ic_valknut_dynamic_monochrome.xml b/app_fenrir/src/main/res/drawable/ic_valknut_dynamic_monochrome.xml index 741f68abf..58216eb5c 100644 --- a/app_fenrir/src/main/res/drawable/ic_valknut_dynamic_monochrome.xml +++ b/app_fenrir/src/main/res/drawable/ic_valknut_dynamic_monochrome.xml @@ -7,6 +7,6 @@ android:viewportHeight="64"> diff --git a/app_fenrir/src/main/res/drawable/splash.xml b/app_fenrir/src/main/res/drawable/splash.xml deleted file mode 100644 index eafa64536..000000000 --- a/app_fenrir/src/main/res/drawable/splash.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/app_fenrir/src/main/res/layout/activity_camera_scan.xml b/app_fenrir/src/main/res/layout/activity_camera_scan.xml index 2eba6f3ec..eb443bf3c 100644 --- a/app_fenrir/src/main/res/layout/activity_camera_scan.xml +++ b/app_fenrir/src/main/res/layout/activity_camera_scan.xml @@ -1,5 +1,5 @@ - @@ -15,6 +15,14 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + + - \ No newline at end of file + diff --git a/app_fenrir/src/main/res/layout/fragment_single_url_photo.xml b/app_fenrir/src/main/res/layout/activity_single_url_photo.xml similarity index 100% rename from app_fenrir/src/main/res/layout/fragment_single_url_photo.xml rename to app_fenrir/src/main/res/layout/activity_single_url_photo.xml diff --git a/app_fenrir/src/main/res/layout/message_attachments_entry.xml b/app_fenrir/src/main/res/layout/message_attachments_entry.xml index ee2069d21..1c46f8ef1 100644 --- a/app_fenrir/src/main/res/layout/message_attachments_entry.xml +++ b/app_fenrir/src/main/res/layout/message_attachments_entry.xml @@ -98,9 +98,6 @@ android:paddingBottom="2dp" android:textAppearance="@style/TextAppearance.Material3.BodySmall" tools:text="Photo" /> - - - diff --git a/app_fenrir/src/main/res/values-night/styles.xml b/app_fenrir/src/main/res/values-night/styles.xml index 18bfd0c5b..8702c1964 100644 --- a/app_fenrir/src/main/res/values-night/styles.xml +++ b/app_fenrir/src/main/res/values-night/styles.xml @@ -143,21 +143,6 @@ #222427 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -78,52 +52,11 @@ @color/m3_floating_toolbar_vibrant_icon_button_text_color_selector - - - - - - - - - - - diff --git a/material/java/com/google/android/material/floatingtoolbar/res/values/tokens.xml b/material/java/com/google/android/material/floatingtoolbar/res/values/tokens.xml index 0d5594c9c..95e1d3aa2 100644 --- a/material/java/com/google/android/material/floatingtoolbar/res/values/tokens.xml +++ b/material/java/com/google/android/material/floatingtoolbar/res/values/tokens.xml @@ -27,7 +27,6 @@ 64dp 8dp 8dp - 16dp + + + + + + diff --git a/material/java/com/google/android/material/motion/res/values/tokens.xml b/material/java/com/google/android/material/motion/res/values/tokens.xml index 241c2cb7b..f9a3a288c 100644 --- a/material/java/com/google/android/material/motion/res/values/tokens.xml +++ b/material/java/com/google/android/material/motion/res/values/tokens.xml @@ -19,7 +19,21 @@ - + + + 0.9 + 1400 + 1 + 3800 + 0.9 + 700 + 1 + 1600 + 0.9 + 300 + 1 + 800 path(M 0,0 C 0.05, 0, 0.133333, 0.06, 0.166666, 0.4 C 0.208333, 0.82, 0.25, 1, 1, 1) diff --git a/material/java/com/google/android/material/navigation/DividerMenuItem.java b/material/java/com/google/android/material/navigation/DividerMenuItem.java new file mode 100644 index 000000000..8105166a3 --- /dev/null +++ b/material/java/com/google/android/material/navigation/DividerMenuItem.java @@ -0,0 +1,265 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.material.navigation; + +import android.content.Intent; +import android.graphics.drawable.Drawable; +import android.view.ActionProvider; +import android.view.ContextMenu.ContextMenuInfo; +import android.view.MenuItem; +import android.view.SubMenu; +import android.view.View; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +/** + * An empty MenuItem that is used to represent a divider in the menu. + */ +class DividerMenuItem implements MenuItem { + + @Override + public boolean collapseActionView() { + return false; + } + + @Override + public boolean expandActionView() { + return false; + } + + @Nullable + @Override + public ActionProvider getActionProvider() { + return null; + } + + @Nullable + @Override + public View getActionView() { + return null; + } + + @Override + public char getAlphabeticShortcut() { + return 0; + } + + @Override + public int getGroupId() { + return 0; + } + + @Nullable + @Override + public Drawable getIcon() { + return null; + } + + @Nullable + @Override + public Intent getIntent() { + return null; + } + + @Override + public int getItemId() { + return 0; + } + + @Nullable + @Override + public ContextMenuInfo getMenuInfo() { + return null; + } + + @Override + public char getNumericShortcut() { + return 0; + } + + @Override + public int getOrder() { + return 0; + } + + @Nullable + @Override + public SubMenu getSubMenu() { + return null; + } + + @Nullable + @Override + public CharSequence getTitle() { + return null; + } + + @Nullable + @Override + public CharSequence getTitleCondensed() { + return null; + } + + @Override + public boolean hasSubMenu() { + return false; + } + + @Override + public boolean isActionViewExpanded() { + return false; + } + + @Override + public boolean isCheckable() { + return false; + } + + @Override + public boolean isChecked() { + return false; + } + + @Override + public boolean isEnabled() { + return false; + } + + @Override + public boolean isVisible() { + return false; + } + + @NonNull + @Override + public MenuItem setActionProvider(@Nullable ActionProvider actionProvider) { + return null; + } + + @NonNull + @Override + public MenuItem setActionView(@Nullable View view) { + return null; + } + + @NonNull + @Override + public MenuItem setActionView(int resId) { + return null; + } + + @NonNull + @Override + public MenuItem setAlphabeticShortcut(char alphaChar) { + return null; + } + + @NonNull + @Override + public MenuItem setCheckable(boolean checkable) { + return null; + } + + @NonNull + @Override + public MenuItem setChecked(boolean checked) { + return null; + } + + @NonNull + @Override + public MenuItem setEnabled(boolean enabled) { + return null; + } + + @NonNull + @Override + public MenuItem setIcon(@Nullable Drawable icon) { + return null; + } + + @NonNull + @Override + public MenuItem setIcon(int iconRes) { + return null; + } + + @NonNull + @Override + public MenuItem setIntent(@Nullable Intent intent) { + return null; + } + + @NonNull + @Override + public MenuItem setNumericShortcut(char numericChar) { + return null; + } + + @NonNull + @Override + public MenuItem setOnActionExpandListener(@Nullable OnActionExpandListener listener) { + return null; + } + + @NonNull + @Override + public MenuItem setOnMenuItemClickListener( + @Nullable OnMenuItemClickListener menuItemClickListener) { + return null; + } + + @NonNull + @Override + public MenuItem setShortcut(char numericChar, char alphaChar) { + return null; + } + + @Override + public void setShowAsAction(int actionEnum) { + + } + + @NonNull + @Override + public MenuItem setShowAsActionFlags(int actionEnum) { + return null; + } + + @NonNull + @Override + public MenuItem setTitle(int title) { + return null; + } + + @NonNull + @Override + public MenuItem setTitle(@Nullable CharSequence title) { + return null; + } + + @NonNull + @Override + public MenuItem setTitleCondensed(@Nullable CharSequence title) { + return null; + } + + @NonNull + @Override + public MenuItem setVisible(boolean visible) { + return null; + } +} diff --git a/material/java/com/google/android/material/navigation/NavigationBarDividerView.java b/material/java/com/google/android/material/navigation/NavigationBarDividerView.java new file mode 100644 index 000000000..b47a911cd --- /dev/null +++ b/material/java/com/google/android/material/navigation/NavigationBarDividerView.java @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.material.navigation; + +import com.google.android.material.R; + +import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import androidx.appcompat.view.menu.MenuItemImpl; +import android.view.LayoutInflater; +import android.widget.FrameLayout; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.RestrictTo; + +/** + * Provides a view that will be used to render subheader items inside a {@link + * NavigationBarMenuView}. + * + * @hide + */ +@RestrictTo(LIBRARY_GROUP) +public class NavigationBarDividerView extends FrameLayout implements NavigationBarMenuItemView { + + private boolean expanded; + boolean onlyShowWhenExpanded; + private boolean dividersEnabled; + + NavigationBarDividerView(@NonNull Context context) { + super(context); + LayoutInflater.from(context).inflate(R.layout.m3_navigation_menu_divider, this, true); + updateVisibility(); + } + + @Override + public void initialize(@NonNull MenuItemImpl menuItem, int i) { + updateVisibility(); + } + + @Override + @Nullable + public MenuItemImpl getItemData() { + return null; + } + + @Override + public void setTitle(@Nullable CharSequence charSequence) {} + + @Override + public void setEnabled(boolean enabled) {} + + @Override + public void setCheckable(boolean checkable) {} + + @Override + public void setChecked(boolean checked) {} + + @Override + public void setShortcut(boolean showShortcut, char shortcutKey) {} + + @Override + public void setIcon(@Nullable Drawable drawable) {} + + @Override + public boolean prefersCondensedTitle() { + return false; + } + + @Override + public boolean showsIcon() { + return false; + } + + @Override + public void setExpanded(boolean expanded) { + this.expanded = expanded; + updateVisibility(); + } + + @Override + public boolean isExpanded() { + return this.expanded; + } + + @Override + public void setOnlyShowWhenExpanded(boolean onlyShowWhenExpanded) { + this.onlyShowWhenExpanded = onlyShowWhenExpanded; + updateVisibility(); + } + + @Override + public boolean isOnlyVisibleWhenExpanded() { + return this.onlyShowWhenExpanded; + } + + public void updateVisibility() { + setVisibility(dividersEnabled && (expanded || !onlyShowWhenExpanded) ? VISIBLE : GONE); + } + + public void setDividersEnabled(boolean dividersEnabled) { + this.dividersEnabled = dividersEnabled; + updateVisibility(); + } + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } +} diff --git a/material/java/com/google/android/material/navigation/NavigationBarMenuBuilder.java b/material/java/com/google/android/material/navigation/NavigationBarMenuBuilder.java index 0d04cd664..92339d685 100644 --- a/material/java/com/google/android/material/navigation/NavigationBarMenuBuilder.java +++ b/material/java/com/google/android/material/navigation/NavigationBarMenuBuilder.java @@ -48,8 +48,9 @@ public class NavigationBarMenuBuilder { } /** - * Returns total number of items in the menu, including submenus and submenu items. For example, - * a Menu with items {Item, SubMenu, SubMenuItem} would have a size of 3. + * Returns total number of items in the menu, including submenus, submenu items, and dividers. For + * example, a Menu with items {Item, Divider, SubMenu, SubMenuItem, Divider} would have a size of + * 5. */ public int size() { return items.size(); @@ -103,8 +104,13 @@ public void refreshItems() { visibleMainItemCount = 0; for (int i = 0; i < menuBuilder.size(); i++) { MenuItem item = menuBuilder.getItem(i); - items.add(item); if (item.hasSubMenu()) { + if (!items.isEmpty() + && !(items.get(items.size() - 1) instanceof DividerMenuItem) + && item.isVisible()) { + items.add(new DividerMenuItem()); + } + items.add(item); SubMenu subMenu = item.getSubMenu(); for (int j = 0; j < subMenu.size(); j++) { MenuItem submenuItem = subMenu.getItem(j); @@ -117,7 +123,9 @@ public void refreshItems() { visibleContentItemCount++; } } + items.add(new DividerMenuItem()); } else { + items.add(item); contentItemCount++; if (item.isVisible()) { visibleContentItemCount++; @@ -125,5 +133,9 @@ public void refreshItems() { } } } + + if (!items.isEmpty() && items.get(items.size()-1) instanceof DividerMenuItem) { + items.remove(items.size()-1); + } } } diff --git a/material/java/com/google/android/material/navigation/NavigationBarMenuView.java b/material/java/com/google/android/material/navigation/NavigationBarMenuView.java index a78d9c8c4..56848fd59 100644 --- a/material/java/com/google/android/material/navigation/NavigationBarMenuView.java +++ b/material/java/com/google/android/material/navigation/NavigationBarMenuView.java @@ -131,6 +131,7 @@ public abstract class NavigationBarMenuView extends ViewGroup implements MenuVie private static final int DEFAULT_COLLAPSED_MAX_COUNT = 7; private int collapsedMaxItemCount = DEFAULT_COLLAPSED_MAX_COUNT; + private boolean dividersEnabled = false; public NavigationBarMenuView(@NonNull Context context) { super(context); @@ -1186,7 +1187,12 @@ public void buildMenuView() { for (int i = 0; i < menuSize; i++) { MenuItem menuItem = menu.getItemAt(i); NavigationBarMenuItemView child; - if (menuItem.hasSubMenu()) { + if (menuItem instanceof DividerMenuItem) { + // Add a divider + child = new NavigationBarDividerView(getContext()); + child.setOnlyShowWhenExpanded(true); + ((NavigationBarDividerView) child).setDividersEnabled(dividersEnabled); + } else if (menuItem.hasSubMenu()) { if (nextSubheaderItemCount > 0) { // We do not support submenus inside submenus. If there is still subheader items to be // instantiated, we should not have another submenu. @@ -1213,7 +1219,9 @@ public void buildMenuView() { i, (MenuItemImpl) menuItem, shifting, collapsedItemsSoFar >= collapsedMaxItemCount); collapsedItemsSoFar++; } - if (menuItem.isCheckable() && selectedItemPosition == NO_SELECTED_ITEM) { + if (!(menuItem instanceof DividerMenuItem) + && menuItem.isCheckable() + && selectedItemPosition == NO_SELECTED_ITEM) { selectedItemPosition = i; } buttons[i] = child; @@ -1228,11 +1236,19 @@ private boolean isMenuStructureSame() { return false; } for (int i = 0; i < buttons.length; i++) { - if (menu.getItemAt(i).hasSubMenu() - ? buttons[i] instanceof NavigationBarItemView - : buttons[i] instanceof NavigationBarSubheaderView) { + // If the menu item is a divider but the existing item is not a divider, return false + if (menu.getItemAt(i) instanceof DividerMenuItem + && !(buttons[i] instanceof NavigationBarDividerView)) { return false; } + boolean incorrectSubheaderType = + menu.getItemAt(i).hasSubMenu() && !(buttons[i] instanceof NavigationBarSubheaderView); + boolean incorrectItemType = + !menu.getItemAt(i).hasSubMenu() && !(buttons[i] instanceof NavigationBarItemView); + if (!(menu.getItemAt(i) instanceof DividerMenuItem) + && (incorrectSubheaderType || incorrectItemType)) { + return false; + } } return true; } @@ -1278,7 +1294,9 @@ public void updateMenuView() { itemView.setItemGravity(itemGravity); itemView.setShifting(shifting); } - buttons[i].initialize((MenuItemImpl) menu.getItemAt(i), 0); + if (menu.getItemAt(i) instanceof MenuItemImpl) { + buttons[i].initialize((MenuItemImpl) menu.getItemAt(i), 0); + } presenter.setUpdateSuspended(false); } } @@ -1291,6 +1309,20 @@ private NavigationBarItemView getNewItem() { return item; } + public void setSubmenuDividersEnabled(boolean dividersEnabled) { + if (this.dividersEnabled == dividersEnabled) { + return; + } + this.dividersEnabled = dividersEnabled; + if (buttons != null) { + for (NavigationBarMenuItemView itemView : buttons) { + if (itemView instanceof NavigationBarDividerView) { + ((NavigationBarDividerView) itemView).setDividersEnabled(dividersEnabled); + } + } + } + } + public void setCollapsedMaxItemCount(int collapsedMaxCount) { this.collapsedMaxItemCount = collapsedMaxCount; } diff --git a/material/java/com/google/android/material/navigation/res/layout/m3_navigation_menu_divider.xml b/material/java/com/google/android/material/navigation/res/layout/m3_navigation_menu_divider.xml new file mode 100644 index 000000000..0eab193e9 --- /dev/null +++ b/material/java/com/google/android/material/navigation/res/layout/m3_navigation_menu_divider.xml @@ -0,0 +1,25 @@ + + + diff --git a/material/java/com/google/android/material/navigation/res/layout/m3_navigation_menu_subheader.xml b/material/java/com/google/android/material/navigation/res/layout/m3_navigation_menu_subheader.xml index 12a62e0e2..f797a7644 100644 --- a/material/java/com/google/android/material/navigation/res/layout/m3_navigation_menu_subheader.xml +++ b/material/java/com/google/android/material/navigation/res/layout/m3_navigation_menu_subheader.xml @@ -20,7 +20,7 @@ android:layout_height="wrap_content" android:paddingHorizontal="@dimen/m3_navigation_subheader_horizontal_padding" android:paddingVertical="@dimen/m3_navigation_subheader_vertical_padding" - android:layout_marginStart="@dimen/m3_navigation_subheader_horizontal_margin" + android:layout_marginStart="@dimen/m3_navigation_content_horizontal_margin" android:layout_marginTop="@dimen/m3_navigation_subheader_top_margin" android:gravity="center_vertical|start" android:ellipsize="end" diff --git a/material/java/com/google/android/material/navigation/res/values/dimens.xml b/material/java/com/google/android/material/navigation/res/values/dimens.xml index 50e91b6d3..2d901c08f 100644 --- a/material/java/com/google/android/material/navigation/res/values/dimens.xml +++ b/material/java/com/google/android/material/navigation/res/values/dimens.xml @@ -50,7 +50,9 @@ 16dp 8dp 12dp - 20dp + 20dp + 8dp + 3dp 12sp 14sp diff --git a/material/java/com/google/android/material/navigationrail/NavigationRailMenuView.java b/material/java/com/google/android/material/navigationrail/NavigationRailMenuView.java index d6942dd8f..3098bf38f 100644 --- a/material/java/com/google/android/material/navigationrail/NavigationRailMenuView.java +++ b/material/java/com/google/android/material/navigationrail/NavigationRailMenuView.java @@ -32,7 +32,6 @@ import androidx.annotation.RestrictTo; import com.google.android.material.navigation.NavigationBarItemView; import com.google.android.material.navigation.NavigationBarMenuView; -import com.google.android.material.navigation.NavigationBarSubheaderView; /** @hide For internal use only. */ @RestrictTo(LIBRARY_GROUP) @@ -140,7 +139,7 @@ private int measureSharedChildHeights( int totalHeight = 0; for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); - if (child instanceof NavigationBarSubheaderView) { + if (!(child instanceof NavigationBarItemView)) { int subheaderHeight = measureChildHeight(child, widthMeasureSpec, subheaderHeightSpec); maxHeight -= subheaderHeight; totalHeight += subheaderHeight; diff --git a/material/java/com/google/android/material/navigationrail/NavigationRailView.java b/material/java/com/google/android/material/navigationrail/NavigationRailView.java index bf9c327de..c417df5c3 100644 --- a/material/java/com/google/android/material/navigationrail/NavigationRailView.java +++ b/material/java/com/google/android/material/navigationrail/NavigationRailView.java @@ -26,11 +26,13 @@ import static java.lang.Math.min; import android.animation.TimeInterpolator; +import android.annotation.SuppressLint; import android.content.Context; import androidx.appcompat.widget.TintTypedArray; import android.util.AttributeSet; import android.view.Gravity; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.animation.PathInterpolator; @@ -52,6 +54,7 @@ import com.google.android.material.internal.ThemeEnforcement; import com.google.android.material.internal.ViewUtils; import com.google.android.material.internal.ViewUtils.RelativePadding; +import com.google.android.material.navigation.NavigationBarDividerView; import com.google.android.material.navigation.NavigationBarItemView; import com.google.android.material.navigation.NavigationBarView; import com.google.android.material.resources.MaterialResources; @@ -133,6 +136,7 @@ public class NavigationRailView extends NavigationBarView { private final int minExpandedWidth; private final int maxExpandedWidth; private final boolean scrollingEnabled; + private boolean submenuDividersEnabled; @Nullable private View headerView; @Nullable private Boolean paddingTopSystemWindowInsets = null; @Nullable private Boolean paddingBottomSystemWindowInsets = null; @@ -190,6 +194,7 @@ public NavigationRailView( getResources().getDimensionPixelSize(R.dimen.mtrl_navigation_rail_margin)); scrollingEnabled = attributes.getBoolean(R.styleable.NavigationRailView_scrollingEnabled, false); + setSubmenuDividersEnabled(attributes.getBoolean(R.styleable.NavigationRailView_submenuDividersEnabled, false)); addContentContainer(); @@ -447,7 +452,7 @@ private int getMaxChildWidth() { int maxChildWidth = 0; for (int i = 0; i < childCount; i++) { View child = getNavigationRailMenuView().getChildAt(i); - if (child.getVisibility() != GONE) { + if (child.getVisibility() != GONE && !(child instanceof NavigationBarDividerView)) { maxChildWidth = max(maxChildWidth, child.getMeasuredWidth()); } } @@ -602,6 +607,24 @@ public int getExpandedItemMinimumHeight() { return expandedItemMinHeight; } + /** + * Set whether or not to enable the dividers which go between each subgroup in the menu. + */ + public void setSubmenuDividersEnabled(boolean submenuDividersEnabled) { + if (this.submenuDividersEnabled == submenuDividersEnabled) { + return; + } + this.submenuDividersEnabled = submenuDividersEnabled; + getNavigationRailMenuView().setSubmenuDividersEnabled(submenuDividersEnabled); + } + + /** + * Get whether or not to enable the dividers which go between each subgroup in the menu. + */ + public boolean getSubmenuDividersEnabled() { + return submenuDividersEnabled; + } + /** * Set the padding in between the navigation rail menu items. */ @@ -713,4 +736,12 @@ private void addContentContainer() { public boolean shouldAddMenuView() { return true; } + + @SuppressLint("ClickableViewAccessibility") + @Override + public boolean onTouchEvent(@NonNull MotionEvent event) { + super.onTouchEvent(event); + // Consume all events to avoid views under the BottomNavigationView from receiving touch events. + return true; + } } diff --git a/material/java/com/google/android/material/navigationrail/res-public/values/public.xml b/material/java/com/google/android/material/navigationrail/res-public/values/public.xml index 6de483528..c868d2d28 100644 --- a/material/java/com/google/android/material/navigationrail/res-public/values/public.xml +++ b/material/java/com/google/android/material/navigationrail/res-public/values/public.xml @@ -27,6 +27,7 @@ + diff --git a/material/java/com/google/android/material/navigationrail/res/values/attrs.xml b/material/java/com/google/android/material/navigationrail/res/values/attrs.xml index d1558b967..82e83ee8c 100644 --- a/material/java/com/google/android/material/navigationrail/res/values/attrs.xml +++ b/material/java/com/google/android/material/navigationrail/res/values/attrs.xml @@ -71,6 +71,8 @@ + + diff --git a/material/java/com/google/android/material/theme/res/values/themes_base.xml b/material/java/com/google/android/material/theme/res/values/themes_base.xml index 432cd379e..fa9c2f1aa 100644 --- a/material/java/com/google/android/material/theme/res/values/themes_base.xml +++ b/material/java/com/google/android/material/theme/res/values/themes_base.xml @@ -145,6 +145,8 @@ @style/Widget.Material3.FloatingActionButton.Large.Secondary @style/Widget.Material3.FloatingActionButton.Large.Tertiary @style/Widget.Material3.FloatingActionButton.Large.Surface + @style/Widget.Material3.FloatingToolbar + @style/Widget.Material3.FloatingToolbar.Vibrant @style/Widget.Material3.LinearProgressIndicator @style/Widget.Material3.LoadingIndicator @style/Widget.Material3.Button.IconButton @@ -271,6 +273,12 @@ @style/ShapeAppearance.Material3.LargeComponent + @style/Motion.Material3.Spring.Standard.Fast.Spatial + @style/Motion.Material3.Spring.Standard.Fast.Effects + @style/Motion.Material3.Spring.Standard.Default.Spatial + @style/Motion.Material3.Spring.Standard.Default.Effects + @style/Motion.Material3.Spring.Standard.Slow.Spatial + @style/Motion.Material3.Spring.Standard.Slow.Effects @interpolator/m3_sys_motion_easing_standard @interpolator/m3_sys_motion_easing_standard_decelerate @interpolator/m3_sys_motion_easing_standard_accelerate @@ -561,6 +569,12 @@ @style/ShapeAppearance.Material3.LargeComponent + @style/Motion.Material3.Spring.Standard.Fast.Spatial + @style/Motion.Material3.Spring.Standard.Fast.Effects + @style/Motion.Material3.Spring.Standard.Default.Spatial + @style/Motion.Material3.Spring.Standard.Default.Effects + @style/Motion.Material3.Spring.Standard.Slow.Spatial + @style/Motion.Material3.Spring.Standard.Slow.Effects @interpolator/m3_sys_motion_easing_standard @interpolator/m3_sys_motion_easing_standard_decelerate @interpolator/m3_sys_motion_easing_standard_accelerate diff --git a/picasso3/build.gradle b/picasso3/build.gradle index fdbced3eb..7e111ecf3 100644 --- a/picasso3/build.gradle +++ b/picasso3/build.gradle @@ -4,7 +4,7 @@ plugins { } android { - namespace "com.squareup.picasso3" + namespace = "com.squareup.picasso3" compileSdk = appCompileSDK buildToolsVersion = appBuildTools diff --git a/preference/build.gradle b/preference/build.gradle index 2886bdfd9..ff20ca519 100644 --- a/preference/build.gradle +++ b/preference/build.gradle @@ -4,7 +4,7 @@ plugins { } android { - namespace "de.maxr1998.modernpreferences" + namespace = "de.maxr1998.modernpreferences" compileSdk = appCompileSDK buildToolsVersion = appBuildTools diff --git a/recyclerview/build.gradle b/recyclerview/build.gradle index 87b917bbd..c37c06fdf 100644 --- a/recyclerview/build.gradle +++ b/recyclerview/build.gradle @@ -8,7 +8,7 @@ plugins { //viewpager 1.1.0 android { - namespace "androidx.recyclerview" + namespace = "androidx.recyclerview" compileSdk = appCompileSDK buildToolsVersion = appBuildTools