From b5894d38731d5d29119cc8a86c698d9512b11078 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 7 Mar 2023 12:22:27 +0400 Subject: [PATCH] Removed unused code --- .../com/woocommerce/android/AppPrefs.kt | 79 -- .../kotlin/com/woocommerce/android/AppUrls.kt | 1 - .../com/woocommerce/android/JobServiceIds.kt | 6 - .../com/woocommerce/android/RequestCodes.kt | 8 - .../android/analytics/AnalyticsEvent.kt | 49 -- .../android/analytics/AnalyticsTracker.kt | 13 - .../android/di/ActivityBindingModule.kt | 15 - .../android/di/LoginFragmentsModule.kt | 22 - .../android/extensions/CollectionUtilsExt.kt | 17 - .../woocommerce/android/extensions/DateExt.kt | 15 - .../android/extensions/EditTextExt.kt | 17 - .../android/extensions/LiveDataExt.kt | 12 - .../android/extensions/StringDateFormatExt.kt | 17 - .../android/extensions/StringExt.kt | 11 - .../android/tools/RateLimitedTask.kt | 8 - .../android/tools/SiteConnectionType.kt | 10 +- .../common/wpcomwebview/WPComWebViewClient.kt | 16 - .../android/ui/login/UnifiedLoginTracker.kt | 4 - .../ui/login/qrcode/CameraPermissionUtils.kt | 21 - .../ui/mystore/RoundedBarChartRenderer.kt | 169 ---- .../ui/orders/list/OrderListFragment.kt | 1 - .../android/ui/orders/list/OrderListType.kt | 7 - .../android/ui/orders/list/OrderListView.kt | 11 - .../ui/orders/list/OrderListViewModel.kt | 6 - .../ShippingLabelActionListener.kt | 5 - .../ShippingLabelCreatePackageViewModel.kt | 1 - .../AddOrderTrackingProviderActionListener.kt | 5 - .../AddOrderTrackingProviderListAdapter.kt | 23 - .../payments/refunds/IssueRefundViewModel.kt | 18 - .../SimplePaymentsSharedViewModel.kt | 7 - .../ui/prefs/WCSettingsOptionValueView.kt | 4 - .../ui/prefs/WCSettingsToggleOptionView.kt | 7 - .../ui/products/ProductDetailViewModel.kt | 79 +- .../ui/products/ProductFilterListViewModel.kt | 41 +- .../variations/VariationDetailViewModel.kt | 4 - .../ui/sitepicker/SitePickerRepository.kt | 4 - .../woocommerce/android/util/AppThemeUtils.kt | 9 - .../android/util/ContinuationWrapper.kt | 22 - .../android/util/CoroutineHelpers.kt | 13 - .../android/util/CurrencyFormatter.kt | 13 - .../com/woocommerce/android/util/DateUtils.kt | 21 - .../woocommerce/android/util/WooAnimUtils.kt | 36 - .../android/util/WooPermissionUtils.kt | 7 - .../android/viewmodel/ViewModelKey.kt | 14 - .../android/widgets/ActionableEmptyView.kt | 27 - .../android/widgets/NumberPickerDialog.kt | 4 - .../SectionParameters.kt | 44 -- .../SectionedRecyclerViewAdapter.kt | 721 ------------------ .../network/ConnectionChangeReceiver.kt | 23 - .../push/NotificationMessageHandlerTest.kt | 4 - .../android/ui/orders/OrderTestUtils.kt | 16 - .../android/ui/products/ProductTestUtils.kt | 28 +- 52 files changed, 30 insertions(+), 1705 deletions(-) delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/JobServiceIds.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/di/ActivityBindingModule.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/di/LoginFragmentsModule.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/CollectionUtilsExt.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/common/wpcomwebview/WPComWebViewClient.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/qrcode/CameraPermissionUtils.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/mystore/RoundedBarChartRenderer.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListType.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/ShippingLabelActionListener.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/tracking/AddOrderTrackingProviderActionListener.kt delete mode 100644 WooCommerce/src/main/kotlin/com/woocommerce/android/viewmodel/ViewModelKey.kt delete mode 100644 WooCommerce/src/test/kotlin/com/woocommerce/android/network/ConnectionChangeReceiver.kt diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/AppPrefs.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/AppPrefs.kt index faee9299d31..2177423845d 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/AppPrefs.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/AppPrefs.kt @@ -40,8 +40,6 @@ import com.woocommerce.android.ui.promobanner.PromoBannerType import com.woocommerce.android.util.PreferenceUtils import com.woocommerce.android.util.ThemeOption import com.woocommerce.android.util.ThemeOption.DEFAULT -import com.woocommerce.android.util.WooLog -import com.woocommerce.android.util.WooLog.T import java.util.Calendar import java.util.Date @@ -135,15 +133,9 @@ object AppPrefs { // Play cha-ching sound on new order notifications NOTIFS_ORDERS_CHA_CHING_ENABLED, - // Number of times the "mark all notifications read" icon was tapped - NUM_TIMES_MARK_ALL_NOTIFS_READ_SNACK_SHOWN, - // The app update for this version was cancelled by the user CANCELLED_APP_VERSION_CODE, - // Application permissions - ASKED_PERMISSION_CAMERA, - // Date of the app installation APP_INSTALATION_DATE, @@ -281,10 +273,6 @@ object AppPrefs { remove(DeletablePrefKey.SUPPORT_EMAIL) } - fun setSupportName(name: String) { - setString(DeletablePrefKey.SUPPORT_NAME, name) - } - fun getSupportName() = getString(DeletablePrefKey.SUPPORT_NAME) fun removeSupportName() { @@ -427,14 +415,6 @@ object AppPrefs { fun setCardReaderWelcomeDialogShown() = setBoolean(UndeletablePrefKey.CARD_READER_WELCOME_SHOWN, true) - /** - * Flag to check products features are enabled - */ - fun isProductsFeatureEnabled() = getBoolean(DeletablePrefKey.IS_PRODUCTS_FEATURE_ENABLED, false) - - fun setIsProductsFeatureEnabled(isProductsFeatureEnabled: Boolean) = - setBoolean(DeletablePrefKey.IS_PRODUCTS_FEATURE_ENABLED, isProductsFeatureEnabled) - fun isCrashReportingEnabled(): Boolean { // default to False for debug builds val default = !BuildConfig.DEBUG @@ -463,14 +443,6 @@ object AppPrefs { setBoolean(UndeletablePrefKey.NOTIFS_ORDERS_CHA_CHING_ENABLED, enabled) } - fun getNumTimesMarkAllReadSnackShown(): Int = - getInt(UndeletablePrefKey.NUM_TIMES_MARK_ALL_NOTIFS_READ_SNACK_SHOWN, 0) - - fun incNumTimesMarkAllReadSnackShown() { - val numTimesShown = getNumTimesMarkAllReadSnackShown() + 1 - setInt(UndeletablePrefKey.NUM_TIMES_MARK_ALL_NOTIFS_READ_SNACK_SHOWN, numTimesShown) - } - fun getSelectedShipmentTrackingProviderName(): String = getString(DeletablePrefKey.SELECTED_SHIPMENT_TRACKING_PROVIDER_NAME) @@ -499,26 +471,12 @@ object AppPrefs { setBoolean(DeletablePrefKey.LOGIN_USER_BYPASSED_JETPACK_REQUIRED, bypassedLogin) } - fun getLoginUserBypassedJetpackRequired() = - getBoolean(DeletablePrefKey.LOGIN_USER_BYPASSED_JETPACK_REQUIRED, false) - - fun removeLoginUserBypassedJetpackRequired() { - remove(DeletablePrefKey.LOGIN_USER_BYPASSED_JETPACK_REQUIRED) - } - fun getDatabaseDowngraded() = getBoolean(DATABASE_DOWNGRADED, false) fun setDatabaseDowngraded(value: Boolean) { setBoolean(DATABASE_DOWNGRADED, value) } - fun setSelectedOrderListTab(selectedOrderListTabPosition: Int) { - setInt(DeletablePrefKey.SELECTED_ORDER_LIST_TAB_POSITION, selectedOrderListTabPosition) - } - - fun getSelectedOrderListTabPosition() = - getInt(DeletablePrefKey.SELECTED_ORDER_LIST_TAB_POSITION, -1) - fun setSelectedProductType(type: ProductType) = setString(DeletablePrefKey.SELECTED_PRODUCT_TYPE, type.value) fun getSelectedProductType(): String = getString(DeletablePrefKey.SELECTED_PRODUCT_TYPE, "") @@ -528,14 +486,6 @@ object AppPrefs { fun isSelectedProductVirtual(): Boolean = getBoolean(DeletablePrefKey.SELECTED_PRODUCT_IS_VIRTUAL, false) - /** - * Checks if the user has a saved order list tab position yet. If no position has been saved, - * then the value will be the default of -1. - * - * @return True if the saved position is not the default -1, else false - */ - fun hasSelectedOrderListTabPosition() = getSelectedOrderListTabPosition() > -1 - fun getImageOptimizationEnabled() = getBoolean(IMAGE_OPTIMIZE_ENABLED, true) fun setImageOptimizationEnabled(enabled: Boolean) { @@ -567,20 +517,6 @@ object AppPrefs { setString(DeletablePrefKey.UNIFIED_LOGIN_LAST_ACTIVE_SOURCE, source) } - /** - * Used during the unified login process to track the last flow the user was in before - * closing the app so if the user opens and finishes the flow at a later day the tracks - * events will be complete. - */ - fun getUnifiedLoginLastFlow(): String? { - val result = getString(DeletablePrefKey.UNIFIED_LOGIN_LAST_ACTIVE_FLOW) - return if (result.isNotEmpty()) { - result - } else { - null - } - } - fun setUnifiedLoginLastFlow(flow: String) { setString(DeletablePrefKey.UNIFIED_LOGIN_LAST_ACTIVE_FLOW, flow) } @@ -1034,21 +970,6 @@ object AppPrefs { ) } - /* - * key in shared preferences which stores a boolean telling whether the app has already - * asked for the passed permission - */ - fun getPermissionAskedKey(permission: String): PrefKey? { - when (permission) { - android.Manifest.permission.CAMERA -> - return UndeletablePrefKey.ASKED_PERMISSION_CAMERA - else -> { - WooLog.w(T.UTILS, "No key for requested permission: $permission") - return null - } - } - } - enum class CardReaderOnboardingStatus { CARD_READER_ONBOARDING_COMPLETED, CARD_READER_ONBOARDING_PENDING, diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/AppUrls.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/AppUrls.kt index 70244473b92..069463267b8 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/AppUrls.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/AppUrls.kt @@ -6,7 +6,6 @@ import com.woocommerce.android.support.help.HelpOrigin.LOGIN_USERNAME_PASSWORD object AppUrls { const val APP_HELP_CENTER = "https://docs.woocommerce.com/document/android/" - const val APP_FEATURE_REQUEST = "http://ideas.woocommerce.com/forums/133476-woocommerce?category_id=84283" const val AUTOMATTIC_TOS = "https://woocommerce.com/terms-conditions/" const val AUTOMATTIC_PRIVACY_POLICY = "https://www.automattic.com/privacy" diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/JobServiceIds.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/JobServiceIds.kt deleted file mode 100644 index 4fd545e85b5..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/JobServiceIds.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.woocommerce.android - -object JobServiceIds { - const val JOB_FCM_REGISTRATION_SERVICE_ID = 1000 - const val JOB_PRODUCT_IMAGES_SERVICE_ID = 2000 -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/RequestCodes.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/RequestCodes.kt index 14778d3c2f3..782251607e7 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/RequestCodes.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/RequestCodes.kt @@ -10,14 +10,6 @@ object RequestCodes { const val SETTINGS = BASE_REQUEST_CODE + 1 const val IN_APP_UPDATE = BASE_REQUEST_CODE + 3 - const val CAMERA_PERMISSION = BASE_REQUEST_CODE + 10 - - const val PRODUCT_IMAGE_VIEWER = BASE_REQUEST_CODE + 100 - const val CHOOSE_PHOTO = BASE_REQUEST_CODE + 101 - const val CAPTURE_PHOTO = BASE_REQUEST_CODE + 102 - const val WPMEDIA_LIBRARY_PICK_PHOTOS = BASE_REQUEST_CODE + 103 - const val WPMEDIA_LIBRARY_PICK_DOWNLOADABLE_FILE = BASE_REQUEST_CODE + 104 - const val PRODUCT_INVENTORY_BACKORDERS = BASE_REQUEST_CODE + 301 const val PRODUCT_INVENTORY_STOCK_STATUS = BASE_REQUEST_CODE + 302 const val PRODUCT_TAX_STATUS = BASE_REQUEST_CODE + 304 diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt index 2c62f24801b..99c295c8151 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsEvent.kt @@ -58,14 +58,7 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { SIGNUP_SOCIAL_BUTTON_FAILURE(siteless = true), SIGNUP_SOCIAL_TO_LOGIN(siteless = true), ADDED_SELF_HOSTED_SITE(siteless = true), - CREATED_ACCOUNT(siteless = true), - LOGIN_PROLOGUE_JETPACK_LOGIN_BUTTON_TAPPED(siteless = true), - LOGIN_PROLOGUE_JETPACK_CONFIGURATION_INSTRUCTIONS_LINK_TAPPED(siteless = true), LOGIN_JETPACK_REQUIRED_SCREEN_VIEWED(siteless = true), - LOGIN_JETPACK_REQUIRED_VIEW_INSTRUCTIONS_BUTTON_TAPPED(siteless = true), - LOGIN_JETPACK_REQUIRED_WHAT_IS_JETPACK_LINK_TAPPED(siteless = true), - LOGIN_JETPACK_REQUIRED_MENU_HELP_TAPPED(siteless = true), - LOGIN_JETPACK_REQUIRED_SIGN_IN_LINK_TAPPED(siteless = true), LOGIN_WHAT_IS_JETPACK_HELP_SCREEN_VIEWED(siteless = true), LOGIN_WHAT_IS_JETPACK_HELP_SCREEN_LEARN_MORE_BUTTON_TAPPED(siteless = true), LOGIN_WHAT_IS_JETPACK_HELP_SCREEN_OK_BUTTON_TAPPED(siteless = true), @@ -76,7 +69,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { LOGIN_FIND_CONNECTED_EMAIL_HELP_SCREEN_NEED_MORE_HELP_LINK_TAPPED(siteless = true), LOGIN_FIND_CONNECTED_EMAIL_HELP_SCREEN_OK_BUTTON_TAPPED(siteless = true), LOGIN_NO_JETPACK_SCREEN_VIEWED(siteless = true), - LOGIN_NO_JETPACK_VIEW_INSTRUCTIONS_BUTTON_TAPPED(siteless = true), LOGIN_NO_JETPACK_LOGOUT_LINK_TAPPED(siteless = true), LOGIN_NO_JETPACK_TRY_AGAIN_TAPPED(siteless = true), LOGIN_NO_JETPACK_MENU_HELP_TAPPED(siteless = true), @@ -98,7 +90,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { UNIFIED_LOGIN_STEP(siteless = true), UNIFIED_LOGIN_FAILURE(siteless = true), UNIFIED_LOGIN_INTERACTION(siteless = true), - LOGIN_NEW_TO_WOO_BUTTON_TAPPED(siteless = true), LOGIN_JETPACK_SETUP_BUTTON_TAPPED(siteless = true), LOGIN_JETPACK_SETUP_DISMISSED(siteless = true), LOGIN_JETPACK_SETUP_COMPLETED(siteless = true), @@ -125,12 +116,8 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { SITE_PICKER_AUTO_LOGIN_SUBMITTED(siteless = true), SITE_PICKER_AUTO_LOGIN_ERROR_NOT_CONNECTED_TO_USER(siteless = true), SITE_PICKER_AUTO_LOGIN_ERROR_NOT_WOO_STORE(siteless = true), - SITE_PICKER_AUTO_LOGIN_ERROR_NOT_CONNECTED_JETPACK(siteless = true), - SITE_PICKER_TRY_ANOTHER_ACCOUNT_BUTTON_TAPPED(siteless = true), - SITE_PICKER_TRY_ANOTHER_STORE_BUTTON_TAPPED(siteless = true), SITE_PICKER_VIEW_CONNECTED_STORES_BUTTON_TAPPED(siteless = true), SITE_PICKER_HELP_FINDING_CONNECTED_EMAIL_LINK_TAPPED(siteless = true), - SITE_PICKER_NOT_WOO_STORE_REFRESH_APP_LINK_TAPPED(siteless = true), SITE_PICKER_NOT_CONNECTED_JETPACK_REFRESH_APP_LINK_TAPPED(siteless = true), SITE_PICKER_NON_WOO_SITE_TAPPED(siteless = true), SITE_PICKER_NEW_TO_WOO_TAPPED(siteless = true), @@ -169,15 +156,12 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { // -- Dashboard DASHBOARD_PULLED_TO_REFRESH, DASHBOARD_SHARE_YOUR_STORE_BUTTON_TAPPED, - DASHBOARD_UNFULFILLED_ORDERS_BUTTON_TAPPED, DASHBOARD_MAIN_STATS_DATE, DASHBOARD_MAIN_STATS_LOADED, DASHBOARD_TOP_PERFORMERS_DATE, DASHBOARD_TOP_PERFORMERS_LOADED, DASHBOARD_NEW_STATS_REVERTED_BANNER_DISMISS_TAPPED, DASHBOARD_NEW_STATS_REVERTED_BANNER_LEARN_MORE_TAPPED, - DASHBOARD_NEW_STATS_AVAILABILITY_BANNER_CANCEL_TAPPED, - DASHBOARD_NEW_STATS_AVAILABILITY_BANNER_TRY_TAPPED, DASHBOARD_WAITING_TIME_LOADED, DASHBOARD_SEE_MORE_ANALYTICS_TAPPED, USED_ANALYTICS, @@ -190,7 +174,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { ORDERS_LIST_FILTER, ORDERS_LIST_SEARCH, ORDERS_LIST_LOADED, - ORDERS_LIST_SHARE_YOUR_STORE_BUTTON_TAPPED, ORDERS_LIST_PULLED_TO_REFRESH, ORDERS_LIST_MENU_SEARCH_TAPPED, ORDERS_LIST_VIEW_FILTER_OPTIONS_TAPPED, @@ -201,8 +184,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { IPP_FEEDBACK_BANNER_DISMISSED, IPP_FEEDBACK_BANNER_CTA_TAPPED, - // -- Order filter by status dialog - FILTER_ORDERS_BY_STATUS_DIALOG_APPLY_FILTER_BUTTON_TAPPED, FILTER_ORDERS_BY_STATUS_DIALOG_OPTION_SELECTED, ORDER_FILTER_LIST_CLEAR_MENU_BUTTON_TAPPED, @@ -226,21 +207,17 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { JITM_DISMISS_SUCCESS, JITM_DISMISS_FAILURE, - // -- Simple Payments - SIMPLE_PAYMENTS_FLOW_STARTED, PAYMENTS_FLOW_CANCELED, SIMPLE_PAYMENTS_FLOW_NOTE_ADDED, SIMPLE_PAYMENTS_FLOW_TAXES_TOGGLED, // -- Order Detail ORDER_OPEN, - ORDER_NOTES_LOADED, ORDER_CONTACT_ACTION, ORDER_CONTACT_ACTION_FAILED, ORDER_STATUS_CHANGE, ORDER_STATUS_CHANGE_FAILED, ORDER_STATUS_CHANGE_SUCCESS, - ORDER_STATUS_CHANGE_UNDO, ORDER_DETAIL_PULLED_TO_REFRESH, ORDER_DETAIL_ADD_NOTE_BUTTON_TAPPED, ORDER_DETAIL_CUSTOMER_INFO_SHOW_BILLING_TAPPED, @@ -249,14 +226,7 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { ORDER_DETAIL_CUSTOMER_INFO_PHONE_MENU_PHONE_TAPPED, ORDER_DETAIL_CUSTOMER_INFO_PHONE_MENU_SMS_TAPPED, ORDER_DETAIL_FULFILL_ORDER_BUTTON_TAPPED, - ORDER_DETAIL_ORDER_STATUS_EDIT_BUTTON_TAPPED, ORDER_DETAIL_PRODUCT_TAPPED, - ORDER_DETAIL_PRODUCT_DETAIL_BUTTON_TAPPED, - ORDER_TRACKING_LOADED, - ORDER_DETAIL_TRACKING_DELETE_BUTTON_TAPPED, - ORDER_DETAIL_TRACKING_ADD_TRACKING_BUTTON_TAPPED, - ORDER_DETAIL_ISSUE_REFUND_BUTTON_TAPPED, - ORDER_DETAIL_VIEW_REFUND_DETAILS_BUTTON_TAPPED, ORDER_DETAIL_CREATE_SHIPPING_LABEL_BUTTON_TAPPED, ORDER_DETAIL_WAITING_TIME_LOADED, ORDER_VIEW_CUSTOM_FIELDS_TAPPED, @@ -293,7 +263,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { CREATE_ORDER_REFUND_ITEM_QUANTITY_DIALOG_OPENED, CREATE_ORDER_REFUND_PRODUCT_AMOUNT_DIALOG_OPENED, CREATE_ORDER_REFUND_SUMMARY_REFUND_BUTTON_TAPPED, - CREATE_ORDER_REFUND_SUMMARY_UNDO_BUTTON_TAPPED, REFUND_CREATE, REFUND_CREATE_SUCCESS, REFUND_CREATE_FAILED, @@ -421,7 +390,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { SETTING_CHANGE, SETTING_CHANGE_FAILED, SETTING_CHANGE_SUCCESS, - SETTINGS_SELECTED_SITE_TAPPED, SETTINGS_LOGOUT_BUTTON_TAPPED, SETTINGS_LOGOUT_CONFIRMATION_DIALOG_RESULT, SETTINGS_BETA_FEATURES_BUTTON_TAPPED, @@ -432,7 +400,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { SETTINGS_ABOUT_OPEN_SOURCE_LICENSES_LINK_TAPPED, SETTINGS_NOTIFICATIONS_OPEN_CHANNEL_SETTINGS_BUTTON_TAPPED, SETTINGS_WE_ARE_HIRING_BUTTON_TAPPED, - SETTINGS_BETA_FEATURES_PRODUCTS_TOGGLED, SETTINGS_IMAGE_OPTIMIZATION_TOGGLED, SETTINGS_CARD_PRESENT_SELECT_PAYMENT_GATEWAY_TAPPED, PRIVACY_SETTINGS_COLLECT_INFO_TOGGLED, @@ -476,7 +443,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { PRODUCT_DETAIL_SHARE_BUTTON_TAPPED, PRODUCT_DETAIL_UPDATE_BUTTON_TAPPED, PRODUCT_DETAIL_VIEW_EXTERNAL_TAPPED, - PRODUCT_DETAIL_VIEW_AFFILIATE_TAPPED, PRODUCT_DETAIL_VIEW_PRODUCT_VARIANTS_TAPPED, PRODUCT_DETAIL_VIEW_PRODUCT_DESCRIPTION_TAPPED, PRODUCT_DETAIL_VIEW_PRICE_SETTINGS_TAPPED, @@ -530,8 +496,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { REVIEW_REPLY_SEND_SUCCESS, REVIEW_REPLY_SEND_FAILED, - // -- Downloadable Files - PRODUCT_DOWNLOADABLE_FILES_SETTINGS_CHANGED, PRODUCTS_DOWNLOADABLE_FILE, // -- Linked Products @@ -588,8 +552,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { PRODUCT_ADDONS_ORDER_DETAIL_VIEW_PRODUCT_ADDONS_TAPPED, PRODUCT_ADDONS_REFUND_DETAIL_VIEW_PRODUCT_ADDONS_TAPPED, - // -- Product settings - PRODUCT_SETTINGS_DONE_BUTTON_TAPPED, PRODUCT_DETAIL_ADD_IMAGE_TAPPED, PRODUCT_IMAGE_SETTINGS_ADD_IMAGES_BUTTON_TAPPED, PRODUCT_IMAGE_SETTINGS_ADD_IMAGES_SOURCE_TAPPED, @@ -600,16 +562,12 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { PRODUCT_SETTINGS_PURCHASE_NOTE_TAPPED, PRODUCT_SETTINGS_VISIBILITY_TAPPED, PRODUCT_SETTINGS_MENU_ORDER_TAPPED, - PRODUCT_SETTINGS_VIRTUAL_TOGGLED, PRODUCT_SETTINGS_REVIEWS_TOGGLED, // -- Product filters PRODUCT_FILTER_LIST_SHOW_PRODUCTS_BUTTON_TAPPED, PRODUCT_FILTER_LIST_CLEAR_MENU_BUTTON_TAPPED, - // -- Aztec editor - AZTEC_EDITOR_DONE_BUTTON_TAPPED, - // -- Product variations PRODUCT_VARIANTS_PULLED_TO_REFRESH, PRODUCT_VARIANTS_LOADED, @@ -624,7 +582,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { // -- Product images PRODUCT_IMAGE_ADDED, - PRODUCT_IMAGE_REMOVED, // -- Duplicate product DUPLICATE_PRODUCT_SUCCESS, @@ -636,9 +593,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { SUPPORT_IDENTITY_SET(siteless = true), SUPPORT_IDENTITY_FORM_VIEWED(siteless = true), SUPPORT_APPLICATION_LOG_VIEWED(siteless = true), - SUPPORT_TICKETS_VIEWED(siteless = true), - SUPPORT_FAQ_VIEWED(siteless = true), - SUPPORT_SSR_OPENED, SUPPORT_SSR_COPY_BUTTON_TAPPED, // -- Push notifications @@ -660,7 +614,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { REVIEWS_MARK_ALL_READ_FAILED, REVIEWS_LIST_PULLED_TO_REFRESH, REVIEWS_LIST_MENU_MARK_READ_BUTTON_TAPPED, - REVIEWS_LIST_SHARE_YOUR_STORE_BUTTON_TAPPED, // -- Product Review Detail REVIEW_OPEN, @@ -674,8 +627,6 @@ enum class AnalyticsEvent(val siteless: Boolean = false) { REVIEW_ACTION, REVIEW_ACTION_FAILED, REVIEW_ACTION_SUCCESS, - REVIEW_ACTION_UNDO, - SNACK_REVIEW_ACTION_APPLIED_UNDO_BUTTON_TAPPED, REVIEW_DETAIL_APPROVE_BUTTON_TAPPED, REVIEW_DETAIL_OPEN_EXTERNAL_BUTTON_TAPPED, REVIEW_DETAIL_SPAM_BUTTON_TAPPED, diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsTracker.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsTracker.kt index 7fd5d870cfe..daef78682dd 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsTracker.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/analytics/AnalyticsTracker.kt @@ -143,8 +143,6 @@ class AnalyticsTracker private constructor(private val context: Context) { const val KEY_ERROR_DESC = "error_description" const val KEY_ERROR_TYPE = "error_type" const val KEY_ERROR_CODE = "error_code" - const val KEY_NETWORK_STATUS_CODE = "network_status_code" - const val KEY_ERROR_MESSAGE = "error_message" const val KEY_FROM = "from" const val KEY_HAS_UNFULFILLED_ORDERS = "has_unfulfilled_orders" const val KEY_ID = "id" @@ -208,9 +206,7 @@ class AnalyticsTracker private constructor(private val context: Context) { const val VALUE_API_FAILED = "failed" const val VALUE_SHIPMENT_TRACK = "track" const val VALUE_SHIPMENT_COPY = "copy" - const val VALUE_ORDER = "order" const val VALUE_REVIEW = "review" - const val VALUE_ORDER_DETAIL = "order_detail" const val VALUE_STARTED = "started" const val VALUE_PURCHASE_INITIATED = "purchase_initiated" const val VALUE_ORIGIN_ADDRESS_STARTED = "origin_address_started" @@ -247,12 +243,6 @@ class AnalyticsTracker private constructor(private val context: Context) { const val KEY_HAS_MULTIPLE_SHIPPING_LINES = "has_multiple_shipping_lines" const val KEY_HAS_MULTIPLE_FEE_LINES = "has_multiple_fee_lines" - const val KEY_CARD = "card" - const val VALUE_REVENUE_CARD_SELECTED = "revenue" - const val VALUE_ORDERS_CARD_SELECTED = "orders" - const val VALUE_PRODUCTS_CARD_SELECTED = "products" - const val VALUE_VISITORS_CARD_SELECTED = "visitors" - const val JITM_ID = "jitm_id" const val JITM_FEATURE_CLASS = "feature_class" @@ -422,9 +412,6 @@ class AnalyticsTracker private constructor(private val context: Context) { const val KEY_IS_ENABLED = "is_enabled" const val KEY_CASH_ON_DELIVERY_SOURCE = "source" - // -- Experiments - const val KEY_EXPERIMENT_VARIANT = "experiment_variant" - // -- Help Center const val KEY_SOURCE_FLOW = "source_flow" const val KEY_SOURCE_STEP = "source_step" diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/di/ActivityBindingModule.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/di/ActivityBindingModule.kt deleted file mode 100644 index 279d3e8f993..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/di/ActivityBindingModule.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.woocommerce.android.di - -import com.woocommerce.android.ui.login.MagicLinkInterceptActivity -import dagger.Module -import dagger.android.ContributesAndroidInjector -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@InstallIn(SingletonComponent::class) -@Module -abstract class ActivityBindingModule { - @ActivityScope - @ContributesAndroidInjector - abstract fun provideMagicLinkInterceptActivityInjector(): MagicLinkInterceptActivity -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/di/LoginFragmentsModule.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/di/LoginFragmentsModule.kt deleted file mode 100644 index c9f30ba5f25..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/di/LoginFragmentsModule.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.woocommerce.android.di - -import com.woocommerce.android.ui.login.overrides.WooLoginEmailFragment -import com.woocommerce.android.ui.login.overrides.WooLoginEmailPasswordFragment -import com.woocommerce.android.ui.login.overrides.WooLoginSiteAddressFragment -import dagger.Module -import dagger.android.ContributesAndroidInjector -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent - -@InstallIn(SingletonComponent::class) -@Module -abstract class LoginFragmentsModule { - @ContributesAndroidInjector - abstract fun provideWooLoginSiteAddressFragment(): WooLoginSiteAddressFragment - - @ContributesAndroidInjector - abstract fun provideWooLoginEmailFragment(): WooLoginEmailFragment - - @ContributesAndroidInjector - abstract fun provideWooLoginEmailPasswordFragment(): WooLoginEmailPasswordFragment -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/CollectionUtilsExt.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/CollectionUtilsExt.kt deleted file mode 100644 index cac971fbf0f..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/CollectionUtilsExt.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.woocommerce.android.extensions - -/** - * Extension function that applies a transformation method on each of the list members, then - * returns the list for chaining. - * - * Example: - *
someList.applyTransform { num -> num * 2 }
- * - * Based on: https://stackoverflow.com/questions/50465292/how-to-apply-map-function-to-array-in-kotlin-and-change-its-values/50466530#50466530 - */ -fun List.applyTransform(transform: (T) -> T): List { - for (i in this.indices) { - transform(this[i]) - } - return this -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/DateExt.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/DateExt.kt index 2a9f1c1751d..ce18f89bb74 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/DateExt.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/DateExt.kt @@ -2,9 +2,6 @@ package com.woocommerce.android.extensions import android.content.Context import android.text.format.DateFormat -import com.woocommerce.android.util.WooLog -import com.woocommerce.android.util.WooLog.T -import org.apache.commons.lang3.time.DateUtils.isSameDay import java.text.DateFormatSymbols import java.text.SimpleDateFormat import java.util.Calendar @@ -61,20 +58,8 @@ fun Date.formatToEEEEMMMddhha(locale: Locale): String { return dateFormat.format(this) } -fun Date.isToday() = - try { - isSameDay(Date(), this) - } catch (e: Exception) { - with("Unable to match dateString with today date. (current dateString value: $this)") { - WooLog.e(T.UTILS, this) - } - null - } - fun Date.getTimeString(context: Context): String = DateFormat.getTimeFormat(context).format(this.time) -fun Date.getShortDate(context: Context): String = DateFormat.getDateFormat(context).format(this) - fun Date.getMediumDate(context: Context): String = DateFormat.getMediumDateFormat(context).format(this) fun Date.formatToYYYYmmDDhhmmss(): String = diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/EditTextExt.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/EditTextExt.kt index 71e49ec3b43..aec74b2093f 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/EditTextExt.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/EditTextExt.kt @@ -1,9 +1,6 @@ package com.woocommerce.android.extensions -import android.view.View -import android.view.autofill.AutofillManager import android.widget.EditText -import com.woocommerce.android.util.SystemVersionUtils import org.wordpress.android.util.ActivityUtils /** @@ -18,18 +15,4 @@ fun EditText.showKeyboardWithDelay(delayMs: Long = DEFAULT_KEYBOARD_DELAY) { ) } -fun EditText.requestPasswordAutoFillWithDelay(delayMs: Long = DEFAULT_AUTOFILL_DELAY) { - if (SystemVersionUtils.isAtLeastO()) { - setAutofillHints(View.AUTOFILL_HINT_PASSWORD) - importantForAutofill = View.IMPORTANT_FOR_AUTOFILL_YES - val af = context.getSystemService(AutofillManager::class.java) - postDelayed( - { - af.requestAutofill(this) - }, delayMs - ) - } -} - private const val DEFAULT_KEYBOARD_DELAY = 500L -private const val DEFAULT_AUTOFILL_DELAY = 500L diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/LiveDataExt.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/LiveDataExt.kt index dc9d521e69b..516ffa894de 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/LiveDataExt.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/LiveDataExt.kt @@ -3,8 +3,6 @@ package com.woocommerce.android.extensions import androidx.lifecycle.LiveData import androidx.lifecycle.MediatorLiveData import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.liveData -import androidx.lifecycle.switchMap fun MutableLiveData>.addNewItem(item: T) { val oldValue = this.value ?: mutableListOf() @@ -39,16 +37,6 @@ fun MutableLiveData>.clearList() { this.value?.clear() } -/** - * A helper function to map a LiveData's value to another one, with the ability to use a suspend function for the - * mapping - */ -fun LiveData.mapAsync(mapper: suspend (T) -> R): LiveData = switchMap { value -> - liveData { - emit(mapper(value)) - } -} - fun LiveData.drop(number: Int): LiveData { val outputLiveData: MediatorLiveData = MediatorLiveData() var remainingItemsToSkip: Int = number diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringDateFormatExt.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringDateFormatExt.kt index 4f3550b50a8..abf2f6d5ee3 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringDateFormatExt.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringDateFormatExt.kt @@ -157,20 +157,3 @@ fun String?.parseGmtDateFromIso8601DateFormat(locale: Locale = Locale.getDefault throw IllegalArgumentException("Date string argument is not of format yyyy-MM-dd'T'HH:mm:ss: $this") } } - -/** - * Method to convert month string from yyyy-MM-dd format to MMM dd - * i.e. 2018-08-08T08:12:03 is formatted to Aug 08 - */ -@Throws(IllegalArgumentException::class) -fun String?.formatDateToYYYYMMDDFormat(locale: Locale = Locale.getDefault()): Date? { - return try { - if (!this.isNullOrEmpty()) { - val originalFormat = SimpleDateFormat("yyyy-MM-dd", locale) - return originalFormat.parse(this) - } - null - } catch (e: Exception) { - throw IllegalArgumentException("Date string argument is not of format yyyy-MM-dd: $this") - } -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringExt.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringExt.kt index 8e697f0f23f..e16178b7885 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringExt.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/extensions/StringExt.kt @@ -2,11 +2,6 @@ package com.woocommerce.android.extensions import org.apache.commons.text.StringEscapeUtils -/** - * Checks if a given string is a number (supports positive or negative numbers) - */ -fun String?.isNumeric() = this?.toIntOrNull()?.let { true } ?: false - /** * Checks if a given string is a Float */ @@ -78,12 +73,6 @@ fun String.semverCompareTo(otherVersion: String): Int { } } -fun String.capitalizeWords(): String { - return this.split(" ").joinToString(" ") { word -> - word.replaceFirstChar { it.uppercase() } - } -} - /** * Returns this string if it's not empty or null otherwise. * Syntactic sugar for `string.ifEmpty { null }`. diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/tools/RateLimitedTask.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/tools/RateLimitedTask.kt index 8598ac1125b..1761badc319 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/tools/RateLimitedTask.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/tools/RateLimitedTask.kt @@ -6,14 +6,6 @@ import java.util.Date abstract class RateLimitedTask(private val minRateInSeconds: Int) { private var lastUpdate: Date? = null - @Synchronized fun forceRun(): Boolean { - if (run()) { - lastUpdate = Date() - return true - } - return false - } - @Synchronized fun runIfNotLimited(): Boolean { val now = Date() if (lastUpdate == null || DateTimeUtils.secondsBetween(now, lastUpdate) >= minRateInSeconds) { diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/tools/SiteConnectionType.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/tools/SiteConnectionType.kt index e8bfe33ed08..91df9ec7028 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/tools/SiteConnectionType.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/tools/SiteConnectionType.kt @@ -1,17 +1,11 @@ package com.woocommerce.android.tools import com.woocommerce.android.BuildConfig -import com.woocommerce.android.tools.AuthenticationType.SiteCredentials -import com.woocommerce.android.tools.AuthenticationType.WPCom import com.woocommerce.android.util.WooLog import org.wordpress.android.fluxc.model.SiteModel -enum class SiteConnectionType(val authenticationType: AuthenticationType) { - Jetpack(WPCom), JetpackConnectionPackage(WPCom), ApplicationPasswords(SiteCredentials) -} - -enum class AuthenticationType { - WPCom, SiteCredentials +enum class SiteConnectionType { + Jetpack, JetpackConnectionPackage, ApplicationPasswords } val SiteModel.connectionType diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/common/wpcomwebview/WPComWebViewClient.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/common/wpcomwebview/WPComWebViewClient.kt deleted file mode 100644 index 054a6ee25b8..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/common/wpcomwebview/WPComWebViewClient.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.woocommerce.android.ui.common.wpcomwebview - -import android.webkit.WebView -import android.webkit.WebViewClient - -class WPComWebViewClient(private val urlInterceptor: UrlInterceptor) : WebViewClient() { - override fun onLoadResource(view: WebView?, url: String?) { - super.onLoadResource(view, url) - url?.let { urlInterceptor.onLoadUrl(url) } - } - - override fun doUpdateVisitedHistory(view: WebView?, url: String?, isReload: Boolean) { - super.doUpdateVisitedHistory(view, url, isReload) - url?.let { urlInterceptor.onLoadUrl(url) } - } -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/UnifiedLoginTracker.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/UnifiedLoginTracker.kt index c4b72edcf0d..4f4eac1c5d2 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/UnifiedLoginTracker.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/UnifiedLoginTracker.kt @@ -104,10 +104,6 @@ class UnifiedLoginTracker } } - fun setSource(source: Source) { - currentSource = source - } - fun setSource(value: String) { Source.values().find { it.value == value }?.let { currentSource = it diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/qrcode/CameraPermissionUtils.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/qrcode/CameraPermissionUtils.kt deleted file mode 100644 index a8382ff0744..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/login/qrcode/CameraPermissionUtils.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.woocommerce.android.ui.login.qrcode - -import android.app.Activity -import com.woocommerce.android.R -import com.woocommerce.android.ui.dialog.WooDialog -import com.woocommerce.android.util.WooPermissionUtils - -fun showCameraPermissionDeniedDialog(activity: Activity) { - WooDialog.showDialog( - activity, - titleId = R.string.qr_code_login_camera_permission_denied_title, - messageId = R.string.qr_code_login_camera_permission_denied_message, - positiveButtonId = R.string.qr_code_login_edit_camera_permission, - negativeButtonId = R.string.cancel, - posBtnAction = { dialog, _ -> - WooPermissionUtils.showAppSettings(activity) - dialog.dismiss() - }, - negBtnAction = { dialog, _ -> dialog.dismiss() }, - ) -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/mystore/RoundedBarChartRenderer.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/mystore/RoundedBarChartRenderer.kt deleted file mode 100644 index e2a90d58880..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/mystore/RoundedBarChartRenderer.kt +++ /dev/null @@ -1,169 +0,0 @@ -package com.woocommerce.android.ui.mystore - -import android.graphics.Canvas -import android.graphics.Path -import android.graphics.RectF -import com.github.mikephil.charting.animation.ChartAnimator -import com.github.mikephil.charting.highlight.Highlight -import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider -import com.github.mikephil.charting.interfaces.datasets.IBarDataSet -import com.github.mikephil.charting.renderer.BarChartRenderer -import com.github.mikephil.charting.utils.Utils -import com.github.mikephil.charting.utils.ViewPortHandler -import kotlin.math.ceil - -/** - * Custom [BarChartRenderer] to handle rounded corner bars for our stats screen. This custom class takes in - * an additional param [mRadius] which is used to determine the radius of the rounded corners. - * - * Round corner bars are not supported in MPAndroidChart lib and based on some suggestions from - * StackOverFlow, the logic is to override the [drawDataSet] method of the [BarChartRenderer] class - * and draw the bars with rounded corners: - * - * https://stackoverflow.com/questions/30761082/mpandroidchart-round-edged-bar-chart - */ -class RoundedBarChartRenderer internal constructor( - chart: BarDataProvider?, - animator: ChartAnimator?, - viewPortHandler: ViewPortHandler?, - private val mRadius: Float -) : BarChartRenderer(chart, animator, viewPortHandler) { - private val mBarShadowRectBuffer: RectF = RectF() - - override fun drawHighlighted(c: Canvas, indices: Array) { - val barData = mChart.barData - for (high in indices) { - val set = barData.getDataSetByIndex(high.dataSetIndex) - if (set == null || !set.isHighlightEnabled) continue - - val e = set.getEntryForXValue(high.x, high.y) - if (!isInBoundsX(e, set)) continue - - val trans = mChart.getTransformer(set.axisDependency) - mHighlightPaint.color = set.highLightColor - mHighlightPaint.alpha = set.highLightAlpha - - val isStack = high.stackIndex >= 0 && e.isStacked - val y1: Float - val y2: Float - if (isStack) { - if (mChart.isHighlightFullBarEnabled) { - y1 = e.positiveSum - y2 = -e.negativeSum - } else { - val range = e.ranges[high.stackIndex] - y1 = range.from - y2 = range.to - } - } else { - y1 = e.y - y2 = 0f - } - prepareBarHighlight(e.x, y1, y2, barData.barWidth / 2f, trans) - setHighlightDrawPos(high, mBarRect) - c.drawRoundRect(mBarRect, mRadius, mRadius, mHighlightPaint) - } - } - - @Suppress("LoopWithTooManyJumpStatements", "LongMethod", "ComplexMethod") - override fun drawDataSet(c: Canvas, dataSet: IBarDataSet, index: Int) { - val trans = mChart.getTransformer(dataSet.axisDependency) - mBarBorderPaint.color = dataSet.barBorderColor - mBarBorderPaint.strokeWidth = Utils.convertDpToPixel(dataSet.barBorderWidth) - val drawBorder = dataSet.barBorderWidth > 0f - val phaseX = mAnimator.phaseX - val phaseY = mAnimator.phaseY - - // draw the bar shadow before the values - if (mChart.isDrawBarShadowEnabled) { - mShadowPaint.color = dataSet.barShadowColor - val barData = mChart.barData - val barWidth = barData.barWidth - val barWidthHalf = barWidth / 2.0f - var x: Float - var i = 0 - val count = ceil(dataSet.entryCount.toFloat() * phaseX.toDouble()).toInt() - .coerceAtMost(dataSet.entryCount) - - while (i < count) { - val e = dataSet.getEntryForIndex(i) - x = e.x - mBarShadowRectBuffer.left = x - barWidthHalf - mBarShadowRectBuffer.right = x + barWidthHalf - trans.rectValueToPixel(mBarShadowRectBuffer) - if (!mViewPortHandler.isInBoundsLeft(mBarShadowRectBuffer.right)) { - i++ - continue - } - if (!mViewPortHandler.isInBoundsRight(mBarShadowRectBuffer.left)) { - break - } - - mBarShadowRectBuffer.top = mViewPortHandler.contentTop() - mBarShadowRectBuffer.bottom = mViewPortHandler.contentBottom() - c.drawRoundRect(mBarShadowRectBuffer, mRadius, mRadius, mShadowPaint) - i++ - } - } - - // initialize the buffer - val buffer = mBarBuffers[index] - buffer.setPhases(phaseX, phaseY) - buffer.setDataSet(index) - buffer.setInverted(mChart.isInverted(dataSet.axisDependency)) - buffer.setBarWidth(mChart.barData.barWidth) - buffer.feed(dataSet) - trans.pointValuesToPixel(buffer.buffer) - val isSingleColor = dataSet.colors.size == 1 - if (isSingleColor) { - mRenderPaint.color = dataSet.color - } - var j = 0 - while (j < buffer.size()) { - if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2])) { - j += 4 - continue - } - if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j])) break - if (!isSingleColor) { - mRenderPaint.color = dataSet.getColor(j / 4) - } - - // Since the bar chart can contain negative and positive values, we first get the current y axis value - // that is being rendered here.If the value is negative, only the bottom right and bottom left corners - // of the bar is rounded. Similarly, if the value is positive, the top right and top left corners of - // the bar is rounded. - val barEntry = dataSet.getEntryForIndex(j / 4) - val corners = if (barEntry != null && barEntry.y < 0) { - floatArrayOf( - 0f, 0f, // Top left corner - 0f, 0f, // Top right corner - mRadius, mRadius, // Bottom right corner - mRadius, mRadius // Bottom left corner - ) - } else { - floatArrayOf( - mRadius, mRadius, // Top left corner - mRadius, mRadius, // Top right corner - 0f, 0f, // Bottom right corner - 0f, 0f // Bottom left corner - ) - } - - val path = Path() - path.addRoundRect( - RectF( - buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], - buffer.buffer[j + 3] - ), - corners, Path.Direction.CW - ) - c.drawPath(path, mRenderPaint) - - if (drawBorder) { - c.drawPath(path, mBarBorderPaint) - } - j += 4 - } - } -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListFragment.kt index 5201bc9fb3b..dc8f9c31ed8 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListFragment.kt @@ -73,7 +73,6 @@ class OrderListFragment : const val STATE_KEY_SEARCH_QUERY = "search-query" const val STATE_KEY_IS_SEARCHING = "is_searching" const val FILTER_CHANGE_NOTICE_KEY = "filters_changed_notice" - const val SWIPE_GLANCE_ANIMATION_DURATION_MILLIS = 300L } @Inject internal lateinit var uiMessageResolver: UIMessageResolver diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListType.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListType.kt deleted file mode 100644 index 41341f9deff..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListType.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.woocommerce.android.ui.orders.list - -enum class OrderListType { - ALL, - PROCESSING, - SEARCH -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListView.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListView.kt index d4f86680edc..8ab670e7f8e 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListView.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListView.kt @@ -1,7 +1,6 @@ package com.woocommerce.android.ui.orders.list import android.content.Context -import android.os.Parcelable import android.util.AttributeSet import android.view.LayoutInflater import android.widget.LinearLayout @@ -88,21 +87,11 @@ class OrderListView @JvmOverloads constructor( binding.ordersList.smoothScrollToPosition(0) } - fun getCurrentPosition() = - (binding.ordersList.layoutManager as? LinearLayoutManager)?.findFirstVisibleItemPosition() ?: 0 - /** * save the order list on configuration change */ fun onFragmentSavedInstanceState() = binding.ordersList.layoutManager?.onSaveInstanceState() - /** - * restore the order list on configuration change - */ - fun onFragmentRestoreInstanceState(listState: Parcelable) { - binding.ordersList.layoutManager?.onRestoreInstanceState(listState) - } - fun setLoadingMoreIndicator(active: Boolean) { binding.loadMoreProgressbar.isVisible = active } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListViewModel.kt index 47768e0b6d2..15e38c89c9c 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListViewModel.kt @@ -693,10 +693,4 @@ class OrderListViewModel @Inject constructor( val bannerData: GetIPPFeedbackBannerData.IPPFeedbackBanner, ) : IPPSurveyFeedbackBannerState() } - - companion object { - const val UTM_CAMPAIGN = "feature_announcement_card" - const val UTM_SOURCE = "orders_list" - const val UTM_CONTENT = "upsell_card_readers" - } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/ShippingLabelActionListener.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/ShippingLabelActionListener.kt deleted file mode 100644 index d41d98ed6c6..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/ShippingLabelActionListener.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.woocommerce.android.ui.orders.shippinglabels - -interface ShippingLabelActionListener { - fun openShippingLabelRefund(orderId: Long, shippingLabelId: Long) -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/creation/ShippingLabelCreatePackageViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/creation/ShippingLabelCreatePackageViewModel.kt index b09ebbcc35c..e0173d33ace 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/creation/ShippingLabelCreatePackageViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/shippinglabels/creation/ShippingLabelCreatePackageViewModel.kt @@ -46,7 +46,6 @@ class ShippingLabelCreatePackageViewModel @Inject constructor( } val viewStateData = LiveDataDelegate(savedState, ShippingLabelCreatePackageViewState()) - private var viewState by viewStateData @Parcelize data class ShippingLabelCreatePackageViewState( diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/tracking/AddOrderTrackingProviderActionListener.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/tracking/AddOrderTrackingProviderActionListener.kt deleted file mode 100644 index 446b63ac663..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/tracking/AddOrderTrackingProviderActionListener.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.woocommerce.android.ui.orders.tracking - -interface AddOrderTrackingProviderActionListener { - fun onTrackingProviderSelected(selectedCarrierName: String) -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/tracking/AddOrderTrackingProviderListAdapter.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/tracking/AddOrderTrackingProviderListAdapter.kt index b9b7f22c8b9..992b8be0994 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/tracking/AddOrderTrackingProviderListAdapter.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/tracking/AddOrderTrackingProviderListAdapter.kt @@ -43,29 +43,6 @@ class AddOrderTrackingProviderListAdapter( providerSearchList.addAll(providerList) } - fun clearAdapterData() { - if (providerList.isNotEmpty()) { - removeAllSections() - providerList.clear() - notifyDataSetChanged() - } - } - - /** - * returns the total item count in a given section - * @param title = the title of the section - */ - fun getSectionItemsTotal(title: String): Int { - for (entry in sectionsMap) { - (entry.value as? ProviderListSection)?.let { - if (title == it.country) { - return it.list.size - } - } - } - return 0 - } - private fun updateAdapter(providers: List) { // clear all the current data from the adapter removeAllSections() diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/refunds/IssueRefundViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/refunds/IssueRefundViewModel.kt index 366a50a68b3..ed055a50da0 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/refunds/IssueRefundViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/refunds/IssueRefundViewModel.kt @@ -8,7 +8,6 @@ import com.woocommerce.android.R import com.woocommerce.android.WooException import com.woocommerce.android.analytics.AnalyticsEvent.CREATE_ORDER_REFUND_ITEM_QUANTITY_DIALOG_OPENED import com.woocommerce.android.analytics.AnalyticsEvent.CREATE_ORDER_REFUND_NEXT_BUTTON_TAPPED -import com.woocommerce.android.analytics.AnalyticsEvent.CREATE_ORDER_REFUND_PRODUCT_AMOUNT_DIALOG_OPENED import com.woocommerce.android.analytics.AnalyticsEvent.CREATE_ORDER_REFUND_SELECT_ALL_ITEMS_BUTTON_TAPPED import com.woocommerce.android.analytics.AnalyticsEvent.CREATE_ORDER_REFUND_SUMMARY_REFUND_BUTTON_TAPPED import com.woocommerce.android.analytics.AnalyticsEvent.CREATE_ORDER_REFUND_TAB_CHANGED @@ -41,7 +40,6 @@ import com.woocommerce.android.ui.payments.refunds.IssueRefundViewModel.InputVal import com.woocommerce.android.ui.payments.refunds.IssueRefundViewModel.IssueRefundEvent.HideValidationError import com.woocommerce.android.ui.payments.refunds.IssueRefundViewModel.IssueRefundEvent.OpenUrl import com.woocommerce.android.ui.payments.refunds.IssueRefundViewModel.IssueRefundEvent.ShowNumberPicker -import com.woocommerce.android.ui.payments.refunds.IssueRefundViewModel.IssueRefundEvent.ShowRefundAmountDialog import com.woocommerce.android.ui.payments.refunds.IssueRefundViewModel.IssueRefundEvent.ShowRefundConfirmation import com.woocommerce.android.ui.payments.refunds.IssueRefundViewModel.IssueRefundEvent.ShowRefundSummary import com.woocommerce.android.ui.payments.refunds.IssueRefundViewModel.IssueRefundEvent.ShowValidationError @@ -572,22 +570,6 @@ class IssueRefundViewModel @Inject constructor( refundSummaryState = refundSummaryState.copy(isSummaryTextTooLong = currLength > maxLength) } - // will be used in the future - fun onProductRefundAmountTapped() { - triggerEvent( - ShowRefundAmountDialog( - refundByItemsState.productsRefund, - maxRefund, - resourceProvider.getString(R.string.order_refunds_available_for_refund, formatCurrency(maxRefund)) - ) - ) - - analyticsTrackerWrapper.track( - CREATE_ORDER_REFUND_PRODUCT_AMOUNT_DIALOG_OPENED, - mapOf(AnalyticsTracker.KEY_ORDER_ID to order.id) - ) - } - fun onProductsRefundAmountChanged(newAmount: BigDecimal) { refundByItemsState = refundByItemsState.copy( productsRefund = newAmount, diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/simplepayments/SimplePaymentsSharedViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/simplepayments/SimplePaymentsSharedViewModel.kt index cca5372cd93..82fb0c6662e 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/simplepayments/SimplePaymentsSharedViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/simplepayments/SimplePaymentsSharedViewModel.kt @@ -17,15 +17,8 @@ class SimplePaymentsSharedViewModel @Inject constructor( val currencyCode: String get() = wooCommerceStore.getSiteSettings(selectedSite.get())?.currencyCode ?: "" - val decimals: Int - get() = wooCommerceStore.getSiteSettings(selectedSite.get())?.currencyDecimalNumber ?: DEFAULT_DECIMAL_PRECISION - init { // Reset order duration recorder to ensure we don't track Simple Payments flow OrderDurationRecorder.reset() } - - companion object { - private const val DEFAULT_DECIMAL_PRECISION = 2 - } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/WCSettingsOptionValueView.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/WCSettingsOptionValueView.kt index 1a3e19bd37c..9c1ee3684d2 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/WCSettingsOptionValueView.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/WCSettingsOptionValueView.kt @@ -75,10 +75,6 @@ class WCSettingsOptionValueView @JvmOverloads constructor( } } - var optionTitle: String - get() { return binding.optionTitle.text.toString() } - set(value) { binding.optionTitle.text = value } - var optionValue: String? get() { return binding.optionValue.text.toString() } set(value) { diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/WCSettingsToggleOptionView.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/WCSettingsToggleOptionView.kt index c84b12a426c..3f7d814895a 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/WCSettingsToggleOptionView.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/prefs/WCSettingsToggleOptionView.kt @@ -2,7 +2,6 @@ package com.woocommerce.android.ui.prefs import android.R.attr import android.content.Context -import android.graphics.drawable.Drawable import android.util.AttributeSet import android.util.TypedValue import android.view.LayoutInflater @@ -83,12 +82,6 @@ class WCSettingsToggleOptionView @JvmOverloads constructor( get() = binding.toggleSettingDesc.text.toString() set(value) { UiHelpers.setTextOrHide(binding.toggleSettingDesc, value) } - var iconImageResource: Int? = null - set(value) { UiHelpers.setImageOrHideInLandscape(binding.toggleSettingIcon, value) } - - var iconDrawable: Drawable? = null - set(value) { UiHelpers.setDrawableOrHide(binding.toggleSettingIcon, value) } - private val checkable: CompoundButton by lazy { binding.toggleSettingSwitch } var listener: OnCheckedChangeListener? = null diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductDetailViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductDetailViewModel.kt index fd06b5a7d9b..7fdec07f1b2 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductDetailViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductDetailViewModel.kt @@ -569,7 +569,7 @@ class ProductDetailViewModel @Inject constructor( updateProductDraft(downloads = updatedDownloads) // If the downloads list is empty now, go directly to the product details screen if (updatedDownloads.isEmpty()) triggerEvent( - ProductExitEvent.ExitProductDownloads(shouldShowDiscardDialog = false) + ProductExitEvent.ExitProductDownloads() ) } } @@ -640,20 +640,6 @@ class ProductDetailViewModel @Inject constructor( fun hasExternalLinkChanges() = storedProduct.value?.hasExternalLinkChanges(viewState.productDraft) ?: false - fun hasLinkedProductChanges() = storedProduct.value?.hasLinkedProductChanges(viewState.productDraft) ?: false - - fun hasDownloadsChanges(): Boolean { - return storedProduct.value?.hasDownloadChanges(viewState.productDraft) ?: false - } - - fun hasDownloadsSettingsChanges(): Boolean { - return storedProduct.value?.let { - it.downloadLimit != viewState.productDraft?.downloadLimit || - it.downloadExpiry != viewState.productDraft?.downloadExpiry || - it.isDownloadable != viewState.productDraft?.isDownloadable - } ?: false - } - /** * Called when the back= button is clicked in a product sub detail screen */ @@ -1346,23 +1332,6 @@ class ProductDetailViewModel @Inject constructor( } } - /** - * Updates (replaces) a single attribute in the product draft - */ - fun updateAttributeInDraft(attributeToUpdate: ProductAttribute) { - productDraftAttributes.map { attribute -> - if (attributeToUpdate.id == attribute.id && attributeToUpdate.name == attribute.name) { - attributeToUpdate - } else { - attribute - } - }.also { attributeList -> - if (productDraftAttributes != attributeList) { - updateProductDraft(attributes = attributeList) - } - } - } - /** * Renames a single attribute in the product draft */ @@ -2005,11 +1974,11 @@ class ProductDetailViewModel @Inject constructor( // redirect to the product detail screen productTagsViewState = productTagsViewState.copy(isProgressDialogShown = false) - onBackButtonClicked(ProductExitEvent.ExitProductTags(shouldShowDiscardDialog = false)) + onBackButtonClicked(ProductExitEvent.ExitProductTags()) } } else { // There are no newly added tags so redirect to the product detail screen - onBackButtonClicked(ProductExitEvent.ExitProductTags(shouldShowDiscardDialog = false)) + onBackButtonClicked(ProductExitEvent.ExitProductTags()) } } @@ -2218,37 +2187,27 @@ class ProductDetailViewModel @Inject constructor( * * Add a new class here for each new product sub detail screen to handle back navigation. */ - sealed class ProductExitEvent(val shouldShowDiscardDialog: Boolean = true) : Event() { - class ExitExternalLink(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent(shouldShowDiscardDialog) - class ExitSettings(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent(shouldShowDiscardDialog) - class ExitProductCategories(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent(shouldShowDiscardDialog) - class ExitProductTags(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent(shouldShowDiscardDialog) - class ExitLinkedProducts(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent(shouldShowDiscardDialog) - class ExitProductDownloads(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent(shouldShowDiscardDialog) - class ExitProductDownloadsSettings(shouldShowDiscardDialog: Boolean = true) : - ProductExitEvent(shouldShowDiscardDialog) - - class ExitProductAttributeList( - shouldShowDiscardDialog: Boolean = true - ) : ProductExitEvent( - shouldShowDiscardDialog - ) + sealed class ProductExitEvent : Event() { + class ExitExternalLink : ProductExitEvent() + class ExitSettings : ProductExitEvent() + class ExitProductCategories : ProductExitEvent() + class ExitProductTags : ProductExitEvent() + class ExitLinkedProducts : ProductExitEvent() + class ExitProductDownloads : ProductExitEvent() + class ExitProductDownloadsSettings : + ProductExitEvent() - class ExitProductAddAttribute(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent( - shouldShowDiscardDialog - ) + class ExitProductAttributeList : ProductExitEvent() - class ExitProductAddAttributeTerms(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent( - shouldShowDiscardDialog - ) + class ExitProductAddAttribute : ProductExitEvent() - class ExitProductRenameAttribute(shouldShowDiscardDialog: Boolean = true) : ProductExitEvent( - shouldShowDiscardDialog - ) + class ExitProductAddAttributeTerms : ProductExitEvent() + + class ExitProductRenameAttribute : ProductExitEvent() - object ExitAttributesAdded : ProductExitEvent(shouldShowDiscardDialog = false) + object ExitAttributesAdded : ProductExitEvent() - object ExitProductAddons : ProductExitEvent(shouldShowDiscardDialog = false) + object ExitProductAddons : ProductExitEvent() } object RefreshMenu : Event() diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductFilterListViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductFilterListViewModel.kt index 7189e911a8c..0480d7ad40e 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductFilterListViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/ProductFilterListViewModel.kt @@ -382,36 +382,7 @@ class ProductFilterListViewModel @Inject constructor( val filterItemKey: ProductFilterOption, val filterItemName: String, var filterOptionListItems: List - ) : Parcelable { - fun isSameFilter(updatedFilterOption: FilterListItemUiModel): Boolean { - if (this.filterItemName == updatedFilterOption.filterItemName && - this.filterItemKey == updatedFilterOption.filterItemKey && - this.filterOptionListItems.isSameFilterOptions(updatedFilterOption.filterOptionListItems) - ) { - return true - } - return false - } - - /** - * Compares this filter's options with the passed list, returns true only if both lists contain - * the same filter options in the same order - */ - private fun List.isSameFilterOptions( - updatedFilterOptions: List - ): Boolean { - if (this.size != updatedFilterOptions.size) { - return false - } - - for (i in this.indices) { - if (!this[i].isSameFilterOption(updatedFilterOptions[i])) { - return false - } - } - return true - } - } + ) : Parcelable /** * [filterOptionItemName] is the display name of the filter option @@ -435,15 +406,5 @@ class ProductFilterListViewModel @Inject constructor( companion object { @DimenRes const val DEFAULT_FILTER_OPTION_MARGIN = 0 } - - fun isSameFilterOption(updatedFilterOption: FilterListOptionItemUiModel): Boolean { - if (this.isSelected == updatedFilterOption.isSelected && - this.filterOptionItemName == updatedFilterOption.filterOptionItemName && - this.filterOptionItemValue == updatedFilterOption.filterOptionItemValue - ) { - return true - } - return false - } } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/variations/VariationDetailViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/variations/VariationDetailViewModel.kt index f32f013706c..4239764dbe5 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/variations/VariationDetailViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/products/variations/VariationDetailViewModel.kt @@ -370,10 +370,6 @@ class VariationDetailViewModel @Inject constructor( ) } - fun getShippingClassByRemoteShippingClassId(remoteShippingClassId: Long) = - productRepository.getProductShippingClassByRemoteId(remoteShippingClassId)?.name - ?: viewState.variation?.shippingClass ?: "" - private fun observeImageUploadEvents() { mediaFileUploadHandler.observeCurrentUploads(navArgs.remoteVariationId) .onEach { diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerRepository.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerRepository.kt index b38b2a3fbed..268ce9681bc 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerRepository.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/sitepicker/SitePickerRepository.kt @@ -52,10 +52,6 @@ class SitePickerRepository @Inject constructor( } } - suspend fun fetchSiteSettings(site: SiteModel) = wooCommerceStore.fetchSiteGeneralSettings(site) - - suspend fun fetchSiteProductSettings(site: SiteModel) = wooCommerceStore.fetchSiteProductSettings(site) - // overrideRetryPolicy = true, will set the JetPackTunnel timeout policy to 15s rather than default 30s suspend fun verifySiteWooAPIVersion(site: SiteModel) = wooCommerceStore.fetchSupportedApiVersion(site, overrideRetryPolicy = true) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/AppThemeUtils.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/AppThemeUtils.kt index 0191a6df81e..b35d2709706 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/AppThemeUtils.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/AppThemeUtils.kt @@ -1,8 +1,6 @@ package com.woocommerce.android.util import android.annotation.SuppressLint -import android.app.Activity -import android.content.res.Configuration import androidx.annotation.StringRes import androidx.appcompat.app.AppCompatDelegate import com.woocommerce.android.AppPrefs @@ -33,13 +31,6 @@ object AppThemeUtils { } } } - - fun isDarkThemeActive(activity: Activity): Boolean { - return when (activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) { - Configuration.UI_MODE_NIGHT_YES -> true - else -> false - } - } } enum class ThemeOption(@StringRes val label: Int) { diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/ContinuationWrapper.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/ContinuationWrapper.kt index 566f6899638..c0c0137bfc3 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/ContinuationWrapper.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/ContinuationWrapper.kt @@ -10,7 +10,6 @@ import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.withTimeout import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException /** * A wrapper class for a [CancellableContinuation], which handles some of the most common errors when a continuation @@ -27,9 +26,6 @@ class ContinuationWrapper(private val tag: WooLog.T) { private var continuation: CancellableContinuation? = null private val mutex = Mutex() - val isWaiting: Boolean - get() = continuation?.isActive ?: false - suspend fun callAndWaitUntilTimeout( timeout: Long = AppConstants.REQUEST_TIMEOUT, asyncAction: () -> Unit @@ -37,10 +33,6 @@ class ContinuationWrapper(private val tag: WooLog.T) { return callAndWait(asyncAction, timeout) } - suspend fun callAndWait(asyncAction: () -> Unit): ContinuationResult { - return callAndWait(asyncAction, 0) - } - private suspend fun callAndWait(asyncAction: () -> Unit, timeout: Long): ContinuationResult { suspend fun suspendCoroutine(asyncRequest: () -> Unit) = suspendCancellableCoroutine { continuation = it @@ -74,13 +66,6 @@ class ContinuationWrapper(private val tag: WooLog.T) { } } - @Synchronized - fun continueWithException(exception: Throwable) { - if (continuation?.isActive == true) { - continuation?.resumeWithException(exception) - } - } - @Synchronized fun cancel() { continuation?.cancel() @@ -91,10 +76,3 @@ class ContinuationWrapper(private val tag: WooLog.T) { data class Cancellation(val exception: CancellationException) : ContinuationResult() } } - -fun ContinuationWrapper.ContinuationResult.isSuccessful(): Boolean { - return when (this) { - is Success -> value - is Cancellation -> false - } -} diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/CoroutineHelpers.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/CoroutineHelpers.kt index 4f9901f7dfb..9e5db180124 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/CoroutineHelpers.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/CoroutineHelpers.kt @@ -1,6 +1,5 @@ package com.woocommerce.android.util -import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Deferred import kotlinx.coroutines.coroutineScope @@ -24,18 +23,6 @@ suspend inline fun suspendCoroutineWithTimeout( } } -/** - * Similar to the above but returns a cancellable continuation - */ -suspend inline fun suspendCancellableCoroutineWithTimeout( - timeout: Long, - crossinline block: (CancellableContinuation) -> Unit -) = coroutineScope { - withTimeoutOrNull(timeout) { - suspendCancellableCoroutine(block = block) - } -} - /** * Waits for the completion of the first [Deferred] from the passed list, then return its result. */ diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/CurrencyFormatter.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/CurrencyFormatter.kt index 8fa09d088da..3b6100af453 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/CurrencyFormatter.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/CurrencyFormatter.kt @@ -133,19 +133,6 @@ class CurrencyFormatter @Inject constructor( }.orEmpty() } - /** - * Utility function that returns a reduced function for formatting currencies for orders. - * - * For order objects, we generally want to show exact values, and the currency used can be set once at a global - * level - then the same function can be used for all the various currency fields of an order. - * - * @param currencyCode the ISO 4217 currency code to use for formatting - * @return a function which, given a raw amount as a String, returns the String formatted for display as a currency - */ - fun buildFormatter(currencyCode: String = defaultCurrencyCode) = { rawValue: String? -> - formatCurrency(rawValue ?: "0.0", currencyCode, true) - } - /** * Utility function that returns a reduced function for formatting currencies for orders. * diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/DateUtils.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/DateUtils.kt index d2dbb3dd8f1..0181c762224 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/DateUtils.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/DateUtils.kt @@ -125,17 +125,6 @@ class DateUtils @Inject constructor( } } - /** - * Given a date string in localized format, returns a date object. - * - * return null from the [DateFormat] class if [dateString] cannot be - * properly parsed - */ - fun getDateFromLocalizedLongDateString(context: Context, dateString: String): Date? { - val df = DateFormat.getLongDateFormat(context) - return df.parse(dateString) - } - /** * Given a date of format YYYY-'W'WW, returns the String in short month ("MMM d") format, * with the day being the first day of that week (a Monday, by ISO8601 convention). @@ -371,12 +360,7 @@ class DateUtils @Inject constructor( } companion object { - const val DAYS_IN_QUARTER = 90 - const val DAYS_TAIL_IN_WEEK = 6 - const val ZERO = 0 - const val ONE = 1 - const val THREE = 3 /** * Compares two dates to determine if [date2] is after [date1]. Note that @@ -391,10 +375,5 @@ class DateUtils @Inject constructor( val dateOnly2 = DateUtils.round(date2, Calendar.DATE) return dateOnly2.after(dateOnly1) } - - fun getDayOfWeekWithMonthAndDayFromDate(date: Date): String { - val dateFormat = SimpleDateFormat("EEEE, MMM dd", Locale.US) - return dateFormat.format(date) - } } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/WooAnimUtils.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/WooAnimUtils.kt index bcd50e6f364..8ed9de68810 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/WooAnimUtils.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/WooAnimUtils.kt @@ -9,15 +9,12 @@ import android.view.View import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.AccelerateInterpolator import android.view.animation.Animation -import android.view.animation.AnimationUtils import android.view.animation.DecelerateInterpolator import android.view.animation.LinearInterpolator import android.view.animation.RotateAnimation import android.view.animation.TranslateAnimation import androidx.core.view.isVisible -import com.woocommerce.android.R import com.woocommerce.android.util.WooAnimUtils.Duration.EXTRA_LONG -import com.woocommerce.android.util.WooAnimUtils.Duration.LONG private const val REPEAT_COUNT_LOOP = -1 private const val DEGREES_0 = 0f @@ -125,32 +122,6 @@ object WooAnimUtils { } } - fun scale( - target: View, - scaleStart: Float, - scaleEnd: Float, - duration: Duration - ) { - val scaleX = PropertyValuesHolder.ofFloat( - View.SCALE_X, - scaleStart, - scaleEnd - ) - val scaleY = PropertyValuesHolder.ofFloat( - View.SCALE_Y, - scaleStart, - scaleEnd - ) - val animator = ObjectAnimator.ofPropertyValuesHolder( - target, - scaleX, - scaleY - ) - animator.duration = duration.toMillis(target.context) - animator.interpolator = AccelerateDecelerateInterpolator() - animator.start() - } - fun animateBottomBar(view: View, show: Boolean, duration: Duration = DEFAULT_DURATION) { animateBar(view, show, false, duration) } @@ -190,13 +161,6 @@ object WooAnimUtils { view.isVisible = isVisible } - fun pop(view: View, duration: Duration = LONG) { - AnimationUtils.loadAnimation(view.context, R.anim.pop)?.let { animation -> - animation.duration = duration.toMillis(view.context) - view.startAnimation(animation) - } - } - fun rotate(view: View, duration: Duration = EXTRA_LONG) { val rotationAnimation: Animation = RotateAnimation( DEGREES_0, DEGREES_360, diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/WooPermissionUtils.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/WooPermissionUtils.kt index 2baa904612a..de8cf375715 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/util/WooPermissionUtils.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/util/WooPermissionUtils.kt @@ -3,7 +3,6 @@ package com.woocommerce.android.util import android.Manifest.permission.ACCESS_FINE_LOCATION import android.Manifest.permission.BLUETOOTH_CONNECT import android.Manifest.permission.BLUETOOTH_SCAN -import android.Manifest.permission.CAMERA import android.app.Activity import android.content.Context import android.content.Intent @@ -51,12 +50,6 @@ object WooPermissionUtils { launcher.launch(arrayOf(BLUETOOTH_SCAN, BLUETOOTH_CONNECT)) } - fun hasCameraPermission(context: Context) = context.checkIfPermissionGiven(CAMERA) - - fun requestCameraPermission(launcher: ActivityResultLauncher) { - launcher.launch(CAMERA) - } - private fun Context.checkIfPermissionGiven(permission: String) = ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/viewmodel/ViewModelKey.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/viewmodel/ViewModelKey.kt deleted file mode 100644 index 7a7cbcf4f19..00000000000 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/viewmodel/ViewModelKey.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.woocommerce.android.viewmodel - -import androidx.lifecycle.ViewModel -import dagger.MapKey -import kotlin.annotation.AnnotationRetention -import kotlin.annotation.AnnotationTarget -import kotlin.annotation.MustBeDocumented -import kotlin.reflect.KClass - -@MustBeDocumented -@Target(AnnotationTarget.FUNCTION) -@Retention(AnnotationRetention.RUNTIME) -@MapKey -annotation class ViewModelKey(val value: KClass) diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/ActionableEmptyView.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/ActionableEmptyView.kt index 357f8a21002..b20da9d6058 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/ActionableEmptyView.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/ActionableEmptyView.kt @@ -6,7 +6,6 @@ import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.widget.LinearLayout -import android.widget.RelativeLayout import androidx.core.view.isVisible import com.woocommerce.android.R import com.woocommerce.android.databinding.ActionableEmptyViewBinding @@ -81,32 +80,6 @@ class ActionableEmptyView : LinearLayout { binding.emptyViewButton.setOnClickListener(action) } - /** - * Update actionable empty view layout when used while searching. The following characteristics are for each case: - * Default - center in parent, use original top margin - * Search - center at top of parent, use original top margin, add 48dp top padding, hide image, hide button - * - * @param isSearching true when searching; false otherwise - * @param topMargin top margin in pixels to offset with other views (e.g. toolbar or tabs) - */ - fun updateLayoutForSearch(isSearching: Boolean, topMargin: Int) { - val params: RelativeLayout.LayoutParams - - if (isSearching) { - params = RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) - binding.root.setPadding(0, context.resources.getDimensionPixelSize(R.dimen.major_300), 0, 0) - - binding.emptyViewImage.visibility = View.GONE - binding.emptyViewButton.visibility = View.GONE - } else { - params = RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) - binding.root.setPadding(0, 0, 0, 0) - } - - params.topMargin = topMargin - binding.root.layoutParams = params - } - /** * Hide the main image in landscape since there isn't enough room for it on most devices */ diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/NumberPickerDialog.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/NumberPickerDialog.kt index b8323bd07d6..71e91264221 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/NumberPickerDialog.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/NumberPickerDialog.kt @@ -104,8 +104,4 @@ open class NumberPickerDialog : DialogFragment(), DialogInterface.OnClickListene resultIntent.putExtra(CUR_VALUE_KEY, numberPicker.value) target?.onActivityResult(targetRequestCode, Activity.RESULT_OK, resultIntent) } - - fun setNumberFormat(format: Formatter) { - this.format = format - } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/sectionedrecyclerview/SectionParameters.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/sectionedrecyclerview/SectionParameters.kt index 5e47f2e0a2f..fcb841ce442 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/sectionedrecyclerview/SectionParameters.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/sectionedrecyclerview/SectionParameters.kt @@ -41,50 +41,6 @@ class SectionParameters private constructor(builder: Builder) { return this } - /** - * Set layout resource for Section's footer - * @param footerResourceId layout resource for Section's footer - * @return this builder - */ - fun footerResourceId(@LayoutRes footerResourceId: Int): Builder { - this.footerResourceId = footerResourceId - - return this - } - - /** - * Set layout resource for Section's loading state - * @param loadingResourceId layout resource for Section's loading state - * @return this builder - */ - fun loadingResourceId(@LayoutRes loadingResourceId: Int): Builder { - this.loadingResourceId = loadingResourceId - - return this - } - - /** - * Set layout resource for Section's failed state - * @param failedResourceId layout resource for Section's failed state - * @return this builder - */ - fun failedResourceId(@LayoutRes failedResourceId: Int): Builder { - this.failedResourceId = failedResourceId - - return this - } - - /** - * Set layout resource for Section's empty state - * @param emptyResourceId layout resource for Section's empty state - * @return this builder - */ - fun emptyResourceId(@LayoutRes emptyResourceId: Int): Builder { - this.emptyResourceId = emptyResourceId - - return this - } - /** * Build an instance of SectionParameters * @return an instance of SectionParameters diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/sectionedrecyclerview/SectionedRecyclerViewAdapter.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/sectionedrecyclerview/SectionedRecyclerViewAdapter.kt index 6abd616ec6e..6ad2a4abb7e 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/sectionedrecyclerview/SectionedRecyclerViewAdapter.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/widgets/sectionedrecyclerview/SectionedRecyclerViewAdapter.kt @@ -3,13 +3,10 @@ package com.woocommerce.android.widgets.sectionedrecyclerview import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.annotation.VisibleForTesting import androidx.recyclerview.widget.RecyclerView import com.woocommerce.android.util.WooLog import com.woocommerce.android.util.WooLog.T import com.woocommerce.android.widgets.sectionedrecyclerview.Section.State -import java.util.HashMap -import java.util.LinkedHashMap import java.util.UUID /** @@ -146,25 +143,6 @@ open class SectionedRecyclerViewAdapter : RecyclerView.Adapter 1) { - notifyItemRangeInsertedInSection(section, 1, contentItemsTotal - 1) - } - } - } - - /** - * Helper method that calls [.notifyItemRangeRemoved] and [.notifyItemChanged] with - * the position of the [State] view holder in the adapter. Useful to be called after - * changing the State from LOADED to LOADING/ FAILED/ EMPTY. - * - * @param tag unique identifier of the section - * @param previousContentItemsCount previous content items count of section - */ - fun notifyStateChangedFromLoaded(tag: String, previousContentItemsCount: Int) { - val section = getValidSectionOrThrowException(tag) - - notifyStateChangedFromLoaded(section, previousContentItemsCount) - } - - /** - * Helper method that calls [.notifyItemRangeRemoved] and [.notifyItemChanged] with - * the position of the [State] view holder in the adapter. Useful to be called after - * changing the State from LOADED to LOADING/ FAILED/ EMPTY. - * - * @param section a mVisible section of this adapter - * @param previousContentItemsCount previous content items count of section - */ - fun notifyStateChangedFromLoaded(section: Section, previousContentItemsCount: Int) { - val state = section.state - - if (state == State.LOADED) { - throw IllegalStateException("Use notifyStateChangedToLoaded") - } - - if (previousContentItemsCount == 0) { - notifyItemInsertedInSection(section, 0) - } else { - if (previousContentItemsCount > 1) { - notifyItemRangeRemovedFromSection(section, 1, previousContentItemsCount - 1) - } - - notifyItemChangedInSection(section, 0) - } - } - - /** - * Helper method that calls [.notifyItemInserted] with the position of the section's - * header in the adapter. Useful to be called after changing the visibility of the section's - * header to mVisible with [Section.setHasHeader]. - * - * @param tag unique identifier of the section - */ - fun notifyHeaderInsertedInSection(tag: String) { - val section = getValidSectionOrThrowException(tag) - - notifyHeaderInsertedInSection(section) - } - - /** - * Helper method that calls [.notifyItemInserted] with the position of the section's - * header in the adapter. Useful to be called after changing the visibility of the section's - * header to mVisible with [Section.setHasHeader]. - * - * @param section a mVisible section of this adapter - */ - fun notifyHeaderInsertedInSection(section: Section) { - val headerPosition = getHeaderPositionInAdapter(section) - - callSuperNotifyItemInserted(headerPosition) - } - - /** - * Helper method that calls [.notifyItemInserted] with the position of the section's - * footer in the adapter. Useful to be called after changing the visibility of the section's - * footer to mVisible with [Section.setHasFooter]. - * - * @param tag unique identifier of the section - */ - fun notifyFooterInsertedInSection(tag: String) { - val section = getValidSectionOrThrowException(tag) - - notifyFooterInsertedInSection(section) - } - - /** - * Helper method that calls [.notifyItemInserted] with the position of the section's - * footer in the adapter. Useful to be called after changing the visibility of the section's - * footer to mVisible with [Section.setHasFooter]. - * - * @param section a mVisible section of this adapter - */ - fun notifyFooterInsertedInSection(section: Section) { - val footerPosition = getFooterPositionInAdapter(section) - - callSuperNotifyItemInserted(footerPosition) - } - - /** - * Helper method that calls [.notifyItemRemoved] with the position of the section's - * header in the adapter. Useful to be called after changing the visibility of the section's - * header to invisible with [Section.setHasHeader]. - * - * @param tag unique identifier of the section - */ - fun notifyHeaderRemovedFromSection(tag: String) { - val section = getValidSectionOrThrowException(tag) - - notifyHeaderRemovedFromSection(section) - } - - /** - * Helper method that calls [.notifyItemRemoved] with the position of the section's - * header in the adapter. Useful to be called after changing the visibility of the section's - * header to invisible with [Section.setHasHeader]. - * - * @param section a mVisible section of this adapter - */ - fun notifyHeaderRemovedFromSection(section: Section) { - val position = getSectionPosition(section) - if (position != INVALID_POSITION) { - callSuperNotifyItemRemoved(position) - } - } - - /** - * Helper method that calls [.notifyItemRemoved] with the position of the section's - * footer in the adapter. Useful to be called after changing the visibility of the section's - * footer to invisible with [Section.setHasFooter]. - * - * @param tag unique identifier of the section - */ - fun notifyFooterRemovedFromSection(tag: String) { - val section = getValidSectionOrThrowException(tag) - - notifyFooterRemovedFromSection(section) - } - - /** - * Helper method that calls [.notifyItemRemoved] with the position of the section's - * footer in the adapter. Useful to be called after changing the visibility of the section's - * footer to invisible with [Section.setHasFooter]. - * - * @param section a mVisible section of this adapter - */ - fun notifyFooterRemovedFromSection(section: Section) { - val sectionPos = getSectionPosition(section) - if (sectionPos != INVALID_POSITION) { - val position = sectionPos + section.sectionItemsTotal - callSuperNotifyItemRemoved(position) - } - } - - /** - * Helper method that calls [.notifyItemRangeInserted] with the position of the section - * in the adapter. Useful to be called after changing the visibility of the section to mVisible - * - * @param tag unique identifier of the section - */ - fun notifySectionChangedToVisible(tag: String) { - val section = getValidSectionOrThrowException(tag) - - notifySectionChangedToVisible(section) - } - - /** - * Helper method that calls [.notifyItemRangeInserted] with the position of the section - * in the adapter. Useful to be called after changing the visibility of the section to mVisible - * - * @param section a mVisible section of this adapter - */ - fun notifySectionChangedToVisible(section: Section) { - if (!section.isVisible) { - throw IllegalStateException("This section is not mVisible.") - } - - val sectionPos = getSectionPosition(section) - if (sectionPos != INVALID_POSITION) { - callSuperNotifyItemRangeInserted(sectionPos, section.sectionItemsTotal) - } - } - - /** - * Helper method that calls [.notifyItemRangeInserted] with the position of the section - * in the adapter. Useful to be called after changing the visibility of the section to invisible - * - * @param tag unique identifier of the section - * @param previousSectionPosition previous section position - */ - fun notifySectionChangedToInvisible(tag: String, previousSectionPosition: Int) { - val section = getValidSectionOrThrowException(tag) - - notifySectionChangedToInvisible(section, previousSectionPosition) - } - - /** - * Helper method that calls [.notifyItemRangeInserted] with the position of the section - * in the adapter. Useful to be called after changing the visibility of the section to invisible - * - * @param section an invisible section of this adapter - * @param previousSectionPosition previous section position - */ - fun notifySectionChangedToInvisible(section: Section, previousSectionPosition: Int) { - if (section.isVisible) { - throw IllegalStateException("This section is not mVisible.") - } - - val sectionItemsTotal = section.sectionItemsTotal - - callSuperNotifyItemRangeRemoved(previousSectionPosition, sectionItemsTotal) - } - - private fun getValidSectionOrThrowException(tag: String): Section { - return getSection(tag) ?: throw IllegalArgumentException("Invalid tag: $tag") - } - /** * A concrete class of an empty ViewHolder. * Should be used to avoid the boilerplate of creating a ViewHolder class for simple case diff --git a/WooCommerce/src/test/kotlin/com/woocommerce/android/network/ConnectionChangeReceiver.kt b/WooCommerce/src/test/kotlin/com/woocommerce/android/network/ConnectionChangeReceiver.kt deleted file mode 100644 index efc6b5e995c..00000000000 --- a/WooCommerce/src/test/kotlin/com/woocommerce/android/network/ConnectionChangeReceiver.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.woocommerce.android.network - -import android.content.BroadcastReceiver -import android.content.Context -import android.content.Intent -import org.greenrobot.eventbus.EventBus -import org.mockito.kotlin.mock -import javax.inject.Inject -import javax.inject.Singleton - -@Singleton -class ConnectionChangeReceiver @Inject constructor() : BroadcastReceiver() { - companion object { - private var mockBus: EventBus = mock() - fun getEventBus() = mockBus - } - - class ConnectionChangeEvent(var isConnected: Boolean) - - override fun onReceive(context: Context, intent: Intent) { - // mocked - do nothing - } -} diff --git a/WooCommerce/src/test/kotlin/com/woocommerce/android/push/NotificationMessageHandlerTest.kt b/WooCommerce/src/test/kotlin/com/woocommerce/android/push/NotificationMessageHandlerTest.kt index 78f8b67d219..d40c6daeef0 100644 --- a/WooCommerce/src/test/kotlin/com/woocommerce/android/push/NotificationMessageHandlerTest.kt +++ b/WooCommerce/src/test/kotlin/com/woocommerce/android/push/NotificationMessageHandlerTest.kt @@ -44,10 +44,6 @@ import org.wordpress.android.fluxc.store.WCLeaderboardsStore import org.wordpress.android.fluxc.store.WCOrderStore.FetchOrderListPayload class NotificationMessageHandlerTest { - companion object { - val SITE_MODEL = SiteModel() - } - private lateinit var notificationMessageHandler: NotificationMessageHandler private val accountModel = AccountModel().apply { userId = 12345 } diff --git a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/OrderTestUtils.kt b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/OrderTestUtils.kt index 8e3d3f9c990..aeb2ff5c790 100644 --- a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/OrderTestUtils.kt +++ b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/orders/OrderTestUtils.kt @@ -37,22 +37,6 @@ object OrderTestUtils { ) } - fun generateOrderShipmentTrackings(totalCount: Int, lOrderId: Int): List { - val result = ArrayList() - for (i in totalCount downTo 1) { - result.add( - WCOrderShipmentTrackingModel(totalCount).apply { - trackingProvider = "TNT Express $i" - trackingNumber = "$i" - dateShipped = SimpleDateFormat("yyyy-MM-dd").format(Date()) - trackingLink = "www.somelink$i.com" - orderId = lOrderId.toLong() - } - ) - } - return result - } - fun generateOrderShipmentProviders(): List { val result = ArrayList() result.add( diff --git a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/products/ProductTestUtils.kt b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/products/ProductTestUtils.kt index d922013205a..c544e35c019 100644 --- a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/products/ProductTestUtils.kt +++ b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/products/ProductTestUtils.kt @@ -1,11 +1,14 @@ package com.woocommerce.android.ui.products -import com.woocommerce.android.model.* +import com.woocommerce.android.model.Product +import com.woocommerce.android.model.ProductAttribute +import com.woocommerce.android.model.ProductCategory +import com.woocommerce.android.model.ProductTag +import com.woocommerce.android.model.ProductVariation +import com.woocommerce.android.model.toAppModel import com.woocommerce.android.ui.products.ProductStatus.DRAFT -import org.wordpress.android.fluxc.model.MediaModel import org.wordpress.android.fluxc.model.WCProductModel import org.wordpress.android.fluxc.model.WCProductVariationModel -import org.wordpress.android.fluxc.store.MediaStore import java.sql.Date import java.time.Instant @@ -125,7 +128,7 @@ object ProductTestUtils { } } - fun generateTags(): List { + private fun generateTags(): List { return listOf(ProductTag(1, "Tag", "Slug", "Desc")) } @@ -153,25 +156,10 @@ object ProductTestUtils { dateCreated = Date.from(Instant.EPOCH) ) - fun generateProductMedia(remoteProductId: Long = 1, siteId: Long = 1) = - MediaModel().apply { - id = 1 - localPostId = remoteProductId.toInt() - localSiteId = siteId.toInt() - mediaId = 1L - fileName = "Image filename $remoteProductId" - url = "google.com" - } - - fun generateMediaUploadErrorModel() = MediaStore.MediaError( - MediaStore.MediaErrorType.GENERIC_ERROR, - "Error uploading media" - ) - fun generateProductImagesList() = (1L..10L).map { id -> generateProductImage(imageId = id) } - fun generateProductAttribute(id: Long): ProductAttribute { + private fun generateProductAttribute(id: Long): ProductAttribute { return ProductAttribute( id = id, name = "attribute$id",