From 6d7e346d5d047f7342ff4a3c7a5807217a8285fc Mon Sep 17 00:00:00 2001 From: Maxwell Date: Sun, 5 May 2024 12:23:39 +0200 Subject: [PATCH] refactor: clean up gradle and re-enable spotless configuration --- .editorconfig | 4 +- android-core/build.gradle.kts | 2 +- android-core/src/main/AndroidManifest.xml | 32 +- .../co/anitrend/core/android/Extensions.kt | 26 +- .../core/android/animations/AlphaAnimator.kt | 17 +- .../android/animations/AnimationExtensions.kt | 28 +- .../android/behaviour/BottomOffsetBehavior.kt | 23 +- .../core/android/binding/IBindingView.kt | 8 +- .../components/action/FloatingActionMenu.kt | 95 ++-- .../action/menu/IFloatingActionMenu.kt | 12 +- .../edgetreatment/SemiCircleCutout.kt | 68 +-- .../sheet/SheetBehaviourCallback.kt | 46 +- .../sheet/action/SheetHandleSlideAction.kt | 23 +- .../sheet/action/contract/OnSlideAction.kt | 9 +- .../action/contract/OnStateChangedAction.kt | 10 +- .../core/android/compose/AniTrendColors.kt | 25 +- .../core/android/compose/AniTrendDimens.kt | 43 +- .../core/android/compose/AniTrendThemes.kt | 242 +++++----- .../android/compose/design/BackIconButton.kt | 18 +- .../android/compose/design/ContentWrapper.kt | 54 ++- .../compose/design/image/AniTrendImage.kt | 55 ++- .../compose/design/image/CoverImageUtils.kt | 31 +- .../power/AndroidPowerController.kt | 39 +- .../power/contract/IPowerController.kt | 10 +- .../controller/widget/WidgetController.kt | 6 +- .../widget/contract/IWidgetController.kt | 6 +- .../extensions/CascadeMenuExtensions.kt | 40 +- .../core/android/extensions/ChipExtensions.kt | 13 +- .../android/extensions/ContextExtensions.kt | 16 +- .../core/android/extensions/CoreExtensions.kt | 10 +- .../android/extensions/InsetsExentions.kt | 7 +- .../android/extensions/IntentExtensions.kt | 16 + .../android/extensions/LiveDataExtensions.kt | 25 +- .../android/extensions/TimberExtensions.kt | 5 +- .../core/android/extensions/ViewExtensions.kt | 20 +- .../android/helpers/color/ColorExtensions.kt | 20 +- .../helpers/date/AniTrendDateHelper.kt | 78 +-- .../android/helpers/image/ImageExtensions.kt | 111 ++--- .../helpers/image/model/RequestImage.kt | 13 +- .../co/anitrend/core/android/koin/Modules.kt | 125 ++--- .../android/provider/StyleActionProvider.kt | 33 +- .../contract/AbstractActionProvider.kt | 38 +- .../core/android/recycler/CarouselRecycler.kt | 89 ++-- .../decorator/DefaultSpacingDecorator.kt | 14 +- .../recycler/model/RecyclerItemBinding.kt | 10 +- .../selection/DefaultSelectionMode.kt | 17 +- .../core/android/settings/Settings.kt | 355 +++++++------- .../settings/common/IConfigurationSettings.kt | 5 +- .../settings/common/locale/ILocaleSettings.kt | 6 +- .../settings/common/theme/IThemeSettings.kt | 6 +- .../settings/extensions/SettingsExtensions.kt | 24 +- .../helper/config/ConfigurationHelper.kt | 15 +- .../config/contract/IConfigurationHelper.kt | 6 +- .../settings/helper/locale/LocaleHelper.kt | 10 +- .../helper/locale/contract/ILocaleHelper.kt | 4 +- .../helper/locale/model/AniTrendLocale.kt | 25 +- .../settings/helper/theme/ThemeHelper.kt | 51 +- .../helper/theme/contract/IThemeHelper.kt | 8 +- .../helper/theme/model/AniTrendTheme.kt | 20 +- .../android/shortcut/ShortcutController.kt | 54 ++- .../shortcut/contract/IShortcutController.kt | 6 +- .../core/android/shortcut/model/Shortcut.kt | 5 +- .../core/android/state/IScreenState.kt | 6 +- .../core/android/storage/StorageController.kt | 48 +- .../storage/contract/IStorageController.kt | 21 +- .../core/android/storage/enums/StorageType.kt | 7 +- .../extensions/StorageControllerExtensions.kt | 15 +- .../core/android/ui/AniTrendPreview.kt | 29 +- .../anitrend/core/android/ui/color/Color.kt | 17 +- .../anitrend/core/android/ui/theme/Theme.kt | 181 +++---- .../ui/theme/preview/PreviewDefaults.kt | 42 +- .../core/android/ui/typography/Typography.kt | 16 + .../android/views/FrameLayoutWithBinding.kt | 60 +-- .../android/views/LinearLayoutWithBinding.kt | 58 ++- .../android/views/drawable/RoundedDrawable.kt | 3 +- .../views/scroll/FillNestedScrollView.kt | 52 +- .../core/android/views/text/TextDrawable.kt | 72 +-- .../android/widget/appbar/BottomAppBar.kt | 90 ++-- .../widget/button/LoadingTextButton.kt | 189 ++++---- .../widget/viewpager/BottomSheetViewPager.kt | 90 ++-- .../src/main/res/anim/enter_from_bottom.xml | 31 +- .../src/main/res/anim/exit_to_bottom.xml | 31 +- .../res/animator/floating_action_hide.xml | 31 +- .../res/animator/floating_action_show.xml | 31 +- .../res/color/material_tab_text_color.xml | 34 +- .../res/color/selector_chip_background.xml | 34 +- .../res/color/selector_chip_text_color.xml | 34 +- .../res/color/selector_text_button_ripple.xml | 34 +- .../main/res/drawable/bubble_background.xml | 31 +- .../main/res/drawable/dashed_background.xml | 34 +- .../src/main/res/drawable/dot_indicator.xml | 16 + .../src/main/res/drawable/gradient_shadow.xml | 31 +- .../res/drawable/gradient_shadow_inverse.xml | 31 +- .../src/main/res/drawable/ic_filter.xml | 17 + .../src/main/res/drawable/ic_heart_filled.xml | 32 +- .../main/res/drawable/ic_heart_outline.xml | 32 +- .../src/main/res/drawable/ic_search.xml | 32 +- .../res/drawable/ic_shortcut_activity.xml | 32 +- .../drawable/ic_shortcut_airing_schedule.xml | 31 +- .../res/drawable/ic_shortcut_anime_list.xml | 31 +- .../res/drawable/ic_shortcut_episodes.xml | 32 +- .../main/res/drawable/ic_shortcut_forum.xml | 32 +- .../res/drawable/ic_shortcut_manga_list.xml | 32 +- .../main/res/drawable/ic_shortcut_news.xml | 32 +- .../drawable/ic_shortcut_notifications.xml | 32 +- .../main/res/drawable/ic_shortcut_profile.xml | 32 +- .../main/res/drawable/ic_shortcut_search.xml | 32 +- .../main/res/drawable/ic_view_comfortable.xml | 17 + .../src/main/res/drawable/ic_view_compact.xml | 32 +- .../main/res/drawable/ic_view_detailed.xml | 32 +- .../src/main/res/drawable/ic_view_summary.xml | 32 +- .../res/drawable/indicator_background.xml | 16 + .../res/drawable/material_tab_indicator.xml | 34 +- .../src/main/res/drawable/touch_thumbnail.xml | 31 +- .../main/res/drawable/widget_background.xml | 34 +- .../main/res/layout/action_frame_layout.xml | 30 +- .../src/main/res/menu/discover_menu.xml | 34 +- .../main/res/values-large-land/columns.xml | 34 +- .../main/res/values-large-port/columns.xml | 34 +- .../src/main/res/values-night/colors.xml | 31 +- .../src/main/res/values-night/environment.xml | 31 +- .../src/main/res/values-night/themes.xml | 31 +- .../main/res/values-normal-land/columns.xml | 34 +- .../src/main/res/values-v28/themes.xml | 30 +- .../src/main/res/values-w600dp/dimens.xml | 16 + .../src/main/res/values-w820dp/dimens.xml | 16 + .../main/res/values-xlarge-land/columns.xml | 34 +- .../main/res/values-xlarge-port/columns.xml | 34 +- .../res/values/attrs_paging_indicator.xml | 31 +- android-core/src/main/res/values/colors.xml | 31 +- android-core/src/main/res/values/columns.xml | 34 +- .../src/main/res/values/custom_ids.xml | 34 +- .../src/main/res/values/debouncer.xml | 31 +- .../src/main/res/values/deep_link.xml | 31 +- android-core/src/main/res/values/dimens.xml | 31 +- .../src/main/res/values/environment.xml | 31 +- .../res/values/material_design_colors.xml | 31 +- android-core/src/main/res/values/motion.xml | 31 +- android-core/src/main/res/values/settings.xml | 31 +- android-core/src/main/res/values/strings.xml | 32 +- android-core/src/main/res/values/styles.xml | 31 +- android-core/src/main/res/values/themes.xml | 31 +- android-deeplink/build.gradle.kts | 2 +- android-deeplink/src/main/AndroidManifest.xml | 32 +- .../deeplink/component/route/AppRoutes.kt | 22 +- .../deeplink/component/route/WebRoutes.kt | 2 +- .../component/route/contract/Route.kt | 2 +- .../component/screen/DeepLinkScreen.kt | 2 +- .../environment/AniTrendEnvironment.kt | 2 +- .../contract/IAniTrendEnvironment.kt | 2 +- .../deeplink/exception/DeepLinkException.kt | 2 +- .../initializer/FeatureInitializer.kt | 2 +- .../co/anitrend/deeplink/koin/Modules.kt | 2 +- .../src/main/res/layout/deep_link_screen.xml | 34 +- .../src/main/res/values/strings.xml | 32 +- android-navigation/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../drawer/action/OnChangedActions.kt | 31 +- .../drawer/action/OnSandwichSlideAction.kt | 23 +- .../navigation/drawer/action/OnSlideAction.kt | 69 ++- .../provider/NotificationActionProvider.kt | 40 +- .../NotificationProviderViewModel.kt | 3 +- .../viewmodel/state/AuthenticatedUserState.kt | 3 +- .../drawer/adapter/AccountAdapter.kt | 23 +- .../drawer/adapter/NavigationAdapter.kt | 10 +- .../component/content/BottomDrawerContent.kt | 168 ++++--- .../content/contract/INavigationDrawer.kt | 15 +- .../component/presenter/DrawerPresenter.kt | 103 ++-- .../component/viewmodel/AccountViewModel.kt | 3 +- .../viewmodel/NavigationViewModel.kt | 196 ++++---- .../viewmodel/mapper/UsersToAccountsMapper.kt | 101 ++-- .../component/viewmodel/state/AccountState.kt | 3 +- .../controller/helpers/ControllerDiffers.kt | 16 +- .../model/account/AnonymousAccountItem.kt | 26 +- .../model/account/AuthenticatedAccountItem.kt | 40 +- .../model/account/AuthorizeAccountItem.kt | 30 +- .../model/account/GroupAccountItem.kt | 19 +- .../model/navigation/DividerNavigationItem.kt | 19 +- .../model/navigation/GroupNavigationItem.kt | 19 +- .../model/navigation/MenuNavigationItem.kt | 23 +- .../drawer/initializer/FeatureInitializer.kt | 19 +- .../navigation/drawer/koin/Modules.kt | 70 +-- .../drawer/model/account/Account.kt | 42 +- .../drawer/model/navigation/Navigation.kt | 43 +- .../drawer/model/state/SandwichState.kt | 8 +- .../drawer/provider/FeatureProvider.kt | 3 +- .../color_navigation_drawer_menu_item.xml | 31 +- .../main/res/drawable/ic_account_add_24dp.xml | 32 +- .../src/main/res/drawable/ic_anime_24.xml | 32 +- .../src/main/res/drawable/ic_check_24.xml | 32 +- .../src/main/res/drawable/ic_deck_24dp.xml | 32 +- .../src/main/res/drawable/ic_discord_24dp.xml | 32 +- .../main/res/drawable/ic_discover_24dp.xml | 32 +- .../src/main/res/drawable/ic_explore_24dp.xml | 32 +- .../src/main/res/drawable/ic_forum_24.xml | 32 +- .../src/main/res/drawable/ic_help_24dp.xml | 32 +- .../src/main/res/drawable/ic_home_24dp.xml | 32 +- .../res/drawable/ic_info_outline_24dp.xml | 32 +- .../res/drawable/ic_invert_colors_24dp.xml | 32 +- .../res/drawable/ic_local_movies_24dp.xml | 32 +- .../src/main/res/drawable/ic_manga_24.xml | 32 +- .../src/main/res/drawable/ic_news_24.xml | 32 +- .../main/res/drawable/ic_notifications_24.xml | 32 +- .../res/drawable/ic_outline_settings_24dp.xml | 32 +- .../src/main/res/drawable/ic_patreon_24dp.xml | 32 +- .../src/main/res/drawable/ic_review_24.xml | 32 +- .../src/main/res/drawable/ic_social_24.xml | 32 +- .../main/res/drawable/ic_suggestions_24.xml | 17 + .../src/main/res/drawable/ic_tv_24dp.xml | 32 +- .../src/main/res/drawable/ic_update_24.xml | 32 +- .../main/res/drawable/nav_item_background.xml | 31 +- .../drawable/nav_item_background_selected.xml | 31 +- .../res/layout/account_anonymous_item.xml | 31 +- .../res/layout/account_authenticated_item.xml | 31 +- .../main/res/layout/account_group_item.xml | 31 +- .../res/layout/bottom_navigation_drawer.xml | 31 +- .../res/layout/navigation_divider_item.xml | 31 +- .../main/res/layout/navigation_group_item.xml | 31 +- .../main/res/layout/navigation_menu_item.xml | 31 +- .../src/main/res/menu/drawer_menu.xml | 31 +- .../src/main/res/values/dimens.xml | 31 +- .../src/main/res/values/ids.xml | 16 + .../src/main/res/values/strings.xml | 32 +- android-onboarding/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../component/content/OnBoardingContent.kt | 2 +- .../component/pager/OnBoardingPageAdapter.kt | 2 +- .../presenter/OnBoardingPresenter.kt | 2 +- .../component/screen/OnBoardingScreen.kt | 2 +- .../component/widget/OnBoardingView.kt | 2 +- .../initializer/FeatureInitializer.kt | 2 +- .../co/anitrend/onboarding/koin/Modules.kt | 2 +- .../onboarding/provider/FeatureProvider.kt | 2 +- .../main/res/drawable/gradient_slide_01.xml | 31 +- .../main/res/drawable/gradient_slide_02.xml | 31 +- .../main/res/layout/onboarding_content.xml | 31 +- .../src/main/res/layout/onboarding_screen.xml | 31 +- .../src/main/res/values-land/ratio.xml | 31 +- .../src/main/res/values/ratio.xml | 31 +- .../src/main/res/values/strings.xml | 32 +- .../src/main/res/values/theme.xml | 31 +- .../src/main/res/xml/oboarding_main_scene.xml | 31 +- android-splash/build.gradle.kts | 2 +- android-splash/src/main/AndroidManifest.xml | 32 +- .../splash/component/content/SplashContent.kt | 2 +- .../component/presenter/SplashPresenter.kt | 2 +- .../splash/component/screen/SplashScreen.kt | 2 +- .../splash/initializer/FeatureInitializer.kt | 2 +- .../kotlin/co/anitrend/splash/koin/Modules.kt | 2 +- .../splash/provider/FeatureProvider.kt | 2 +- .../drawable/stripe_decoration_rounded.xml | 31 +- .../src/main/res/layout/activity_splash.xml | 31 +- .../src/main/res/layout/content_splash.xml | 31 +- .../src/main/res/values-v31/themes.xml | 34 +- android-splash/src/main/res/values/dimens.xml | 31 +- .../src/main/res/values/strings.xml | 32 +- android-splash/src/main/res/values/themes.xml | 31 +- .../src/main/res/xml/content_splash_scene.xml | 31 +- app-core/build.gradle.kts | 2 +- app-core/src/main/AndroidManifest.xml | 32 +- .../co/anitrend/core/AniTrendApplication.kt | 11 +- .../core/coil/client/CoilRequestClient.kt | 41 +- .../core/coil/fetch/RequestImageFetcher.kt | 18 +- .../core/coil/mapper/RequestImageMapper.kt | 29 +- .../co/anitrend/core/component/Defaults.kt | 38 +- .../adapter/AniTrendLoadStateAdapter.kt | 6 +- .../core/component/content/AniTrendContent.kt | 11 +- .../content/list/AniTrendListContent.kt | 32 +- .../presenter/AniTrendListContentPresenter.kt | 14 +- .../selection/AniTrendSelectionContent.kt | 33 +- .../component/screen/AniTrendBoundScreen.kt | 4 +- .../core/component/screen/AniTrendScreen.kt | 5 +- .../component/sheet/AniTrendBottomSheet.kt | 50 +- .../component/viewmodel/AniTrendViewModel.kt | 3 +- .../viewmodel/state/AniTrendViewModelState.kt | 3 +- .../config/AbstractDeveloperModeConfig.kt | 5 +- .../config/contract/IDeveloperModeConfig.kt | 6 +- .../core/crash/ExceptionCrashHandler.kt | 24 +- .../crash/contract/IExceptionCrashHandler.kt | 11 +- .../crash/runtime/UncaughtExceptionHandler.kt | 11 +- .../extensions/AuthenticationExtensions.kt | 22 +- .../core/extensions/CollectionExtensions.kt | 13 +- .../core/extensions/ComponentExtensions.kt | 5 +- .../core/extensions/CoreExtensions.kt | 43 +- .../core/extensions/FlowExtensions.kt | 23 +- .../core/extensions/ScopeExtensions.kt | 14 +- .../contract/AbstractCoreInitializer.kt | 6 +- .../contract/AbstractFeatureInitializer.kt | 6 +- .../contract/AbstractTaskInitializer.kt | 6 +- .../injector/InjectorInitializer.kt | 7 +- .../injector/extensions/InjectorExtensions.kt | 23 +- .../injector/factory/WorkManagerFactory.kt | 17 +- .../initializer/injector/logger/KoinLogger.kt | 11 +- .../initializer/logger/TimberInitializer.kt | 7 +- .../migration/MigrationInitializer.kt | 13 +- .../kotlin/co/anitrend/core/koin/Modules.kt | 224 ++++----- .../koin/helper/DynamicFeatureModuleHelper.kt | 12 +- .../co/anitrend/core/koin/scope/AppScope.kt | 7 +- .../core/koin/scope/contract/ICustomScope.kt | 5 +- .../core/migration/MigrationManager.kt | 48 +- .../contract/AbstractMigrationManager.kt | 7 +- .../migration/contract/IMigrationManager.kt | 6 +- .../core/migration/model/Migration.kt | 12 +- .../core/migration/model/Migrations.kt | 92 ++-- .../kotlin/co/anitrend/core/model/Emote.kt | 8 +- .../anitrend/core/presenter/CorePresenter.kt | 11 +- .../core/service/AniTrendCoroutineService.kt | 6 +- .../core/service/AniTrendLifecycleService.kt | 4 +- .../co/anitrend/core/ui/UiExtensions.kt | 96 ++-- .../co/anitrend/core/ui/model/FragmentItem.kt | 9 +- app-core/src/main/res/anim/popup_enter.xml | 31 +- app-core/src/main/res/anim/popup_exit.xml | 31 +- .../main/res/drawable/ic_anitrend_logo.xml | 32 +- .../ic_anitrend_notification_logo.xml | 32 +- .../res/drawable/ic_launcher_background.xml | 31 +- .../main/res/layout/shared_list_content.xml | 31 +- .../res/mipmap-anydpi-v26/ic_launcher.xml | 31 +- .../mipmap-anydpi-v26/ic_launcher_round.xml | 31 +- app-core/src/main/res/values/strings.xml | 32 +- .../src/main/res/xml/backup_descriptor.xml | 31 +- app-data-android/build.gradle.kts | 2 +- app-data-android/src/main/AndroidManifest.xml | 32 +- .../android/cache/datasource/ICacheStore.kt | 5 +- .../data/android/cache/entity/CacheEntity.kt | 29 +- .../cache/helper/ThreeTenExtensions.kt | 26 +- .../data/android/cache/model/CacheIdentity.kt | 5 +- .../data/android/cache/model/CacheRequest.kt | 3 +- .../cache/repository/CacheStorePolicy.kt | 54 +-- .../repository/contract/ICacheStorePolicy.kt | 14 +- .../controller/core/DefaultController.kt | 5 +- .../controller/graphql/GraphQLController.kt | 18 +- .../strategy/contract/ControllerStrategy.kt | 53 ++- .../strategy/policy/OfflineStrategy.kt | 14 +- .../strategy/policy/OnlineStrategy.kt | 17 +- .../android/extensions/DatabaseExtensions.kt | 7 +- .../android/extensions/ScopeExtensions.kt | 33 +- .../android/extensions/SourceExtensions.kt | 15 +- .../data/android/filter/FilterQueryBuilder.kt | 65 +-- .../co/anitrend/data/android/info/AppInfo.kt | 16 + .../anitrend/data/android/info/DeviceInfo.kt | 4 +- .../{GraphLogger.kt => GraphTimberLogger.kt} | 19 +- .../data/android/logger/OkHttpLogger.kt | 5 +- .../data/android/mapper/DefaultMapper.kt | 12 +- .../data/android/mapper/EmbedMapper.kt | 7 +- .../data/android/network/cache/CacheHelper.kt | 29 +- .../network/cache/model/TimeSpecification.kt | 7 +- .../network/client/DeferrableNetworkClient.kt | 30 +- .../network/client/OkHttpCallNetworkClient.kt | 37 +- .../client/RetrofitCallNetworkClient.kt | 33 +- .../network/contract/AbstractNetworkClient.kt | 15 +- .../network/cookie/ApplicationCookieJar.kt | 15 +- .../data/android/network/cookie/Extensions.kt | 14 +- .../cookie/contract/AndroidCookieJar.kt | 5 +- .../network/default/DefaultNetworkClient.kt | 7 +- .../network/graphql/GraphNetworkClient.kt | 33 +- .../network/interceptor/app/AppInterceptor.kt | 19 +- .../interceptor/shared/SharedInterceptor.kt | 6 +- .../android/network/model/NetworkMessage.kt | 7 +- .../source/local/AbstractLocalSource.kt | 3 +- app-data-core/build.gradle.kts | 2 +- app-data-core/src/main/AndroidManifest.xml | 32 +- .../co/anitrend/data/core/Annotations.kt | 7 +- .../data/core/api/factory/IEndpointFactory.kt | 6 +- .../api/factory/contract/IEndpointType.kt | 3 +- .../anitrend/data/core/api/model/GraphQL.kt | 9 +- .../core/api/provider/RetrofitProvider.kt | 41 +- .../co/anitrend/data/core/app/IAppInfo.kt | 18 +- .../co/anitrend/data/core/common/Identity.kt | 5 +- .../anitrend/data/core/device/IDeviceInfo.kt | 5 +- .../data/core/extensions/KoinExtensions.kt | 32 +- .../co/anitrend/data/core/railway/OutCome.kt | 9 +- .../data/core/railway/extension/Extensions.kt | 29 +- app-data-edge/build.gradle.kts | 16 + app-data-edge/src/debug/AndroidManifest.xml | 17 + .../debug/res/xml/network_security_config.xml | 16 + app-data-edge/src/main/AndroidManifest.xml | 17 + .../co/anitrend/data/edge/config/Types.kt | 16 + .../data/edge/config/cache/EdgeConfigCache.kt | 22 +- .../config/converters/EdgeConfigConverters.kt | 68 ++- .../datasource/local/EdgeConfigLocalSource.kt | 39 +- .../datasource/local/IEdgeConfigStore.kt | 16 + .../remote/EdgeConfigRemoteSource.kt | 19 +- .../edge/config/entity/EdgeConfigEntity.kt | 21 +- .../edge/config/extensions/ScopeExtensions.kt | 25 +- .../anitrend/data/edge/config/koin/Modules.kt | 156 +++--- .../edge/config/mapper/EdgeConfigMapper.kt | 19 +- .../config/model/remote/EdgeConfigModel.kt | 17 +- .../edge/core/api/factory/EdgeApiFactory.kt | 56 ++- .../api/interceptor/EdgeClientInterceptor.kt | 16 + .../edge/core/extensions/ScopeExtensions.kt | 16 + .../datasource/local/EdgeHomeLocalSource.kt | 29 +- .../home/datasource/local/IEdgeHomeStore.kt | 16 + .../data/edge/home/entity/EdgeHomeEntity.kt | 18 +- .../edge/home/mapper/EdgeHomeGenreMapper.kt | 54 ++- .../co/anitrend/data/edge/koin/Modules.kt | 31 +- .../converters/EdgeNavigationConverters.kt | 24 - .../EdgeNavigationModelConverter.kt | 39 ++ .../local/EdgeNavigationLocalSource.kt | 29 +- .../datasource/local/IEdgeNavigationStore.kt | 16 + .../navigation/entity/EdgeNavigationEntity.kt | 16 + .../navigation/mapper/EdgeNavigationMapper.kt | 18 +- .../navigation/model/EdgeNavigationModel.kt | 17 +- app-data-feed/build.gradle.kts | 2 +- app-data-feed/src/main/AndroidManifest.xml | 32 +- .../anitrend/data/feed/api/FeedApiFactory.kt | 18 +- .../data/feed/api/factory/IFeedFactory.kt | 5 +- .../co/anitrend/data/feed/contract/Types.kt | 5 +- .../feed/contract/model/IRssChannelModel.kt | 5 +- .../contract/model/contract/IRssContainer.kt | 5 +- .../co/anitrend/data/feed/episode/Types.kt | 5 +- .../data/feed/episode/cache/EpisodeCache.kt | 14 +- .../episode/converter/EpisodeConverters.kt | 148 +++--- .../episode/datasource/local/IEpisodeStore.kt | 5 +- .../datasource/remote/EpisodeRemoteSource.kt | 10 +- .../data/feed/episode/entity/EpisodeEntity.kt | 15 +- .../episode/entity/fts/EpisodeFtsEntity.kt | 7 +- .../data/feed/episode/koin/Modules.kt | 175 +++---- .../data/feed/episode/mapper/EpisodeMapper.kt | 12 +- .../feed/episode/model/EpisodeModelItem.kt | 120 ++--- .../episode/model/page/EpisodePageModel.kt | 40 +- .../feed/episode/model/query/EpisodeQuery.kt | 7 +- .../data/feed/extensions/DateExtensions.kt | 13 +- .../data/feed/extensions/ScopeExtensions.kt | 9 +- .../co/anitrend/data/feed/koin/Modules.kt | 21 +- .../co/anitrend/data/feed/news/Types.kt | 5 +- .../data/feed/news/cache/NewsCache.kt | 14 +- .../feed/news/converter/NewsConverters.kt | 51 +- .../feed/news/datasource/local/INewsStore.kt | 5 +- .../datasource/remote/NewsRemoteSource.kt | 8 +- .../data/feed/news/entity/NewsEntity.kt | 10 +- .../feed/news/entity/fts/NewsFtsEntity.kt | 7 +- .../anitrend/data/feed/news/koin/Modules.kt | 141 +++--- .../data/feed/news/mapper/NewsMapper.kt | 12 +- .../data/feed/news/model/NewsModelItem.kt | 33 +- .../feed/news/model/page/NewsPageModel.kt | 40 +- .../data/feed/news/model/query/NewsQuery.kt | 7 +- .../feed/news/source/contract/NewsSource.kt | 6 +- app-data-imgur/build.gradle.kts | 2 +- app-data-imgur/src/main/AndroidManifest.xml | 32 +- app-data-jikan/build.gradle.kts | 2 +- app-data-jikan/src/main/AndroidManifest.xml | 32 +- .../jikan/media/source/JikanSourceImpl.kt | 2 - app-data-relation/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- app-data-settings/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../data/settings/cache/ICacheSettings.kt | 2 +- .../connectivity/IConnectivitySettings.kt | 3 +- .../customize/ICustomizationSettings.kt | 2 +- .../customize/common/PreferredViewMode.kt | 2 +- .../settings/developer/IDeveloperSettings.kt | 2 +- .../data/settings/power/IPowerSettings.kt | 2 +- .../data/settings/privacy/IPrivacySettings.kt | 2 +- .../refresh/IRefreshBehaviourSettings.kt | 2 +- .../data/settings/sort/ISortOrderSettings.kt | 2 +- .../data/settings/sync/ISyncSettings.kt | 2 +- app-data-theme/build.gradle.kts | 2 +- app-data-theme/src/main/AndroidManifest.xml | 32 +- .../data/themes/api/ThemesApiFactory.kt | 16 +- .../co/anitrend/data/themes/koin/Modules.kt | 19 +- app-data-thexem/build.gradle.kts | 2 +- app-data-thexem/src/main/AndroidManifest.xml | 32 +- .../data/thexem/api/TheXemApiFactory.kt | 16 +- .../co/anitrend/data/thexem/koin/Modules.kt | 19 +- .../data/thexem/single/cache/XemCache.kt | 11 +- .../thexem/single/model/local/XemQuery.kt | 11 +- app-data-tmdb/build.gradle.kts | 2 +- app-data-tmdb/src/main/AndroidManifest.xml | 32 +- .../co/anitrend/data/tmdb/api/TmdbApi.kt | 8 +- .../co/anitrend/data/tmdb/koin/Modules.kt | 31 +- app-data-trakt/build.gradle.kts | 2 +- app-data-trakt/src/main/AndroidManifest.xml | 32 +- .../co/anitrend/data/trakt/api/TraktApi.kt | 8 +- .../co/anitrend/data/trakt/koin/Modules.kt | 36 +- app-data/build.gradle.kts | 2 +- app-data/src/main/AndroidManifest.xml | 32 +- .../kotlin/co/anitrend/data/account/Types.kt | 2 +- .../co/anitrend/data/android/koin/Modules.kt | 4 +- .../co/anitrend/data/character/Types.kt | 1 + .../co/anitrend/data/favourite/Types.kt | 1 + .../kotlin/co/anitrend/data/genre/Types.kt | 3 +- .../datasource/local/GenreLocalSource.kt | 5 +- .../co/anitrend/data/mediatrend/Types.kt | 1 + .../converter/MediaTrendConverters.kt | 2 +- .../co/anitrend/data/notification/Types.kt | 1 + ...ankConverters.kt => RankModelConverter.kt} | 2 +- .../data/rank/datasource/RankLocalSource.kt | 3 +- .../co/anitrend/data/recommendation/Types.kt | 1 + .../kotlin/co/anitrend/data/staff/Types.kt | 1 + .../kotlin/co/anitrend/data/status/Types.kt | 3 + .../status/converters/StatusConverters.kt | 3 + .../kotlin/co/anitrend/data/studio/Types.kt | 1 + .../tag/datasource/local/TagLocalSource.kt | 7 +- .../kotlin/co/anitrend/data/thread/Types.kt | 1 + app-domain/build.gradle.kts | 2 +- app-domain/src/main/AndroidManifest.xml | 32 +- .../co/anitrend/domain/genre/entity/Genre.kt | 31 +- .../co/anitrend/domain/tag/entity/Tag.kt | 6 +- app-navigation/build.gradle.kts | 2 +- app-navigation/src/main/AndroidManifest.xml | 32 +- .../anitrend/navigation/NavigationTargets.kt | 114 +++-- .../extensions/ReflectionExtensions.kt | 47 +- .../navigation/extensions/RouterExtensions.kt | 36 +- .../navigation/extensions/WorkerExtensions.kt | 46 +- .../anitrend/navigation/model/NavPayload.kt | 7 +- .../navigation/model/common/IParam.kt | 3 +- .../navigation/model/sorting/Sorting.kt | 7 +- .../provider/INavigationProvider.kt | 5 +- .../navigation/router/NavigationRouter.kt | 5 +- .../work/WorkSchedulerController.kt | 6 +- app/build.gradle.kts | 2 +- app/src/debug/AndroidManifest.xml | 31 +- .../co/anitrend/config/DeveloperModeConfig.kt | 20 +- .../DebugApplicationInitializer.kt | 9 +- .../kotlin/co/anitrend/koin/DebugModules.kt | 23 +- app/src/github/AndroidManifest.xml | 31 +- .../co/anitrend/analytics/AnalyticsTree.kt | 35 +- .../co/anitrend/service/MessagingService.kt | 6 +- app/src/google/AndroidManifest.xml | 31 +- .../co/anitrend/analytics/AnalyticsTree.kt | 41 +- .../co/anitrend/service/MessagingService.kt | 5 +- app/src/main/AndroidManifest.xml | 31 +- app/src/main/kotlin/co/anitrend/App.kt | 6 +- .../component/action/StateChangeActions.kt | 25 +- .../component/presenter/MainPresenter.kt | 24 +- .../anitrend/component/screen/MainScreen.kt | 219 ++++----- .../viewmodel/MainScreenViewModel.kt | 5 +- .../initializer/ApplicationInitializer.kt | 9 +- .../main/kotlin/co/anitrend/koin/Modules.kt | 64 +-- .../kotlin/co/anitrend/model/ScreenState.kt | 40 +- .../co/anitrend/presenter/MainPresenter.kt | 7 +- .../co/anitrend/provider/FeatureProvider.kt | 8 +- app/src/main/res/drawable/ic_explore_24dp.xml | 32 +- .../main/res/drawable/ic_menu_open_24dp.xml | 32 +- .../res/drawable/ic_outline_settings_24dp.xml | 32 +- app/src/main/res/layout/main_screen.xml | 31 +- app/src/main/res/menu/main_menu.xml | 31 +- app/src/main/res/values/strings.xml | 32 +- .../main/res/xml/data_extraction_rules.xml | 31 +- .../java/co/anitrend/buildSrc/Libraries.kt | 10 +- .../co/anitrend/buildSrc/module/Modules.kt | 10 +- .../anitrend/buildSrc/plugins/CorePlugin.kt | 2 +- .../components/ProjectConfiguration.kt | 1 - .../plugins/components/ProjectSpotless.kt | 8 +- common-character-ui/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../src/main/res/values/dimens.xml | 34 +- common-editor-ui/build.gradle.kts | 2 +- common-editor-ui/src/main/AndroidManifest.xml | 32 +- .../ui/initializer/FeatureInitializer.kt | 6 +- .../anitrend/common/editor/ui/koin/Modules.kt | 33 +- .../editor/ui/widget/MarkDownInputWidget.kt | 446 +++++++++-------- common-episode-ui/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../episode/ui/adapter/EpisodePagedAdapter.kt | 8 +- ...ontrollerDiffers.kt => EpisodeDiffUtil.kt} | 9 +- .../ui/controller/model/EpisodeItem.kt | 31 +- .../ui/widget/rating/EpisodeRatingWidget.kt | 6 +- .../ui/widget/summary/EpisodeSummaryWidget.kt | 83 ++-- .../controller/EpisodeSummaryController.kt | 20 +- .../src/main/res/drawable/ic_play_circle.xml | 32 +- .../src/main/res/drawable/ic_timelapse.xml | 32 +- .../src/main/res/layout/episode_item.xml | 31 +- .../src/main/res/values/dimens.xml | 31 +- .../src/main/res/values/strings.xml | 31 +- common-feed-ui/build.gradle.kts | 2 +- common-feed-ui/src/main/AndroidManifest.xml | 32 +- common-forum-ui/build.gradle.kts | 2 +- common-forum-ui/src/main/AndroidManifest.xml | 32 +- common-genre-ui/build.gradle.kts | 2 +- common-genre-ui/src/main/AndroidManifest.xml | 32 +- .../genre/ui/adapter/GenreListAdapter.kt | 10 +- .../common/genre/ui/compose/GenreCompose.kt | 13 +- .../genre/ui/compose/GenreComposePreview.kt | 7 +- ...{ControllerDiffers.kt => GenreDiffUtil.kt} | 9 +- .../genre/ui/controller/model/GenreItem.kt | 29 +- .../src/main/res/layout/genre_item.xml | 31 +- common-markdown-ui/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../ui/animator/PushOnPressAnimator.kt | 10 +- .../markdown/ui/compose/MarkdownText.kt | 20 +- .../ui/extension/ConfigurationExtensions.kt | 34 +- .../ui/initializer/FeatureInitializer.kt | 5 +- .../common/markdown/ui/koin/Modules.kt | 27 +- .../plugin/decorator/AlignmentTagHandler.kt | 23 +- .../ui/plugin/decorator/CenterTagHandler.kt | 18 +- .../plugin/decorator/ParagraphTagHandler.kt | 31 +- .../span/configuration/ISpanConfiguration.kt | 5 +- .../ui/plugin/span/image/AbstractImageSpan.kt | 69 +-- .../plugin/span/size/SizeMeasurementUnit.kt | 7 +- .../ui/plugin/store/CoilStorePlugin.kt | 43 +- .../ui/widget/MarkdownSynopsisWidget.kt | 181 +++---- .../markdown/ui/widget/MarkdownTextWidget.kt | 130 ++--- .../src/main/res/drawable/ic_arrow_down.xml | 17 + .../src/main/res/drawable/ic_arrow_up.xml | 17 + .../src/main/res/values/strings.xml | 34 +- common-media-ui/build.gradle.kts | 2 +- common-media-ui/src/main/AndroidManifest.xml | 32 +- .../media/ui/adapter/MediaCarouselAdapter.kt | 9 +- .../media/ui/adapter/MediaCompactAdapter.kt | 10 +- .../media/ui/adapter/MediaPagedAdapter.kt | 8 +- .../media/ui/compose/MediaAiringSchedule.kt | 40 +- .../common/media/ui/compose/SummarySection.kt | 109 +++-- .../extensions/MediaComposeExtensions.kt | 16 +- .../controller/extensions/RouterExtensions.kt | 32 +- .../controller/helpers/ControllerDiffers.kt | 30 +- .../ui/controller/model/MediaCarouselItem.kt | 225 ++++----- .../controller/model/MediaComfortableItem.kt | 28 +- .../ui/controller/model/MediaCompactItem.kt | 34 +- .../ui/controller/model/MediaDetailedItem.kt | 38 +- .../ui/controller/model/MediaSummaryItem.kt | 40 +- .../media/ui/presenter/MediaPresenter.kt | 20 +- .../airing/MediaAiringScheduleWidget.kt | 112 +++-- .../MediaAiringScheduleController.kt | 8 +- .../ui/widget/progress/MediaProgressWidget.kt | 296 ++++++------ .../controller/MediaProgressController.kt | 48 +- .../ui/widget/rating/MediaRatingWidget.kt | 448 ++++++++++-------- .../controller/MediaRatingController.kt | 6 +- .../ui/widget/status/MediaStatusWidget.kt | 105 ++-- .../controller/MediaStatusController.kt | 6 +- .../ui/widget/title/MediaSubTitleWidget.kt | 178 ++++--- .../controller/MediaSubTitleController.kt | 9 +- .../src/main/res/drawable/ic_add.xml | 17 + .../src/main/res/drawable/ic_completed.xml | 32 +- .../src/main/res/drawable/ic_current.xml | 32 +- .../src/main/res/drawable/ic_dropped.xml | 32 +- .../src/main/res/drawable/ic_face.xml | 32 +- .../src/main/res/drawable/ic_face_happy.xml | 32 +- .../src/main/res/drawable/ic_face_neutral.xml | 32 +- .../src/main/res/drawable/ic_face_sad.xml | 32 +- .../src/main/res/drawable/ic_favourite.xml | 32 +- .../src/main/res/drawable/ic_note.xml | 32 +- .../src/main/res/drawable/ic_paused.xml | 32 +- .../src/main/res/drawable/ic_planning.xml | 32 +- .../src/main/res/drawable/ic_repeat.xml | 32 +- .../main/res/layout/media_carousel_item.xml | 30 +- .../res/layout/media_comfortable_item.xml | 30 +- .../main/res/layout/media_compact_item.xml | 34 +- .../main/res/layout/media_detailed_item.xml | 31 +- .../main/res/layout/media_summary_item.xml | 31 +- .../src/main/res/values-night/colors.xml | 31 +- .../src/main/res/values/colors.xml | 31 +- .../src/main/res/values/dimens.xml | 31 +- .../src/main/res/values/strings.xml | 31 +- common-medialist-ui/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../ui/widget/contract/AbstractEditWidget.kt | 338 +++++++------ .../controller/AbstractEditController.kt | 6 +- .../contract/model/AbstractEditModel.kt | 3 +- .../ui/widget/counter/CounterEditWidget.kt | 109 +++-- .../controller/CounterEditController.kt | 20 +- .../widget/counter/model/CounterEditModel.kt | 5 +- .../ui/widget/date/FuzzyDateWidget.kt | 158 +++--- .../date/controller/FuzzyDateController.kt | 12 +- .../date/presenter/FuzzyDatePresenter.kt | 38 +- .../ui/widget/progress/ProgressEditWidget.kt | 112 +++-- .../controller/ProgressCounterController.kt | 17 +- .../progress/model/ProgressEditModel.kt | 5 +- .../ui/widget/score/ScoreEditWidget.kt | 107 +++-- .../score/controller/ScoreEditController.kt | 37 +- .../ui/widget/score/model/ScoreEditModel.kt | 7 +- .../ui/widget/status/StatusSpinnerWidget.kt | 178 +++---- .../status/adapter/StatusIconAdapter.kt | 44 +- .../StatusSpinnerWidgetController.kt | 7 +- .../src/main/res/drawable/ic_arrow_down.xml | 17 + .../src/main/res/drawable/ic_arrow_up.xml | 17 + .../main/res/drawable/ic_edit_calendar.xml | 17 + .../res/drawable/outline_button_frame.xml | 34 +- .../res/layout/adapter_status_spiner_item.xml | 34 +- .../src/main/res/values/strings.xml | 32 +- .../src/main/res/values/strings_arrays.xml | 34 +- common-news-ui/build.gradle.kts | 2 +- common-news-ui/src/main/AndroidManifest.xml | 32 +- .../news/ui/adapter/NewsPagedAdapter.kt | 8 +- .../{ControllerDiffers.kt => NewsDiffUtil.kt} | 9 +- .../news/ui/controller/model/NewsItem.kt | 44 +- .../src/main/res/layout/news_item.xml | 31 +- common-recommendation-ui/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- common-review-ui/build.gradle.kts | 2 +- common-review-ui/src/main/AndroidManifest.xml | 32 +- .../review/ui/adapter/ReviewPagedAdapter.kt | 8 +- .../ui/controller/helpers/ReviewDiffUtil.kt | 23 +- .../ui/controller/model/ReviewCompactItem.kt | 21 +- .../ui/controller/model/ReviewDetailedItem.kt | 28 +- .../ui/widget/action/ReviewActionWidget.kt | 279 +++++------ .../controller/ReviewActionController.kt | 8 +- .../action/presenter/ReviewActionPresenter.kt | 28 +- .../ui/widget/avatar/ReviewAvatarWidget.kt | 142 +++--- .../ui/widget/rating/ReviewRatingWidget.kt | 94 ++-- .../vote/controller/ReviewVoteController.kt | 8 +- .../vote/presenter/ReviewVotePresenter.kt | 19 +- .../src/main/res/drawable/ic_delete.xml | 32 +- .../src/main/res/drawable/ic_edit.xml | 32 +- .../src/main/res/drawable/ic_star.xml | 17 + .../src/main/res/drawable/ic_thumb_down.xml | 32 +- .../src/main/res/drawable/ic_thumb_up.xml | 32 +- .../main/res/layout/review_compact_item.xml | 34 +- .../main/res/layout/review_detailed_item.xml | 31 +- .../src/main/res/values/strings.xml | 34 +- common-shared-ui/build.gradle.kts | 2 +- common-shared-ui/src/main/AndroidManifest.xml | 32 +- .../extension/MaterialSortChipExtensions.kt | 10 +- .../shared/ui/extension/RecyclerExtensions.kt | 7 +- .../ui/extension/ShareCompatExtensions.kt | 33 +- .../ui/initializer/FeatureInitializer.kt | 5 +- .../anitrend/common/shared/ui/koin/Modules.kt | 51 +- .../common/shared/ui/plugin/MarkdownPlugin.kt | 10 +- .../ui/plugin/span/ImageSpanConfiguration.kt | 13 +- .../shared/ui/plugin/tag/ImageTagHandler.kt | 25 +- .../common/shared/ui/view/FavouriteView.kt | 119 +++-- .../shared/ui/view/chip/MaterialSortChip.kt | 173 +++---- .../controller/MaterialSortChipController.kt | 46 +- .../contract/IMaterialSortChipController.kt | 9 +- .../shared/ui/view/chip/enums/CheckedState.kt | 7 +- .../shared/ui/view/image/CircleImageView.kt | 44 +- .../shared/ui/view/text/SharedNameView.kt | 67 +-- .../main/res/drawable/card_drop_shadow.xml | 34 +- .../src/main/res/drawable/ic_arrow_down.xml | 17 + .../src/main/res/drawable/ic_arrow_up.xml | 17 + .../src/main/res/drawable/ic_bookmark.xml | 32 +- .../src/main/res/drawable/ic_edit.xml | 32 +- .../src/main/res/drawable/ic_favorite.xml | 32 +- .../src/main/res/drawable/ic_not_favorite.xml | 32 +- .../src/main/res/drawable/ic_share.xml | 32 +- .../main/res/layout/shared_compact_item.xml | 31 +- .../main/res/layout/shared_summary_item.xml | 34 +- .../src/main/res/layout/shared_text_item.xml | 34 +- .../res/layout/shared_with_embed_item.xml | 31 +- .../src/main/res/values/dimens.xml | 34 +- .../src/main/res/values/strings.xml | 34 +- common-staff-ui/build.gradle.kts | 2 +- common-staff-ui/src/main/AndroidManifest.xml | 32 +- common-studio-ui/build.gradle.kts | 2 +- common-studio-ui/src/main/AndroidManifest.xml | 32 +- common-tag-ui/build.gradle.kts | 2 +- common-tag-ui/src/main/AndroidManifest.xml | 32 +- .../common/tag/ui/adpter/TagListAdapter.kt | 9 +- .../{ControllerDiffers.kt => TagDiffUtil.kt} | 9 +- .../common/tag/ui/controller/model/TagItem.kt | 29 +- .../src/main/res/drawable/ic_info.xml | 32 +- .../src/main/res/layout/tag_item.xml | 34 +- common-user-ui/build.gradle.kts | 2 +- common-user-ui/src/main/AndroidManifest.xml | 32 +- feature-about/build.gradle.kts | 2 +- feature-about/src/main/AndroidManifest.xml | 32 +- .../about/component/content/AboutContent.kt | 5 +- .../about/component/screen/AboutScreen.kt | 5 +- .../about/initializer/FeatureInitializer.kt | 5 +- .../kotlin/co/anitrend/about/koin/Modules.kt | 14 +- .../about/provider/FeatureProvider.kt | 8 +- feature-about/src/main/res/values/strings.xml | 31 +- feature-account/build.gradle.kts | 2 +- feature-account/src/main/AndroidManifest.xml | 32 +- .../account/component/screen/AccountScreen.kt | 5 +- .../src/main/res/layout/about_screen.xml | 31 +- feature-airing/build.gradle.kts | 2 +- feature-airing/src/main/AndroidManifest.xml | 32 +- .../airing/component/content/AiringContent.kt | 40 +- .../airing/component/screen/AiringScreen.kt | 15 +- .../airing/initializer/FeatureInitializer.kt | 3 +- .../kotlin/co/anitrend/airing/koin/Modules.kt | 67 +-- .../airing/provider/FeatureProvider.kt | 7 +- .../src/main/res/layout/airing_screen.xml | 58 +-- .../src/main/res/values/strings.xml | 31 +- feature-auth/build.gradle.kts | 2 +- feature-auth/src/main/AndroidManifest.xml | 32 +- .../auth/component/content/AuthContent.kt | 21 +- .../auth/component/screen/AuthScreen.kt | 13 +- .../auth/contract/AuthResultContract.kt | 49 +- .../auth/initializer/FeatureInitializer.kt | 5 +- .../kotlin/co/anitrend/auth/koin/Modules.kt | 75 +-- .../co/anitrend/auth/model/Authentication.kt | 15 +- .../anitrend/auth/presenter/AuthPresenter.kt | 27 +- .../anitrend/auth/provider/FeatureProvider.kt | 8 +- .../src/main/res/drawable/ic_account_24.xml | 32 +- .../res/drawable/ic_account_circle_24.xml | 32 +- .../main/res/drawable/ic_error_outline_24.xml | 32 +- .../main/res/layout/auth_anonymous_frame.xml | 32 +- .../res/layout/auth_authorization_frame.xml | 31 +- .../src/main/res/layout/auth_content.xml | 30 +- .../src/main/res/layout/auth_header_frame.xml | 31 +- .../src/main/res/layout/auth_screen.xml | 31 +- feature-auth/src/main/res/values/strings.xml | 32 +- feature-character/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../component/screen/CharacterScreen.kt | 5 +- .../src/main/res/layout/character_screen.xml | 31 +- .../src/main/res/values/strings.xml | 32 +- feature-episode/build.gradle.kts | 2 +- feature-episode/src/main/AndroidManifest.xml | 32 +- .../component/content/EpisodeContent.kt | 6 +- .../episode/component/sheet/EpisodeSheet.kt | 43 +- .../episode/initializer/FeatureInitializer.kt | 5 +- .../co/anitrend/episode/koin/Modules.kt | 80 ++-- .../episode/provider/FeatureProvider.kt | 5 +- .../src/main/res/layout/episode_sheet.xml | 30 +- .../src/main/res/values/strings.xml | 32 +- feature-feed/build.gradle.kts | 2 +- feature-feed/src/main/AndroidManifest.xml | 32 +- .../feed/component/content/FeedContent.kt | 9 +- .../feed/component/screen/FeedScreen.kt | 13 +- .../feed/initializer/FeatureInitializer.kt | 7 +- .../anitrend/feed/provider/FeatureProvider.kt | 10 +- .../src/main/res/layout/feed_content.xml | 32 +- .../src/main/res/layout/feed_screen.xml | 32 +- feature-feed/src/main/res/values/strings.xml | 32 +- feature-forum/build.gradle.kts | 2 +- feature-forum/src/main/AndroidManifest.xml | 32 +- .../forum/component/content/ForumContent.kt | 9 +- .../forum/component/screen/ForumScreen.kt | 13 +- .../forum/initializer/FeatureInitializer.kt | 7 +- .../forum/provider/FeatureProvider.kt | 10 +- .../src/main/res/layout/forum_content.xml | 32 +- .../src/main/res/layout/forum_screen.xml | 32 +- feature-forum/src/main/res/values/strings.xml | 32 +- feature-image-viewer/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../viewmodel/ImageViewerViewModel.kt | 10 +- .../viewer/initializer/FeatureInitializer.kt | 5 +- .../kotlin/co/anitrend/viewer/koin/Modules.kt | 32 +- .../viewer/provider/FeatureProvider.kt | 8 +- .../main/res/layout/image_viewer_screen.xml | 31 +- .../src/main/res/values/strings.xml | 32 +- feature-media-carousel/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../controller/CarouselContentController.kt | 55 ++- .../initializer/FeatureInitializer.kt | 3 +- .../anitrend/media/carousel/koin/Modules.kt | 87 ++-- .../carousel/provider/FeatureProvider.kt | 3 +- .../src/main/res/values/strings.xml | 32 +- .../build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../compose/MediaDiscoverFilterData.kt | 16 + .../compose/MediaDiscoverFilterScreen.kt | 82 ++-- .../component/content/GeneralContent.kt | 32 +- .../filter/component/content/GenreContent.kt | 17 +- .../component/content/SortingContent.kt | 25 +- .../filter/component/content/TagContent.kt | 24 +- .../viewmodel/genre/GenreViewModel.kt | 3 +- .../genre/state/GenreViewModelState.kt | 4 +- .../component/viewmodel/tag/TagViewModel.kt | 3 +- .../viewmodel/tag/state/TagViewModelState.kt | 4 +- .../filter/initializer/FeatureInitializer.kt | 3 +- .../media/discover/filter/koin/Modules.kt | 117 ++--- .../filter/provider/FeatureProvider.kt | 3 +- .../layout/media_discover_filter_general.xml | 35 +- .../layout/media_discover_filter_genre.xml | 33 +- .../layout/media_discover_filter_sorting.xml | 33 +- .../res/layout/media_discover_filter_tag.xml | 33 +- .../src/main/res/values/strings.xml | 31 +- feature-media-discover/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../component/content/MediaDiscoverContent.kt | 38 +- .../component/screen/MediaDiscoverScreen.kt | 13 +- .../sheet/MediaDiscoverFilterSheet.kt | 37 +- .../sheet/adapter/FilterPageAdapter.kt | 41 +- .../sheet/controller/MediaFilterController.kt | 53 ++- .../initializer/FeatureInitializer.kt | 3 +- .../anitrend/media/discover/koin/Modules.kt | 79 +-- .../discover/provider/FeatureProvider.kt | 7 +- .../layout/media_discover_filter_sheet.xml | 34 +- .../main/res/layout/media_discover_screen.xml | 31 +- .../src/main/res/values/strings.xml | 31 +- feature-media/build.gradle.kts | 2 +- feature-media/src/main/AndroidManifest.xml | 32 +- .../component/action/ManageMediaProvider.kt | 20 +- .../action/MediaFavouriteActionProvider.kt | 14 +- .../media/component/compose/MediaCompose.kt | 78 +-- .../media/component/screen/MediaScreen.kt | 8 +- .../media/initializer/FeatureInitializer.kt | 5 +- .../kotlin/co/anitrend/media/koin/Modules.kt | 37 +- .../media/provider/FeatureProvider.kt | 6 +- .../main/res/drawable/ic_my_anime_list.xml | 17 + .../src/main/res/menu/media_content_menu.xml | 34 +- feature-media/src/main/res/values/strings.xml | 32 +- feature-medialist-editor/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../component/screen/MediaListEditorScreen.kt | 4 +- .../component/sheet/MediaListEditorContent.kt | 19 +- .../compose/MediaListEditorComponents.kt | 18 +- .../controller/MediaListEditorController.kt | 106 +++-- .../editor/initializer/FeatureInitializer.kt | 7 +- .../anitrend/medialist/editor/koin/Modules.kt | 53 ++- .../editor/provider/FeatureProvider.kt | 10 +- .../res/layout/media_list_editor_content.xml | 31 +- .../res/layout/media_list_editor_screen.xml | 32 +- .../src/main/res/values/strings.xml | 32 +- feature-medialist/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../component/container/MediaListContainer.kt | 49 +- .../container/adapter/MediaListPageAdapter.kt | 26 +- .../mediator/MediaListTabConfiguration.kt | 19 +- .../component/content/MediaListContent.kt | 36 +- .../component/screen/MediaListScreen.kt | 13 +- .../initializer/FeatureInitializer.kt | 5 +- .../co/anitrend/medialist/koin/Modules.kt | 94 ++-- .../medialist/provider/FeatureProvider.kt | 8 +- .../main/res/layout/media_list_container.xml | 33 +- .../src/main/res/layout/media_list_screen.xml | 31 +- .../src/main/res/values/strings.xml | 32 +- feature-news/build.gradle.kts | 2 +- feature-news/src/main/AndroidManifest.xml | 32 +- .../news/plugin/decorator/FrameTagReplacer.kt | 6 +- .../plugin/span/YouTubeSpanConfiguration.kt | 2 +- .../src/main/res/drawable/ic_explore_24.xml | 31 +- .../src/main/res/drawable/ic_share_24.xml | 32 +- .../src/main/res/layout/news_content.xml | 31 +- .../src/main/res/layout/news_screen.xml | 31 +- feature-news/src/main/res/menu/news_menu.xml | 31 +- feature-news/src/main/res/values/strings.xml | 31 +- feature-notification/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../component/content/NotificationContent.kt | 9 +- .../component/screen/NotificationScreen.kt | 13 +- .../viewmodel/NotificationViewModel.kt | 3 +- .../viewmodel/state/NotificationState.kt | 3 +- .../initializer/FeatureInitializer.kt | 7 +- .../co/anitrend/notification/koin/Modules.kt | 23 +- .../notification/provider/FeatureProvider.kt | 8 +- .../main/res/layout/notification_content.xml | 32 +- .../main/res/layout/notification_screen.xml | 32 +- .../src/main/res/values/strings.xml | 32 +- feature-profile/build.gradle.kts | 16 + feature-profile/src/main/AndroidManifest.xml | 32 +- .../component/compose/ProfileCompose.kt | 71 +-- .../component/content/ProfileContent.kt | 13 +- .../profile/component/screen/ProfileScreen.kt | 8 +- .../component/viewmodel/ProfileViewModel.kt | 3 +- .../component/viewmodel/state/ProfileState.kt | 3 +- .../profile/initializer/FeatureInitializer.kt | 5 +- .../co/anitrend/profile/koin/Modules.kt | 54 ++- .../profile/provider/FeatureProvider.kt | 8 +- .../src/main/res/layout/profile_content.xml | 31 +- .../src/main/res/layout/profile_screen.xml | 31 +- feature-recommendation/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../src/main/res/values/strings.xml | 32 +- feature-review-discover/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../content/ReviewDiscoverContent.kt | 13 +- .../viewmodel/ReviewDiscoverViewModel.kt | 3 +- .../viewmodel/state/ReviewDiscoverState.kt | 38 +- .../component/screen/ReviewDiscoverScreen.kt | 4 +- .../initializer/FeatureInitializer.kt | 7 +- .../anitrend/review/discover/koin/Modules.kt | 63 +-- .../discover/provider/FeatureProvider.kt | 10 +- .../src/main/res/layout/discover_screen.xml | 32 +- .../src/main/res/values/strings.xml | 32 +- feature-review/build.gradle.kts | 2 +- feature-review/src/main/AndroidManifest.xml | 32 +- .../review/component/content/ReviewContent.kt | 15 +- .../review/component/screen/ReviewScreen.kt | 13 +- .../component/viewmodel/ReviewViewModel.kt | 3 +- .../component/viewmodel/state/ReviewState.kt | 3 +- .../review/initializer/FeatureInitializer.kt | 7 +- .../kotlin/co/anitrend/review/koin/Modules.kt | 23 +- .../review/provider/FeatureProvider.kt | 10 +- .../src/main/res/layout/review_content.xml | 32 +- .../src/main/res/layout/review_screen.xml | 32 +- .../src/main/res/values/strings.xml | 32 +- feature-search/build.gradle.kts | 2 +- feature-search/src/main/AndroidManifest.xml | 32 +- .../search/component/compose/SearchCompose.kt | 28 +- .../component/presenter/SearchPresenter.kt | 7 +- .../search/component/screen/SearchScreen.kt | 4 +- .../search/initializer/FeatureInitializer.kt | 6 +- .../kotlin/co/anitrend/search/koin/Modules.kt | 43 +- .../search/provider/FeatureProvider.kt | 8 +- .../src/main/res/drawable/ic_close_10dp.xml | 32 +- .../res/drawable/ic_search_indicator_line.xml | 31 +- .../src/main/res/layout/search_content.xml | 31 +- .../src/main/res/layout/search_screen.xml | 31 +- .../src/main/res/values/configuration.xml | 31 +- .../src/main/res/values/strings.xml | 31 +- feature-search/src/main/res/values/styles.xml | 31 +- .../src/main/res/xml/searchable.xml | 34 +- feature-settings/build.gradle.kts | 2 +- feature-settings/src/main/AndroidManifest.xml | 16 + .../component/content/SettingsContent.kt | 10 +- .../component/presenter/SettingsPresenter.kt | 7 +- .../component/screen/SettingsScreen.kt | 11 +- .../initializer/FeatureInitializer.kt | 5 +- .../co/anitrend/settings/koin/Modules.kt | 47 +- .../settings/provider/FeatureProvider.kt | 8 +- .../res/drawable/ic_account_circle_24dp.xml | 32 +- .../main/res/drawable/ic_color_lens_24dp.xml | 32 +- .../main/res/drawable/ic_filter_list_24dp.xml | 32 +- .../res/drawable/ic_layers_clear_24dp.xml | 32 +- .../src/main/res/drawable/ic_memory_24dp.xml | 17 + .../res/drawable/ic_notifications_24dp.xml | 32 +- .../res/drawable/ic_photo_filter_24dp.xml | 32 +- .../src/main/res/drawable/ic_policy_24dp.xml | 32 +- .../src/main/res/drawable/ic_power_24.xml | 17 + .../src/main/res/drawable/ic_storage_24dp.xml | 32 +- .../src/main/res/drawable/ic_sync_24dp.xml | 32 +- .../res/drawable/ic_system_update_24dp.xml | 32 +- .../main/res/drawable/ic_translate_24dp.xml | 32 +- .../src/main/res/layout/settings_activity.xml | 32 +- .../src/main/res/values/arrays.xml | 32 +- .../src/main/res/values/strings.xml | 32 +- .../src/main/res/xml/root_preferences.xml | 32 +- feature-staff/build.gradle.kts | 2 +- feature-staff/src/main/AndroidManifest.xml | 32 +- .../staff/component/screen/StaffScreen.kt | 4 +- .../src/main/res/layout/staff_screen.xml | 31 +- feature-staff/src/main/res/values/strings.xml | 32 +- feature-studio/build.gradle.kts | 2 +- feature-studio/src/main/AndroidManifest.xml | 32 +- .../studio/component/screen/StudioScreen.kt | 4 +- .../src/main/res/layout/studio_screen.xml | 31 +- .../src/main/res/values/strings.xml | 32 +- feature-suggestion/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- .../component/content/SuggestionContent.kt | 9 +- .../component/screen/SuggestionScreen.kt | 13 +- .../viewmodel/SuggestionViewModel.kt | 3 +- .../viewmodel/state/SuggestionState.kt | 3 +- .../initializer/FeatureInitializer.kt | 7 +- .../co/anitrend/suggestion/koin/Modules.kt | 23 +- .../suggestion/provider/FeatureProvider.kt | 10 +- .../main/res/layout/suggestion_content.xml | 32 +- .../src/main/res/layout/suggestion_screen.xml | 32 +- .../src/main/res/values/strings.xml | 32 +- feature-updater/build.gradle.kts | 2 +- feature-updater/src/main/AndroidManifest.xml | 32 +- .../updater/component/compose/UpdateScreen.kt | 15 +- .../updater/component/screen/UpdateScreen.kt | 3 +- .../updater/initializer/FeatureInitializer.kt | 5 +- .../co/anitrend/updater/koin/Modules.kt | 37 +- .../updater/provider/FeatureProvider.kt | 6 +- gradle/libs.versions.toml | 4 +- settings.gradle.kts | 5 - task-account/build.gradle.kts | 2 +- task-account/src/main/AndroidManifest.xml | 32 +- .../account/component/AccountSignInWorker.kt | 30 +- .../account/component/AccountSignOutWorker.kt | 12 +- .../account/initializer/FeatureInitializer.kt | 5 +- .../co/anitrend/task/account/koin/Modules.kt | 54 ++- .../task/account/provider/FeatureProvider.kt | 6 +- task-character/build.gradle.kts | 2 +- task-character/src/main/AndroidManifest.xml | 32 +- task-config/build.gradle.kts | 2 +- task-config/src/main/AndroidManifest.xml | 32 +- .../task/config/component/ConfigWorker.kt | 32 +- .../config/initializer/FeatureInitializer.kt | 17 +- .../initializer/WorkSchedulerInitializer.kt | 18 +- .../co/anitrend/task/config/koin/Modules.kt | 49 +- .../task/config/provider/FeatureProvider.kt | 17 + .../task/config/scheduler/ConfigScheduler.kt | 42 +- task-episode/build.gradle.kts | 2 +- task-episode/src/main/AndroidManifest.xml | 32 +- .../task/episode/component/EpisodeWorker.kt | 21 +- .../episode/initializer/FeatureInitializer.kt | 6 +- .../initializer/WorkSchedulerInitializer.kt | 7 +- .../co/anitrend/task/episode/koin/Modules.kt | 38 +- .../task/episode/provider/FeatureProvider.kt | 6 +- .../episode/scheduler/EpisodeScheduler.kt | 30 +- task-favourite/build.gradle.kts | 2 +- task-favourite/src/main/AndroidManifest.xml | 32 +- .../component/MediaFavouriteWorker.kt | 30 +- .../initializer/FeatureInitializer.kt | 5 +- .../anitrend/task/favourite/koin/Modules.kt | 23 +- .../favourite/provider/FeatureProvider.kt | 3 +- .../src/main/res/values/strings.xml | 32 +- task-feed/build.gradle.kts | 2 +- task-feed/src/main/AndroidManifest.xml | 32 +- task-forum/build.gradle.kts | 2 +- task-forum/src/main/AndroidManifest.xml | 32 +- task-genre/build.gradle.kts | 2 +- task-genre/src/main/AndroidManifest.xml | 32 +- .../task/genre/component/GenreWorker.kt | 28 +- .../genre/initializer/FeatureInitializer.kt | 6 +- .../initializer/WorkSchedulerInitializer.kt | 5 +- .../co/anitrend/task/genre/koin/Modules.kt | 36 +- .../task/genre/provider/FeatureProvider.kt | 7 +- .../task/genre/scheduler/GenreScheduler.kt | 30 +- task-media/build.gradle.kts | 2 +- task-media/src/main/AndroidManifest.xml | 32 +- task-medialist/build.gradle.kts | 2 +- task-medialist/src/main/AndroidManifest.xml | 32 +- .../sync/MediaListAnimeSyncWorker.kt | 28 +- .../sync/MediaListMangaSyncWorker.kt | 28 +- .../worker/MediaListDeleteCustomListWorker.kt | 17 +- .../worker/MediaListDeleteEntryWorker.kt | 17 +- .../worker/MediaListSaveEntriesWorker.kt | 19 +- .../worker/MediaListSaveEntryWorker.kt | 19 +- .../initializer/FeatureInitializer.kt | 5 +- .../initializer/WorkSchedulerInitializer.kt | 6 +- .../anitrend/task/medialist/koin/Modules.kt | 110 ++--- .../medialist/provider/FeatureProvider.kt | 13 +- .../medialist/scheduler/AnimeSyncScheduler.kt | 30 +- .../medialist/scheduler/MangaSyncScheduler.kt | 30 +- task-news/build.gradle.kts | 2 +- task-news/src/main/AndroidManifest.xml | 32 +- .../task/news/component/NewsWorker.kt | 21 +- .../news/initializer/FeatureInitializer.kt | 6 +- .../initializer/WorkSchedulerInitializer.kt | 7 +- .../co/anitrend/task/news/koin/Modules.kt | 38 +- .../task/news/provider/FeatureProvider.kt | 6 +- .../task/news/scheduler/NewsScheduler.kt | 30 +- task-recommendation/build.gradle.kts | 2 +- .../src/main/AndroidManifest.xml | 32 +- task-review/build.gradle.kts | 2 +- task-review/src/main/AndroidManifest.xml | 32 +- .../component/ReviewDeleteEntryWorker.kt | 17 +- .../review/component/ReviewSaveEntryWorker.kt | 17 +- .../review/component/ReviewVoteEntryWorker.kt | 20 +- .../review/initializer/FeatureInitializer.kt | 5 +- .../co/anitrend/task/review/koin/Modules.kt | 64 +-- .../task/review/provider/FeatureProvider.kt | 8 +- task-staff/build.gradle.kts | 2 +- task-staff/src/main/AndroidManifest.xml | 32 +- task-studio/build.gradle.kts | 2 +- task-studio/src/main/AndroidManifest.xml | 32 +- task-tag/build.gradle.kts | 2 +- task-tag/src/main/AndroidManifest.xml | 32 +- .../anitrend/task/tag/component/TagWorker.kt | 28 +- .../tag/initializer/FeatureInitializer.kt | 6 +- .../initializer/WorkSchedulerInitializer.kt | 5 +- .../co/anitrend/task/tag/koin/Modules.kt | 36 +- .../task/tag/provider/FeatureProvider.kt | 7 +- .../task/tag/scheduler/TagScheduler.kt | 30 +- task-updater/build.gradle.kts | 2 +- task-updater/src/main/AndroidManifest.xml | 32 +- task-user/build.gradle.kts | 2 +- task-user/src/main/AndroidManifest.xml | 32 +- .../user/component/UserAccountSyncWorker.kt | 11 +- .../user/component/UserFollowToggleWorker.kt | 16 +- .../user/component/UserStatisticSyncWorker.kt | 6 +- .../user/initializer/FeatureInitializer.kt | 5 +- .../initializer/WorkSchedulerInitializer.kt | 6 +- .../co/anitrend/task/user/koin/Modules.kt | 62 +-- .../task/user/provider/FeatureProvider.kt | 9 +- .../user/scheduler/UserAccountScheduler.kt | 30 +- .../user/scheduler/UserStatisticScheduler.kt | 30 +- 1136 files changed, 16685 insertions(+), 14640 deletions(-) rename app-data-android/src/main/kotlin/co/anitrend/data/android/logger/{GraphLogger.kt => GraphTimberLogger.kt} (86%) delete mode 100644 app-data-edge/src/main/kotlin/co/anitrend/data/edge/navigation/converters/EdgeNavigationConverters.kt create mode 100644 app-data-edge/src/main/kotlin/co/anitrend/data/edge/navigation/converters/EdgeNavigationModelConverter.kt rename app-data/src/main/kotlin/co/anitrend/data/rank/converter/{RankConverters.kt => RankModelConverter.kt} (99%) rename common-episode-ui/src/main/kotlin/co/anitrend/common/episode/ui/controller/helpers/{ControllerDiffers.kt => EpisodeDiffUtil.kt} (92%) rename common-genre-ui/src/main/kotlin/co/anitrend/common/genre/ui/controller/helpers/{ControllerDiffers.kt => GenreDiffUtil.kt} (93%) rename common-news-ui/src/main/kotlin/co/anitrend/common/news/ui/controller/helpers/{ControllerDiffers.kt => NewsDiffUtil.kt} (93%) rename common-tag-ui/src/main/kotlin/co/anitrend/common/tag/ui/controller/helpers/{ControllerDiffers.kt => TagDiffUtil.kt} (93%) diff --git a/.editorconfig b/.editorconfig index 0f1bfad5b..d06448c92 100644 --- a/.editorconfig +++ b/.editorconfig @@ -20,5 +20,7 @@ ij_kotlin_allow_trailing_comma_on_call_site=true # Don't allow any wildcard imports ij_kotlin_packages_to_use_import_on_demand = unset +ktlint_function_naming_ignore_when_annotated_with = Composable + [*.md] -trim_trailing_whitespace = false +trim_trailing_whitespace = false \ No newline at end of file diff --git a/android-core/build.gradle.kts b/android-core/build.gradle.kts index 9bb38fa4e..b6439e4fd 100644 --- a/android-core/build.gradle.kts +++ b/android-core/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/android-core/src/main/AndroidManifest.xml b/android-core/src/main/AndroidManifest.xml index d3958e7c2..89e087b99 100644 --- a/android-core/src/main/AndroidManifest.xml +++ b/android-core/src/main/AndroidManifest.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2019 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/Extensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/Extensions.kt index e077139ef..6167ef3a1 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/Extensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/Extensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android import android.view.ViewGroup @@ -40,7 +39,7 @@ import java.util.Date */ inline fun koinOf( qualifier: Qualifier? = null, - noinline parameters: ParametersDefinition? = null + noinline parameters: ParametersDefinition? = null, ): T { val context = KoinPlatformTools.defaultContext() val koin = context.get() @@ -55,7 +54,7 @@ inline fun koinOf( fun AiringSchedule.asPrettyTime(): String { val prettyTime = koinOf() return prettyTime.format( - Date(airingAt * 1000) + Date(airingAt * 1000), ) } @@ -72,15 +71,20 @@ fun Instant.asPrettyTime(): String { /** * Displays an error message for missing parameters otherwise runs [block] */ -inline fun ISupportStateLayout.assureParamNotMissing(param: IParam?, block: () -> Unit) { +inline fun ISupportStateLayout.assureParamNotMissing( + param: IParam?, + block: () -> Unit, +) { if (param == null) { this as ViewGroup - loadStateFlow.value = LoadState.Error( - RequestError( - topic = context.getString(R.string.app_controller_heading_missing_param), - description = context.getString(R.string.app_controller_message_missing_param), + loadStateFlow.value = + LoadState.Error( + RequestError( + topic = context.getString(R.string.app_controller_heading_missing_param), + description = context.getString(R.string.app_controller_message_missing_param), + ), ) - ) + } else { + block() } - else block() } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/animations/AlphaAnimator.kt b/android-core/src/main/kotlin/co/anitrend/core/android/animations/AlphaAnimator.kt index 5ffac8c6e..6a6d2161d 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/animations/AlphaAnimator.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/animations/AlphaAnimator.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.animations import android.animation.Animator @@ -25,18 +24,22 @@ import co.anitrend.arch.theme.animator.contract.AbstractAnimator class AlphaAnimator( val from: Float = .85f, - val to: Float = 1f + val to: Float = 1f, ) : AbstractAnimator() { override val interpolator = LinearInterpolator() override fun getAnimators(view: View): Array { - val animator = ObjectAnimator.ofFloat( - view, PROPERTY_NAME, from, to - ) + val animator = + ObjectAnimator.ofFloat( + view, + PROPERTY_NAME, + from, + to, + ) return arrayOf(animator) } companion object { private const val PROPERTY_NAME = "alpha" } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/animations/AnimationExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/animations/AnimationExtensions.kt index e2ebf1f0a..05c54c898 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/animations/AnimationExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/animations/AnimationExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.animations import androidx.annotation.ColorInt @@ -22,14 +21,13 @@ import androidx.annotation.FloatRange import com.google.android.material.animation.ArgbEvaluatorCompat import kotlin.math.roundToInt - /** * Linearly interpolate between two values */ fun lerp( startValue: Float, endValue: Float, - @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float + @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float, ): Float { return startValue + fraction * (endValue - startValue) } @@ -40,7 +38,7 @@ fun lerp( fun lerp( startValue: Int, endValue: Int, - @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float + @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float, ): Int { return (startValue + fraction * (endValue - startValue)).roundToInt() } @@ -55,10 +53,10 @@ fun lerp( from = 0.0, fromInclusive = true, to = 1.0, - toInclusive = false + toInclusive = false, ) startFraction: Float, @FloatRange(from = 0.0, fromInclusive = false, to = 1.0, toInclusive = true) endFraction: Float, - @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float + @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float, ): Float { if (fraction < startFraction) return startValue if (fraction > endFraction) return endValue @@ -76,10 +74,10 @@ fun lerp( from = 0.0, fromInclusive = true, to = 1.0, - toInclusive = false + toInclusive = false, ) startFraction: Float, @FloatRange(from = 0.0, fromInclusive = false, to = 1.0, toInclusive = true) endFraction: Float, - @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float + @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float, ): Int { if (fraction < startFraction) return startValue if (fraction > endFraction) return endValue @@ -98,10 +96,10 @@ fun lerpArgb( from = 0.0, fromInclusive = true, to = 1.0, - toInclusive = false + toInclusive = false, ) startFraction: Float, @FloatRange(from = 0.0, fromInclusive = false, to = 1.0, toInclusive = true) endFraction: Float, - @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float + @FloatRange(from = 0.0, fromInclusive = true, to = 1.0, toInclusive = true) fraction: Float, ): Int { if (fraction < startFraction) return startColor if (fraction > endFraction) return endColor @@ -109,7 +107,7 @@ fun lerpArgb( return ArgbEvaluatorCompat.getInstance().evaluate( (fraction - startFraction) / (endFraction - startFraction), startColor, - endColor + endColor, ) } @@ -124,7 +122,7 @@ fun Float.normalize( inputMin: Float, inputMax: Float, outputMin: Float, - outputMax: Float + outputMax: Float, ): Float { if (this < inputMin) { return outputMin @@ -133,5 +131,5 @@ fun Float.normalize( } return outputMin * (1 - (this - inputMin) / (inputMax - inputMin)) + - outputMax * ((this - inputMin) / (inputMax - inputMin)) -} \ No newline at end of file + outputMax * ((this - inputMin) / (inputMax - inputMin)) +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/behaviour/BottomOffsetBehavior.kt b/android-core/src/main/kotlin/co/anitrend/core/android/behaviour/BottomOffsetBehavior.kt index 79ae05d40..8ce74ec1e 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/behaviour/BottomOffsetBehavior.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/behaviour/BottomOffsetBehavior.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.behaviour import android.content.Context @@ -29,10 +28,9 @@ import co.anitrend.core.android.R */ class BottomOffsetBehavior( private val context: Context, - private val attributeSet: AttributeSet + private val attributeSet: AttributeSet, ) : CoordinatorLayout.Behavior() { - - //TODO: Offsets don't seem to be getting applied on the bottom, not entirely sure what could be missing + // TODO: Offsets don't seem to be getting applied on the bottom, not entirely sure what could be missing private lateinit var viewOffsetHelper: ViewOffsetHelper @@ -60,33 +58,34 @@ class BottomOffsetBehavior( override fun onLayoutChild( parent: CoordinatorLayout, child: View, - layoutDirection: Int + layoutDirection: Int, ): Boolean { parent.onLayoutChild(child, layoutDirection) - if (!::viewOffsetHelper.isInitialized) + if (!::viewOffsetHelper.isInitialized) { viewOffsetHelper = ViewOffsetHelper(child) + } viewOffsetHelper.doOnInit() viewOffsetHelper.applyOffsets() return setBottomOffset( context.resources.getDimensionPixelSize( - R.dimen.design_bottom_app_bar_height - ) + R.dimen.design_bottom_app_bar_height, + ), ) } private fun setBottomOffset(offset: Int): Boolean { val offsetHelper = viewOffsetHelper - if (::viewOffsetHelper.isInitialized) + if (::viewOffsetHelper.isInitialized) { return offsetHelper.setBottomOffset(offset) + } return false } private class ViewOffsetHelper(private val view: View) { - private var layoutBottom = 0 private var offsetBottom = 0 @@ -117,4 +116,4 @@ class BottomOffsetBehavior( return false } } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/binding/IBindingView.kt b/android-core/src/main/kotlin/co/anitrend/core/android/binding/IBindingView.kt index 3bb7da7ff..5287dfcea 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/binding/IBindingView.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/binding/IBindingView.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.binding import androidx.viewbinding.ViewBinding @@ -24,8 +23,7 @@ import androidx.viewbinding.ViewBinding * * @property binding The binding property that represents a view */ -interface IBindingView { - +interface IBindingView { var binding: B? /** @@ -36,4 +34,4 @@ interface IBindingView { */ @Throws(IllegalArgumentException::class) fun requireBinding(): B = requireNotNull(binding) -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/components/action/FloatingActionMenu.kt b/android-core/src/main/kotlin/co/anitrend/core/android/components/action/FloatingActionMenu.kt index 460cc937d..f5410c657 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/components/action/FloatingActionMenu.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/components/action/FloatingActionMenu.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.components.action import android.content.Context @@ -30,56 +29,60 @@ import co.anitrend.core.android.components.action.menu.IFloatingActionMenu import co.anitrend.core.android.databinding.ActionFrameLayoutBinding import co.anitrend.core.android.views.FrameLayoutWithBinding -class FloatingActionMenu @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : FrameLayoutWithBinding(context, attrs, defStyleAttr), - CustomView, IFloatingActionMenu { - - init { - onInit(context, attrs, defStyleAttr) - } +class FloatingActionMenu + @JvmOverloads + constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + ) : FrameLayoutWithBinding(context, attrs, defStyleAttr), + CustomView, + IFloatingActionMenu { + init { + onInit(context, attrs, defStyleAttr) + } - override fun onViewRecycled() { - dismiss() - binding?.actionMenuView?.setOnMenuItemClickListener(null) - super.onViewRecycled() - } + override fun onViewRecycled() { + dismiss() + binding?.actionMenuView?.setOnMenuItemClickListener(null) + super.onViewRecycled() + } - override fun onDetachedFromWindow() { - super.onDetachedFromWindow() - onViewRecycled() - } + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + onViewRecycled() + } - override fun findMenuItem(id: Int): MenuItem? { - return binding?.actionMenuView?.menu?.findItem(id) - } + override fun findMenuItem(id: Int): MenuItem? { + return binding?.actionMenuView?.menu?.findItem(id) + } - override fun inflate( - menuInflater: MenuInflater?, - @MenuRes menuRes: Int, - clickListener: (item: MenuItem?) -> Boolean - ) { - val actionMenuView = binding?.actionMenuView - if (actionMenuView?.menu?.size() == 0) { - menuInflater?.inflate(menuRes, actionMenuView.menu) - actionMenuView.setOnMenuItemClickListener { - clickListener(it) + override fun inflate( + menuInflater: MenuInflater?, + @MenuRes menuRes: Int, + clickListener: (item: MenuItem?) -> Boolean, + ) { + val actionMenuView = binding?.actionMenuView + if (actionMenuView?.menu?.size() == 0) { + menuInflater?.inflate(menuRes, actionMenuView.menu) + actionMenuView.setOnMenuItemClickListener { + clickListener(it) + } } } - } - override fun show() { - visible() - } + override fun show() { + visible() + } - override fun dismiss() { - gone() - } + override fun dismiss() { + gone() + } - override fun createBinding() = - ActionFrameLayoutBinding.inflate( - getLayoutInflater(), - this, - true - ) -} \ No newline at end of file + override fun createBinding() = + ActionFrameLayoutBinding.inflate( + getLayoutInflater(), + this, + true, + ) + } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/components/action/menu/IFloatingActionMenu.kt b/android-core/src/main/kotlin/co/anitrend/core/android/components/action/menu/IFloatingActionMenu.kt index 02af04389..64e0fafb6 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/components/action/menu/IFloatingActionMenu.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/components/action/menu/IFloatingActionMenu.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.components.action.menu import android.view.MenuInflater @@ -23,11 +22,12 @@ import androidx.annotation.IdRes import androidx.annotation.MenuRes interface IFloatingActionMenu { - /** * Find a menu item for the given [id] */ - fun findMenuItem(@IdRes id: Int): MenuItem? + fun findMenuItem( + @IdRes id: Int, + ): MenuItem? /** * Inflate menu @@ -35,7 +35,7 @@ interface IFloatingActionMenu { fun inflate( menuInflater: MenuInflater?, @MenuRes menuRes: Int, - clickListener: (item: MenuItem?) -> Boolean + clickListener: (item: MenuItem?) -> Boolean, ) /** @@ -47,4 +47,4 @@ interface IFloatingActionMenu { * Close action menu */ fun dismiss() -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/components/edgetreatment/SemiCircleCutout.kt b/android-core/src/main/kotlin/co/anitrend/core/android/components/edgetreatment/SemiCircleCutout.kt index 6ab01b422..228c9e2eb 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/components/edgetreatment/SemiCircleCutout.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/components/edgetreatment/SemiCircleCutout.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.components.edgetreatment import com.google.android.material.shape.EdgeTreatment @@ -40,9 +39,8 @@ class SemiCircleCutout( private var cutoutRoundedCornerRadius: Float = 0F, private var cutoutVerticalOffset: Float = 0F, private var cutoutDiameter: Float = 0F, - private var cutoutHorizontalOffset: Float = 0F + private var cutoutHorizontalOffset: Float = 0F, ) : EdgeTreatment() { - private var cradleDiameter = 0F private var cradleRadius = 0F private var roundedCornerOffset = 0F @@ -65,10 +63,10 @@ class SemiCircleCutout( } override fun getEdgePath( - length: Float, - center: Float, - interpolation: Float, - shapePath: ShapePath + length: Float, + center: Float, + interpolation: Float, + shapePath: ShapePath, ) { if (cutoutDiameter == 0f) { // There is no cutout to draw. @@ -82,7 +80,7 @@ class SemiCircleCutout( middle = length / 2f + cutoutHorizontalOffset verticalOffset = interpolation * cutoutVerticalOffset + - (1 - interpolation) * cradleRadius + (1 - interpolation) * cradleRadius verticalOffsetRatio = verticalOffset / cradleRadius if (verticalOffsetRatio >= 1.0f) { @@ -101,18 +99,20 @@ class SemiCircleCutout( distanceBetweenCenters = cradleRadius + roundedCornerOffset distanceBetweenCentersSquared = distanceBetweenCenters * distanceBetweenCenters distanceY = verticalOffset + roundedCornerOffset - distanceX = sqrt( - (distanceBetweenCentersSquared - distanceY * distanceY).toDouble() - ).toFloat() + distanceX = + sqrt( + (distanceBetweenCentersSquared - distanceY * distanceY).toDouble(), + ).toFloat() // Calculate the x position of the rounded corner circles. leftRoundedCornerCircleX = middle - distanceX rightRoundedCornerCircleX = middle + distanceX // Calculate the arc between the center of the two circles. - cornerRadiusArcLength = Math.toDegrees( - atan((distanceX / distanceY).toDouble()) - ).toFloat() + cornerRadiusArcLength = + Math.toDegrees( + atan((distanceX / distanceY).toDouble()), + ).toFloat() cutoutArcOffset = ARC_QUARTER - cornerRadiusArcLength // Draw the starting line up to the left rounded corner. @@ -121,32 +121,34 @@ class SemiCircleCutout( // Draw the arc for the left rounded corner circle. The bounding box is the area around the // circle's center which is at (leftRoundedCornerCircleX, roundedCornerOffset). shapePath.addArc( - leftRoundedCornerCircleX - roundedCornerOffset, - 0f, - leftRoundedCornerCircleX + roundedCornerOffset, - roundedCornerOffset * 2, - ANGLE_UP.toFloat(), - cornerRadiusArcLength) + leftRoundedCornerCircleX - roundedCornerOffset, + 0f, + leftRoundedCornerCircleX + roundedCornerOffset, + roundedCornerOffset * 2, + ANGLE_UP.toFloat(), + cornerRadiusArcLength, + ) // Draw the cutout circle. shapePath.addArc( - middle - cradleRadius, - -cradleRadius - verticalOffset, - middle + cradleRadius, - cradleRadius - verticalOffset, - ANGLE_LEFT - cutoutArcOffset, - cutoutArcOffset * 2 - ARC_HALF + middle - cradleRadius, + -cradleRadius - verticalOffset, + middle + cradleRadius, + cradleRadius - verticalOffset, + ANGLE_LEFT - cutoutArcOffset, + cutoutArcOffset * 2 - ARC_HALF, ) // Draw an arc for the right rounded corner circle. The bounding box is the area around the // circle's center which is at (rightRoundedCornerCircleX, roundedCornerOffset). shapePath.addArc( - rightRoundedCornerCircleX - roundedCornerOffset, - 0f, - rightRoundedCornerCircleX + roundedCornerOffset, - roundedCornerOffset * 2, - ANGLE_UP - cornerRadiusArcLength, - cornerRadiusArcLength) + rightRoundedCornerCircleX - roundedCornerOffset, + 0f, + rightRoundedCornerCircleX + roundedCornerOffset, + roundedCornerOffset * 2, + ANGLE_UP - cornerRadiusArcLength, + cornerRadiusArcLength, + ) // Draw the ending line after the right rounded corner. shapePath.lineTo(length, 0f) diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/SheetBehaviourCallback.kt b/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/SheetBehaviourCallback.kt index 851578f0b..bdf849f48 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/SheetBehaviourCallback.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/SheetBehaviourCallback.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.components.sheet import android.view.View @@ -43,25 +42,32 @@ class SheetBehaviourCallback : BottomSheetBehavior.BottomSheetCallback() { private var lastSlideOffset = -1.0F private var halfExpandedSlideOffset = Float.MAX_VALUE - - override fun onSlide(sheet: View, slideOffset: Float) { - if (halfExpandedSlideOffset == Float.MAX_VALUE) + override fun onSlide( + sheet: View, + slideOffset: Float, + ) { + if (halfExpandedSlideOffset == Float.MAX_VALUE) { calculateInitialHalfExpandedSlideOffset(sheet) + } lastSlideOffset = slideOffset // Correct for the fact that the slideOffset is not zero when half expanded - val trueOffset = if (slideOffset <= halfExpandedSlideOffset) { - slideOffset.normalize(-1F, halfExpandedSlideOffset, -1F, 0F) - } else { - slideOffset.normalize(halfExpandedSlideOffset, 1F, 0F, 1F) - } + val trueOffset = + if (slideOffset <= halfExpandedSlideOffset) { + slideOffset.normalize(-1F, halfExpandedSlideOffset, -1F, 0F) + } else { + slideOffset.normalize(halfExpandedSlideOffset, 1F, 0F, 1F) + } onSlideActions.forEach { it.onSlide(sheet, trueOffset) } } - override fun onStateChanged(sheet: View, newState: Int) { + override fun onStateChanged( + sheet: View, + newState: Int, + ) { if (newState == BottomSheetBehavior.STATE_HALF_EXPANDED) { halfExpandedSlideOffset = lastSlideOffset onSlide(sheet, lastSlideOffset) @@ -91,14 +97,16 @@ class SheetBehaviourCallback : BottomSheetBehavior.BottomSheetCallback() { val behavior = BottomSheetBehavior.from(sheet) val halfExpandedOffset = parent.height * (1 - behavior.halfExpandedRatio) - val peekHeightMin = parent.resources.getDimensionPixelSize( - R.dimen.design_bottom_sheet_peek_height_min - ) + val peekHeightMin = + parent.resources.getDimensionPixelSize( + R.dimen.design_bottom_sheet_peek_height_min, + ) val peek = max(peekHeightMin, parent.height - parent.width * 9 / 16) - val collapsedOffset = max( - parent.height - peek, - max(0, parent.height - sheet.height) - ) + val collapsedOffset = + max( + parent.height - peek, + max(0, parent.height - sheet.height), + ) halfExpandedSlideOffset = (collapsedOffset - halfExpandedOffset) / (parent.height - collapsedOffset) } @@ -118,4 +126,4 @@ class SheetBehaviourCallback : BottomSheetBehavior.BottomSheetCallback() { fun removeOnStateChangedAction(action: OnStateChangedAction): Boolean { return onStateChangedActions.remove(action) } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/SheetHandleSlideAction.kt b/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/SheetHandleSlideAction.kt index e51c09248..cf446ca80 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/SheetHandleSlideAction.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/SheetHandleSlideAction.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.components.sheet.action import android.view.View @@ -22,13 +21,17 @@ import co.anitrend.core.android.animations.normalize import co.anitrend.core.android.components.sheet.action.contract.OnSlideAction class SheetHandleSlideAction(private val handle: View) : OnSlideAction { - override fun onSlide(sheet: View, slideOffset: Float) { - val alpha = slideOffset.normalize( - -1f, - 0f, - 0f, - 1f - ) + override fun onSlide( + sheet: View, + slideOffset: Float, + ) { + val alpha = + slideOffset.normalize( + -1f, + 0f, + 0f, + 1f, + ) handle.alpha = 1f - alpha } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/contract/OnSlideAction.kt b/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/contract/OnSlideAction.kt index 5fbf32ed1..da3342898 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/contract/OnSlideAction.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/contract/OnSlideAction.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.components.sheet.action.contract import android.view.View @@ -37,7 +36,7 @@ interface OnSlideAction { from = -1.0, fromInclusive = true, to = 1.0, - toInclusive = true - ) slideOffset: Float + toInclusive = true, + ) slideOffset: Float, ) -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/contract/OnStateChangedAction.kt b/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/contract/OnStateChangedAction.kt index 3e4aa0af4..d62aaf55e 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/contract/OnStateChangedAction.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/components/sheet/action/contract/OnStateChangedAction.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.components.sheet.action.contract import android.view.View @@ -23,5 +22,8 @@ import android.view.View * An action to be performed when a bottom sheet's state is changed. */ interface OnStateChangedAction { - fun onStateChanged(sheet: View, newState: Int) -} \ No newline at end of file + fun onStateChanged( + sheet: View, + newState: Int, + ) +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendColors.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendColors.kt index ca24fb8a9..8d73e237e 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendColors.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendColors.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.compose import android.content.Context @@ -26,25 +25,17 @@ import androidx.compose.ui.graphics.compositeOver import androidx.compose.ui.unit.Dp import co.anitrend.arch.extension.ext.getCompatColor +fun Context.primaryColor() = Color(getCompatColor(co.anitrend.arch.theme.R.color.primaryColor)) -fun Context.primaryColor() = - Color(getCompatColor(co.anitrend.arch.theme.R.color.primaryColor)) - -fun Context.secondaryColor() = - Color(getCompatColor(co.anitrend.arch.theme.R.color.secondaryColor)) - -fun Context.backgroundColor() = - Color(getCompatColor(co.anitrend.arch.theme.R.color.colorBackground)) +fun Context.secondaryColor() = Color(getCompatColor(co.anitrend.arch.theme.R.color.secondaryColor)) -fun Context.onBackgroundColor() = - Color(getCompatColor(co.anitrend.arch.theme.R.color.colorOnBackground)) +fun Context.backgroundColor() = Color(getCompatColor(co.anitrend.arch.theme.R.color.colorBackground)) -fun Context.primaryTextColor() = - Color(getCompatColor(co.anitrend.arch.theme.R.color.primaryTextColor)) +fun Context.onBackgroundColor() = Color(getCompatColor(co.anitrend.arch.theme.R.color.colorOnBackground)) -fun Context.secondaryTextColor() = - Color(getCompatColor(co.anitrend.arch.theme.R.color.secondaryTextColor)) +fun Context.primaryTextColor() = Color(getCompatColor(co.anitrend.arch.theme.R.color.primaryTextColor)) +fun Context.secondaryTextColor() = Color(getCompatColor(co.anitrend.arch.theme.R.color.secondaryTextColor)) /** * Return the fully opaque color that results from compositing [onSurface] atop [surface] with the @@ -62,6 +53,6 @@ fun Colors.compositedOnSurface(alpha: Float): Color { fun Colors.elevatedSurface(elevation: Dp): Color { return LocalElevationOverlay.current?.apply( color = this.surface, - elevation = elevation + elevation = elevation, ) ?: this.surface } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendDimens.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendDimens.kt index 8fb5d6400..ceafa9aa7 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendDimens.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendDimens.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 AniTrend + * Copyright (C) 2022 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,34 +14,33 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.compose import androidx.compose.ui.unit.dp -val bottom_sheet_margin = 0.dp +val BOTTOM_SHEET_MARGIN = 0.dp -val design_bottom_app_bar_height = 56.dp -val design_bottom_app_status_bar_height = 24.dp -val design_bottom_sheet_peek_height_min = 64.dp +val DESIGN_BOTTOM_APP_BAR_HEIGHT = 56.dp +val DESIGN_BOTTOM_APP_STATUS_BAR_HEIGHT = 24.dp +val DESIGN_BOTTOM_SHEET_PEEK_HEIGHT_MIN = 64.dp -val design_bottom_sheet_nav_divider_width = 120.dp -val design_tab_layout_min_width = 145.dp +val DESIGN_BOTTOM_SHEET_NAV_DIVIDER_WIDTH = 120.dp +val DESIGN_TAB_LAYOUT_MIN_WIDTH = 145.dp -val nav_item_selector_margin = 100.dp -val text_drawable_margin = 3.dp +val NAV_ITEM_SELECTOR_MARGIN = 100.dp +val TEXT_DRAWABLE_MARGIN = 3.dp -val avatar_xs = 8.dp -val avatar_sm = 12.dp -val avatar_md = 16.dp -val avatar_lg = 24.dp -val avatar_xl = 36.dp -val avatar_xx = 48.dp +val AVATAR_XS = 8.dp +val AVATAR_SM = 12.dp +val AVATAR_MD = 16.dp +val AVATAR_LG = 24.dp +val AVATAR_XL = 36.dp +val AVATAR_XX = 48.dp -val series_image_lg = 165.dp -val series_image_md = 145.dp -val series_image_sm = 125.dp -val series_image_xl = 185.dp -val series_image_xs = 100.dp +val SERIES_IMAGE_LG = 165.dp +val SERIES_IMAGE_MD = 145.dp +val SERIES_IMAGE_SM = 125.dp +val SERIES_IMAGE_XL = 185.dp +val SERIES_IMAGE_XS = 100.dp -const val series_aspect_ration = 0.65f \ No newline at end of file +const val SERIES_ASPECT_RATIO = 0.65f diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendThemes.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendThemes.kt index 45af91fe5..066ebad89 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendThemes.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/AniTrendThemes.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.compose import androidx.compose.foundation.shape.RoundedCornerShape @@ -36,40 +35,41 @@ import co.anitrend.arch.extension.ext.getCompatColor import co.anitrend.arch.theme.extensions.isEnvironmentNightMode object AniTrendTheme { - - private val defaultFontFamily = FontFamily( - Font( - resId = co.anitrend.arch.theme.R.font.product_sans_bold, - style = FontStyle.Normal, - weight = FontWeight.Bold - ), - Font( - resId = co.anitrend.arch.theme.R.font.product_sans_bold_italic, - style = FontStyle.Italic, - weight = FontWeight.Bold - ), - Font( - resId = co.anitrend.arch.theme.R.font.product_sans_italic, - style = FontStyle.Italic, - weight = FontWeight.Normal - ), - Font( - resId = co.anitrend.arch.theme.R.font.product_sans_regular, - style = FontStyle.Normal, - weight = FontWeight.Normal + private val defaultFontFamily = + FontFamily( + Font( + resId = co.anitrend.arch.theme.R.font.product_sans_bold, + style = FontStyle.Normal, + weight = FontWeight.Bold, + ), + Font( + resId = co.anitrend.arch.theme.R.font.product_sans_bold_italic, + style = FontStyle.Italic, + weight = FontWeight.Bold, + ), + Font( + resId = co.anitrend.arch.theme.R.font.product_sans_italic, + style = FontStyle.Italic, + weight = FontWeight.Normal, + ), + Font( + resId = co.anitrend.arch.theme.R.font.product_sans_regular, + style = FontStyle.Normal, + weight = FontWeight.Normal, + ), ) - ) /** * Shapes mirroring [co.anitrend.core.android.R.style.ShapeAppearance_MaterialComponents_SmallComponent], * [co.anitrend.core.android.R.style.ShapeAppearance_MaterialComponents_MediumComponent] and * [co.anitrend.core.android.R.style.ShapeAppearance_MaterialComponents_LargeComponent] */ - val shapes = Shapes( - small = RoundedCornerShape(8.dp), - medium = RoundedCornerShape(16.dp), - large = RoundedCornerShape(16.dp) - ) + val shapes = + Shapes( + small = RoundedCornerShape(8.dp), + medium = RoundedCornerShape(16.dp), + large = RoundedCornerShape(16.dp), + ) val colors: Colors @Composable get() { @@ -87,7 +87,7 @@ object AniTrendTheme { onBackground = Color(context.getCompatColor(co.anitrend.arch.theme.R.color.colorOnBackground)), onSurface = Color(context.getCompatColor(co.anitrend.arch.theme.R.color.colorOnSurface)), onError = Color(context.getCompatColor(co.anitrend.arch.theme.R.color.colorOnError)), - isLight = !context.isEnvironmentNightMode() + isLight = !context.isEnvironmentNightMode(), ) } @@ -96,94 +96,108 @@ object AniTrendTheme { val context = LocalContext.current return Typography( defaultFontFamily = defaultFontFamily, - h1 = TextStyle( - fontWeight = FontWeight.Light, - fontSize = 96.sp, - letterSpacing = (-1.5).sp, - color = context.primaryTextColor() - ), - h2 = TextStyle( - fontWeight = FontWeight.Light, - fontSize = 60.sp, - letterSpacing = (-0.5).sp, - color = context.primaryTextColor() - ), - h3 = TextStyle( - fontWeight = FontWeight.Normal, - fontSize = 48.sp, - letterSpacing = 0.sp, - color = context.primaryTextColor() - ), - h4 = TextStyle( - fontWeight = FontWeight.Normal, - fontSize = 34.sp, - letterSpacing = 0.25.sp, - color = context.primaryTextColor() - ), - h5 = TextStyle( - fontWeight = FontWeight.Normal, - fontSize = 24.sp, - letterSpacing = 0.sp, - color = context.primaryTextColor() - ), - h6 = TextStyle( - fontWeight = FontWeight.Medium, - fontSize = 20.sp, - letterSpacing = 0.15.sp, - color = context.primaryTextColor() - ), - subtitle1 = TextStyle( - fontWeight = FontWeight.Normal, - fontSize = 16.sp, - letterSpacing = 0.15.sp, - color = context.secondaryTextColor() - ), - subtitle2 = TextStyle( - fontWeight = FontWeight.Medium, - fontSize = 14.sp, - letterSpacing = 0.1.sp, - color = context.secondaryTextColor() - ), - body1 = TextStyle( - fontWeight = FontWeight.Normal, - fontSize = 16.sp, - letterSpacing = 0.5.sp, - color = context.primaryTextColor() - ), - body2 = TextStyle( - fontWeight = FontWeight.Normal, - fontSize = 14.sp, - letterSpacing = 0.25.sp, - color = context.primaryTextColor() - ), - button = TextStyle( - fontWeight = FontWeight.Medium, - fontSize = 14.sp, - letterSpacing = 1.25.sp, - color = context.primaryTextColor() - ), - caption = TextStyle( - fontWeight = FontWeight.Normal, - fontSize = 12.sp, - letterSpacing = 0.4.sp, - color = context.secondaryTextColor() - ), - overline = TextStyle( - fontWeight = FontWeight.Normal, - fontSize = 10.sp, - letterSpacing = 1.5.sp, - color = context.secondaryTextColor() - ) + h1 = + TextStyle( + fontWeight = FontWeight.Light, + fontSize = 96.sp, + letterSpacing = (-1.5).sp, + color = context.primaryTextColor(), + ), + h2 = + TextStyle( + fontWeight = FontWeight.Light, + fontSize = 60.sp, + letterSpacing = (-0.5).sp, + color = context.primaryTextColor(), + ), + h3 = + TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 48.sp, + letterSpacing = 0.sp, + color = context.primaryTextColor(), + ), + h4 = + TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 34.sp, + letterSpacing = 0.25.sp, + color = context.primaryTextColor(), + ), + h5 = + TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 24.sp, + letterSpacing = 0.sp, + color = context.primaryTextColor(), + ), + h6 = + TextStyle( + fontWeight = FontWeight.Medium, + fontSize = 20.sp, + letterSpacing = 0.15.sp, + color = context.primaryTextColor(), + ), + subtitle1 = + TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + letterSpacing = 0.15.sp, + color = context.secondaryTextColor(), + ), + subtitle2 = + TextStyle( + fontWeight = FontWeight.Medium, + fontSize = 14.sp, + letterSpacing = 0.1.sp, + color = context.secondaryTextColor(), + ), + body1 = + TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + letterSpacing = 0.5.sp, + color = context.primaryTextColor(), + ), + body2 = + TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 14.sp, + letterSpacing = 0.25.sp, + color = context.primaryTextColor(), + ), + button = + TextStyle( + fontWeight = FontWeight.Medium, + fontSize = 14.sp, + letterSpacing = 1.25.sp, + color = context.primaryTextColor(), + ), + caption = + TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 12.sp, + letterSpacing = 0.4.sp, + color = context.secondaryTextColor(), + ), + overline = + TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 10.sp, + letterSpacing = 1.5.sp, + color = context.secondaryTextColor(), + ), ) } } @Deprecated( message = "Use AniTrendTheme3 instead", - replaceWith = ReplaceWith( - "AniTrend3()", - "co.anitrend.core.android.ui.theme" - ), + replaceWith = + ReplaceWith( + "AniTrend3()", + "co.anitrend.core.android.ui.theme", + ), level = DeprecationLevel.ERROR, ) @Composable @@ -191,12 +205,12 @@ fun AniTrendTheme( colors: Colors = AniTrendTheme.colors, typography: Typography = AniTrendTheme.typography, shapes: Shapes = AniTrendTheme.shapes, - content: @Composable () -> Unit + content: @Composable () -> Unit, ) { MaterialTheme( colors = colors, content = content, typography = typography, - shapes = shapes + shapes = shapes, ) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/BackIconButton.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/BackIconButton.kt index 5fd5e849f..965cce696 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/BackIconButton.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/BackIconButton.kt @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.compose.design import androidx.compose.material.icons.Icons @@ -11,7 +27,7 @@ fun BackIconButton(onBackClick: () -> Unit) { IconButton(onClick = onBackClick) { Icon( imageVector = Icons.AutoMirrored.Rounded.ArrowBack, - contentDescription = "Back" + contentDescription = "Back", ) } } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/ContentWrapper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/ContentWrapper.kt index 8b1984e7f..28cc10289 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/ContentWrapper.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/ContentWrapper.kt @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.compose.design import androidx.compose.foundation.Image @@ -31,7 +47,6 @@ import co.anitrend.core.android.R import co.anitrend.core.android.compose.AniTrendTheme import co.anitrend.navigation.model.common.IParam import coil.compose.rememberAsyncImagePainter -import coil.compose.rememberImagePainter import kotlinx.coroutines.launch import org.koin.compose.koinInject @@ -47,8 +62,9 @@ private fun LoadingContent( Image( painter = rememberAsyncImagePainter(config.loadingDrawable), contentDescription = "", - modifier = Modifier.size(64.dp) - .align(alignment = Alignment.CenterHorizontally), + modifier = + Modifier.size(64.dp) + .align(alignment = Alignment.CenterHorizontally), ) Spacer(modifier = Modifier.height(8.dp)) Row( @@ -86,24 +102,27 @@ private fun ErrorContent( Image( painter = rememberAsyncImagePainter(config.errorDrawable), contentDescription = "", - modifier = Modifier.size(64.dp) - .align(alignment = Alignment.CenterHorizontally) + modifier = + Modifier.size(64.dp) + .align(alignment = Alignment.CenterHorizontally), ) Spacer(modifier = Modifier.height(8.dp)) state.details.message?.also { Text( text = it, style = AniTrendTheme.typography.body2, - modifier = Modifier - .align(alignment = Alignment.CenterHorizontally) + modifier = + Modifier + .align(alignment = Alignment.CenterHorizontally), ) } Spacer(modifier = Modifier.height(8.dp)) config.retryAction?.also { FilledTonalButton( onClick = { scope.launch { onClick() } }, - modifier = Modifier - .align(alignment = Alignment.CenterHorizontally), + modifier = + Modifier + .align(alignment = Alignment.CenterHorizontally), ) { Text( text = stringResource(it), @@ -115,7 +134,7 @@ private fun ErrorContent( } @Composable -fun ContentWrapper( +fun

ContentWrapper( stateFlow: LiveData, config: IStateLayoutConfig = koinInject(), param: P? = null, @@ -129,14 +148,15 @@ fun ContentWrapper( if (param == null) { ErrorContent( config = config, - state = LoadState.Error( - RequestError( - topic = stringResource(R.string.app_controller_heading_missing_param), - description = stringResource(R.string.app_controller_message_missing_param), - ) - ), + state = + LoadState.Error( + RequestError( + topic = stringResource(R.string.app_controller_heading_missing_param), + description = stringResource(R.string.app_controller_message_missing_param), + ), + ), modifier = modifier, - onClick = onClick + onClick = onClick, ) return } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/AniTrendImage.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/AniTrendImage.kt index ee404ba11..2e0deec21 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/AniTrendImage.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/AniTrendImage.kt @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.compose.design.image import androidx.compose.foundation.clickable @@ -8,7 +24,6 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import co.anitrend.core.android.helpers.image.model.RequestImage -import co.anitrend.core.android.helpers.image.model.RequestImage.Media.ImageType.* import co.anitrend.core.android.helpers.image.toRequestBuilder import co.anitrend.domain.common.entity.contract.ICoverImage import co.anitrend.domain.common.entity.contract.IMediaCover @@ -43,27 +58,33 @@ fun AniTrendImage( onClick: (ImageViewerRouter.ImageSourceParam) -> Unit, ) { val context = LocalContext.current - val requestImageBuilder = rememberRequestImage( - image = image, - type = imageType - ) { toRequestBuilder(context, transformations) } + val requestImageBuilder = + rememberRequestImage( + image = image, + type = imageType, + ) { toRequestBuilder(context, transformations) } AsyncImage( model = requestImageBuilder.build(), contentDescription = "$imageType image", contentScale = contentScale, - modifier = modifier.clickable { - val source = when (image) { - is IMediaCover -> { - if (imageType == BANNER) image.banner - else image.extraLarge ?: image.large ?: image.medium - } - else -> image.large ?: image.medium - } ?: return@clickable + modifier = + modifier.clickable { + val source = + when (image) { + is IMediaCover -> { + if (imageType == RequestImage.Media.ImageType.BANNER) { + image.banner + } else { + image.extraLarge ?: image.large ?: image.medium + } + } + else -> image.large ?: image.medium + } ?: return@clickable - onClick( - ImageViewerRouter.ImageSourceParam(source) - ) - }, + onClick( + ImageViewerRouter.ImageSourceParam(source), + ) + }, ) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/CoverImageUtils.kt b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/CoverImageUtils.kt index 602c475bb..ce5cb1208 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/CoverImageUtils.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/compose/design/image/CoverImageUtils.kt @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.compose.design.image import androidx.compose.runtime.Composable @@ -13,10 +29,11 @@ import coil.request.ImageRequest fun rememberRequestImage( image: ICoverImage, type: RequestImage.Media.ImageType, - builder: RequestImage.() -> ImageRequest.Builder -): ImageRequest.Builder = remember(image) { - when (image) { - is IMediaCover -> image.toMediaRequestImage(type) - else -> image.toRequestImage() - }.run(builder) -} + builder: RequestImage.() -> ImageRequest.Builder, +): ImageRequest.Builder = + remember(image) { + when (image) { + is IMediaCover -> image.toMediaRequestImage(type) + else -> image.toRequestImage() + }.run(builder) + } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/AndroidPowerController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/AndroidPowerController.kt index a38ff8aa6..afed55961 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/AndroidPowerController.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/AndroidPowerController.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.controller.power import android.content.Context @@ -45,17 +44,16 @@ internal class AndroidPowerController( private val connectivityManager: ConnectivityManager?, private val settings: IPowerSettings, ) : IPowerController { - override fun powerSaverStateFlow(ignorePreference: Boolean): Flow { return when { Build.VERSION.SDK_INT >= Build.VERSION_CODES.N -> { merge( context.flowOfBroadcast( - IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED) + IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED), ), context.flowOfBroadcast( - IntentFilter(ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGED) - ) + IntentFilter(ConnectivityManager.ACTION_RESTRICT_BACKGROUND_CHANGED), + ), ).map { powerSaverState() }.onStart { @@ -64,7 +62,7 @@ internal class AndroidPowerController( } else -> { context.flowOfBroadcast( - IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED) + IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED), ).map { powerSaverState() }.onStart { @@ -74,18 +72,19 @@ internal class AndroidPowerController( } } - override fun powerSaverState(): PowerSaverState = when { - settings.isPowerSaverOn.value -> { - PowerSaverState.Enabled(PowerSaverState.Reason.PREFERENCE) - } - powerManager?.isPowerSaveMode == true -> { - PowerSaverState.Enabled(PowerSaverState.Reason.SYSTEM_POWER_SAVER) - } - Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isBackgroundDataRestricted() -> { - PowerSaverState.Enabled(PowerSaverState.Reason.SYSTEM_DATA_SAVER) + override fun powerSaverState(): PowerSaverState = + when { + settings.isPowerSaverOn.value -> { + PowerSaverState.Enabled(PowerSaverState.Reason.PREFERENCE) + } + powerManager?.isPowerSaveMode == true -> { + PowerSaverState.Enabled(PowerSaverState.Reason.SYSTEM_POWER_SAVER) + } + Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isBackgroundDataRestricted() -> { + PowerSaverState.Enabled(PowerSaverState.Reason.SYSTEM_DATA_SAVER) + } + else -> PowerSaverState.Disabled } - else -> PowerSaverState.Disabled - } override fun disableBatteryOptimization() { val packageUri = "package:${context.packageName}" @@ -95,7 +94,7 @@ internal class AndroidPowerController( intentOf { action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS data = packageUri.toUri() - } + }, ) }.onFailure(Timber::e) } @@ -104,6 +103,6 @@ internal class AndroidPowerController( @RequiresApi(Build.VERSION_CODES.N) private fun isBackgroundDataRestricted(): Boolean { return connectivityManager?.restrictBackgroundStatus == - ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED + ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED } } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/contract/IPowerController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/contract/IPowerController.kt index 66d2fb80f..934b80ac2 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/contract/IPowerController.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/controller/power/contract/IPowerController.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.controller.power.contract import kotlinx.coroutines.flow.Flow @@ -25,9 +24,7 @@ import kotlinx.coroutines.flow.Flow * @see [co.anitrend.data.settings.power.IPowerSettings] */ interface IPowerController { - fun powerSaverStateFlow( - ignorePreference: Boolean - ): Flow + fun powerSaverStateFlow(ignorePreference: Boolean): Flow fun powerSaverState(): PowerSaverState @@ -36,8 +33,9 @@ interface IPowerController { sealed class PowerSaverState { data object Disabled : PowerSaverState() + data class Enabled( - val reason: Reason + val reason: Reason, ) : PowerSaverState() enum class Reason { diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/WidgetController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/WidgetController.kt index 3e035acc6..9ff2d56aa 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/WidgetController.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/WidgetController.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.controller.widget import co.anitrend.arch.extension.lifecycle.SupportLifecycle @@ -25,7 +24,6 @@ import co.anitrend.core.android.controller.widget.contract.IWidgetController * is to delegate view logic outside of the UI driver (e.g. Activity, Fragment, View) */ abstract class WidgetController : IWidgetController, SupportLifecycle { - /** * This is called when the view is attached to a window. At this point it * has a Surface and will start drawing. @@ -45,4 +43,4 @@ abstract class WidgetController : IWidgetController, SupportLifecycle { override fun onDetached() { // Optional use-case } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/contract/IWidgetController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/contract/IWidgetController.kt index 555d4a107..26e3ca58a 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/contract/IWidgetController.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/controller/widget/contract/IWidgetController.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,14 +14,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.controller.widget.contract /** * Widget controller contract */ interface IWidgetController { - /** * This is called when the view is attached to a window. At this point it * has a Surface and will start drawing. @@ -37,4 +35,4 @@ interface IWidgetController { * @see android.view.View.onAttachedToWindow */ fun onDetached() -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CascadeMenuExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CascadeMenuExtensions.kt index ba9568e9a..d8c5522ab 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CascadeMenuExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CascadeMenuExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.extensions import android.content.Context @@ -38,12 +37,12 @@ fun Context.cascadePopupStyler(): CascadePopupMenu.Styler { val rippleDrawable = { RippleDrawable( ColorStateList.valueOf( - getColorFromAttr(androidx.appcompat.R.attr.colorPrimaryDark) + getColorFromAttr(androidx.appcompat.R.attr.colorPrimaryDark), ), null, ColorDrawable( - getColorFromAttr(com.google.android.material.R.attr.colorOnBackground) - ) + getColorFromAttr(com.google.android.material.R.attr.colorOnBackground), + ), ) } @@ -51,26 +50,28 @@ fun Context.cascadePopupStyler(): CascadePopupMenu.Styler { background = { RoundedDrawable( color = getColorFromAttr(com.google.android.material.R.attr.colorPrimaryVariant), - radius = 8f.dp + radius = 8f.dp, ) }, menuTitle = { header -> - header.titleView.typeface = ResourcesCompat.getFont( - this, - co.anitrend.arch.theme.R.font.product_sans_regular - ) + header.titleView.typeface = + ResourcesCompat.getFont( + this, + co.anitrend.arch.theme.R.font.product_sans_regular, + ) header.setBackground(rippleDrawable()) }, menuItem = { item -> - item.titleView.typeface = ResourcesCompat.getFont( - this, - co.anitrend.arch.theme.R.font.product_sans_regular - ) + item.titleView.typeface = + ResourcesCompat.getFont( + this, + co.anitrend.arch.theme.R.font.product_sans_regular, + ) item.setBackground(rippleDrawable()) item.setGroupDividerColor( - getColorFromAttr(com.google.android.material.R.attr.colorOnSurface) + getColorFromAttr(com.google.android.material.R.attr.colorOnSurface), ) - } + }, ) } @@ -84,7 +85,7 @@ fun View.cascadeMenu(): CascadePopupMenu { context = context, anchor = this, gravity = Gravity.NO_GRAVITY, - styler = context.cascadePopupStyler() + styler = context.cascadePopupStyler(), ) } @@ -96,11 +97,11 @@ fun View.cascadeMenu(): CascadePopupMenu { */ fun CascadePopupMenu.onMenu( shouldNavigateBack: Boolean = true, - action: Menu.() -> Unit + action: Menu.() -> Unit, ): CascadePopupMenu { MenuCompat.setGroupDividerEnabled(menu, true) menu.action() - if (shouldNavigateBack) + if (shouldNavigateBack) { menu.allChildren.filter { menuItem -> menuItem.intent == null }.forEach { menuItem -> @@ -108,5 +109,6 @@ fun CascadePopupMenu.onMenu( navigateBack() } } + } return this } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ChipExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ChipExtensions.kt index e1990d9d7..fc831c495 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ChipExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ChipExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.extensions import android.content.Context @@ -27,7 +26,7 @@ import com.google.android.material.chip.Chip fun Chip.asChoice() { style(co.anitrend.core.android.R.style.AppTheme_Material_Chip_Choice) setChipBackgroundColorResource( - co.anitrend.core.android.R.color.selector_chip_background + co.anitrend.core.android.R.color.selector_chip_background, ) isCheckedIconVisible = false isCheckable = true @@ -40,9 +39,7 @@ fun Chip.asChoice() { * * @see asChoice */ -inline fun Chip.asChoice( - action: Chip.() -> Unit -): Chip { +inline fun Chip.asChoice(action: Chip.() -> Unit): Chip { asChoice() action(this) return this @@ -53,6 +50,4 @@ inline fun Chip.asChoice( * * @param action Delegate to access the chip */ -inline fun Context.createChipChoice( - action: Chip.() -> Unit -): Chip = Chip(this).asChoice(action) +inline fun Context.createChipChoice(action: Chip.() -> Unit): Chip = Chip(this).asChoice(action) diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ContextExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ContextExtensions.kt index 7280e2be1..c22f8e332 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ContextExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ContextExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.extensions import android.content.Context @@ -32,11 +31,12 @@ import timber.log.Timber * @throws NotImplementedError when a context type cannot be handled */ @Throws(NotImplementedError::class) -fun Context.fragmentManager() = when (this) { - is FragmentActivity -> supportFragmentManager - is ContextWrapper -> (baseContext as FragmentActivity).supportFragmentManager - else -> throw NotImplementedError("This type of context: $this is not handled/supported") -} +fun Context.fragmentManager() = + when (this) { + is FragmentActivity -> supportFragmentManager + is ContextWrapper -> (baseContext as FragmentActivity).supportFragmentManager + else -> throw NotImplementedError("This type of context: $this is not handled/supported") + } @Throws(IllegalArgumentException::class) fun Context.requireLifecycleOwner(): LifecycleOwner { @@ -57,4 +57,4 @@ fun Context.lifecycleOwner(): LifecycleOwner? { fun Context.lifecycleScope(): LifecycleCoroutineScope? { val lifecycleOwner = lifecycleOwner() return lifecycleOwner?.lifecycleScope -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CoreExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CoreExtensions.kt index 1785d2873..d878fb022 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CoreExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/CoreExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.extensions import android.content.res.Resources @@ -28,8 +27,11 @@ fun Int.toHumanReadableQuantity(digits: Int = 1): String { if (quantity < unit) return "$quantity" val exp = (ln(quantity.toDouble()) / ln(unit.toDouble())).toInt() val suffix = "KMGTPE"[exp - 1].toString() - return String.format(Locale.getDefault(), "%.${digits}f %s", - quantity / unit.toDouble().pow(exp.toDouble()), suffix + return String.format( + Locale.getDefault(), + "%.${digits}f %s", + quantity / unit.toDouble().pow(exp.toDouble()), + suffix, ) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/InsetsExentions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/InsetsExentions.kt index 40d562988..b11ca5ded 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/InsetsExentions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/InsetsExentions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.extensions import android.view.ViewGroup @@ -31,8 +30,8 @@ fun ViewGroup.applySystemBarsWindowInsetsListener() { val systemBars = WindowInsetsCompat.Type.systemBars() view.setTag( R.id.tag_system_window_inset_top, - windowInsetsCompat.getInsets(systemBars) + windowInsetsCompat.getInsets(systemBars), ) windowInsets } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/IntentExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/IntentExtensions.kt index 50155f4cc..35efeb56b 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/IntentExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/IntentExtensions.kt @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.extensions import android.content.Intent diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/LiveDataExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/LiveDataExtensions.kt index 33fe329bc..4b7cda889 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/LiveDataExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/LiveDataExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 AniTrend + * Copyright (C) 2022 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.extensions import androidx.lifecycle.LifecycleOwner @@ -30,11 +29,17 @@ import androidx.lifecycle.Observer * @param owner The [LifecycleOwner] which controls the observer * @param observer The observer that will receive the events */ -fun LiveData.observeOnce(owner: LifecycleOwner, observer: (T) -> Unit) { - observe(owner, object: Observer { - override fun onChanged(value: T) { - removeObserver(this) - observer(value) - } - }) -} \ No newline at end of file +fun LiveData.observeOnce( + owner: LifecycleOwner, + observer: (T) -> Unit, +) { + observe( + owner, + object : Observer { + override fun onChanged(value: T) { + removeObserver(this) + observer(value) + } + }, + ) +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/TimberExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/TimberExtensions.kt index 0896405c7..ce4a1a0d1 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/TimberExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/TimberExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 AniTrend + * Copyright (C) 2022 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.extensions import co.anitrend.arch.analytics.contract.ISupportAnalytics @@ -30,7 +29,9 @@ object Tags { private const val STATE_PREFIX = "state_" fun action(postfix: String) = ACTION_PREFIX.plus(postfix) + fun view(postfix: String) = VIEW_PREFIX.plus(postfix) + fun state(postfix: String) = STATE_PREFIX.plus(postfix) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ViewExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ViewExtensions.kt index d3f0ab9f2..1d44cc6b8 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ViewExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/extensions/ViewExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.extensions import android.content.Intent @@ -29,11 +28,12 @@ import androidx.viewpager2.widget.ViewPager2 import timber.log.Timber fun View.startViewIntent(url: String) { - val intent = Intent().apply { - flags = Intent.FLAG_ACTIVITY_NEW_TASK - action = Intent.ACTION_VIEW - data = url.toUri() - } + val intent = + Intent().apply { + flags = Intent.FLAG_ACTIVITY_NEW_TASK + action = Intent.ACTION_VIEW + data = url.toUri() + } runCatching { context.startActivity(intent) }.onFailure { Timber.w(it) } @@ -53,7 +53,9 @@ fun View.setTooltip(tooltipText: String) { * * @param tooltipText the tooltip text */ -fun View.setTooltip(@StringRes tooltipText: Int) { +fun View.setTooltip( + @StringRes tooltipText: Int, +) { setTooltip(context.getString(tooltipText)) } @@ -75,4 +77,4 @@ fun ViewPager2.enableBottomSheetScrolling() { */ fun View.fragmentManager(): FragmentManager { return context.fragmentManager() -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt index c9d0b4066..705eb6051 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/color/ColorExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.helpers.color import android.content.Context @@ -27,10 +26,10 @@ import co.anitrend.domain.common.HexColor /** Checks if a color has enough contrast */ fun Int.hasEnoughContrastFor( - @ColorInt backgroundColor: Int + @ColorInt backgroundColor: Int, ) = ColorUtils.calculateContrast( this, - backgroundColor + backgroundColor, ) > 1.8f /** Decreases the lightness of the color by the [factor] */ @@ -47,11 +46,15 @@ fun Int.increaseContrastBy(factor: Float): Int { * @param backgroundColor Current background color to allow auto adjusting contrast */ @ColorInt -fun HexColor.asColorInt(@ColorInt backgroundColor: Int): Int { +fun HexColor.asColorInt( + @ColorInt backgroundColor: Int, +): Int { val foregroundColor = Color.parseColor(toString()) - return if (foregroundColor.hasEnoughContrastFor(backgroundColor)) + return if (foregroundColor.hasEnoughContrastFor(backgroundColor)) { foregroundColor - else foregroundColor.increaseContrastBy(0.5f) + } else { + foregroundColor.increaseContrastBy(0.5f) + } } /** @@ -70,5 +73,4 @@ fun HexColor.asColorInt(context: Context): Int { * * @param context Used to retrieve current theme background color for contrast fixes */ -fun HexColor.asDrawable(context: Context) = - ColorDrawable(asColorInt(context)) +fun HexColor.asDrawable(context: Context) = ColorDrawable(asColorInt(context)) diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/date/AniTrendDateHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/date/AniTrendDateHelper.kt index d093e4a92..9ef2f0bc0 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/date/AniTrendDateHelper.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/date/AniTrendDateHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.helpers.date import androidx.annotation.IntRange @@ -31,14 +30,14 @@ import java.util.Date import java.util.Locale class AniTrendDateHelper : AbstractSupportDateHelper() { - /** * Returns the current month in the form of an [Int]. * * @return [IntRange] between 0 - 11 */ val month: Int - @IntRange(from = 0, to = 11) get() = + @IntRange(from = 0, to = 11) + get() = Calendar.getInstance().get(Calendar.MONTH) /** @@ -47,7 +46,8 @@ class AniTrendDateHelper : AbstractSupportDateHelper() { * @return [IntRange] between 1 - 31 */ val day: Int - @IntRange(from = 0, to = 30) get() = + @IntRange(from = 0, to = 30) + get() = Calendar.getInstance().get(Calendar.DATE) /** @@ -59,11 +59,12 @@ class AniTrendDateHelper : AbstractSupportDateHelper() { /** * @return [FuzzyDate] */ - fun fuzzyDateNow() = FuzzyDate( - day = day, - month = month.plus(1), - year = year - ) + fun fuzzyDateNow() = + FuzzyDate( + day = day, + month = month.plus(1), + year = year, + ) /** * @return current seasons name @@ -85,46 +86,61 @@ class AniTrendDateHelper : AbstractSupportDateHelper() { * @return current year with a given delta */ override fun getCurrentYear(delta: Int): Int { - return if (month >= 11 && currentSeason == SeasonType.WINTER) + return if (month >= 11 && currentSeason == SeasonType.WINTER) { year + delta - else year + } else { + year + } } fun convertToTextDate(fuzzyDate: FuzzyDate?): CharSequence? { if (fuzzyDate == null || fuzzyDate.isDateNotSet()) return null - val month = if (fuzzyDate.month <= 9) - "0${fuzzyDate.month}" - else "${fuzzyDate.month}" + val month = + if (fuzzyDate.month <= 9) { + "0${fuzzyDate.month}" + } else { + "${fuzzyDate.month}" + } - val day = if (fuzzyDate.day <= 9) - "0${fuzzyDate.day}" - else "${fuzzyDate.day}" + val day = + if (fuzzyDate.day <= 9) { + "0${fuzzyDate.day}" + } else { + "${fuzzyDate.day}" + } - val dateFormatted = "${fuzzyDate.year}-${month}-${day}" - val dateFormatter = DateTimeFormatter.ofPattern( - "yyyy-MM-dd", Locale.getDefault() - ) + val dateFormatted = "${fuzzyDate.year}-$month-$day" + val dateFormatter = + DateTimeFormatter.ofPattern( + "yyyy-MM-dd", + Locale.getDefault(), + ) val parsedDate = dateFormatter.parse(dateFormatted) val localDate = from(parsedDate) - val outputDateFormat = DateTimeFormatter.ofPattern( - "MMM dd, yyyy", Locale.getDefault() - ) + val outputDateFormat = + DateTimeFormatter.ofPattern( + "MMM dd, yyyy", + Locale.getDefault(), + ) return localDate.format(outputDateFormat) } fun convertToUnixTimeStamp(fuzzyDate: FuzzyDate): Long { val fuzzyTextDate = convertToTextDate(fuzzyDate) - val dateFormatter = DateTimeFormatter.ofPattern( - "MMM dd, yyyy", Locale.getDefault() - ) + val dateFormatter = + DateTimeFormatter.ofPattern( + "MMM dd, yyyy", + Locale.getDefault(), + ) val parsedDate = dateFormatter.parse(fuzzyTextDate) - val instant = from(parsedDate).atTime(LocalTime.MIDNIGHT) - .toInstant(ZoneOffset.UTC) + val instant = + from(parsedDate).atTime(LocalTime.MIDNIGHT) + .toInstant(ZoneOffset.UTC) return instant.toEpochMilli() } @@ -136,7 +152,7 @@ class AniTrendDateHelper : AbstractSupportDateHelper() { return FuzzyDate( year = segments[0].toInt(), month = segments[1].toInt(), - day = segments[2].toInt() + day = segments[2].toInt(), ) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/ImageExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/ImageExtensions.kt index f86e8106a..559cfea83 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/ImageExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/ImageExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.helpers.image import android.content.Context @@ -34,7 +33,6 @@ import coil.request.ImageRequest import coil.target.Target import coil.transform.RoundedCornersTransformation import coil.transform.Transformation -import coil.transition.CrossfadeTransition val roundedCornersTransformation = RoundedCornersTransformation(8f.dp) @@ -67,9 +65,7 @@ fun ICoverImage.toRequestImage() = RequestImage.Cover(this) * @see using for usage from multiple receiver types * @see toRequestBuilder to build a coil image request builder */ -fun IMediaCover.toMediaRequestImage( - type: RequestImage.Media.ImageType -) = RequestImage.Media(this, type) +fun IMediaCover.toMediaRequestImage(type: RequestImage.Media.ImageType) = RequestImage.Media(this, type) /** * A request image builder for coil @@ -79,12 +75,13 @@ fun IMediaCover.toMediaRequestImage( */ fun RequestImage<*>.toRequestBuilder( context: Context, - transformations: List = emptyList() + transformations: List = emptyList(), ): ImageRequest.Builder { val requestBuilder = ImageRequest.Builder(context) - if (transformations.isNotEmpty()) + if (transformations.isNotEmpty()) { requestBuilder.transformations(transformations) + } if (this is RequestImage.Media) { val color = image?.color @@ -99,8 +96,8 @@ fun RequestImage<*>.toRequestBuilder( return requestBuilder .crossfade( context.resources.getInteger( - R.integer.motion_duration_long - ) + R.integer.motion_duration_long, + ), ).data(this) } @@ -115,12 +112,13 @@ fun RequestImage<*>.toRequestBuilder( */ fun AppCompatImageView.using( requestImage: RequestImage<*>, - transformations: List = emptyList() + transformations: List = emptyList(), ): Disposable { val requestBuilder = ImageRequest.Builder(context) - if (transformations.isNotEmpty()) + if (transformations.isNotEmpty()) { requestBuilder.transformations(transformations) + } if (requestImage is RequestImage.Media) { val color = requestImage.image?.color @@ -132,15 +130,16 @@ fun AppCompatImageView.using( } } - val request = requestBuilder - .crossfade( - context.resources.getInteger( - R.integer.motion_duration_long + val request = + requestBuilder + .crossfade( + context.resources.getInteger( + R.integer.motion_duration_long, + ), ) - ) - .data(requestImage) - .target(this) - .build() + .data(requestImage) + .target(this) + .build() return Coil.imageLoader(context).enqueue(request) } @@ -156,22 +155,24 @@ fun AppCompatImageView.using( */ fun AppCompatImageView.using( resource: Drawable?, - transformations: List = emptyList() + transformations: List = emptyList(), ): Disposable { val requestBuilder = ImageRequest.Builder(context) - if (transformations.isNotEmpty()) + if (transformations.isNotEmpty()) { requestBuilder.transformations(transformations) + } - val request = requestBuilder - .crossfade( - context.resources.getInteger( - R.integer.motion_duration_long + val request = + requestBuilder + .crossfade( + context.resources.getInteger( + R.integer.motion_duration_long, + ), ) - ) - .data(resource) - .target(this) - .build() + .data(resource) + .target(this) + .build() return Coil.imageLoader(context).enqueue(request) } @@ -187,7 +188,7 @@ fun AppCompatImageView.using( */ fun AppCompatImageView.using( @DrawableRes resource: Int, - transformations: List = emptyList() + transformations: List = emptyList(), ): Disposable { val drawable = context.getCompatDrawable(resource) return using(resource = drawable, transformations) @@ -202,24 +203,26 @@ fun AppCompatImageView.using( * * @return A [Disposable] contract */ -fun AppCompatImageView.using( +fun AppCompatImageView.using( resource: T?, - transformations: List = emptyList() + transformations: List = emptyList(), ): Disposable { val requestBuilder = ImageRequest.Builder(context) - if (transformations.isNotEmpty()) + if (transformations.isNotEmpty()) { requestBuilder.transformations(transformations) + } - val request = requestBuilder - .crossfade( - context.resources.getInteger( - R.integer.motion_duration_long + val request = + requestBuilder + .crossfade( + context.resources.getInteger( + R.integer.motion_duration_long, + ), ) - ) - .data(resource?.toRequestImage()) - .target(this) - .build() + .data(resource?.toRequestImage()) + .target(this) + .build() return Coil.imageLoader(context).enqueue(request) } @@ -233,25 +236,27 @@ fun AppCompatImageView.using( * * @return A [Disposable] contract */ -fun Target.using( +fun Target.using( resource: T?, context: Context, - transformations: List = emptyList() + transformations: List = emptyList(), ): Disposable { val requestBuilder = ImageRequest.Builder(context) - if (transformations.isNotEmpty()) + if (transformations.isNotEmpty()) { requestBuilder.transformations(transformations) + } - val request = requestBuilder - .crossfade( - context.resources.getInteger( - R.integer.motion_duration_long + val request = + requestBuilder + .crossfade( + context.resources.getInteger( + R.integer.motion_duration_long, + ), ) - ) - .data(resource?.toRequestImage()) - .target(this) - .build() + .data(resource?.toRequestImage()) + .target(this) + .build() return Coil.imageLoader(context).enqueue(request) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/model/RequestImage.kt b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/model/RequestImage.kt index 388b5f90a..acda4ee95 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/model/RequestImage.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/helpers/image/model/RequestImage.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.helpers.image.model import co.anitrend.domain.common.entity.contract.ICoverImage @@ -24,17 +23,17 @@ import co.anitrend.domain.common.entity.contract.IMediaCover * Request image model that our custom image loader will use */ sealed class RequestImage(val image: T?) { - class Media( mediaImage: IMediaCover?, - val type: ImageType + val type: ImageType, ) : RequestImage(mediaImage) { enum class ImageType { - BANNER, POSTER + BANNER, + POSTER, } } class Cover( - coverImage: ICoverImage? + coverImage: ICoverImage?, ) : RequestImage(coverImage) -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/koin/Modules.kt b/android-core/src/main/kotlin/co/anitrend/core/android/koin/Modules.kt index 810da4cd3..1fb26185a 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/koin/Modules.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/koin/Modules.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.koin import android.content.pm.ShortcutManager @@ -44,79 +43,83 @@ import org.koin.dsl.binds import org.koin.dsl.module import org.ocpsoft.prettytime.PrettyTime -private val coreModule = module { - factory { - Settings( - context = androidContext() - ) - } binds (Settings.BINDINGS) +private val coreModule = + module { + factory { + Settings( + context = androidContext(), + ) + } binds (Settings.BINDINGS) - single { - SupportDispatcher() - } + single { + SupportDispatcher() + } - single { - StorageController() - } + single { + StorageController() + } - factory { - AniTrendDateHelper() - } bind AbstractSupportDateHelper::class + factory { + AniTrendDateHelper() + } bind AbstractSupportDateHelper::class - single { - /** TODO: On language preference change, destroy and recreate [PrettyTime] */ - val localeHelper = get() - PrettyTime(localeHelper.locale) + single { + /** TODO: On language preference change, destroy and recreate [PrettyTime] */ + val localeHelper = get() + PrettyTime(localeHelper.locale) + } } -} -private val configurationModule = module { - single { - LocaleHelper( - settings = get() - ) - } +private val configurationModule = + module { + single { + LocaleHelper( + settings = get(), + ) + } - single { - ThemeHelper( - settings = get() - ) - } + single { + ThemeHelper( + settings = get(), + ) + } - factory { - ConfigurationHelper( - settings = get(), - localeHelper = get(), - themeHelper = get() - ) + factory { + ConfigurationHelper( + settings = get(), + localeHelper = get(), + themeHelper = get(), + ) + } } -} -private val controllerModule = module { - factory { - val context = androidContext() - AndroidPowerController( - context = context, - powerManager = context.systemServiceOf(), - connectivityManager = context.systemServiceOf(), - settings = get() - ) - } +private val controllerModule = + module { + factory { + val context = androidContext() + AndroidPowerController( + context = context, + powerManager = context.systemServiceOf(), + connectivityManager = context.systemServiceOf(), + settings = get(), + ) + } - factory { - val context = androidContext() - ShortcutController( - context = context, - shortcutManager = context.systemServiceOf() - ) + factory { + val context = androidContext() + ShortcutController( + context = context, + shortcutManager = context.systemServiceOf(), + ) + } } -} -val androidCoreModules = module { - includes(coreModule, configurationModule, controllerModule) -} +val androidCoreModules = + module { + includes(coreModule, configurationModule, controllerModule) + } enum class MarkdownFlavour { STANDARD, - ANILIST + ANILIST, } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/provider/StyleActionProvider.kt b/android-core/src/main/kotlin/co/anitrend/core/android/provider/StyleActionProvider.kt index 5d1cf3519..ae1eae4f7 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/provider/StyleActionProvider.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/provider/StyleActionProvider.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.provider import android.content.Context @@ -35,7 +34,6 @@ import org.koin.core.component.inject import timber.log.Timber class StyleActionProvider(context: Context) : AbstractActionProvider(context), KoinComponent { - private val settings by inject() private val viewModes = PreferredViewMode.values() @@ -43,21 +41,23 @@ class StyleActionProvider(context: Context) : AbstractActionProvider(context), K private fun onActionClicked(view: View) { val current = settings.preferredViewMode.value val currentIndex = viewModes.indexOf(current) - settings.preferredViewMode.value = when (currentIndex) { - PreferredViewMode.DETAILED.ordinal -> PreferredViewMode.SUMMARY - PreferredViewMode.SUMMARY.ordinal -> PreferredViewMode.COMPACT - PreferredViewMode.COMPACT.ordinal -> PreferredViewMode.COMFORTABLE - else -> PreferredViewMode.DETAILED - } + settings.preferredViewMode.value = + when (currentIndex) { + PreferredViewMode.DETAILED.ordinal -> PreferredViewMode.SUMMARY + PreferredViewMode.SUMMARY.ordinal -> PreferredViewMode.COMPACT + PreferredViewMode.COMPACT.ordinal -> PreferredViewMode.COMFORTABLE + else -> PreferredViewMode.DETAILED + } } private fun iconForSetting(preferredViewMode: PreferredViewMode) { - val resource = when (preferredViewMode) { - PreferredViewMode.DETAILED -> R.drawable.ic_view_detailed - PreferredViewMode.SUMMARY -> R.drawable.ic_view_summary - PreferredViewMode.COMPACT -> R.drawable.ic_view_compact - else -> R.drawable.ic_view_comfortable - } + val resource = + when (preferredViewMode) { + PreferredViewMode.DETAILED -> R.drawable.ic_view_detailed + PreferredViewMode.SUMMARY -> R.drawable.ic_view_summary + PreferredViewMode.COMPACT -> R.drawable.ic_view_compact + else -> R.drawable.ic_view_comfortable + } val drawable = context.getCompatDrawable(resource) actionImageView.setImageDrawable(drawable) } @@ -68,8 +68,9 @@ class StyleActionProvider(context: Context) : AbstractActionProvider(context), K * @param forItem Optional menu item to create view for */ override fun createWidget(forItem: MenuItem?): View { - if (!actionImageView.hasOnClickListeners()) + if (!actionImageView.hasOnClickListeners()) { actionImageView.setOnClickListener(::onActionClicked) + } context.lifecycleScope()?.launch { context.lifecycleOwner()?.repeatOnLifecycle(Lifecycle.State.RESUMED) { diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/provider/contract/AbstractActionProvider.kt b/android-core/src/main/kotlin/co/anitrend/core/android/provider/contract/AbstractActionProvider.kt index d98156e96..c006ac072 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/provider/contract/AbstractActionProvider.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/provider/contract/AbstractActionProvider.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.provider.contract import android.content.Context @@ -29,23 +28,26 @@ import co.anitrend.arch.extension.ext.getDrawableAttr import co.anitrend.core.android.extensions.dp abstract class AbstractActionProvider(context: Context) : ActionProvider(context) { + protected val actionImageView = + AppCompatImageView(context).apply { + background = + context.getDrawableAttr( + androidx.appcompat.R.attr.selectableItemBackgroundBorderless, + ) + isClickable = true + isFocusable = true + setPadding(2.dp) + } - protected val actionImageView = AppCompatImageView(context).apply { - background = context.getDrawableAttr( - androidx.appcompat.R.attr.selectableItemBackgroundBorderless - ) - isClickable = true - isFocusable = true - setPadding(2.dp) - } - - protected val container = FrameLayout(context).apply { - layoutParams = FrameLayout.LayoutParams( - ViewGroup.MarginLayoutParams.WRAP_CONTENT, - ViewGroup.MarginLayoutParams.WRAP_CONTENT - ) - setPadding(10.dp) - } + protected val container = + FrameLayout(context).apply { + layoutParams = + FrameLayout.LayoutParams( + ViewGroup.MarginLayoutParams.WRAP_CONTENT, + ViewGroup.MarginLayoutParams.WRAP_CONTENT, + ) + setPadding(10.dp) + } /** * Factory for creating the [androidx.core.view.ActionProvider] view diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/CarouselRecycler.kt b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/CarouselRecycler.kt index b95f51c13..2f8483ad9 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/CarouselRecycler.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/CarouselRecycler.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.recycler import android.content.Context @@ -26,47 +25,61 @@ import co.anitrend.arch.recycler.SupportRecyclerView import co.anitrend.arch.ui.view.contract.CustomView import co.anitrend.core.android.recycler.decorator.DefaultSpacingDecorator -class CarouselRecycler @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyle: Int = 0 -) : SupportRecyclerView(context, attrs, defStyle), CustomView { - - private val defaultItemAnimator by lazy(UNSAFE) { - val animator = object : DefaultItemAnimator() { - override fun getSupportsChangeAnimations() = false +class CarouselRecycler + @JvmOverloads + constructor( + context: Context, + attrs: AttributeSet? = null, + defStyle: Int = 0, + ) : SupportRecyclerView(context, attrs, defStyle), CustomView { + private val defaultItemAnimator by lazy(UNSAFE) { + val animator = + object : DefaultItemAnimator() { + override fun getSupportsChangeAnimations() = false + } + animator.supportsChangeAnimations = false + animator } - animator.supportsChangeAnimations = false - animator - } - private val defaultDecorator by lazy(UNSAFE) { - DefaultSpacingDecorator() - } + private val defaultDecorator by lazy(UNSAFE) { + DefaultSpacingDecorator() + } - init { onInit(context, attrs, defStyle) } + init { + onInit(context, attrs, defStyle) + } - /** - * Applies start and end padding to items - */ - private fun useCarouselDecorator() { - if (itemDecorationCount == 0) - addItemDecoration(defaultDecorator) - } + /** + * Applies start and end padding to items + */ + private fun useCarouselDecorator() { + if (itemDecorationCount == 0) { + addItemDecoration(defaultDecorator) + } + } - private fun disableItemAnimator() { - itemAnimator = defaultItemAnimator - } + private fun disableItemAnimator() { + itemAnimator = defaultItemAnimator + } - override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) { - layoutManager = LinearLayoutManager( - context, HORIZONTAL, false - ).apply { - // allow prefetching to speed up recycler performance - isItemPrefetchEnabled = true - initialPrefetchItemCount = 5 - // If the view types are not the same across RecyclerView then it may lead to performance degradation. - recycleChildrenOnDetach = true + override fun onInit( + context: Context, + attrs: AttributeSet?, + styleAttr: Int?, + ) { + layoutManager = + LinearLayoutManager( + context, + HORIZONTAL, + false, + ).apply { + // allow prefetching to speed up recycler performance + isItemPrefetchEnabled = true + initialPrefetchItemCount = 5 + // If the view types are not the same across RecyclerView then it may lead to performance degradation. + recycleChildrenOnDetach = true + } + useCarouselDecorator() + disableItemAnimator() } - useCarouselDecorator() - disableItemAnimator() } -} \ No newline at end of file diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/decorator/DefaultSpacingDecorator.kt b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/decorator/DefaultSpacingDecorator.kt index 99cba9470..40ac7fc7e 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/decorator/DefaultSpacingDecorator.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/decorator/DefaultSpacingDecorator.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.recycler.decorator import android.graphics.Rect @@ -30,9 +29,8 @@ import timber.log.Timber class DefaultSpacingDecorator( private val itemSpacing: Int = 2.dp, - private val edgeSpacing: Int = 2.dp -): RecyclerView.ItemDecoration() { - + private val edgeSpacing: Int = 2.dp, +) : RecyclerView.ItemDecoration() { private fun isVerticalOrientation(recyclerView: RecyclerView): Boolean { return when (val layoutManager = recyclerView.layoutManager) { is FlexboxLayoutManager -> layoutManager.flexDirection == FlexDirection.COLUMN @@ -69,14 +67,14 @@ class DefaultSpacingDecorator( outRect: Rect, view: View, parent: RecyclerView, - state: RecyclerView.State + state: RecyclerView.State, ) { /** Credits: https://stackoverflow.com/a/64375667/1725347 */ val count = parent.adapter?.itemCount ?: 0 val position = parent.getChildAdapterPosition(view) val leading = if (position == 0) edgeSpacing else itemSpacing val trailing = if (position == count - 1) edgeSpacing else 0 - with (outRect) { + with(outRect) { if (isVerticalOrientation(parent)) { top = leading bottom = trailing @@ -86,4 +84,4 @@ class DefaultSpacingDecorator( } } } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/model/RecyclerItemBinding.kt b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/model/RecyclerItemBinding.kt index 3157991c6..ebc59f224 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/model/RecyclerItemBinding.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/model/RecyclerItemBinding.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.recycler.model import android.content.res.Resources @@ -26,9 +25,8 @@ import co.anitrend.core.android.R import co.anitrend.core.android.binding.IBindingView abstract class RecyclerItemBinding( - override val id: Long + override val id: Long, ) : IRecyclerItem, IBindingView { - override var binding: B? = null /** @@ -63,6 +61,6 @@ abstract class RecyclerItemBinding( override fun getSpanSize( spanCount: Int, position: Int, - resources: Resources - )= resources.getInteger(co.anitrend.arch.theme.R.integer.single_list_size) + resources: Resources, + ) = resources.getInteger(co.anitrend.arch.theme.R.integer.single_list_size) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/selection/DefaultSelectionMode.kt b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/selection/DefaultSelectionMode.kt index 8751a4d24..2a18df616 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/recycler/selection/DefaultSelectionMode.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/recycler/selection/DefaultSelectionMode.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.recycler.selection import android.view.ActionMode @@ -25,7 +24,6 @@ import co.anitrend.arch.recycler.action.contract.ISupportSelectionMode import co.anitrend.arch.recycler.action.decorator.ISelectionDecorator class DefaultSelectionMode : ISupportSelectionMode { - private val selections = mutableListOf() /** @@ -60,7 +58,7 @@ class DefaultSelectionMode : ISupportSelectionMode { override fun isLongSelectionClickable( view: View, decorator: ISelectionDecorator, - id: Long + id: Long, ): Boolean = false /** @@ -76,12 +74,15 @@ class DefaultSelectionMode : ISupportSelectionMode { override fun isSelectionClickable( view: View, decorator: ISelectionDecorator, - id: Long + id: Long, ): Boolean { if (id != RecyclerView.NO_ID) { val exists = containsItem(id) - if (!exists) selections.add(id) - else selections.remove(id) + if (!exists) { + selections.add(id) + } else { + selections.remove(id) + } decorator.decorateUsing(view, !exists) return true } @@ -103,4 +104,4 @@ class DefaultSelectionMode : ISupportSelectionMode { override fun selectedItems(): List { return selections } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/Settings.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/Settings.kt index 2bb850e1e..f5d9c7443 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/Settings.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/Settings.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings import android.content.Context @@ -48,171 +47,201 @@ import co.anitrend.domain.common.sort.order.SortOrder import co.anitrend.domain.medialist.enums.ScoreFormat import co.anitrend.domain.user.enums.UserTitleLanguage -class Settings(context: Context) : SupportPreference(context), IConfigurationSettings, - IPrivacySettings, IAuthenticationSettings, ISortOrderSettings, IRefreshBehaviourSettings, - ICustomizationSettings, IPowerSettings, IConnectivitySettings, IUserSettings, ICacheSettings, - ISyncSettings, IDeveloperSettings { - - override val locale = EnumSetting( - key = R.string.settings_configuration_locale, - default = AniTrendLocale.AUTOMATIC, - resources = context.resources, - preference = this - ) - - override val theme = EnumSetting( - key = R.string.settings_configuration_theme, - default = AniTrendTheme.SYSTEM, - resources = context.resources, - preference = this - ) - - override val isAnalyticsEnabled = BooleanSetting( - key = R.string.settings_privacy_usage_analytics, - default = false, - resources = context.resources, - preference = this - ) - - override val isCrashlyticsEnabled = BooleanSetting( - key = R.string.settings_privacy_crash_analytics, - default = true, - resources = context.resources, - preference = this - ) - - override val authenticatedUserId = LongSetting( - key = R.string.settings_authentication_id, - default = INVALID_USER_ID, - resources = context.resources, - preference = this - ) - - override val isAuthenticated = BooleanSetting( - key = R.string.settings_is_authenticated, - default = false, - resources = context.resources, - preference = this - ) - - override val sortOrder = EnumSetting( - key = R.string.settings_sort_order, - default = SortOrder.DESC, - resources = context.resources, - preference = this - ) - - override val isNewInstallation = BooleanSetting( - key = R.string.settings_is_new_installation, - default = true, - resources = context.resources, - preference = this - ) - - override val versionCode = IntSetting( - key = R.string.settings_version_code, - default = 1, - resources = context.resources, - preference = this - ) - - override val clearDataOnSwipeRefresh = BooleanSetting( - key = R.string.settings_clear_on_swipe_refresh, - default = false, - resources = context.resources, - preference = this - ) - - override val preferredViewMode = EnumSetting( - key = R.string.settings_view_mode_preferred, - default = PreferredViewMode.COMFORTABLE, - resources = context.resources, - preference = this - ) - - override val isPowerSaverOn = BooleanSetting( - key = R.string.settings_power_saver, - default = false, - resources = context.resources, - preference = this - ) - - override val isBatteryOptimizationOn = BooleanSetting( - key = R.string.settings_battery_optimization, - default = false, - resources = context.resources, - preference = this - ) - - - override val titleLanguage = EnumSetting( - key = R.string.settings_user_title_language, - default = UserTitleLanguage.ROMAJI, - resources = context.resources, - preference = this - ) - - override val scoreFormat = EnumSetting( - key = R.string.settings_user_score_format, - default = ScoreFormat.POINT_10_DECIMAL, - resources = context.resources, - preference = this - ) - - override val cacheUsageRatio = FloatSetting( - key = R.string.settings_cache_usage_ratio, - default = ICacheSettings.MINIMUM_CACHE_LIMIT, - resources = context.resources, - preference = this - ) - - override val metaSyncInterval = IntSetting( - key = R.string.settings_sync_meta_interval, - default = ISyncSettings.MINIMUM_INTERVAL, - resources = context.resources, - preference = this - ) - - override val listSyncInterval = IntSetting( - key = R.string.settings_sync_list_interval, - default = ISyncSettings.MINIMUM_INTERVAL, - resources = context.resources, - preference = this - ) - - override val userSyncInterval = IntSetting( - key = R.string.settings_sync_user_interval, - default = 300, - resources = context.resources, - preference = this - ) - - override val automaticHeapDump = BooleanSetting( - key = R.string.settings_auto_heap_dump, - default = false, - resources = context.resources, - preference = this - ) - - override val showLeakLauncher = BooleanSetting( - key = R.string.settings_show_leak_launcher, - default = false, - resources = context.resources, - preference = this - ) +class Settings(context: Context) : + SupportPreference(context), + IConfigurationSettings, + IPrivacySettings, + IAuthenticationSettings, + ISortOrderSettings, + IRefreshBehaviourSettings, + ICustomizationSettings, + IPowerSettings, + IConnectivitySettings, + IUserSettings, + ICacheSettings, + ISyncSettings, + IDeveloperSettings { + override val locale = + EnumSetting( + key = R.string.settings_configuration_locale, + default = AniTrendLocale.AUTOMATIC, + resources = context.resources, + preference = this, + ) + + override val theme = + EnumSetting( + key = R.string.settings_configuration_theme, + default = AniTrendTheme.SYSTEM, + resources = context.resources, + preference = this, + ) + + override val isAnalyticsEnabled = + BooleanSetting( + key = R.string.settings_privacy_usage_analytics, + default = false, + resources = context.resources, + preference = this, + ) + + override val isCrashlyticsEnabled = + BooleanSetting( + key = R.string.settings_privacy_crash_analytics, + default = true, + resources = context.resources, + preference = this, + ) + + override val authenticatedUserId = + LongSetting( + key = R.string.settings_authentication_id, + default = INVALID_USER_ID, + resources = context.resources, + preference = this, + ) + + override val isAuthenticated = + BooleanSetting( + key = R.string.settings_is_authenticated, + default = false, + resources = context.resources, + preference = this, + ) + + override val sortOrder = + EnumSetting( + key = R.string.settings_sort_order, + default = SortOrder.DESC, + resources = context.resources, + preference = this, + ) + + override val isNewInstallation = + BooleanSetting( + key = R.string.settings_is_new_installation, + default = true, + resources = context.resources, + preference = this, + ) + + override val versionCode = + IntSetting( + key = R.string.settings_version_code, + default = 1, + resources = context.resources, + preference = this, + ) + + override val clearDataOnSwipeRefresh = + BooleanSetting( + key = R.string.settings_clear_on_swipe_refresh, + default = false, + resources = context.resources, + preference = this, + ) + + override val preferredViewMode = + EnumSetting( + key = R.string.settings_view_mode_preferred, + default = PreferredViewMode.COMFORTABLE, + resources = context.resources, + preference = this, + ) + + override val isPowerSaverOn = + BooleanSetting( + key = R.string.settings_power_saver, + default = false, + resources = context.resources, + preference = this, + ) + + override val isBatteryOptimizationOn = + BooleanSetting( + key = R.string.settings_battery_optimization, + default = false, + resources = context.resources, + preference = this, + ) + + override val titleLanguage = + EnumSetting( + key = R.string.settings_user_title_language, + default = UserTitleLanguage.ROMAJI, + resources = context.resources, + preference = this, + ) + + override val scoreFormat = + EnumSetting( + key = R.string.settings_user_score_format, + default = ScoreFormat.POINT_10_DECIMAL, + resources = context.resources, + preference = this, + ) + + override val cacheUsageRatio = + FloatSetting( + key = R.string.settings_cache_usage_ratio, + default = ICacheSettings.MINIMUM_CACHE_LIMIT, + resources = context.resources, + preference = this, + ) + + override val metaSyncInterval = + IntSetting( + key = R.string.settings_sync_meta_interval, + default = ISyncSettings.MINIMUM_INTERVAL, + resources = context.resources, + preference = this, + ) + + override val listSyncInterval = + IntSetting( + key = R.string.settings_sync_list_interval, + default = ISyncSettings.MINIMUM_INTERVAL, + resources = context.resources, + preference = this, + ) + + override val userSyncInterval = + IntSetting( + key = R.string.settings_sync_user_interval, + default = 300, + resources = context.resources, + preference = this, + ) + + override val automaticHeapDump = + BooleanSetting( + key = R.string.settings_auto_heap_dump, + default = false, + resources = context.resources, + preference = this, + ) + + override val showLeakLauncher = + BooleanSetting( + key = R.string.settings_show_leak_launcher, + default = false, + resources = context.resources, + preference = this, + ) companion object { /** * Binding types for [Settings] */ - internal val BINDINGS = arrayOf( - ISupportPreference::class, IConfigurationSettings::class, - ILocaleSettings::class, IThemeSettings::class, - IAuthenticationSettings::class, IPrivacySettings::class, - ISortOrderSettings::class, IRefreshBehaviourSettings::class, - ICustomizationSettings::class, IPowerSettings::class, - IConnectivitySettings::class, IUserSettings::class, - ICacheSettings::class, ISyncSettings::class, IDeveloperSettings::class - ) + internal val BINDINGS = + arrayOf( + ISupportPreference::class, IConfigurationSettings::class, + ILocaleSettings::class, IThemeSettings::class, + IAuthenticationSettings::class, IPrivacySettings::class, + ISortOrderSettings::class, IRefreshBehaviourSettings::class, + ICustomizationSettings::class, IPowerSettings::class, + IConnectivitySettings::class, IUserSettings::class, + ICacheSettings::class, ISyncSettings::class, IDeveloperSettings::class, + ) } } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/IConfigurationSettings.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/IConfigurationSettings.kt index 1e5f6feed..bb2c22207 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/IConfigurationSettings.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/IConfigurationSettings.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.common import co.anitrend.core.android.settings.common.locale.ILocaleSettings import co.anitrend.core.android.settings.common.theme.IThemeSettings -interface IConfigurationSettings : ILocaleSettings, IThemeSettings \ No newline at end of file +interface IConfigurationSettings : ILocaleSettings, IThemeSettings diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/locale/ILocaleSettings.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/locale/ILocaleSettings.kt index 4f52e2df6..6899d6e98 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/locale/ILocaleSettings.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/locale/ILocaleSettings.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,13 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.common.locale import co.anitrend.arch.extension.settings.contract.AbstractSetting import co.anitrend.core.android.settings.helper.locale.model.AniTrendLocale interface ILocaleSettings { - val locale: AbstractSetting -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/theme/IThemeSettings.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/theme/IThemeSettings.kt index b6862c996..1a84f4a3d 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/theme/IThemeSettings.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/common/theme/IThemeSettings.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,13 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.common.theme import co.anitrend.arch.extension.settings.contract.AbstractSetting import co.anitrend.core.android.settings.helper.theme.model.AniTrendTheme interface IThemeSettings { - val theme: AbstractSetting -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/extensions/SettingsExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/extensions/SettingsExtensions.kt index 0788741c3..7870e9cb3 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/extensions/SettingsExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/extensions/SettingsExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 AniTrend + * Copyright (C) 2022 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.extensions import android.annotation.SuppressLint @@ -34,31 +33,34 @@ import co.anitrend.data.settings.customize.common.PreferredViewMode */ suspend fun AbstractSetting.flowUpdating( recyclerView: RecyclerView?, - resolver: (PreferredViewMode) -> Int + resolver: (PreferredViewMode) -> Int, ) { flow.collect { viewMode -> requireNotNull(recyclerView) val adapter = recyclerView.adapter as RecyclerView.Adapter<*> - val newSpanCount = recyclerView.resources.getInteger( - resolver(viewMode) - ) + val newSpanCount = + recyclerView.resources.getInteger( + resolver(viewMode), + ) @SuppressLint("NotifyDataSetChanged") when (val layoutManager = recyclerView.layoutManager) { is StaggeredGridLayoutManager -> { val currentSpanCount = layoutManager.spanCount - if (currentSpanCount != newSpanCount) + if (currentSpanCount != newSpanCount) { layoutManager.spanCount = newSpanCount - else + } else { adapter.notifyDataSetChanged() + } } is GridLayoutManager -> { val currentSpanCount = layoutManager.spanCount - if (currentSpanCount != newSpanCount) + if (currentSpanCount != newSpanCount) { layoutManager.spanCount = newSpanCount - else + } else { adapter.notifyDataSetChanged() + } } } } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/ConfigurationHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/ConfigurationHelper.kt index c8c742027..174f95f8e 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/ConfigurationHelper.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/ConfigurationHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.helper.config import android.content.Context @@ -38,9 +37,8 @@ import co.anitrend.core.android.settings.helper.theme.model.AniTrendTheme internal class ConfigurationHelper( private val settings: IConfigurationSettings, private val localeHelper: ILocaleHelper, - private val themeHelper: IThemeHelper + private val themeHelper: IThemeHelper, ) : IConfigurationHelper { - @StyleRes override var themeOverride: Int? = null @@ -51,8 +49,7 @@ internal class ConfigurationHelper( /** * Creates a new context with configuration */ - override fun attachContext(context: Context?) = - localeHelper.applyLocale(context) + override fun attachContext(context: Context?) = localeHelper.applyLocale(context) /** * Applies configuration upon the create state of the current activity @@ -72,7 +69,7 @@ internal class ConfigurationHelper( */ override fun onResume(activity: FragmentActivity) { if (applicationTheme != settings.theme.value) { - //activity.recreate() + // activity.recreate() activity.resetActivity() themeHelper.applyDynamicNightModeFromTheme() } @@ -93,8 +90,8 @@ internal class ConfigurationHelper( private operator fun FragmentActivity.invoke() { overridePendingTransition( android.R.anim.fade_in, - android.R.anim.fade_out + android.R.anim.fade_out, ) } } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/contract/IConfigurationHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/contract/IConfigurationHelper.kt index 575b784a9..905108bf1 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/contract/IConfigurationHelper.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/config/contract/IConfigurationHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.helper.config.contract import android.content.Context @@ -26,7 +25,6 @@ import androidx.fragment.app.FragmentActivity * @property themeOverride Theme resource override option */ interface IConfigurationHelper { - var themeOverride: Int? /** @@ -47,4 +45,4 @@ interface IConfigurationHelper { * @param activity */ fun onResume(activity: FragmentActivity) -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/LocaleHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/LocaleHelper.kt index e1ac58880..a469da544 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/LocaleHelper.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/LocaleHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.helper.locale import android.content.Context @@ -27,14 +26,14 @@ import co.anitrend.core.android.settings.helper.locale.model.AniTrendLocale import java.util.Locale internal class LocaleHelper(private val settings: ILocaleSettings) : ILocaleHelper { - /** * Current locale */ override val locale: Locale get() { - if (settings.locale.value == AniTrendLocale.AUTOMATIC) + if (settings.locale.value == AniTrendLocale.AUTOMATIC) { return Locale.getDefault() + } return getPersonalizedLocale() } @@ -61,8 +60,9 @@ internal class LocaleHelper(private val settings: ILocaleSettings) : ILocaleHelp private fun getPersonalizedLocale(): Locale { val locale = settings.locale.value - if (locale.country == null) + if (locale.country == null) { return Locale(locale.language) + } return Locale(locale.language, locale.country) } } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/contract/ILocaleHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/contract/ILocaleHelper.kt index cd935f428..ea3e29f8b 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/contract/ILocaleHelper.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/contract/ILocaleHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.helper.locale.contract import android.content.Context @@ -22,7 +21,6 @@ import androidx.appcompat.app.AppCompatDelegate import java.util.Locale interface ILocaleHelper { - /** * Current application locale */ diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/model/AniTrendLocale.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/model/AniTrendLocale.kt index 180ada06c..46dbe9481 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/model/AniTrendLocale.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/locale/model/AniTrendLocale.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.helper.locale.model import co.anitrend.arch.extension.ext.empty @@ -36,26 +35,28 @@ enum class AniTrendLocale(val language: String, val country: String? = null) { AUTOMATIC(String.empty()), GERMAN_GERMANY( language = Locale.GERMAN.language, - country = Locale.GERMAN.country + country = Locale.GERMAN.country, ), ITALIAN_ITALY( language = Locale.ITALY.language, - country = Locale.ITALY.country + country = Locale.ITALY.country, ), FRENCH_FRANCE( language = Locale.FRANCE.language, - country = Locale.FRANCE.country - ); + country = Locale.FRANCE.country, + ), + ; companion object { fun Locale.asLocaleString() = "$language$country" - fun AniTrendLocale.asLocaleString() = when (this) { - AUTOMATIC -> { - val default = Locale.getDefault() - default.asLocaleString() + fun AniTrendLocale.asLocaleString() = + when (this) { + AUTOMATIC -> { + val default = Locale.getDefault() + default.asLocaleString() + } + else -> "$language$country" } - else -> "$language$country" - } } } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/ThemeHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/ThemeHelper.kt index 4d517cff4..73ab27f1e 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/ThemeHelper.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/ThemeHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.helper.theme import android.annotation.TargetApi @@ -36,7 +35,6 @@ import co.anitrend.core.android.settings.helper.theme.model.AniTrendTheme * @param settings instance of theme settings */ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper { - @TargetApi(Build.VERSION_CODES.O) private fun FragmentActivity.applyNightModeDecorations(systemUiOptions: Int) { val primaryColor = getCompatColor(co.anitrend.arch.theme.R.color.colorPrimary) @@ -46,13 +44,13 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { window.insetsController?.setSystemBarsAppearance( WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS and WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, - WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS and WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS + WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS and WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, ) } else { @Suppress("DEPRECATION") window.decorView.systemUiVisibility = systemUiOptions and - View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR and - View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR and + View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR } } @@ -67,17 +65,16 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper } else { @Suppress("DEPRECATION") window.decorView.systemUiVisibility = systemUiOptions or - View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR or - View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR or + View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR window.navigationBarColor = primaryColor window.statusBarColor = primaryColor } } - private fun FragmentActivity.applyWindowStyle() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - @Suppress("DEPRECATION") //Until I figure out a way to apply decorations using window controller + @Suppress("DEPRECATION") // Until I figure out a way to apply decorations using window controller val systemUiOptions = window.decorView.systemUiVisibility when (AppCompatDelegate.getDefaultNightMode()) { AppCompatDelegate.MODE_NIGHT_NO -> applyDayModeDecorations(systemUiOptions) @@ -85,9 +82,11 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper else -> { // According to Google/IO other ui options like auto and follow system // will be deprecated in the future - if (isEnvironmentNightMode()) + if (isEnvironmentNightMode()) { applyNightModeDecorations(systemUiOptions) - else applyDayModeDecorations(systemUiOptions) + } else { + applyDayModeDecorations(systemUiOptions) + } } } } @@ -98,19 +97,22 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper */ override fun applyDynamicNightModeFromTheme() { val theme = settings.theme.value - if (theme == AniTrendTheme.SYSTEM) + if (theme == AniTrendTheme.SYSTEM) { AppCompatDelegate.setDefaultNightMode( - AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM, ) - else + } else { when (theme.useNightMode) { - true -> AppCompatDelegate.setDefaultNightMode( - AppCompatDelegate.MODE_NIGHT_NO - ) - else -> AppCompatDelegate.setDefaultNightMode( - AppCompatDelegate.MODE_NIGHT_YES - ) + true -> + AppCompatDelegate.setDefaultNightMode( + AppCompatDelegate.MODE_NIGHT_NO, + ) + else -> + AppCompatDelegate.setDefaultNightMode( + AppCompatDelegate.MODE_NIGHT_YES, + ) } + } } /** @@ -118,12 +120,13 @@ internal class ThemeHelper(private val settings: IThemeSettings) : IThemeHelper */ override fun applyApplicationTheme( context: FragmentActivity, - themeOverride: Int? + themeOverride: Int?, ) { - if (themeOverride != null) + if (themeOverride != null) { context.setTheme(themeOverride) - else + } else { context.setTheme(settings.theme.value.styleAttribute) + } context.applyWindowStyle() } } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/contract/IThemeHelper.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/contract/IThemeHelper.kt index 2990b7d84..87f48f14b 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/contract/IThemeHelper.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/contract/IThemeHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,14 +14,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.helper.theme.contract import androidx.annotation.StyleRes import androidx.fragment.app.FragmentActivity interface IThemeHelper { - /** * Sets the default night mode based on the theme set in settings */ @@ -32,6 +30,6 @@ interface IThemeHelper { */ fun applyApplicationTheme( context: FragmentActivity, - @StyleRes themeOverride: Int? = null + @StyleRes themeOverride: Int? = null, ) -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/model/AniTrendTheme.kt b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/model/AniTrendTheme.kt index 9c2c6b436..d6be91be9 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/model/AniTrendTheme.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/settings/helper/theme/model/AniTrendTheme.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 AniTrend + * Copyright (C) 2019 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.settings.helper.theme.model import androidx.annotation.StyleRes @@ -26,20 +25,23 @@ import co.anitrend.core.android.R * @param styleAttribute The style resource attribute that will be applied * @param useNightMode If the current theme should also change the system to use night mode */ -enum class AniTrendTheme(@StyleRes val styleAttribute: Int, val useNightMode: Boolean = false) { +enum class AniTrendTheme( + @StyleRes val styleAttribute: Int, + val useNightMode: Boolean = false, +) { SYSTEM( - styleAttribute = 0 + styleAttribute = 0, ), AMOLED( styleAttribute = R.style.AppTheme, - useNightMode = true + useNightMode = true, ), LIGHT( styleAttribute = R.style.AppTheme, - useNightMode = false + useNightMode = false, ), DARK( styleAttribute = R.style.AppTheme_Dark, - useNightMode = true - ) -} \ No newline at end of file + useNightMode = true, + ), +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/ShortcutController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/ShortcutController.kt index 7e458e3e9..4b066da66 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/ShortcutController.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/ShortcutController.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.shortcut import android.annotation.SuppressLint @@ -34,7 +33,6 @@ internal class ShortcutController( private val context: Context, private val shortcutManager: ShortcutManager?, ) : IShortcutController { - /** * Publish the list of dynamic [shortcuts]. If there are already dynamic or * pinned shortcuts with the same IDs, each mutable shortcut is updated. @@ -45,27 +43,29 @@ internal class ShortcutController( */ override fun createShortcuts(vararg shortcuts: Shortcut): Boolean { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { - val shortcutInfo = shortcuts.mapNotNull { shortcut -> - val intent = shortcut.router.forActivity( - context = context, - navPayload = shortcut.navPayload, - ) - if (intent == null) { - Timber.w("Intent for shortcut: `${shortcut.id}` returned null") - null - } else { - ShortcutInfo.Builder(context, shortcut.id) - .setShortLabel(context.getString(shortcut.label)) - .setDisabledMessage(context.getString(shortcut.disabledMessage)) - .setIcon(Icon.createWithResource(context, shortcut.icon)) - .setIntent(intent) - .build() + val shortcutInfo = + shortcuts.mapNotNull { shortcut -> + val intent = + shortcut.router.forActivity( + context = context, + navPayload = shortcut.navPayload, + ) + if (intent == null) { + Timber.w("Intent for shortcut: `${shortcut.id}` returned null") + null + } else { + ShortcutInfo.Builder(context, shortcut.id) + .setShortLabel(context.getString(shortcut.label)) + .setDisabledMessage(context.getString(shortcut.disabledMessage)) + .setIcon(Icon.createWithResource(context, shortcut.icon)) + .setIntent(intent) + .build() + } } - } shortcutManager?.addDynamicShortcuts(shortcutInfo) ?: false - } - else + } else { false + } } /** @@ -77,8 +77,9 @@ internal class ShortcutController( */ @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1, lambda = 1) override fun enableShortcuts(vararg shortcuts: Shortcut) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { shortcutManager?.enableShortcuts(shortcuts.map(Shortcut::id)) + } } /** @@ -90,8 +91,9 @@ internal class ShortcutController( */ @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1, lambda = 1) override fun disableShortcuts(vararg shortcuts: Shortcut) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { shortcutManager?.disableShortcuts(shortcuts.map(Shortcut::id)) + } } /** @@ -103,8 +105,9 @@ internal class ShortcutController( */ @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1, lambda = 1) override fun reportShortcutUsage(shortcut: Shortcut) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { shortcutManager?.reportShortcutUsed(shortcut.id) + } } /** @@ -114,7 +117,8 @@ internal class ShortcutController( */ @ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N_MR1, lambda = 1) override fun removeAllDynamicShortcuts() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { shortcutManager?.removeAllDynamicShortcuts() + } } } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/contract/IShortcutController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/contract/IShortcutController.kt index 088aea162..550ee0d00 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/contract/IShortcutController.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/contract/IShortcutController.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.shortcut.contract import android.os.Build @@ -23,7 +22,6 @@ import co.anitrend.core.android.shortcut.model.Shortcut @RequiresApi(Build.VERSION_CODES.N_MR1) interface IShortcutController { - /** * Publish the list of dynamic [shortcuts]. If there are already dynamic or * pinned shortcuts with the same IDs, each mutable shortcut is updated. @@ -77,4 +75,4 @@ interface IShortcutController { @RequiresApi(Build.VERSION_CODES.N_MR1) @Throws(IllegalStateException::class) fun removeAllDynamicShortcuts() -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/model/Shortcut.kt b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/model/Shortcut.kt index 07ee3fdcd..f8b1cfea9 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/model/Shortcut.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/shortcut/model/Shortcut.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.shortcut.model import androidx.annotation.DrawableRes @@ -38,7 +37,9 @@ sealed class Shortcut { abstract val navPayload: NavPayload? @get:StringRes abstract val label: Int + @get:DrawableRes abstract val icon: Int + @get:StringRes abstract val disabledMessage: Int data class AiringSchedule( diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/state/IScreenState.kt b/android-core/src/main/kotlin/co/anitrend/core/android/state/IScreenState.kt index 8d249ff92..2a3527fe3 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/state/IScreenState.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/state/IScreenState.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.state import android.os.Bundle @@ -26,5 +25,6 @@ import android.os.Bundle */ interface IScreenState { fun onSaveInstanceState(outState: Bundle) + fun onRestoreInstanceState(savedInstanceState: Bundle) -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/storage/StorageController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/storage/StorageController.kt index fe9d9bf26..094c999e1 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/storage/StorageController.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/storage/StorageController.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.storage import android.content.Context @@ -26,27 +25,25 @@ import timber.log.Timber import java.io.File class StorageController : IStorageController { - - private fun Context.directoryOf( - storageType: StorageType - ) = when (storageType) { - StorageType.CACHE -> externalCacheDir ?: cacheDir - StorageType.FILES -> getExternalFilesDir(storageType.type) ?: filesDir - StorageType.MUSIC -> requireNotNull(getExternalFilesDir(storageType.type)) - StorageType.PICTURES -> requireNotNull(getExternalFilesDir(storageType.type)) - StorageType.MOVIES -> requireNotNull(getExternalFilesDir(storageType.type)) - } + private fun Context.directoryOf(storageType: StorageType) = + when (storageType) { + StorageType.CACHE -> externalCacheDir ?: cacheDir + StorageType.FILES -> getExternalFilesDir(storageType.type) ?: filesDir + StorageType.MUSIC -> requireNotNull(getExternalFilesDir(storageType.type)) + StorageType.PICTURES -> requireNotNull(getExternalFilesDir(storageType.type)) + StorageType.MOVIES -> requireNotNull(getExternalFilesDir(storageType.type)) + } override fun getLogsCache(context: Context): File { val external = context.directoryOf(StorageType.FILES) - val logs = File(external, logsName) + val logs = File(external, LOGS) if (!logs.exists()) logs.mkdirs() return logs } override fun getImageCache(context: Context): File { val cache = context.directoryOf(StorageType.CACHE) - val imageCache = File(cache, imageCacheName) + val imageCache = File(cache, IMAGE_CACHE) if (!imageCache.exists()) imageCache.mkdirs() Timber.v("Cache directory for images: ${imageCache.canonicalPath}") return imageCache @@ -54,7 +51,7 @@ class StorageController : IStorageController { override fun getVideoCache(context: Context): File { val cache = context.directoryOf(StorageType.CACHE) - val videoCache = File(cache, videoCacheName) + val videoCache = File(cache, VIDEO_CACHE) if (!videoCache.exists()) videoCache.mkdirs() Timber.v("Cache directory for exo player cache: ${videoCache.canonicalPath}") return videoCache @@ -62,13 +59,16 @@ class StorageController : IStorageController { override fun getVideoOfflineCache(context: Context): File { val cache = context.directoryOf(StorageType.CACHE) - val videoOfflineCache = File(cache, videoOfflineCacheName) + val videoOfflineCache = File(cache, VIDEO_OFFLINE_CACHE) if (!videoOfflineCache.exists()) videoOfflineCache.mkdirs() Timber.v("Cache directory for exo player offline sync cache: ${videoOfflineCache.canonicalPath}") return videoOfflineCache } - override fun getFreeSpace(context: Context, type: StorageType): Long { + override fun getFreeSpace( + context: Context, + type: StorageType, + ): Long { val cache = context.directoryOf(type) return cache.freeSpace } @@ -76,7 +76,7 @@ class StorageController : IStorageController { override fun getStorageUsageLimit( context: Context, type: StorageType, - settings: ICacheSettings + settings: ICacheSettings, ): Long { val freeSpace = getFreeSpace(context, type) val ratio = settings.cacheUsageRatio.value @@ -85,10 +85,10 @@ class StorageController : IStorageController { return limit } - companion object { - private const val logsName = "logs" - private const val imageCacheName = "coil_image_cache" - private const val videoCacheName = "exo_video_cache" - private const val videoOfflineCacheName = "exo_video_offline_cache" + private companion object { + private const val LOGS = "logs" + private const val IMAGE_CACHE = "coil_image_cache" + private const val VIDEO_CACHE = "exo_video_cache" + private const val VIDEO_OFFLINE_CACHE = "exo_video_offline_cache" } -} \ No newline at end of file +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/storage/contract/IStorageController.kt b/android-core/src/main/kotlin/co/anitrend/core/android/storage/contract/IStorageController.kt index 44d3cc32c..e540aec6e 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/storage/contract/IStorageController.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/storage/contract/IStorageController.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.storage.contract import android.content.Context @@ -24,9 +23,21 @@ import java.io.File interface IStorageController { fun getLogsCache(context: Context): File + fun getImageCache(context: Context): File + fun getVideoCache(context: Context): File + fun getVideoOfflineCache(context: Context): File - fun getFreeSpace(context: Context, type: StorageType): Long - fun getStorageUsageLimit(context: Context, type: StorageType, settings: ICacheSettings): Long -} \ No newline at end of file + + fun getFreeSpace( + context: Context, + type: StorageType, + ): Long + + fun getStorageUsageLimit( + context: Context, + type: StorageType, + settings: ICacheSettings, + ): Long +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/storage/enums/StorageType.kt b/android-core/src/main/kotlin/co/anitrend/core/android/storage/enums/StorageType.kt index 272a2b418..722afc140 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/storage/enums/StorageType.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/storage/enums/StorageType.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.storage.enums import android.os.Environment @@ -29,5 +28,5 @@ enum class StorageType(val type: String?) { FILES(null), MUSIC(Environment.DIRECTORY_MUSIC), PICTURES(Environment.DIRECTORY_PICTURES), - MOVIES(Environment.DIRECTORY_MOVIES) -} \ No newline at end of file + MOVIES(Environment.DIRECTORY_MOVIES), +} diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/storage/extensions/StorageControllerExtensions.kt b/android-core/src/main/kotlin/co/anitrend/core/android/storage/extensions/StorageControllerExtensions.kt index 3b46ef811..639bdf3d9 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/storage/extensions/StorageControllerExtensions.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/storage/extensions/StorageControllerExtensions.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.storage.extensions import java.util.Locale @@ -30,8 +29,10 @@ fun Float.toHumanReadableByteValue(si: Boolean = false): String { val pre = (if (si) "kMGTPE" else "KMGTPE")[exp - 1].toString() + if (si) "" else "i" return String.format( - Locale.getDefault(), "%.1f %sB", - bytes / unit.toDouble().pow(exp.toDouble()), pre + Locale.getDefault(), + "%.1f %sB", + bytes / unit.toDouble().pow(exp.toDouble()), + pre, ) } @@ -44,7 +45,9 @@ fun Long.toHumanReadableByteValue(si: Boolean = false): String { val pre = (if (si) "kMGTPE" else "KMGTPE")[exp - 1].toString() + if (si) "" else "i" return String.format( - Locale.getDefault(), "%.1f %sB", - bytes / unit.toDouble().pow(exp.toDouble()), pre + Locale.getDefault(), + "%.1f %sB", + bytes / unit.toDouble().pow(exp.toDouble()), + pre, ) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/AniTrendPreview.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/AniTrendPreview.kt index 7438330b7..c4540c1f2 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/AniTrendPreview.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/AniTrendPreview.kt @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.ui import android.content.res.Configuration.UI_MODE_NIGHT_NO @@ -5,44 +21,43 @@ import android.content.res.Configuration.UI_MODE_NIGHT_YES import androidx.compose.ui.tooling.preview.Preview annotation class AniTrendPreview { - @Preview( uiMode = UI_MODE_NIGHT_NO, - name = "Light" + name = "Light", ) annotation class Light @Preview( uiMode = UI_MODE_NIGHT_YES, - name = "Dark" + name = "Dark", ) annotation class Dark @Preview( showSystemUi = true, device = "spec:width=411dp,height=891dp", - name = "Mobile" + name = "Mobile", ) annotation class Mobile @Preview( showSystemUi = true, device = "spec:width=673.5dp,height=841dp,dpi=480", - name = "Foldable" + name = "Foldable", ) annotation class Foldable @Preview( showSystemUi = true, device = "spec:width=1280dp,height=800dp,dpi=480", - name = "Tablet" + name = "Tablet", ) annotation class Tablet @Preview( showSystemUi = true, device = "spec:width=1920dp,height=1080dp,dpi=480", - name = "Desktop" + name = "Desktop", ) annotation class Desktop } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/color/Color.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/color/Color.kt index 009ad4c57..f43defb49 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/color/Color.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/color/Color.kt @@ -1,8 +1,23 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.ui.color import androidx.compose.ui.graphics.Color - val md_theme_light_primary = Color(0xFF6750A4) val md_theme_light_onPrimary = Color(0xFFFFFFFF) val md_theme_light_primaryContainer = Color(0xFFEADDFF) diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/Theme.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/Theme.kt index 57d47b5b7..7bcaa5ba6 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/Theme.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/Theme.kt @@ -1,8 +1,23 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.ui.theme import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.material.icons.Icons import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ShapeDefaults import androidx.compose.material3.Shapes @@ -77,96 +92,98 @@ import co.anitrend.core.android.ui.color.md_theme_light_tertiaryContainer import co.anitrend.core.android.ui.typography.AniTrendTypography import org.koin.compose.koinInject +private val LightColorScheme = + lightColorScheme( + primary = md_theme_light_primary, + onPrimary = md_theme_light_onPrimary, + primaryContainer = md_theme_light_primaryContainer, + onPrimaryContainer = md_theme_light_onPrimaryContainer, + secondary = md_theme_light_secondary, + onSecondary = md_theme_light_onSecondary, + secondaryContainer = md_theme_light_secondaryContainer, + onSecondaryContainer = md_theme_light_onSecondaryContainer, + tertiary = md_theme_light_tertiary, + onTertiary = md_theme_light_onTertiary, + tertiaryContainer = md_theme_light_tertiaryContainer, + onTertiaryContainer = md_theme_light_onTertiaryContainer, + error = md_theme_light_error, + onError = md_theme_light_onError, + errorContainer = md_theme_light_errorContainer, + onErrorContainer = md_theme_light_onErrorContainer, + outline = md_theme_light_outline, + background = md_theme_light_background, + onBackground = md_theme_light_onBackground, + surface = md_theme_light_surface, + onSurface = md_theme_light_onSurface, + surfaceVariant = md_theme_light_surfaceVariant, + onSurfaceVariant = md_theme_light_onSurfaceVariant, + inverseSurface = md_theme_light_inverseSurface, + inverseOnSurface = md_theme_light_inverseOnSurface, + inversePrimary = md_theme_light_inversePrimary, + surfaceTint = md_theme_light_surfaceTint, + outlineVariant = md_theme_light_outlineVariant, + scrim = md_theme_light_scrim, + ) -private val LightColorScheme = lightColorScheme( - primary = md_theme_light_primary, - onPrimary = md_theme_light_onPrimary, - primaryContainer = md_theme_light_primaryContainer, - onPrimaryContainer = md_theme_light_onPrimaryContainer, - secondary = md_theme_light_secondary, - onSecondary = md_theme_light_onSecondary, - secondaryContainer = md_theme_light_secondaryContainer, - onSecondaryContainer = md_theme_light_onSecondaryContainer, - tertiary = md_theme_light_tertiary, - onTertiary = md_theme_light_onTertiary, - tertiaryContainer = md_theme_light_tertiaryContainer, - onTertiaryContainer = md_theme_light_onTertiaryContainer, - error = md_theme_light_error, - onError = md_theme_light_onError, - errorContainer = md_theme_light_errorContainer, - onErrorContainer = md_theme_light_onErrorContainer, - outline = md_theme_light_outline, - background = md_theme_light_background, - onBackground = md_theme_light_onBackground, - surface = md_theme_light_surface, - onSurface = md_theme_light_onSurface, - surfaceVariant = md_theme_light_surfaceVariant, - onSurfaceVariant = md_theme_light_onSurfaceVariant, - inverseSurface = md_theme_light_inverseSurface, - inverseOnSurface = md_theme_light_inverseOnSurface, - inversePrimary = md_theme_light_inversePrimary, - surfaceTint = md_theme_light_surfaceTint, - outlineVariant = md_theme_light_outlineVariant, - scrim = md_theme_light_scrim, -) - -private val DarkColorScheme = darkColorScheme( - primary = md_theme_dark_primary, - onPrimary = md_theme_dark_onPrimary, - primaryContainer = md_theme_dark_primaryContainer, - onPrimaryContainer = md_theme_dark_onPrimaryContainer, - secondary = md_theme_dark_secondary, - onSecondary = md_theme_dark_onSecondary, - secondaryContainer = md_theme_dark_secondaryContainer, - onSecondaryContainer = md_theme_dark_onSecondaryContainer, - tertiary = md_theme_dark_tertiary, - onTertiary = md_theme_dark_onTertiary, - tertiaryContainer = md_theme_dark_tertiaryContainer, - onTertiaryContainer = md_theme_dark_onTertiaryContainer, - error = md_theme_dark_error, - onError = md_theme_dark_onError, - errorContainer = md_theme_dark_errorContainer, - onErrorContainer = md_theme_dark_onErrorContainer, - outline = md_theme_dark_outline, - background = md_theme_dark_background, - onBackground = md_theme_dark_onBackground, - surface = md_theme_dark_surface, - onSurface = md_theme_dark_onSurface, - surfaceVariant = md_theme_dark_surfaceVariant, - onSurfaceVariant = md_theme_dark_onSurfaceVariant, - inverseSurface = md_theme_dark_inverseSurface, - inverseOnSurface = md_theme_dark_inverseOnSurface, - inversePrimary = md_theme_dark_inversePrimary, - surfaceTint = md_theme_dark_surfaceTint, - outlineVariant = md_theme_dark_outlineVariant, - scrim = md_theme_dark_scrim, -) - -private val AniTrendShapes = Shapes( - extraSmall = ShapeDefaults.ExtraLarge, - small = ShapeDefaults.ExtraLarge, - medium = ShapeDefaults.ExtraLarge, - large = ShapeDefaults.ExtraLarge, - extraLarge = ShapeDefaults.ExtraLarge, -) +private val DarkColorScheme = + darkColorScheme( + primary = md_theme_dark_primary, + onPrimary = md_theme_dark_onPrimary, + primaryContainer = md_theme_dark_primaryContainer, + onPrimaryContainer = md_theme_dark_onPrimaryContainer, + secondary = md_theme_dark_secondary, + onSecondary = md_theme_dark_onSecondary, + secondaryContainer = md_theme_dark_secondaryContainer, + onSecondaryContainer = md_theme_dark_onSecondaryContainer, + tertiary = md_theme_dark_tertiary, + onTertiary = md_theme_dark_onTertiary, + tertiaryContainer = md_theme_dark_tertiaryContainer, + onTertiaryContainer = md_theme_dark_onTertiaryContainer, + error = md_theme_dark_error, + onError = md_theme_dark_onError, + errorContainer = md_theme_dark_errorContainer, + onErrorContainer = md_theme_dark_onErrorContainer, + outline = md_theme_dark_outline, + background = md_theme_dark_background, + onBackground = md_theme_dark_onBackground, + surface = md_theme_dark_surface, + onSurface = md_theme_dark_onSurface, + surfaceVariant = md_theme_dark_surfaceVariant, + onSurfaceVariant = md_theme_dark_onSurfaceVariant, + inverseSurface = md_theme_dark_inverseSurface, + inverseOnSurface = md_theme_dark_inverseOnSurface, + inversePrimary = md_theme_dark_inversePrimary, + surfaceTint = md_theme_dark_surfaceTint, + outlineVariant = md_theme_dark_outlineVariant, + scrim = md_theme_dark_scrim, + ) +private val AniTrendShapes = + Shapes( + extraSmall = ShapeDefaults.ExtraLarge, + small = ShapeDefaults.ExtraLarge, + medium = ShapeDefaults.ExtraLarge, + large = ShapeDefaults.ExtraLarge, + extraLarge = ShapeDefaults.ExtraLarge, + ) @Composable fun AniTrendTheme3( darkTheme: Boolean = isSystemInDarkTheme(), themeHelper: IThemeHelper = koinInject(), dynamicColor: Boolean = true, - content: @Composable () -> Unit + content: @Composable () -> Unit, ) { - val colorScheme = when { - dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { - val context = LocalContext.current - if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) - } + val colorScheme = + when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } - darkTheme -> DarkColorScheme - else -> LightColorScheme - } + darkTheme -> DarkColorScheme + else -> LightColorScheme + } val view = LocalView.current if (!view.isInEditMode) { SideEffect { @@ -179,6 +196,6 @@ fun AniTrendTheme3( colorScheme = colorScheme, shapes = AniTrendShapes, typography = AniTrendTypography, - content = content + content = content, ) } diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/preview/PreviewDefaults.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/preview/PreviewDefaults.kt index 54826a09b..7046760d9 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/preview/PreviewDefaults.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/theme/preview/PreviewDefaults.kt @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.ui.theme.preview import androidx.compose.foundation.isSystemInDarkTheme @@ -6,23 +22,27 @@ import androidx.fragment.app.FragmentActivity import co.anitrend.core.android.settings.helper.theme.contract.IThemeHelper import co.anitrend.core.android.ui.theme.AniTrendTheme3 -private val PreviewThemeHelper = object : IThemeHelper { - /** - * Sets the default night mode based on the theme set in settings - */ - override fun applyDynamicNightModeFromTheme() {} +private val PreviewThemeHelper = + object : IThemeHelper { + /** + * Sets the default night mode based on the theme set in settings + */ + override fun applyDynamicNightModeFromTheme() {} - /** - * Applies settings theme resource or provided [themeOverride] which overrides settings - */ - override fun applyApplicationTheme(context: FragmentActivity, themeOverride: Int?) {} -} + /** + * Applies settings theme resource or provided [themeOverride] which overrides settings + */ + override fun applyApplicationTheme( + context: FragmentActivity, + themeOverride: Int?, + ) {} + } @Composable fun PreviewTheme( darkTheme: Boolean = isSystemInDarkTheme(), dynamicColor: Boolean = true, - content: @Composable () -> Unit + content: @Composable () -> Unit, ) { AniTrendTheme3( darkTheme = darkTheme, diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/ui/typography/Typography.kt b/android-core/src/main/kotlin/co/anitrend/core/android/ui/typography/Typography.kt index cf34aba73..aa5457e1a 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/ui/typography/Typography.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/ui/typography/Typography.kt @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2024 AniTrend + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package co.anitrend.core.android.ui.typography import androidx.compose.material3.Typography diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/FrameLayoutWithBinding.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/FrameLayoutWithBinding.kt index 20483a0ad..aaa375be2 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/views/FrameLayoutWithBinding.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/FrameLayoutWithBinding.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.views import android.content.Context @@ -28,34 +27,39 @@ import co.anitrend.core.android.binding.IBindingView * Frame layout with view binding support * > **N.B.** View binding seems to cause a lot of data mix-ups within a view holder item */ -abstract class FrameLayoutWithBinding @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : FrameLayout(context, attrs, defStyleAttr), CustomView, IBindingView { - - override var binding: V? = null +abstract class FrameLayoutWithBinding + @JvmOverloads + constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + ) : FrameLayout(context, attrs, defStyleAttr), CustomView, IBindingView { + override var binding: V? = null - override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) { - binding = createBinding() - } + override fun onInit( + context: Context, + attrs: AttributeSet?, + styleAttr: Int?, + ) { + binding = createBinding() + } - protected abstract fun createBinding(): V + protected abstract fun createBinding(): V - /** - * Should be called on a view's detach from window to unbind or release object references - * and cancel all running coroutine jobs if the current view - * - * Consider calling this in [android.view.View.onDetachedFromWindow] - */ - override fun onViewRecycled() { - super.onViewRecycled() - binding = null - } + /** + * Should be called on a view's detach from window to unbind or release object references + * and cancel all running coroutine jobs if the current view + * + * Consider calling this in [android.view.View.onDetachedFromWindow] + */ + override fun onViewRecycled() { + super.onViewRecycled() + binding = null + } - override fun onDetachedFromWindow() { - super.onDetachedFromWindow() - // TODO: Avoid setting binding to null in onDetach otherwise views don't get updated in a recycler - //onViewRecycled() + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + // TODO: Avoid setting binding to null in onDetach otherwise views don't get updated in a recycler + // onViewRecycled() + } } - - -} \ No newline at end of file diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/LinearLayoutWithBinding.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/LinearLayoutWithBinding.kt index 405179d9b..a467de883 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/views/LinearLayoutWithBinding.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/LinearLayoutWithBinding.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 AniTrend + * Copyright (C) 2020 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.views import android.content.Context @@ -28,32 +27,39 @@ import co.anitrend.core.android.binding.IBindingView * Linear layout with view binding support * > **N.B.** View binding seems to cause a lot of data mix-ups within a view holder item */ -abstract class LinearLayoutWithBinding @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : LinearLayoutCompat(context, attrs, defStyleAttr), CustomView, IBindingView { - - override var binding: V? = null +abstract class LinearLayoutWithBinding + @JvmOverloads + constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + ) : LinearLayoutCompat(context, attrs, defStyleAttr), CustomView, IBindingView { + override var binding: V? = null - override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) { - binding = createBinding() - } + override fun onInit( + context: Context, + attrs: AttributeSet?, + styleAttr: Int?, + ) { + binding = createBinding() + } - protected abstract fun createBinding(): V + protected abstract fun createBinding(): V - /** - * Should be called on a view's detach from window to unbind or release object references - * and cancel all running coroutine jobs if the current view - * - * Consider calling this in [android.view.View.onDetachedFromWindow] - */ - override fun onViewRecycled() { - super.onViewRecycled() - binding = null - } + /** + * Should be called on a view's detach from window to unbind or release object references + * and cancel all running coroutine jobs if the current view + * + * Consider calling this in [android.view.View.onDetachedFromWindow] + */ + override fun onViewRecycled() { + super.onViewRecycled() + binding = null + } - override fun onDetachedFromWindow() { - super.onDetachedFromWindow() - // TODO: Avoid setting binding to null in onDetach otherwise views don't get updated in a recycler - //onViewRecycled() + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + // TODO: Avoid setting binding to null in onDetach otherwise views don't get updated in a recycler + // onViewRecycled() + } } -} \ No newline at end of file diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/drawable/RoundedDrawable.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/drawable/RoundedDrawable.kt index 86c55e631..a56fb0c93 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/views/drawable/RoundedDrawable.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/drawable/RoundedDrawable.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.views.drawable import android.graphics.drawable.PaintDrawable diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/scroll/FillNestedScrollView.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/scroll/FillNestedScrollView.kt index 86e0a1642..3dc74f7a3 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/views/scroll/FillNestedScrollView.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/scroll/FillNestedScrollView.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.views.scroll import android.content.Context @@ -23,28 +22,35 @@ import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat import androidx.core.widget.NestedScrollView -class FillNestedScrollView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : NestedScrollView(context, attrs, defStyleAttr) { - - var maxHeight = -1 +class FillNestedScrollView + @JvmOverloads + constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, + ) : NestedScrollView(context, attrs, defStyleAttr) { + var maxHeight = -1 - private fun getBottomHeight(): Int { - val insets = ViewCompat.getRootWindowInsets(this) - val systemBars = WindowInsetsCompat.Type.systemBars() - return insets?.getInsets(systemBars)?.bottom ?: 0 - } + private fun getBottomHeight(): Int { + val insets = ViewCompat.getRootWindowInsets(this) + val systemBars = WindowInsetsCompat.Type.systemBars() + return insets?.getInsets(systemBars)?.bottom ?: 0 + } - override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { - var heightSpec = if (maxHeight > 0) - MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST) - else - heightMeasureSpec + override fun onMeasure( + widthMeasureSpec: Int, + heightMeasureSpec: Int, + ) { + var heightSpec = + if (maxHeight > 0) { + MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST) + } else { + heightMeasureSpec + } - if (maxHeight < height + getBottomHeight()) - heightSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST) - super.onMeasure(widthMeasureSpec, heightSpec) + if (maxHeight < height + getBottomHeight()) { + heightSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST) + } + super.onMeasure(widthMeasureSpec, heightSpec) + } } -} \ No newline at end of file diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/views/text/TextDrawable.kt b/android-core/src/main/kotlin/co/anitrend/core/android/views/text/TextDrawable.kt index 5b7123ed2..3583bbe20 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/views/text/TextDrawable.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/views/text/TextDrawable.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.views.text import android.content.Context @@ -34,42 +33,53 @@ import com.google.android.material.textview.MaterialTextView */ class TextDrawable( context: Context, - private val text: String? + private val text: String?, ) : Drawable() { - - private val materialTextView = MaterialTextView(context).also { textView -> - textView.text = text - textView.background = textView.context.getCompatDrawable( - R.drawable.indicator_background, co.anitrend.arch.theme.R.color.colorBackground - ) - textView.layoutParams = ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, - ViewGroup.LayoutParams.MATCH_PARENT - ) - textView.setTextColor( - textView.context.getCompatColor( - co.anitrend.arch.theme.R.color.colorOnBackground + private val materialTextView = + MaterialTextView(context).also { textView -> + textView.text = text + textView.background = + textView.context.getCompatDrawable( + R.drawable.indicator_background, + co.anitrend.arch.theme.R.color.colorBackground, + ) + textView.layoutParams = + ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT, + ) + textView.setTextColor( + textView.context.getCompatColor( + co.anitrend.arch.theme.R.color.colorOnBackground, + ), ) - ) - val padding = textView.resources - .getDimensionPixelSize(R.dimen.text_drawable_margin) - textView.setPadding(padding, padding, padding, padding) - } + val padding = + textView.resources + .getDimensionPixelSize(R.dimen.text_drawable_margin) + textView.setPadding(padding, padding, padding, padding) + } /** * Specify a bounding rectangle for the Drawable. This is where the drawable * will draw when its draw() method is called. */ - override fun setBounds(left: Int, top: Int, right: Int, bottom: Int) { + override fun setBounds( + left: Int, + top: Int, + right: Int, + bottom: Int, + ) { super.setBounds(left, top, right, bottom) - val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec( - right - left, - View.MeasureSpec.EXACTLY - ) - val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec( - bottom - top, - View.MeasureSpec.EXACTLY - ) + val widthMeasureSpec = + View.MeasureSpec.makeMeasureSpec( + right - left, + View.MeasureSpec.EXACTLY, + ) + val heightMeasureSpec = + View.MeasureSpec.makeMeasureSpec( + bottom - top, + View.MeasureSpec.EXACTLY, + ) materialTextView.measure(widthMeasureSpec, heightMeasureSpec) materialTextView.layout(left, top, right, bottom) } @@ -89,7 +99,7 @@ class TextDrawable( * 255 means fully opaque. */ override fun setAlpha(alpha: Int) { - materialTextView.alpha = alpha/255f + materialTextView.alpha = alpha / 255f } /** diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/widget/appbar/BottomAppBar.kt b/android-core/src/main/kotlin/co/anitrend/core/android/widget/appbar/BottomAppBar.kt index f048bc34b..ec20b6714 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/widget/appbar/BottomAppBar.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/widget/appbar/BottomAppBar.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.widget.appbar import android.content.Context @@ -28,49 +27,54 @@ import com.google.android.material.bottomappbar.BottomAppBar import kotlinx.coroutines.delay import me.saket.cascade.overrideAllPopupMenus -class BottomAppBar @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = R.attr.bottomAppBarStyle -) : BottomAppBar(context, attrs, defStyleAttr), CustomView { - - init { - onInit(context, attrs, defStyleAttr) - } +class BottomAppBar + @JvmOverloads + constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = R.attr.bottomAppBarStyle, + ) : BottomAppBar(context, attrs, defStyleAttr), CustomView { + init { + onInit(context, attrs, defStyleAttr) + } - /** - * Change visibility of all items for in this menu - * - * @param shouldShow Visibility - * @param filter Predicate for which menu items to hid - */ - suspend fun toggleVisibility( - shouldShow: Boolean, - filter: (MenuItem) -> Boolean - ) { - runCatching { - delay(128) - menu.iterator().asSequence() - .filter(filter) - .forEach { menuItem -> - menuItem.isVisible = shouldShow - } + /** + * Change visibility of all items for in this menu + * + * @param shouldShow Visibility + * @param filter Predicate for which menu items to hid + */ + suspend fun toggleVisibility( + shouldShow: Boolean, + filter: (MenuItem) -> Boolean, + ) { + runCatching { + delay(128) + menu.iterator().asSequence() + .filter(filter) + .forEach { menuItem -> + menuItem.isVisible = shouldShow + } + } } - } - /** - * Callable in view constructors to perform view inflation and attribute initialization - * - * @param context view context - * @param attrs view attributes if applicable - * @param styleAttr style attribute if applicable - */ - override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) { - hideOnScroll = true - isHapticFeedbackEnabled = true - overrideAllPopupMenus { _, anchor -> - anchor.cascadeMenu() + /** + * Callable in view constructors to perform view inflation and attribute initialization + * + * @param context view context + * @param attrs view attributes if applicable + * @param styleAttr style attribute if applicable + */ + override fun onInit( + context: Context, + attrs: AttributeSet?, + styleAttr: Int?, + ) { + hideOnScroll = true + isHapticFeedbackEnabled = true + overrideAllPopupMenus { _, anchor -> + anchor.cascadeMenu() + } + // HideBottomViewOnScrollBehavior } - // HideBottomViewOnScrollBehavior } -} \ No newline at end of file diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/widget/button/LoadingTextButton.kt b/android-core/src/main/kotlin/co/anitrend/core/android/widget/button/LoadingTextButton.kt index 4821bc0db..a412e5e7d 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/widget/button/LoadingTextButton.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/widget/button/LoadingTextButton.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.widget.button import android.content.Context @@ -40,103 +39,121 @@ import com.google.android.material.textview.MaterialTextView * * @param icon Optional icon for this text button */ -class LoadingTextButton @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - icon: Int? = null, -) : ViewFlipper(context, attrs), CustomView { +class LoadingTextButton + @JvmOverloads + constructor( + context: Context, + attrs: AttributeSet? = null, + icon: Int? = null, + ) : ViewFlipper(context, attrs), CustomView { + private val indicator = + CircularProgressIndicator(context).apply { + layoutParams = + LayoutParams( + LinearLayoutCompat.LayoutParams.WRAP_CONTENT, + LinearLayoutCompat.LayoutParams.WRAP_CONTENT, + ).also { params -> + params.gravity = Gravity.CENTER_VERTICAL + params.marginEnd = 8.dp + } + indicatorSize = 16.dp + trackCornerRadius = 8.dp + trackThickness = 4.dp + isIndeterminate = true + } - private val indicator = CircularProgressIndicator(context).apply { - layoutParams = LayoutParams( - LinearLayoutCompat.LayoutParams.WRAP_CONTENT, - LinearLayoutCompat.LayoutParams.WRAP_CONTENT - ).also { params -> - params.gravity = Gravity.CENTER_VERTICAL - params.marginEnd = 8.dp - } - indicatorSize = 16.dp - trackCornerRadius = 8.dp - trackThickness = 4.dp - isIndeterminate = true - } + private val primaryText = + MaterialTextView(context).apply { + applyDefaultTextStyle { + setCompoundDrawablesWithIntrinsicBounds( + icon?.let { context.getCompatDrawable(it) }, + null, + null, + null, + ) + } + } - private val primaryText = MaterialTextView(context).apply { - applyDefaultTextStyle { - setCompoundDrawablesWithIntrinsicBounds( - icon?.let { context.getCompatDrawable(it) }, - null, null, null - ) + init { + onInit(context, attrs) } - } - init { onInit(context, attrs) } + /** + * @see MaterialTextView.setText + */ + fun setText(text: CharSequence?) { + primaryText.text = text + showContent() + } - /** - * @see MaterialTextView.setText - */ - fun setText(text: CharSequence?) { - primaryText.text = text - showContent() - } + /** + * @see MaterialTextView.setCompoundDrawables + */ + fun setDrawable(drawable: Drawable?) { + primaryText.setCompoundDrawablesWithIntrinsicBounds( + drawable, + null, + null, + null, + ) + showContent() + } - /** - * @see MaterialTextView.setCompoundDrawables - */ - fun setDrawable(drawable: Drawable?) { - primaryText.setCompoundDrawablesWithIntrinsicBounds( - drawable, null, null, null - ) - showContent() - } + fun showLoading() { + if (displayedChild != LOADING_INDEX) { + displayedChild = LOADING_INDEX + } + } - fun showLoading() { - if (displayedChild != LOADING_INDEX) - displayedChild = LOADING_INDEX - } + fun showContent() { + if (displayedChild != CONTENT_INDEX) { + displayedChild = CONTENT_INDEX + } + } - fun showContent() { - if (displayedChild != CONTENT_INDEX) - displayedChild = CONTENT_INDEX - } + override fun onInit( + context: Context, + attrs: AttributeSet?, + styleAttr: Int?, + ) { + inAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_in) + outAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_out) + layoutParams = + LayoutParams( + LinearLayoutCompat.LayoutParams.WRAP_CONTENT, + LinearLayoutCompat.LayoutParams.WRAP_CONTENT, + ) + addView(primaryText) + addView(indicator) - override fun onInit(context: Context, attrs: AttributeSet?, styleAttr: Int?) { - inAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_in) - outAnimation = AnimationUtils.loadAnimation(context, android.R.anim.fade_out) - layoutParams = LayoutParams( - LinearLayoutCompat.LayoutParams.WRAP_CONTENT, - LinearLayoutCompat.LayoutParams.WRAP_CONTENT - ) - addView(primaryText) - addView(indicator) + if (isInEditMode) { + displayedChild = CONTENT_INDEX + } + } - if (isInEditMode) + override fun onViewRecycled() { + super.onViewRecycled() displayedChild = CONTENT_INDEX - } - - override fun onViewRecycled() { - super.onViewRecycled() - displayedChild = CONTENT_INDEX - setOnClickListener(null) - } + setOnClickListener(null) + } - private companion object { - const val CONTENT_INDEX = 0 - const val LOADING_INDEX = 1 + private companion object { + const val CONTENT_INDEX = 0 + const val LOADING_INDEX = 1 - fun MaterialTextView.applyDefaultTextStyle( - unit: MaterialTextView.() -> Unit - ) { - layoutParams = LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT - ).also { param -> - param.gravity = Gravity.CENTER_VERTICAL + fun MaterialTextView.applyDefaultTextStyle(unit: MaterialTextView.() -> Unit) { + layoutParams = + LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT, + ).also { param -> + param.gravity = Gravity.CENTER_VERTICAL + } + compoundDrawablePadding = 8.dp + style(R.style.AppTheme_Material_TextBody_Primary) + setTypeface(typeface, Typeface.BOLD) + setTextColor(context.getCompatColor(R.color.white_1000)) + unit() } - compoundDrawablePadding = 8.dp - style(R.style.AppTheme_Material_TextBody_Primary) - setTypeface(typeface, Typeface.BOLD) - setTextColor(context.getCompatColor(R.color.white_1000)) - unit() } } -} \ No newline at end of file diff --git a/android-core/src/main/kotlin/co/anitrend/core/android/widget/viewpager/BottomSheetViewPager.kt b/android-core/src/main/kotlin/co/anitrend/core/android/widget/viewpager/BottomSheetViewPager.kt index 2d63a9d9e..e860463d8 100644 --- a/android-core/src/main/kotlin/co/anitrend/core/android/widget/viewpager/BottomSheetViewPager.kt +++ b/android-core/src/main/kotlin/co/anitrend/core/android/widget/viewpager/BottomSheetViewPager.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 AniTrend + * Copyright (C) 2021 AniTrend * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package co.anitrend.core.android.widget.viewpager import android.content.Context @@ -31,54 +30,57 @@ import java.lang.reflect.Field * * @author kafumi */ -class BottomSheetViewPager @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, -) : ViewPager(context, attrs) { - - // Need to access package-private `position` field of `ViewPager.LayoutParams` to determine - // which child view is the view for currently selected item from `ViewPager.getCurrentItem()`. - private val positionField: Field = - LayoutParams::class.java.getDeclaredField( - "position" - ).also { it.isAccessible = true } +class BottomSheetViewPager + @JvmOverloads + constructor( + context: Context, + attrs: AttributeSet? = null, + ) : ViewPager(context, attrs) { + // Need to access package-private `position` field of `ViewPager.LayoutParams` to determine + // which child view is the view for currently selected item from `ViewPager.getCurrentItem()`. + private val positionField: Field = + LayoutParams::class.java.getDeclaredField( + "position", + ).also { it.isAccessible = true } - init { - addOnPageChangeListener(object : SimpleOnPageChangeListener() { - override fun onPageSelected(position: Int) { - // Need to call requestLayout() when selected page is changed so that - // `BottomSheetBehavior` calls `findScrollingChild()` and recognizes the new page - // as the "scrollable child". - requestLayout() - } - }) - } + init { + addOnPageChangeListener( + object : SimpleOnPageChangeListener() { + override fun onPageSelected(position: Int) { + // Need to call requestLayout() when selected page is changed so that + // `BottomSheetBehavior` calls `findScrollingChild()` and recognizes the new page + // as the "scrollable child". + requestLayout() + } + }, + ) + } - override fun getChildAt(index: Int): View { - // Swap index 0 and `currentItem` - val currentView = getCurrentView() ?: return super.getChildAt(index) - return if (index == 0) { - currentView - } else { - var view = super.getChildAt(index) - if (view == currentView) { - view = super.getChildAt(0) + override fun getChildAt(index: Int): View { + // Swap index 0 and `currentItem` + val currentView = getCurrentView() ?: return super.getChildAt(index) + return if (index == 0) { + currentView + } else { + var view = super.getChildAt(index) + if (view == currentView) { + view = super.getChildAt(0) + } + return view } - return view } - } - private fun getCurrentView(): View? { - for (i in 0 until childCount) { - val child = super.getChildAt(i) - val lp = child.layoutParams as? LayoutParams - if (lp != null) { - val position = positionField.getInt(lp) - if (!lp.isDecor && currentItem == position) { - return child + private fun getCurrentView(): View? { + for (i in 0 until childCount) { + val child = super.getChildAt(i) + val lp = child.layoutParams as? LayoutParams + if (lp != null) { + val position = positionField.getInt(lp) + if (!lp.isDecor && currentItem == position) { + return child + } } } + return null } - return null } -} \ No newline at end of file diff --git a/android-core/src/main/res/anim/enter_from_bottom.xml b/android-core/src/main/res/anim/enter_from_bottom.xml index 2fdc7387a..fc4b0238a 100644 --- a/android-core/src/main/res/anim/enter_from_bottom.xml +++ b/android-core/src/main/res/anim/enter_from_bottom.xml @@ -1,21 +1,20 @@ - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> - + + diff --git a/android-core/src/main/res/color/selector_chip_background.xml b/android-core/src/main/res/color/selector_chip_background.xml index ecb69d567..20183bbe7 100644 --- a/android-core/src/main/res/color/selector_chip_background.xml +++ b/android-core/src/main/res/color/selector_chip_background.xml @@ -1,20 +1,20 @@ - - + + diff --git a/android-core/src/main/res/color/selector_chip_text_color.xml b/android-core/src/main/res/color/selector_chip_text_color.xml index 5500ca1d6..1773b030c 100644 --- a/android-core/src/main/res/color/selector_chip_text_color.xml +++ b/android-core/src/main/res/color/selector_chip_text_color.xml @@ -1,20 +1,20 @@ - - + + diff --git a/android-core/src/main/res/color/selector_text_button_ripple.xml b/android-core/src/main/res/color/selector_text_button_ripple.xml index f27bf12af..c69755f47 100644 --- a/android-core/src/main/res/color/selector_text_button_ripple.xml +++ b/android-core/src/main/res/color/selector_text_button_ripple.xml @@ -1,20 +1,20 @@ - - + + - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/dashed_background.xml b/android-core/src/main/res/drawable/dashed_background.xml index 7f0d70dbe..44f24cd48 100644 --- a/android-core/src/main/res/drawable/dashed_background.xml +++ b/android-core/src/main/res/drawable/dashed_background.xml @@ -1,20 +1,20 @@ - - + + + diff --git a/android-core/src/main/res/drawable/gradient_shadow.xml b/android-core/src/main/res/drawable/gradient_shadow.xml index 4c38c1855..958487820 100644 --- a/android-core/src/main/res/drawable/gradient_shadow.xml +++ b/android-core/src/main/res/drawable/gradient_shadow.xml @@ -1,21 +1,20 @@ - +~ Copyright (C) 2021 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/gradient_shadow_inverse.xml b/android-core/src/main/res/drawable/gradient_shadow_inverse.xml index a8935e210..7c6532d59 100644 --- a/android-core/src/main/res/drawable/gradient_shadow_inverse.xml +++ b/android-core/src/main/res/drawable/gradient_shadow_inverse.xml @@ -1,21 +1,20 @@ - +~ Copyright (C) 2021 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> + diff --git a/android-core/src/main/res/drawable/ic_heart_filled.xml b/android-core/src/main/res/drawable/ic_heart_filled.xml index e4abe9faf..26806ad91 100644 --- a/android-core/src/main/res/drawable/ic_heart_filled.xml +++ b/android-core/src/main/res/drawable/ic_heart_filled.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2022 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_heart_outline.xml b/android-core/src/main/res/drawable/ic_heart_outline.xml index 33c850fd0..80f95efe2 100644 --- a/android-core/src/main/res/drawable/ic_heart_outline.xml +++ b/android-core/src/main/res/drawable/ic_heart_outline.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2022 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_search.xml b/android-core/src/main/res/drawable/ic_search.xml index 129974f1d..9d97d01cf 100644 --- a/android-core/src/main/res/drawable/ic_search.xml +++ b/android-core/src/main/res/drawable/ic_search.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2019 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_activity.xml b/android-core/src/main/res/drawable/ic_shortcut_activity.xml index a297562fb..8d9330a15 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_activity.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_activity.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_airing_schedule.xml b/android-core/src/main/res/drawable/ic_shortcut_airing_schedule.xml index ae7f06532..a349c5fa1 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_airing_schedule.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_airing_schedule.xml @@ -1,21 +1,20 @@ - +~ Copyright (C) 2021 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_anime_list.xml b/android-core/src/main/res/drawable/ic_shortcut_anime_list.xml index e36fda4a0..877a61fad 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_anime_list.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_anime_list.xml @@ -1,21 +1,20 @@ - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_episodes.xml b/android-core/src/main/res/drawable/ic_shortcut_episodes.xml index d47b950ce..a7772b72f 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_episodes.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_episodes.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2019 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_forum.xml b/android-core/src/main/res/drawable/ic_shortcut_forum.xml index d39c90520..f31b896de 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_forum.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_forum.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_manga_list.xml b/android-core/src/main/res/drawable/ic_shortcut_manga_list.xml index 26529fdbc..e00b4b399 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_manga_list.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_manga_list.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_news.xml b/android-core/src/main/res/drawable/ic_shortcut_news.xml index f2b4c731e..0f9eecf17 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_news.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_news.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_notifications.xml b/android-core/src/main/res/drawable/ic_shortcut_notifications.xml index 68fd58b79..117467e4b 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_notifications.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_notifications.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_profile.xml b/android-core/src/main/res/drawable/ic_shortcut_profile.xml index 24b363437..b1195c1ed 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_profile.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_profile.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_shortcut_search.xml b/android-core/src/main/res/drawable/ic_shortcut_search.xml index 68357829a..d8d0f0b22 100644 --- a/android-core/src/main/res/drawable/ic_shortcut_search.xml +++ b/android-core/src/main/res/drawable/ic_shortcut_search.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2021 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_view_comfortable.xml b/android-core/src/main/res/drawable/ic_view_comfortable.xml index 344ee8f90..6e8e02811 100644 --- a/android-core/src/main/res/drawable/ic_view_comfortable.xml +++ b/android-core/src/main/res/drawable/ic_view_comfortable.xml @@ -1,3 +1,20 @@ + + diff --git a/android-core/src/main/res/drawable/ic_view_compact.xml b/android-core/src/main/res/drawable/ic_view_compact.xml index dc9b078d7..824007686 100644 --- a/android-core/src/main/res/drawable/ic_view_compact.xml +++ b/android-core/src/main/res/drawable/ic_view_compact.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2021 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_view_detailed.xml b/android-core/src/main/res/drawable/ic_view_detailed.xml index ae5453ea4..2702328ea 100644 --- a/android-core/src/main/res/drawable/ic_view_detailed.xml +++ b/android-core/src/main/res/drawable/ic_view_detailed.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2021 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/ic_view_summary.xml b/android-core/src/main/res/drawable/ic_view_summary.xml index 15beeda0d..0f784e89a 100644 --- a/android-core/src/main/res/drawable/ic_view_summary.xml +++ b/android-core/src/main/res/drawable/ic_view_summary.xml @@ -1,20 +1,20 @@ + - +~ Copyright (C) 2021 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/indicator_background.xml b/android-core/src/main/res/drawable/indicator_background.xml index 7577206b7..5c83caf86 100644 --- a/android-core/src/main/res/drawable/indicator_background.xml +++ b/android-core/src/main/res/drawable/indicator_background.xml @@ -1,4 +1,20 @@ + diff --git a/android-core/src/main/res/drawable/material_tab_indicator.xml b/android-core/src/main/res/drawable/material_tab_indicator.xml index e53e9fbfb..143bdda36 100644 --- a/android-core/src/main/res/drawable/material_tab_indicator.xml +++ b/android-core/src/main/res/drawable/material_tab_indicator.xml @@ -1,20 +1,20 @@ - - + + - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/drawable/widget_background.xml b/android-core/src/main/res/drawable/widget_background.xml index 82ec3fc7a..c7682d082 100644 --- a/android-core/src/main/res/drawable/widget_background.xml +++ b/android-core/src/main/res/drawable/widget_background.xml @@ -1,20 +1,20 @@ - - + + diff --git a/android-core/src/main/res/layout/action_frame_layout.xml b/android-core/src/main/res/layout/action_frame_layout.xml index 6fbd2e4f4..5959fc515 100644 --- a/android-core/src/main/res/layout/action_frame_layout.xml +++ b/android-core/src/main/res/layout/action_frame_layout.xml @@ -1,20 +1,20 @@ +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> - + +

diff --git a/android-core/src/main/res/values-large-land/columns.xml b/android-core/src/main/res/values-large-land/columns.xml index 445160261..7cfe9d2f4 100644 --- a/android-core/src/main/res/values-large-land/columns.xml +++ b/android-core/src/main/res/values-large-land/columns.xml @@ -1,20 +1,20 @@ - - + + 3 5 diff --git a/android-core/src/main/res/values-large-port/columns.xml b/android-core/src/main/res/values-large-port/columns.xml index 272ce0278..05d7f5f25 100644 --- a/android-core/src/main/res/values-large-port/columns.xml +++ b/android-core/src/main/res/values-large-port/columns.xml @@ -1,20 +1,20 @@ - - + + 2 3 diff --git a/android-core/src/main/res/values-night/colors.xml b/android-core/src/main/res/values-night/colors.xml index bb7bd2d19..714a700d3 100644 --- a/android-core/src/main/res/values-night/colors.xml +++ b/android-core/src/main/res/values-night/colors.xml @@ -1,21 +1,20 @@ - +~ Copyright (C) 2019 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> #272727 #292929 diff --git a/android-core/src/main/res/values-night/environment.xml b/android-core/src/main/res/values-night/environment.xml index ec2b9eefc..214a465ff 100644 --- a/android-core/src/main/res/values-night/environment.xml +++ b/android-core/src/main/res/values-night/environment.xml @@ -1,21 +1,20 @@ - +~ Copyright (C) 2019 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> true \ No newline at end of file diff --git a/android-core/src/main/res/values-night/themes.xml b/android-core/src/main/res/values-night/themes.xml index 74c48a59d..025d58d52 100644 --- a/android-core/src/main/res/values-night/themes.xml +++ b/android-core/src/main/res/values-night/themes.xml @@ -1,21 +1,20 @@ - +~ Copyright (C) 2020 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +--> diff --git a/android-core/src/main/res/values-normal-land/columns.xml b/android-core/src/main/res/values-normal-land/columns.xml index d71daefd0..563b036f1 100644 --- a/android-core/src/main/res/values-normal-land/columns.xml +++ b/android-core/src/main/res/values-normal-land/columns.xml @@ -1,20 +1,20 @@ - - + + 2 4 diff --git a/android-core/src/main/res/values-v28/themes.xml b/android-core/src/main/res/values-v28/themes.xml index 24a2c3cba..fa2363a34 100644 --- a/android-core/src/main/res/values-v28/themes.xml +++ b/android-core/src/main/res/values-v28/themes.xml @@ -1,20 +1,20 @@ +~ Copyright (C) 2019 AniTrend +~ +~ This program is free software: you can redistribute it and/or modify +~ it under the terms of the GNU General Public License as published by +~ the Free Software Foundation, either version 3 of the License, or +~ (at your option) any later version. +~ +~ This program is distributed in the hope that it will be useful, +~ but WITHOUT ANY WARRANTY; without even the implied warranty of +~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +~ GNU General Public License for more details. +~ +~ You should have received a copy of the GNU General Public License +~ along with this program. If not, see . +-->