From 91fb9022cd28cb834c55c611d3dbe0be271919e4 Mon Sep 17 00:00:00 2001 From: Klymentiy Haykov Date: Fri, 20 Mar 2020 13:04:38 -0700 Subject: [PATCH] Revert "Feature/material theme and Dark Theme support (#11469)" (#11486) --- RELEASE-NOTES.txt | 10 +- WordPress/build.gradle | 4 +- WordPress/lint-baseline.xml | 12 - WordPress/src/main/AndroidManifest.xml | 125 ++- .../java/org/wordpress/android/WordPress.java | 7 +- .../android/support/SupportHelper.kt | 6 +- .../ui/AddQuickPressShortcutActivity.java | 86 +- .../android/ui/AppLogViewerActivity.java | 13 +- .../ui/CollapseFullScreenDialogFragment.java | 38 +- .../ui/CommentFullScreenDialogFragment.kt | 4 +- .../ui/DeepLinkingIntentReceiverActivity.java | 10 +- .../android/ui/FilteredRecyclerView.java | 39 +- .../android/ui/FullScreenDialogFragment.java | 32 +- .../ui/JetpackConnectionResultActivity.java | 5 +- .../ui/JetpackRemoteInstallActivity.kt | 7 +- .../ui/JetpackRemoteInstallViewState.kt | 6 +- .../android/ui/LocaleAwareActivity.kt | 33 - .../ui/ShareIntentReceiverActivity.java | 10 +- .../android/ui/WPLaunchActivity.java | 11 +- .../org/wordpress/android/ui/WPWebView.kt | 24 - .../android/ui/WPWebViewActivity.java | 75 +- .../wordpress/android/ui/WebViewActivity.java | 12 +- .../android/ui/accounts/HelpActivity.kt | 20 +- .../android/ui/accounts/LoginActivity.java | 11 +- .../ui/accounts/LoginEpilogueActivity.java | 11 +- .../LoginMagicLinkInterceptActivity.java | 4 +- .../PostSignupInterstitialActivity.kt | 4 +- .../ui/accounts/SignupEpilogueActivity.java | 11 +- .../accounts/login/LoginEpilogueFragment.java | 9 + .../login/LoginPrologueAnimationFragment.java | 2 + ...ernameChangerFullScreenDialogFragment.java | 41 +- .../signup/SettingsUsernameChangerFragment.kt | 23 +- .../detail/ActivityLogDetailActivity.kt | 8 +- .../detail/ActivityLogDetailFragment.kt | 2 +- .../list/ActivityLogListActivity.kt | 9 +- .../list/ActivityLogListFragment.kt | 2 +- .../activitylog/list/EventItemViewHolder.kt | 16 +- .../android/ui/comments/CommentAdapter.java | 43 +- .../ui/comments/CommentDetailFragment.java | 295 +++--- .../android/ui/comments/CommentDialogs.java | 12 +- .../android/ui/comments/CommentsActivity.java | 43 +- .../ui/comments/CommentsDetailActivity.java | 19 +- .../ui/comments/CommentsListFragment.java | 114 ++- .../ui/comments/EditCommentActivity.java | 56 +- .../ui/domains/DomainRegistrationActivity.kt | 38 +- .../DomainRegistrationDetailsFragment.kt | 67 +- .../ui/domains/DomainSuggestionsFragment.kt | 21 +- .../android/ui/giphy/GiphyPickerActivity.kt | 4 +- .../ui/history/HistoryDetailActivity.kt | 6 +- .../ui/main/MainBottomSheetFragment.kt | 8 +- .../wordpress/android/ui/main/MeActivity.kt | 16 +- .../wordpress/android/ui/main/MeFragment.java | 124 ++- .../android/ui/main/MySiteFragment.java | 361 +++++-- .../android/ui/main/SitePickerActivity.java | 156 +-- .../android/ui/main/SitePickerAdapter.java | 118 ++- .../android/ui/main/WPMainActivity.java | 16 +- .../android/ui/main/WPMainNavigationView.kt | 16 +- .../ui/media/MediaBrowserActivity.java | 99 +- .../ui/media/MediaPreviewActivity.java | 11 +- .../ui/media/MediaSettingsActivity.java | 123 ++- .../NotificationsDetailActivity.java | 22 +- .../NotificationsDetailListFragment.java | 6 +- .../adapters/NoteBlockAdapter.java | 6 +- .../notifications/adapters/NotesAdapter.java | 30 +- .../blocks/CommentUserNoteBlock.java | 27 +- .../ui/notifications/blocks/NoteBlock.java | 7 + .../blocks/NoteBlockClickableSpan.java | 9 +- .../android/ui/pages/PageItemViewHolder.kt | 7 +- .../android/ui/pages/PageParentActivity.kt | 8 +- .../android/ui/pages/PagesActivity.kt | 4 +- .../android/ui/pages/PagesFragment.kt | 2 +- .../ui/people/PeopleInviteFragment.java | 123 +-- .../android/ui/people/PeopleListFragment.java | 45 +- .../ui/people/PeopleManagementActivity.java | 95 +- .../ui/people/PersonDetailFragment.java | 36 +- .../ui/people/RoleChangeDialogFragment.java | 51 +- .../ui/people/RoleSelectDialogFragment.java | 26 +- .../ui/photopicker/PhotoPickerActivity.java | 13 +- .../ui/photopicker/PhotoPickerFragment.java | 3 + .../android/ui/plans/PlansActivity.kt | 15 +- .../ui/plugins/PluginBrowserActivity.java | 168 ++-- .../ui/plugins/PluginDetailActivity.java | 286 ++++-- .../ui/plugins/PluginListFragment.java | 118 ++- .../android/ui/plugins/PluginUtils.java | 4 +- .../android/ui/posts/AddCategoryFragment.java | 6 +- .../android/ui/posts/BasicFragmentDialog.kt | 10 +- .../ui/posts/CategoryArrayAdapter.java | 10 +- .../android/ui/posts/EditPostActivity.java | 21 +- .../ui/posts/EditPostSettingsFragment.java | 3 + .../android/ui/posts/HistoryListFragment.kt | 2 +- .../ui/posts/PostDatePickerDialogFragment.kt | 6 +- .../android/ui/posts/PostListFragment.kt | 1 + .../android/ui/posts/PostListMainViewState.kt | 23 +- ...tNotificationScheduleTimeDialogFragment.kt | 2 +- .../PostSettingsInputDialogFragment.java | 16 +- .../posts/PostSettingsListDialogFragment.java | 6 +- .../ui/posts/PostSettingsTagsActivity.java | 13 +- .../ui/posts/PostTimePickerDialogFragment.kt | 7 +- .../android/ui/posts/PostsListActivity.kt | 37 +- .../ui/posts/SelectCategoriesActivity.java | 17 +- .../posts/adapters/AuthorSelectionAdapter.kt | 36 +- .../android/ui/prefs/AboutActivity.java | 18 +- .../ui/prefs/AccountSettingsActivity.java | 38 +- .../ui/prefs/AccountSettingsFragment.java | 6 +- .../android/ui/prefs/AppSettingsActivity.java | 49 +- .../android/ui/prefs/AppSettingsFragment.java | 48 +- .../ui/prefs/BlogPreferencesActivity.java | 18 +- .../ui/prefs/DetailListPreference.java | 79 +- .../EditTextPreferenceWithValidation.java | 14 +- .../ui/prefs/EmptyViewRecyclerView.java | 19 - .../prefs/MultiSelectRecyclerViewAdapter.java | 35 +- .../android/ui/prefs/MyProfileActivity.java | 36 +- .../android/ui/prefs/MyProfileFragment.java | 29 +- .../android/ui/prefs/NumberPickerDialog.java | 29 +- .../ui/prefs/ProfileInputDialogFragment.java | 53 +- .../android/ui/prefs/RelatedPostsDialog.java | 37 +- .../ui/prefs/SiteSettingsFormatDialog.java | 35 +- .../ui/prefs/SiteSettingsFragment.java | 419 +++++--- .../ui/prefs/SiteSettingsTagListActivity.java | 98 +- .../ui/prefs/SiteSettingsTimezoneDialog.java | 109 ++- .../ui/prefs/SummaryEditTextPreference.java | 30 +- .../android/ui/prefs/WPPreference.java | 26 +- .../ui/prefs/WPStartOverPreference.java | 28 +- .../android/ui/prefs/WPSwitchPreference.java | 79 +- .../NotificationSettingsFollowedDialog.java | 27 +- .../NotificationsSettingsActivity.java | 21 +- ...NotificationsSettingsDialogPreference.java | 31 +- .../NotificationsSettingsFragment.java | 41 +- .../PrefMasterSwitchToolbarView.kt | 59 +- .../android/ui/publicize/ConnectButton.java | 18 +- ...PublicizeAccountChooserDialogFragment.java | 50 +- .../PublicizeAccountChooserListAdapter.java | 14 +- .../ui/publicize/PublicizeBaseFragment.java | 4 +- .../PublicizeButtonPrefsFragment.java | 63 +- .../ui/publicize/PublicizeDetailFragment.java | 30 +- .../ui/publicize/PublicizeListActivity.java | 63 +- .../ui/publicize/PublicizeListFragment.java | 32 +- .../adapters/PublicizeConnectionAdapter.java | 19 +- .../ui/quickstart/QuickStartAdapter.java | 75 +- .../ui/reader/ReaderCommentListActivity.java | 17 +- .../ui/reader/ReaderPhotoViewerActivity.java | 11 +- .../ui/reader/ReaderPostDetailFragment.kt | 21 +- .../ui/reader/ReaderPostListActivity.java | 13 +- .../ui/reader/ReaderPostListFragment.java | 112 +-- .../ui/reader/ReaderPostPagerActivity.java | 13 +- .../android/ui/reader/ReaderPostRenderer.java | 7 +- .../android/ui/reader/ReaderResourceVars.java | 33 +- .../android/ui/reader/ReaderSubsActivity.java | 65 +- .../ui/reader/ReaderUserListActivity.java | 13 +- .../ui/reader/ReaderVideoViewerActivity.java | 11 +- .../ui/reader/SubfilterBottomSheetFragment.kt | 8 +- .../reader/adapters/ReaderCommentAdapter.java | 21 +- .../ui/reader/adapters/ReaderMenuAdapter.java | 35 +- .../ui/reader/adapters/ReaderPostAdapter.java | 31 +- .../ReaderSearchSuggestionAdapter.java | 17 +- .../SubfilterListItemViewHolder.kt | 20 +- .../views/ReaderCommentsPostHeaderView.java | 7 - .../ui/reader/views/ReaderFollowButton.java | 5 +- .../ui/reader/views/ReaderIconCountView.java | 15 +- .../ui/reader/views/ReaderWebView.java | 10 +- .../ui/sitecreation/SiteCreationActivity.kt | 10 +- .../SiteCreationBaseFormFragment.java | 2 +- .../domains/SiteCreationDomainsFragment.kt | 13 +- .../misc/SearchInputWithHeader.kt | 14 + .../previews/SiteCreationPreviewFragment.kt | 2 +- .../segments/SiteCreationSegmentViewHolder.kt | 35 +- .../segments/SiteCreationSegmentsFragment.kt | 17 +- .../ui/stats/StatsConnectJetpackActivity.java | 13 +- .../android/ui/stats/refresh/StatsActivity.kt | 11 +- .../ui/stats/refresh/StatsViewAllActivity.kt | 6 +- .../lists/detail/StatsDetailActivity.kt | 6 +- .../management/InsightsManagementActivity.kt | 7 +- .../management/InsightsManagementAdapter.kt | 5 +- .../management/InsightsManagementFragment.kt | 4 +- .../InsightsManagementViewHolder.kt | 12 +- .../usecases/ManagementControlUseCase.kt | 1 - .../viewholders/BarChartViewHolder.kt | 18 +- .../viewholders/BlockListItemViewHolder.kt | 5 +- .../sections/viewholders/DayViewHolder.kt | 4 +- .../sections/viewholders/LinkViewHolder.kt | 7 +- .../viewholders/ListItemWithIconViewHolder.kt | 8 +- .../sections/viewholders/MapViewHolder.kt | 29 +- .../sections/viewholders/TextViewHolder.kt | 10 +- .../sections/viewholders/ValueViewHolder.kt | 12 +- .../StatsAllTimeWidgetConfigureActivity.kt | 14 +- ...StatsWidgetColorSelectionDialogFragment.kt | 6 +- .../StatsWidgetConfigureFragment.kt | 11 +- ...tsWidgetDataTypeSelectionDialogFragment.kt | 6 +- .../StatsWidgetSiteSelectionDialogFragment.kt | 10 +- .../StatsMinifiedWidgetConfigureActivity.kt | 14 +- .../StatsMinifiedWidgetConfigureFragment.kt | 14 +- .../StatsTodayWidgetConfigureActivity.kt | 14 +- .../StatsViewsWidgetConfigureActivity.kt | 14 +- .../refresh/utils/DateSelectorViewUtils.kt | 10 - .../refresh/utils/ItemPopupMenuHandler.kt | 2 +- .../stockmedia/StockMediaPickerActivity.java | 11 +- .../ui/themes/ThemeBrowserActivity.java | 35 +- .../ui/themes/ThemeBrowserAdapter.java | 37 +- .../ui/themes/ThemeBrowserFragment.java | 106 +- .../wordpress/android/util/AppThemeUtils.kt | 43 - .../org/wordpress/android/util/ColorUtils.kt | 10 +- .../android/util/ConfigurationExtensions.kt | 7 - .../android/util/ContextExtensions.kt | 10 +- .../wordpress/android/util/LocaleManager.java | 20 - .../android/util/WPActivityUtils.java | 33 +- .../wordpress/android/util/WPMediaUtils.java | 11 +- .../wordpress/android/util/WPPrefUtils.java | 99 ++ .../android/util/WPSwipeToRefreshHelper.java | 22 +- .../android/util/image/ImageManager.kt | 3 +- .../android/widgets/BadgedImageView.kt | 205 ---- .../org/wordpress/android/widgets/DiffView.kt | 39 +- .../widgets/MultiUsernameEditText.java | 4 +- .../android/widgets/PostListButtonType.kt | 26 +- .../wordpress/android/widgets/WPPrefView.java | 80 +- .../wordpress/android/widgets/WPSnackbar.java | 5 - .../android/widgets/WPSwipeSnackbar.java | 6 +- .../wordpress/android/widgets/WPTextView.java | 4 +- WordPress/src/main/res/anim/pressed_card.xml | 19 + ...ack_translucent_50_neutral_70_selector.xml | 13 + .../color/neutral_10_neutral_0_selector.xml | 5 + .../color/neutral_50_neutral_20_selector.xml | 9 + .../color/neutral_70_neutral_20_selector.xml | 9 + .../neutral_accent_neutral_40_selector.xml | 11 + .../res/color/neutral_neutral_20_selector.xml | 9 + ...neutral_primary_40_neutral_40_selector.xml | 10 + .../color/on_surface_disabled_selector.xml | 5 - .../src/main/res/color/on_surface_divider.xml | 4 - ...rface_medium_disabled_checked_selector.xml | 9 - .../on_surface_medium_primary_selector.xml | 10 - .../on_surface_medium_secondary_selector.xml | 10 - .../res/color/on_surface_primary_selector.xml | 9 - .../primary_0_gray_20_gray_40_selector.xml | 10 + .../primary_0_gray_90_gray_50_selector.xml | 10 + .../color/primary_30_neutral_10_selector.xml | 9 + .../res/color/primary_30_neutral_selector.xml | 9 + .../color/primary_30_primary_20_selector.xml | 9 + .../primary_40_gray_20_gray_40_selector.xml | 10 + .../primary_40_gray_90_gray_50_selector.xml | 10 + .../color/primary_40_neutral_40_selector.xml | 9 + .../color/primary_5_neutral_20_selector.xml | 9 + .../res/color/primary_disabled_selector.xml | 7 - .../primary_on_surface_disabled_selector.xml | 7 - .../res/color/primary_on_surface_selector.xml | 7 - .../res/color/primary_success_selector.xml | 4 +- .../res/color/quick_start_icon_selector.xml | 9 + .../res/color/quick_start_title_selector.xml | 9 + .../color/related_posts_preview_header.xml | 13 + .../res/color/secondary_disabled_selector.xml | 6 - .../secondary_variant_disabled_selector.xml | 6 - .../src/main/res/color/stats_block_column.xml | 13 +- .../insights_management_feature_image.png | Bin 24150 -> 12499 bytes .../insights_management_feature_image_tab.png | Bin 23270 -> 25396 bytes ...tangle_gradient_primary_50_transparent.xml | 11 + .../bg_rectangle_warning_0_warning.xml} | 6 +- ... bg_rectangle_warning_0_warning_white.xml} | 8 +- .../comment_reply_background.xml | 22 +- .../drawable-ldrtl/people_list_divider.xml | 8 + .../insights_management_feature_image.png | Bin 13067 -> 7299 bytes .../insights_management_feature_image_tab.png | Bin 12859 -> 13965 bytes .../insights_management_feature_image.png | Bin 28561 -> 0 bytes .../insights_management_feature_image_tab.png | Bin 31195 -> 0 bytes .../insights_management_feature_image.png | Bin 15792 -> 0 bytes .../insights_management_feature_image_tab.png | Bin 16406 -> 0 bytes .../insights_management_feature_image.png | Bin 42750 -> 0 bytes .../insights_management_feature_image_tab.png | Bin 47343 -> 0 bytes .../insights_management_feature_image.png | Bin 77710 -> 0 bytes .../insights_management_feature_image_tab.png | Bin 88237 -> 0 bytes .../insights_management_feature_image.png | Bin 119783 -> 0 bytes .../insights_management_feature_image_tab.png | Bin 141745 -> 0 bytes .../bg_rectangle_white_radius_bottom_card.xml | 17 + .../bg_rectangle_white_radius_card.xml | 17 + .../bg_rectangle_white_radius_top_card.xml | 17 + .../insights_management_feature_image.png | Bin 34845 -> 19288 bytes .../insights_management_feature_image_tab.png | Bin 36088 -> 38373 bytes .../insights_management_feature_image.png | Bin 61883 -> 34111 bytes .../insights_management_feature_image_tab.png | Bin 64748 -> 68066 bytes .../insights_management_feature_image.png | Bin 0 -> 51556 bytes .../insights_management_feature_image_tab.png | Bin 0 -> 99805 bytes .../res/drawable/bg_bottom_sheet_handle.xml | 2 +- .../bg_bottom_sheet_handle_container.xml | 15 + ... => bg_oval_error_50_minus_white_16dp.xml} | 2 +- .../main/res/drawable/bg_oval_neutral_20.xml | 5 - .../bg_oval_neutral_20_stroke_white.xml | 16 + ..._primary_40_stroke_notification_unread.xml | 16 + ...=> bg_oval_primary_50_plus_white_16dp.xml} | 2 +- .../res/drawable/bg_oval_warning_dark.xml | 5 - .../drawable/bg_oval_warning_stroke_white.xml | 16 + .../main/res/drawable/bg_oval_white_24dp.xml | 11 - ...bg_rectangle_gradient_accent_5_accent.xml} | 4 +- ...tangle_gradient_primary_50_transparent.xml | 11 + ...d.xml => bg_rectangle_primary_60_16dp.xml} | 2 +- .../bg_rectangle_warning_0_warning.xml} | 6 +- ... bg_rectangle_warning_0_warning_white.xml} | 8 +- .../main/res/drawable/bg_rectangle_white.xml | 10 + .../src/main/res/drawable/button_frame.xml | 21 + .../main/res/drawable/category_checkmark.xml | 7 + .../res/drawable/comment_reply_background.xml | 22 +- ...xml => ic_send_accent_neutral_30_24dp.xml} | 2 +- .../src/main/res/drawable/list_divider.xml | 8 + .../res/drawable/moderate_button_selector.xml | 28 + .../res/drawable/nav_bar_button_selector.xml | 4 +- .../drawable/notifications_list_divider.xml | 7 +- .../notifications_list_divider_full_width.xml | 8 +- .../main/res/drawable/people_list_divider.xml | 8 + .../drawable/photo_picker_circle_pressed.xml | 2 +- .../main/res/drawable/reader_image_border.xml | 12 + .../reader_new_posts_bar_background.xml | 9 + .../res/drawable/related_posts_divider.xml | 13 + .../res/drawable/stats_bar_background.xml | 2 +- .../src/main/res/drawable/tag_list_circle.xml | 2 +- .../drawable/web_preview_navbar_selector.xml | 7 +- .../layout-land/login_intro_template_view.xml | 2 +- .../res/layout-land/login_signup_screen.xml | 57 +- .../site_creation_preview_screen.xml | 26 +- .../theme_grid_cardview_header.xml | 84 +- .../res/layout-w528dp/stats_loading_view.xml | 17 + .../src/main/res/layout/about_activity.xml | 76 +- .../res/layout/account_settings_activity.xml | 15 - .../main/res/layout/actionable_empty_view.xml | 63 +- ... activity_domain_suggestions_activity.xml} | 10 +- .../layout/activity_log_detail_activity.xml | 9 +- .../res/layout/activity_log_item_detail.xml | 241 ++--- .../res/layout/activity_log_list_activity.xml | 15 +- .../layout/activity_log_list_event_item.xml | 139 +-- .../layout/activity_log_list_footer_item.xml | 12 +- .../res/layout/activity_log_list_fragment.xml | 15 +- .../layout/activity_log_list_header_item.xml | 17 +- .../layout/activity_log_list_loading_item.xml | 16 +- .../activity_log_list_progress_item.xml | 70 +- .../src/main/res/layout/add_category.xml | 73 +- .../res/layout/add_new_site_dialog_item.xml | 13 +- .../res/layout/add_quickpress_shortcut.xml | 14 + .../main/res/layout/app_settings_activity.xml | 15 - .../res/layout/bottom_sheet_handle_view.xml | 1 - .../src/main/res/layout/categories_row.xml | 23 +- .../main/res/layout/categories_row_parent.xml | 11 +- .../collapse_full_screen_dialog_fragment.xml | 28 +- .../main/res/layout/comment_action_footer.xml | 117 ++- .../src/main/res/layout/comment_activity.xml | 10 +- .../res/layout/comment_detail_fragment.xml | 75 +- .../res/layout/comment_dialog_fragment.xml | 30 +- .../main/res/layout/comment_edit_activity.xml | 94 +- .../main/res/layout/comment_list_fragment.xml | 17 +- .../src/main/res/layout/comment_listitem.xml | 50 +- .../res/layout/comments_detail_activity.xml | 16 +- .../res/layout/detail_list_preference.xml | 42 +- .../layout/detail_list_preference_title.xml | 20 +- .../domain_registration_details_fragment.xml | 141 +-- .../domain_registration_result_fragment.xml | 23 +- .../layout/domain_suggestion_list_item.xml | 26 +- .../layout/domain_suggestions_activity.xml | 13 - .../layout/domain_suggestions_fragment.xml | 123 +-- .../edit_post_published_settings_fragment.xml | 1 + .../layout/edit_post_settings_fragment.xml | 471 ++++----- .../res/layout/filtered_list_component.xml | 46 +- .../main/res/layout/followed_sites_dialog.xml | 142 +-- .../layout/full_screen_dialog_fragment.xml | 22 +- .../src/main/res/layout/help_activity.xml | 112 +-- .../res/layout/history_detail_activity.xml | 16 +- .../history_detail_container_fragment.xml | 186 ++-- .../res/layout/history_detail_fragment.xml | 54 +- .../main/res/layout/history_list_footer.xml | 14 +- .../main/res/layout/history_list_fragment.xml | 22 +- .../main/res/layout/history_list_header.xml | 18 +- .../src/main/res/layout/history_list_item.xml | 171 ++-- WordPress/src/main/res/layout/home_row.xml | 60 ++ .../main/res/layout/insert_media_dialog.xml | 3 +- .../layout/insights_management_activity.xml | 11 +- .../insights_management_header_item.xml | 18 +- .../layout/insights_management_list_item.xml | 54 +- .../res/layout/invite_username_button.xml | 6 +- .../jetpack_remote_install_activity.xml | 9 +- .../jetpack_remote_install_fragment.xml | 35 +- .../src/main/res/layout/learn_more_pref.xml | 50 +- .../main/res/layout/learn_more_pref_old.xml | 38 +- WordPress/src/main/res/layout/list_editor.xml | 27 +- .../main/res/layout/login_epilogue_header.xml | 28 +- .../main/res/layout/login_epilogue_screen.xml | 53 +- .../res/layout/login_intro_template_view.xml | 1 - .../main/res/layout/login_signup_screen.xml | 58 +- .../main/res/layout/logviewer_activity.xml | 19 +- .../main/res/layout/logviewer_listitem.xml | 14 +- .../src/main/res/layout/main_activity.xml | 14 +- WordPress/src/main/res/layout/me_fragment.xml | 69 +- .../res/layout/media_browser_activity.xml | 61 +- .../src/main/res/layout/media_grid_item.xml | 6 +- .../main/res/layout/media_picker_activity.xml | 56 +- .../res/layout/media_preview_activity.xml | 4 +- .../res/layout/media_preview_fragment.xml | 9 +- .../res/layout/media_settings_activity.xml | 728 +++++++------- .../main/res/layout/my_profile_activity.xml | 15 - .../src/main/res/layout/my_profile_dialog.xml | 23 +- .../main/res/layout/my_profile_fragment.xml | 8 +- .../src/main/res/layout/my_site_fragment.xml | 413 ++++---- WordPress/src/main/res/layout/navbar_item.xml | 18 +- .../res/layout/new_edit_post_activity.xml | 17 +- WordPress/src/main/res/layout/news_card.xml | 6 +- .../src/main/res/layout/note_block_basic.xml | 4 +- .../res/layout/note_block_comment_user.xml | 48 +- .../src/main/res/layout/note_block_footer.xml | 11 +- .../src/main/res/layout/note_block_header.xml | 96 +- .../src/main/res/layout/note_block_user.xml | 118 +-- .../layout/notifications_detail_activity.xml | 39 +- .../notifications_fragment_detail_list.xml | 1 + .../layout/notifications_list_fragment.xml | 91 +- .../res/layout/notifications_list_item.xml | 169 ++-- .../notifications_settings_activity.xml | 93 +- .../layout/notifications_settings_switch.xml | 25 +- ...notifications_tab_disabled_text_layout.xml | 55 +- ...otifications_tab_for_blog_title_layout.xml | 30 +- .../main/res/layout/number_picker_dialog.xml | 32 +- .../src/main/res/layout/page_divider_item.xml | 4 +- .../src/main/res/layout/page_empty_item.xml | 6 +- .../src/main/res/layout/page_list_item.xml | 150 ++- .../main/res/layout/page_parent_list_item.xml | 14 +- .../res/layout/page_parent_top_level_item.xml | 14 +- .../src/main/res/layout/pages_fragment.xml | 27 +- .../main/res/layout/pages_list_fragment.xml | 3 +- .../main/res/layout/pages_parent_activity.xml | 9 +- .../res/layout/people_invite_error_view.xml | 9 +- .../res/layout/people_invite_fragment.xml | 294 +++--- .../main/res/layout/people_list_fragment.xml | 59 +- .../src/main/res/layout/people_list_row.xml | 47 +- .../res/layout/people_management_activity.xml | 12 +- .../res/layout/person_detail_fragment.xml | 118 ++- .../main/res/layout/photo_picker_activity.xml | 8 +- .../main/res/layout/photo_picker_fragment.xml | 49 +- .../res/layout/photo_picker_thumbnail.xml | 2 +- .../main/res/layout/plan_details_fragment.xml | 35 +- .../src/main/res/layout/plan_feature_item.xml | 18 +- .../src/main/res/layout/plans_activity.xml | 9 +- .../main/res/layout/plans_list_fragment.xml | 13 +- .../src/main/res/layout/plans_list_item.xml | 102 +- .../res/layout/plugin_browser_activity.xml | 183 ++-- .../main/res/layout/plugin_browser_row.xml | 161 ++-- .../res/layout/plugin_detail_activity.xml | 218 ++--- .../src/main/res/layout/plugin_info_row.xml | 10 +- .../main/res/layout/plugin_list_fragment.xml | 2 +- .../src/main/res/layout/plugin_list_row.xml | 22 +- .../res/layout/plugin_ratings_cardview.xml | 119 ++- .../main/res/layout/post_list_activity.xml | 38 +- .../post_list_author_selection_dropdown.xml | 31 +- .../src/main/res/layout/post_list_button.xml | 1 - .../main/res/layout/post_list_fragment.xml | 19 +- .../src/main/res/layout/post_list_item.xml | 289 +++--- .../res/layout/post_list_item_compact.xml | 53 +- .../res/layout/post_list_item_skeleton.xml | 48 +- .../post_list_item_skeleton_compact.xml | 26 +- .../res/layout/post_settings_input_dialog.xml | 39 +- .../layout/post_settings_tags_activity.xml | 34 +- .../post_signup_interstitial_default.xml | 17 +- .../post_signup_interstitial_landscape.xml | 17 +- .../res/layout/preference_dialog_title.xml | 11 +- .../preferences_master_switch_toolbar.xml | 11 +- .../layout/preview_mode_popup_menu_item.xml | 19 +- .../src/main/res/layout/progress_layout.xml | 13 +- .../src/main/res/layout/promo_dialog.xml | 91 +- .../publicize_button_prefs_fragment.xml | 248 +++-- .../res/layout/publicize_connect_button.xml | 25 + .../layout/publicize_connection_list_item.xml | 17 +- .../res/layout/publicize_detail_fragment.xml | 137 +-- .../res/layout/publicize_list_activity.xml | 2 +- .../res/layout/publicize_list_fragment.xml | 183 ++-- .../layout/publicize_listitem_connection.xml | 28 +- .../res/layout/publicize_listitem_service.xml | 24 +- .../res/layout/publicize_webview_fragment.xml | 2 +- .../res/layout/quick_press_input_dialog.xml | 25 - .../quick_press_widget_configure_list_row.xml | 42 - ...uick_start_completed_tasks_list_header.xml | 60 +- .../layout/quick_start_dialog_fragment.xml | 10 +- .../main/res/layout/quick_start_list_item.xml | 89 +- .../quickpress_widget_configure_activity.xml | 16 - .../layout/reader_activity_comment_list.xml | 111 +-- .../res/layout/reader_activity_post_list.xml | 3 +- .../res/layout/reader_activity_post_pager.xml | 2 +- .../main/res/layout/reader_activity_subs.xml | 59 +- .../res/layout/reader_activity_userlist.xml | 2 +- .../layout/reader_activity_video_player.xml | 2 +- .../res/layout/reader_bookmark_button.xml | 32 +- .../main/res/layout/reader_cardview_post.xml | 239 ++--- .../layout/reader_cardview_removed_post.xml | 37 +- .../main/res/layout/reader_cardview_xpost.xml | 42 +- .../reader_comments_post_header_view.xml | 108 ++- .../src/main/res/layout/reader_empty_view.xml | 8 +- .../main/res/layout/reader_follow_button.xml | 8 +- .../main/res/layout/reader_fragment_list.xml | 5 +- .../res/layout/reader_fragment_post_cards.xml | 58 +- .../layout/reader_fragment_post_detail.xml | 1 + .../res/layout/reader_icon_count_view.xml | 35 +- .../res/layout/reader_include_comment_box.xml | 33 +- .../reader_include_post_detail_content.xml | 57 +- .../reader_include_post_detail_footer.xml | 54 +- .../main/res/layout/reader_listitem_blog.xml | 12 +- .../res/layout/reader_listitem_comment.xml | 71 +- .../res/layout/reader_listitem_suggestion.xml | 8 +- .../reader_listitem_suggestion_recycler.xml | 5 +- .../main/res/layout/reader_listitem_tag.xml | 23 +- .../main/res/layout/reader_listitem_user.xml | 78 +- .../res/layout/reader_popup_menu_item.xml | 1 - .../layout/reader_post_detail_header_view.xml | 24 +- .../main/res/layout/reader_search_tabs.xml | 5 +- .../res/layout/reader_simple_post_view.xml | 60 +- .../reader_simple_posts_container_view.xml | 11 +- .../res/layout/reader_site_header_view.xml | 59 +- .../res/layout/reader_site_search_result.xml | 12 +- .../res/layout/reader_tag_strip_label.xml | 4 +- .../layout/reader_thumbnail_strip_image.xml | 2 +- .../main/res/layout/related_posts_dialog.xml | 108 ++- .../src/main/res/layout/role_list_row.xml | 25 +- .../src/main/res/layout/select_categories.xml | 63 +- ...ttings_username_changer_confirm_dialog.xml | 21 +- .../src/main/res/layout/signup_epilogue.xml | 183 ++-- .../single_choice_recycler_view_item.xml | 32 +- .../res/layout/site_creation_domains_item.xml | 33 +- .../layout/site_creation_domains_screen.xml | 30 +- .../layout/site_creation_error_with_retry.xml | 34 +- .../res/layout/site_creation_form_screen.xml | 6 +- .../res/layout/site_creation_header_item.xml | 13 +- .../site_creation_preview_header_item.xml | 7 +- .../site_creation_preview_screen_default.xml | 32 +- .../layout/site_creation_preview_skeleton.xml | 1 + .../site_creation_preview_skeleton_set.xml | 17 +- ...te_creation_preview_web_view_container.xml | 44 +- .../site_creation_search_input_item.xml | 73 +- .../res/layout/site_creation_segment_item.xml | 18 +- .../site_creation_suggestions_error_item.xml | 29 +- .../main/res/layout/site_picker_activity.xml | 73 +- .../main/res/layout/site_picker_listitem.xml | 34 +- .../layout/site_settings_format_dialog.xml | 29 +- .../site_settings_tag_detail_fragment.xml | 92 +- .../site_settings_tag_list_activity.xml | 82 +- .../res/layout/site_settings_tag_list_row.xml | 31 +- .../layout/site_settings_timezone_dialog.xml | 13 +- .../main/res/layout/start_over_preference.xml | 46 +- ...ats_all_time_widget_configure_activity.xml | 24 +- .../res/layout/stats_block_activity_item.xml | 47 +- .../res/layout/stats_block_bar_chart_item.xml | 34 +- .../res/layout/stats_block_big_title_item.xml | 14 +- .../stats_block_dialog_buttons_item.xml | 23 +- .../res/layout/stats_block_divider_item.xml | 9 +- .../res/layout/stats_block_empty_item.xml | 2 +- .../layout/stats_block_four_columns_item.xml | 23 +- .../res/layout/stats_block_header_item.xml | 26 +- .../res/layout/stats_block_image_item.xml | 10 +- .../main/res/layout/stats_block_info_item.xml | 16 +- .../res/layout/stats_block_legend_item.xml | 5 +- .../main/res/layout/stats_block_link_item.xml | 18 +- .../main/res/layout/stats_block_list_item.xml | 49 +- .../res/layout/stats_block_loading_item.xml | 6 +- .../layout/stats_block_map_legend_item.xml | 17 +- .../res/layout/stats_block_referred_item.xml | 15 +- .../layout/stats_block_selectable_column.xml | 21 +- .../layout/stats_block_single_activity.xml | 11 +- .../main/res/layout/stats_block_tabs_item.xml | 15 +- .../main/res/layout/stats_block_tag_item.xml | 16 +- .../main/res/layout/stats_block_text_item.xml | 18 +- .../res/layout/stats_block_title_item.xml | 16 +- .../res/layout/stats_block_value_item.xml | 25 +- .../res/layout/stats_block_web_view_item.xml | 2 +- .../main/res/layout/stats_color_selector.xml | 15 +- .../res/layout/stats_data_type_selector.xml | 27 +- .../main/res/layout/stats_date_selector.xml | 38 +- .../main/res/layout/stats_detail_fragment.xml | 14 +- .../src/main/res/layout/stats_empty_view.xml | 8 +- .../src/main/res/layout/stats_fragment.xml | 18 +- .../layout/stats_insights_popup_menu_item.xml | 6 +- .../stats_jetpack_connection_activity.xml | 29 +- .../main/res/layout/stats_list_activity.xml | 5 +- .../src/main/res/layout/stats_list_block.xml | 14 +- .../res/layout/stats_loading_activity.xml | 4 +- .../main/res/layout/stats_loading_view.xml | 25 +- ...ats_minified_widget_configure_activity.xml | 24 +- .../main/res/layout/stats_quick_scan_item.xml | 27 +- .../stats_today_widget_configure_activity.xml | 26 +- .../res/layout/stats_view_all_activity.xml | 9 +- .../res/layout/stats_view_all_fragment.xml | 17 +- .../stats_views_widget_configure_activity.xml | 26 +- .../stats_widget_configure_fragment.xml | 33 +- .../stats_widget_site_selector_item.xml | 15 +- .../res/layout/subfilter_bottom_sheet.xml | 27 +- .../main/res/layout/subfilter_component.xml | 25 +- .../res/layout/subfilter_divider_item.xml | 8 +- .../main/res/layout/subfilter_list_item.xml | 4 +- .../src/main/res/layout/tags_list_row.xml | 19 +- .../res/layout/theme_browser_activity.xml | 4 +- .../res/layout/theme_browser_fragment.xml | 23 +- .../res/layout/theme_grid_cardview_header.xml | 86 +- .../src/main/res/layout/theme_grid_item.xml | 61 +- WordPress/src/main/res/layout/toolbar.xml | 28 + .../src/main/res/layout/toolbar_login.xml | 22 + .../src/main/res/layout/toolbar_main.xml | 20 +- .../src/main/res/layout/toolbar_switch.xml | 9 +- .../username_changer_dialog_fragment.xml | 71 +- WordPress/src/main/res/layout/webview.xml | 4 +- .../src/main/res/layout/wp_preference.xml | 64 ++ .../res/layout/wp_preference_category.xml | 19 + .../main/res/layout/wp_preference_layout.xml | 68 ++ .../main/res/layout/wp_simple_list_item_1.xml | 4 +- WordPress/src/main/res/layout/wppref_view.xml | 43 +- .../main/res/layout/wpwebview_activity.xml | 64 +- .../src/main/res/menu/menu_comments_cab.xml | 25 +- .../main/res/menu/notifications_settings.xml | 6 +- .../res/menu/photo_picker_action_mode.xml | 6 +- WordPress/src/main/res/menu/site_picker.xml | 2 +- WordPress/src/main/res/menu/webview.xml | 2 +- WordPress/src/main/res/values-ar/strings.xml | 32 +- WordPress/src/main/res/values-cs/strings.xml | 767 ++++++++------- WordPress/src/main/res/values-de/strings.xml | 12 +- WordPress/src/main/res/values-el/strings.xml | 34 +- .../src/main/res/values-en-rAU/strings.xml | 1 - .../src/main/res/values-en-rCA/strings.xml | 1 - .../src/main/res/values-en-rGB/strings.xml | 12 +- .../src/main/res/values-es-rCL/strings.xml | 881 +++++++++-------- .../src/main/res/values-es-rMX/strings.xml | 574 +++++------ .../src/main/res/values-es-rVE/strings.xml | 506 +++++----- WordPress/src/main/res/values-es/strings.xml | 902 +++++++++--------- WordPress/src/main/res/values-fr/strings.xml | 12 +- WordPress/src/main/res/values-gl/strings.xml | 1 - WordPress/src/main/res/values-he/strings.xml | 24 +- WordPress/src/main/res/values-hr/strings.xml | 1 - WordPress/src/main/res/values-id/strings.xml | 12 +- WordPress/src/main/res/values-it/strings.xml | 13 +- WordPress/src/main/res/values-ja/strings.xml | 24 +- WordPress/src/main/res/values-kmr/strings.xml | 1 - WordPress/src/main/res/values-ko/strings.xml | 12 +- WordPress/src/main/res/values-nb/strings.xml | 1 - .../src/main/res/values-night/colors.xml | 41 - .../src/main/res/values-night/styles.xml | 134 --- WordPress/src/main/res/values-nl/strings.xml | 12 +- WordPress/src/main/res/values-pl/strings.xml | 1 - .../src/main/res/values-pt-rBR/strings.xml | 1 - WordPress/src/main/res/values-ro/strings.xml | 16 +- WordPress/src/main/res/values-ru/strings.xml | 12 +- WordPress/src/main/res/values-sk/strings.xml | 1 - WordPress/src/main/res/values-sq/strings.xml | 13 +- WordPress/src/main/res/values-sv/strings.xml | 12 +- .../src/main/res/values-sw600dp/styles.xml | 6 +- WordPress/src/main/res/values-tr/strings.xml | 12 +- WordPress/src/main/res/values-v27/styles.xml | 15 + WordPress/src/main/res/values-v28/strings.xml | 14 - WordPress/src/main/res/values-v29/strings.xml | 4 - .../src/main/res/values-w528dp/dimens.xml | 8 +- .../src/main/res/values-zh-rCN/strings.xml | 12 +- .../src/main/res/values-zh-rHK/strings.xml | 12 +- .../src/main/res/values-zh-rTW/strings.xml | 12 +- WordPress/src/main/res/values/attrs.xml | 23 +- WordPress/src/main/res/values/colors.xml | 33 +- WordPress/src/main/res/values/dimens.xml | 65 +- WordPress/src/main/res/values/drawables.xml | 9 + WordPress/src/main/res/values/integers.xml | 7 +- WordPress/src/main/res/values/key_strings.xml | 1 - .../src/main/res/values/reader_styles.xml | 45 +- .../src/main/res/values/stats_styles.xml | 156 ++- WordPress/src/main/res/values/strings.xml | 20 +- WordPress/src/main/res/values/styles.xml | 617 ++++++------ .../src/main/res/values/styles_calypso.xml | 30 + .../src/main/res/xml/account_settings.xml | 5 + WordPress/src/main/res/xml/app_settings.xml | 59 +- .../main/res/xml/notifications_settings.xml | 21 +- WordPress/src/main/res/xml/site_settings.xml | 159 +-- .../metadata/android/ar/changelogs/836.txt | 6 + .../metadata/android/de-DE/changelogs/831.txt | 9 - .../metadata/android/de-DE/changelogs/836.txt | 6 + .../metadata/android/en-US/changelogs/831.txt | 9 - .../metadata/android/en-US/changelogs/836.txt | 6 + .../metadata/android/es-ES/changelogs/831.txt | 9 - .../metadata/android/es-ES/changelogs/836.txt | 6 + .../metadata/android/fr-CA/changelogs/831.txt | 9 - .../metadata/android/fr-CA/changelogs/836.txt | 6 + .../metadata/android/fr-FR/changelogs/831.txt | 9 - .../metadata/android/fr-FR/changelogs/836.txt | 6 + .../metadata/android/id/changelogs/831.txt | 9 - .../metadata/android/id/changelogs/836.txt | 6 + .../metadata/android/it-IT/changelogs/831.txt | 9 - .../metadata/android/it-IT/changelogs/836.txt | 6 + .../metadata/android/iw-IL/changelogs/836.txt | 6 + .../metadata/android/ja-JP/changelogs/836.txt | 6 + .../metadata/android/ko-KR/changelogs/836.txt | 6 + .../metadata/android/nl-NL/changelogs/831.txt | 9 - .../metadata/android/nl-NL/changelogs/836.txt | 6 + .../metadata/android/pt-BR/changelogs/831.txt | 8 - fastlane/metadata/android/release_notes.xml | 201 ++-- .../metadata/android/ru-RU/changelogs/831.txt | 9 - .../metadata/android/ru-RU/changelogs/836.txt | 6 + .../metadata/android/sv-SE/changelogs/831.txt | 9 - .../metadata/android/sv-SE/changelogs/836.txt | 6 + .../metadata/android/tr-TR/changelogs/831.txt | 8 - .../metadata/android/tr-TR/changelogs/836.txt | 6 + .../metadata/android/zh-CN/changelogs/831.txt | 9 - .../metadata/android/zh-CN/changelogs/836.txt | 6 + .../metadata/android/zh-TW/changelogs/831.txt | 9 - .../metadata/android/zh-TW/changelogs/836.txt | 6 + .../android/editor/AztecEditorFragment.java | 9 - .../editor/GutenbergContainerFragment.java | 18 +- .../editor/GutenbergEditorFragment.java | 15 +- .../media_button_background_tint_selector.xml | 7 - .../main/res/drawable-anydpi-v21/img_hr.xml | 15 - .../src/main/res/drawable/img_hr.xml | 15 - .../main/res/layout/fragment_aztec_editor.xml | 86 +- .../src/main/res/values-night/colors.xml | 8 - .../src/main/res/values/colors.xml | 6 - libs/gutenberg-mobile | 2 +- libs/login/WordPressLoginFlow/build.gradle | 2 +- .../android/login/Login2FaFragment.java | 9 +- .../android/login/LoginEmailFragment.java | 4 +- .../login/LoginHttpAuthDialogFragment.java | 5 +- .../login/LoginMagicLinkRequestFragment.java | 5 + .../LoginSiteAddressHelpDialogFragment.java | 5 +- .../android/login/SignupEmailFragment.java | 4 +- .../login/SignupMagicLinkFragment.java | 5 +- .../widgets/WPBottomSheetDialogFragment.java | 5 + .../login/widgets/WPLoginInputRow.java | 43 +- .../login_magic_link_request_screen.xml | 88 +- .../login_magic_link_sent_screen.xml | 90 +- .../signup_bottom_sheet_dialog.xml | 47 +- .../res/layout-land/signup_magic_link.xml | 85 +- .../src/main/res/layout/login_2fa_screen.xml | 2 +- .../main/res/layout/login_alert_http_auth.xml | 18 +- .../layout/login_alert_site_address_help.xml | 14 +- .../layout/login_email_password_screen.xml | 43 +- .../main/res/layout/login_email_screen.xml | 108 ++- .../src/main/res/layout/login_form_screen.xml | 76 +- .../src/main/res/layout/login_input_row.xml | 28 +- .../login_magic_link_request_screen.xml | 46 +- .../layout/login_magic_link_sent_screen.xml | 37 +- .../res/layout/login_site_address_screen.xml | 22 +- .../layout/login_username_password_screen.xml | 71 +- .../res/layout/signup_bottom_sheet_dialog.xml | 43 +- .../main/res/layout/signup_email_fragment.xml | 30 +- .../src/main/res/layout/signup_magic_link.xml | 58 +- .../src/main/res/layout/toolbar_login.xml | 39 +- .../src/main/res/values/attrs.xml | 3 + .../src/main/res/values/styles.xml | 57 +- .../org/wordpress/android/util/AppLog.java | 20 + .../util/helpers/SwipeToRefreshHelper.java | 22 +- 735 files changed, 15372 insertions(+), 13114 deletions(-) delete mode 100644 WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt delete mode 100644 WordPress/src/main/java/org/wordpress/android/ui/WPWebView.kt delete mode 100644 WordPress/src/main/java/org/wordpress/android/util/AppThemeUtils.kt delete mode 100644 WordPress/src/main/java/org/wordpress/android/util/ConfigurationExtensions.kt delete mode 100644 WordPress/src/main/java/org/wordpress/android/widgets/BadgedImageView.kt create mode 100644 WordPress/src/main/res/anim/pressed_card.xml create mode 100644 WordPress/src/main/res/color/black_translucent_50_neutral_70_selector.xml create mode 100644 WordPress/src/main/res/color/neutral_10_neutral_0_selector.xml create mode 100644 WordPress/src/main/res/color/neutral_50_neutral_20_selector.xml create mode 100644 WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml create mode 100644 WordPress/src/main/res/color/neutral_accent_neutral_40_selector.xml create mode 100644 WordPress/src/main/res/color/neutral_neutral_20_selector.xml create mode 100644 WordPress/src/main/res/color/neutral_primary_40_neutral_40_selector.xml delete mode 100644 WordPress/src/main/res/color/on_surface_disabled_selector.xml delete mode 100644 WordPress/src/main/res/color/on_surface_divider.xml delete mode 100644 WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml delete mode 100644 WordPress/src/main/res/color/on_surface_medium_primary_selector.xml delete mode 100644 WordPress/src/main/res/color/on_surface_medium_secondary_selector.xml delete mode 100644 WordPress/src/main/res/color/on_surface_primary_selector.xml create mode 100644 WordPress/src/main/res/color/primary_0_gray_20_gray_40_selector.xml create mode 100644 WordPress/src/main/res/color/primary_0_gray_90_gray_50_selector.xml create mode 100644 WordPress/src/main/res/color/primary_30_neutral_10_selector.xml create mode 100644 WordPress/src/main/res/color/primary_30_neutral_selector.xml create mode 100644 WordPress/src/main/res/color/primary_30_primary_20_selector.xml create mode 100644 WordPress/src/main/res/color/primary_40_gray_20_gray_40_selector.xml create mode 100644 WordPress/src/main/res/color/primary_40_gray_90_gray_50_selector.xml create mode 100644 WordPress/src/main/res/color/primary_40_neutral_40_selector.xml create mode 100644 WordPress/src/main/res/color/primary_5_neutral_20_selector.xml delete mode 100644 WordPress/src/main/res/color/primary_disabled_selector.xml delete mode 100644 WordPress/src/main/res/color/primary_on_surface_disabled_selector.xml delete mode 100644 WordPress/src/main/res/color/primary_on_surface_selector.xml create mode 100644 WordPress/src/main/res/color/quick_start_icon_selector.xml create mode 100644 WordPress/src/main/res/color/quick_start_title_selector.xml create mode 100644 WordPress/src/main/res/color/related_posts_preview_header.xml delete mode 100644 WordPress/src/main/res/color/secondary_disabled_selector.xml delete mode 100644 WordPress/src/main/res/color/secondary_variant_disabled_selector.xml mode change 100644 => 100755 WordPress/src/main/res/drawable-hdpi/insights_management_feature_image.png mode change 100644 => 100755 WordPress/src/main/res/drawable-hdpi/insights_management_feature_image_tab.png create mode 100644 WordPress/src/main/res/drawable-ldrtl/bg_rectangle_gradient_primary_50_transparent.xml rename WordPress/src/main/res/{drawable/bg_rectangle_warning_surface.xml => drawable-ldrtl/bg_rectangle_warning_0_warning.xml} (62%) rename WordPress/src/main/res/drawable-ldrtl/{bg_rectangle_warning_surface_with_padding.xml => bg_rectangle_warning_0_warning_white.xml} (64%) create mode 100644 WordPress/src/main/res/drawable-ldrtl/people_list_divider.xml mode change 100644 => 100755 WordPress/src/main/res/drawable-mdpi/insights_management_feature_image.png mode change 100644 => 100755 WordPress/src/main/res/drawable-mdpi/insights_management_feature_image_tab.png delete mode 100644 WordPress/src/main/res/drawable-night-hdpi/insights_management_feature_image.png delete mode 100644 WordPress/src/main/res/drawable-night-hdpi/insights_management_feature_image_tab.png delete mode 100644 WordPress/src/main/res/drawable-night-mdpi/insights_management_feature_image.png delete mode 100644 WordPress/src/main/res/drawable-night-mdpi/insights_management_feature_image_tab.png delete mode 100644 WordPress/src/main/res/drawable-night-xhdpi/insights_management_feature_image.png delete mode 100644 WordPress/src/main/res/drawable-night-xhdpi/insights_management_feature_image_tab.png delete mode 100644 WordPress/src/main/res/drawable-night-xxhdpi/insights_management_feature_image.png delete mode 100644 WordPress/src/main/res/drawable-night-xxhdpi/insights_management_feature_image_tab.png delete mode 100644 WordPress/src/main/res/drawable-night-xxxhdpi/insights_management_feature_image.png delete mode 100644 WordPress/src/main/res/drawable-night-xxxhdpi/insights_management_feature_image_tab.png create mode 100644 WordPress/src/main/res/drawable-sw600dp/bg_rectangle_white_radius_bottom_card.xml create mode 100644 WordPress/src/main/res/drawable-sw600dp/bg_rectangle_white_radius_card.xml create mode 100644 WordPress/src/main/res/drawable-sw600dp/bg_rectangle_white_radius_top_card.xml mode change 100644 => 100755 WordPress/src/main/res/drawable-xhdpi/insights_management_feature_image.png mode change 100644 => 100755 WordPress/src/main/res/drawable-xhdpi/insights_management_feature_image_tab.png mode change 100644 => 100755 WordPress/src/main/res/drawable-xxhdpi/insights_management_feature_image.png mode change 100644 => 100755 WordPress/src/main/res/drawable-xxhdpi/insights_management_feature_image_tab.png create mode 100755 WordPress/src/main/res/drawable-xxxhdpi/insights_management_feature_image.png create mode 100755 WordPress/src/main/res/drawable-xxxhdpi/insights_management_feature_image_tab.png create mode 100644 WordPress/src/main/res/drawable/bg_bottom_sheet_handle_container.xml rename WordPress/src/main/res/drawable/{bg_oval_error_minus_white_16dp.xml => bg_oval_error_50_minus_white_16dp.xml} (89%) delete mode 100644 WordPress/src/main/res/drawable/bg_oval_neutral_20.xml create mode 100644 WordPress/src/main/res/drawable/bg_oval_neutral_20_stroke_white.xml create mode 100644 WordPress/src/main/res/drawable/bg_oval_primary_40_stroke_notification_unread.xml rename WordPress/src/main/res/drawable/{bg_oval_primary_plus_white_16dp.xml => bg_oval_primary_50_plus_white_16dp.xml} (89%) delete mode 100644 WordPress/src/main/res/drawable/bg_oval_warning_dark.xml create mode 100644 WordPress/src/main/res/drawable/bg_oval_warning_stroke_white.xml delete mode 100644 WordPress/src/main/res/drawable/bg_oval_white_24dp.xml rename WordPress/src/main/res/drawable/{bg_rectangle_stats_map_legend_gradient.xml => bg_rectangle_gradient_accent_5_accent.xml} (69%) create mode 100644 WordPress/src/main/res/drawable/bg_rectangle_gradient_primary_50_transparent.xml rename WordPress/src/main/res/drawable/{bg_stats_visitors_legend.xml => bg_rectangle_primary_60_16dp.xml} (76%) rename WordPress/src/main/res/{drawable-ldrtl/bg_rectangle_warning_surface.xml => drawable/bg_rectangle_warning_0_warning.xml} (62%) rename WordPress/src/main/res/drawable/{bg_rectangle_warning_surface_with_padding.xml => bg_rectangle_warning_0_warning_white.xml} (64%) create mode 100644 WordPress/src/main/res/drawable/bg_rectangle_white.xml create mode 100644 WordPress/src/main/res/drawable/button_frame.xml create mode 100644 WordPress/src/main/res/drawable/category_checkmark.xml rename WordPress/src/main/res/drawable/{ic_send_white_24dp.xml => ic_send_accent_neutral_30_24dp.xml} (82%) create mode 100644 WordPress/src/main/res/drawable/list_divider.xml create mode 100644 WordPress/src/main/res/drawable/moderate_button_selector.xml create mode 100644 WordPress/src/main/res/drawable/people_list_divider.xml create mode 100644 WordPress/src/main/res/drawable/reader_image_border.xml create mode 100644 WordPress/src/main/res/drawable/reader_new_posts_bar_background.xml create mode 100644 WordPress/src/main/res/drawable/related_posts_divider.xml create mode 100644 WordPress/src/main/res/layout-w528dp/stats_loading_view.xml delete mode 100644 WordPress/src/main/res/layout/account_settings_activity.xml rename WordPress/src/main/res/layout/{site_settings_activity.xml => activity_domain_suggestions_activity.xml} (57%) create mode 100644 WordPress/src/main/res/layout/add_quickpress_shortcut.xml delete mode 100644 WordPress/src/main/res/layout/app_settings_activity.xml delete mode 100644 WordPress/src/main/res/layout/domain_suggestions_activity.xml create mode 100644 WordPress/src/main/res/layout/home_row.xml delete mode 100644 WordPress/src/main/res/layout/my_profile_activity.xml create mode 100644 WordPress/src/main/res/layout/publicize_connect_button.xml delete mode 100644 WordPress/src/main/res/layout/quick_press_input_dialog.xml delete mode 100644 WordPress/src/main/res/layout/quick_press_widget_configure_list_row.xml delete mode 100644 WordPress/src/main/res/layout/quickpress_widget_configure_activity.xml create mode 100644 WordPress/src/main/res/layout/toolbar.xml create mode 100644 WordPress/src/main/res/layout/toolbar_login.xml create mode 100644 WordPress/src/main/res/layout/wp_preference.xml create mode 100644 WordPress/src/main/res/layout/wp_preference_category.xml create mode 100644 WordPress/src/main/res/layout/wp_preference_layout.xml delete mode 100644 WordPress/src/main/res/values-night/colors.xml delete mode 100644 WordPress/src/main/res/values-night/styles.xml delete mode 100644 WordPress/src/main/res/values-v28/strings.xml delete mode 100644 WordPress/src/main/res/values-v29/strings.xml create mode 100644 fastlane/metadata/android/ar/changelogs/836.txt delete mode 100644 fastlane/metadata/android/de-DE/changelogs/831.txt create mode 100644 fastlane/metadata/android/de-DE/changelogs/836.txt delete mode 100644 fastlane/metadata/android/en-US/changelogs/831.txt create mode 100644 fastlane/metadata/android/en-US/changelogs/836.txt delete mode 100644 fastlane/metadata/android/es-ES/changelogs/831.txt create mode 100644 fastlane/metadata/android/es-ES/changelogs/836.txt delete mode 100644 fastlane/metadata/android/fr-CA/changelogs/831.txt create mode 100644 fastlane/metadata/android/fr-CA/changelogs/836.txt delete mode 100644 fastlane/metadata/android/fr-FR/changelogs/831.txt create mode 100644 fastlane/metadata/android/fr-FR/changelogs/836.txt delete mode 100644 fastlane/metadata/android/id/changelogs/831.txt create mode 100644 fastlane/metadata/android/id/changelogs/836.txt delete mode 100644 fastlane/metadata/android/it-IT/changelogs/831.txt create mode 100644 fastlane/metadata/android/it-IT/changelogs/836.txt create mode 100644 fastlane/metadata/android/iw-IL/changelogs/836.txt create mode 100644 fastlane/metadata/android/ja-JP/changelogs/836.txt create mode 100644 fastlane/metadata/android/ko-KR/changelogs/836.txt delete mode 100644 fastlane/metadata/android/nl-NL/changelogs/831.txt create mode 100644 fastlane/metadata/android/nl-NL/changelogs/836.txt delete mode 100644 fastlane/metadata/android/pt-BR/changelogs/831.txt delete mode 100644 fastlane/metadata/android/ru-RU/changelogs/831.txt create mode 100644 fastlane/metadata/android/ru-RU/changelogs/836.txt delete mode 100644 fastlane/metadata/android/sv-SE/changelogs/831.txt create mode 100644 fastlane/metadata/android/sv-SE/changelogs/836.txt delete mode 100644 fastlane/metadata/android/tr-TR/changelogs/831.txt create mode 100644 fastlane/metadata/android/tr-TR/changelogs/836.txt delete mode 100644 fastlane/metadata/android/zh-CN/changelogs/831.txt create mode 100644 fastlane/metadata/android/zh-CN/changelogs/836.txt delete mode 100644 fastlane/metadata/android/zh-TW/changelogs/831.txt create mode 100644 fastlane/metadata/android/zh-TW/changelogs/836.txt delete mode 100644 libs/editor/WordPressEditor/src/main/res/color/media_button_background_tint_selector.xml delete mode 100644 libs/editor/WordPressEditor/src/main/res/drawable-anydpi-v21/img_hr.xml delete mode 100644 libs/editor/WordPressEditor/src/main/res/drawable/img_hr.xml delete mode 100755 libs/editor/WordPressEditor/src/main/res/values-night/colors.xml diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 77d5ba9f6333..b2664d3ece90 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,15 +1,13 @@ 14.5 ----- * Removes sections from post search results -* Dark Theme support - * Site Creation: faster site creation, removed intermediate steps. Just select what kind of site you'd like, enter the domain name and the site will be created. * Fixed a bug where failed post uploads were sometimes being retried indefinitely 14.4 ----- * Fix an issue where image is sometimes uploaded with a path to local storage - + 14.3 ----- * Added search to set page parent screen @@ -22,7 +20,7 @@ * Block editor: Fix issue where adding emojis to the post title added strong HTML elements to the title of the post * Block editor: We’ve introduced a new toolbar that floats above the block you’re editing, which makes navigating your blocks easier — especially complex ones. * Reader Information Architecture: added tab filtering; added bottom sheet to filter and navigate the followed sites/tags posts. - + 14.2 ----- * Block editor: Long-press Inserter icon to show options to add before/after @@ -56,7 +54,7 @@ * Block Editor: Add support for the Preformatted block. * Block Editor: Add support for changing Settings in the List Block. * Block Editor: Add support for Video block settings. - + 13.8 ----- * Modified Blog Post search to search for posts under all categories. @@ -73,7 +71,7 @@ * Fixed time displayed on Post Conflict Detected and Unpublished Revision dialogs * Block editor: Fix issue when removing image/page break block crashes the app * Fixed a crash on Samsung devices running Android 5 (Lollipop) - + * Removed support for Giphy 13.6 diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 609b0432e0c7..9ad3d5b8dfd0 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -168,10 +168,10 @@ dependencies { implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.exifinterface:exifinterface:1.0.0' implementation 'androidx.media:media:1.0.1' - implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.0.0' - implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.android.material:material:1.0.0' implementation 'androidx.percentlayout:percentlayout:1.0.0' implementation 'androidx.preference:preference:1.0.0' implementation "androidx.work:work-runtime:$androidx_work_version" diff --git a/WordPress/lint-baseline.xml b/WordPress/lint-baseline.xml index 6e14796f1ffa..50a205427243 100644 --- a/WordPress/lint-baseline.xml +++ b/WordPress/lint-baseline.xml @@ -1,18 +1,6 @@ - - - - @@ -137,20 +137,20 @@ + android:theme="@style/CalypsoTheme.NoActionBarShadow" /> + android:theme="@style/WordPress.TransparentToolbarTheme" /> + android:theme="@style/CalypsoTheme" /> + android:theme="@style/CalypsoTheme" /> + android:theme="@style/CalypsoTheme" /> @@ -189,22 +189,22 @@ + android:theme="@style/CalypsoTheme" /> + android:theme="@style/CalypsoTheme" /> + android:theme="@style/CalypsoTheme" /> - + + android:theme="@style/Calypso.NoActionBar" /> + android:theme="@style/Calypso.NoActionBar" /> + android:theme="@style/CalypsoTheme" /> + android:theme="@style/Calypso.NoActionBar" /> + android:theme="@style/Calypso.NoActionBar"/> - + android:theme="@style/Calypso.NoActionBar" /> + @@ -307,29 +305,29 @@ + android:theme="@style/Theme.AppCompat.NoActionBar" /> + android:theme="@style/MediaSettings.Activity" /> + android:theme="@style/Calypso.NoActionBar"> + android:theme="@style/CalypsoTheme" /> + android:theme="@style/Calypso.NoActionBar" /> + android:label="WordPress QuickPress"> @@ -510,12 +507,12 @@ + android:theme="@style/CalypsoTheme" /> + android:theme="@style/Calypso.NoActionBar" /> + android:theme="@style/CalypsoTheme" /> + android:theme="@style/Calypso.NoActionBar"/> + android:theme="@style/Calypso.NoActionBar"/> + android:theme="@style/Calypso.NoActionBar"/> + android:theme="@style/Calypso.NoActionBar"/> + android:theme="@style/Calypso.NoActionBar"/> + android:theme="@style/Calypso.NoActionBar"/> + android:theme="@style/CalypsoTheme" /> + android:theme="@style/Calypso.NoActionBar"> - + + android:theme="@style/Calypso.NoActionBar"> - + + android:theme="@style/Calypso.NoActionBar"> - + + android:theme="@style/Calypso.NoActionBar"> - + accountNames = new ArrayList<>(); @Inject SiteStore mSiteStore; @Inject FluxCImageLoader mImageLoader; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); - setContentView(R.layout.quickpress_widget_configure_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setHomeButtonEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(true); - } + setContentView(R.layout.add_quickpress_shortcut); + setTitle(getResources().getText(R.string.quickpress_window_title)); displayAccounts(); } - @Override - public boolean onOptionsItemSelected(final MenuItem item) { - if (item.getItemId() == android.R.id.home) { - onBackPressed(); - return true; - } - return super.onOptionsItemSelected(item); - } - private void displayAccounts() { List sites = mSiteStore.getVisibleSites(); ListView listView = (ListView) findViewById(android.R.id.list); + View iv = new View(this); + iv.setBackgroundResource(R.drawable.list_divider); + listView.addFooterView(iv); listView.setVerticalFadingEdgeEnabled(false); listView.setVerticalScrollBarEnabled(true); if (sites.size() > 0) { + ScrollView sv = new ScrollView(this); + sv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); + LinearLayout layout = new LinearLayout(this); + layout.setPadding(10, 10, 10, 0); + layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); + + layout.setOrientation(LinearLayout.VERTICAL); + blogNames = new String[sites.size()]; siteIds = new int[sites.size()]; - blogUrls = new String[sites.size()]; + accountUsers = new String[sites.size()]; blavatars = new String[sites.size()]; for (int i = 0; i < sites.size(); i++) { SiteModel site = sites.get(i); blogNames[i] = SiteUtils.getSiteNameOrHomeURL(site); - blogUrls[i] = site.getUrl(); + accountUsers[i] = site.getUsername(); siteIds[i] = site.getId(); blavatars[i] = SiteUtils.getSiteIconUrl(site, 60); accountNames.add(i, blogNames[i]); } - listView.setAdapter(new HomeListAdapter()); + setListAdapter(new HomeListAdapter()); listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView arg0, View row, int position, long id) { @@ -117,24 +121,20 @@ public void onItemClick(AdapterView arg0, View row, int position, long id) { } private void buildDialog(final int position) { - AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( + new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)); dialogBuilder.setTitle(R.string.quickpress_add_alert_title); - LayoutInflater layoutInflater = LayoutInflater.from(this); - //noinspection InflateParams - View dialogView = layoutInflater.inflate(R.layout.quick_press_input_dialog, null); - - TextInputEditText quickPressShortcutName = dialogView.findViewById(R.id.quick_press_input_dialog_edit_text); + final EditText quickPressShortcutName = new EditText(AddQuickPressShortcutActivity.this); quickPressShortcutName.setText(getString(R.string.quickpress_shortcut_with_account_param, StringEscapeUtils.unescapeHtml4(accountNames.get(position)))); - - dialogBuilder.setView(dialogView); + dialogBuilder.setView(quickPressShortcutName); dialogBuilder.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (TextUtils.isEmpty(quickPressShortcutName.getText())) { ToastUtils.showToast(AddQuickPressShortcutActivity.this, R.string.quickpress_add_error, - ToastUtils.Duration.LONG); + ToastUtils.Duration.LONG); } else { Intent shortcutIntent = new Intent(getApplicationContext(), EditPostActivity.class); shortcutIntent.setAction(Intent.ACTION_MAIN); @@ -206,19 +206,19 @@ public View getView(int position, View convertView, ViewGroup parent) { RelativeLayout view = (RelativeLayout) convertView; if (view == null) { LayoutInflater inflater = getLayoutInflater(); - view = (RelativeLayout) inflater.inflate(R.layout.quick_press_widget_configure_list_row, parent, false); + view = (RelativeLayout) inflater.inflate(R.layout.home_row, parent, false); } - view.setId(siteIds[position]); + String username = accountUsers[position]; + view.setId(Integer.valueOf(siteIds[position])); TextView blogName = (TextView) view.findViewById(R.id.blogName); - TextView blogUrl = (TextView) view.findViewById(R.id.blogUrl); + TextView blogUsername = (TextView) view.findViewById(R.id.blogUser); NetworkImageView blavatar = (NetworkImageView) view.findViewById(R.id.blavatar); - blavatar.setDefaultImageResId(R.drawable.ic_placeholder_blavatar_grey_lighten_20_40dp); blogName.setText( StringEscapeUtils.unescapeHtml4(blogNames[position])); - blogUrl.setText( - StringEscapeUtils.unescapeHtml4(blogUrls[position])); + blogUsername.setText( + StringEscapeUtils.unescapeHtml4(username)); blavatar.setErrorImageResId(R.drawable.bg_rectangle_neutral_10_globe_32dp); blavatar.setImageUrl(blavatars[position], mImageLoader); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java index bbafa3ff1787..47b9b2d4c8ff 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java @@ -16,11 +16,12 @@ import android.widget.TextView; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.R; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.ToastUtils; import java.util.ArrayList; @@ -31,19 +32,23 @@ /** * views the activity log (see utils/AppLog.java) */ -public class AppLogViewerActivity extends LocaleAwareActivity { +public class AppLogViewerActivity extends AppCompatActivity { private static final int ID_SHARE = 1; private static final int ID_COPY_TO_CLIPBOARD = 2; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.logviewer_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { + actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.reader_title_applog); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/CollapseFullScreenDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/CollapseFullScreenDialogFragment.java index 61a87e5952f4..04411af46329 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/CollapseFullScreenDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/CollapseFullScreenDialogFragment.java @@ -19,11 +19,9 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.core.content.res.ResourcesCompat; -import androidx.core.view.MenuItemCompat; import androidx.core.view.ViewCompat; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; @@ -31,8 +29,6 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; -import com.google.android.material.elevation.ElevationOverlayProvider; - import org.wordpress.android.R; /** @@ -59,17 +55,13 @@ public class CollapseFullScreenDialogFragment extends DialogFragment { public interface CollapseFullScreenDialogContent { boolean onCollapseClicked(CollapseFullScreenDialogController controller); - boolean onConfirmClicked(CollapseFullScreenDialogController controller); - void onViewCreated(CollapseFullScreenDialogController controller); } public interface CollapseFullScreenDialogController { void collapse(@Nullable Bundle result); - void confirm(@Nullable Bundle result); - void setConfirmEnabled(boolean enabled); } @@ -107,7 +99,7 @@ public void onActivityCreated(Bundle savedInstanceState) { getChildFragmentManager() .beginTransaction() .setCustomAnimations(R.anim.full_screen_dialog_fragment_none, 0, 0, - R.anim.full_screen_dialog_fragment_none) + R.anim.full_screen_dialog_fragment_none) .add(R.id.full_screen_dialog_fragment_content, mFragment) .commitNow(); } @@ -202,7 +194,7 @@ public void show(FragmentManager manager, String tag) { public int show(FragmentTransaction transaction, String tag) { initBuilderArguments(); transaction.setCustomAnimations(R.anim.full_screen_dialog_fragment_slide_up, 0, 0, - R.anim.full_screen_dialog_fragment_slide_down); + R.anim.full_screen_dialog_fragment_slide_down); return transaction.add(android.R.id.content, this, tag).addToBackStack(null).commit(); } @@ -265,27 +257,26 @@ private void initBuilderArguments() { */ private void initToolbar(View view) { Toolbar toolbar = view.findViewById(R.id.full_screen_dialog_fragment_toolbar); - - ElevationOverlayProvider elevationOverlayProvider = new ElevationOverlayProvider(view.getContext()); - float appbarElevation = getResources().getDimension(R.dimen.appbar_elevation); - int elevatedColor = elevationOverlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded(appbarElevation); - toolbar.setBackgroundColor(elevatedColor); - toolbar.setTitle(mTitle); toolbar.setNavigationContentDescription(R.string.description_collapse); toolbar.setNavigationIcon(ContextCompat.getDrawable(view.getContext(), R.drawable.ic_chevron_down_white_24dp)); - toolbar.setNavigationOnClickListener(v -> onCollapseClicked()); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + onCollapseClicked(); + } + }); if (!mAction.isEmpty()) { Menu menu = toolbar.getMenu(); mMenuAction = menu.add(0, ID_ACTION, 0, this.mAction); - mMenuAction.setIcon(R.drawable.ic_send_white_24dp); - MenuItemCompat.setIconTintList(mMenuAction, - AppCompatResources.getColorStateList(view.getContext(), R.color.accent_neutral_30_selector)); + mMenuAction.setIcon(R.drawable.ic_send_accent_neutral_30_24dp); mMenuAction.setEnabled(false); mMenuAction.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mMenuAction.setOnMenuItemClickListener( - item -> { + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == ID_ACTION) { onConfirmClicked(); return true; @@ -293,6 +284,7 @@ private void initToolbar(View view) { return false; } } + } ); } } @@ -442,11 +434,11 @@ public Builder setAction(@StringRes int textId) { /** * Set {@link Fragment} to be added as dialog, which must implement {@link CollapseFullScreenDialogContent}. * - * @param contentClass Fragment class to be instantiated + * @param contentClass Fragment class to be instantiated * @param contentArguments arguments to be added to Fragment * @return {@link Builder} object to allow for chaining of calls to set methods * @throws IllegalArgumentException if content class does not implement - * {@link CollapseFullScreenDialogContent} interface + * {@link CollapseFullScreenDialogContent} interface */ public Builder setContent(Class contentClass, @Nullable Bundle contentArguments) { if (!CollapseFullScreenDialogContent.class.isAssignableFrom(contentClass)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/CommentFullScreenDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/CommentFullScreenDialogFragment.kt index 6a84005a0992..0faf56b62672 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/CommentFullScreenDialogFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/CommentFullScreenDialogFragment.kt @@ -16,7 +16,6 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.wordpress.android.R import org.wordpress.android.fluxc.model.SiteModel -import org.wordpress.android.fluxc.store.SiteStore import org.wordpress.android.ui.CollapseFullScreenDialogFragment.CollapseFullScreenDialogContent import org.wordpress.android.ui.CollapseFullScreenDialogFragment.CollapseFullScreenDialogController import org.wordpress.android.ui.suggestion.util.SuggestionServiceConnectionManager @@ -24,6 +23,7 @@ import org.wordpress.android.ui.suggestion.util.SuggestionUtils import org.wordpress.android.util.SiteUtils import org.wordpress.android.widgets.SuggestionAutoCompleteText import javax.inject.Inject +import org.wordpress.android.fluxc.store.SiteStore class CommentFullScreenDialogFragment : Fragment(), CollapseFullScreenDialogContent { @Inject lateinit var viewModel: CommentFullScreenDialogViewModel @@ -114,7 +114,7 @@ class CommentFullScreenDialogFragment : Fragment(), CollapseFullScreenDialogCont dialogController = controller } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) AndroidSupportInjection.inject(this) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/DeepLinkingIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/DeepLinkingIntentReceiverActivity.java index 236d82c1862a..9dc2f4bf942e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/DeepLinkingIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/DeepLinkingIntentReceiverActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -7,6 +8,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.R; import org.wordpress.android.WordPress; @@ -17,6 +19,7 @@ import org.wordpress.android.ui.reader.ReaderActivityLauncher; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.analytics.AnalyticsUtils; @@ -34,7 +37,7 @@ *

* Redirects users to the reader activity along with IDs passed in the intent */ -public class DeepLinkingIntentReceiverActivity extends LocaleAwareActivity { +public class DeepLinkingIntentReceiverActivity extends AppCompatActivity { private static final String DEEP_LINK_HOST_NOTIFICATIONS = "notifications"; private static final String DEEP_LINK_HOST_POST = "post"; private static final String DEEP_LINK_HOST_STATS = "stats"; @@ -55,6 +58,11 @@ public class DeepLinkingIntentReceiverActivity extends LocaleAwareActivity { @Inject AccountStore mAccountStore; @Inject SiteStore mSiteStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/FilteredRecyclerView.java b/WordPress/src/main/java/org/wordpress/android/ui/FilteredRecyclerView.java index b9c6aba93f15..d09aee635ba7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/FilteredRecyclerView.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/FilteredRecyclerView.java @@ -26,7 +26,6 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.elevation.ElevationOverlayProvider; import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout.OnTabSelectedListener; import com.google.android.material.tabs.TabLayout.Tab; @@ -34,7 +33,6 @@ import org.wordpress.android.R; import org.wordpress.android.models.FilterCriteria; import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.DisplayUtils; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.helpers.SwipeToRefreshHelper; @@ -188,15 +186,6 @@ private void init(@NonNull Context context, @Nullable AttributeSet attrs) { mToolbar = findViewById(R.id.toolbar_with_spinner); mAppBarLayout = findViewById(R.id.app_bar_layout); - ElevationOverlayProvider elevationOverlayProvider = new ElevationOverlayProvider(getContext()); - float cardElevation = getResources().getDimension(R.dimen.card_elevation); - int appBarColor = - elevationOverlayProvider - .compositeOverlay(ContextExtensionsKt.getColorFromAttribute(getContext(), R.attr.wpColorAppBar), - cardElevation); - - mToolbar.setBackgroundColor(appBarColor); - AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) mToolbar.getLayoutParams(); if (mToolbarDisableScrollGestures) { params.setScrollFlags(0); @@ -428,17 +417,17 @@ public void setToolbarSpinnerDrawable(int drawableResId) { public void setToolbarLeftPadding(int paddingLeft) { ViewCompat.setPaddingRelative(mToolbar, paddingLeft, mToolbar.getPaddingTop(), - ViewCompat.getPaddingEnd(mToolbar), mToolbar.getPaddingBottom()); + ViewCompat.getPaddingEnd(mToolbar), mToolbar.getPaddingBottom()); } public void setToolbarRightPadding(int paddingRight) { ViewCompat.setPaddingRelative(mToolbar, ViewCompat.getPaddingStart(mToolbar), mToolbar.getPaddingTop(), - paddingRight, mToolbar.getPaddingBottom()); + paddingRight, mToolbar.getPaddingBottom()); } public void setToolbarLeftAndRightPadding(int paddingLeft, int paddingRight) { ViewCompat.setPaddingRelative(mToolbar, paddingLeft, mToolbar.getPaddingTop(), paddingRight, - mToolbar.getPaddingBottom()); + mToolbar.getPaddingBottom()); } public void setToolbarTitle(@StringRes int title, int startMargin) { @@ -497,13 +486,13 @@ public AppBarLayout getAppBarLayout() { } /* - * use this if you need to reload the criterias for this FilteredRecyclerView. The actual data loading goes - * through the FilteredRecyclerView lifecycle using its listeners: - * - * - FilterCriteriaAsyncLoaderListener - * and - * - FilterListener.onLoadFilterCriteriaOptions - * */ + * use this if you need to reload the criterias for this FilteredRecyclerView. The actual data loading goes + * through the FilteredRecyclerView lifecycle using its listeners: + * + * - FilterCriteriaAsyncLoaderListener + * and + * - FilterListener.onLoadFilterCriteriaOptions + * */ public void refreshFilterCriteriaOptions() { setup(true); } @@ -633,7 +622,7 @@ public int getIndexOfCriteria(FilterCriteria tm) { */ public boolean isFirstItemVisible() { if (mRecyclerView == null - || mRecyclerView.getLayoutManager() == null) { + || mRecyclerView.getLayoutManager() == null) { return false; } @@ -661,7 +650,7 @@ public interface FilterListener { * The Spinner is then loaded with such array of FilterCriterias, through which the main data can be filtered. * * @param listener to be called to pass the FilterCriteria array when done - * @param refresh "true"if the criterias need be refreshed + * @param refresh "true"if the criterias need be refreshed */ void onLoadFilterCriteriaOptionsAsync(FilterCriteriaAsyncLoaderListener listener, boolean refresh); @@ -699,7 +688,7 @@ public interface FilterListener { * Called when there's no data to show. * * @param emptyViewMsgType this will hint you on the reason why no data is being shown, so you can return - * a proper message to be displayed to the user + * a proper message to be displayed to the user * @return the message to be displayed to the user, or null if using a Custom Empty View (see below) */ String onShowEmptyViewMessage(EmptyViewMessageType emptyViewMsgType); @@ -709,7 +698,7 @@ public interface FilterListener { * be called otherwise). * * @param emptyViewMsgType this will hint you on the reason why no data is being shown, and - * also here you should perform any actions on your custom empty view + * also here you should perform any actions on your custom empty view * @return nothing */ void onShowCustomEmptyView(EmptyViewMessageType emptyViewMsgType); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/FullScreenDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/FullScreenDialogFragment.java index 266beaa5fbfa..21c818267505 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/FullScreenDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/FullScreenDialogFragment.java @@ -261,28 +261,34 @@ private void initBuilderArguments() { * @param view {@link View} */ private void initToolbar(View view) { - mToolbar = view.findViewById(R.id.toolbar_main); + mToolbar = view.findViewById(R.id.full_screen_dialog_fragment_toolbar); mToolbar.setTitle(mTitle); mToolbar.setSubtitle(mSubtitle); + mToolbar.setSubtitleTextAppearance(view.getContext(), R.style.Toolbar_Subtitle); + mToolbar.setBackgroundColor(getResources().getColor(mToolbarColor)); mToolbar.setNavigationIcon(ContextCompat.getDrawable(view.getContext(), R.drawable.ic_close_white_24dp)); mToolbar.setNavigationContentDescription(R.string.close_dialog_button_desc); - mToolbar.setNavigationOnClickListener(v -> onDismissClicked()); - - if (mToolbarColor > 0) { - mToolbar.setBackgroundColor(getResources().getColor(mToolbarColor)); - } + mToolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + onDismissClicked(); + } + }); if (!mAction.isEmpty()) { Menu menu = mToolbar.getMenu(); mActionItem = menu.add(0, ID_ACTION, 0, this.mAction); mActionItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mActionItem.setOnMenuItemClickListener( - item -> { - if (item.getItemId() == ID_ACTION) { - onConfirmClicked(); - return true; - } else { - return false; + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + if (item.getItemId() == ID_ACTION) { + onConfirmClicked(); + return true; + } else { + return false; + } } } ); @@ -415,7 +421,7 @@ public static class Builder { String mSubtitle = ""; String mTitle = ""; boolean mHideActivityBar = false; - int mToolbarColor = 0; + int mToolbarColor = R.color.primary; /** * Builder to construct {@link FullScreenDialogFragment}. diff --git a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java index 0cb686fed0b7..de5e22cebd6b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java @@ -6,6 +6,7 @@ import android.text.TextUtils; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import org.wordpress.android.R; @@ -34,7 +35,7 @@ *

* Redirects users to the stats activity if the jetpack connection was succesful */ -public class JetpackConnectionResultActivity extends LocaleAwareActivity { +public class JetpackConnectionResultActivity extends AppCompatActivity { private static final String ALREADY_CONNECTED = "already-connected"; private static final String REASON_PARAM = "reason"; private static final String SOURCE_PARAM = "source"; @@ -54,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.stats_loading_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); + Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallActivity.kt index 31f7ab714a8f..1f2c6e938b1d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallActivity.kt @@ -2,19 +2,20 @@ package org.wordpress.android.ui import android.os.Bundle import android.view.MenuItem -import kotlinx.android.synthetic.main.toolbar_main.* +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.toolbar.* import org.wordpress.android.R import org.wordpress.android.analytics.AnalyticsTracker.Stat.INSTALL_JETPACK_CANCELLED import org.wordpress.android.ui.JetpackConnectionUtils.trackWithSource import org.wordpress.android.ui.JetpackRemoteInstallFragment.Companion.TRACKING_SOURCE_KEY -class JetpackRemoteInstallActivity : LocaleAwareActivity() { +class JetpackRemoteInstallActivity : AppCompatActivity() { public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.jetpack_remote_install_activity) - setSupportActionBar(toolbar_main) + setSupportActionBar(toolbar) supportActionBar?.let { it.setHomeButtonEnabled(true) it.setDisplayHomeAsUpEnabled(true) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallViewState.kt b/WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallViewState.kt index ff672099ff23..056b7f8de523 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallViewState.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/JetpackRemoteInstallViewState.kt @@ -24,7 +24,7 @@ sealed class JetpackRemoteInstallViewState( R.string.install_jetpack, R.string.install_jetpack_message, icon = R.drawable.ic_plans_white_24dp, - iconTint = R.color.jetpack_green, + iconTint = R.color.jetpack_green_50, buttonResource = R.string.install_jetpack_continue, onClick = onClick ) @@ -34,7 +34,7 @@ sealed class JetpackRemoteInstallViewState( R.string.installing_jetpack, R.string.installing_jetpack_message, icon = R.drawable.ic_plans_white_24dp, - iconTint = R.color.jetpack_green, + iconTint = R.color.jetpack_green_50, progressBarVisible = true ) @@ -44,7 +44,7 @@ sealed class JetpackRemoteInstallViewState( R.string.jetpack_installed_message, icon = R.drawable.ic_plans_white_24dp, buttonResource = R.string.install_jetpack_continue, - iconTint = R.color.jetpack_green, + iconTint = R.color.jetpack_green_50, onClick = onClick ) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt deleted file mode 100644 index 54453ca1a52e..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/ui/LocaleAwareActivity.kt +++ /dev/null @@ -1,33 +0,0 @@ -package org.wordpress.android.ui - -import android.content.Context -import android.content.res.Configuration -import androidx.appcompat.app.AppCompatActivity -import org.wordpress.android.util.LocaleManager - -/** - * Newer versions of the AppCompat library no longer support locale changes at application level, - * so this activity is used to help handle those changes at activity level. - * Reference: https://issuetracker.google.com/issues/141869006#comment9 - * - * All the actual logic is inside the LocaleManager class, which should be used directly in cases where - * extending from this class is not possible/preferable. - * - * Note: please be mindful of the principle of favoring composition over inheritance and refrain from - * building upon this class unless it's absolutely necessary. - */ -abstract class LocaleAwareActivity : AppCompatActivity() { - /** - * Used to update locales on API 21 to API 25. - */ - override fun attachBaseContext(newBase: Context?) { - super.attachBaseContext(LocaleManager.setLocale(newBase)) - } - - /** - * Used to update locales on API 26 and beyond. - */ - override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) { - super.applyOverrideConfiguration(LocaleManager.updatedConfigLocale(baseContext, overrideConfiguration)) - } -} diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java index fcf28f73ab08..df8085e18a8e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui; +import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; @@ -8,6 +9,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.TaskStackBuilder; import org.wordpress.android.R; @@ -22,6 +24,7 @@ import org.wordpress.android.ui.media.MediaBrowserActivity; import org.wordpress.android.ui.media.MediaBrowserType; import org.wordpress.android.util.FluxCUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.MediaUtils; import org.wordpress.android.util.PermissionUtils; import org.wordpress.android.util.ToastUtils; @@ -42,7 +45,7 @@ * Moreover it lists what actions the user can perform and redirects the user to the activity, * along with the content passed in the intent. */ -public class ShareIntentReceiverActivity extends LocaleAwareActivity implements ShareIntentFragmentListener { +public class ShareIntentReceiverActivity extends AppCompatActivity implements ShareIntentFragmentListener { private static final String SHARE_LAST_USED_BLOG_ID_KEY = "wp-settings-share-last-used-text-blogid"; private static final String KEY_SELECTED_SITE_LOCAL_ID = "KEY_SELECTED_SITE_LOCAL_ID"; private static final String KEY_SHARE_ACTION_ID = "KEY_SHARE_ACTION_ID"; @@ -62,6 +65,11 @@ protected void onNewIntent(Intent intent) { refreshContent(); } + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.java index 23fbb32375ea..e40238b56636 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WPLaunchActivity.java @@ -1,21 +1,30 @@ package org.wordpress.android.ui; +import android.content.Context; import android.content.Intent; import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; + import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.ui.main.WPMainActivity; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.ProfilingUtils; import org.wordpress.android.util.ToastUtils; -public class WPLaunchActivity extends LocaleAwareActivity { +public class WPLaunchActivity extends AppCompatActivity { /* * this the main (default) activity, which does nothing more than launch the * previously active activity on startup - note that it's defined in the * manifest to have no UI */ + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WPWebView.kt b/WordPress/src/main/java/org/wordpress/android/ui/WPWebView.kt deleted file mode 100644 index e5954ed14b92..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/ui/WPWebView.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.wordpress.android.ui - -import android.content.Context -import android.content.res.Configuration -import android.os.Build -import android.util.AttributeSet -import android.webkit.WebView -import androidx.appcompat.view.ContextThemeWrapper -import org.wordpress.android.R - -// https://stackoverflow.com/questions/58028821/webview-crash-on-android-5-5-1-api-21-22-resourcesnotfoundexception-string-r -open class WPWebView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : - WebView(context.getModifiedContextForOlderAPIs(), attrs, defStyleAttr) { - init { - isFocusable = true - isFocusableInTouchMode = true - } -} - -private fun Context.getModifiedContextForOlderAPIs(): Context { - return if (Build.VERSION.SDK_INT in 21..22) { - ContextThemeWrapper(createConfigurationContext(Configuration()), R.style.WordPress) - } else this -} diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java index ffc9accf0aab..716b4727c76c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java @@ -4,7 +4,8 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; -import android.graphics.drawable.ColorDrawable; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; @@ -34,8 +35,6 @@ import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProviders; -import com.google.android.material.elevation.ElevationOverlayProvider; - import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.PostImmutableModel; @@ -46,8 +45,6 @@ import org.wordpress.android.ui.utils.UiHelpers; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.ConfigurationExtensionsKt; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.ErrorManagedWebViewClient.ErrorManagedWebViewClientListener; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; @@ -134,7 +131,6 @@ public class WPWebViewActivity extends WebViewActivity implements ErrorManagedWe private ViewGroup mFullScreenProgressLayout; private WPWebViewViewModel mViewModel; private ListPopupWindow mPreviewModeSelector; - private ElevationOverlayProvider mElevationOverlayProvider; private View mNavBarContainer; private LinearLayout mNavBar; private View mNavigateForwardButton; @@ -154,12 +150,9 @@ public void onCreate(Bundle savedInstanceState) { private void setLightStatusBar() { if (VERSION.SDK_INT >= VERSION_CODES.M) { Window window = getWindow(); - window.setStatusBarColor(ContextExtensionsKt.getColorFromAttribute(this, R.attr.colorSurface)); - - if (!ConfigurationExtensionsKt.isDarkTheme(getResources().getConfiguration())) { - window.getDecorView().setSystemUiVisibility( - window.getDecorView().getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } + window.setStatusBarColor(getColor(R.color.white)); + window.getDecorView().setSystemUiVisibility( + window.getDecorView().getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } } @@ -178,15 +171,6 @@ public final void configureView() { initViewModel(webViewUsageCategory); mNavBarContainer = findViewById(R.id.navbar_container); - - mElevationOverlayProvider = new ElevationOverlayProvider(WPWebViewActivity.this); - - int elevatedAppbarColor = - mElevationOverlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded( - getResources().getDimension(R.dimen.appbar_elevation)); - - mNavBarContainer.setBackgroundColor(elevatedAppbarColor); - mNavBar = findViewById(R.id.navbar); mNavigateBackButton = findViewById(R.id.back_button); @@ -255,6 +239,12 @@ private void setupToolbar() { showSubtitle(actionBar); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); + + Drawable upIcon = toolbar.getNavigationIcon(); + if (upIcon != null) { + upIcon.setColorFilter(getResources().getColor(R.color.gray_60), PorterDuff.Mode.SRC_ATOP); + } + if (isActionableDirectUsage()) { String title = getIntent().getStringExtra(ACTION_BAR_TITLE); if (title != null) { @@ -370,13 +360,9 @@ public void onChanged(@Nullable Unit unit) { } }); - mViewModel.getOpenExternalBrowser().observe(this, new Observer() { - @Override - public void onChanged(@Nullable Unit unit) { - ReaderActivityLauncher.openUrl(WPWebViewActivity.this, mWebView.getUrl(), - ReaderActivityLauncher.OpenUrlType.EXTERNAL); - } - }); + mViewModel.getOpenExternalBrowser().observe(this, + unit -> ReaderActivityLauncher.openUrl(WPWebViewActivity.this, getExternalBrowserUrl(), + ReaderActivityLauncher.OpenUrlType.EXTERNAL)); mViewModel.getPreviewModeSelector().observe(this, new Observer() { @Override @@ -403,12 +389,6 @@ public void onChanged(final @Nullable PreviewModeSelectorStatus previewModelSele mPreviewModeSelector.setHorizontalOffset(-popupOffset); mPreviewModeSelector.setVerticalOffset(popupOffset); mPreviewModeSelector.setModal(true); - - int elevatedPopupBackgroundColor = - mElevationOverlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded( - getResources().getDimension(R.dimen.popup_over_toolbar_elevation)); - mPreviewModeSelector.setBackgroundDrawable(new ColorDrawable(elevatedPopupBackgroundColor)); - mPreviewModeSelector.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss() { mViewModel.togglePreviewModeSelectorVisibility(false); @@ -538,7 +518,7 @@ public static void openActionableEmptyViewDirectly( Context context, WPWebViewUsageCategory directUsageCategory, String postTitle - ) { + ) { Intent intent = new Intent(context, WPWebViewActivity.class); intent.putExtra(WPWebViewActivity.WEBVIEW_USAGE_TYPE, directUsageCategory.getValue()); intent.putExtra(WPWebViewActivity.ACTION_BAR_TITLE, postTitle); @@ -614,7 +594,7 @@ private static void openWPCOMURL( String shareSubject, boolean allowPreviewModeSelection, boolean startPreviewForResult - ) { + ) { if (!checkContextAndUrl(context, url)) { return; } @@ -804,7 +784,7 @@ public static String getAuthenticationPostData(String authenticationUrl, String URLEncoder.encode(StringUtils.notNullStr(username), ENCODING_UTF8), URLEncoder.encode(StringUtils.notNullStr(password), ENCODING_UTF8), URLEncoder.encode(StringUtils.notNullStr(urlToLoad), ENCODING_UTF8) - ); + ); // Add token authorization when signing in to WP.com if (WPUrlUtils.safeToAddWordPressComAuthToken(authenticationUrl) @@ -820,6 +800,27 @@ public static String getAuthenticationPostData(String authenticationUrl, String return ""; } + /** + * This function is necessary because we want the external browser to use a link with a primary domain without + * preview parameters. + * + * 1. Within the loadContent function at line 734, the primary domain is being removed for authentication reasons. + * 2. For posts on all site types, the shareable url will be available which doesn't have any preview parameters. + * 3. In any other case we just fallback to the WebView's current URL. + * @return external url + */ + public String getExternalBrowserUrl() { + final Bundle extras = getIntent().getExtras(); + if (extras != null) { + String shareableUrl = extras.getString(SHAREABLE_URL, null); + if (!TextUtils.isEmpty(shareableUrl)) { + return shareableUrl; + } + } + + return mWebView.getUrl(); + } + /** * Get the URL of the WordPress login page. * diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java index 0c8bbc8702e4..358be878e86a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui; +import android.content.Context; import android.os.Bundle; import android.view.MenuItem; import android.view.View; @@ -7,17 +8,19 @@ import android.webkit.WebView; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import org.wordpress.android.R; import org.wordpress.android.WordPress; +import org.wordpress.android.util.LocaleManager; import java.util.Map; /** * Basic activity for displaying a WebView. */ -public abstract class WebViewActivity extends LocaleAwareActivity { +public abstract class WebViewActivity extends AppCompatActivity { /** * Primary webview used to display content. */ @@ -26,6 +29,11 @@ public abstract class WebViewActivity extends LocaleAwareActivity { protected WebView mWebView; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { supportRequestWindowFeature(Window.FEATURE_PROGRESS); @@ -97,7 +105,7 @@ protected void onResume() { public void configureView() { setContentView(R.layout.webview); - Toolbar toolbar = findViewById(R.id.toolbar_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt index 5071899d84cd..9f6025d88365 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/HelpActivity.kt @@ -4,8 +4,8 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.help_activity.* -import kotlinx.android.synthetic.main.toolbar_main.* import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.analytics.AnalyticsTracker @@ -18,13 +18,13 @@ import org.wordpress.android.support.ZendeskExtraTags import org.wordpress.android.support.ZendeskHelper import org.wordpress.android.ui.ActivityId import org.wordpress.android.ui.AppLogViewerActivity -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.prefs.AppPrefs +import org.wordpress.android.util.LocaleManager import org.wordpress.android.util.SiteUtils import java.util.ArrayList import javax.inject.Inject -class HelpActivity : LocaleAwareActivity() { +class HelpActivity : AppCompatActivity() { @Inject lateinit var accountStore: AccountStore @Inject lateinit var siteStore: SiteStore @Inject lateinit var supportHelper: SupportHelper @@ -40,14 +40,16 @@ class HelpActivity : LocaleAwareActivity() { intent.extras?.get(WordPress.SITE) as SiteModel? } + override fun attachBaseContext(newBase: Context) { + super.attachBaseContext(LocaleManager.setLocale(newBase)) + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (application as WordPress).component().inject(this) setContentView(R.layout.help_activity) - setSupportActionBar(toolbar_main) - val actionBar = supportActionBar if (actionBar != null) { actionBar.setHomeButtonEnabled(true) @@ -55,11 +57,11 @@ class HelpActivity : LocaleAwareActivity() { actionBar.elevation = 0f // remove shadow } - contact_us_button.setOnClickListener { createNewZendeskTicket() } - faq_button.setOnClickListener { showZendeskFaq() } - my_tickets_button.setOnClickListener { showZendeskTickets() } + contactUsButton.setOnClickListener { createNewZendeskTicket() } + faqButton.setOnClickListener { showZendeskFaq() } + myTicketsButton.setOnClickListener { showZendeskTickets() } applicationVersion.text = getString(R.string.version_with_name_param, WordPress.versionName) - application_log_button.setOnClickListener { v -> + applicationLogButton.setOnClickListener { v -> startActivity(Intent(v.context, AppLogViewerActivity::class.java)) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java index 9f36c38233a0..be54b2426931 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.accounts; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -8,6 +9,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; @@ -47,7 +49,6 @@ import org.wordpress.android.support.ZendeskHelper; import org.wordpress.android.ui.ActivityLauncher; import org.wordpress.android.ui.JetpackConnectionSource; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.accounts.HelpActivity.Origin; import org.wordpress.android.ui.accounts.SmartLockHelper.Callback; @@ -63,6 +64,7 @@ import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; import org.wordpress.android.util.CrashLoggingUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.SelfSignedSSLUtils; import org.wordpress.android.util.StringUtils; @@ -82,7 +84,7 @@ import dagger.android.DispatchingAndroidInjector; import dagger.android.support.HasSupportFragmentInjector; -public class LoginActivity extends LocaleAwareActivity implements ConnectionCallbacks, OnConnectionFailedListener, +public class LoginActivity extends AppCompatActivity implements ConnectionCallbacks, OnConnectionFailedListener, Callback, LoginListener, GoogleListener, LoginPrologueListener, SignupSheetListener, HasSupportFragmentInjector, BasicDialogPositiveClickInterface { public static final String ARG_JETPACK_CONNECT_SOURCE = "ARG_JETPACK_CONNECT_SOURCE"; @@ -115,6 +117,11 @@ private enum SmartLockHelperState { @Inject ZendeskHelper mZendeskHelper; @Inject protected SiteStore mSiteStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(Bundle savedInstanceState) { ((WordPress) getApplication()).component().inject(this); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java index 090bbf73db8b..1f2c07cf5d12 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java @@ -1,7 +1,9 @@ package org.wordpress.android.ui.accounts; +import android.content.Context; import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentTransaction; import org.wordpress.android.R; @@ -9,16 +11,16 @@ import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.accounts.login.LoginEpilogueFragment; import org.wordpress.android.ui.accounts.login.LoginEpilogueListener; import org.wordpress.android.ui.prefs.AppPrefs; +import org.wordpress.android.util.LocaleManager; import java.util.ArrayList; import javax.inject.Inject; -public class LoginEpilogueActivity extends LocaleAwareActivity implements LoginEpilogueListener { +public class LoginEpilogueActivity extends AppCompatActivity implements LoginEpilogueListener { public static final String EXTRA_DO_LOGIN_UPDATE = "EXTRA_DO_LOGIN_UPDATE"; public static final String EXTRA_SHOW_AND_RETURN = "EXTRA_SHOW_AND_RETURN"; public static final String ARG_OLD_SITES_IDS = "ARG_OLD_SITES_IDS"; @@ -26,6 +28,11 @@ public class LoginEpilogueActivity extends LocaleAwareActivity implements LoginE @Inject AccountStore mAccountStore; @Inject SiteStore mSiteStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java index 6282e59c507a..d26177a464af 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui.accounts; +import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -7,7 +8,6 @@ import org.wordpress.android.WordPress; import org.wordpress.android.login.LoginAnalyticsListener; import org.wordpress.android.ui.JetpackConnectionSource; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.main.WPMainActivity; import javax.inject.Inject; @@ -16,7 +16,7 @@ * Deep link receiver for magic links. Starts {@link WPMainActivity} where flow is routed to login * or signup based on deep link scheme, host, and parameters. */ -public class LoginMagicLinkInterceptActivity extends LocaleAwareActivity { +public class LoginMagicLinkInterceptActivity extends Activity { private static final String PARAMETER_FLOW = "flow"; private static final String PARAMETER_FLOW_JETPACK = "jetpack"; private static final String PARAMETER_SOURCE = "source"; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/PostSignupInterstitialActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/PostSignupInterstitialActivity.kt index df07258b88dd..f0bec052f1a3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/PostSignupInterstitialActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/PostSignupInterstitialActivity.kt @@ -1,6 +1,7 @@ package org.wordpress.android.ui.accounts import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProviders @@ -8,7 +9,6 @@ import kotlinx.android.synthetic.main.post_signup_interstitial_default.* import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.viewmodel.accounts.PostSignupInterstitialViewModel import org.wordpress.android.viewmodel.accounts.PostSignupInterstitialViewModel.NavigationAction import org.wordpress.android.viewmodel.accounts.PostSignupInterstitialViewModel.NavigationAction.DISMISS @@ -16,7 +16,7 @@ import org.wordpress.android.viewmodel.accounts.PostSignupInterstitialViewModel. import org.wordpress.android.viewmodel.accounts.PostSignupInterstitialViewModel.NavigationAction.START_SITE_CREATION_FLOW import javax.inject.Inject -class PostSignupInterstitialActivity : LocaleAwareActivity() { +class PostSignupInterstitialActivity : AppCompatActivity() { @Inject lateinit var viewModelFactory: ViewModelProvider.Factory private lateinit var viewModel: PostSignupInterstitialViewModel diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java index a39ba36e7f00..3a2721f1eb73 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java @@ -1,20 +1,22 @@ package org.wordpress.android.ui.accounts; +import android.content.Context; import android.os.Bundle; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.FragmentTransaction; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.accounts.signup.SignupEpilogueFragment; import org.wordpress.android.ui.accounts.signup.SignupEpilogueListener; +import org.wordpress.android.util.LocaleManager; import javax.inject.Inject; -public class SignupEpilogueActivity extends LocaleAwareActivity implements SignupEpilogueListener { +public class SignupEpilogueActivity extends AppCompatActivity implements SignupEpilogueListener { public static final String EXTRA_SIGNUP_DISPLAY_NAME = "EXTRA_SIGNUP_DISPLAY_NAME"; public static final String EXTRA_SIGNUP_EMAIL_ADDRESS = "EXTRA_SIGNUP_EMAIL_ADDRESS"; public static final String EXTRA_SIGNUP_IS_EMAIL = "EXTRA_SIGNUP_IS_EMAIL"; @@ -25,6 +27,11 @@ public class SignupEpilogueActivity extends LocaleAwareActivity implements Signu @Inject SiteStore mSiteStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java index 3f952b29494d..24a9a4285293 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java @@ -24,6 +24,7 @@ import org.wordpress.android.ui.main.SitePickerAdapter.SiteList; import org.wordpress.android.util.GravatarUtils; import org.wordpress.android.util.StringUtils; +import org.wordpress.android.util.ViewUtils; import org.wordpress.android.util.analytics.AnalyticsUtils; import org.wordpress.android.util.image.ImageManager; @@ -169,8 +170,16 @@ public void run() { if (mSitesList.computeVerticalScrollRange() > mSitesList.getHeight()) { mBottomShadow.setVisibility(View.VISIBLE); + mBottomButtonsContainer.setBackgroundResource(android.R.color.white); + ViewUtils.setButtonBackgroundColor(getContext(), mConnectMore, + R.style.WordPress_Button_Grey, + R.attr.colorButtonNormal); } else { mBottomShadow.setVisibility(View.GONE); + mBottomButtonsContainer.setBackground(null); + ViewUtils.setButtonBackgroundColor(getContext(), mConnectMore, + R.style.WordPress_Button, + R.attr.colorButtonNormal); } } }); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginPrologueAnimationFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginPrologueAnimationFragment.java index 4f0ad101160f..de6e33e8fc00 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginPrologueAnimationFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginPrologueAnimationFragment.java @@ -47,9 +47,11 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.login_intro_template_view, container, false); + rootView.setBackgroundColor(getResources().getColor(R.color.primary)); TextView promoText = (TextView) rootView.findViewById(R.id.promo_text); promoText.setText(mPromoText); + promoText.setTextColor(getResources().getColor(android.R.color.white)); mLottieAnimationView = (LottieAnimationView) rootView.findViewById(R.id.animation_view); mLottieAnimationView.setAnimation(mAnimationFilename); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/BaseUsernameChangerFullScreenDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/BaseUsernameChangerFullScreenDialogFragment.java index 896f84c9dec6..1612a260cd3f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/BaseUsernameChangerFullScreenDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/BaseUsernameChangerFullScreenDialogFragment.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui.accounts.signup; +import android.content.DialogInterface; import android.os.Bundle; import android.os.Handler; import android.text.Editable; @@ -8,6 +9,7 @@ import android.text.SpannedString; import android.text.TextUtils; import android.text.TextWatcher; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -20,12 +22,10 @@ import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.SimpleItemAnimator; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.textfield.TextInputEditText; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.analytics.AnalyticsTracker; import org.wordpress.android.analytics.AnalyticsTracker.Stat; @@ -191,9 +191,12 @@ public void afterTextChanged(Editable s) { }); mGetSuggestionsHandler = new Handler(); - mGetSuggestionsRunnable = () -> { - mUsernameSuggestionInput = mUsernameView.getText().toString(); - getUsernameSuggestions(mUsernameSuggestionInput); + mGetSuggestionsRunnable = new Runnable() { + @Override + public void run() { + mUsernameSuggestionInput = mUsernameView.getText().toString(); + getUsernameSuggestions(mUsernameSuggestionInput); + } }; } @@ -214,7 +217,7 @@ public boolean onConfirmClicked(FullScreenDialogController controller) { ActivityUtils.hideKeyboard(getActivity()); if (mUsernamesAdapter != null && mUsernamesAdapter.mItems != null) { - onUsernameConfirmed(controller, mUsernameSelected); + onUsernameConfirmed(controller, mUsernameSelected); } else { controller.dismiss(); } @@ -238,7 +241,7 @@ public boolean onDismissClicked(FullScreenDialogController controller) { } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(KEY_IS_SHOWING_DISMISS_DIALOG, mIsShowingDismissDialog); outState.putBoolean(KEY_SHOULD_WATCH_TEXT, false); @@ -305,17 +308,27 @@ private void setUsernameSuggestions(List suggestions) { private void showDismissDialog() { mIsShowingDismissDialog = true; - new MaterialAlertDialogBuilder(getContext()) + new AlertDialog.Builder(new ContextThemeWrapper(getContext(), R.style.LoginTheme)) .setMessage(R.string.username_changer_dismiss_message) .setPositiveButton(R.string.username_changer_dismiss_button_positive, - (dialog, which) -> mDialogController.dismiss()) + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + mDialogController.dismiss(); + } + }) .setNegativeButton(android.R.string.cancel, - (dialog, which) -> mIsShowingDismissDialog = false) + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + mIsShowingDismissDialog = false; + } + }) .show(); } protected void showErrorDialog(Spanned message) { - AlertDialog dialog = new MaterialAlertDialogBuilder(getContext()) + AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)) .setMessage(message) .setPositiveButton(R.string.login_error_button, null) .create(); @@ -344,9 +357,9 @@ public void onUsernameSuggestionsFetched(OnUsernameSuggestionsFetched event) { "", mUsernameSuggestionInput, "" - ) - ) - ); + ) + ) + ); } else { populateUsernameSuggestions(event.suggestions); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SettingsUsernameChangerFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SettingsUsernameChangerFragment.kt index 82693315b4ec..89b010bebdc4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SettingsUsernameChangerFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SettingsUsernameChangerFragment.kt @@ -6,15 +6,16 @@ import android.text.Editable import android.text.SpannableStringBuilder import android.text.Spanned import android.text.TextWatcher +import android.view.ContextThemeWrapper import android.widget.EditText import android.widget.TextView import androidx.appcompat.app.AlertDialog import androidx.core.text.HtmlCompat -import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.snackbar.Snackbar import org.greenrobot.eventbus.Subscribe import org.greenrobot.eventbus.ThreadMode import org.wordpress.android.R +import org.wordpress.android.R.style import org.wordpress.android.analytics.AnalyticsTracker import org.wordpress.android.analytics.AnalyticsTracker.Stat.ACCOUNT_SETTINGS_CHANGE_USERNAME_FAILED import org.wordpress.android.analytics.AnalyticsTracker.Stat.ACCOUNT_SETTINGS_CHANGE_USERNAME_SUCCEEDED @@ -61,10 +62,7 @@ class SettingsUsernameChangerFragment : BaseUsernameChangerFullScreenDialogFragm dialogController.setActionEnabled(hasUsernameChanged()) } - override fun onUsernameConfirmed( - controller: FullScreenDialogController, - usernameSelected: String - ) { + override fun onUsernameConfirmed(controller: FullScreenDialogController, usernameSelected: String) { showUsernameConfirmationDialog(usernameSelected) } @@ -89,7 +87,7 @@ class SettingsUsernameChangerFragment : BaseUsernameChangerFullScreenDialogFragm ), HtmlCompat.FROM_HTML_MODE_LEGACY ) - MaterialAlertDialogBuilder(activity).apply { + AlertDialog.Builder(ContextThemeWrapper(activity, style.Calypso_Dialog_Alert)).apply { setTitle(R.string.settings_username_changer_confirm_dialog_title) setView(layout) setPositiveButton( @@ -111,12 +109,7 @@ class SettingsUsernameChangerFragment : BaseUsernameChangerFullScreenDialogFragm } } - override fun beforeTextChanged( - s: CharSequence?, - start: Int, - count: Int, - after: Int - ) { + override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { } override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { @@ -179,11 +172,7 @@ class SettingsUsernameChangerFragment : BaseUsernameChangerFullScreenDialogFragm } private fun showChangeUsernameActionCancelledMessage() = view?.let { - WPDialogSnackbar.make( - it, - getString(R.string.settings_username_changer_snackbar_cancel), - Snackbar.LENGTH_LONG - ) + WPDialogSnackbar.make(it, getString(R.string.settings_username_changer_snackbar_cancel), Snackbar.LENGTH_LONG) .show() } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailActivity.kt index ce9f4a15830e..0cfad8045989 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailActivity.kt @@ -2,20 +2,20 @@ package org.wordpress.android.ui.activitylog.detail import android.os.Bundle import android.view.MenuItem -import kotlinx.android.synthetic.main.toolbar_main.* +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.toolbar.* import org.wordpress.android.R -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogNegativeClickInterface import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogPositiveClickInterface -class ActivityLogDetailActivity : LocaleAwareActivity(), BasicDialogPositiveClickInterface, +class ActivityLogDetailActivity : AppCompatActivity(), BasicDialogPositiveClickInterface, BasicDialogNegativeClickInterface { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_log_detail_activity) - setSupportActionBar(toolbar_main) + setSupportActionBar(toolbar) supportActionBar?.let { it.setHomeButtonEnabled(true) it.setDisplayHomeAsUpEnabled(true) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailFragment.kt index c675aa161e75..dcad242107cc 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailFragment.kt @@ -160,7 +160,7 @@ class ActivityLogDetailFragment : Fragment() { getString(R.string.activity_log_rewind_site), getString(R.string.cancel) ) - dialog.show(requireFragmentManager(), it) + dialog.show(fragmentManager, it) } } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListActivity.kt index 3e8776686e5b..cb706a75323f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListActivity.kt @@ -3,21 +3,21 @@ package org.wordpress.android.ui.activitylog.list import android.content.Intent import android.os.Bundle import android.view.MenuItem -import kotlinx.android.synthetic.main.toolbar_main.* +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.toolbar.* import org.wordpress.android.R -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.posts.BasicFragmentDialog import org.wordpress.android.viewmodel.activitylog.ACTIVITY_LOG_REWIND_ID_KEY -class ActivityLogListActivity : LocaleAwareActivity(), BasicFragmentDialog.BasicDialogPositiveClickInterface, +class ActivityLogListActivity : AppCompatActivity(), BasicFragmentDialog.BasicDialogPositiveClickInterface, BasicFragmentDialog.BasicDialogNegativeClickInterface { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_log_list_activity) - setSupportActionBar(toolbar_main) + setSupportActionBar(toolbar) supportActionBar?.let { it.setHomeButtonEnabled(true) it.setDisplayHomeAsUpEnabled(true) @@ -33,7 +33,6 @@ class ActivityLogListActivity : LocaleAwareActivity(), BasicFragmentDialog.Basic } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { - super.onActivityResult(requestCode, resultCode, data) if (requestCode == RequestCodes.ACTIVITY_LOG_DETAIL) { data?.getStringExtra(ACTIVITY_LOG_REWIND_ID_KEY)?.let { passRewindConfirmation(it) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListFragment.kt index aff8ae26de14..dc8871e6d061 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListFragment.kt @@ -126,7 +126,7 @@ class ActivityLogListFragment : Fragment() { getString(R.string.activity_log_rewind_dialog_message, item.formattedDate, item.formattedTime), getString(R.string.activity_log_rewind_site), getString(R.string.cancel)) - dialog.show(requireFragmentManager(), it) + dialog.show(fragmentManager, it) } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/EventItemViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/EventItemViewHolder.kt index cac254251141..42e5d668ba69 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/EventItemViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/EventItemViewHolder.kt @@ -6,9 +6,9 @@ import android.view.ViewGroup import android.widget.ImageButton import android.widget.ImageView import android.widget.TextView +import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.DrawableCompat import org.wordpress.android.R -import org.wordpress.android.util.ColorUtils -import org.wordpress.android.util.getColorResIdFromAttribute class EventItemViewHolder( parent: ViewGroup, @@ -36,12 +36,12 @@ class EventItemViewHolder( text.text = activity.description if (activity.isButtonVisible) { - ColorUtils.setImageResourceWithTint( - actionButton, - activity.buttonIcon.drawable, - actionButton.context.getColorResIdFromAttribute(R.attr.colorPrimary) - ) - actionButton.visibility = View.VISIBLE + ContextCompat.getDrawable(container.context, activity.buttonIcon.drawable)?.let { buttonIcon -> + val wrapDrawable = DrawableCompat.wrap(buttonIcon).mutate() + DrawableCompat.setTint(wrapDrawable, ContextCompat.getColor(container.context, R.color.primary_40)) + actionButton.setImageDrawable(DrawableCompat.unwrap(wrapDrawable)) + actionButton.visibility = View.VISIBLE + } } else { actionButton.visibility = View.GONE } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentAdapter.java index 09e652a9de39..3608ea4f44e7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentAdapter.java @@ -12,10 +12,9 @@ import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.core.graphics.ColorUtils; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.CommentModel; @@ -25,7 +24,6 @@ import org.wordpress.android.models.CommentList; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.DateTimeUtils; import org.wordpress.android.util.GravatarUtils; import org.wordpress.android.util.StringUtils; @@ -35,6 +33,7 @@ import org.wordpress.android.util.image.ImageType; import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -69,11 +68,11 @@ interface OnCommentPressedListener { private final int mStatusColorSpam; private final int mStatusColorUnapproved; - private int mSelectedItemBackground; - private final int mAvatarSz; private final String mStatusTextSpam; private final String mStatusTextUnapproved; + private final int mSelectedColor; + private final int mUnselectedColor; private OnDataLoadedListener mOnDataLoadedListener; private OnCommentPressedListener mOnCommentPressedListener; @@ -135,19 +134,17 @@ public boolean onLongClick(View v) { mSite = site; - mStatusColorSpam = ContextExtensionsKt.getColorFromAttribute(context, R.attr.wpColorError); - mStatusColorUnapproved = ContextExtensionsKt.getColorFromAttribute(context, R.attr.wpColorWarningDark); + mStatusColorSpam = ContextCompat.getColor(context, R.color.error); + mStatusColorUnapproved = ContextCompat.getColor(context, R.color.accent); + mUnselectedColor = ContextCompat.getColor(context, android.R.color.white); + mSelectedColor = ContextCompat.getColor(context, R.color.gray_5); mStatusTextSpam = context.getResources().getString(R.string.comment_status_spam); mStatusTextUnapproved = context.getResources().getString(R.string.comment_status_unapproved); mAvatarSz = context.getResources().getDimensionPixelSize(R.dimen.avatar_sz_medium); - mSelectedItemBackground = ColorUtils - .setAlphaComponent(ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorOnSurface), - context.getResources().getInteger(R.integer.selected_list_item_opacity)); - setHasStableIds(true); } @@ -167,9 +164,8 @@ void setOnSelectedItemsChangeListener(OnSelectedItemsChangeListener listener) { mOnSelectedChangeListener = listener; } - @NotNull @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) { + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { //noinspection InflateParams View view = mInflater.inflate(R.layout.comment_listitem, null); CommentHolder holder = new CommentHolder(view); @@ -217,7 +213,7 @@ private String getFormattedDate(CommentModel comment, Context context) { } @Override - public void onBindViewHolder(@NotNull RecyclerView.ViewHolder viewHolder, int position) { + public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { CommentModel comment = mComments.get(position); CommentHolder holder = (CommentHolder) viewHolder; @@ -251,12 +247,12 @@ public void onBindViewHolder(@NotNull RecyclerView.ViewHolder viewHolder, int po if (mEnableSelection && isItemSelected(position)) { checkmarkVisibility = View.VISIBLE; mImageManager.cancelRequestAndClearImageView(holder.mImgAvatar); - holder.mContainerView.setBackgroundColor(mSelectedItemBackground); + holder.mContainerView.setBackgroundColor(mSelectedColor); } else { checkmarkVisibility = View.GONE; mImageManager.loadIntoCircle(holder.mImgAvatar, ImageType.AVATAR_WITH_BACKGROUND, getAvatarForDisplay(comment, mAvatarSz)); - holder.mContainerView.setBackground(null); + holder.mContainerView.setBackgroundColor(mUnselectedColor); } if (holder.mImgCheckmark.getVisibility() != checkmarkVisibility) { @@ -452,13 +448,16 @@ protected void onPostExecute(Boolean result) { mComments.clear(); mComments.addAll(mTmpComments); // Sort by date - Collections.sort(mComments, (commentModel, t1) -> { - Date d0 = DateTimeUtils.dateFromIso8601(commentModel.getDatePublished()); - Date d1 = DateTimeUtils.dateFromIso8601(t1.getDatePublished()); - if (d0 == null || d1 == null) { - return 0; + Collections.sort(mComments, new Comparator() { + @Override + public int compare(CommentModel commentModel, CommentModel t1) { + Date d0 = DateTimeUtils.dateFromIso8601(commentModel.getDatePublished()); + Date d1 = DateTimeUtils.dateFromIso8601(t1.getDatePublished()); + if (d0 == null || d1 == null) { + return 0; + } + return d1.compareTo(d0); } - return d1.compareTo(d0); }); notifyDataSetChanged(); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java index 425cca8447ed..55f3645d3405 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java @@ -1,15 +1,21 @@ package org.wordpress.android.ui.comments; import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.Html; import android.text.TextUtils; import android.text.TextWatcher; +import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.widget.ImageView; @@ -20,21 +26,15 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; -import androidx.core.content.res.ResourcesCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.elevation.ElevationOverlayProvider; - import org.apache.commons.text.StringEscapeUtils; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.analytics.AnalyticsTracker; @@ -62,6 +62,8 @@ import org.wordpress.android.ui.ActivityId; import org.wordpress.android.ui.CollapseFullScreenDialogFragment; import org.wordpress.android.ui.CollapseFullScreenDialogFragment.Builder; +import org.wordpress.android.ui.CollapseFullScreenDialogFragment.OnCollapseListener; +import org.wordpress.android.ui.CollapseFullScreenDialogFragment.OnConfirmListener; import org.wordpress.android.ui.CommentFullScreenDialogFragment; import org.wordpress.android.ui.comments.CommentActions.OnCommentActionListener; import org.wordpress.android.ui.comments.CommentActions.OnNoteCommentActionListener; @@ -80,7 +82,6 @@ import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; import org.wordpress.android.util.ColorUtils; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.DateTimeUtils; import org.wordpress.android.util.EditTextUtils; import org.wordpress.android.util.GravatarUtils; @@ -101,6 +102,11 @@ import javax.inject.Inject; +import static org.wordpress.android.ui.CommentFullScreenDialogFragment.Companion; +import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_REPLY; +import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_SELECTION_END; +import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_SELECTION_START; + /** * comment detail displayed from both the notification list and the comment list * prior to this there were separate comment detail screens for each list @@ -145,8 +151,6 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm private boolean mIsUsersBlog = false; private boolean mShouldFocusReplyField; private String mPreviousStatus; - private float mNormalOpacity = 1f; - private float mMediumOpacity; @Inject Dispatcher mDispatcher; @Inject AccountStore mAccountStore; @@ -225,7 +229,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mComment != null) { outState.putLong(KEY_COMMENT_ID, mComment.getRemoteCommentId()); @@ -251,8 +255,6 @@ public void onDestroy() { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.comment_detail_fragment, container, false); - mMediumOpacity = ResourcesCompat.getFloat(getResources(), R.dimen.material_emphasis_medium); - mTxtStatus = view.findViewById(R.id.text_status); mTxtContent = view.findViewById(R.id.text_content); @@ -281,21 +283,17 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mLayoutReply = view.findViewById(R.id.layout_comment_box); - ElevationOverlayProvider elevationOverlayProvider = new ElevationOverlayProvider(view.getContext()); - float appbarElevation = getResources().getDimension(R.dimen.appbar_elevation); - int elevatedColor = elevationOverlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded(appbarElevation); - - mLayoutReply.setBackgroundColor(elevatedColor); - mSubmitReplyBtn = mLayoutReply.findViewById(R.id.btn_submit_reply); mSubmitReplyBtn.setEnabled(false); - mSubmitReplyBtn.setOnLongClickListener(view1 -> { - if (view1.isHapticFeedbackEnabled()) { - view1.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - } + mSubmitReplyBtn.setOnLongClickListener(new OnLongClickListener() { + @Override public boolean onLongClick(View view) { + if (view.isHapticFeedbackEnabled()) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } - Toast.makeText(view1.getContext(), R.string.send, Toast.LENGTH_SHORT).show(); - return true; + Toast.makeText(view.getContext(), R.string.send, Toast.LENGTH_SHORT).show(); + return true; + } }); ViewUtilsKt.redirectContextClickToLongPressListener(mSubmitReplyBtn); @@ -317,46 +315,55 @@ public void afterTextChanged(Editable s) { ImageView buttonExpand = mLayoutReply.findViewById(R.id.button_expand); buttonExpand.setOnClickListener( - v -> { - Bundle bundle = CommentFullScreenDialogFragment.Companion.newBundle( + new OnClickListener() { + @Override + public void onClick(View v) { + Bundle bundle = Companion.newBundle( mEditReply.getText().toString(), mEditReply.getSelectionStart(), mEditReply.getSelectionEnd(), mSite.getSiteId() - ); + ); new Builder(requireContext()) - .setTitle(R.string.comment) - .setOnCollapseListener(result -> { + .setTitle(R.string.comment) + .setOnCollapseListener(new OnCollapseListener() { + @Override + public void onCollapse(@Nullable Bundle result) { if (result != null) { - mEditReply.setText(result.getString(CommentFullScreenDialogFragment.RESULT_REPLY)); - mEditReply.setSelection(result.getInt( - CommentFullScreenDialogFragment.RESULT_SELECTION_START), - result.getInt(CommentFullScreenDialogFragment.RESULT_SELECTION_END)); + mEditReply.setText(result.getString(RESULT_REPLY)); + mEditReply.setSelection(result.getInt(RESULT_SELECTION_START), + result.getInt(RESULT_SELECTION_END)); mEditReply.requestFocus(); } - }) - .setOnConfirmListener(result -> { + } + }) + .setOnConfirmListener(new OnConfirmListener() { + @Override + public void onConfirm(@Nullable Bundle result) { if (result != null) { - mEditReply.setText(result.getString(CommentFullScreenDialogFragment.RESULT_REPLY)); + mEditReply.setText(result.getString(RESULT_REPLY)); submitReply(); } - }) - .setContent(CommentFullScreenDialogFragment.class, bundle) - .setAction(R.string.send) - .setHideActivityBar(true) - .build() - .show(requireActivity().getSupportFragmentManager(), - CollapseFullScreenDialogFragment.TAG); + } + }) + .setContent(CommentFullScreenDialogFragment.class, bundle) + .setAction(R.string.send) + .setHideActivityBar(true) + .build() + .show(requireActivity().getSupportFragmentManager(), CollapseFullScreenDialogFragment.TAG); } - ); - buttonExpand.setOnLongClickListener(v -> { - if (v.isHapticFeedbackEnabled()) { - v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } + ); + buttonExpand.setOnLongClickListener(new OnLongClickListener() { + @Override public boolean onLongClick(View view) { + if (view.isHapticFeedbackEnabled()) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } - Toast.makeText(v.getContext(), R.string.description_expand, Toast.LENGTH_SHORT).show(); - return true; + Toast.makeText(view.getContext(), R.string.description_expand, Toast.LENGTH_SHORT).show(); + return true; + } }); ViewUtilsKt.redirectContextClickToLongPressListener(buttonExpand); setReplyUniqueId(); @@ -372,11 +379,14 @@ public void afterTextChanged(Editable s) { mTxtContent.setMovementMethod(WPLinkMovementMethod.getInstance()); mEditReply.setHint(R.string.reader_hint_comment_on_comment); - mEditReply.setOnEditorActionListener((v, actionId, event) -> { - if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEND) { - submitReply(); + mEditReply.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEND) { + submitReply(); + } + return false; } - return false; }); if (!TextUtils.isEmpty(mRestoredReplyText)) { @@ -384,52 +394,76 @@ public void afterTextChanged(Editable s) { mRestoredReplyText = null; } - mSubmitReplyBtn.setOnClickListener(v -> submitReply()); - - mBtnSpamComment.setOnClickListener(v -> { - if (mComment == null) { - return; + mSubmitReplyBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + submitReply(); } + }); - if (CommentStatus.fromString(mComment.getStatus()) == CommentStatus.SPAM) { - moderateComment(CommentStatus.APPROVED); - announceCommentStatusChangeForAccessibility(CommentStatus.UNSPAM); - } else { - moderateComment(CommentStatus.SPAM); - announceCommentStatusChangeForAccessibility(CommentStatus.SPAM); + mBtnSpamComment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mComment == null) { + return; + } + + if (CommentStatus.fromString(mComment.getStatus()) == CommentStatus.SPAM) { + moderateComment(CommentStatus.APPROVED); + announceCommentStatusChangeForAccessibility(CommentStatus.UNSPAM); + } else { + moderateComment(CommentStatus.SPAM); + announceCommentStatusChangeForAccessibility(CommentStatus.SPAM); + } } }); - mBtnTrashComment.setOnClickListener(v -> { - if (mComment == null) { - return; - } + mBtnTrashComment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mComment == null) { + return; + } - CommentStatus status = CommentStatus.fromString(mComment.getStatus()); - // If the comment status is trash or spam, next deletion is a permanent deletion. - if (status == CommentStatus.TRASH || status == CommentStatus.SPAM) { - AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(getActivity()); - dialogBuilder.setTitle(getResources().getText(R.string.delete)); - dialogBuilder.setMessage(getResources().getText(R.string.dlg_sure_to_delete_comment)); - dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), - (dialog, whichButton) -> { - moderateComment(CommentStatus.DELETED); - announceCommentStatusChangeForAccessibility(CommentStatus.DELETED); - }); - dialogBuilder.setNegativeButton( - getResources().getText(R.string.no), - null); - dialogBuilder.setCancelable(true); - dialogBuilder.create().show(); - } else { - moderateComment(CommentStatus.TRASH); - announceCommentStatusChangeForAccessibility(CommentStatus.TRASH); + CommentStatus status = CommentStatus.fromString(mComment.getStatus()); + // If the comment status is trash or spam, next deletion is a permanent deletion. + if (status == CommentStatus.TRASH || status == CommentStatus.SPAM) { + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + dialogBuilder.setTitle(getResources().getText(R.string.delete)); + dialogBuilder.setMessage(getResources().getText(R.string.dlg_sure_to_delete_comment)); + dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + moderateComment(CommentStatus.DELETED); + announceCommentStatusChangeForAccessibility(CommentStatus.DELETED); + } + }); + dialogBuilder.setNegativeButton( + getResources().getText(R.string.no), + null); + dialogBuilder.setCancelable(true); + dialogBuilder.create().show(); + } else { + moderateComment(CommentStatus.TRASH); + announceCommentStatusChangeForAccessibility(CommentStatus.TRASH); + } } }); - mBtnLikeComment.setOnClickListener(v -> likeComment(false)); + mBtnLikeComment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + likeComment(false); + } + }); - mBtnEditComment.setOnClickListener(v -> editComment()); + mBtnEditComment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + editComment(); + } + }); setupSuggestionServiceAndAdapter(); @@ -454,7 +488,7 @@ private void setupSuggestionServiceAndAdapter() { } mSuggestionServiceConnectionManager = new SuggestionServiceConnectionManager(getActivity(), mSite.getSiteId()); mSuggestionAdapter = SuggestionUtils.setupSuggestions(mSite, getActivity(), - mSuggestionServiceConnectionManager); + mSuggestionServiceConnectionManager); if (mSuggestionAdapter != null) { mEditReply.setAdapter(mSuggestionAdapter); } @@ -559,7 +593,7 @@ private void showErrorToastAndFinish() { } @SuppressWarnings("deprecation") // TODO: Remove when minSdkVersion >= 23 - public void onAttach(@NotNull Activity activity) { + public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof OnPostClickListener) { mOnPostClickListener = (OnPostClickListener) activity; @@ -701,7 +735,7 @@ private void showComment() { txtName.setText(mComment.getAuthorName() == null ? getString(R.string.anonymous) : mComment.getAuthorName()); txtDate.setText(DateTimeUtils.javaDateToTimeSpan(DateTimeUtils.dateFromIso8601(mComment.getDatePublished()), - WordPress.getContext())); + WordPress.getContext())); int maxImageSz = getResources().getDimensionPixelSize(R.dimen.reader_comment_max_image_size); CommentUtils.displayHtmlComment(mTxtContent, mComment.getContent(), maxImageSz); @@ -719,14 +753,17 @@ private void showComment() { // navigate to author's blog when avatar or name clicked if (mComment.getAuthorUrl() != null) { - View.OnClickListener authorListener = - v -> ReaderActivityLauncher.openUrl(getActivity(), mComment.getAuthorUrl()); + View.OnClickListener authorListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + ReaderActivityLauncher.openUrl(getActivity(), mComment.getAuthorUrl()); + } + }; imgAvatar.setOnClickListener(authorListener); txtName.setOnClickListener(authorListener); - txtName.setTextColor(ContextExtensionsKt.getColorFromAttribute(txtName.getContext(), R.attr.colorPrimary)); + txtName.setTextColor(ContextCompat.getColor(getActivity(), R.color.link_reader)); } else { - txtName.setTextColor( - ContextExtensionsKt.getColorFromAttribute(txtName.getContext(), R.attr.colorOnSurface)); + txtName.setTextColor(ContextCompat.getColor(getActivity(), R.color.neutral_60)); } showPostTitle(mSite, mComment.getRemotePostId()); @@ -764,8 +801,7 @@ private void setPostTitle(TextView txtTitle, String postTitle, boolean isHyperli // display "on [Post Title]..." if (isHyperlink) { String html = getString(R.string.on) - + " " + postTitle.trim() + ""; @@ -843,15 +879,18 @@ public void onFailure(int statusCode) { }); } - txtPostTitle.setOnClickListener(v -> { - if (mOnPostClickListener != null) { - mOnPostClickListener.onPostClicked(getNote(), site.getSiteId(), - (int) mComment.getRemotePostId()); - } else { - // right now this will happen from notifications - AppLog.i(T.COMMENTS, "comment detail > no post click listener"); - ReaderActivityLauncher.showReaderPostDetail(getActivity(), site.getSiteId(), - mComment.getRemotePostId()); + txtPostTitle.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mOnPostClickListener != null) { + mOnPostClickListener.onPostClicked(getNote(), site.getSiteId(), + (int) mComment.getRemotePostId()); + } else { + // right now this will happen from notifications + AppLog.i(T.COMMENTS, "comment detail > no post click listener"); + ReaderActivityLauncher.showReaderPostDetail(getActivity(), site.getSiteId(), + mComment.getRemotePostId()); + } } }); } @@ -946,8 +985,8 @@ private void submitReply() { reply.setContent(replyText); mDispatcher.dispatch(CommentActionBuilder.newCreateNewCommentAction(new RemoteCreateCommentPayload(mSite, - mComment, - reply))); + mComment, + reply))); } /* @@ -967,20 +1006,20 @@ private void updateStatusViews() { switch (commentStatus) { case APPROVED: statusTextResId = R.string.comment_status_approved; - statusColor = ContextExtensionsKt.getColorFromAttribute(getActivity(), R.attr.wpColorWarningDark); + statusColor = ContextCompat.getColor(getActivity(), R.color.warning_60); break; case UNAPPROVED: statusTextResId = R.string.comment_status_unapproved; - statusColor = ContextExtensionsKt.getColorFromAttribute(getActivity(), R.attr.wpColorWarningDark); + statusColor = ContextCompat.getColor(getActivity(), R.color.warning_60); break; case SPAM: statusTextResId = R.string.comment_status_spam; - statusColor = ContextExtensionsKt.getColorFromAttribute(getActivity(), R.attr.colorError); + statusColor = ContextCompat.getColor(getActivity(), R.color.error); break; case TRASH: default: statusTextResId = R.string.comment_status_trash; - statusColor = ContextExtensionsKt.getColorFromAttribute(getActivity(), R.attr.colorError); + statusColor = ContextCompat.getColor(getActivity(), R.color.error); break; } @@ -1008,7 +1047,12 @@ private void updateStatusViews() { if (canModerate()) { setModerateButtonForStatus(commentStatus); - mBtnModerateComment.setOnClickListener(v -> performModerateAction()); + mBtnModerateComment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + performModerateAction(); + } + }); mBtnModerateComment.setVisibility(View.VISIBLE); } else { mBtnModerateComment.setVisibility(View.GONE); @@ -1029,8 +1073,7 @@ private void updateStatusViews() { mBtnTrashComment.setVisibility(View.VISIBLE); if (commentStatus == CommentStatus.TRASH) { ColorUtils.INSTANCE.setImageResourceWithTint(mBtnModerateIcon, R.drawable.ic_undo_white_24dp, - ContextExtensionsKt - .getColorResIdFromAttribute(mBtnModerateTextView.getContext(), R.attr.colorOnSurface)); + R.color.neutral); mBtnModerateTextView.setText(R.string.mnu_comment_untrash); mBtnTrashCommentText.setText(R.string.mnu_comment_delete_permanently); } else { @@ -1070,17 +1113,11 @@ private void setModerateButtonForStatus(CommentStatus status) { int color; if (status == CommentStatus.APPROVED) { - color = ContextExtensionsKt - .getColorResIdFromAttribute(mBtnModerateTextView.getContext(), R.attr.colorSecondary); + color = R.color.accent; mBtnModerateTextView.setText(R.string.comment_status_approved); - mBtnModerateTextView.setAlpha(mNormalOpacity); - mBtnModerateIcon.setAlpha(mNormalOpacity); } else { - color = ContextExtensionsKt - .getColorResIdFromAttribute(mBtnModerateTextView.getContext(), R.attr.colorOnSurface); + color = R.color.neutral; mBtnModerateTextView.setText(R.string.mnu_comment_approve); - mBtnModerateTextView.setAlpha(mMediumOpacity); - mBtnModerateIcon.setAlpha(mMediumOpacity); } ColorUtils.INSTANCE.setImageResourceWithTint(mBtnModerateIcon, R.drawable.ic_checkmark_white_24dp, color); @@ -1206,19 +1243,15 @@ private void toggleLikeButton(boolean isLiked) { int drawable; if (isLiked) { - color = ContextExtensionsKt.getColorResIdFromAttribute(mBtnLikeIcon.getContext(), R.attr.colorSecondary); + color = R.color.accent; drawable = R.drawable.ic_star_white_24dp; mBtnLikeTextView.setText(getResources().getString(R.string.mnu_comment_liked)); mBtnLikeComment.setActivated(true); - mBtnLikeTextView.setAlpha(mNormalOpacity); - mBtnLikeIcon.setAlpha(mNormalOpacity); } else { - color = ContextExtensionsKt.getColorResIdFromAttribute(mBtnLikeIcon.getContext(), R.attr.colorOnSurface); + color = R.color.neutral; drawable = R.drawable.ic_star_outline_white_24dp; mBtnLikeTextView.setText(getResources().getString(R.string.reader_label_like)); mBtnLikeComment.setActivated(false); - mBtnLikeTextView.setAlpha(mMediumOpacity); - mBtnLikeIcon.setAlpha(mMediumOpacity); } ColorUtils.INSTANCE.setImageResourceWithTint(mBtnLikeIcon, drawable, color); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDialogs.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDialogs.java index c9d9eeaaa45f..96d9b48034d3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDialogs.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDialogs.java @@ -10,17 +10,17 @@ * Dialogs related to comment moderation displayed from CommentsActivity and NotificationsActivity */ class CommentDialogs { - static final int ID_COMMENT_DLG_APPROVING = 100; - static final int ID_COMMENT_DLG_DISAPPROVING = 101; - static final int ID_COMMENT_DLG_SPAMMING = 102; - static final int ID_COMMENT_DLG_TRASHING = 103; - static final int ID_COMMENT_DLG_DELETING = 104; + public static final int ID_COMMENT_DLG_APPROVING = 100; + public static final int ID_COMMENT_DLG_DISAPPROVING = 101; + public static final int ID_COMMENT_DLG_SPAMMING = 102; + public static final int ID_COMMENT_DLG_TRASHING = 103; + public static final int ID_COMMENT_DLG_DELETING = 104; private CommentDialogs() { throw new AssertionError(); } - static Dialog createCommentDialog(Activity activity, int dialogId) { + public static Dialog createCommentDialog(Activity activity, int dialogId) { final int resId; switch (dialogId) { case ID_COMMENT_DLG_APPROVING: diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsActivity.java index 501f8bf5bc99..87ac8c3793ca 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsActivity.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.comments; import android.app.Dialog; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; @@ -9,6 +10,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -29,7 +31,6 @@ import org.wordpress.android.models.CommentList; import org.wordpress.android.models.Note; import org.wordpress.android.ui.ActivityId; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.comments.CommentsListFragment.OnCommentSelectedListener; import org.wordpress.android.ui.notifications.NotificationFragment; import org.wordpress.android.ui.posts.BasicFragmentDialog; @@ -37,12 +38,13 @@ import org.wordpress.android.ui.prefs.AppPrefs; import org.wordpress.android.ui.reader.ReaderPostDetailFragment; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.widgets.WPSnackbar; import javax.inject.Inject; -public class CommentsActivity extends LocaleAwareActivity +public class CommentsActivity extends AppCompatActivity implements OnCommentSelectedListener, NotificationFragment.OnPostClickListener, BasicFragmentDialog.BasicDialogPositiveClickInterface { @@ -53,11 +55,18 @@ public class CommentsActivity extends LocaleAwareActivity public static final String COMMENT_MODERATE_STATUS_EXTRA = "commentModerateStatus"; private final CommentList mTrashedComments = new CommentList(); + private CommentStatus mCurrentCommentStatusType = CommentStatus.ALL; + private SiteModel mSite; @Inject Dispatcher mDispatcher; @Inject CommentStore mCommentStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -65,10 +74,11 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.comment_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); + Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { + actionBar.setElevation(0); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } @@ -85,22 +95,21 @@ public void onCreate(Bundle savedInstanceState) { return; } - CommentStatus currentCommentStatusType; if (getIntent() != null && getIntent().hasExtra(SAVED_COMMENTS_STATUS_TYPE)) { - currentCommentStatusType = (CommentStatus) getIntent().getSerializableExtra(SAVED_COMMENTS_STATUS_TYPE); + mCurrentCommentStatusType = (CommentStatus) getIntent().getSerializableExtra(SAVED_COMMENTS_STATUS_TYPE); } else { // Read the value from app preferences here. Default to 0 - All - currentCommentStatusType = AppPrefs.getCommentsStatusFilter().toCommentStatus(); + mCurrentCommentStatusType = AppPrefs.getCommentsStatusFilter().toCommentStatus(); } if (savedInstanceState == null) { CommentsListFragment commentsListFragment = new CommentsListFragment(); // initialize comment status filter first time - commentsListFragment.setCommentStatusFilter(currentCommentStatusType); + commentsListFragment.setCommentStatusFilter(mCurrentCommentStatusType); getSupportFragmentManager().beginTransaction() - .add(R.id.layout_fragment_container, commentsListFragment, - getString(R.string.fragment_tag_comment_list)) - .commitAllowingStateLoss(); + .add(R.id.layout_fragment_container, commentsListFragment, + getString(R.string.fragment_tag_comment_list)) + .commitAllowingStateLoss(); } else { getIntent().putExtra(KEY_AUTO_REFRESHED, savedInstanceState.getBoolean(KEY_AUTO_REFRESHED)); getIntent().putExtra(KEY_EMPTY_VIEW_MESSAGE, savedInstanceState.getString(KEY_EMPTY_VIEW_MESSAGE)); @@ -208,13 +217,12 @@ protected Dialog onCreateDialog(int id) { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { long commentId = data.getLongExtra(COMMENT_MODERATE_ID_EXTRA, -1); String newStatus = data.getStringExtra(COMMENT_MODERATE_STATUS_EXTRA); if (commentId >= 0 && !TextUtils.isEmpty(newStatus)) { onModerateComment(mCommentStore.getCommentBySiteAndRemoteId(mSite, commentId), - CommentStatus.fromString(newStatus)); + CommentStatus.fromString(newStatus)); } } } @@ -234,13 +242,16 @@ public void onModerateComment(final CommentModel comment, String message = (newStatus == CommentStatus.TRASH ? getString(R.string.comment_trashed) : newStatus == CommentStatus.SPAM ? getString(R.string.comment_spammed) : getString(R.string.comment_deleted_permanently)); - View.OnClickListener undoListener = v -> { - mTrashedComments.remove(comment); - getListFragment().loadComments(); + View.OnClickListener undoListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + mTrashedComments.remove(comment); + getListFragment().loadComments(); + } }; WPSnackbar snackbar = WPSnackbar.make(getListFragment().getView(), message, Snackbar.LENGTH_LONG) - .setAction(R.string.undo, undoListener); + .setAction(R.string.undo, undoListener); // do the actual moderation once the undo bar has been hidden snackbar.setCallback(new Snackbar.Callback() { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java index c5d6ab50f3f5..1512bcc14dbf 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui.comments; +import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; @@ -9,7 +10,7 @@ import android.widget.ProgressBar; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import androidx.viewpager.widget.ViewPager; import org.greenrobot.eventbus.Subscribe; @@ -27,8 +28,8 @@ import org.wordpress.android.fluxc.store.CommentStore.OnCommentChanged; import org.wordpress.android.models.CommentList; import org.wordpress.android.ui.CollapseFullScreenDialogFragment; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.widgets.WPViewPager; @@ -38,7 +39,7 @@ import static org.wordpress.android.ui.comments.CommentsListFragment.COMMENTS_PER_PAGE; -public class CommentsDetailActivity extends LocaleAwareActivity +public class CommentsDetailActivity extends AppCompatActivity implements CommentAdapter.OnLoadMoreListener, CommentActions.OnCommentActionListener { public static final String COMMENT_ID_EXTRA = "commentId"; @@ -60,6 +61,11 @@ public class CommentsDetailActivity extends LocaleAwareActivity private boolean mIsUpdatingComments; private boolean mCanLoadMoreComments = true; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onBackPressed() { CollapseFullScreenDialogFragment fragment = (CollapseFullScreenDialogFragment) @@ -81,10 +87,9 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.comments_detail_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { + actionBar.setElevation(0); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } @@ -102,7 +107,7 @@ public void onCreate(Bundle savedInstanceState) { // set up the viewpager and adapter for lateral navigation mViewPager = findViewById(R.id.viewpager); mViewPager.setPageTransformer(false, - new WPViewPagerTransformer(WPViewPagerTransformer.TransformType.SLIDE_OVER)); + new WPViewPagerTransformer(WPViewPagerTransformer.TransformType.SLIDE_OVER)); mProgressBar = findViewById(R.id.progress_loading); @@ -208,7 +213,7 @@ private void showCommentList(CommentList commentList) { } else { // If current items change, rebuild the adapter mAdapter = new CommentDetailFragmentAdapter(getSupportFragmentManager(), commentList, mSite, - CommentsDetailActivity.this); + CommentsDetailActivity.this); mViewPager.setAdapter(mAdapter); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsListFragment.java index 8cb8e0568b38..ba94fef19f14 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsListFragment.java @@ -1,8 +1,11 @@ package org.wordpress.android.ui.comments; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -12,14 +15,12 @@ import androidx.annotation.NonNull; import androidx.annotation.StringRes; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.view.ActionMode; +import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.DividerItemDecoration; import com.google.android.material.appbar.AppBarLayout; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -53,7 +54,7 @@ import javax.inject.Inject; public class CommentsListFragment extends Fragment { - static final int COMMENTS_PER_PAGE = 30; + public static final int COMMENTS_PER_PAGE = 30; interface OnCommentSelectedListener { void onCommentSelected(long commentId, CommentStatus statusFilter); @@ -143,40 +144,49 @@ private void updateSiteOrFinishActivity(Bundle savedInstanceState) { private CommentAdapter getAdapter() { if (mAdapter == null) { // called after comments have been loaded - CommentAdapter.OnDataLoadedListener dataLoadedListener = isEmpty -> { - if (!isAdded()) { - return; - } + CommentAdapter.OnDataLoadedListener dataLoadedListener = new CommentAdapter.OnDataLoadedListener() { + @Override + public void onDataLoaded(boolean isEmpty) { + if (!isAdded()) { + return; + } - if (!isEmpty) { - // Hide the empty view if there are already some displayed comments - mFilteredCommentsView.hideEmptyView(); - mFilteredCommentsView.setToolbarScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL - | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); - mActionableEmptyView.setVisibility(View.GONE); - } else if (!mIsUpdatingComments) { - // Change LOADING to NO_CONTENT message - mFilteredCommentsView.updateEmptyView(EmptyViewMessageType.NO_CONTENT); + if (!isEmpty) { + // Hide the empty view if there are already some displayed comments + mFilteredCommentsView.hideEmptyView(); + mFilteredCommentsView.setToolbarScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL + | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); + mActionableEmptyView.setVisibility(View.GONE); + } else if (!mIsUpdatingComments) { + // Change LOADING to NO_CONTENT message + mFilteredCommentsView.updateEmptyView(EmptyViewMessageType.NO_CONTENT); + } } }; // adapter calls this to request more comments from server when it reaches the end - CommentAdapter.OnLoadMoreListener loadMoreListener = () -> { - if (mCanLoadMoreComments && !mIsUpdatingComments) { - updateComments(true); + CommentAdapter.OnLoadMoreListener loadMoreListener = new CommentAdapter.OnLoadMoreListener() { + @Override + public void onLoadMore() { + if (mCanLoadMoreComments && !mIsUpdatingComments) { + updateComments(true); + } } }; // adapter calls this when selected comments have changed (CAB) CommentAdapter.OnSelectedItemsChangeListener changeListener = - () -> { - if (mActionMode != null) { - if (getSelectedCommentCount() == 0) { - mActionMode.finish(); - } else { - updateActionModeTitle(); - // must invalidate to ensure onPrepareActionMode is called - mActionMode.invalidate(); + new CommentAdapter.OnSelectedItemsChangeListener() { + @Override + public void onSelectedItemsChanged() { + if (mActionMode != null) { + if (getSelectedCommentCount() == 0) { + mActionMode.finish(); + } else { + updateActionModeTitle(); + // must invalidate to ensure onPrepareActionMode is called + mActionMode.invalidate(); + } } } }; @@ -192,8 +202,8 @@ public void onCommentPressed(int position, View view) { mFilteredCommentsView.invalidate(); if (getActivity() instanceof OnCommentSelectedListener) { ((OnCommentSelectedListener) getActivity()).onCommentSelected(comment.getRemoteCommentId(), - mCommentStatusFilter - .toCommentStatus()); + mCommentStatusFilter + .toCommentStatus()); } } else { getAdapter().toggleItemSelected(position, view); @@ -233,7 +243,7 @@ private int getSelectedCommentCount() { return getAdapter().getSelectedCommentCount(); } - void removeComment(CommentModel comment) { + public void removeComment(CommentModel comment) { if (hasAdapter() && comment != null) { getAdapter().removeComment(comment); } @@ -275,8 +285,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, mActionableEmptyView = view.findViewById(R.id.actionable_empty_view); mFilteredCommentsView = view.findViewById(R.id.filtered_recycler_view); - mFilteredCommentsView - .addItemDecoration(new DividerItemDecoration(view.getContext(), DividerItemDecoration.VERTICAL)); mFilteredCommentsView.setLogT(AppLog.T.COMMENTS); mFilteredCommentsView.setFilterListener(new FilteredRecyclerView.FilterListener() { @Override @@ -360,7 +368,7 @@ public String onShowEmptyViewMessage(EmptyViewMessageType emptyViewMsgType) { mActionableEmptyView.setVisibility(View.GONE); mFilteredCommentsView.setToolbarScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL - | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); + | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); return getString(stringId); } } @@ -370,6 +378,9 @@ public void onShowCustomEmptyView(EmptyViewMessageType emptyViewMsgType) { } }); + // the following will change the look and feel of the toolbar to match the current design + mFilteredCommentsView.setToolbarBackgroundColor(ContextCompat.getColor(getActivity(), R.color.primary_40)); + mFilteredCommentsView.setToolbarSpinnerTextColor(ContextCompat.getColor(getActivity(), android.R.color.white)); mFilteredCommentsView.setToolbarSpinnerDrawable(R.drawable.ic_dropdown_primary_30_24dp); mFilteredCommentsView.setToolbarLeftAndRightPadding( getResources().getDimensionPixelSize(R.dimen.margin_filter_spinner), @@ -390,7 +401,7 @@ public void onResume() { } } - void setCommentStatusFilter(CommentStatus statusFilter) { + public void setCommentStatusFilter(CommentStatus statusFilter) { mCommentStatusFilter = CommentStatusCriteria.fromCommentStatus(statusFilter); } @@ -431,24 +442,39 @@ private void moderateSelectedComments(final CommentStatus newStatus) { private void confirmDeleteComments() { if (mCommentStatusFilter == CommentStatusCriteria.TRASH) { - AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); dialogBuilder.setTitle(getResources().getText(R.string.delete)); int resId = getAdapter().getSelectedCommentCount() > 1 ? R.string.dlg_sure_to_delete_comments : R.string.dlg_sure_to_delete_comment; dialogBuilder.setMessage(getResources().getText(resId)); dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), - (dialog, whichButton) -> deleteSelectedComments(true)); + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + deleteSelectedComments(true); + } + }); dialogBuilder.setNegativeButton(getResources().getText(R.string.no), null); dialogBuilder.setCancelable(true); dialogBuilder.create().show(); } else { - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setMessage(R.string.dlg_confirm_trash_comments); builder.setTitle(R.string.trash); builder.setCancelable(true); - builder.setPositiveButton(R.string.dlg_confirm_action_trash, (dialog, id) -> deleteSelectedComments(false)); - builder.setNegativeButton(R.string.dlg_cancel_action_dont_trash, (dialog, id) -> dialog.cancel()); - + builder.setPositiveButton(R.string.dlg_confirm_action_trash, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + deleteSelectedComments(false); + } + }); + builder.setNegativeButton(R.string.dlg_cancel_action_dont_trash, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }); AlertDialog alert = builder.create(); alert.show(); } @@ -528,7 +554,7 @@ void updateEmptyView() { * get latest comments from server, or pass loadMore=true to get comments beyond the * existing ones */ - private void updateComments(boolean loadMore) { + void updateComments(boolean loadMore) { if (mIsUpdatingComments) { AppLog.w(AppLog.T.COMMENTS, "update comments task already running"); return; @@ -556,11 +582,11 @@ private void updateComments(boolean loadMore) { mFilteredCommentsView.setRefreshing(true); mDispatcher.dispatch(CommentActionBuilder.newFetchCommentsAction( - new FetchCommentsPayload(mSite, mCommentStatusFilter.toCommentStatus(), COMMENTS_PER_PAGE, offset))); + new FetchCommentsPayload(mSite, mCommentStatusFilter.toCommentStatus(), COMMENTS_PER_PAGE, offset))); } - String getEmptyViewMessage() { + public String getEmptyViewMessage() { return mEmptyViewMessageType.name(); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java index e36ee8f24d60..5c78a308c91f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java @@ -1,11 +1,15 @@ package org.wordpress.android.ui.comments; +import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; +import android.view.ContextThemeWrapper; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -14,14 +18,10 @@ import android.widget.ProgressBar; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; - -import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import androidx.appcompat.app.AppCompatActivity; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.datasets.NotificationsTable; @@ -36,16 +36,16 @@ import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.models.Note; import org.wordpress.android.ui.ActivityId; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; import org.wordpress.android.util.EditTextUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ToastUtils; import javax.inject.Inject; -public class EditCommentActivity extends LocaleAwareActivity { +public class EditCommentActivity extends AppCompatActivity { static final String KEY_COMMENT = "KEY_COMMENT"; static final String KEY_NOTE_ID = "KEY_NOTE_ID"; @@ -63,14 +63,18 @@ public class EditCommentActivity extends LocaleAwareActivity { @Inject SiteStore mSiteStore; @Inject CommentStore mCommentStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); ((WordPress) getApplication()).component().inject(this); setContentView(R.layout.comment_edit_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); + ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(true); @@ -95,7 +99,7 @@ public void onStart() { } @Override - protected void onSaveInstanceState(@NotNull Bundle outState) { + protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mCancelEditCommentDialog != null) { @@ -152,7 +156,7 @@ private void showErrorAndFinish() { } private void configureViews() { - final EditText editContent = this.findViewById(R.id.edit_comment_content); + final EditText editContent = (EditText) this.findViewById(R.id.edit_comment_content); editContent.setText(mComment.getContent()); // show error when comment content is empty @@ -201,13 +205,13 @@ public boolean onOptionsItemSelected(final MenuItem item) { } private String getEditTextStr(int resId) { - final EditText edit = findViewById(resId); + final EditText edit = (EditText) findViewById(resId); return EditTextUtils.getText(edit); } private void saveComment() { // make sure comment content was entered - final EditText editContent = findViewById(R.id.edit_comment_content); + final EditText editContent = (EditText) findViewById(R.id.edit_comment_content); if (EditTextUtils.isEmpty(editContent)) { editContent.setError(getString(R.string.content_required)); return; @@ -265,18 +269,21 @@ private void dismissSaveDialog() { } private void showEditErrorAlert() { - MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( + new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)); dialogBuilder.setTitle(getResources().getText(R.string.error)); dialogBuilder.setMessage(R.string.error_edit_comment); - dialogBuilder.setPositiveButton(android.R.string.ok, (dialog1, whichButton) -> { - // just close the dialog + dialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + // just close the dialog + } }); dialogBuilder.setCancelable(true); dialogBuilder.create().show(); } private void setFetchProgressVisible(boolean progressVisible) { - final ProgressBar progress = findViewById(R.id.edit_comment_progress); + final ProgressBar progress = (ProgressBar) findViewById(R.id.edit_comment_progress); final View editContainer = findViewById(R.id.edit_comment_container); if (progress == null || editContainer == null) { @@ -302,15 +309,22 @@ private void cancelEditCommentConfirmation() { return; } - MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( + new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)); dialogBuilder.setTitle(getResources().getText(R.string.cancel_edit)); dialogBuilder.setMessage(getResources().getText(R.string.sure_to_cancel_edit_comment)); dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), - (dialog, whichButton) -> finish()); + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + finish(); + } + }); dialogBuilder.setNegativeButton( getResources().getText(R.string.no), - (dialog, whichButton) -> { - // just close the dialog + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + // just close the dialog + } }); dialogBuilder.setCancelable(true); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationActivity.kt index 0957356c6e22..bd22a9792931 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationActivity.kt @@ -4,18 +4,18 @@ import android.app.Activity import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProviders -import kotlinx.android.synthetic.main.toolbar_main.* +import kotlinx.android.synthetic.main.toolbar.* import org.wordpress.android.R import org.wordpress.android.WordPress -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.domains.DomainRegistrationActivity.DomainRegistrationPurpose.CTA_DOMAIN_CREDIT_REDEMPTION import javax.inject.Inject -class DomainRegistrationActivity : LocaleAwareActivity() { +class DomainRegistrationActivity : AppCompatActivity() { enum class DomainRegistrationPurpose { AUTOMATED_TRANSFER, CTA_DOMAIN_CREDIT_REDEMPTION @@ -32,12 +32,12 @@ class DomainRegistrationActivity : LocaleAwareActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) (application as WordPress).component().inject(this) - setContentView(R.layout.domain_suggestions_activity) + setContentView(R.layout.activity_domain_suggestions_activity) domainRegistrationPurpose = intent.getSerializableExtra(DOMAIN_REGISTRATION_PURPOSE_KEY) as DomainRegistrationPurpose - setSupportActionBar(toolbar_main) + setSupportActionBar(toolbar) supportActionBar?.let { it.setHomeButtonEnabled(true) it.setDisplayHomeAsUpEnabled(true) @@ -46,8 +46,7 @@ class DomainRegistrationActivity : LocaleAwareActivity() { } private fun setupViewModel() { - viewModel = ViewModelProviders.of(this, viewModelFactory) - .get(DomainRegistrationMainViewModel::class.java) + viewModel = ViewModelProviders.of(this, viewModelFactory).get(DomainRegistrationMainViewModel::class.java) viewModel.start() viewModel.domainSuggestionsVisible.observe(this, Observer { isVisible -> @@ -55,21 +54,14 @@ class DomainRegistrationActivity : LocaleAwareActivity() { var fragment = supportFragmentManager.findFragmentByTag(DomainSuggestionsFragment.TAG) if (fragment == null) { fragment = DomainSuggestionsFragment.newInstance() - showFragment( - fragment, - DomainSuggestionsFragment.TAG, - slideIn = false, - isRootFragment = true - ) + showFragment(fragment, DomainSuggestionsFragment.TAG, slideIn = false, isRootFragment = true) } } }) viewModel.selectedDomain.observe(this, Observer { selectedDomain -> selectedDomain?.let { - var fragment = supportFragmentManager.findFragmentByTag( - DomainRegistrationDetailsFragment.TAG - ) + var fragment = supportFragmentManager.findFragmentByTag(DomainRegistrationDetailsFragment.TAG) if (fragment == null) { fragment = DomainRegistrationDetailsFragment.newInstance(it) @@ -81,23 +73,15 @@ class DomainRegistrationActivity : LocaleAwareActivity() { viewModel.domainRegistrationCompleted.observe(this, Observer { event -> event?.let { if (shouldShowCongratsScreen()) { - var fragment = supportFragmentManager.findFragmentByTag( - DomainRegistrationResultFragment.TAG - ) + var fragment = supportFragmentManager.findFragmentByTag(DomainRegistrationResultFragment.TAG) if (fragment == null) { - fragment = DomainRegistrationResultFragment.newInstance( - it.domainName, - it.email - ) + fragment = DomainRegistrationResultFragment.newInstance(it.domainName, it.email) showFragment(fragment!!, DomainRegistrationResultFragment.TAG) } } else { val intent = Intent() - intent.putExtra( - DomainRegistrationResultFragment.RESULT_REGISTERED_DOMAIN_EMAIL, - it.email - ) + intent.putExtra(DomainRegistrationResultFragment.RESULT_REGISTERED_DOMAIN_EMAIL, it.email) setResult(Activity.RESULT_OK, intent) finish() } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationDetailsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationDetailsFragment.kt index 180cd404c478..e4818d7a4989 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationDetailsFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainRegistrationDetailsFragment.kt @@ -19,7 +19,6 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProviders -import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputLayout import dagger.android.support.AndroidSupportInjection @@ -75,11 +74,7 @@ class DomainRegistrationDetailsFragment : Fragment() { (nonNullActivity.application as WordPress).component()?.inject(this) } - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.domain_registration_details_fragment, container, false) } @@ -157,9 +152,7 @@ class DomainRegistrationDetailsFragment : Fragment() { private fun setupTosLink() { tos_explanation.text = Html.fromHtml( String.format( - resources.getString(R.string.domain_registration_privacy_protection_tos), - "", - "" + resources.getString(R.string.domain_registration_privacy_protection_tos), "", "" ) ) tos_explanation.movementMethod = LinkMovementMethod.getInstance() @@ -196,14 +189,12 @@ class DomainRegistrationDetailsFragment : Fragment() { } }) - viewModel.domainContactForm.observe( - this, - Observer { domainContactFormModel -> - val currentModel = getDomainContactFormModel() - if (currentModel != domainContactFormModel) { - populateContactForm(domainContactFormModel!!) - } - }) + viewModel.domainContactForm.observe(this, Observer { domainContactFormModel -> + val currentModel = getDomainContactFormModel() + if (currentModel != domainContactFormModel) { + populateContactForm(domainContactFormModel!!) + } + }) viewModel.showCountryPickerDialog.observe(this, Observer { @@ -234,10 +225,7 @@ class DomainRegistrationDetailsFragment : Fragment() { STATE -> affectedInputFields = arrayOf(state_input) COUNTRY_CODE -> affectedInputFields = arrayOf(country_input) EMAIL -> affectedInputFields = arrayOf(email_input) - PHONE -> affectedInputFields = arrayOf( - country_code_input, - phone_number_input - ) + PHONE -> affectedInputFields = arrayOf(country_code_input, phone_number_input) else -> { } // Something else, will just show a Toast with an error message } @@ -262,10 +250,7 @@ class DomainRegistrationDetailsFragment : Fragment() { viewModel.showTos.observe(this, Observer { - ActivityLauncher.openUrlExternal( - context, - WPUrlUtils.buildTermsOfServiceUrl(context) - ) + ActivityLauncher.openUrlExternal(context, WPUrlUtils.buildTermsOfServiceUrl(context)) }) } @@ -287,15 +272,8 @@ class DomainRegistrationDetailsFragment : Fragment() { var formIsCompleted = true val requiredFields = arrayOf( - first_name_input, - last_name_input, - email_input, - country_code_input, - phone_number_input, - country_input, - address_first_line_input, - city_input, - postal_code_input + first_name_input, last_name_input, email_input, country_code_input, phone_number_input, + country_input, address_first_line_input, city_input, postal_code_input ) var fieldToFocusOn: TextInputEditText? = null @@ -323,10 +301,7 @@ class DomainRegistrationDetailsFragment : Fragment() { private fun showEmptyFieldError(editText: EditText) { val parent = editText.parent.parent if (parent is TextInputLayout) { - showFieldError( - editText, - getString(R.string.domain_registration_contact_form_input_error, parent.hint) - ) + showFieldError(editText, getString(R.string.domain_registration_contact_form_input_error, parent.hint)) } } @@ -361,17 +336,13 @@ class DomainRegistrationDetailsFragment : Fragment() { private fun showStatePicker(states: List) { val dialogFragment = StatePickerDialogFragment.newInstance(states.toCollection(ArrayList())) dialogFragment.setTargetFragment(this, 0) - dialogFragment.show(requireFragmentManager(), StatePickerDialogFragment.TAG) + dialogFragment.show(fragmentManager, StatePickerDialogFragment.TAG) } private fun showCountryPicker(countries: List) { - val dialogFragment = CountryPickerDialogFragment.newInstance( - countries.toCollection( - ArrayList() - ) - ) + val dialogFragment = CountryPickerDialogFragment.newInstance(countries.toCollection(ArrayList())) dialogFragment.setTargetFragment(this, 0) - dialogFragment.show(requireFragmentManager(), CountryPickerDialogFragment.TAG) + dialogFragment.show(fragmentManager, CountryPickerDialogFragment.TAG) } private fun toggleFormProgressIndictor(visible: Boolean) { @@ -452,7 +423,7 @@ class DomainRegistrationDetailsFragment : Fragment() { viewModel = ViewModelProviders.of(targetFragment!!, viewModelFactory) .get(DomainRegistrationDetailsViewModel::class.java) - val builder = MaterialAlertDialogBuilder(requireContext()) + val builder = AlertDialog.Builder(requireContext()) builder.setTitle(R.string.domain_registration_state_picker_dialog_title) builder.setItems(states.map { it.name }.toTypedArray()) { _, which -> viewModel.onStateSelected(states[which]) @@ -465,7 +436,7 @@ class DomainRegistrationDetailsFragment : Fragment() { return builder.create() } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) AndroidSupportInjection.inject(this) } @@ -515,7 +486,7 @@ class DomainRegistrationDetailsFragment : Fragment() { return builder.create() } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) AndroidSupportInjection.inject(this) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainSuggestionsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainSuggestionsFragment.kt index 0b72d211cf9a..650de14b7648 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainSuggestionsFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/domains/DomainSuggestionsFragment.kt @@ -35,11 +35,7 @@ class DomainSuggestionsFragment : Fragment() { } } - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { return inflater.inflate(R.layout.domain_suggestions_fragment, container, false) } @@ -52,8 +48,7 @@ class DomainSuggestionsFragment : Fragment() { mainViewModel = ViewModelProviders.of(activity!!, viewModelFactory) .get(DomainRegistrationMainViewModel::class.java) - viewModel = ViewModelProviders.of(this, viewModelFactory) - .get(DomainSuggestionsViewModel::class.java) + viewModel = ViewModelProviders.of(this, viewModelFactory).get(DomainSuggestionsViewModel::class.java) val nonNullIntent = checkNotNull(nonNullActivity.intent) val site = nonNullIntent.getSerializableExtra(WordPress.SITE) as SiteModel @@ -64,11 +59,7 @@ class DomainSuggestionsFragment : Fragment() { } private fun setupViews() { - domain_suggestions_list.layoutManager = LinearLayoutManager( - activity, - RecyclerView.VERTICAL, - false - ) + domain_suggestions_list.layoutManager = LinearLayoutManager(activity, RecyclerView.VERTICAL, false) domain_suggestions_list.setEmptyView(actionableEmptyView) chose_domain_button.setOnClickListener { val selectedDomain = viewModel.selectedSuggestion.value @@ -104,7 +95,6 @@ class DomainSuggestionsFragment : Fragment() { domain_suggestions_container.visibility = if (isLoading) View.INVISIBLE else View.VISIBLE suggestion_progress_bar.visibility = if (isLoading) View.VISIBLE else View.GONE - suggestion_search_icon.visibility = if (isLoading) View.GONE else View.VISIBLE if (!isLoading) { reloadSuggestions(listState.data) @@ -131,10 +121,7 @@ class DomainSuggestionsFragment : Fragment() { adapter.updateSuggestionsList(domainSuggestions) } - private fun onDomainSuggestionSelected( - domainSuggestion: DomainSuggestionResponse?, - selectedPosition: Int - ) { + private fun onDomainSuggestionSelected(domainSuggestion: DomainSuggestionResponse?, selectedPosition: Int) { viewModel.onDomainSuggestionsSelected(domainSuggestion, selectedPosition) } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/giphy/GiphyPickerActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/giphy/GiphyPickerActivity.kt index c977e783fdc9..8516ed2c8aaf 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/giphy/GiphyPickerActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/giphy/GiphyPickerActivity.kt @@ -8,6 +8,7 @@ import android.view.View import android.view.ViewGroup import android.widget.ImageView import android.widget.RelativeLayout +import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView.OnQueryTextListener import androidx.lifecycle.Observer @@ -19,7 +20,6 @@ import org.wordpress.android.WordPress import org.wordpress.android.analytics.AnalyticsTracker import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.ui.ActionableEmptyView -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.giphy.GiphyMediaViewHolder.ThumbnailViewDimensions import org.wordpress.android.ui.media.MediaPreviewActivity import org.wordpress.android.util.AniUtils @@ -39,7 +39,7 @@ import javax.inject.Inject * * Important: Giphy is currently disabled everywhere. We are planning to replace it with a different service provider. */ -class GiphyPickerActivity : LocaleAwareActivity() { +class GiphyPickerActivity : AppCompatActivity() { /** * Used for loading images in [GiphyMediaViewHolder] */ diff --git a/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt index c8a748c15009..d4c3779342e8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailActivity.kt @@ -1,14 +1,13 @@ package org.wordpress.android.ui.history import android.os.Bundle -import kotlinx.android.synthetic.main.toolbar_main.* +import androidx.appcompat.app.AppCompatActivity import org.wordpress.android.R import org.wordpress.android.analytics.AnalyticsTracker import org.wordpress.android.analytics.AnalyticsTracker.Stat -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.history.HistoryListItem.Revision -class HistoryDetailActivity : LocaleAwareActivity() { +class HistoryDetailActivity : AppCompatActivity() { companion object { const val KEY_HISTORY_DETAIL_FRAGMENT = "history_detail_fragment" } @@ -17,7 +16,6 @@ class HistoryDetailActivity : LocaleAwareActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.history_detail_activity) - setSupportActionBar(toolbar_main) supportActionBar?.setDisplayHomeAsUpEnabled(true) val extras = intent.extras diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/MainBottomSheetFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/MainBottomSheetFragment.kt index 5d7f6862ea84..f3c3f923f7d5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/MainBottomSheetFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/MainBottomSheetFragment.kt @@ -24,6 +24,8 @@ class MainBottomSheetFragment : BottomSheetDialogFragment() { @Inject lateinit var viewModelFactory: ViewModelProvider.Factory private lateinit var viewModel: WPMainActivityViewModel + override fun getTheme() = R.style.Handled_BottomSheetDialogStyle + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -42,10 +44,10 @@ class MainBottomSheetFragment : BottomSheetDialogFragment() { viewModel = ViewModelProviders.of(requireActivity(), viewModelFactory).get(WPMainActivityViewModel::class.java) viewModel.mainActions.observe(this, Observer { - (dialog?.content_recycler_view?.adapter as? AddContentAdapter)?.update(it ?: listOf()) + (dialog.content_recycler_view.adapter as? AddContentAdapter)?.update(it ?: listOf()) }) - dialog?.setOnShowListener { dialogInterface -> + dialog.setOnShowListener { dialogInterface -> val sheetDialog = dialogInterface as? BottomSheetDialog val bottomSheet = sheetDialog?.findViewById( @@ -59,7 +61,7 @@ class MainBottomSheetFragment : BottomSheetDialogFragment() { } } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) (requireActivity().applicationContext as WordPress).component().inject(this) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/MeActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/MeActivity.kt index f18045d5d642..8a2dba55d8d1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/MeActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/MeActivity.kt @@ -1,16 +1,21 @@ package org.wordpress.android.ui.main +import android.content.Context import android.content.Intent -import android.content.pm.PackageManager import android.os.Bundle import android.view.MenuItem +import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.toolbar_main.* import org.wordpress.android.R -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.prefs.AppSettingsFragment.LANGUAGE_CHANGED +import org.wordpress.android.util.LocaleManager + +class MeActivity : AppCompatActivity() { + override fun attachBaseContext(newBase: Context) { + super.attachBaseContext(LocaleManager.setLocale(newBase)) + } -class MeActivity : LocaleAwareActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.me_activity) @@ -19,11 +24,6 @@ class MeActivity : LocaleAwareActivity() { supportActionBar?.let { it.setHomeButtonEnabled(true) it.setDisplayHomeAsUpEnabled(true) - val activityInfo = packageManager.getActivityInfo( - componentName, - PackageManager.GET_META_DATA - ) - it.setTitle(activityInfo.labelRes) } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/MeFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/main/MeFragment.java index ffa7f211c403..ff5153860af7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/MeFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/MeFragment.java @@ -3,6 +3,7 @@ import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; @@ -11,6 +12,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -20,11 +22,11 @@ import android.widget.TextView; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.yalantis.ucrop.UCrop; import com.yalantis.ucrop.UCropActivity; @@ -73,6 +75,7 @@ public class MeFragment extends Fragment implements MainToolbarFragment, WPMainA private ViewGroup mAvatarCard; private View mProgressBar; + private ViewGroup mAvatarContainer; private ImageView mAvatarImageView; private TextView mDisplayNameTextView; private TextView mUsernameTextView; @@ -86,6 +89,9 @@ public class MeFragment extends Fragment implements MainToolbarFragment, WPMainA private Toolbar mToolbar = null; private String mToolbarTitle; + // setUserVisibleHint is not available so we need to manually handle the UserVisibleHint state + private boolean mIsUserVisible; + private boolean mIsUpdatingGravatar; @Inject Dispatcher mDispatcher; @@ -109,13 +115,20 @@ public void onCreate(Bundle savedInstanceState) { } } + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + + mIsUserVisible = isVisibleToUser; + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.me_fragment, container, false); mAvatarCard = rootView.findViewById(R.id.card_avatar); - ViewGroup avatarContainer = rootView.findViewById(R.id.avatar_container); + mAvatarContainer = rootView.findViewById(R.id.avatar_container); mAvatarImageView = rootView.findViewById(R.id.me_avatar); mProgressBar = rootView.findViewById(R.id.avatar_progress); mDisplayNameTextView = rootView.findViewById(R.id.me_display_name); @@ -125,30 +138,53 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, mAccountSettingsView = rootView.findViewById(R.id.row_account_settings); mScrollView = rootView.findViewById(R.id.scroll_view); - OnClickListener showPickerListener = v -> { - AnalyticsTracker.track(AnalyticsTracker.Stat.ME_GRAVATAR_TAPPED); - showPhotoPickerForGravatar(); + OnClickListener showPickerListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + AnalyticsTracker.track(AnalyticsTracker.Stat.ME_GRAVATAR_TAPPED); + showPhotoPickerForGravatar(); + } }; - avatarContainer.setOnClickListener(showPickerListener); + mAvatarContainer.setOnClickListener(showPickerListener); rootView.findViewById(R.id.change_photo).setOnClickListener(showPickerListener); - mMyProfileView.setOnClickListener(v -> ActivityLauncher.viewMyProfile(getActivity())); + mMyProfileView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.viewMyProfile(getActivity()); + } + }); - mAccountSettingsView.setOnClickListener(v -> ActivityLauncher.viewAccountSettings(getActivity())); + mAccountSettingsView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.viewAccountSettings(getActivity()); + } + }); - rootView.findViewById(R.id.row_app_settings).setOnClickListener( - v -> ActivityLauncher.viewAppSettingsForResult(getActivity())); + rootView.findViewById(R.id.row_app_settings).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.viewAppSettingsForResult(getActivity()); + } + }); - rootView.findViewById(R.id.row_support).setOnClickListener( - v -> ActivityLauncher - .viewHelpAndSupport(getActivity(), Origin.ME_SCREEN_HELP, getSelectedSite(), null)); + rootView.findViewById(R.id.row_support).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.viewHelpAndSupport(getActivity(), Origin.ME_SCREEN_HELP, getSelectedSite(), null); + } + }); - rootView.findViewById(R.id.row_logout).setOnClickListener(v -> { - if (mAccountStore.hasAccessToken()) { - signOutWordPressComWithConfirmation(); - } else { - ActivityLauncher.showSignInForResult(getActivity()); + rootView.findViewById(R.id.row_logout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mAccountStore.hasAccessToken()) { + signOutWordPressComWithConfirmation(); + } else { + ActivityLauncher.showSignInForResult(getActivity()); + } } }); @@ -169,7 +205,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { if (mDisconnectProgressDialog != null) { outState.putBoolean(IS_DISCONNECTING, true); } @@ -193,7 +229,7 @@ public void onStart() { } @Override - public void setTitle(@NotNull String title) { + public void setTitle(String title) { mToolbarTitle = title; if (mToolbar != null) { mToolbar.setTitle(title); @@ -326,9 +362,13 @@ private void signOutWordPressComWithConfirmation() { message = getString(R.string.sign_out_wpcom_confirm_with_no_changes); } - new MaterialAlertDialogBuilder(getActivity()) + new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)) .setMessage(message) - .setPositiveButton(R.string.signout, (dialog, whichButton) -> signOutWordPressCom()) + .setPositiveButton(R.string.signout, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + signOutWordPressCom(); + } + }) .setNegativeButton(R.string.cancel, null) .setCancelable(true) .create().show(); @@ -372,7 +412,12 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { Uri imageUri = Uri.parse(strMediaUri); if (imageUri != null) { boolean didGoWell = WPMediaUtils.fetchMediaAndDoNext(getActivity(), imageUri, - this::startCropActivity); + new WPMediaUtils.MediaFetchDoNext() { + @Override + public void doNext(Uri uri) { + startCropActivity(uri); + } + }); if (!didGoWell) { AppLog.e(AppLog.T.UTILS, "Can't download picked or captured image"); @@ -385,8 +430,13 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { WPMediaUtils.fetchMediaAndDoNext(getActivity(), UCrop.getOutput(data), - uri -> startGravatarUpload( - MediaUtils.getRealPathFromURI(getActivity(), uri))); + new WPMediaUtils.MediaFetchDoNext() { + @Override + public void doNext(Uri uri) { + startGravatarUpload( + MediaUtils.getRealPathFromURI(getActivity(), uri)); + } + }); } else if (resultCode == UCrop.RESULT_ERROR) { AppLog.e(AppLog.T.MAIN, "Image cropping failed!", UCrop.getError(data)); ToastUtils.showToast(getActivity(), R.string.error_cropping_image, Duration.SHORT); @@ -434,24 +484,24 @@ private void startGravatarUpload(final String filePath) { showGravatarProgressBar(true); GravatarApi.uploadGravatar(file, mAccountStore.getAccount().getEmail(), mAccountStore.getAccessToken(), - new GravatarApi.GravatarUploadListener() { - @Override - public void onSuccess() { - EventBus.getDefault().post(new GravatarUploadFinished(filePath, true)); - } - - @Override - public void onError() { - EventBus.getDefault().post(new GravatarUploadFinished(filePath, false)); - } - }); + new GravatarApi.GravatarUploadListener() { + @Override + public void onSuccess() { + EventBus.getDefault().post(new GravatarUploadFinished(filePath, true)); + } + + @Override + public void onError() { + EventBus.getDefault().post(new GravatarUploadFinished(filePath, false)); + } + }); } public static class GravatarUploadFinished { public final String filePath; public final boolean success; - GravatarUploadFinished(String filePath, boolean success) { + public GravatarUploadFinished(String filePath, boolean success) { this.filePath = filePath; this.success = success; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java index 820da5a27adc..6667f63b3701 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/MySiteFragment.java @@ -10,7 +10,9 @@ import android.text.Spannable; import android.text.TextUtils; import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; @@ -21,6 +23,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.PopupMenu; +import androidx.appcompat.widget.PopupMenu.OnMenuItemClickListener; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; @@ -209,6 +212,8 @@ public void onResume() { updateSiteSettingsIfNecessary(); + reattachQuickStartFragmentListeners(); + // Site details may have changed (e.g. via Settings and returning to this Fragment) so update the UI refreshSelectedSiteDetails(getSelectedSite()); @@ -232,6 +237,18 @@ public void onResume() { showQuickStartNoticeIfNecessary(); } + private void reattachQuickStartFragmentListeners() { + if (getFragmentManager() != null) { + for (Fragment fragment : getFragmentManager().getFragments()) { + if (fragment instanceof FullScreenDialogFragment) { + FullScreenDialogFragment targetFragment = (FullScreenDialogFragment) fragment; + targetFragment.setOnConfirmListener(this); + targetFragment.setOnDismissListener(this); + } + } + } + } + private void showQuickStartNoticeIfNecessary() { if (!QuickStartUtils.isQuickStartInProgress(mQuickStartStore) || !AppPrefs.isQuickStartNoticeRequired()) { return; @@ -242,43 +259,54 @@ private void showQuickStartNoticeIfNecessary() { if (taskToPrompt != null) { mQuickStartSnackBarHandler.removeCallbacksAndMessages(null); - mQuickStartSnackBarHandler.postDelayed(() -> { - if (!isAdded() || getView() == null || !(getActivity() instanceof WPMainActivity)) { - return; - } - - QuickStartNoticeDetails noticeDetails = QuickStartNoticeDetails.getNoticeForTask(taskToPrompt); - if (noticeDetails == null) { - return; - } - - String noticeTitle = getString(noticeDetails.getTitleResId()); - String noticeMessage = getString(noticeDetails.getMessageResId()); - - WPDialogSnackbar quickStartNoticeSnackBar = - WPDialogSnackbar.make( - requireActivity().findViewById(R.id.coordinator), - noticeMessage, - getResources().getInteger(R.integer.quick_start_snackbar_duration_ms)); - - quickStartNoticeSnackBar.setTitle(noticeTitle); + mQuickStartSnackBarHandler.postDelayed(new Runnable() { + @Override + public void run() { + if (!isAdded() || getView() == null || !(getActivity() instanceof WPMainActivity)) { + return; + } - quickStartNoticeSnackBar.setPositiveButton( - getString(R.string.quick_start_button_positive), v -> { - AnalyticsTracker.track(Stat.QUICK_START_TASK_DIALOG_POSITIVE_TAPPED); - mActiveTutorialPrompt = - QuickStartMySitePrompts.getPromptDetailsForTask(taskToPrompt); - showActiveQuickStartTutorial(); - }); + QuickStartNoticeDetails noticeDetails = QuickStartNoticeDetails.getNoticeForTask(taskToPrompt); + if (noticeDetails == null) { + return; + } - quickStartNoticeSnackBar - .setNegativeButton(getString(R.string.quick_start_button_negative), - v -> AnalyticsTracker.track(Stat.QUICK_START_TASK_DIALOG_NEGATIVE_TAPPED)); + String noticeTitle = getString(noticeDetails.getTitleResId()); + String noticeMessage = getString(noticeDetails.getMessageResId()); + + WPDialogSnackbar quickStartNoticeSnackBar = + WPDialogSnackbar.make( + requireActivity().findViewById(R.id.coordinator), + noticeMessage, + getResources().getInteger(R.integer.quick_start_snackbar_duration_ms)); + + quickStartNoticeSnackBar.setTitle(noticeTitle); + + quickStartNoticeSnackBar.setPositiveButton( + getString(R.string.quick_start_button_positive), new OnClickListener() { + @Override + public void onClick(View v) { + AnalyticsTracker.track(Stat.QUICK_START_TASK_DIALOG_POSITIVE_TAPPED); + mActiveTutorialPrompt = + QuickStartMySitePrompts.getPromptDetailsForTask(taskToPrompt); + showActiveQuickStartTutorial(); + } + }); + + quickStartNoticeSnackBar + .setNegativeButton(getString(R.string.quick_start_button_negative), + new OnClickListener() { + @Override + public void onClick(View v) { + AnalyticsTracker.track(Stat.QUICK_START_TASK_DIALOG_NEGATIVE_TAPPED); + } + }); - ((WPMainActivity) requireActivity()).showQuickStartSnackBar(quickStartNoticeSnackBar); + ((WPMainActivity) requireActivity()).showQuickStartSnackBar(quickStartNoticeSnackBar); - AnalyticsTracker.track(Stat.QUICK_START_TASK_DIALOG_VIEWED); - AppPrefs.setQuickStartNoticeRequired(false); + AnalyticsTracker.track(Stat.QUICK_START_TASK_DIALOG_VIEWED); + AppPrefs.setQuickStartNoticeRequired(false); + } }, AUTO_QUICK_START_SNACKBAR_DELAY_MS); } } @@ -371,89 +399,199 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, } private void setupClickListeners(View rootView) { - rootView.findViewById(R.id.site_info_container).setOnClickListener(view -> viewSite()); + rootView.findViewById(R.id.site_info_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + viewSite(); + } + }); - rootView.findViewById(R.id.switch_site).setOnClickListener(v -> showSitePicker()); + rootView.findViewById(R.id.switch_site).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showSitePicker(); + } + }); - rootView.findViewById(R.id.row_view_site).setOnClickListener(v -> viewSite()); + rootView.findViewById(R.id.row_view_site).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewSite(); + } + }); - rootView.findViewById(R.id.row_register_domain).setOnClickListener(v -> registerDomain()); + rootView.findViewById(R.id.row_register_domain).setOnClickListener(new OnClickListener() { + @Override public void onClick(View v) { + registerDomain(); + } + }); - rootView.findViewById(R.id.quick_action_stats_button).setOnClickListener(v -> { - AnalyticsTracker.track(Stat.QUICK_ACTION_STATS_TAPPED); - viewStats(); + rootView.findViewById(R.id.quick_action_stats_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AnalyticsTracker.track(Stat.QUICK_ACTION_STATS_TAPPED); + viewStats(); + } }); - rootView.findViewById(R.id.row_stats).setOnClickListener(v -> viewStats()); + rootView.findViewById(R.id.row_stats).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewStats(); + } + }); - mBlavatarImageView.setOnClickListener(v -> updateBlavatar()); + mBlavatarImageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + updateBlavatar(); + } + }); - mPlanContainer.setOnClickListener(v -> { - completeQuickStarTask(QuickStartTask.EXPLORE_PLANS); - ActivityLauncher.viewBlogPlans(getActivity(), getSelectedSite()); + mPlanContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + completeQuickStarTask(QuickStartTask.EXPLORE_PLANS); + ActivityLauncher.viewBlogPlans(getActivity(), getSelectedSite()); + } }); - rootView.findViewById(R.id.quick_action_posts_button).setOnClickListener(v -> { - AnalyticsTracker.track(Stat.QUICK_ACTION_POSTS_TAPPED); - viewPosts(); + rootView.findViewById(R.id.quick_action_posts_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AnalyticsTracker.track(Stat.QUICK_ACTION_POSTS_TAPPED); + viewPosts(); + } }); - rootView.findViewById(R.id.row_blog_posts).setOnClickListener(v -> viewPosts()); + rootView.findViewById(R.id.row_blog_posts).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewPosts(); + } + }); - rootView.findViewById(R.id.quick_action_media_button).setOnClickListener(v -> { - AnalyticsTracker.track(Stat.QUICK_ACTION_MEDIA_TAPPED); - viewMedia(); + rootView.findViewById(R.id.quick_action_media_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AnalyticsTracker.track(Stat.QUICK_ACTION_MEDIA_TAPPED); + viewMedia(); + } }); - rootView.findViewById(R.id.row_media).setOnClickListener(v -> viewMedia()); + rootView.findViewById(R.id.row_media).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewMedia(); + } + }); - rootView.findViewById(R.id.quick_action_pages_button).setOnClickListener(v -> { - AnalyticsTracker.track(Stat.QUICK_ACTION_PAGES_TAPPED); - viewPages(); + rootView.findViewById(R.id.quick_action_pages_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AnalyticsTracker.track(Stat.QUICK_ACTION_PAGES_TAPPED); + viewPages(); + } }); - mPageView.setOnClickListener(v -> viewPages()); + mPageView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + viewPages(); + } + }); - rootView.findViewById(R.id.row_comments).setOnClickListener( - v -> ActivityLauncher.viewCurrentBlogComments(getActivity(), getSelectedSite())); + rootView.findViewById(R.id.row_comments).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.viewCurrentBlogComments(getActivity(), getSelectedSite()); + } + }); - mThemesContainer.setOnClickListener(v -> { - completeQuickStarTask(QuickStartTask.CHOOSE_THEME); - if (isQuickStartTaskActive(QuickStartTask.CUSTOMIZE_SITE)) { - requestNextStepOfActiveQuickStartTask(); + mThemesContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + completeQuickStarTask(QuickStartTask.CHOOSE_THEME); + if (isQuickStartTaskActive(QuickStartTask.CUSTOMIZE_SITE)) { + requestNextStepOfActiveQuickStartTask(); + } + ActivityLauncher.viewCurrentBlogThemes(getActivity(), getSelectedSite()); } - ActivityLauncher.viewCurrentBlogThemes(getActivity(), getSelectedSite()); }); - mPeopleView.setOnClickListener(v -> ActivityLauncher.viewCurrentBlogPeople(getActivity(), getSelectedSite())); + mPeopleView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.viewCurrentBlogPeople(getActivity(), getSelectedSite()); + } + }); - mPluginsContainer.setOnClickListener( - view -> ActivityLauncher.viewPluginBrowser(getActivity(), getSelectedSite())); + mPluginsContainer.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + ActivityLauncher.viewPluginBrowser(getActivity(), getSelectedSite()); + } + }); - mActivityLogContainer.setOnClickListener( - view -> ActivityLauncher.viewActivityLogList(getActivity(), getSelectedSite())); + mActivityLogContainer.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + ActivityLauncher.viewActivityLogList(getActivity(), getSelectedSite()); + } + }); - mSettingsView.setOnClickListener( - v -> ActivityLauncher.viewBlogSettingsForResult(getActivity(), getSelectedSite())); + mSettingsView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.viewBlogSettingsForResult(getActivity(), getSelectedSite()); + } + }); - mSharingView.setOnClickListener(v -> { - if (isQuickStartTaskActive(QuickStartTask.ENABLE_POST_SHARING)) { - requestNextStepOfActiveQuickStartTask(); + mSharingView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (isQuickStartTaskActive(QuickStartTask.ENABLE_POST_SHARING)) { + requestNextStepOfActiveQuickStartTask(); + } + ActivityLauncher.viewBlogSharing(getActivity(), getSelectedSite()); } - ActivityLauncher.viewBlogSharing(getActivity(), getSelectedSite()); }); - rootView.findViewById(R.id.row_admin).setOnClickListener( - v -> ActivityLauncher.viewBlogAdmin(getActivity(), getSelectedSite())); + rootView.findViewById(R.id.row_admin).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.viewBlogAdmin(getActivity(), getSelectedSite()); + } + }); - mActionableEmptyView.button.setOnClickListener( - v -> SitePickerActivity.addSite(getActivity(), mAccountStore.hasAccessToken())); + mActionableEmptyView.button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + SitePickerActivity.addSite(getActivity(), mAccountStore.hasAccessToken(), + mAccountStore.getAccount().getUserName()); + } + }); - mQuickStartCustomizeView.setOnClickListener(v -> showQuickStartList(CUSTOMIZE)); + mQuickStartCustomizeView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showQuickStartList(CUSTOMIZE); + } + }); - mQuickStartGrowView.setOnClickListener(v -> showQuickStartList(GROW)); + mQuickStartGrowView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showQuickStartList(GROW); + } + }); - mQuickStartMenuButton.setOnClickListener(v -> showQuickStartCardMenu()); + mQuickStartMenuButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + showQuickStartCardMenu(); + } + }); } private void registerDomain() { @@ -587,12 +725,15 @@ private void updateQuickStartContainer() { private void showQuickStartCardMenu() { PopupMenu quickStartPopupMenu = new PopupMenu(requireContext(), mQuickStartMenuButton); - quickStartPopupMenu.setOnMenuItemClickListener(item -> { - if (item.getItemId() == R.id.quick_start_card_menu_remove) { - showRemoveNextStepsDialog(); - return true; + quickStartPopupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + if (item.getItemId() == R.id.quick_start_card_menu_remove) { + showRemoveNextStepsDialog(); + return true; + } + return false; } - return false; }); quickStartPopupMenu.inflate(R.menu.quick_start_card_menu); quickStartPopupMenu.show(); @@ -726,9 +867,12 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { Uri imageUri = Uri.parse(strMediaUri); if (imageUri != null) { boolean didGoWell = WPMediaUtils.fetchMediaAndDoNext(getActivity(), imageUri, - uri -> { - showSiteIconProgressBar(true); - startCropActivity(uri); + new WPMediaUtils.MediaFetchDoNext() { + @Override + public void doNext(Uri uri) { + showSiteIconProgressBar(true); + startCropActivity(uri); + } }); if (!didGoWell) { @@ -742,8 +886,13 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { AnalyticsTracker.track(Stat.MY_SITE_ICON_CROPPED); WPMediaUtils.fetchMediaAndDoNext(getActivity(), UCrop.getOutput(data), - uri -> startSiteIconUpload( - MediaUtils.getRealPathFromURI(getActivity(), uri))); + new WPMediaUtils.MediaFetchDoNext() { + @Override + public void doNext(Uri uri) { + startSiteIconUpload( + MediaUtils.getRealPathFromURI(getActivity(), uri)); + } + }); } else if (resultCode == UCrop.RESULT_ERROR) { AppLog.e(AppLog.T.MAIN, "Image cropping failed!", UCrop.getError(data)); ToastUtils.showToast(getActivity(), R.string.error_cropping_image, Duration.SHORT); @@ -1143,12 +1292,14 @@ public void onNegativeClicked(@NonNull String instanceTag) { @Override public void onNeutralClicked(@NonNull String instanceTag) { - if (TAG_QUICK_START_DIALOG.equals(instanceTag)) { - AppPrefs.setQuickStartDisabled(true); - AnalyticsTracker.track(Stat.QUICK_START_REQUEST_DIALOG_NEUTRAL_TAPPED); - } else { - AppLog.e(T.EDITOR, "Dialog instanceTag '" + instanceTag + "' is not recognized"); - throw new UnsupportedOperationException("Dialog instanceTag is not recognized"); + switch (instanceTag) { + case TAG_QUICK_START_DIALOG: + AppPrefs.setQuickStartDisabled(true); + AnalyticsTracker.track(Stat.QUICK_START_REQUEST_DIALOG_NEUTRAL_TAPPED); + break; + default: + AppLog.e(T.EDITOR, "Dialog instanceTag '" + instanceTag + "' is not recognized"); + throw new UnsupportedOperationException("Dialog instanceTag is not recognized"); } } @@ -1205,7 +1356,6 @@ private void fetchSitePlans(@Nullable SiteModel site) { mDispatcher.dispatch(SiteActionBuilder.newFetchPlansAction(site)); } - @SuppressWarnings("unused") @Subscribe(threadMode = ThreadMode.MAIN) public void onPlansFetched(OnPlansFetched event) { if (AppPrefs.getSelectedSite() != event.site.getId()) { @@ -1258,7 +1408,12 @@ public void run() { // highlight MySite row and scroll to it if (!QuickStartMySitePrompts.isTargetingBottomNavBar(mActiveTutorialPrompt.getTask())) { - mScrollView.post(() -> mScrollView.smoothScrollTo(0, quickStartTarget.getTop())); + mScrollView.post(new Runnable() { + @Override + public void run() { + mScrollView.smoothScrollTo(0, quickStartTarget.getTop()); + } + }); } } }; @@ -1275,10 +1430,10 @@ private void removeQuickStartFocusPoint() { return; } getView().removeCallbacks(mAddQuickStartFocusPointTask); - QuickStartUtils.removeQuickStartFocusPoint(requireActivity().findViewById(R.id.root_view_main)); + QuickStartUtils.removeQuickStartFocusPoint((ViewGroup) requireActivity().findViewById(R.id.root_view_main)); } - boolean isQuickStartTaskActive(QuickStartTask task) { + public boolean isQuickStartTaskActive(QuickStartTask task) { return hasActiveQuickStartTask() && mActiveTutorialPrompt.getTask() == task; } @@ -1319,7 +1474,7 @@ private void clearActiveQuickStart() { mQuickStartSnackBarHandler.removeCallbacksAndMessages(null); } - void requestNextStepOfActiveQuickStartTask() { + public void requestNextStepOfActiveQuickStartTask() { if (!hasActiveQuickStartTask()) { return; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 31813d0347e0..324132345d4f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -1,24 +1,31 @@ package org.wordpress.android.ui.main; import android.app.Activity; +import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; +import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.inputmethod.InputMethodManager; import android.widget.ArrayAdapter; +import android.widget.SearchView; import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.view.ActionMode; -import androidx.appcompat.widget.SearchView; -import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.DefaultItemAnimator; import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import com.android.volley.VolleyError; +import com.wordpress.rest.RestRequest; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -37,21 +44,21 @@ import org.wordpress.android.ui.ActionableEmptyView; import org.wordpress.android.ui.ActivityId; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.main.SitePickerAdapter.SiteList; import org.wordpress.android.ui.main.SitePickerAdapter.SiteRecord; import org.wordpress.android.ui.prefs.AppPrefs; -import org.wordpress.android.ui.prefs.EmptyViewRecyclerView; import org.wordpress.android.util.AccessibilityUtils; import org.wordpress.android.util.ActivityUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.DeviceUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.helpers.Debouncer; import org.wordpress.android.util.helpers.SwipeToRefreshHelper; +import org.wordpress.android.util.widgets.CustomSwipeRefreshLayout; import org.wordpress.android.widgets.WPDialogSnackbar; import java.util.ArrayList; @@ -64,7 +71,7 @@ import static org.wordpress.android.util.WPSwipeToRefreshHelper.buildSwipeToRefreshHelper; -public class SitePickerActivity extends LocaleAwareActivity +public class SitePickerActivity extends AppCompatActivity implements SitePickerAdapter.OnSiteClickListener, SitePickerAdapter.OnSelectedCountChangedListener, SearchView.OnQueryTextListener { @@ -74,8 +81,9 @@ public class SitePickerActivity extends LocaleAwareActivity private static final String KEY_LAST_SEARCH = "last_search"; private static final String KEY_REFRESHING = "refreshing_sites"; + private ActionableEmptyView mActionableEmptyView; private SitePickerAdapter mAdapter; - private EmptyViewRecyclerView mRecycleView; + private RecyclerView mRecycleView; private SwipeToRefreshHelper mSwipeToRefreshHelper; private ActionMode mActionMode; private MenuItem mMenuEdit; @@ -90,6 +98,11 @@ public class SitePickerActivity extends LocaleAwareActivity @Inject Dispatcher mDispatcher; @Inject StatsStore mStatsStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -99,6 +112,7 @@ public void onCreate(Bundle savedInstanceState) { restoreSavedInstanceState(savedInstanceState); setupActionBar(); setupRecycleView(); + setupEmptyView(); initSwipeToRefreshHelper(findViewById(android.R.id.content)); if (savedInstanceState != null) { @@ -166,8 +180,12 @@ public boolean onOptionsItemSelected(final MenuItem item) { } else if (itemId == R.id.menu_edit) { startEditingVisibility(); return true; + } else if (itemId == R.id.menu_search) { + mSearchView.requestFocus(); + showSoftKeyboard(); + return true; } else if (itemId == R.id.menu_add) { - addSite(this, mAccountStore.hasAccessToken()); + addSite(this, mAccountStore.hasAccessToken(), mAccountStore.getAccount().getUserName()); return true; } return super.onOptionsItemSelected(item); @@ -242,9 +260,12 @@ public void onSiteChanged(OnSiteChanged event) { } private void debounceLoadSites() { - mDebouncer.debounce(Void.class, () -> { - if (!isFinishing()) { - getAdapter().loadSites(); + mDebouncer.debounce(Void.class, new Runnable() { + @Override + public void run() { + if (!isFinishing()) { + getAdapter().loadSites(); + } } }, 200, TimeUnit.MILLISECONDS); } @@ -254,16 +275,19 @@ private void initSwipeToRefreshHelper(View view) { return; } mSwipeToRefreshHelper = buildSwipeToRefreshHelper( - view.findViewById(R.id.ptr_layout), - () -> { - if (isFinishing()) { - return; - } - if (!NetworkUtils.checkConnection(SitePickerActivity.this) || !mAccountStore.hasAccessToken()) { - mSwipeToRefreshHelper.setRefreshing(false); - return; + (CustomSwipeRefreshLayout) view.findViewById(R.id.ptr_layout), + new SwipeToRefreshHelper.RefreshListener() { + @Override + public void onRefreshStarted() { + if (isFinishing()) { + return; + } + if (!NetworkUtils.checkConnection(SitePickerActivity.this) || !mAccountStore.hasAccessToken()) { + mSwipeToRefreshHelper.setRefreshing(false); + return; + } + mDispatcher.dispatch(SiteActionBuilder.newFetchSitesAction()); } - mDispatcher.dispatch(SiteActionBuilder.newFetchSitesAction()); } ); } @@ -274,10 +298,11 @@ private void setupRecycleView() { mRecycleView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY); mRecycleView.setItemAnimator(null); mRecycleView.setAdapter(getAdapter()); + } - ActionableEmptyView actionableEmptyView = findViewById(R.id.actionable_empty_view); - actionableEmptyView.updateLayoutForSearch(true, 0); - mRecycleView.setEmptyView(actionableEmptyView); + private void setupEmptyView() { + mActionableEmptyView = findViewById(R.id.actionable_empty_view); + mActionableEmptyView.updateLayoutForSearch(true, 0); } private void restoreSavedInstanceState(Bundle savedInstanceState) { @@ -296,8 +321,6 @@ private void restoreSavedInstanceState(Bundle savedInstanceState) { } private void setupActionBar() { - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeAsUpIndicator(R.drawable.ic_cross_white_24dp); @@ -379,8 +402,8 @@ private void saveSitesVisibility(Set changeSet) { if (skippedCurrentSite) { String cantHideCurrentSite = getString(R.string.site_picker_cant_hide_current_site); ToastUtils.showToast(this, - String.format(cantHideCurrentSite, currentSiteName), - ToastUtils.Duration.LONG); + String.format(cantHideCurrentSite, currentSiteName), + ToastUtils.Duration.LONG); } } @@ -403,10 +426,17 @@ private void updateVisibilityOfSitesOnRemote(List siteList) { return; } - WordPress.getRestClientUtilsV1_1().post("me/sites", jsonObject, null, - response -> AppLog.v(AppLog.T.API, "Site visibility successfully updated"), - volleyError -> AppLog - .e(AppLog.T.API, "An error occurred while updating site visibility: " + volleyError)); + WordPress.getRestClientUtilsV1_1().post("me/sites", jsonObject, null, new RestRequest.Listener() { + @Override + public void onResponse(JSONObject response) { + AppLog.v(AppLog.T.API, "Site visibility successfully updated"); + } + }, new RestRequest.ErrorListener() { + @Override + public void onErrorResponse(VolleyError volleyError) { + AppLog.e(AppLog.T.API, "An error occurred while updating site visibility: " + volleyError); + } + }); } private void updateActionModeTitle() { @@ -419,26 +449,22 @@ private void updateActionModeTitle() { private void setupSearchView() { mSearchView = (SearchView) mMenuSearch.getActionView(); + mSearchView.setIconifiedByDefault(false); + mSearchView.setIconified(false); + mSearchView.setOnQueryTextListener(this); mSearchView.setMaxWidth(Integer.MAX_VALUE); mMenuSearch.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { - if (!getAdapter().getIsInSearchMode()) { - enableSearchMode(); - mMenuEdit.setVisible(false); - mMenuAdd.setVisible(false); - - mSearchView.setOnQueryTextListener(SitePickerActivity.this); - } - + enableSearchMode(); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { + mActionableEmptyView.setVisibility(View.GONE); disableSearchMode(); - mSearchView.setOnQueryTextListener(null); return true; } }); @@ -449,14 +475,14 @@ public boolean onMenuItemActionCollapse(MenuItem item) { private void setQueryIfInSearch() { if (getAdapter().getIsInSearchMode()) { mMenuSearch.expandActionView(); - mSearchView.setOnQueryTextListener(SitePickerActivity.this); - mSearchView.setQuery(getAdapter().getLastSearch(), true); + mSearchView.setQuery(getAdapter().getLastSearch(), false); } } private void enableSearchMode() { setIsInSearchModeAndSetNewAdapter(true); mRecycleView.swapAdapter(getAdapter(), true); + invalidateOptionsMenu(); } private void disableSearchMode() { @@ -472,6 +498,13 @@ private void hideSoftKeyboard() { } } + private void showSoftKeyboard() { + if (!DeviceUtils.getInstance().hasHardwareKeyboard(this)) { + InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS); + } + } + @Override public void onSelectedCountChanged(int numSelected) { if (mActionMode != null) { @@ -520,13 +553,16 @@ public boolean onQueryTextSubmit(String s) { @Override public boolean onQueryTextChange(String s) { - if (getAdapter().getIsInSearchMode()) { - getAdapter().setLastSearch(s); - getAdapter().searchSites(s); - } + getAdapter().setLastSearch(s); + getAdapter().searchSites(s); + updateEmptyViewVisibility(); return true; } + private void updateEmptyViewVisibility() { + mActionableEmptyView.setVisibility(getAdapter().getItemCount() > 0 ? View.GONE : View.VISIBLE); + } + public void showProgress(boolean show) { findViewById(R.id.progress).setVisibility(show ? View.VISIBLE : View.GONE); } @@ -593,7 +629,7 @@ public void onDestroyActionMode(ActionMode actionMode) { } } - public static void addSite(Activity activity, boolean isSignedInWpCom) { + public static void addSite(Activity activity, boolean isSignedInWpCom, String username) { // if user is signed into wp.com use the dialog to enable choosing whether to // create a new wp.com blog or add a self-hosted one if (isSignedInWpCom) { @@ -618,15 +654,19 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { CharSequence[] items = {getString(R.string.site_picker_create_wpcom), getString(R.string.site_picker_add_self_hosted)}; - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(R.string.site_picker_add_site); builder.setAdapter( new ArrayAdapter<>(getActivity(), R.layout.add_new_site_dialog_item, R.id.text, items), - (dialog, which) -> { - if (which == 0) { - ActivityLauncher.newBlogForResult(getActivity()); - } else { - ActivityLauncher.addSelfHostedSiteForResult(getActivity()); + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == 0) { + ActivityLauncher.newBlogForResult(getActivity()); + } else { + ActivityLauncher.addSelfHostedSiteForResult(getActivity()); + } } }); return builder.create(); @@ -640,11 +680,15 @@ private void startEditingVisibility() { } private void showRemoveSelfHostedSiteDialog(@NonNull final SiteModel site) { - MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( + new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)); dialogBuilder.setTitle(getResources().getText(R.string.remove_account)); dialogBuilder.setMessage(getResources().getText(R.string.sure_to_remove_account)); - dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), - (dialog, whichButton) -> mDispatcher.dispatch(SiteActionBuilder.newRemoveSiteAction(site))); + dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + mDispatcher.dispatch(SiteActionBuilder.newRemoveSiteAction(site)); + } + }); dialogBuilder.setNegativeButton(getResources().getText(R.string.no), null); dialogBuilder.setCancelable(false); dialogBuilder.create().show(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerAdapter.java index db937b631ce7..f7d0934296c3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerAdapter.java @@ -2,11 +2,13 @@ import android.content.Context; import android.graphics.Typeface; +import android.graphics.drawable.ColorDrawable; +import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.text.TextUtils; -import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; +import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.RadioButton; @@ -14,7 +16,6 @@ import androidx.annotation.LayoutRes; import androidx.annotation.NonNull; -import androidx.core.graphics.ColorUtils; import androidx.recyclerview.widget.RecyclerView; import org.wordpress.android.R; @@ -33,6 +34,7 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Locale; @@ -63,6 +65,8 @@ RecyclerView.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, ViewGr void onBindViewHolder(RecyclerView.ViewHolder holder, SiteList sites); } + private final int mTextColorNormal; + private final int mTextColorHidden; private final @LayoutRes int mItemLayoutReourceId; private static int mBlavatarSz; @@ -70,9 +74,7 @@ RecyclerView.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, ViewGr private SiteList mSites = new SiteList(); private final int mCurrentLocalId; - private final int mSelectedItemBackground; - - private final float mDisabledSiteOpacity; + private final Drawable mSelectedItemBackground; private final LayoutInflater mInflater; private final HashSet mSelectedPositions = new HashSet<>(); @@ -131,7 +133,7 @@ public SitePickerAdapter(Context context, boolean isInSearchMode, OnDataLoadedListener dataLoadedListener) { this(context, itemLayoutResourceId, currentLocalBlogId, lastSearch, isInSearchMode, dataLoadedListener, null, - null); + null); } public SitePickerAdapter(Context context, @@ -156,13 +158,11 @@ public SitePickerAdapter(Context context, mDataLoadedListener = dataLoadedListener; mBlavatarSz = context.getResources().getDimensionPixelSize(R.dimen.blavatar_sz); + mTextColorNormal = ContextExtensionsKt.getColorFromAttribute(context, R.attr.wpColorText); + mTextColorHidden = context.getResources().getColor(R.color.neutral_30); - TypedValue disabledAlpha = new TypedValue(); - context.getResources().getValue(R.dimen.material_emphasis_disabled, disabledAlpha, true); - mDisabledSiteOpacity = disabledAlpha.getFloat(); - mSelectedItemBackground = ColorUtils - .setAlphaComponent(ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorOnSurface), - context.getResources().getInteger(R.integer.selected_list_item_opacity)); + mSelectedItemBackground = + new ColorDrawable(context.getResources().getColor(R.color.gray_5)); mHeaderHandler = headerHandler; mSelectedItemPos = getPositionOffset(); @@ -177,7 +177,7 @@ public int getItemCount() { return (mHeaderHandler != null ? 1 : 0) + mSites.size(); } - private int getSitesCount() { + public int getSitesCount() { return mSites.size(); } @@ -211,7 +211,7 @@ void setOnSelectedCountChangedListener(OnSelectedCountChangedListener listener) mSelectedCountListener = listener; } - void setOnSiteClickListener(OnSiteClickListener listener) { + public void setOnSiteClickListener(OnSiteClickListener listener) { mSiteSelectedListener = listener; notifyDataSetChanged(); } @@ -243,10 +243,9 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, holder.mTxtDomain.setText(site.mHomeURL); mImageManager.load(holder.mImgBlavatar, ImageType.BLAVATAR, site.mBlavatarUrl); - if ((site.mLocalId == mCurrentLocalId && !mIsMultiSelectEnabled) || (mIsMultiSelectEnabled && isItemSelected(position))) { - holder.mLayoutContainer.setBackgroundColor(mSelectedItemBackground); + holder.mLayoutContainer.setBackground(mSelectedItemBackground); } else { holder.mLayoutContainer.setBackground(null); } @@ -254,10 +253,10 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder viewHolder, // different styling for visible/hidden sites if (holder.mIsSiteHidden == null || holder.mIsSiteHidden != site.mIsHidden) { holder.mIsSiteHidden = site.mIsHidden; - holder.mTxtTitle.setAlpha(site.mIsHidden ? mDisabledSiteOpacity : 1f); + holder.mTxtTitle.setTextColor(site.mIsHidden ? mTextColorHidden : mTextColorNormal); holder.mTxtTitle .setTypeface(holder.mTxtTitle.getTypeface(), site.mIsHidden ? Typeface.NORMAL : Typeface.BOLD); - holder.mImgBlavatar.setAlpha(site.mIsHidden ? mDisabledSiteOpacity : 1f); + holder.mImgBlavatar.setAlpha(site.mIsHidden ? 0.5f : 1f); } if (holder.mDivider != null) { @@ -270,32 +269,38 @@ && position < getItemCount() - 1 } if (mIsMultiSelectEnabled || mSiteSelectedListener != null) { - holder.itemView.setOnClickListener(view -> { - int clickedPosition = holder.getAdapterPosition(); - if (isValidPosition(clickedPosition)) { - if (mIsMultiSelectEnabled) { - toggleSelection(clickedPosition); - } else if (mSiteSelectedListener != null) { - mSiteSelectedListener.onSiteClick(getItem(clickedPosition)); + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int clickedPosition = holder.getAdapterPosition(); + if (isValidPosition(clickedPosition)) { + if (mIsMultiSelectEnabled) { + toggleSelection(clickedPosition); + } else if (mSiteSelectedListener != null) { + mSiteSelectedListener.onSiteClick(getItem(clickedPosition)); + } + } else { + AppLog.w(AppLog.T.MAIN, "site picker > invalid clicked position " + clickedPosition); } - } else { - AppLog.w(AppLog.T.MAIN, "site picker > invalid clicked position " + clickedPosition); } }); - holder.itemView.setOnLongClickListener(view -> { - int clickedPosition = holder.getAdapterPosition(); - if (isValidPosition(clickedPosition)) { - if (mIsMultiSelectEnabled) { - toggleSelection(clickedPosition); - return true; - } else if (mSiteSelectedListener != null) { - return mSiteSelectedListener.onSiteLongClick(getItem(clickedPosition)); + holder.itemView.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View view) { + int clickedPosition = holder.getAdapterPosition(); + if (isValidPosition(clickedPosition)) { + if (mIsMultiSelectEnabled) { + toggleSelection(clickedPosition); + return true; + } else if (mSiteSelectedListener != null) { + return mSiteSelectedListener.onSiteLongClick(getItem(clickedPosition)); + } + } else { + AppLog.w(AppLog.T.MAIN, "site picker > invalid clicked position " + clickedPosition); } - } else { - AppLog.w(AppLog.T.MAIN, "site picker > invalid clicked position " + clickedPosition); + return false; } - return false; }); ViewUtilsKt.redirectContextClickToLongPressListener(holder.itemView); } @@ -306,7 +311,12 @@ && position < getItemCount() - 1 } else { holder.mSelectedRadioButton.setVisibility(View.VISIBLE); holder.mSelectedRadioButton.setChecked(mSelectedItemPos == position); - holder.mLayoutContainer.setOnClickListener(v -> selectSingleItem(holder.getAdapterPosition())); + holder.mLayoutContainer.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + selectSingleItem(holder.getAdapterPosition()); + } + }); } } else { if (holder.mSelectedRadioButton != null) { @@ -341,19 +351,19 @@ public int getSelectedItemLocalId() { return mSites.size() != 0 ? getItem(mSelectedItemPos).mLocalId : -1; } - String getLastSearch() { + public String getLastSearch() { return mLastSearch; } - void setLastSearch(String lastSearch) { + public void setLastSearch(String lastSearch) { mLastSearch = lastSearch; } - boolean getIsInSearchMode() { + public boolean getIsInSearchMode() { return mIsInSearchMode; } - void searchSites(String searchText) { + public void searchSites(String searchText) { mLastSearch = searchText; mSites = filteredSitesByText(mAllSites); @@ -520,7 +530,7 @@ Set setVisibilityForSelectedSites(boolean makeVisible) { return changeSet; } - void loadSites() { + public void loadSites() { new LoadSitesTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @@ -590,15 +600,17 @@ protected SiteList[] doInBackground(Void... params) { // sort primary blog to the top, otherwise sort by blog/host final long primaryBlogId = mAccountStore.getAccount().getPrimarySiteId(); - Collections.sort(sites, (site1, site2) -> { - if (primaryBlogId > 0 && !mIsInSearchMode) { - if (site1.mSiteId == primaryBlogId) { - return -1; - } else if (site2.mSiteId == primaryBlogId) { - return 1; + Collections.sort(sites, new Comparator() { + public int compare(SiteRecord site1, SiteRecord site2) { + if (primaryBlogId > 0 && !mIsInSearchMode) { + if (site1.mSiteId == primaryBlogId) { + return -1; + } else if (site2.mSiteId == primaryBlogId) { + return 1; + } } + return site1.getBlogNameOrHomeURL().compareToIgnoreCase(site2.getBlogNameOrHomeURL()); } - return site1.getBlogNameOrHomeURL().compareToIgnoreCase(site2.getBlogNameOrHomeURL()); }); // flag recently-picked sites and move them to the top if there are enough sites and @@ -669,7 +681,7 @@ public static class SiteRecord { private boolean mIsHidden; private boolean mIsRecentPick; - SiteRecord(SiteModel siteModel) { + public SiteRecord(SiteModel siteModel) { mLocalId = siteModel.getId(); mSiteId = siteModel.getSiteId(); mBlogName = SiteUtils.getSiteNameOrHomeURL(siteModel); @@ -678,7 +690,7 @@ public static class SiteRecord { mIsHidden = !siteModel.isVisible(); } - String getBlogNameOrHomeURL() { + public String getBlogNameOrHomeURL() { if (TextUtils.isEmpty(mBlogName)) { return mHomeURL; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index 20ef3909dcdf..0fbadc488d94 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -2,13 +2,13 @@ import android.app.Activity; import android.app.Dialog; +import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.os.Looper; import android.text.TextUtils; import android.view.HapticFeedbackConstants; import android.view.View; @@ -18,6 +18,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.RemoteInput; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -71,7 +72,6 @@ import org.wordpress.android.ui.ActivityLauncher; import org.wordpress.android.ui.JetpackConnectionSource; import org.wordpress.android.ui.JetpackConnectionWebViewActivity; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.PagePostCreationSourcesDetail; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.ShortcutsNavigator; @@ -109,6 +109,7 @@ import org.wordpress.android.util.AuthenticationDialogUtils; import org.wordpress.android.util.DeviceUtils; import org.wordpress.android.util.FluxCUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ProfilingUtils; import org.wordpress.android.util.QuickStartUtils; @@ -136,7 +137,7 @@ /** * Main activity which hosts sites, reader, me and notifications pages */ -public class WPMainActivity extends LocaleAwareActivity implements +public class WPMainActivity extends AppCompatActivity implements OnPageListener, BottomNavController, BasicDialogPositiveClickInterface, @@ -207,6 +208,11 @@ public interface OnActivityBackPressedListener { boolean onActivityBackPressed(); } + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { ProfilingUtils.split("WPMainActivity.onCreate"); @@ -991,9 +997,7 @@ private void showQuickStartDialog() { private void appLanguageChanged() { // Recreate this activity (much like a configuration change) - // We need to post this call to UI thread, since it's called from onActivityResult and the call interferes with - // onResume that is called right afterwards. - new Handler(Looper.getMainLooper()).post(this::recreate); + recreate(); // When language changed we need to reset the shared prefs reader tag since if we have it stored // it's fields can be in a different language and we can get odd behaviors since we will generally fail diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainNavigationView.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainNavigationView.kt index 8c4f3260e5b4..edf6dccd1c20 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainNavigationView.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainNavigationView.kt @@ -11,7 +11,7 @@ import android.widget.TextView import androidx.annotation.DrawableRes import androidx.annotation.IdRes import androidx.annotation.StringRes -import androidx.core.content.res.ResourcesCompat +import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import com.google.android.material.bottomnavigation.BottomNavigationItemView @@ -30,7 +30,6 @@ import org.wordpress.android.ui.prefs.AppPrefs import org.wordpress.android.ui.reader.ReaderPostListFragment import org.wordpress.android.util.AniUtils import org.wordpress.android.util.AniUtils.Duration -import org.wordpress.android.util.getColorStateListFromAttribute /* * Bottom navigation view and related adapter used by the main activity for the @@ -47,10 +46,6 @@ class WPMainNavigationView @JvmOverloads constructor( private lateinit var fragmentManager: FragmentManager private lateinit var pageListener: OnPageListener private var prevPosition = -1 - private val unselectedButtonAlpha = ResourcesCompat.getFloat( - resources, - R.dimen.material_emphasis_disabled - ) private var currentPosition: Int get() = getPositionForItemId(selectedItemId) @@ -177,17 +172,12 @@ class WPMainNavigationView @JvmOverloads constructor( } private fun setImageViewSelected(position: Int, isSelected: Boolean) { - getImageViewForPosition(position)?.let { - it.isSelected = isSelected - it.alpha = if (isSelected) 1f else unselectedButtonAlpha - } + getImageViewForPosition(position)?.isSelected = isSelected } private fun setTitleViewSelected(position: Int, isSelected: Boolean) { getTitleViewForPosition(position)?.setTextColor( - context.getColorStateListFromAttribute( - if (isSelected) R.attr.colorPrimary else R.attr.wpColorOnSurfaceMedium - ) + ContextCompat.getColor(context, if (isSelected) R.color.primary_40 else R.color.neutral_20) ) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java index 112d828464df..5d663ee8d1de 100755 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java @@ -28,9 +28,12 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.view.ActionMode; import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView.OnQueryTextListener; +import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; import androidx.core.view.MenuItemCompat; import androidx.core.view.ViewCompat; import androidx.fragment.app.FragmentManager; @@ -42,7 +45,6 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.BuildConfig; import org.wordpress.android.R; import org.wordpress.android.WordPress; @@ -61,7 +63,6 @@ import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged; import org.wordpress.android.ui.ActivityId; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.media.MediaGridFragment.MediaFilter; import org.wordpress.android.ui.media.MediaGridFragment.MediaGridListener; @@ -75,6 +76,7 @@ import org.wordpress.android.util.FluxCUtils; import org.wordpress.android.util.FormatUtils; import org.wordpress.android.util.ListUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.MediaUtils; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.PermissionUtils; @@ -96,7 +98,7 @@ /** * The main activity in which the user can browse their media. */ -public class MediaBrowserActivity extends LocaleAwareActivity implements MediaGridListener, +public class MediaBrowserActivity extends AppCompatActivity implements MediaGridListener, OnQueryTextListener, OnActionExpandListener, WPMediaUtils.LaunchCameraCallback { public static final String ARG_BROWSER_TYPE = "media_browser_type"; @@ -137,6 +139,11 @@ private enum AddMenuItem { ITEM_CHOOSE_STOCK_MEDIA } + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -167,13 +174,13 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.media_browser_activity); - setSupportActionBar(findViewById(R.id.toolbar_main)); + setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setTitle(R.string.wp_media_title); } + actionBar.setTitle(R.string.wp_media_title); FragmentManager fm = getSupportFragmentManager(); fm.addOnBackStackChangedListener(mOnBackStackChangedListener); @@ -181,7 +188,7 @@ public void onCreate(Bundle savedInstanceState) { // if media was shared add it to the library handleSharedMedia(); - mTabLayout = findViewById(R.id.tab_layout); + mTabLayout = (TabLayout) findViewById(R.id.tab_layout); setupTabs(); MediaFilter filter; @@ -277,6 +284,10 @@ private void enableTabs(boolean enable) { private void setupTabs() { if (shouldShowTabs()) { + int normalColor = ContextCompat.getColor(this, R.color.primary_30); + int selectedColor = ContextCompat.getColor(this, android.R.color.white); + mTabLayout.setTabTextColors(normalColor, selectedColor); + mTabLayout.removeAllTabs(); mTabLayout.addTab(mTabLayout.newTab().setText(R.string.media_all)); // FILTER_ALL mTabLayout.addTab(mTabLayout.newTab().setText(R.string.media_images)); // FILTER_IMAGES @@ -396,7 +407,7 @@ protected void onDestroy() { } @Override - protected void onSaveInstanceState(@NotNull Bundle outState) { + protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(SAVED_QUERY, mQuery); @@ -412,8 +423,12 @@ protected void onSaveInstanceState(@NotNull Bundle outState) { private void getMediaFromDeviceAndTrack(Uri imageUri, int requestCode) { final String mimeType = getContentResolver().getType(imageUri); - WPMediaUtils.fetchMediaAndDoNext(this, imageUri, - uri -> queueFileForUpload(getOptimizedPictureIfNecessary(uri), mimeType)); + WPMediaUtils.fetchMediaAndDoNext(this, imageUri, new WPMediaUtils.MediaFetchDoNext() { + @Override + public void doNext(Uri uri) { + queueFileForUpload(getOptimizedPictureIfNecessary(uri), mimeType); + } + }); trackAddMediaFromDeviceEvents( false, requestCode == RequestCodes.VIDEO_LIBRARY, @@ -786,15 +801,24 @@ private void uploadList(List uriList) { for (Uri uri : uriList) { if (uri != null) { WPMediaUtils.fetchMediaAndDoNext(this, uri, - downloadedUri -> queueFileForUpload( - getOptimizedPictureIfNecessary(downloadedUri), - getContentResolver().getType(downloadedUri))); + new WPMediaUtils.MediaFetchDoNext() { + @Override + public void doNext(Uri downloadedUri) { + queueFileForUpload( + getOptimizedPictureIfNecessary(downloadedUri), + getContentResolver().getType(downloadedUri)); + } + }); } } } - private final OnBackStackChangedListener mOnBackStackChangedListener = - () -> ActivityUtils.hideKeyboard(MediaBrowserActivity.this); + private final OnBackStackChangedListener mOnBackStackChangedListener = new OnBackStackChangedListener() { + @Override + public void onBackStackChanged() { + ActivityUtils.hideKeyboard(MediaBrowserActivity.this); + } + }; private void doBindDeleteService(Intent intent) { mDeleteServiceBound = bindService(intent, mDeleteConnection, @@ -837,38 +861,53 @@ public void showAddMediaPopup() { PopupMenu popup = new PopupMenu(this, anchor); popup.getMenu().add(R.string.photo_picker_capture_photo).setOnMenuItemClickListener( - item -> { - doAddMediaItemClicked(AddMenuItem.ITEM_CAPTURE_PHOTO); - return true; + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + doAddMediaItemClicked(AddMenuItem.ITEM_CAPTURE_PHOTO); + return true; + } }); if (!mBrowserType.isSingleImagePicker()) { popup.getMenu().add(R.string.photo_picker_capture_video).setOnMenuItemClickListener( - item -> { - doAddMediaItemClicked(AddMenuItem.ITEM_CAPTURE_VIDEO); - return true; + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + doAddMediaItemClicked(AddMenuItem.ITEM_CAPTURE_VIDEO); + return true; + } }); } popup.getMenu().add(R.string.photo_picker_choose_photo).setOnMenuItemClickListener( - item -> { - doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_PHOTO); - return true; + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_PHOTO); + return true; + } }); if (!mBrowserType.isSingleImagePicker()) { popup.getMenu().add(R.string.photo_picker_choose_video).setOnMenuItemClickListener( - item -> { - doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_VIDEO); - return true; + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_VIDEO); + return true; + } }); } if (mBrowserType.isBrowser() && mSite.isUsingWpComRestApi()) { popup.getMenu().add(R.string.photo_picker_stock_media).setOnMenuItemClickListener( - item -> { - doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_STOCK_MEDIA); - return true; + new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_STOCK_MEDIA); + return true; + } }); } @@ -975,7 +1014,7 @@ private void handleSharedMedia() { multiStream = intent.getParcelableArrayListExtra((Intent.EXTRA_STREAM)); } else if (Intent.ACTION_SEND.equals(intent.getAction())) { multiStream = new ArrayList<>(); - multiStream.add(intent.getParcelableExtra(Intent.EXTRA_STREAM)); + multiStream.add((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM)); } else { multiStream = null; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java index e89e0de3f8d7..82878aa141a4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java @@ -16,6 +16,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityOptionsCompat; @@ -32,9 +33,9 @@ import org.wordpress.android.fluxc.model.MediaModel; import org.wordpress.android.fluxc.model.SiteModel; import org.wordpress.android.fluxc.store.MediaStore; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.widgets.WPViewPagerTransformer; import org.wordpress.android.widgets.WPViewPagerTransformer.TransformType; @@ -43,7 +44,8 @@ import javax.inject.Inject; -public class MediaPreviewActivity extends LocaleAwareActivity implements MediaPreviewFragment.OnMediaTappedListener { + +public class MediaPreviewActivity extends AppCompatActivity implements MediaPreviewFragment.OnMediaTappedListener { private static final String ARG_ID_OR_URL_LIST = "id_list"; private static final String ARG_PREVIEW_TYPE = "preview_type"; @@ -165,6 +167,11 @@ private static void startIntent(Context context, Intent intent) { ActivityCompat.startActivity(context, intent, options.toBundle()); } + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java index 71618bf43133..473a2268734c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java @@ -2,12 +2,14 @@ import android.Manifest; import android.app.Activity; +import android.app.AlertDialog; import android.app.DownloadManager; import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.database.Cursor; @@ -19,10 +21,12 @@ import android.os.Handler; import android.text.TextUtils; import android.text.format.DateUtils; +import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.CheckBox; @@ -40,15 +44,13 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.content.res.AppCompatResources; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityOptionsCompat; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.elevation.ElevationOverlayProvider; import com.google.android.material.floatingactionbutton.FloatingActionButton; import org.greenrobot.eventbus.EventBus; @@ -66,18 +68,17 @@ import org.wordpress.android.fluxc.store.MediaStore; import org.wordpress.android.fluxc.store.MediaStore.MediaPayload; import org.wordpress.android.fluxc.store.MediaStore.OnMediaChanged; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.media.MediaPreviewActivity.MediaPreviewSwiped; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; import org.wordpress.android.util.ColorUtils; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.DateTimeUtils; import org.wordpress.android.util.DisplayUtils; import org.wordpress.android.util.EditTextUtils; import org.wordpress.android.util.ImageUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.MediaUtils; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.PermissionUtils; @@ -102,7 +103,7 @@ import static org.wordpress.android.editor.EditorImageMetaData.ARG_EDITOR_IMAGE_METADATA; -public class MediaSettingsActivity extends LocaleAwareActivity +public class MediaSettingsActivity extends AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCallback { private static final String ARG_MEDIA_LOCAL_ID = "media_local_id"; private static final String ARG_ID_LIST = "id_list"; @@ -206,6 +207,11 @@ public static void showForResult(@NonNull Activity activity, ActivityCompat.startActivityForResult(activity, intent, RequestCodes.MEDIA_SETTINGS, options.toBundle()); } + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -213,7 +219,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { setContentView(R.layout.media_settings_activity); - setSupportActionBar(findViewById(R.id.toolbar)); + setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(false); @@ -263,19 +269,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { // only show title when toolbar is collapsed final CollapsingToolbarLayout collapsingToolbar = findViewById(R.id.collapsing_toolbar); AppBarLayout appBarLayout = findViewById(R.id.app_bar_layout); - collapsingToolbar.setCollapsedTitleTextColor( - AppCompatResources.getColorStateList(this, - ContextExtensionsKt.getColorResIdFromAttribute(this, R.attr.colorOnPrimarySurface))); - - ElevationOverlayProvider elevationOverlayProvider = new ElevationOverlayProvider(this); - - float appbarElevation = getResources().getDimension(R.dimen.appbar_elevation); - int elevatedColor = elevationOverlayProvider - .compositeOverlayIfNeeded(ContextExtensionsKt.getColorFromAttribute(this, R.attr.wpColorAppBar), - appbarElevation); - - collapsingToolbar.setContentScrimColor(elevatedColor); - appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { int mScrollRange = -1; @@ -312,17 +305,24 @@ public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { // tap to show full screen view (not supported for documents) if (!isDocument()) { - View.OnClickListener listener = v -> showFullScreen(); + View.OnClickListener listener = new View.OnClickListener() { + @Override + public void onClick(View v) { + showFullScreen(); + } + }; mImageView.setOnClickListener(listener); mImagePlay.setOnClickListener(listener); mFabView.setOnClickListener(listener); - mFabView.setOnLongClickListener(view -> { - if (view.isHapticFeedbackEnabled()) { - view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - } + mFabView.setOnLongClickListener(new OnLongClickListener() { + @Override public boolean onLongClick(View view) { + if (view.isHapticFeedbackEnabled()) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } - Toast.makeText(view.getContext(), R.string.button_preview, Toast.LENGTH_SHORT).show(); - return true; + Toast.makeText(view.getContext(), R.string.button_preview, Toast.LENGTH_SHORT).show(); + return true; + } }); ViewUtilsKt.redirectContextClickToLongPressListener(mFabView); } @@ -414,9 +414,12 @@ protected void onResume() { super.onResume(); long delayMs = getResources().getInteger(R.integer.fab_animation_delay); - new Handler().postDelayed(() -> { - if (!isFinishing() && shouldShowFab()) { - showFab(); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + if (!isFinishing() && shouldShowFab()) { + showFab(); + } } }, delayMs); @@ -427,7 +430,7 @@ protected void onResume() { } @Override - protected void onSaveInstanceState(@NotNull Bundle outState) { + protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(ARG_MEDIA_LOCAL_ID, mMedia.getId()); outState.putParcelable(ARG_EDITOR_IMAGE_METADATA, mEditorImageMetaData); @@ -475,7 +478,12 @@ protected void onDestroy() { private void delayedFinishWithError() { ToastUtils.showToast(this, R.string.error_media_not_found); - new Handler().postDelayed(this::finish, 1500); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + finish(); + } + }, 1500); } @Override @@ -592,7 +600,7 @@ private void showMetaData() { } else { mDescriptionView.setText(mMedia.getDescription()); - findViewById(R.id.media_customisation_options).setVisibility(View.GONE); + findViewById(R.id.card1).setVisibility(View.GONE); findViewById(R.id.edit_link_container).setVisibility(View.GONE); } @@ -643,7 +651,12 @@ private void showMetaData() { View txtCopyUrl = findViewById(R.id.text_copy_url); txtCopyUrl.setVisibility(hasUrl ? View.VISIBLE : View.GONE); if (hasUrl) { - txtCopyUrl.setOnClickListener(v -> copyMediaUrlToClipboard()); + txtCopyUrl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + copyMediaUrlToClipboard(); + } + }); } } @@ -788,10 +801,13 @@ public void run() { int width = DisplayUtils.getDisplayPixelWidth(MediaSettingsActivity.this); final Bitmap thumb = ImageUtils.getVideoFrameFromVideo(mMedia.getUrl(), width); if (thumb != null) { - runOnUiThread(() -> { - if (!isFinishing()) { - WordPress.getBitmapCache().put(mMedia.getUrl(), thumb); - mImageView.setImageBitmap(thumb); + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!isFinishing()) { + WordPress.getBitmapCache().put(mMedia.getUrl(), thumb); + mImageView.setImageBitmap(thumb); + } } }); } @@ -804,11 +820,14 @@ private void showFullScreen() { hideFab(); // show fullscreen preview after a brief delay so fab & actionBar animations don't stutter - new Handler().postDelayed(() -> { - if (isMediaFromEditor()) { - MediaPreviewActivity.showPreview(MediaSettingsActivity.this, mSite, mEditorImageMetaData.getSrc()); - } else { - MediaPreviewActivity.showPreview(MediaSettingsActivity.this, mSite, mMedia, mMediaIdList); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + if (isMediaFromEditor()) { + MediaPreviewActivity.showPreview(MediaSettingsActivity.this, mSite, mEditorImageMetaData.getSrc()); + } else { + MediaPreviewActivity.showPreview(MediaSettingsActivity.this, mSite, mMedia, mMediaIdList); + } } }, 200); } @@ -1036,14 +1055,18 @@ private void deleteMediaWithConfirmation() { resId = R.string.confirm_delete_media_image; } - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this) + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)) .setMessage(resId) .setCancelable(true).setPositiveButton( - isMediaFromEditor() ? R.string.remove : R.string.delete, (dialog, which) -> { - if (isMediaFromEditor()) { - removeMediaFromPost(); - } else { - deleteMedia(); + isMediaFromEditor() ? R.string.remove : R.string.delete, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (isMediaFromEditor()) { + removeMediaFromPost(); + } else { + deleteMedia(); + } } }).setNegativeButton(R.string.cancel, null); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java index 711380b3bb24..5026705e14fb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui.notifications; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Parcelable; @@ -11,7 +12,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; @@ -34,7 +35,6 @@ import org.wordpress.android.push.GCMMessageHandler; import org.wordpress.android.ui.ActivityLauncher; import org.wordpress.android.ui.CollapseFullScreenDialogFragment; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.WPWebViewActivity; import org.wordpress.android.ui.comments.CommentActions; import org.wordpress.android.ui.comments.CommentDetailFragment; @@ -49,6 +49,7 @@ import org.wordpress.android.ui.reader.ReaderPostDetailFragment; import org.wordpress.android.ui.stats.StatsViewType; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.widgets.WPSwipeSnackbar; @@ -67,7 +68,7 @@ import static org.wordpress.android.models.Note.NOTE_LIKE_TYPE; import static org.wordpress.android.ui.notifications.services.NotificationsUpdateServiceStarter.IS_TAPPED_ON_NOTIFICATION; -public class NotificationsDetailActivity extends LocaleAwareActivity implements +public class NotificationsDetailActivity extends AppCompatActivity implements CommentActions.OnNoteCommentActionListener, BasicFragmentDialog.BasicDialogPositiveClickInterface { private static final String ARG_TITLE = "activityTitle"; @@ -84,6 +85,11 @@ public class NotificationsDetailActivity extends LocaleAwareActivity implements private ViewPager.OnPageChangeListener mOnPageChangeListener; private NotificationDetailFragmentAdapter mAdapter; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onBackPressed() { CollapseFullScreenDialogFragment fragment = (CollapseFullScreenDialogFragment) @@ -104,9 +110,6 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.notifications_detail_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); @@ -126,7 +129,7 @@ public void onCreate(Bundle savedInstanceState) { // set up the viewpager and adapter for lateral navigation mViewPager = findViewById(R.id.viewpager); mViewPager.setPageTransformer(false, - new WPViewPagerTransformer(WPViewPagerTransformer.TransformType.SLIDE_OVER)); + new WPViewPagerTransformer(WPViewPagerTransformer.TransformType.SLIDE_OVER)); Note note = NotificationsTable.getNoteById(mNoteId); // if this is coming from a tapped push notification, let's try refreshing it as its contents may have been @@ -340,9 +343,10 @@ private Fragment getDetailFragmentForNote(Note note) { if (note.isCommentType()) { // show comment detail for comment notifications boolean isInstantReply = getIntent().getBooleanExtra(NotificationsListFragment.NOTE_INSTANT_REPLY_EXTRA, - false); + false); fragment = CommentDetailFragment.newInstance(note.getId(), - getIntent().getStringExtra(NotificationsListFragment.NOTE_PREFILLED_REPLY_EXTRA)); + getIntent().getStringExtra( + NotificationsListFragment.NOTE_PREFILLED_REPLY_EXTRA)); if (isInstantReply) { ((CommentDetailFragment) fragment).enableShouldFocusReplyField(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailListFragment.java index 204907d12d69..bb5e1a30dbf4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailListFragment.java @@ -66,6 +66,7 @@ public class NotificationsDetailListFragment extends ListFragment implements Not private ViewGroup mFooterView; private String mRestoredNoteId; + private int mBackgroundColor; private int mCommentListPosition = ListView.INVALID_POSITION; private CommentUserNoteBlock.OnCommentStatusChangeListener mOnCommentStatusChangeListener; @@ -107,6 +108,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public void onActivityCreated(Bundle bundle) { super.onActivityCreated(bundle); + mBackgroundColor = getResources().getColor(android.R.color.white); + ListView listView = getListView(); listView.setDivider(null); listView.setDividerHeight(0); @@ -413,6 +416,7 @@ protected List doInBackground(Void... params) { // Badge notifications apply different colors and formatting if (isAdded() && noteBlock.containsBadgeMediaType()) { mIsBadgeView = true; + mBackgroundColor = getActivity().getResources().getColor(android.R.color.transparent); } if (mIsBadgeView) { @@ -500,7 +504,7 @@ protected void onPostExecute(List noteList) { } if (!hasNoteBlockAdapter()) { - mNoteBlockAdapter = new NoteBlockAdapter(getActivity(), noteList); + mNoteBlockAdapter = new NoteBlockAdapter(getActivity(), noteList, mBackgroundColor); setListAdapter(mNoteBlockAdapter); } else { mNoteBlockAdapter.setNoteList(noteList); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/adapters/NoteBlockAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/adapters/NoteBlockAdapter.java index 13a9d4e3aa33..9346a71c07ca 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/adapters/NoteBlockAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/adapters/NoteBlockAdapter.java @@ -13,14 +13,16 @@ public class NoteBlockAdapter extends ArrayAdapter { private final LayoutInflater mLayoutInflater; + private final int mBackgroundColor; private List mNoteBlockList; - public NoteBlockAdapter(Context context, List noteBlocks) { + public NoteBlockAdapter(Context context, List noteBlocks, int backgroundColor) { super(context, 0, noteBlocks); mNoteBlockList = noteBlocks; mLayoutInflater = LayoutInflater.from(context); + mBackgroundColor = backgroundColor; } @Override @@ -46,6 +48,8 @@ public View getView(int position, View convertView, ViewGroup parent) { // Update the block type for this view convertView.setTag(R.id.note_block_tag_id, noteBlock.getBlockType()); + noteBlock.setBackgroundColor(mBackgroundColor); + return noteBlock.configureView(convertView); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/adapters/NotesAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/adapters/NotesAdapter.java index f2b8335b1145..c8f3997ec4af 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/adapters/NotesAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/adapters/NotesAdapter.java @@ -8,9 +8,9 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; +import android.widget.ImageView; import android.widget.TextView; -import androidx.core.graphics.ColorUtils; import androidx.core.text.BidiFormatter; import androidx.core.view.ViewCompat; import androidx.recyclerview.widget.RecyclerView; @@ -25,12 +25,10 @@ import org.wordpress.android.ui.notifications.NotificationsListFragmentPage.OnNoteClickListener; import org.wordpress.android.ui.notifications.blocks.NoteBlockClickableSpan; import org.wordpress.android.ui.notifications.utils.NotificationsUtilsWrapper; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.GravatarUtils; import org.wordpress.android.util.RtlUtils; import org.wordpress.android.util.image.ImageManager; import org.wordpress.android.util.image.ImageType; -import org.wordpress.android.widgets.BadgedImageView; import java.util.ArrayList; import java.util.Collections; @@ -40,6 +38,7 @@ public class NotesAdapter extends RecyclerView.Adapter { private final int mAvatarSz; + private final int mColorRead; private final int mColorUnread; private final int mTextIndentSize; @@ -101,9 +100,8 @@ public NotesAdapter(Context context, DataLoadedListener dataLoadedListener, OnLo setHasStableIds(false); mAvatarSz = (int) context.getResources().getDimension(R.dimen.notifications_avatar_sz); - mColorUnread = ColorUtils - .setAlphaComponent(ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorOnSurface), - context.getResources().getInteger(R.integer.selected_list_item_opacity)); + mColorRead = context.getResources().getColor(android.R.color.white); + mColorUnread = context.getResources().getColor(R.color.background_notification_unread); mTextIndentSize = context.getResources().getDimensionPixelSize(R.dimen.notifications_text_indent_sz); } @@ -221,10 +219,8 @@ public void onBindViewHolder(NoteViewHolder noteViewHolder, int position) { if (previousTimeGroup != null && previousTimeGroup == timeGroup) { noteViewHolder.mHeaderText.setVisibility(View.GONE); - noteViewHolder.mHeaderDivider.setVisibility(View.GONE); } else { noteViewHolder.mHeaderText.setVisibility(View.VISIBLE); - noteViewHolder.mHeaderDivider.setVisibility(View.VISIBLE); if (timeGroup == Note.NoteTimeGroup.GROUP_TODAY) { noteViewHolder.mHeaderText.setText(R.string.stats_timeframe_today); @@ -298,19 +294,19 @@ public void onBindViewHolder(NoteViewHolder noteViewHolder, int position) { boolean isUnread = note.isUnread(); int gridicon = mNoticonUtils.noticonToGridicon(note.getNoticonCharacter()); - noteViewHolder.mImgAvatar.setBadgeIcon(gridicon); + mImageManager.load(noteViewHolder.mNoteIcon, gridicon); if (commentStatus == CommentStatus.UNAPPROVED) { - noteViewHolder.mImgAvatar.setBadgeBackground(R.drawable.bg_oval_warning_dark); + noteViewHolder.mNoteIcon.setBackgroundResource(R.drawable.bg_oval_warning_stroke_white); } else if (isUnread) { - noteViewHolder.mImgAvatar.setBadgeBackground(R.drawable.bg_oval_primary); + noteViewHolder.mNoteIcon.setBackgroundResource(R.drawable.bg_oval_primary_40_stroke_notification_unread); } else { - noteViewHolder.mImgAvatar.setBadgeBackground(R.drawable.bg_oval_neutral_20); + noteViewHolder.mNoteIcon.setBackgroundResource(R.drawable.bg_oval_neutral_20_stroke_white); } if (isUnread) { - noteViewHolder.mContentView.setBackgroundColor(mColorUnread); + noteViewHolder.itemView.setBackgroundColor(mColorUnread); } else { - noteViewHolder.mContentView.setBackgroundColor(0); + noteViewHolder.itemView.setBackgroundColor(mColorRead); } // request to load more comments when we near the end @@ -360,21 +356,21 @@ protected void onPostExecute(ArrayList notes) { class NoteViewHolder extends RecyclerView.ViewHolder { private final View mContentView; private final TextView mHeaderText; - private final View mHeaderDivider; private final TextView mTxtSubject; private final TextView mTxtSubjectNoticon; private final TextView mTxtDetail; - private final BadgedImageView mImgAvatar; + private final ImageView mImgAvatar; + private final ImageView mNoteIcon; NoteViewHolder(View view) { super(view); mContentView = view.findViewById(R.id.note_content_container); mHeaderText = view.findViewById(R.id.header_text); - mHeaderDivider = view.findViewById(R.id.header_divider); mTxtSubject = view.findViewById(R.id.note_subject); mTxtSubjectNoticon = view.findViewById(R.id.note_subject_noticon); mTxtDetail = view.findViewById(R.id.note_detail); mImgAvatar = view.findViewById(R.id.note_avatar); + mNoteIcon = view.findViewById(R.id.note_icon); mContentView.setOnClickListener(mOnClickListener); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java index 3509c4f8d2ab..4cb74f653e8f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java @@ -13,6 +13,7 @@ import androidx.core.view.ViewCompat; import org.wordpress.android.R; +import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.CommentStatus; import org.wordpress.android.fluxc.tools.FormattableContent; import org.wordpress.android.ui.notifications.utils.NotificationsUtilsWrapper; @@ -28,6 +29,9 @@ public class CommentUserNoteBlock extends UserNoteBlock { private static final String DOUBLE_EMPTY_LINE = "\n\t\n\t"; private CommentStatus mCommentStatus = CommentStatus.APPROVED; private int mNormalBackgroundColor; + private int mNormalTextColor; + private int mAgoTextColor; + private int mUnapprovedTextColor; private int mIndentedLeftPadding; private boolean mStatusChanged; @@ -73,7 +77,7 @@ public View configureView(View view) { noteBlockHolder.mNameTextView .setText(Html.fromHtml("" + getNoteText().toString() + "")); noteBlockHolder.mAgoTextView.setText(DateTimeUtils.timeSpanFromTimestamp(getTimestamp(), - noteBlockHolder.mAgoTextView.getContext())); + WordPress.getContext())); if (!TextUtils.isEmpty(getMetaHomeTitle()) || !TextUtils.isEmpty(getMetaSiteUrl())) { noteBlockHolder.mBulletTextView.setVisibility(View.VISIBLE); noteBlockHolder.mSiteTextView.setVisibility(View.VISIBLE); @@ -136,12 +140,18 @@ public void onClick(View v) { if (mCommentStatus == CommentStatus.UNAPPROVED) { if (hasCommentNestingLevel()) { paddingStart = mIndentedLeftPadding; - view.setBackgroundResource(R.drawable.bg_rectangle_warning_surface_with_padding); + view.setBackgroundResource(R.drawable.bg_rectangle_warning_0_warning_white); } else { - view.setBackgroundResource(R.drawable.bg_rectangle_warning_surface); + view.setBackgroundResource(R.drawable.bg_rectangle_warning_0_warning); } noteBlockHolder.mDividerView.setVisibility(View.INVISIBLE); + + noteBlockHolder.mAgoTextView.setTextColor(mUnapprovedTextColor); + noteBlockHolder.mBulletTextView.setTextColor(mUnapprovedTextColor); + noteBlockHolder.mSiteTextView.setTextColor(mUnapprovedTextColor); + noteBlockHolder.mNameTextView.setTextColor(mUnapprovedTextColor); + noteBlockHolder.mCommentTextView.setTextColor(mUnapprovedTextColor); } else { if (hasCommentNestingLevel()) { paddingStart = mIndentedLeftPadding; @@ -151,6 +161,12 @@ public void onClick(View v) { view.setBackgroundColor(mNormalBackgroundColor); noteBlockHolder.mDividerView.setVisibility(View.VISIBLE); } + + noteBlockHolder.mAgoTextView.setTextColor(mAgoTextColor); + noteBlockHolder.mBulletTextView.setTextColor(mAgoTextColor); + noteBlockHolder.mSiteTextView.setTextColor(mAgoTextColor); + noteBlockHolder.mNameTextView.setTextColor(mNormalTextColor); + noteBlockHolder.mCommentTextView.setTextColor(mNormalTextColor); } ViewCompat.setPaddingRelative(view, paddingStart, paddingTop, paddingEnd, paddingBottom); @@ -240,7 +256,10 @@ public void configureResources(Context context) { return; } - mNormalBackgroundColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorSurface); + mNormalTextColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.wpColorText); + mNormalBackgroundColor = context.getResources().getColor(android.R.color.white); + mAgoTextColor = context.getResources().getColor(R.color.neutral); + mUnapprovedTextColor = context.getResources().getColor(R.color.warning_60); // Double margin_extra_large for increased indent in comment replies mIndentedLeftPadding = context.getResources().getDimensionPixelSize(R.dimen.margin_extra_large) * 2; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/NoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/NoteBlock.java index a37aec226dcc..8c7661a18311 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/NoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/NoteBlock.java @@ -48,6 +48,7 @@ public class NoteBlock { private boolean mIsBadge; private boolean mIsPingback; private boolean mHasAnimatedBadge; + private int mBackgroundColor; public interface OnNoteBlockTextClickListener { void onNoteBlockTextClicked(NoteBlockClickableSpan clickedSpan); @@ -113,6 +114,9 @@ public void setIsBadge() { mIsBadge = true; } + public void setBackgroundColor(int backgroundColor) { + mBackgroundColor = backgroundColor; + } public int getLayoutResourceId() { return R.layout.note_block_basic; @@ -240,6 +244,9 @@ public void onClick(View v) { noteBlockHolder.getTextView().setVisibility(View.GONE); } + + view.setBackgroundColor(mBackgroundColor); + return view; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/NoteBlockClickableSpan.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/NoteBlockClickableSpan.java index 89d054985ac0..829eb0faa69d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/NoteBlockClickableSpan.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/NoteBlockClickableSpan.java @@ -50,10 +50,10 @@ public NoteBlockClickableSpan(FormattableRange range, boolean shouldLink, boolea // We need to use theme-styled colors in NoteBlockClickableSpan but current Notifications architecture makes it // difficult to get right type of context to this span to style the colors. We are doing it in this method instead. public void enableColors(Context context) { - mTextColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorOnSurface); + mTextColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.wpColorText); mBackgroundColor = ContextCompat.getColor(context, R.color.primary_5); - mLinkColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorPrimary); - mLightTextColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorOnSurface); + mLinkColor = ContextCompat.getColor(context, R.color.primary_40); + mLightTextColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.wpColorText); } public void setColors(@ColorInt int textColor, @ColorInt int backgroundColor, @ColorInt int linkColor, @@ -116,11 +116,10 @@ public int getSpanStyle() { switch (getRangeType()) { case USER: case MATCH: + return Typeface.BOLD; case SITE: case POST: case COMMENT: - case B: - return Typeface.BOLD; case BLOCKQUOTE: return Typeface.ITALIC; case STAT: diff --git a/WordPress/src/main/java/org/wordpress/android/ui/pages/PageItemViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/pages/PageItemViewHolder.kt index 4c88ffb61325..8710f2c69359 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/pages/PageItemViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/pages/PageItemViewHolder.kt @@ -11,6 +11,7 @@ import android.widget.PopupMenu import android.widget.RadioButton import android.widget.TextView import androidx.annotation.LayoutRes +import androidx.core.widget.CompoundButtonCompat import androidx.recyclerview.widget.RecyclerView import org.wordpress.android.R import org.wordpress.android.ui.ActionableEmptyView @@ -19,11 +20,11 @@ import org.wordpress.android.ui.pages.PageItem.Empty import org.wordpress.android.ui.pages.PageItem.Page import org.wordpress.android.ui.pages.PageItem.ParentPage import org.wordpress.android.ui.reader.utils.ReaderUtils +import org.wordpress.android.util.currentLocale import org.wordpress.android.util.DateTimeUtils import org.wordpress.android.util.DisplayUtils import org.wordpress.android.util.ImageUtils import org.wordpress.android.util.capitalizeWithLocaleWithoutLint -import org.wordpress.android.util.currentLocale import org.wordpress.android.util.getDrawableFromAttribute import org.wordpress.android.util.image.ImageManager import org.wordpress.android.util.image.ImageType @@ -162,6 +163,10 @@ sealed class PageItemViewHolder(internal val parent: ViewGroup, @LayoutRes layou radioButton.setOnClickListener { onParentSelected(pageItem) } + + @Suppress("DEPRECATION") + CompoundButtonCompat.setButtonTintList(radioButton, + radioButton.resources.getColorStateList(R.color.primary_40_gray_20_gray_40_selector)) } } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/pages/PageParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/pages/PageParentActivity.kt index 2bd7fdd52be5..66632734fa8e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/pages/PageParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/pages/PageParentActivity.kt @@ -1,17 +1,17 @@ package org.wordpress.android.ui.pages import android.os.Bundle -import kotlinx.android.synthetic.main.toolbar_main.* +import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.toolbar.* import org.wordpress.android.R -import org.wordpress.android.ui.LocaleAwareActivity -class PageParentActivity : LocaleAwareActivity() { +class PageParentActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.pages_parent_activity) - setSupportActionBar(toolbar_main) + setSupportActionBar(toolbar) supportActionBar?.let { it.setHomeButtonEnabled(true) it.setDisplayHomeAsUpEnabled(true) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesActivity.kt index a2d3cebaa10f..d46b421721bd 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesActivity.kt @@ -3,16 +3,16 @@ package org.wordpress.android.ui.pages import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.appcompat.app.AppCompatActivity import kotlinx.android.synthetic.main.pages_fragment.* import org.wordpress.android.R -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogNegativeClickInterface import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogPositiveClickInterface const val EXTRA_PAGE_REMOTE_ID_KEY = "extra_page_remote_id_key" const val EXTRA_PAGE_PARENT_ID_KEY = "extra_page_parent_id_key" -class PagesActivity : LocaleAwareActivity(), +class PagesActivity : AppCompatActivity(), BasicDialogPositiveClickInterface, BasicDialogNegativeClickInterface { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesFragment.kt index 8eec224974a2..dec2c9e56596 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesFragment.kt @@ -417,7 +417,7 @@ class PagesFragment : Fragment() { getString(R.string.delete), getString(R.string.cancel) ) - dialog.show(requireFragmentManager(), page.id.toString()) + dialog.show(fragmentManager, page.id.toString()) } override fun onStart() { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleInviteFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleInviteFragment.java index 65b3053f84f2..eaa8952b7376 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleInviteFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleInviteFragment.java @@ -18,9 +18,6 @@ import android.widget.TextView; import androidx.annotation.Nullable; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; @@ -76,10 +73,6 @@ public class PeopleInviteFragment extends Fragment implements RoleSelectDialogFr @Inject SiteStore mSiteStore; - private int mNormalUsernameColor; - private int mAddedUsernameColor; - private int mErrorUsernameColor; - public static PeopleInviteFragment newInstance(SiteModel site) { PeopleInviteFragment peopleInviteFragment = new PeopleInviteFragment(); Bundle bundle = new Bundle(); @@ -151,22 +144,7 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true); - View rootView = inflater.inflate(R.layout.people_invite_fragment, container, false); - - Toolbar toolbar = rootView.findViewById(R.id.toolbar_main); - ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); - ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); - if (actionBar != null) { - actionBar.setHomeButtonEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setTitle(R.string.people); - } - - mNormalUsernameColor = ContextExtensionsKt.getColorResIdFromAttribute(getActivity(), R.attr.colorOnSurface); - mAddedUsernameColor = ContextExtensionsKt.getColorResIdFromAttribute(getActivity(), R.attr.colorPrimary); - mErrorUsernameColor = ContextExtensionsKt.getColorResIdFromAttribute(getActivity(), R.attr.wpColorError); - - return rootView; + return inflater.inflate(R.layout.people_invite_fragment, container, false); } @Override @@ -355,11 +333,11 @@ private String getDefaultRole() { private void updateRemainingCharsView(TextView remainingCharsTextView, String currentString, int limit) { remainingCharsTextView.setText(StringUtils.getQuantityString(getActivity(), - R.string.invite_message_remaining_zero, - R.string.invite_message_remaining_one, - R.string.invite_message_remaining_other, - limit - (currentString == null ? 0 - : currentString.length()))); + R.string.invite_message_remaining_zero, + R.string.invite_message_remaining_one, + R.string.invite_message_remaining_other, + limit - (currentString == null ? 0 + : currentString.length()))); } private void populateUsernameButtons(Collection usernames) { @@ -489,39 +467,39 @@ private void validateAndStyleUsername(Collection usernames, if (usernamesToCheck.size() > 0) { long wpcomBlogId = mSite.getSiteId(); PeopleUtils.validateUsernames(usernamesToCheck, mCurrentRole, wpcomBlogId, - new PeopleUtils.ValidateUsernameCallback() { - @Override - public void onUsernameValidation(String username, - ValidationResult validationResult) { - if (!isAdded()) { - return; - } - - if (!isUserInInvitees(username)) { - // user is removed from invitees before validation - return; - } - - final String usernameResultString = - getValidationErrorString(username, validationResult); - mUsernameResults.put(username, usernameResultString); - - styleButton(username, usernameResultString); - updateUsernameError(username, usernameResultString); - } - - @Override - public void onValidationFinished() { - if (validationEndListener != null) { - validationEndListener.onValidationEnd(); - } - } - - @Override - public void onError() { - // properly style the button - } - }); + new PeopleUtils.ValidateUsernameCallback() { + @Override + public void onUsernameValidation(String username, + ValidationResult validationResult) { + if (!isAdded()) { + return; + } + + if (!isUserInInvitees(username)) { + // user is removed from invitees before validation + return; + } + + final String usernameResultString = + getValidationErrorString(username, validationResult); + mUsernameResults.put(username, usernameResultString); + + styleButton(username, usernameResultString); + updateUsernameError(username, usernameResultString); + } + + @Override + public void onValidationFinished() { + if (validationEndListener != null) { + validationEndListener.onValidationEnd(); + } + } + + @Override + public void onError() { + // properly style the button + } + }); } else { if (validationEndListener != null) { validationEndListener.onValidationEnd(); @@ -534,10 +512,11 @@ private void styleButton(String username, @Nullable String validationResultMessa return; } - TextView textView = mUsernameButtons.get(username).findViewById(R.id.username); + TextView textView = (TextView) mUsernameButtons.get(username).findViewById(R.id.username); textView.setTextColor(ContextCompat.getColor(getActivity(), - validationResultMessage == null ? mNormalUsernameColor - : (validationResultMessage.equals(FLAG_SUCCESS) ? mAddedUsernameColor : mErrorUsernameColor))); + validationResultMessage == null ? ContextExtensionsKt + .getColorResIdFromAttribute(getActivity(), R.attr.wpColorText) + : (validationResultMessage.equals(FLAG_SUCCESS) ? R.color.primary_50 : R.color.error_50))); } private @@ -587,7 +566,7 @@ private void updateUsernameError(String username, @Nullable String usernameResul usernameErrorTextView = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.people_invite_error_view, - usernameErrorsContainer, false); + usernameErrorsContainer, false); usernameErrorsContainer.addView(usernameErrorTextView); @@ -639,8 +618,8 @@ public void onValidationEnd() { } /* - * returns true if send is attempted, false if validation failed - * */ + * returns true if send is attempted, false if validation failed + * */ private boolean checkAndSend() { if (!isAdded()) { return false; @@ -664,10 +643,10 @@ private boolean checkAndSend() { if (invalidCount > 0) { ToastUtils.showToast(getActivity(), - StringUtils.getQuantityString(getActivity(), 0, - R.string.invite_error_invalid_usernames_one, - R.string.invite_error_invalid_usernames_multiple, - invalidCount)); + StringUtils.getQuantityString(getActivity(), 0, + R.string.invite_error_invalid_usernames_one, + R.string.invite_error_invalid_usernames_multiple, + invalidCount)); return false; } @@ -693,7 +672,7 @@ public void onSent(List succeededUsernames, Map failedUs final String username = error.getKey(); final String errorMessage = error.getValue(); mUsernameResults.put(username, getString(R.string.invite_error_for_username, - username, errorMessage)); + username, errorMessage)); } populateUsernameButtons(failedUsernameErrors.keySet()); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleListFragment.java index fe6edd338f3e..9f8a2dbea22e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleListFragment.java @@ -1,10 +1,8 @@ package org.wordpress.android.ui.people; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.drawable.Drawable; -import android.graphics.drawable.InsetDrawable; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -16,9 +14,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; @@ -27,7 +23,6 @@ import com.google.android.material.appbar.AppBarLayout; import org.apache.commons.text.StringEscapeUtils; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.datasets.PeopleTable; @@ -45,7 +40,6 @@ import org.wordpress.android.util.AppLog; import org.wordpress.android.util.GravatarUtils; import org.wordpress.android.util.NetworkUtils; -import org.wordpress.android.util.RtlUtils; import org.wordpress.android.util.image.ImageManager; import org.wordpress.android.util.image.ImageType; @@ -108,26 +102,20 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.people_list_fragment, container, false); - Toolbar toolbar = rootView.findViewById(R.id.toolbar_main); - ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); - ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); - if (actionBar != null) { - actionBar.setHomeButtonEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setTitle(R.string.people); - } - mSite = (SiteModel) getArguments().getSerializable(WordPress.SITE); final boolean isPrivate = mSite != null && mSite.isPrivate(); mActionableEmptyView = rootView.findViewById(R.id.actionable_empty_view); mFilteredRecyclerView = rootView.findViewById(R.id.filtered_recycler_view); mFilteredRecyclerView - .addItemDecoration(new PeopleItemDecoration(getActivity())); + .addItemDecoration(new PeopleItemDecoration(getActivity(), R.drawable.people_list_divider)); mFilteredRecyclerView.setLogT(AppLog.T.PEOPLE); mFilteredRecyclerView.setSwipeToRefreshEnabled(false); // the following will change the look and feel of the toolbar to match the current design + mFilteredRecyclerView.setToolbarBackgroundColor(ContextCompat.getColor(getActivity(), R.color.primary_40)); + mFilteredRecyclerView.setToolbarSpinnerTextColor(ContextCompat.getColor(getActivity(), android.R.color.white)); + mFilteredRecyclerView.setToolbarSpinnerDrawable(R.drawable.ic_dropdown_primary_30_24dp); mFilteredRecyclerView.setToolbarLeftAndRightPadding( getResources().getDimensionPixelSize(R.dimen.margin_filter_spinner), getResources().getDimensionPixelSize(R.dimen.margin_none)); @@ -177,7 +165,7 @@ public void onFilterSelected(int position, FilterCriteria criteria) { public String onShowEmptyViewMessage(EmptyViewMessageType emptyViewMsgType) { mActionableEmptyView.setVisibility(View.GONE); mFilteredRecyclerView.setToolbarScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL - | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); + | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); switch (emptyViewMsgType) { case LOADING: @@ -304,7 +292,7 @@ public void refreshPeopleList(boolean isFetching) { // if the list is not empty, don't show any message mFilteredRecyclerView.hideEmptyView(); mFilteredRecyclerView.setToolbarScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL - | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); + | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); mActionableEmptyView.setVisibility(View.GONE); } else if (!isFetching) { // if we are not fetching and list is empty, show no content message @@ -480,26 +468,15 @@ public void onClick(View v) { // Taken from http://stackoverflow.com/a/27037230 private class PeopleItemDecoration extends RecyclerView.ItemDecoration { - private InsetDrawable mDivider; + private Drawable mDivider; // use a custom drawable - PeopleItemDecoration(Context context) { - int[] attrs = {android.R.attr.listDivider}; - TypedArray ta = context.obtainStyledAttributes(attrs); - Drawable drawable = ta.getDrawable(0); - ta.recycle(); - - int inset = context.getResources().getDimensionPixelOffset(R.dimen.people_list_divider_left_margin); - - if (RtlUtils.isRtl(context)) { - mDivider = new InsetDrawable(drawable, 0, 0, inset, 0); - } else { - mDivider = new InsetDrawable(drawable, inset, 0, 0, 0); - } + PeopleItemDecoration(Context context, int resId) { + mDivider = ContextCompat.getDrawable(context, resId); } @Override - public void onDraw(@NotNull Canvas c, @NotNull RecyclerView parent, @NotNull RecyclerView.State state) { + public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { int left = ViewCompat.getPaddingStart(parent); int right = parent.getWidth() - ViewCompat.getPaddingEnd(parent); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java index 4b4ac31e44d6..73bf2f94bad5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java @@ -1,17 +1,18 @@ package org.wordpress.android.ui.people; +import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.view.MenuItem; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -26,9 +27,9 @@ import org.wordpress.android.fluxc.store.SiteStore.OnUserRolesChanged; import org.wordpress.android.models.PeopleListFilter; import org.wordpress.android.models.Person; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.people.utils.PeopleUtils; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.analytics.AnalyticsUtils; @@ -37,7 +38,7 @@ import javax.inject.Inject; -public class PeopleManagementActivity extends LocaleAwareActivity +public class PeopleManagementActivity extends AppCompatActivity implements PeopleListFragment.OnPersonSelectedListener, PeopleListFragment.OnFetchPeopleListener { private static final String KEY_PEOPLE_LIST_FRAGMENT = "people-list-fragment"; private static final String KEY_PERSON_DETAIL_FRAGMENT = "person-detail-fragment"; @@ -90,6 +91,11 @@ public class PeopleManagementActivity extends LocaleAwareActivity private SiteModel mSite; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -112,6 +118,16 @@ public void onCreate(Bundle savedInstanceState) { // Fetch the user roles to get ready mDispatcher.dispatch(SiteActionBuilder.newFetchUserRolesAction(mSite)); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setHomeButtonEnabled(true); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setElevation(0); + } + + FragmentManager fragmentManager = getSupportFragmentManager(); if (savedInstanceState == null) { @@ -120,6 +136,10 @@ public void onCreate(Bundle savedInstanceState) { PeopleTable.deletePeopleExceptForFirstPage(mSite.getId()); } + if (actionBar != null) { + actionBar.setTitle(R.string.people); + } + PeopleListFragment peopleListFragment = PeopleListFragment.newInstance(mSite); peopleListFragment.setOnPersonSelectedListener(this); peopleListFragment.setOnFetchPeopleListener(this); @@ -165,6 +185,11 @@ public void onCreate(Bundle savedInstanceState) { mFollowersLastFetchedPage = savedInstanceState.getInt(KEY_FOLLOWERS_LAST_FETCHED_PAGE); mEmailFollowersLastFetchedPage = savedInstanceState.getInt(KEY_EMAIL_FOLLOWERS_LAST_FETCHED_PAGE); + CharSequence title = savedInstanceState.getCharSequence(KEY_TITLE); + if (actionBar != null && title != null) { + actionBar.setTitle(title); + } + PeopleListFragment peopleListFragment = getListFragment(); if (peopleListFragment != null) { peopleListFragment.setOnPersonSelectedListener(this); @@ -285,8 +310,8 @@ public void onError() { } mUsersFetchRequestInProgress = false; ToastUtils.showToast(PeopleManagementActivity.this, - R.string.error_fetch_users_list, - ToastUtils.Duration.SHORT); + R.string.error_fetch_users_list, + ToastUtils.Duration.SHORT); } }); @@ -327,8 +352,8 @@ public void onError() { } mFollowersFetchRequestInProgress = false; ToastUtils.showToast(PeopleManagementActivity.this, - R.string.error_fetch_followers_list, - ToastUtils.Duration.SHORT); + R.string.error_fetch_followers_list, + ToastUtils.Duration.SHORT); } }); @@ -370,8 +395,8 @@ public void onError() { } mEmailFollowersFetchRequestInProgress = false; ToastUtils.showToast(PeopleManagementActivity.this, - R.string.error_fetch_email_followers_list, - ToastUtils.Duration.SHORT); + R.string.error_fetch_email_followers_list, + ToastUtils.Duration.SHORT); } }); @@ -411,8 +436,8 @@ public void onError() { } mViewersFetchRequestInProgress = false; ToastUtils.showToast(PeopleManagementActivity.this, - R.string.error_fetch_viewers_list, - ToastUtils.Duration.SHORT); + R.string.error_fetch_viewers_list, + ToastUtils.Duration.SHORT); } }); @@ -428,7 +453,7 @@ public void onPersonSelected(Person person) { if (personDetailFragment == null) { personDetailFragment = PersonDetailFragment.newInstance(mAccountStore.getAccount().getUserId(), personID, - localTableBlogID, person.getPersonType()); + localTableBlogID, person.getPersonType()); } else { personDetailFragment.setPersonDetails(personID, localTableBlogID); } @@ -467,25 +492,25 @@ public void onEventMainThread(RoleChangeDialogFragment.RoleChangeEvent event) { } PeopleUtils.updateRole(mSite, person.getPersonID(), event.getNewRole(), event.getLocalTableBlogId(), - new PeopleUtils.UpdateUserCallback() { - @Override - public void onSuccess(Person person) { - AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.PERSON_UPDATED, mSite); - PeopleTable.saveUser(person); - refreshOnScreenFragmentDetails(); - } - - @Override - public void onError() { - // change the role back to it's original value - if (personDetailFragment != null) { - personDetailFragment.refreshPersonDetails(); - } - ToastUtils.showToast(PeopleManagementActivity.this, - R.string.error_update_role, - ToastUtils.Duration.LONG); - } - }); + new PeopleUtils.UpdateUserCallback() { + @Override + public void onSuccess(Person person) { + AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.PERSON_UPDATED, mSite); + PeopleTable.saveUser(person); + refreshOnScreenFragmentDetails(); + } + + @Override + public void onError() { + // change the role back to it's original value + if (personDetailFragment != null) { + personDetailFragment.refreshPersonDetails(); + } + ToastUtils.showToast(PeopleManagementActivity.this, + R.string.error_update_role, + ToastUtils.Duration.LONG); + } + }); } private void confirmRemovePerson() { @@ -494,7 +519,7 @@ private void confirmRemovePerson() { return; } - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Calypso_Dialog_Alert); builder.setTitle(getString(R.string.person_remove_confirmation_title, person.getDisplayName())); if (person.getPersonType() == Person.PersonType.USER) { builder.setMessage(getString(R.string.user_remove_confirmation_message, person.getDisplayName())); @@ -558,8 +583,8 @@ public void onError() { break; } ToastUtils.showToast(PeopleManagementActivity.this, - errorMessageRes, - ToastUtils.Duration.LONG); + errorMessageRes, + ToastUtils.Duration.LONG); } }; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PersonDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PersonDetailFragment.java index 8c49fca61f0a..61e7a86d3e4b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PersonDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PersonDetailFragment.java @@ -11,13 +11,9 @@ import android.widget.LinearLayout; import android.widget.TextView; -import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import org.apache.commons.text.StringEscapeUtils; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.datasets.PeopleTable; @@ -95,7 +91,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putLong(ARG_CURRENT_USER_ID, mCurrentUserId); outState.putLong(ARG_PERSON_ID, mPersonId); @@ -113,15 +109,6 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.person_detail_fragment, container, false); - Toolbar toolbar = rootView.findViewById(R.id.toolbar_main); - ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); - ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); - if (actionBar != null) { - actionBar.setHomeButtonEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setTitle(null); - } - mAvatarImageView = rootView.findViewById(R.id.person_avatar); mDisplayNameTextView = rootView.findViewById(R.id.person_display_name); mUsernameTextView = rootView.findViewById(R.id.person_username); @@ -147,7 +134,7 @@ public void onResume() { refreshPersonDetails(); } - void refreshPersonDetails() { + public void refreshPersonDetails() { if (!isAdded()) { return; } @@ -198,7 +185,7 @@ void refreshPersonDetails() { } } - void setPersonDetails(long personID, int localTableBlogID) { + public void setPersonDetails(long personID, int localTableBlogID) { mPersonId = personID; mLocalTableBlogId = localTableBlogID; refreshPersonDetails(); @@ -210,7 +197,12 @@ private void setupRoleContainerForCapability() { boolean isCurrentUser = mCurrentUserId == mPersonId; boolean canChangeRole = (site != null) && !isCurrentUser && site.getHasCapabilityPromoteUsers(); if (canChangeRole) { - mRoleContainer.setOnClickListener(v -> showRoleChangeDialog()); + mRoleContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showRoleChangeDialog(); + } + }); } else { // Remove the selectableItemBackground if the user can't be edited mRoleContainer.setBackground(null); @@ -226,14 +218,14 @@ private void showRoleChangeDialog() { } RoleChangeDialogFragment dialog = RoleChangeDialogFragment.newInstance(person.getPersonID(), - mSiteStore.getSiteByLocalId( - mLocalTableBlogId), - person.getRole()); + mSiteStore.getSiteByLocalId( + mLocalTableBlogId), + person.getRole()); dialog.show(getFragmentManager(), null); } // used to optimistically update the role - void changeRole(String newRole) { + public void changeRole(String newRole) { mRoleTextView.setText(RoleUtils.getDisplayName(newRole, mUserRoles)); } @@ -244,7 +236,7 @@ private void changeDisplayNameTopPadding(int newPadding) { mDisplayNameTextView.setPadding(0, newPadding, 0, 0); } - Person loadPerson() { + public Person loadPerson() { return PeopleTable.getPerson(mPersonId, mLocalTableBlogId, mPersonType); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/RoleChangeDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/people/RoleChangeDialogFragment.java index 69bbc1a2c0bd..41a8f812dae4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/RoleChangeDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/RoleChangeDialogFragment.java @@ -2,7 +2,9 @@ import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; @@ -13,10 +15,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.greenrobot.eventbus.EventBus; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.RoleModel; @@ -42,7 +41,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); String role = mRoleListAdapter.getSelectedRole(); outState.putSerializable(ROLE_TAG, role); @@ -64,16 +63,20 @@ public static RoleChangeDialogFragment newInstance(long personID, SiteModel site public Dialog onCreateDialog(Bundle savedInstanceState) { final SiteModel site = (SiteModel) getArguments().getSerializable(WordPress.SITE); - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(R.string.role); builder.setNegativeButton(R.string.cancel, null); - builder.setPositiveButton(android.R.string.ok, (dialog, which) -> { - String role = mRoleListAdapter.getSelectedRole(); - Bundle args = getArguments(); - if (args != null) { - long personID = args.getLong(PERSON_ID_TAG); - if (site != null) { - EventBus.getDefault().post(new RoleChangeEvent(personID, site.getId(), role)); + builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + String role = mRoleListAdapter.getSelectedRole(); + Bundle args = getArguments(); + if (args != null) { + long personID = args.getLong(PERSON_ID_TAG); + if (site != null) { + EventBus.getDefault().post(new RoleChangeEvent(personID, site.getId(), role)); + } } } }); @@ -112,10 +115,20 @@ public View getView(final int position, View convertView, @NonNull ViewGroup par convertView = View.inflate(getContext(), R.layout.role_list_row, null); } - TextView mainText = convertView.findViewById(R.id.role_label); - final RadioButton radioButton = convertView.findViewById(R.id.radio); - radioButton.setOnClickListener(v -> changeSelection(position)); - convertView.setOnClickListener(v -> changeSelection(position)); + TextView mainText = (TextView) convertView.findViewById(R.id.role_label); + final RadioButton radioButton = (RadioButton) convertView.findViewById(R.id.radio); + radioButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + changeSelection(position); + } + }); + convertView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + changeSelection(position); + } + }); RoleModel role = getItem(position); if (role != null) { @@ -154,15 +167,15 @@ static class RoleChangeEvent { mNewRole = newRole; } - long getPersonID() { + public long getPersonID() { return mPersonID; } - int getLocalTableBlogId() { + public int getLocalTableBlogId() { return mLocalTableBlogId; } - String getNewRole() { + public String getNewRole() { return mNewRole; } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/RoleSelectDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/people/RoleSelectDialogFragment.java index d3a7d3cc6dc3..cf0c7e571efd 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/RoleSelectDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/RoleSelectDialogFragment.java @@ -1,7 +1,9 @@ package org.wordpress.android.ui.people; import android.app.Dialog; +import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextThemeWrapper; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; @@ -9,8 +11,6 @@ import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.RoleModel; @@ -40,17 +40,21 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { stringRoles[i] = inviteRoles.get(i).getDisplayName(); } - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(R.string.role); - builder.setItems(stringRoles, (dialog, which) -> { - if (!isAdded()) { - return; - } + builder.setItems(stringRoles, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (!isAdded()) { + return; + } - if (getTargetFragment() instanceof OnRoleSelectListener) { - ((OnRoleSelectListener) getTargetFragment()).onRoleSelected(inviteRoles.get(which)); - } else if (getActivity() instanceof OnRoleSelectListener) { - ((OnRoleSelectListener) getActivity()).onRoleSelected(inviteRoles.get(which)); + if (getTargetFragment() instanceof OnRoleSelectListener) { + ((OnRoleSelectListener) getTargetFragment()).onRoleSelected(inviteRoles.get(which)); + } else if (getActivity() instanceof OnRoleSelectListener) { + ((OnRoleSelectListener) getActivity()).onRoleSelected(inviteRoles.get(which)); + } } }); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java index 354469296573..30014445202a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.photopicker; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -11,6 +12,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -22,7 +24,6 @@ import org.wordpress.android.fluxc.model.SiteModel; import org.wordpress.android.fluxc.store.MediaStore; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.media.MediaBrowserActivity; import org.wordpress.android.ui.media.MediaBrowserType; @@ -30,6 +31,7 @@ import org.wordpress.android.ui.posts.FeaturedImageHelper.EnqueueFeaturedImageResult; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.ListUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.WPMediaUtils; @@ -41,7 +43,7 @@ import static org.wordpress.android.ui.posts.FeaturedImageHelperKt.EMPTY_LOCAL_POST_ID; -public class PhotoPickerActivity extends LocaleAwareActivity +public class PhotoPickerActivity extends AppCompatActivity implements PhotoPickerFragment.PhotoPickerListener { private static final String PICKER_FRAGMENT_TAG = "picker_fragment_tag"; private static final String KEY_MEDIA_CAPTURE_PATH = "media_capture_path"; @@ -87,13 +89,18 @@ public static PhotoPickerMediaSource fromString(String strSource) { } } + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); setContentView(R.layout.photo_picker_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); + Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setNavigationIcon(R.drawable.ic_close_white_24dp); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerFragment.java index 82ff18776f17..6392a3071d68 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerFragment.java @@ -37,6 +37,7 @@ import org.wordpress.android.util.AppLog; import org.wordpress.android.util.DisplayUtils; import org.wordpress.android.util.MediaUtils; +import org.wordpress.android.util.WPActivityUtils; import org.wordpress.android.util.WPMediaUtils; import org.wordpress.android.util.WPPermissionUtils; import org.wordpress.android.util.analytics.AnalyticsUtils; @@ -457,6 +458,7 @@ private final class ActionModeCallback implements ActionMode.Callback { @Override public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { mActionMode = actionMode; + WPActivityUtils.setStatusBarColor(getActivity().getWindow(), R.color.neutral_60); MenuInflater inflater = actionMode.getMenuInflater(); inflater.inflate(R.menu.photo_picker_action_mode, menu); hideBottomBar(); @@ -482,6 +484,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { @Override public void onDestroyActionMode(ActionMode mode) { + WPActivityUtils.setStatusBarColor(getActivity().getWindow(), R.color.status_bar); mActionMode = null; showBottomBar(); getAdapter().clearSelection(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plans/PlansActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/plans/PlansActivity.kt index 4a4a3b1ecfdc..3dfc94358505 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plans/PlansActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/plans/PlansActivity.kt @@ -1,20 +1,21 @@ package org.wordpress.android.ui.plans import android.os.Bundle -import kotlinx.android.synthetic.main.toolbar_main.* +import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.widget.Toolbar import org.wordpress.android.R import org.wordpress.android.fluxc.model.plans.PlanOffersModel import org.wordpress.android.ui.FullScreenDialogFragment -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.plans.PlansListFragment.PlansListInterface import org.wordpress.android.util.StringUtils -class PlansActivity : LocaleAwareActivity(), PlansListInterface { +class PlansActivity : AppCompatActivity(), PlansListInterface { public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.plans_activity) - - setSupportActionBar(toolbar_main) + val toolbar = findViewById(R.id.toolbar) + toolbar!!.title = getString(R.string.plans) + setSupportActionBar(toolbar) supportActionBar!!.setDisplayHomeAsUpEnabled(true) } @@ -28,9 +29,7 @@ class PlansActivity : LocaleAwareActivity(), PlansListInterface { } override fun onPlansUpdating() { - val planDetailsDialogFragment = supportFragmentManager.findFragmentByTag( - FullScreenDialogFragment.TAG - ) + val planDetailsDialogFragment = supportFragmentManager.findFragmentByTag(FullScreenDialogFragment.TAG) if (planDetailsDialogFragment != null && planDetailsDialogFragment is FullScreenDialogFragment) { planDetailsDialogFragment.dismissAllowingStateLoss() } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java index a8da9e20083b..cdf62b3c6fb6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java @@ -17,10 +17,12 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.content.res.AppCompatResources; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; +import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProviders; import androidx.recyclerview.widget.DiffUtil; @@ -28,7 +30,6 @@ import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.ViewHolder; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.analytics.AnalyticsTracker; @@ -36,11 +37,10 @@ import org.wordpress.android.fluxc.model.plugin.ImmutablePluginModel; import org.wordpress.android.models.networkresource.ListState; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.ActivityUtils; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.ColorUtils; -import org.wordpress.android.util.ContextExtensionsKt; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; @@ -56,7 +56,7 @@ import javax.inject.Inject; -public class PluginBrowserActivity extends LocaleAwareActivity +public class PluginBrowserActivity extends AppCompatActivity implements SearchView.OnQueryTextListener, MenuItem.OnActionExpandListener { @Inject ViewModelProvider.Factory mViewModelFactory; @@ -71,6 +71,11 @@ public class PluginBrowserActivity extends LocaleAwareActivity private MenuItem mSearchMenuItem; private SearchView mSearchView; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -84,7 +89,7 @@ public void onCreate(Bundle savedInstanceState) { mPopularPluginsRecycler = findViewById(R.id.popular_plugins_recycler); mNewPluginsRecycler = findViewById(R.id.new_plugins_recycler); - Toolbar toolbar = findViewById(R.id.toolbar_main); + Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { @@ -107,20 +112,43 @@ public void onCreate(Bundle savedInstanceState) { mViewModel.start(); // site plugin list - findViewById(R.id.text_manage).setOnClickListener(v -> showListFragment(PluginListType.SITE)); + findViewById(R.id.text_manage).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showListFragment(PluginListType.SITE); + } + }); // featured plugin list - findViewById(R.id.text_all_featured).setOnClickListener(v -> showListFragment(PluginListType.FEATURED)); + findViewById(R.id.text_all_featured).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showListFragment(PluginListType.FEATURED); + } + }); // popular plugin list - findViewById(R.id.text_all_popular).setOnClickListener(v -> showListFragment(PluginListType.POPULAR)); + findViewById(R.id.text_all_popular).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showListFragment(PluginListType.POPULAR); + } + }); // new plugin list - findViewById(R.id.text_all_new).setOnClickListener(v -> showListFragment(PluginListType.NEW)); + findViewById(R.id.text_all_new).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showListFragment(PluginListType.NEW); + } + }); - getSupportFragmentManager().addOnBackStackChangedListener(() -> { - if (getSupportFragmentManager().getBackStackEntryCount() == 0) { - mViewModel.setTitle(getString(R.string.plugins)); + getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { + @Override + public void onBackStackChanged() { + if (getSupportFragmentManager().getBackStackEntryCount() == 0) { + mViewModel.setTitle(getString(R.string.plugins)); + } } }); @@ -133,50 +161,67 @@ public void onCreate(Bundle savedInstanceState) { } @Override - protected void onSaveInstanceState(@NotNull Bundle outState) { + protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); mViewModel.writeToBundle(outState); } private void setupObservers() { - mViewModel.getTitle().observe(this, title -> setTitle(title)); + mViewModel.getTitle().observe(this, new Observer() { + @Override + public void onChanged(@Nullable String title) { + setTitle(title); + } + }); mViewModel.getSitePluginsLiveData() - .observe(this, listState -> { - if (listState != null) { - reloadPluginAdapterAndVisibility(PluginListType.SITE, listState); - - showProgress(listState.isFetchingFirstPage() && listState.getData().isEmpty()); - - // We should ignore the errors due to network condition, unless this is the first - // fetch, the user - // can use the cached data and showing the error while the data is loaded might cause - // confusion - if (listState instanceof ListState.Error - && NetworkUtils.isNetworkAvailable(PluginBrowserActivity.this)) { - ToastUtils.showToast(PluginBrowserActivity.this, R.string.plugin_fetch_error); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (listState != null) { + reloadPluginAdapterAndVisibility(PluginListType.SITE, listState); + + showProgress(listState.isFetchingFirstPage() && listState.getData().isEmpty()); + + // We should ignore the errors due to network condition, unless this is the first + // fetch, the user + // can use the cached data and showing the error while the data is loaded might cause + // confusion + if (listState instanceof ListState.Error + && NetworkUtils.isNetworkAvailable(PluginBrowserActivity.this)) { + ToastUtils.showToast(PluginBrowserActivity.this, R.string.plugin_fetch_error); + } } } }); mViewModel.getFeaturedPluginsLiveData() - .observe(this, listState -> { - if (listState != null) { - reloadPluginAdapterAndVisibility(PluginListType.FEATURED, listState); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (listState != null) { + reloadPluginAdapterAndVisibility(PluginListType.FEATURED, listState); + } } }); mViewModel.getPopularPluginsLiveData() - .observe(this, listState -> { - if (listState != null) { - reloadPluginAdapterAndVisibility(PluginListType.POPULAR, listState); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (listState != null) { + reloadPluginAdapterAndVisibility(PluginListType.POPULAR, listState); + } } }); mViewModel.getNewPluginsLiveData() - .observe(this, listState -> { - if (listState != null) { - reloadPluginAdapterAndVisibility(PluginListType.NEW, listState); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (listState != null) { + reloadPluginAdapterAndVisibility(PluginListType.NEW, listState); + } } }); } @@ -237,19 +282,19 @@ private void reloadPluginAdapterAndVisibility(@NonNull PluginListType pluginType switch (pluginType) { case SITE: adapter = (PluginBrowserAdapter) mSitePluginsRecycler.getAdapter(); - cardView = findViewById(R.id.installed_plugins_container); + cardView = findViewById(R.id.installed_plugins_cardview); break; case FEATURED: adapter = (PluginBrowserAdapter) mFeaturedPluginsRecycler.getAdapter(); - cardView = findViewById(R.id.featured_plugins_container); + cardView = findViewById(R.id.featured_plugins_cardview); break; case POPULAR: adapter = (PluginBrowserAdapter) mPopularPluginsRecycler.getAdapter(); - cardView = findViewById(R.id.popular_plugins_container); + cardView = findViewById(R.id.popular_plugins_cardview); break; case NEW: adapter = (PluginBrowserAdapter) mNewPluginsRecycler.getAdapter(); - cardView = findViewById(R.id.new_plugins_container); + cardView = findViewById(R.id.new_plugins_cardview); break; case SEARCH: return; @@ -287,7 +332,7 @@ public boolean onQueryTextChange(String query) { private void showListFragment(@NonNull PluginListType listType) { PluginListFragment listFragment = PluginListFragment.newInstance(mViewModel.getSite(), listType); getSupportFragmentManager().beginTransaction() - .replace(R.id.fragment_container, listFragment, PluginListFragment.TAG) + .add(R.id.fragment_container, listFragment, PluginListFragment.TAG) .addToBackStack(null) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .commit(); @@ -354,15 +399,14 @@ public long getItemId(int position) { return mItems.getItemId(position); } - @NotNull @Override - public ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) { + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = mLayoutInflater.inflate(R.layout.plugin_browser_row, parent, false); return new PluginBrowserViewHolder(view); } @Override - public void onBindViewHolder(@NotNull ViewHolder viewHolder, int position) { + public void onBindViewHolder(ViewHolder viewHolder, int position) { PluginBrowserViewHolder holder = (PluginBrowserViewHolder) viewHolder; ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); if (plugin == null) { @@ -380,28 +424,23 @@ public void onBindViewHolder(@NotNull ViewHolder viewHolder, int position) { boolean isAutoManaged = PluginUtils.isAutoManaged(mViewModel.getSite(), plugin); if (isAutoManaged) { textResId = R.string.plugin_auto_managed; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); + colorResId = R.color.success_50; drawableResId = android.R.color.transparent; } else if (PluginUtils.isUpdateAvailable(plugin)) { textResId = R.string.plugin_needs_update; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorWarningDark); + colorResId = R.color.warning_50; drawableResId = R.drawable.ic_sync_white_24dp; } else if (plugin.isActive()) { textResId = R.string.plugin_active; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); + colorResId = R.color.success_50; drawableResId = R.drawable.ic_checkmark_white_24dp; } else { textResId = R.string.plugin_inactive; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorOnSurfaceMedium); + colorResId = R.color.neutral_30; drawableResId = R.drawable.ic_cross_white_24dp; } holder.mStatusText.setText(textResId); - holder.mStatusText.setTextColor( - AppCompatResources.getColorStateList(holder.mStatusText.getContext(), colorResId)); + holder.mStatusText.setTextColor(getResources().getColor(colorResId)); holder.mStatusIcon.setVisibility(isAutoManaged ? View.GONE : View.VISIBLE); ColorUtils.INSTANCE.setImageResourceWithTint(holder.mStatusIcon, drawableResId, colorResId); holder.mStatusContainer.setVisibility(View.VISIBLE); @@ -433,15 +472,18 @@ private class PluginBrowserViewHolder extends ViewHolder { mStatusText = mStatusContainer.findViewById(R.id.plugin_status_text); mStatusIcon = mStatusContainer.findViewById(R.id.plugin_status_icon); - view.setOnClickListener(v -> { - int position = getAdapterPosition(); - ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); - if (plugin == null) { - return; + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = getAdapterPosition(); + ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); + if (plugin == null) { + return; + } + + ActivityLauncher.viewPluginDetail(PluginBrowserActivity.this, mViewModel.getSite(), + plugin.getSlug()); } - - ActivityLauncher.viewPluginDetail(PluginBrowserActivity.this, mViewModel.getSite(), - plugin.getSlug()); }); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java index 4bb164dee36a..e73a27e689f8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java @@ -4,15 +4,20 @@ import android.app.Activity; import android.app.Dialog; import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.text.Html; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.CompoundButton; +import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ImageView; import android.widget.ImageView.ScaleType; import android.widget.ProgressBar; @@ -26,6 +31,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.AppCompatButton; import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.Toolbar; @@ -33,9 +39,6 @@ import androidx.fragment.app.DialogFragment; import androidx.fragment.app.FragmentTransaction; -import com.google.android.material.appbar.CollapsingToolbarLayout; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.elevation.ElevationOverlayProvider; import com.google.android.material.snackbar.Snackbar; import org.greenrobot.eventbus.Subscribe; @@ -71,7 +74,6 @@ import org.wordpress.android.fluxc.store.SiteStore.OnPlansFetched; import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.domains.DomainRegistrationActivity.DomainRegistrationPurpose; import org.wordpress.android.ui.domains.DomainRegistrationResultFragment; @@ -84,6 +86,7 @@ import org.wordpress.android.util.DateTimeUtils; import org.wordpress.android.util.DisplayUtils; import org.wordpress.android.util.FormatUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.StringUtils; @@ -111,7 +114,7 @@ import static org.wordpress.android.ui.plans.PlanUtilsKt.isDomainCreditAvailable; import static org.wordpress.android.util.DomainRegistrationUtilsKt.requestEmailValidation; -public class PluginDetailActivity extends LocaleAwareActivity implements OnDomainRegistrationRequestedListener, +public class PluginDetailActivity extends AppCompatActivity implements OnDomainRegistrationRequestedListener, BasicDialogPositiveClickInterface { public static final String KEY_PLUGIN_SLUG = "KEY_PLUGIN_SLUG"; private static final String KEY_IS_CONFIGURING_PLUGIN = "KEY_IS_CONFIGURING_PLUGIN"; @@ -188,6 +191,11 @@ public class PluginDetailActivity extends LocaleAwareActivity implements OnDomai @Inject Dispatcher mDispatcher; @Inject ImageManager mImageManager; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -253,16 +261,6 @@ public void onCreate(Bundle savedInstanceState) { actionBar.setElevation(0); } - - CollapsingToolbarLayout collapsingToolbarLayout = findViewById(R.id.collapsing_toolbar); - ElevationOverlayProvider elevationOverlayProvider = new ElevationOverlayProvider(this); - - float appbarElevation = getResources().getDimension(R.dimen.appbar_elevation); - int elevatedColor = elevationOverlayProvider - .compositeOverlayIfNeeded(ContextExtensionsKt.getColorFromAttribute(this, R.attr.wpColorAppBar), - appbarElevation); - collapsingToolbarLayout.setContentScrimColor(elevatedColor); - mHandler = new Handler(); setupViews(); @@ -355,17 +353,24 @@ public static class DomainRegistrationPromptDialog extends DialogFragment { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(R.string.plugin_install_custom_domain_required_dialog_title); builder.setMessage(R.string.plugin_install_custom_domain_required_dialog_message); builder.setPositiveButton(R.string.plugin_install_custom_domain_required_dialog_register_btn, - (dialogInterface, i) -> { - if (isAdded() && getActivity() instanceof OnDomainRegistrationRequestedListener) { - ((OnDomainRegistrationRequestedListener) getActivity()).onDomainRegistrationRequested(); + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + if (isAdded() && getActivity() instanceof OnDomainRegistrationRequestedListener) { + ((OnDomainRegistrationRequestedListener) getActivity()).onDomainRegistrationRequested(); + } } }); builder.setNegativeButton(R.string.cancel, - (dialogInterface, i) -> { + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + } }); builder.setCancelable(true); @@ -425,7 +430,7 @@ public boolean onOptionsItemSelected(final MenuItem item) { } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); outState.putString(KEY_PLUGIN_SLUG, mSlug); @@ -465,18 +470,30 @@ private void setupViews() { mDescriptionTextView = findViewById(R.id.plugin_description_text); mDescriptionChevron = findViewById(R.id.plugin_description_chevron); - findViewById(R.id.plugin_description_container).setOnClickListener( - v -> toggleText(mDescriptionTextView, mDescriptionChevron)); + findViewById(R.id.plugin_description_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + toggleText(mDescriptionTextView, mDescriptionChevron); + } + }); mInstallationTextView = findViewById(R.id.plugin_installation_text); mInstallationChevron = findViewById(R.id.plugin_installation_chevron); - findViewById(R.id.plugin_installation_container).setOnClickListener( - v -> toggleText(mInstallationTextView, mInstallationChevron)); + findViewById(R.id.plugin_installation_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + toggleText(mInstallationTextView, mInstallationChevron); + } + }); mWhatsNewTextView = findViewById(R.id.plugin_whatsnew_text); mWhatsNewChevron = findViewById(R.id.plugin_whatsnew_chevron); - findViewById(R.id.plugin_whatsnew_container).setOnClickListener( - v -> toggleText(mWhatsNewTextView, mWhatsNewChevron)); + findViewById(R.id.plugin_whatsnew_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + toggleText(mWhatsNewTextView, mWhatsNewChevron); + } + }); // expand description if this plugin isn't installed, otherwise expand "what's new" if // this is an installed plugin and there's an update available @@ -488,56 +505,100 @@ private void setupViews() { mFaqTextView = findViewById(R.id.plugin_faq_text); mFaqChevron = findViewById(R.id.plugin_faq_chevron); - findViewById(R.id.plugin_faq_container).setOnClickListener(v -> toggleText(mFaqTextView, mFaqChevron)); + findViewById(R.id.plugin_faq_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + toggleText(mFaqTextView, mFaqChevron); + } + }); - findViewById(R.id.plugin_version_layout).setOnClickListener(v -> showPluginInfoPopup()); + findViewById(R.id.plugin_version_layout).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + showPluginInfoPopup(); + } + }); - mSwitchActive.setOnCheckedChangeListener((compoundButton, isChecked) -> { - if (compoundButton.isPressed()) { - if (NetworkUtils.checkConnection(PluginDetailActivity.this)) { - mIsActive = isChecked; - dispatchConfigurePluginAction(false); - } else { - compoundButton.setChecked(mIsActive); + mSwitchActive.setOnCheckedChangeListener(new OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { + if (compoundButton.isPressed()) { + if (NetworkUtils.checkConnection(PluginDetailActivity.this)) { + mIsActive = isChecked; + dispatchConfigurePluginAction(false); + } else { + compoundButton.setChecked(mIsActive); + } } } }); - mSwitchAutoupdates.setOnCheckedChangeListener((compoundButton, isChecked) -> { - if (compoundButton.isPressed()) { - if (NetworkUtils.checkConnection(PluginDetailActivity.this)) { - mIsAutoUpdateEnabled = isChecked; - dispatchConfigurePluginAction(false); - } else { - compoundButton.setChecked(mIsAutoUpdateEnabled); + mSwitchAutoupdates.setOnCheckedChangeListener(new OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { + if (compoundButton.isPressed()) { + if (NetworkUtils.checkConnection(PluginDetailActivity.this)) { + mIsAutoUpdateEnabled = isChecked; + dispatchConfigurePluginAction(false); + } else { + compoundButton.setChecked(mIsAutoUpdateEnabled); + } } } }); - mUpdateButton.setOnClickListener(view -> dispatchUpdatePluginAction()); + mUpdateButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dispatchUpdatePluginAction(); + } + }); - mInstallButton.setOnClickListener(v -> { - if (isCustomDomainRequired()) { - showDomainCreditsCheckProgressDialog(); - mDispatcher.dispatch(SiteActionBuilder.newFetchPlansAction(mSite)); - } else { - dispatchInstallPluginAction(); + mInstallButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (isCustomDomainRequired()) { + showDomainCreditsCheckProgressDialog(); + mDispatcher.dispatch(SiteActionBuilder.newFetchPlansAction(mSite)); + } else { + dispatchInstallPluginAction(); + } } }); View settingsView = findViewById(R.id.plugin_settings_page); if (canShowSettings()) { settingsView.setVisibility(View.VISIBLE); - settingsView.setOnClickListener(v -> openUrl(mPlugin.getSettingsUrl())); + settingsView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + openUrl(mPlugin.getSettingsUrl()); + } + }); } else { settingsView.setVisibility(View.GONE); } - findViewById(R.id.plugin_wp_org_page).setOnClickListener(view -> openUrl(getWpOrgPluginUrl())); + findViewById(R.id.plugin_wp_org_page).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + openUrl(getWpOrgPluginUrl()); + } + }); - findViewById(R.id.plugin_home_page).setOnClickListener(view -> openUrl(mPlugin.getHomepageUrl())); + findViewById(R.id.plugin_home_page).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + openUrl(mPlugin.getHomepageUrl()); + } + }); - findViewById(R.id.read_reviews_container).setOnClickListener(view -> openUrl(getWpOrgReviewsUrl())); + findViewById(R.id.read_reviews_container).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + openUrl(getWpOrgReviewsUrl()); + } + }); // set the height of the gradient scrim that appears atop the banner image int toolbarHeight = DisplayUtils.getActionBarHeight(this); @@ -601,12 +662,11 @@ private void refreshViews() { private void setCollapsibleHtmlText(@NonNull TextView textView, @Nullable String htmlText) { if (!TextUtils.isEmpty(htmlText)) { - textView.setTextColor(ContextExtensionsKt.getColorFromAttribute(this, R.attr.colorOnSurface)); + textView.setTextColor(ContextExtensionsKt.getColorFromAttribute(this, R.attr.wpColorText)); textView.setMovementMethod(WPLinkMovementMethod.getInstance()); textView.setText(Html.fromHtml(htmlText)); } else { - textView.setTextColor( - ContextExtensionsKt.getColorStateListFromAttribute(this, R.attr.wpColorOnSurfaceMedium)); + textView.setTextColor(getResources().getColor(R.color.neutral_20)); textView.setText(R.string.plugin_empty_text); } } @@ -751,9 +811,14 @@ protected void showPluginInfoPopup() { from, to); - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Calypso_Dialog_Alert); builder.setCancelable(true); - builder.setAdapter(adapter, (dialog, which) -> dialog.dismiss()); + builder.setAdapter(adapter, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); builder.show(); } @@ -780,19 +845,31 @@ protected void openUrl(@Nullable String url) { } private void confirmRemovePlugin() { - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Calypso_Dialog_Alert); builder.setTitle(getResources().getText(R.string.plugin_remove_dialog_title)); String confirmationMessage = getString(R.string.plugin_remove_dialog_message, mPlugin.getDisplayName(), SiteUtils.getSiteNameOrHomeURL(mSite)); builder.setMessage(confirmationMessage); - builder.setPositiveButton(R.string.remove, (dialogInterface, i) -> { - mIsShowingRemovePluginConfirmationDialog = false; - disableAndRemovePlugin(); + builder.setPositiveButton(R.string.remove, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + mIsShowingRemovePluginConfirmationDialog = false; + disableAndRemovePlugin(); + } + }); + builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + mIsShowingRemovePluginConfirmationDialog = false; + } + }); + builder.setOnCancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialogInterface) { + mIsShowingRemovePluginConfirmationDialog = false; + } }); - builder.setNegativeButton(R.string.cancel, - (dialogInterface, i) -> mIsShowingRemovePluginConfirmationDialog = false); - builder.setOnCancelListener(dialogInterface -> mIsShowingRemovePluginConfirmationDialog = false); builder.setCancelable(true); builder.create(); mIsShowingRemovePluginConfirmationDialog = true; @@ -823,14 +900,24 @@ private void showSuccessfulPluginRemovedSnackbar() { private void showUpdateFailedSnackbar() { WPSnackbar.make(mContainer, getString(R.string.plugin_updated_failed, mPlugin.getDisplayName()), Snackbar.LENGTH_LONG) - .setAction(R.string.retry, view -> dispatchUpdatePluginAction()) + .setAction(R.string.retry, new View.OnClickListener() { + @Override + public void onClick(View view) { + dispatchUpdatePluginAction(); + } + }) .show(); } private void showInstallFailedSnackbar() { WPSnackbar.make(mContainer, getString(R.string.plugin_installed_failed, mPlugin.getDisplayName()), Snackbar.LENGTH_LONG) - .setAction(R.string.retry, view -> dispatchInstallPluginAction()) + .setAction(R.string.retry, new View.OnClickListener() { + @Override + public void onClick(View view) { + dispatchInstallPluginAction(); + } + }) .show(); } @@ -1216,21 +1303,30 @@ private boolean isPluginStateChangedSinceLastConfigurationDispatch() { * UI for it, so we get a confirmation first in this step. */ private void confirmInstallPluginForAutomatedTransfer() { - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Calypso_Dialog_Alert); builder.setTitle(getResources().getText(R.string.plugin_install_first_plugin_confirmation_dialog_title)); builder.setMessage(R.string.plugin_install_first_plugin_confirmation_dialog_message); builder.setPositiveButton(R.string.plugin_install_first_plugin_confirmation_dialog_install_btn, - (dialogInterface, i) -> { - mIsShowingInstallFirstPluginConfirmationDialog = false; - startAutomatedTransfer(); + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + mIsShowingInstallFirstPluginConfirmationDialog = false; + startAutomatedTransfer(); + } }); - builder.setNegativeButton(R.string.cancel, (dialogInterface, i) -> { - AnalyticsUtils.trackWithSiteDetails(Stat.AUTOMATED_TRANSFER_CONFIRM_DIALOG_CANCELLED, mSite); - mIsShowingInstallFirstPluginConfirmationDialog = false; + builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + AnalyticsUtils.trackWithSiteDetails(Stat.AUTOMATED_TRANSFER_CONFIRM_DIALOG_CANCELLED, mSite); + mIsShowingInstallFirstPluginConfirmationDialog = false; + } }); - builder.setOnCancelListener(dialogInterface -> { - AnalyticsUtils.trackWithSiteDetails(Stat.AUTOMATED_TRANSFER_CONFIRM_DIALOG_CANCELLED, mSite); - mIsShowingInstallFirstPluginConfirmationDialog = false; + builder.setOnCancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialogInterface) { + AnalyticsUtils.trackWithSiteDetails(Stat.AUTOMATED_TRANSFER_CONFIRM_DIALOG_CANCELLED, mSite); + mIsShowingInstallFirstPluginConfirmationDialog = false; + } }); builder.setCancelable(true); builder.create(); @@ -1419,10 +1515,13 @@ public void onAutomatedTransferStatusChecked(OnAutomatedTransferStatusChecked ev AppLog.v(T.PLUGINS, "Automated Transfer is still in progress: " + event.currentStep + "/" + event.totalSteps); mAutomatedTransferProgressDialog.setProgress(event.currentStep * 100 / event.totalSteps); - mHandler.postDelayed(() -> { - AppLog.v(T.PLUGINS, "Checking the Automated Transfer status..."); - // Wait 3 seconds before checking the status again - mDispatcher.dispatch(SiteActionBuilder.newCheckAutomatedTransferStatusAction(mSite)); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + AppLog.v(T.PLUGINS, "Checking the Automated Transfer status..."); + // Wait 3 seconds before checking the status again + mDispatcher.dispatch(SiteActionBuilder.newCheckAutomatedTransferStatusAction(mSite)); + } }, DEFAULT_RETRY_DELAY_MS); } } @@ -1463,11 +1562,14 @@ public void onSiteChanged(OnSiteChanged event) { // the user will make after this point will not be done on the correct `SiteModel`. If we don't get the // correct site information, it's actually safer if the user force quits the app, because they will // start from the my site page and the site will be refreshed. - mHandler.postDelayed(() -> { - AppLog.v(T.PLUGINS, "Fetching the site again after Automated Transfer since the changes " - + "are not yet reflected"); - // Wait 3 seconds before fetching the site again - mDispatcher.dispatch(SiteActionBuilder.newFetchSiteAction(mSite)); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + AppLog.v(T.PLUGINS, "Fetching the site again after Automated Transfer since the changes " + + "are not yet reflected"); + // Wait 3 seconds before fetching the site again + mDispatcher.dispatch(SiteActionBuilder.newFetchSiteAction(mSite)); + } }, DEFAULT_RETRY_DELAY_MS); } } @@ -1533,9 +1635,13 @@ public void onPluginDirectoryFetched(OnPluginDirectoryFetched event) { } private void fetchPluginDirectory(int delay) { - mHandler.postDelayed( - () -> mDispatcher.dispatch(PluginActionBuilder.newFetchPluginDirectoryAction(new PluginStore - .FetchPluginDirectoryPayload(PluginDirectoryType.SITE, mSite, false))), delay); + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + mDispatcher.dispatch(PluginActionBuilder.newFetchPluginDirectoryAction(new PluginStore + .FetchPluginDirectoryPayload(PluginDirectoryType.SITE, mSite, false))); + } + }, delay); } private String getEligibilityErrorMessage(String errorCode) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginListFragment.java index 42e685d1428b..9fdcbbeaf560 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginListFragment.java @@ -16,8 +16,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; -import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; +import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; import androidx.lifecycle.ViewModelProviders; import androidx.recyclerview.widget.DiffUtil; @@ -25,7 +25,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.SiteModel; @@ -33,13 +32,13 @@ import org.wordpress.android.models.networkresource.ListState; import org.wordpress.android.ui.ActivityLauncher; import org.wordpress.android.util.ColorUtils; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.helpers.SwipeToRefreshHelper; import org.wordpress.android.util.image.ImageManager; import org.wordpress.android.util.image.ImageType; +import org.wordpress.android.util.widgets.CustomSwipeRefreshLayout; import org.wordpress.android.viewmodel.plugins.PluginBrowserViewModel; import org.wordpress.android.viewmodel.plugins.PluginBrowserViewModel.PluginListType; @@ -93,43 +92,58 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { private void setupObservers() { mViewModel.getSitePluginsLiveData() - .observe(this, listState -> { - if (mListType == PluginListType.SITE) { - refreshPluginsAndProgressBars(listState); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (mListType == PluginListType.SITE) { + refreshPluginsAndProgressBars(listState); + } } }); mViewModel.getFeaturedPluginsLiveData() - .observe(this, listState -> { - if (mListType == PluginListType.FEATURED) { - refreshPluginsAndProgressBars(listState); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (mListType == PluginListType.FEATURED) { + refreshPluginsAndProgressBars(listState); + } } }); mViewModel.getPopularPluginsLiveData() - .observe(this, listState -> { - if (mListType == PluginListType.POPULAR) { - refreshPluginsAndProgressBars(listState); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (mListType == PluginListType.POPULAR) { + refreshPluginsAndProgressBars(listState); + } } }); mViewModel.getNewPluginsLiveData() - .observe(this, listState -> { - if (mListType == PluginListType.NEW) { - refreshPluginsAndProgressBars(listState); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (mListType == PluginListType.NEW) { + refreshPluginsAndProgressBars(listState); + } } }); mViewModel.getSearchResultsLiveData() - .observe(this, listState -> { - if (mListType == PluginListType.SEARCH) { - refreshPluginsAndProgressBars(listState); + .observe(this, new Observer>() { + @Override + public void onChanged(@Nullable ListState listState) { + if (mListType == PluginListType.SEARCH) { + refreshPluginsAndProgressBars(listState); - if (listState instanceof ListState.Error) { - ToastUtils.showToast(getActivity(), R.string.plugin_search_error); - } + if (listState instanceof ListState.Error) { + ToastUtils.showToast(getActivity(), R.string.plugin_search_error); + } - showEmptyView(mViewModel.shouldShowEmptySearchResultsView()); + showEmptyView(mViewModel.shouldShowEmptySearchResultsView()); + } } }); } @@ -143,24 +157,27 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mRecycler.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL)); mSwipeToRefreshHelper = buildSwipeToRefreshHelper( - view.findViewById(R.id.ptr_layout), - () -> { - if (NetworkUtils.checkConnection(getActivity())) { - mViewModel.pullToRefresh(mListType); - } else { - mSwipeToRefreshHelper.setRefreshing(false); + (CustomSwipeRefreshLayout) view.findViewById(R.id.ptr_layout), + new SwipeToRefreshHelper.RefreshListener() { + @Override + public void onRefreshStarted() { + if (NetworkUtils.checkConnection(getActivity())) { + mViewModel.pullToRefresh(mListType); + } else { + mSwipeToRefreshHelper.setRefreshing(false); + } } }); return view; } @Override - public void onCreateOptionsMenu(Menu menu, @NotNull MenuInflater inflater) { + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); super.onCreateOptionsMenu(menu, inflater); } - PluginListType getListType() { + public PluginListType getListType() { return mListType; } @@ -226,15 +243,14 @@ public int getItemCount() { return mItems.size(); } - @NotNull @Override - public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) { + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = mLayoutInflater.inflate(R.layout.plugin_list_row, parent, false); return new PluginViewHolder(view); } @Override - public void onBindViewHolder(@NotNull RecyclerView.ViewHolder viewHolder, int position) { + public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); if (plugin == null) { return; @@ -251,29 +267,24 @@ public void onBindViewHolder(@NotNull RecyclerView.ViewHolder viewHolder, int po @DrawableRes int drawableResId; if (PluginUtils.isAutoManaged(mViewModel.getSite(), plugin)) { textResId = R.string.plugin_auto_managed; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); + colorResId = R.color.success_50; drawableResId = android.R.color.transparent; } else if (PluginUtils.isUpdateAvailable(plugin)) { textResId = R.string.plugin_needs_update; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorWarningDark); + colorResId = R.color.warning_50; drawableResId = R.drawable.ic_sync_white_24dp; } else if (plugin.isActive()) { textResId = R.string.plugin_active; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); + colorResId = R.color.success_50; drawableResId = R.drawable.ic_checkmark_white_24dp; } else { textResId = R.string.plugin_inactive; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorOnSurfaceMedium); + colorResId = R.color.neutral_30; drawableResId = R.drawable.ic_cross_white_24dp; } - + int color = getResources().getColor(colorResId); holder.mStatusText.setText(textResId); - holder.mStatusText.setTextColor( - AppCompatResources.getColorStateList(holder.mStatusText.getContext(), colorResId)); + holder.mStatusText.setTextColor(color); ColorUtils.INSTANCE.setImageResourceWithTint(holder.mStatusIcon, drawableResId, colorResId); holder.mStatusText.setVisibility(View.VISIBLE); holder.mStatusIcon.setVisibility(View.VISIBLE); @@ -307,15 +318,18 @@ private class PluginViewHolder extends RecyclerView.ViewHolder { mIcon = view.findViewById(R.id.plugin_icon); mRatingBar = view.findViewById(R.id.rating_bar); - view.setOnClickListener(v -> { - int position = getAdapterPosition(); - ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); - if (plugin == null) { - return; + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + int position = getAdapterPosition(); + ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); + if (plugin == null) { + return; + } + + ActivityLauncher.viewPluginDetail(getActivity(), mViewModel.getSite(), + plugin.getSlug()); } - - ActivityLauncher.viewPluginDetail(getActivity(), mViewModel.getSite(), - plugin.getSlug()); }); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginUtils.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginUtils.java index 90de4fdc97da..51afcdf8ce8d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginUtils.java @@ -57,11 +57,11 @@ static boolean isUpdateAvailable(@Nullable ImmutablePluginModel immutablePlugin) } } - static boolean isJetpack(@NonNull ImmutablePluginModel plugin) { + public static boolean isJetpack(@NonNull ImmutablePluginModel plugin) { return StringUtils.equals(plugin.getName(), JETPACK_PLUGIN_NAME); } - static boolean isAutoManaged(@NonNull SiteModel site, @NonNull ImmutablePluginModel plugin) { + public static boolean isAutoManaged(@NonNull SiteModel site, @NonNull ImmutablePluginModel plugin) { if (!site.isAutomatedTransfer()) { return false; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.java index a3b285b40f90..fa5cb2769dca 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/AddCategoryFragment.java @@ -3,6 +3,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; @@ -12,8 +13,6 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatDialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.model.SiteModel; @@ -48,7 +47,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { initSite(savedInstanceState); - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/BasicFragmentDialog.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/BasicFragmentDialog.kt index 4b83d019e6ef..4d074c6b21f7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/BasicFragmentDialog.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/BasicFragmentDialog.kt @@ -4,8 +4,10 @@ import android.app.Dialog import android.content.Context import android.content.DialogInterface import android.os.Bundle +import android.view.ContextThemeWrapper +import androidx.appcompat.app.AlertDialog.Builder import androidx.appcompat.app.AppCompatDialogFragment -import com.google.android.material.dialog.MaterialAlertDialogBuilder +import org.wordpress.android.R /** * Basic dialog fragment with support for 1,2 or 3 buttons. @@ -76,7 +78,7 @@ class BasicFragmentDialog : AppCompatDialogFragment() { } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - val builder = MaterialAlertDialogBuilder(activity) + val builder = Builder(ContextThemeWrapper(activity, R.style.Calypso_Dialog_Alert)) builder.setMessage(mMessage) .setPositiveButton(mPositiveButtonLabel) { _, _ -> dismissedByPositiveButton = true @@ -111,7 +113,7 @@ class BasicFragmentDialog : AppCompatDialogFragment() { return builder.create() } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) if (activity !is BasicDialogPositiveClickInterface) { throw RuntimeException("Hosting activity must implement BasicDialogPositiveClickInterface") @@ -121,7 +123,7 @@ class BasicFragmentDialog : AppCompatDialogFragment() { } } - override fun onDismiss(dialog: DialogInterface) { + override fun onDismiss(dialog: DialogInterface?) { val activity = activity if (activity != null && activity is BasicDialogOnDismissByOutsideTouchInterface) { // Only handle the event if it wasn't triggered by a button diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/CategoryArrayAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/CategoryArrayAdapter.java index 165c55189866..d4424ac77d2d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/CategoryArrayAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/CategoryArrayAdapter.java @@ -14,6 +14,7 @@ import org.apache.commons.text.StringEscapeUtils; import org.wordpress.android.R; import org.wordpress.android.models.CategoryNode; +import org.wordpress.android.util.DisplayUtils; import java.util.List; @@ -39,15 +40,10 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup ViewHolder viewHolder = (ViewHolder) rowView.getTag(); CategoryNode node = getItem(position); if (node != null) { - int verticalPadding = rowView.getResources().getDimensionPixelOffset(R.dimen.margin_large); - int horizontalPadding = rowView.getResources().getDimensionPixelOffset(R.dimen.margin_extra_large); - viewHolder.mCategoryRowText.setText(StringEscapeUtils.unescapeHtml4(node.getName())); ViewCompat.setPaddingRelative(viewHolder.mCategoryRowText, - horizontalPadding * node.getLevel(), - verticalPadding, - horizontalPadding, - verticalPadding); + DisplayUtils.dpToPx(getContext(), 16) * node.getLevel(), 0, + DisplayUtils.dpToPx(getContext(), 16), 0); } return rowView; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index ff8977897e18..eead47256b5e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.app.ProgressDialog; import android.content.ClipData; +import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.graphics.drawable.Drawable; @@ -27,7 +28,7 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback; import androidx.core.util.Consumer; import androidx.fragment.app.Fragment; @@ -95,7 +96,6 @@ import org.wordpress.android.fluxc.tools.FluxCImageLoader; import org.wordpress.android.ui.ActivityId; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.PagePostCreationSourcesDetail; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.Shortcut; @@ -194,7 +194,7 @@ import kotlin.Unit; import kotlin.jvm.functions.Function0; -public class EditPostActivity extends LocaleAwareActivity implements +public class EditPostActivity extends AppCompatActivity implements EditorFragmentActivity, EditorImageSettingsListener, EditorImagePreviewListener, @@ -333,6 +333,11 @@ public static boolean checkToRestart(@NonNull Intent data) { != RestartEditorOptions.NO_RESTART; } + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + private void newPostSetup() { mIsNewPost = true; @@ -404,8 +409,6 @@ protected void onCreate(Bundle savedInstanceState) { } // Set up the action bar. - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); @@ -541,12 +544,6 @@ protected void onCreate(Bundle savedInstanceState) { setTitle(SiteUtils.getSiteNameOrHomeURL(mSite)); mSectionsPagerAdapter = new SectionsPagerAdapter(fragmentManager); - setupViewPager(); - - ActivityId.trackLastActivity(ActivityId.POST_EDITOR); - } - - private void setupViewPager() { // Set up the ViewPager with the sections adapter. mViewPager = findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); @@ -574,6 +571,8 @@ public void onPageSelected(int position) { } } }); + + ActivityId.trackLastActivity(ActivityId.POST_EDITOR); } private void startObserving() { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostSettingsFragment.java index 2cf5a14771a6..5e1cd3e06416 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostSettingsFragment.java @@ -24,6 +24,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.view.menu.MenuPopupHelper; import androidx.appcompat.widget.PopupMenu; +import androidx.cardview.widget.CardView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; @@ -275,6 +276,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c mFeaturedImageRetryOverlay = rootView.findViewById(R.id.post_featured_image_retry_overlay); mFeaturedImageProgressOverlay = rootView.findViewById(R.id.post_featured_image_progress_overlay); + final CardView featuredImageCardView = rootView.findViewById(R.id.post_featured_image_card_view); + OnClickListener showContextMenuListener = new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/HistoryListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/HistoryListFragment.kt index befe8417091d..99a425496ea3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/HistoryListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/HistoryListFragment.kt @@ -64,7 +64,7 @@ class HistoryListFragment : Fragment() { viewModel = ViewModelProviders.of(this, viewModelFactory).get(HistoryViewModel::class.java) } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) check(activity is HistoryItemClickInterface) { "Parent activity has to implement HistoryItemClickInterface" diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostDatePickerDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostDatePickerDialogFragment.kt index de3239844384..f96ff69cbab4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostDatePickerDialogFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostDatePickerDialogFragment.kt @@ -5,6 +5,7 @@ import android.app.Dialog import android.content.Context import android.content.DialogInterface import android.os.Bundle +import android.view.ContextThemeWrapper import androidx.fragment.app.DialogFragment import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProviders @@ -20,7 +21,8 @@ class PostDatePickerDialogFragment : DialogFragment() { viewModel = ViewModelProviders.of(activity!!, viewModelFactory) .get(EditPostPublishSettingsViewModel::class.java) - val datePickerDialog = DatePickerDialog(activity, + val datePickerDialog = DatePickerDialog( + ContextThemeWrapper(activity, R.style.Calypso_Dialog), null, viewModel.year ?: 0, viewModel.month ?: 0, @@ -49,7 +51,7 @@ class PostDatePickerDialogFragment : DialogFragment() { return datePickerDialog } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) (activity!!.applicationContext as WordPress).component().inject(this) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListFragment.kt index 013ba828764a..77a9d44c5331 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListFragment.kt @@ -38,6 +38,7 @@ import org.wordpress.android.viewmodel.posts.PostListViewModel import org.wordpress.android.widgets.RecyclerItemDecoration import javax.inject.Inject +private const val EXTRA_POST_LIST_AUTHOR_FILTER = "post_list_author_filter" private const val EXTRA_POST_LIST_TYPE = "post_list_type" private const val MAX_INDEX_FOR_VISIBLE_ITEM_TO_KEEP_SCROLL_POSITION = 2 diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewState.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewState.kt index caaa5d23a9c4..c3d80e20a831 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewState.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostListMainViewState.kt @@ -1,5 +1,6 @@ package org.wordpress.android.ui.posts +import androidx.annotation.ColorRes import androidx.annotation.DrawableRes import org.wordpress.android.R import org.wordpress.android.ui.posts.AuthorFilterSelection.EVERYONE @@ -29,20 +30,20 @@ sealed class PostListViewLayoutTypeMenuUiState(@DrawableRes val iconRes: Int, va sealed class AuthorFilterListItemUIState( val id: Long, val text: UiString, - open val isSelected: Boolean + @ColorRes open val dropDownBackground: Int ) { - data class Everyone(override val isSelected: Boolean, @DrawableRes val imageRes: Int) : + data class Everyone(@ColorRes override val dropDownBackground: Int, @DrawableRes val imageRes: Int) : AuthorFilterListItemUIState( - id = EVERYONE.id, + id = AuthorFilterSelection.EVERYONE.id, text = UiStringRes(R.string.post_list_author_everyone), - isSelected = isSelected + dropDownBackground = dropDownBackground ) - data class Me(val avatarUrl: String?, override val isSelected: Boolean) : + data class Me(val avatarUrl: String?, @ColorRes override val dropDownBackground: Int) : AuthorFilterListItemUIState( - id = ME.id, + id = AuthorFilterSelection.ME.id, text = UiStringRes(R.string.post_list_author_me), - isSelected = isSelected + dropDownBackground = dropDownBackground ) } @@ -51,10 +52,14 @@ fun getAuthorFilterItems( avatarUrl: String? ): List { return AuthorFilterSelection.values().map { value -> + @ColorRes val backgroundColorRes: Int = + if (selection == value) R.color.grey_lighten_30_translucent_50 + else R.color.transparent + when (value) { - ME -> AuthorFilterListItemUIState.Me(avatarUrl, selection == value) + ME -> AuthorFilterListItemUIState.Me(avatarUrl, backgroundColorRes) EVERYONE -> AuthorFilterListItemUIState.Everyone( - selection == value, + backgroundColorRes, R.drawable.bg_oval_neutral_30_multiple_users_white_40dp ) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostNotificationScheduleTimeDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostNotificationScheduleTimeDialogFragment.kt index b415cf0cc838..7fbca3991d55 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostNotificationScheduleTimeDialogFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostNotificationScheduleTimeDialogFragment.kt @@ -61,7 +61,7 @@ class PostNotificationScheduleTimeDialogFragment : DialogFragment() { } } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) (activity!!.applicationContext as WordPress).component().inject(this) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsInputDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsInputDialogFragment.java index c9573849a905..7ddd8c35bbd3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsInputDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsInputDialogFragment.java @@ -6,6 +6,7 @@ import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; @@ -14,9 +15,6 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.textfield.TextInputLayout; - import org.wordpress.android.R; import org.wordpress.android.util.ActivityUtils; @@ -81,25 +79,23 @@ public void onDismiss(DialogInterface dialog) { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); LayoutInflater layoutInflater = LayoutInflater.from(getActivity()); //noinspection InflateParams View dialogView = layoutInflater.inflate(R.layout.post_settings_input_dialog, null); builder.setView(dialogView); - final EditText editText = dialogView.findViewById(R.id.post_settings_input_dialog_edit_text); + final EditText editText = (EditText) dialogView.findViewById(R.id.post_settings_input_dialog_edit_text); if (!TextUtils.isEmpty(mCurrentInput)) { editText.setText(mCurrentInput); // move the cursor to the end editText.setSelection(mCurrentInput.length()); } editText.addTextChangedListener(this); - - TextInputLayout textInputLayout = dialogView.findViewById(R.id.post_settings_input_dialog_input_layout); - textInputLayout.setHint(mTitle); - - TextView hintTextView = dialogView.findViewById(R.id.post_settings_input_dialog_hint); + TextView hintTextView = (TextView) dialogView.findViewById(R.id.post_settings_input_dialog_hint); hintTextView.setText(mHint); + builder.setTitle(mTitle); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsListDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsListDialogFragment.java index f2be8f084059..fdf2d5c735f4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsListDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsListDialogFragment.java @@ -4,6 +4,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.widget.ListView; import androidx.annotation.NonNull; @@ -11,8 +12,6 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.R; import org.wordpress.android.util.AppLog; @@ -71,7 +70,8 @@ public void onAttach(Activity activity) { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java index 5a0faaeceed0..e464c2e1a1f1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java @@ -18,7 +18,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -32,8 +32,8 @@ import org.wordpress.android.fluxc.model.TermModel; import org.wordpress.android.fluxc.store.TaxonomyStore; import org.wordpress.android.fluxc.store.TaxonomyStore.OnTaxonomyChanged; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.ActivityUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.ToastUtils; import java.util.ArrayList; @@ -42,7 +42,7 @@ import javax.inject.Inject; -public class PostSettingsTagsActivity extends LocaleAwareActivity implements TextWatcher, View.OnKeyListener { +public class PostSettingsTagsActivity extends AppCompatActivity implements TextWatcher, View.OnKeyListener { public static final String KEY_TAGS = "KEY_TAGS"; public static final String KEY_SELECTED_TAGS = "KEY_SELECTED_TAGS"; private SiteModel mSite; @@ -53,6 +53,11 @@ public class PostSettingsTagsActivity extends LocaleAwareActivity implements Tex @Inject Dispatcher mDispatcher; @Inject TaxonomyStore mTaxonomyStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -73,8 +78,6 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.post_settings_tags_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostTimePickerDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostTimePickerDialogFragment.kt index 747ca53605c3..d52f9c82cf48 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostTimePickerDialogFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostTimePickerDialogFragment.kt @@ -6,9 +6,11 @@ import android.app.TimePickerDialog.OnTimeSetListener import android.content.Context import android.os.Bundle import android.text.format.DateFormat +import android.view.ContextThemeWrapper import androidx.fragment.app.DialogFragment import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProviders +import org.wordpress.android.R.style import org.wordpress.android.WordPress import javax.inject.Inject @@ -21,7 +23,8 @@ class PostTimePickerDialogFragment : DialogFragment() { .get(EditPostPublishSettingsViewModel::class.java) val is24HrFormat = DateFormat.is24HourFormat(activity) - val timePickerDialog = TimePickerDialog(activity, + val timePickerDialog = TimePickerDialog( + ContextThemeWrapper(activity, style.Calypso_Dialog_Alert), OnTimeSetListener { _, selectedHour, selectedMinute -> viewModel.onTimeSelected(selectedHour, selectedMinute) }, @@ -32,7 +35,7 @@ class PostTimePickerDialogFragment : DialogFragment() { return timePickerDialog } - override fun onAttach(context: Context) { + override fun onAttach(context: Context?) { super.onAttach(context) (activity!!.applicationContext as WordPress).component().inject(this) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.kt index ebfab3643823..e1a7d0073a15 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.kt @@ -1,11 +1,9 @@ package org.wordpress.android.ui.posts -import android.R.color import android.app.Activity import android.app.ProgressDialog +import android.content.Context import android.content.Intent -import android.graphics.drawable.GradientDrawable -import android.graphics.drawable.GradientDrawable.Orientation import android.os.Bundle import android.view.HapticFeedbackConstants import android.view.Menu @@ -16,15 +14,14 @@ import android.view.View.OnClickListener import android.widget.AdapterView import android.widget.Toast import androidx.annotation.DrawableRes +import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.AppCompatSpinner import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.Toolbar -import androidx.core.content.ContextCompat import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProviders import androidx.viewpager.widget.ViewPager.OnPageChangeListener -import com.google.android.material.elevation.ElevationOverlayProvider import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.snackbar.Snackbar import com.google.android.material.tabs.TabLayout @@ -40,7 +37,6 @@ import org.wordpress.android.fluxc.store.QuickStartStore.QuickStartTask import org.wordpress.android.fluxc.store.SiteStore import org.wordpress.android.ui.ActivityId import org.wordpress.android.ui.ActivityLauncher -import org.wordpress.android.ui.LocaleAwareActivity import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogNegativeClickInterface @@ -55,11 +51,10 @@ import org.wordpress.android.ui.utils.UiHelpers import org.wordpress.android.ui.utils.UiString import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.AppLog +import org.wordpress.android.util.LocaleManager import org.wordpress.android.util.QuickStartUtils -import org.wordpress.android.util.RtlUtils -import org.wordpress.android.util.SnackbarItem import org.wordpress.android.util.SnackbarSequencer -import org.wordpress.android.util.getColorFromAttribute +import org.wordpress.android.util.SnackbarItem import org.wordpress.android.util.redirectContextClickToLongPressListener import org.wordpress.android.widgets.WPDialogSnackbar import javax.inject.Inject @@ -67,7 +62,7 @@ import javax.inject.Inject const val EXTRA_TARGET_POST_LOCAL_ID = "targetPostLocalId" const val STATE_KEY_PREVIEW_STATE = "stateKeyPreviewState" -class PostsListActivity : LocaleAwareActivity(), +class PostsListActivity : AppCompatActivity(), BasicDialogPositiveClickInterface, BasicDialogNegativeClickInterface, BasicDialogOnDismissByOutsideTouchInterface { @@ -114,6 +109,10 @@ class PostsListActivity : LocaleAwareActivity(), override fun onPageScrollStateChanged(state: Int) {} } + override fun attachBaseContext(newBase: Context) { + super.attachBaseContext(LocaleManager.setLocale(newBase)) + } + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) if (!intent.hasExtra(WordPress.SITE)) { @@ -171,25 +170,7 @@ class PostsListActivity : LocaleAwareActivity(), private fun setupContent() { authorSelection = findViewById(R.id.post_list_author_selection) - - val elevationOverlayProvider = ElevationOverlayProvider(this) - val appbarElevation = resources.getDimension(R.dimen.appbar_elevation) - val appBarColor = elevationOverlayProvider.compositeOverlayIfNeeded( - this.getColorFromAttribute(R.attr.wpColorAppBar), - appbarElevation - ) - - val fadingEdgeDrawable = GradientDrawable( - if (RtlUtils.isRtl(this)) { - Orientation.LEFT_RIGHT - } else { - Orientation.RIGHT_LEFT - }, - intArrayOf(ContextCompat.getColor(this, color.transparent), appBarColor) - ) - tabLayoutFadingEdge = findViewById(R.id.post_list_tab_layout_fading_edge) - tabLayoutFadingEdge.background = fadingEdgeDrawable authorSelectionAdapter = AuthorSelectionAdapter(this) authorSelection.adapter = authorSelectionAdapter diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java index f71f0af6dcaf..db24101272f7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui.posts; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.LongSparseArray; @@ -11,7 +12,7 @@ import android.widget.TextView; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -31,7 +32,7 @@ import org.wordpress.android.fluxc.store.TaxonomyStore.OnTermUploaded; import org.wordpress.android.fluxc.store.TaxonomyStore.RemoteTermPayload; import org.wordpress.android.models.CategoryNode; -import org.wordpress.android.ui.LocaleAwareActivity; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.ToastUtils.Duration; @@ -48,7 +49,7 @@ import static org.wordpress.android.ui.posts.EditPostActivity.EXTRA_POST_LOCAL_ID; import static org.wordpress.android.util.WPSwipeToRefreshHelper.buildSwipeToRefreshHelper; -public class SelectCategoriesActivity extends LocaleAwareActivity { +public class SelectCategoriesActivity extends AppCompatActivity { public static final String KEY_SELECTED_CATEGORY_IDS = "KEY_SELECTED_CATEGORY_IDS"; private ListView mListView; @@ -65,6 +66,11 @@ public class SelectCategoriesActivity extends LocaleAwareActivity { @Inject TaxonomyStore mTaxonomyStore; @Inject Dispatcher mDispatcher; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -83,17 +89,14 @@ public void onCreate(Bundle savedInstanceState) { } setContentView(R.layout.select_categories); + setTitle(getResources().getString(R.string.select_categories)); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } - setTitle(getResources().getString(R.string.select_categories)); - mListView = (ListView) findViewById(android.R.id.list); mListScrollPositionManager = new ListScrollPositionManager(mListView, false); mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/adapters/AuthorSelectionAdapter.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/adapters/AuthorSelectionAdapter.kt index cf4f5a383eed..5a000163413c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/adapters/AuthorSelectionAdapter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/adapters/AuthorSelectionAdapter.kt @@ -8,15 +8,13 @@ import android.widget.BaseAdapter import androidx.annotation.CallSuper import androidx.appcompat.widget.AppCompatImageView import androidx.appcompat.widget.AppCompatTextView -import androidx.core.graphics.ColorUtils -import com.google.android.material.elevation.ElevationOverlayProvider +import androidx.core.content.ContextCompat import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.ui.posts.AuthorFilterListItemUIState import org.wordpress.android.ui.posts.AuthorFilterSelection import org.wordpress.android.ui.utils.UiHelpers import org.wordpress.android.util.GravatarUtils -import org.wordpress.android.util.getColorFromAttribute import org.wordpress.android.util.image.ImageManager import org.wordpress.android.util.image.ImageType.NO_PLACEHOLDER import javax.inject.Inject @@ -95,11 +93,7 @@ class AuthorSelectionAdapter(context: Context) : BaseAdapter() { protected val image: AppCompatImageView = itemView.findViewById(R.id.post_list_author_selection_image) @CallSuper - open fun bind( - state: AuthorFilterListItemUIState, - imageManager: ImageManager, - uiHelpers: UiHelpers - ) { + open fun bind(state: AuthorFilterListItemUIState, imageManager: ImageManager, uiHelpers: UiHelpers) { /** * We can't use error/placeholder drawables as it causes an issue described here * https://github.com/wordpress-mobile/WordPress-Android/issues/9745. @@ -128,33 +122,11 @@ class AuthorSelectionAdapter(context: Context) : BaseAdapter() { private class DropdownViewHolder(itemView: View) : NormalViewHolder(itemView) { private val text: AppCompatTextView = itemView.findViewById(R.id.post_list_author_selection_text) - override fun bind( - state: AuthorFilterListItemUIState, - imageManager: ImageManager, - uiHelpers: UiHelpers - ) { + override fun bind(state: AuthorFilterListItemUIState, imageManager: ImageManager, uiHelpers: UiHelpers) { super.bind(state, imageManager, uiHelpers) val context = itemView.context - - // Because it's a custom popup list we need to manage colors of list items manually - val elevationOverlayProvider = ElevationOverlayProvider(context) - val appbarElevation = context.resources.getDimension(R.dimen.appbar_elevation) - val elevatedSurfaceColor = elevationOverlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded( - appbarElevation - ) - - val selectedColor = ColorUtils - .setAlphaComponent( - context.getColorFromAttribute(R.attr.colorOnSurface), - context.resources.getInteger(R.integer.custom_popup_selected_list_item_opacity_dec) - ) - text.text = uiHelpers.getTextOfUiString(context, state.text) - if (state.isSelected) { - itemView.setBackgroundColor(selectedColor) - } else { - itemView.setBackgroundColor(elevatedSurfaceColor) - } + itemView.setBackgroundColor(ContextCompat.getColor(context, state.dropDownBackground)) } } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AboutActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AboutActivity.java index 67e1554581c2..0b6e82a5f313 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AboutActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AboutActivity.java @@ -1,23 +1,30 @@ package org.wordpress.android.ui.prefs; +import android.content.Context; import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import org.wordpress.android.Constants; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.WPUrlUtils; import org.wordpress.android.widgets.WPTextView; import java.util.Calendar; -public class AboutActivity extends LocaleAwareActivity implements OnClickListener { +public class AboutActivity extends AppCompatActivity implements OnClickListener { + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); @@ -29,14 +36,15 @@ public void onCreate(Bundle icicle) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); + getSupportActionBar().setElevation(0); WPTextView version = findViewById(R.id.about_version); version.setText(getString(R.string.version_with_name_param, WordPress.versionName)); - View tos = findViewById(R.id.about_tos); + WPTextView tos = findViewById(R.id.about_tos); tos.setOnClickListener(this); - View pp = findViewById(R.id.about_privacy); + WPTextView pp = findViewById(R.id.about_privacy); pp.setOnClickListener(this); WPTextView publisher = findViewById(R.id.about_publisher); @@ -47,7 +55,7 @@ public void onCreate(Bundle icicle) { getString(R.string.copyright_with_year_and_company_params, Calendar.getInstance().get(Calendar.YEAR), getString(R.string.automattic_inc))); - View about = findViewById(R.id.about_url); + WPTextView about = findViewById(R.id.about_url); about.setOnClickListener(this); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java index c5b9fb9d979a..d471188e8987 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java @@ -1,36 +1,52 @@ package org.wordpress.android.ui.prefs; +import android.app.FragmentManager; +import android.content.Context; import android.os.Bundle; import android.view.MenuItem; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.R; -import org.wordpress.android.ui.LocaleAwareActivity; +import org.wordpress.android.util.LocaleManager; + +public class AccountSettingsActivity extends AppCompatActivity { + private static final String KEY_ACCOUNT_SETTINGS_FRAGMENT = "account-settings-fragment"; + + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } -public class AccountSettingsActivity extends LocaleAwareActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.account_settings_activity); - - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.account_settings); } + + FragmentManager fragmentManager = getFragmentManager(); + AccountSettingsFragment accountSettingsFragment = + (AccountSettingsFragment) fragmentManager.findFragmentByTag(KEY_ACCOUNT_SETTINGS_FRAGMENT); + if (accountSettingsFragment == null) { + accountSettingsFragment = new AccountSettingsFragment(); + + fragmentManager.beginTransaction() + .add(android.R.id.content, accountSettingsFragment, KEY_ACCOUNT_SETTINGS_FRAGMENT) + .commit(); + } } @Override public boolean onOptionsItemSelected(final MenuItem item) { - if (item.getItemId() == android.R.id.home) { - onBackPressed(); - return true; + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; } return super.onOptionsItemSelected(item); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsFragment.java index 90ebbe1886d9..8b02ac8304e5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsFragment.java @@ -1,6 +1,5 @@ package org.wordpress.android.ui.prefs; -import android.annotation.SuppressLint; import android.app.ProgressDialog; import android.os.AsyncTask; import android.os.Bundle; @@ -20,7 +19,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.coordinatorlayout.widget.CoordinatorLayout; -import com.google.android.material.snackbar.BaseTransientBottomBar; import com.google.android.material.snackbar.Snackbar; import org.greenrobot.eventbus.Subscribe; @@ -214,8 +212,6 @@ private void checkIfEmailChangeIsPending() { mEmailPreference.setEnabled(!account.getPendingEmailChange()); } - // BaseTransientBottomBar.LENGTH_LONG is pointing to Snackabr.LENGTH_LONG which confuses checkstyle - @SuppressLint("WrongConstant") private void showPendingEmailChangeSnackbar(String newEmail) { if (getView() != null) { if (mEmailSnackbar == null || !mEmailSnackbar.isShown()) { @@ -227,7 +223,7 @@ public void onClick(View v) { }; mEmailSnackbar = Snackbar - .make(getView(), "", BaseTransientBottomBar.LENGTH_INDEFINITE) + .make(getView(), "", Snackbar.LENGTH_INDEFINITE) .setAction(getString(R.string.button_discard), clickListener); TextView textView = mEmailSnackbar.getView().findViewById(com.google.android.material.R.id.snackbar_text); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsActivity.java index 666d851c3eea..14ddf0c729f7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsActivity.java @@ -1,47 +1,54 @@ package org.wordpress.android.ui.prefs; -import android.content.Intent; +import android.app.FragmentManager; +import android.content.Context; import android.os.Bundle; import android.view.MenuItem; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import org.wordpress.android.R; -import org.wordpress.android.ui.LocaleAwareActivity; +import org.wordpress.android.util.LocaleManager; + +public class AppSettingsActivity extends AppCompatActivity { + private static final String KEY_APP_SETTINGS_FRAGMENT = "app-settings-fragment"; + + private AppSettingsFragment mAppSettingsFragment; + + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } -public class AppSettingsActivity extends LocaleAwareActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.app_settings_activity); - - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.me_btn_app_settings); } + + FragmentManager fragmentManager = getFragmentManager(); + mAppSettingsFragment = (AppSettingsFragment) fragmentManager.findFragmentByTag(KEY_APP_SETTINGS_FRAGMENT); + if (mAppSettingsFragment == null) { + mAppSettingsFragment = new AppSettingsFragment(); + + fragmentManager.beginTransaction() + .add(android.R.id.content, mAppSettingsFragment, KEY_APP_SETTINGS_FRAGMENT) + .commit(); + } } @Override public boolean onOptionsItemSelected(final MenuItem item) { - if (item.getItemId() == android.R.id.home) { - onBackPressed(); - return true; + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; } return super.onOptionsItemSelected(item); } - - @Override - public void recreate() { - Intent intent = new Intent(AppSettingsActivity.this, AppSettingsActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - finish(); - } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java index 5651450c8b8a..f111cdbb8e22 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java @@ -5,7 +5,6 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceCategory; @@ -32,7 +31,6 @@ import org.wordpress.android.ui.reader.services.update.ReaderUpdateLogic; import org.wordpress.android.ui.reader.services.update.ReaderUpdateServiceStarter; import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.AppThemeUtils; import org.wordpress.android.util.CrashLoggingUtils; import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; @@ -54,7 +52,6 @@ public class AppSettingsFragment extends PreferenceFragment public static final int LANGUAGE_CHANGED = 1000; private DetailListPreference mLanguagePreference; - private ListPreference mAppThemePreference; // This Device settings private WPSwitchPreference mOptimizedImage; @@ -77,7 +74,6 @@ public void onCreate(Bundle savedInstanceState) { ((WordPress) getActivity().getApplication()).component().inject(this); setRetainInstance(true); - addPreferencesFromResource(R.xml.app_settings); findPreference(getString(R.string.pref_key_send_usage)).setOnPreferenceChangeListener( @@ -106,9 +102,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { mLanguagePreference = (DetailListPreference) findPreference(getString(R.string.pref_key_language)); mLanguagePreference.setOnPreferenceChangeListener(this); - mAppThemePreference = (ListPreference) findPreference(getString(R.string.pref_key_app_theme)); - mAppThemePreference.setOnPreferenceChangeListener(this); - findPreference(getString(R.string.pref_key_language)) .setOnPreferenceClickListener(this); findPreference(getString(R.string.pref_key_device_settings)) @@ -146,19 +139,19 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { // Set Local settings mOptimizedImage.setChecked(AppPrefs.isImageOptimize()); setDetailListPreferenceValue(mImageMaxSizePref, - String.valueOf(AppPrefs.getImageOptimizeMaxSize()), - getLabelForImageMaxSizeValue(AppPrefs.getImageOptimizeMaxSize())); + String.valueOf(AppPrefs.getImageOptimizeMaxSize()), + getLabelForImageMaxSizeValue(AppPrefs.getImageOptimizeMaxSize())); setDetailListPreferenceValue(mImageQualityPref, - String.valueOf(AppPrefs.getImageOptimizeQuality()), - getLabelForImageQualityValue(AppPrefs.getImageOptimizeQuality())); + String.valueOf(AppPrefs.getImageOptimizeQuality()), + getLabelForImageQualityValue(AppPrefs.getImageOptimizeQuality())); mOptimizedVideo.setChecked(AppPrefs.isVideoOptimize()); setDetailListPreferenceValue(mVideoWidthPref, - String.valueOf(AppPrefs.getVideoOptimizeWidth()), - getLabelForVideoMaxWidthValue(AppPrefs.getVideoOptimizeWidth())); + String.valueOf(AppPrefs.getVideoOptimizeWidth()), + getLabelForVideoMaxWidthValue(AppPrefs.getVideoOptimizeWidth())); setDetailListPreferenceValue(mVideoEncorderBitratePref, - String.valueOf(AppPrefs.getVideoOptimizeQuality()), - getLabelForVideoEncoderBitrateValue(AppPrefs.getVideoOptimizeQuality())); + String.valueOf(AppPrefs.getVideoOptimizeQuality()), + getLabelForVideoEncoderBitrateValue(AppPrefs.getVideoOptimizeQuality())); mStripImageLocation.setChecked(AppPrefs.isStripImageLocation()); @@ -237,8 +230,8 @@ private void updateAnalyticsSyncUI() { return; } if (mAccountStore.hasAccessToken()) { - SwitchPreference tracksOptOutPreference = - (SwitchPreference) findPreference(getString(R.string.pref_key_send_usage)); + SwitchPreference tracksOptOutPreference = + (SwitchPreference) findPreference(getString(R.string.pref_key_send_usage)); tracksOptOutPreference.setChecked(!mAccountStore.getAccount().getTracksOptOut()); } } @@ -279,13 +272,13 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { int newWidth = Integer.parseInt(newValue.toString()); AppPrefs.setImageOptimizeMaxSize(newWidth); setDetailListPreferenceValue(mImageMaxSizePref, - newValue.toString(), - getLabelForImageMaxSizeValue(AppPrefs.getImageOptimizeMaxSize())); + newValue.toString(), + getLabelForImageMaxSizeValue(AppPrefs.getImageOptimizeMaxSize())); } else if (preference == mImageQualityPref) { AppPrefs.setImageOptimizeQuality(Integer.parseInt(newValue.toString())); setDetailListPreferenceValue(mImageQualityPref, - newValue.toString(), - getLabelForImageQualityValue(AppPrefs.getImageOptimizeQuality())); + newValue.toString(), + getLabelForImageQualityValue(AppPrefs.getImageOptimizeQuality())); } else if (preference == mOptimizedVideo) { AppPrefs.setVideoOptimize((Boolean) newValue); mVideoEncorderBitratePref.setEnabled((Boolean) newValue); @@ -293,19 +286,15 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { int newWidth = Integer.parseInt(newValue.toString()); AppPrefs.setVideoOptimizeWidth(newWidth); setDetailListPreferenceValue(mVideoWidthPref, - newValue.toString(), - getLabelForVideoMaxWidthValue(AppPrefs.getVideoOptimizeWidth())); + newValue.toString(), + getLabelForVideoMaxWidthValue(AppPrefs.getVideoOptimizeWidth())); } else if (preference == mVideoEncorderBitratePref) { AppPrefs.setVideoOptimizeQuality(Integer.parseInt(newValue.toString())); setDetailListPreferenceValue(mVideoEncorderBitratePref, - newValue.toString(), - getLabelForVideoEncoderBitrateValue(AppPrefs.getVideoOptimizeQuality())); + newValue.toString(), + getLabelForVideoEncoderBitrateValue(AppPrefs.getVideoOptimizeQuality())); } else if (preference == mStripImageLocation) { AppPrefs.setStripImageLocation((Boolean) newValue); - } else if (preference == mAppThemePreference) { - AppThemeUtils.Companion.setAppTheme(getActivity(), (String) newValue); - // restart activity to make sure changes are applied to PreferenceScreen - getActivity().recreate(); } return true; } @@ -345,7 +334,6 @@ private void changeLanguage(String languageCode) { Intent refresh = new Intent(getActivity(), getActivity().getClass()); startActivity(refresh); getActivity().setResult(LANGUAGE_CHANGED); - getActivity().overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); getActivity().finish(); // update Reader tags as they need be localized diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java index 4b45cf26b10f..0b556512a861 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java @@ -1,11 +1,12 @@ package org.wordpress.android.ui.prefs; import android.app.FragmentManager; +import android.content.Context; import android.os.Bundle; import android.view.MenuItem; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import org.apache.commons.text.StringEscapeUtils; import org.greenrobot.eventbus.EventBus; @@ -20,7 +21,7 @@ import org.wordpress.android.fluxc.store.SiteStore.OnSiteDeleted; import org.wordpress.android.fluxc.store.SiteStore.OnSiteRemoved; import org.wordpress.android.networking.ConnectionChangeReceiver; -import org.wordpress.android.ui.LocaleAwareActivity; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.ToastUtils.Duration; @@ -30,7 +31,7 @@ /** * Activity for configuring blog specific settings. */ -public class BlogPreferencesActivity extends LocaleAwareActivity { +public class BlogPreferencesActivity extends AppCompatActivity { private static final String KEY_SETTINGS_FRAGMENT = "settings-fragment"; private SiteModel mSite; @@ -39,11 +40,15 @@ public class BlogPreferencesActivity extends LocaleAwareActivity { @Inject SiteStore mSiteStore; @Inject Dispatcher mDispatcher; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); - setContentView(R.layout.site_settings_activity); if (savedInstanceState == null) { mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE); @@ -57,9 +62,6 @@ public void onCreate(Bundle savedInstanceState) { return; } - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); @@ -77,7 +79,7 @@ public void onCreate(Bundle savedInstanceState) { siteSettingsFragment = new SiteSettingsFragment(); siteSettingsFragment.setArguments(getIntent().getExtras()); fragmentManager.beginTransaction() - .replace(R.id.fragment_container, siteSettingsFragment, KEY_SETTINGS_FRAGMENT) + .replace(android.R.id.content, siteSettingsFragment, KEY_SETTINGS_FRAGMENT) .commit(); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/DetailListPreference.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/DetailListPreference.java index f77e5c798247..2b690ed1d67b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/DetailListPreference.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/DetailListPreference.java @@ -8,21 +8,22 @@ import android.preference.ListPreference; import android.text.TextUtils; import android.util.AttributeSet; +import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.Button; import android.widget.ListView; import android.widget.RadioButton; import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.apache.commons.lang3.ArrayUtils; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.ui.utils.UiHelpers; +import org.wordpress.android.util.ContextExtensionsKt; import java.util.Locale; @@ -62,6 +63,20 @@ public DetailListPreference(Context context, AttributeSet attrs) { mSelectedIndex = -1; } + @Override + protected void onBindView(@NonNull View view) { + super.onBindView(view); + + setupView((TextView) view.findViewById(android.R.id.title), + R.dimen.text_sz_large, + ContextExtensionsKt.getColorResIdFromAttribute(getContext(), R.attr.wpColorText), + R.color.neutral_20); + setupView((TextView) view.findViewById(android.R.id.summary), + R.dimen.text_sz_medium, + ContextExtensionsKt.getColorResIdFromAttribute(getContext(), R.attr.wpColorTextSubtle), + R.color.neutral_20); + } + @Override public CharSequence getEntry() { int index = findIndexOfValue(getValue()); @@ -77,11 +92,7 @@ public CharSequence getEntry() { protected void showDialog(Bundle state) { Context context = getContext(); Resources res = context.getResources(); - int topOffset = res.getDimensionPixelOffset(R.dimen.settings_fragment_dialog_vertical_inset); - - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context) - .setBackgroundInsetTop(topOffset) - .setBackgroundInsetBottom(topOffset); + AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.Calypso_Dialog_Alert); mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE; builder.setPositiveButton(android.R.string.ok, this); @@ -96,12 +107,16 @@ protected void showDialog(Bundle state) { mSelectedIndex = findIndexOfValue(mStartingValue); builder.setSingleChoiceItems(mListAdapter, mSelectedIndex, - (dialog, which) -> mSelectedIndex = which); + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + mSelectedIndex = which; + } + }); View titleView = View.inflate(getContext(), R.layout.detail_list_preference_title, null); if (titleView != null) { - TextView titleText = titleView.findViewById(R.id.title); + TextView titleText = (TextView) titleView.findViewById(R.id.title); if (titleText != null) { titleText.setText(getTitle()); } @@ -111,7 +126,9 @@ protected void showDialog(Bundle state) { builder.setTitle(getTitle()); } - mDialog = builder.create(); + if ((mDialog = builder.create()) == null) { + return; + } if (state != null) { mDialog.onRestoreInstanceState(state); @@ -120,6 +137,8 @@ protected void showDialog(Bundle state) { mDialog.show(); ListView listView = mDialog.getListView(); + Button positive = mDialog.getButton(DialogInterface.BUTTON_POSITIVE); + Button negative = mDialog.getButton(DialogInterface.BUTTON_NEGATIVE); if (listView != null) { listView.setDividerHeight(0); @@ -127,6 +146,16 @@ protected void showDialog(Bundle state) { listView.setPadding(0, 0, 0, res.getDimensionPixelSize(R.dimen.site_settings_divider_height)); } + if (positive != null) { + //noinspection deprecation + positive.setTextColor(res.getColor(R.color.primary_40)); + } + + if (negative != null) { + //noinspection deprecation + negative.setTextColor(res.getColor(R.color.primary_40)); + } + UiHelpers.Companion.adjustDialogSize(mDialog); } @@ -186,21 +215,32 @@ public void setDetails(String[] details) { refreshAdapter(); } + /** + * Helper method to style the Preference screen view + */ + private void setupView(TextView view, int sizeRes, int enabledColorRes, int disabledColorRes) { + if (view != null) { + Resources res = getContext().getResources(); + view.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimensionPixelSize(sizeRes)); + //noinspection deprecation + view.setTextColor(res.getColor(isEnabled() ? enabledColorRes : disabledColorRes)); + } + } + private class DetailListAdapter extends ArrayAdapter { DetailListAdapter(Context context, int resource, String[] objects) { super(context, resource, objects); } - @NotNull @Override - public View getView(final int position, View convertView, @NotNull ViewGroup parent) { + public View getView(final int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = View.inflate(getContext(), R.layout.detail_list_preference, null); } - final RadioButton radioButton = convertView.findViewById(R.id.radio); - TextView mainText = convertView.findViewById(R.id.main_text); - TextView detailText = convertView.findViewById(R.id.detail_text); + final RadioButton radioButton = (RadioButton) convertView.findViewById(R.id.radio); + TextView mainText = (TextView) convertView.findViewById(R.id.main_text); + TextView detailText = (TextView) convertView.findViewById(R.id.detail_text); if (mainText != null && getEntries() != null && position < getEntries().length) { mainText.setText(getEntries()[position]); @@ -219,7 +259,12 @@ public View getView(final int position, View convertView, @NotNull ViewGroup par radioButton.setChecked(mSelectedIndex == position); } - convertView.setOnClickListener(v -> changeSelection(position)); + convertView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + changeSelection(position); + } + }); return convertView; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/EditTextPreferenceWithValidation.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/EditTextPreferenceWithValidation.java index 4d5523934ec9..68664c520ccf 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/EditTextPreferenceWithValidation.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/EditTextPreferenceWithValidation.java @@ -7,10 +7,13 @@ import android.text.TextWatcher; import android.text.method.PasswordTransformationMethod; import android.util.AttributeSet; +import android.view.View; import android.widget.Button; import androidx.appcompat.app.AlertDialog; +import androidx.core.content.ContextCompat; +import org.wordpress.android.R; import org.wordpress.android.util.ValidationUtils; public class EditTextPreferenceWithValidation extends SummaryEditTextPreference { @@ -37,11 +40,16 @@ protected void showDialog(Bundle state) { final AlertDialog dialog = (AlertDialog) getDialog(); final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); if (positiveButton != null) { - positiveButton.setOnClickListener(v -> { - callChangeListener(getEditText().getText()); - dialog.dismiss(); + positiveButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + callChangeListener(getEditText().getText()); + dialog.dismiss(); + } }); + positiveButton.setTextColor(ContextCompat.getColorStateList(getContext(), + R.color.primary_40_neutral_40_selector)); getEditText().addTextChangedListener(new TextWatcher() { @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/EmptyViewRecyclerView.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/EmptyViewRecyclerView.java index 9d459949c24b..a4ee18f06c94 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/EmptyViewRecyclerView.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/EmptyViewRecyclerView.java @@ -58,25 +58,6 @@ public void setAdapter(Adapter adapterNew) { toggleEmptyView(); } - @Override - public void swapAdapter(Adapter adapter, boolean removeAndRecycleExistingViews) { - final RecyclerView.Adapter adapterOld = getAdapter(); - - if (adapterOld != null) { - adapterOld.unregisterAdapterDataObserver(mObserver); - } - - super.swapAdapter(adapter, removeAndRecycleExistingViews); - - final RecyclerView.Adapter adapterNew = getAdapter(); - - if (adapterNew != null) { - adapterNew.registerAdapterDataObserver(mObserver); - } - - toggleEmptyView(); - } - public void setEmptyView(View emptyView) { mEmptyView = emptyView; toggleEmptyView(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MultiSelectRecyclerViewAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MultiSelectRecyclerViewAdapter.java index a3eeddc7e238..412ab0683b6a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MultiSelectRecyclerViewAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MultiSelectRecyclerViewAdapter.java @@ -1,14 +1,16 @@ package org.wordpress.android.ui.prefs; +import android.content.Context; import android.util.SparseBooleanArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import java.util.List; @@ -19,20 +21,24 @@ public class MultiSelectRecyclerViewAdapter extends RecyclerView.Adapter { private final List mItems; private final SparseBooleanArray mItemsSelected; + private final int mSelectedColor; + private final int mUnselectedColor; - MultiSelectRecyclerViewAdapter(List items) { + public MultiSelectRecyclerViewAdapter(Context context, List items) { + this.mSelectedColor = ContextCompat.getColor(context, android.R.color.white); + this.mUnselectedColor = ContextCompat.getColor(context, android.R.color.transparent); this.mItems = items; this.mItemsSelected = new SparseBooleanArray(); } - class ItemHolder extends RecyclerView.ViewHolder { - private final View mContainer; + public class ItemHolder extends RecyclerView.ViewHolder { + private final LinearLayout mContainer; private final TextView mText; - ItemHolder(View view) { + public ItemHolder(View view) { super(view); - mContainer = view.findViewById(R.id.container); - mText = view.findViewById(R.id.text); + mContainer = (LinearLayout) view.findViewById(R.id.container); + mText = (TextView) view.findViewById(R.id.text); } } @@ -45,10 +51,13 @@ public int getItemCount() { public void onBindViewHolder(final ItemHolder holder, int position) { String item = getItem(holder.getAdapterPosition()); holder.mText.setText(item); - holder.mContainer.setSelected(isItemSelected(position)); + holder.mContainer.setBackgroundColor( + isItemSelected(position) + ? mSelectedColor + : mUnselectedColor); } - @NotNull @Override + @Override public ItemHolder onCreateViewHolder(ViewGroup parent, int type) { return new ItemHolder( LayoutInflater.from(parent.getContext()).inflate(R.layout.wp_simple_list_item_1, parent, false)); @@ -58,7 +67,7 @@ public String getItem(int position) { return mItems.get(position); } - SparseBooleanArray getItemsSelected() { + public SparseBooleanArray getItemsSelected() { return mItemsSelected; } @@ -67,12 +76,12 @@ private boolean isItemSelected(int position) { return item != null && mItemsSelected.get(position); } - void removeItemsSelected() { + public void removeItemsSelected() { mItemsSelected.clear(); notifyDataSetChanged(); } - void setItemSelected(int position) { + public void setItemSelected(int position) { if (!mItemsSelected.get(position)) { mItemsSelected.put(position, true); } @@ -80,7 +89,7 @@ void setItemSelected(int position) { notifyItemChanged(position); } - void toggleItemSelected(int position) { + public void toggleItemSelected(int position) { if (!mItemsSelected.get(position)) { mItemsSelected.put(position, true); } else { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java index b16ea68032ef..7408f77bd5fb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java @@ -1,33 +1,37 @@ package org.wordpress.android.ui.prefs; +import android.content.Context; import android.os.Bundle; import android.view.MenuItem; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentManager; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.Dispatcher; import org.wordpress.android.fluxc.store.AccountStore; -import org.wordpress.android.ui.LocaleAwareActivity; +import org.wordpress.android.util.LocaleManager; import javax.inject.Inject; -public class MyProfileActivity extends LocaleAwareActivity { +public class MyProfileActivity extends AppCompatActivity { + private static final String KEY_MY_PROFILE_FRAGMENT = "my-profile-fragment"; + @Inject Dispatcher mDispatcher; @Inject AccountStore mAccountStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); - setContentView(R.layout.my_profile_activity); - - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); @@ -36,6 +40,22 @@ public void onCreate(Bundle savedInstanceState) { } } + @Override + protected void onResume() { + super.onResume(); + + FragmentManager fragmentManager = getSupportFragmentManager(); + MyProfileFragment myProfileFragment = + (MyProfileFragment) fragmentManager.findFragmentByTag(KEY_MY_PROFILE_FRAGMENT); + if (myProfileFragment == null) { + myProfileFragment = MyProfileFragment.newInstance(); + + fragmentManager.beginTransaction() + .add(android.R.id.content, myProfileFragment, KEY_MY_PROFILE_FRAGMENT) + .commit(); + } + } + @Override public boolean onOptionsItemSelected(final MenuItem item) { if (item.getItemId() == android.R.id.home) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileFragment.java index 4e4212f05af1..89b86fc0cff4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileFragment.java @@ -74,10 +74,10 @@ public void onStop() { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.my_profile_fragment, container, false); - mFirstName = rootView.findViewById(R.id.first_name); - mLastName = rootView.findViewById(R.id.last_name); - mDisplayName = rootView.findViewById(R.id.display_name); - mAboutMe = rootView.findViewById(R.id.about_me); + mFirstName = (WPTextView) rootView.findViewById(R.id.first_name); + mLastName = (WPTextView) rootView.findViewById(R.id.last_name); + mDisplayName = (WPTextView) rootView.findViewById(R.id.display_name); + mAboutMe = (WPTextView) rootView.findViewById(R.id.about_me); rootView.findViewById(R.id.first_name_row).setOnClickListener( createOnClickListener( @@ -137,14 +137,17 @@ private View.OnClickListener createOnClickListener(final String dialogTitle, final String hint, final WPTextView textView, final boolean isMultiline) { - return v -> { - ProfileInputDialogFragment inputDialog = ProfileInputDialogFragment.newInstance(dialogTitle, - textView.getText() - .toString(), - hint, isMultiline, - textView.getId()); - inputDialog.setTargetFragment(MyProfileFragment.this, 0); - inputDialog.show(getFragmentManager(), DIALOG_TAG); + return new View.OnClickListener() { + @Override + public void onClick(View v) { + ProfileInputDialogFragment inputDialog = ProfileInputDialogFragment.newInstance(dialogTitle, + textView.getText() + .toString(), + hint, isMultiline, + textView.getId()); + inputDialog.setTargetFragment(MyProfileFragment.this, 0); + inputDialog.show(getFragmentManager(), DIALOG_TAG); + } }; } @@ -181,7 +184,7 @@ public void onSuccessfulInput(String input, int callbackId) { return; } - WPTextView textView = rootView.findViewById(callbackId); + WPTextView textView = (WPTextView) rootView.findViewById(callbackId); updateLabel(textView, input); updateMyProfileForLabel(textView); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/NumberPickerDialog.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/NumberPickerDialog.java index 5637b6a4abdf..8f401f82e8ff 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/NumberPickerDialog.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/NumberPickerDialog.java @@ -2,6 +2,7 @@ import android.annotation.SuppressLint; import android.app.Activity; +import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.DialogInterface; @@ -9,20 +10,20 @@ import android.os.Bundle; import android.text.InputFilter; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; +import android.widget.Button; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.NumberPicker; import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.SwitchCompat; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.R; +import org.wordpress.android.util.WPPrefUtils; public class NumberPickerDialog extends DialogFragment implements DialogInterface.OnClickListener, @@ -55,11 +56,8 @@ public NumberPickerDialog() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - int topOffset = getResources().getDimensionPixelOffset(R.dimen.settings_fragment_dialog_vertical_inset); - - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()) - .setBackgroundInsetTop(topOffset) - .setBackgroundInsetBottom(topOffset); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); View view = View.inflate(getActivity(), R.layout.number_picker_dialog, null); TextView switchText = view.findViewById(R.id.number_picker_text); mSwitch = view.findViewById(R.id.number_picker_switch); @@ -116,6 +114,21 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { return builder.create(); } + @Override + public void onStart() { + super.onStart(); + + AlertDialog dialog = (AlertDialog) getDialog(); + Button positive = dialog.getButton(DialogInterface.BUTTON_POSITIVE); + Button negative = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); + if (positive != null) { + WPPrefUtils.layoutAsFlatButton(positive); + } + if (negative != null) { + WPPrefUtils.layoutAsFlatButton(negative); + } + } + @Override public void onClick(DialogInterface dialog, int which) { mConfirmed = which == DialogInterface.BUTTON_POSITIVE; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/ProfileInputDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/ProfileInputDialogFragment.java index d2dea8646feb..1405323c611c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/ProfileInputDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/ProfileInputDialogFragment.java @@ -1,19 +1,21 @@ package org.wordpress.android.ui.prefs; import android.app.Dialog; +import android.content.DialogInterface; import android.os.Bundle; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; +import android.widget.Button; import android.widget.EditText; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.R; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.WPPrefUtils; import org.wordpress.android.widgets.WPTextView; public class ProfileInputDialogFragment extends DialogFragment { @@ -46,17 +48,18 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater layoutInflater = LayoutInflater.from(getActivity()); //noinspection InflateParams View promptView = layoutInflater.inflate(R.layout.my_profile_dialog, null); - AlertDialog.Builder alertDialogBuilder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); alertDialogBuilder.setView(promptView); - final WPTextView textView = promptView.findViewById(R.id.my_profile_dialog_label); - final EditText editText = promptView.findViewById(R.id.my_profile_dialog_input); - final WPTextView hintView = promptView.findViewById(R.id.my_profile_dialog_hint); + final WPTextView textView = (WPTextView) promptView.findViewById(R.id.my_profile_dialog_label); + final EditText editText = (EditText) promptView.findViewById(R.id.my_profile_dialog_input); + final WPTextView hintView = (WPTextView) promptView.findViewById(R.id.my_profile_dialog_hint); Bundle args = getArguments(); String title = args.getString(TITLE_TAG); String hint = args.getString(HINT_TAG); - boolean isMultiline = args.getBoolean(IS_MULTILINE_TAG); + Boolean isMultiline = args.getBoolean(IS_MULTILINE_TAG); String initialText = args.getString(INITIAL_TEXT_TAG); final int callbackId = args.getInt(CALLBACK_ID_TAG); @@ -76,21 +79,41 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { } alertDialogBuilder.setCancelable(true) - .setPositiveButton(android.R.string.ok, (dialog, id) -> { - if (getTargetFragment() instanceof Callback) { - ((Callback) getTargetFragment()) - .onSuccessfulInput(editText.getText().toString(), callbackId); - } else { - AppLog.e(AppLog.T.UTILS, - "Target fragment doesn't implement ProfileInputDialogFragment.Callback"); + .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + if (getTargetFragment() instanceof Callback) { + ((Callback) getTargetFragment()) + .onSuccessfulInput(editText.getText().toString(), callbackId); + } else { + AppLog.e(AppLog.T.UTILS, + "Target fragment doesn't implement ProfileInputDialogFragment.Callback"); + } } }) .setNegativeButton(R.string.cancel, - (dialog, id) -> dialog.cancel()); + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.cancel(); + } + }); return alertDialogBuilder.create(); } + @Override + public void onStart() { + super.onStart(); + AlertDialog dialog = (AlertDialog) getDialog(); + Button positive = dialog.getButton(DialogInterface.BUTTON_POSITIVE); + Button negative = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); + if (positive != null) { + WPPrefUtils.layoutAsFlatButton(positive); + } + if (negative != null) { + WPPrefUtils.layoutAsFlatButton(negative); + } + } + public interface Callback { void onSuccessfulInput(String input, int callbackId); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/RelatedPostsDialog.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/RelatedPostsDialog.java index c202eb8a8135..9d8eb1174f96 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/RelatedPostsDialog.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/RelatedPostsDialog.java @@ -1,13 +1,16 @@ package org.wordpress.android.ui.prefs; import android.app.Activity; +import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; +import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.ImageView; @@ -15,12 +18,10 @@ import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.SwitchCompat; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.R; +import org.wordpress.android.util.WPPrefUtils; import java.util.ArrayList; import java.util.List; @@ -72,9 +73,9 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { mRelatedPostsList = v.findViewById(R.id.related_posts_list); mPreviewImages = new ArrayList<>(); - mPreviewImages.add(v.findViewById(R.id.related_post_image1)); - mPreviewImages.add(v.findViewById(R.id.related_post_image2)); - mPreviewImages.add(v.findViewById(R.id.related_post_image3)); + mPreviewImages.add((ImageView) v.findViewById(R.id.related_post_image1)); + mPreviewImages.add((ImageView) v.findViewById(R.id.related_post_image2)); + mPreviewImages.add((ImageView) v.findViewById(R.id.related_post_image3)); Bundle args = getArguments(); if (args != null) { @@ -92,17 +93,14 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { toggleViews(mShowRelatedPosts.isChecked()); - int topOffset = getResources().getDimensionPixelOffset(R.dimen.settings_fragment_dialog_vertical_inset); - - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()) - .setBackgroundInsetTop(topOffset) - .setBackgroundInsetBottom(topOffset); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); //noinspection InflateParams View titleView = inflater.inflate(R.layout.detail_list_preference_title, null); TextView titleText = titleView.findViewById(R.id.title); titleText.setText(R.string.site_settings_related_posts_title); titleText.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, - RelativeLayout.LayoutParams.WRAP_CONTENT)); + RelativeLayout.LayoutParams.WRAP_CONTENT)); builder.setCustomTitle(titleView); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(R.string.cancel, this); @@ -111,6 +109,21 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { return builder.create(); } + @Override + public void onStart() { + super.onStart(); + + AlertDialog dialog = (AlertDialog) getDialog(); + Button positive = dialog.getButton(DialogInterface.BUTTON_POSITIVE); + Button negative = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); + if (positive != null) { + WPPrefUtils.layoutAsFlatButton(positive); + } + if (negative != null) { + WPPrefUtils.layoutAsFlatButton(negative); + } + } + @Override public void onClick(DialogInterface dialog, int which) { mConfirmed = which == DialogInterface.BUTTON_POSITIVE; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsFormatDialog.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsFormatDialog.java index bb3a9526a959..fa56c8daa20e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsFormatDialog.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsFormatDialog.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.prefs; import android.app.Activity; +import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.Context; @@ -8,18 +9,17 @@ import android.content.Intent; import android.os.Bundle; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; +import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.StringRes; -import androidx.appcompat.app.AlertDialog; - -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.radiobutton.MaterialRadioButton; +import androidx.core.widget.CompoundButtonCompat; import org.wordpress.android.Constants; import org.wordpress.android.R; @@ -104,14 +104,15 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { ? R.string.site_settings_date_format_title : R.string.site_settings_time_format_title; txtTitle.setText(titleRes); - txtHelp.setOnClickListener( - v -> ActivityLauncher.openUrlExternal(v.getContext(), Constants.URL_DATETIME_FORMAT_HELP)); - - int topOffset = getResources().getDimensionPixelOffset(R.dimen.settings_fragment_dialog_vertical_inset); + txtHelp.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + ActivityLauncher.openUrlExternal(v.getContext(), Constants.URL_DATETIME_FORMAT_HELP); + } + }); - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()) - .setBackgroundInsetTop(topOffset) - .setBackgroundInsetBottom(topOffset); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(R.string.cancel, this); builder.setView(view); @@ -124,7 +125,9 @@ private void createRadioButtons() { int margin = getResources().getDimensionPixelSize(R.dimen.margin_small); for (int i = 0; i < mEntries.length; i++) { - MaterialRadioButton radio = new MaterialRadioButton(getActivity()); + RadioButton radio = new RadioButton(getActivity()); + CompoundButtonCompat.setButtonTintList(radio, + getResources().getColorStateList(R.color.primary_40_gray_20_gray_40_selector)); radio.setText(mEntries[i]); radio.setId(i); mRadioGroup.addView(radio); @@ -140,8 +143,12 @@ private void createRadioButtons() { } } - mRadioGroup.setOnCheckedChangeListener( - (group, checkedId) -> mEditCustomFormat.setEnabled(isCustomFormatEntry(mEntries[checkedId]))); + mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(RadioGroup group, int checkedId) { + mEditCustomFormat.setEnabled(isCustomFormatEntry(mEntries[checkedId])); + } + }); } @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsFragment.java index 9df3f95d6584..a2979fd332ce 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsFragment.java @@ -1,9 +1,11 @@ package org.wordpress.android.ui.prefs; import android.app.Activity; +import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; @@ -19,17 +21,20 @@ import android.util.Pair; import android.util.SparseBooleanArray; import android.view.ActionMode; +import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; +import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager.LayoutParams; import android.widget.AdapterView; import android.widget.BaseAdapter; +import android.widget.Button; import android.widget.EditText; import android.widget.ListAdapter; import android.widget.ListView; @@ -38,13 +43,13 @@ import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; import androidx.collection.SparseArrayCompat; import androidx.recyclerview.widget.LinearLayoutManager; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import com.android.volley.VolleyError; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; +import com.wordpress.rest.RestRequest; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.text.StringEscapeUtils; @@ -69,7 +74,6 @@ import org.wordpress.android.ui.prefs.EditTextPreferenceWithValidation.ValidationType; import org.wordpress.android.ui.prefs.SiteSettingsFormatDialog.FormatType; import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.ContextUtilsKt; import org.wordpress.android.util.HtmlUtils; import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; @@ -104,6 +108,7 @@ public class SiteSettingsFragment extends PreferenceFragment implements Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener, AdapterView.OnItemLongClickListener, + ViewGroup.OnHierarchyChangeListener, Dialog.OnDismissListener, SiteSettingsInterface.SiteSettingsListener { /** @@ -322,9 +327,12 @@ public void addPreferencesFromResource() { Preference disconnectPref = new Preference(getActivity()); disconnectPref.setTitle(getString(R.string.jetpack_disconnect_pref_title)); disconnectPref.setKey(getString(R.string.pref_key_site_disconnect)); - disconnectPref.setOnPreferenceClickListener(preference -> { - disconnectFromJetpack(); - return true; + disconnectPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(Preference preference) { + disconnectFromJetpack(); + return true; + } }); parent.addPreference(disconnectPref); } @@ -351,9 +359,12 @@ public void onResume() { mSiteSettings.init(false); if (mShouldFetch) { - new Handler().postDelayed(() -> { - // initialize settings with locally cached values, fetch remote on first pass - mSiteSettings.init(true); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + // initialize settings with locally cached values, fetch remote on first pass + mSiteSettings.init(true); + } }, FETCH_DELAY); // stop future calls from fetching remote settings mShouldFetch = false; @@ -389,13 +400,13 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { break; case PAGING_REQUEST_CODE: mSiteSettings.setShouldPageComments(data.getBooleanExtra(NumberPickerDialog.SWITCH_ENABLED_KEY, - false)); + false)); onPreferenceChange(mPagingPref, data.getIntExtra( NumberPickerDialog.CUR_VALUE_KEY, -1)); break; case CLOSE_AFTER_REQUEST_CODE: mSiteSettings.setShouldCloseAfter(data.getBooleanExtra(NumberPickerDialog.SWITCH_ENABLED_KEY, - false)); + false)); onPreferenceChange(mCloseAfterPref, data.getIntExtra(NumberPickerDialog.CUR_VALUE_KEY, -1)); break; case MULTIPLE_LINKS_REQUEST_CODE: @@ -428,8 +439,10 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { break; } } else { - if (requestCode == DELETE_SITE_REQUEST_CODE) { - deleteSite(); + switch (requestCode) { + case DELETE_SITE_REQUEST_CODE: + deleteSite(); + break; } } @@ -447,10 +460,12 @@ public View onCreateView(@NonNull LayoutInflater inflater, getActivity().getActionBar().setDisplayShowHomeEnabled(true); } - View view = super.onCreateView(inflater, container, savedInstanceState); + Context themer = new ContextThemeWrapper(getActivity(), R.style.Calypso_SiteSettingsTheme); + LayoutInflater localInflater = inflater.cloneInContext(themer); + View view = super.onCreateView(localInflater, container, savedInstanceState); if (view != null) { - setupPreferenceList(view.findViewById(android.R.id.list), getResources()); + setupPreferenceList((ListView) view.findViewById(android.R.id.list), getResources()); } return view; @@ -475,6 +490,26 @@ public void onActivityCreated(Bundle savedInstanceState) { } } + @Override + public void onChildViewAdded(View parent, View child) { + if (child.getId() == android.R.id.title && child instanceof TextView) { + // style preference category title views + TextView title = (TextView) child; + WPPrefUtils.layoutAsBody2(title); + } else { + // style preference title views + TextView title = child.findViewById(android.R.id.title); + if (title != null) { + WPPrefUtils.layoutAsSubhead(title); + } + } + } + + @Override + public void onChildViewRemoved(View parent, View child) { + // NOP + } + @Override public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference preference) { super.onPreferenceTreeClick(screen, preference); @@ -507,7 +542,7 @@ public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference prefere dialog.dismiss(); WPWebViewActivity.openUrlByUsingGlobalWPCOMCredentials(getActivity(), WORDPRESS_EMPTY_SITE_SUPPORT_URL); } else { - setupPreferenceList(dialog.findViewById(android.R.id.list), getResources()); + setupPreferenceList((ListView) dialog.findViewById(android.R.id.list), getResources()); String title = getString(R.string.start_over); WPActivityUtils.addToolbarToDialog(this, dialog, title); } @@ -533,15 +568,15 @@ public boolean onPreferenceClick(Preference preference) { } else if (preference == mModerationHoldPref) { mEditingList = mSiteSettings.getModerationKeys(); showListEditorDialog(R.string.site_settings_moderation_hold_title, - R.string.site_settings_hold_for_moderation_description); + R.string.site_settings_hold_for_moderation_description); } else if (preference == mBlacklistPref) { mEditingList = mSiteSettings.getBlacklistKeys(); showListEditorDialog(R.string.site_settings_blacklist_title, - R.string.site_settings_blacklist_description); + R.string.site_settings_blacklist_description); } else if (preference == mJpWhitelistPref) { mEditingList = mSiteSettings.getJetpackWhitelistKeys(); showListEditorDialog(R.string.jetpack_brute_force_whitelist_title, - R.string.site_settings_jetpack_whitelist_description); + R.string.site_settings_jetpack_whitelist_description); } else if (preference == mStartOverPref) { handleStartOver(); } else if (preference == mCloseAfterPref) { @@ -567,19 +602,29 @@ public boolean onPreferenceClick(Preference preference) { } private void disconnectFromJetpack() { - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setMessage(R.string.jetpack_disconnect_confirmation_message); - builder.setPositiveButton(R.string.jetpack_disconnect_confirm, (dialog, which) -> { - String url = String.format(Locale.US, "jetpack-blogs/%d/mine/delete", mSite.getSiteId()); - WordPress.getRestClientUtilsV1_1().post(url, response -> { - AppLog.v(AppLog.T.API, "Successfully disconnected Jetpack site"); - ToastUtils.showToast(getActivity(), R.string.jetpack_disconnect_success_toast); - mDispatcher.dispatch(SiteActionBuilder.newRemoveSiteAction(mSite)); - mSite = null; - }, error -> { - AppLog.e(AppLog.T.API, "Error disconnecting Jetpack site"); - ToastUtils.showToast(getActivity(), R.string.jetpack_disconnect_error_toast); - }); + builder.setPositiveButton(R.string.jetpack_disconnect_confirm, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + String url = String.format(Locale.US, "jetpack-blogs/%d/mine/delete", mSite.getSiteId()); + WordPress.getRestClientUtilsV1_1().post(url, new RestRequest.Listener() { + @Override + public void onResponse(JSONObject response) { + AppLog.v(AppLog.T.API, "Successfully disconnected Jetpack site"); + ToastUtils.showToast(getActivity(), R.string.jetpack_disconnect_success_toast); + mDispatcher.dispatch(SiteActionBuilder.newRemoveSiteAction(mSite)); + mSite = null; + } + }, new RestRequest.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + AppLog.e(AppLog.T.API, "Error disconnecting Jetpack site"); + ToastUtils.showToast(getActivity(), R.string.jetpack_disconnect_error_toast); + } + }); + } }); builder.setNegativeButton(android.R.string.cancel, null); builder.show(); @@ -649,15 +694,15 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } else if (preference == mLanguagePref) { if (!mSiteSettings.setLanguageCode(newValue.toString())) { AppLog.w(AppLog.T.SETTINGS, - "Unknown language code " + newValue.toString() + " selected in Site Settings."); + "Unknown language code " + newValue.toString() + " selected in Site Settings."); ToastUtils.showToast(getActivity(), R.string.site_settings_unknown_language_code_error); } changeLanguageValue(mSiteSettings.getLanguageCode()); } else if (preference == mPrivacyPref) { mSiteSettings.setPrivacy(Integer.parseInt(newValue.toString())); setDetailListPreferenceValue(mPrivacyPref, - String.valueOf(mSiteSettings.getPrivacy()), - mSiteSettings.getPrivacyDescription()); + String.valueOf(mSiteSettings.getPrivacy()), + mSiteSettings.getPrivacyDescription()); } else if (preference == mAllowCommentsPref || preference == mAllowCommentsNested) { setAllowComments((Boolean) newValue); } else if (preference == mSendPingbacksPref || preference == mSendPingbacksNested) { @@ -670,8 +715,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } else if (preference == mSortByPref) { mSiteSettings.setCommentSorting(Integer.parseInt(newValue.toString())); setDetailListPreferenceValue(mSortByPref, - newValue.toString(), - mSiteSettings.getSortingDescription()); + newValue.toString(), + mSiteSettings.getSortingDescription()); } else if (preference == mThreadingPref) { mSiteSettings.setThreadingLevels(Integer.parseInt(newValue.toString())); mThreadingPref.setSummary(mSiteSettings.getThreadingDescription()); @@ -687,9 +732,9 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } else if (preference == mMultipleLinksPref) { mSiteSettings.setMultipleLinks(Integer.parseInt(newValue.toString())); String s = StringUtils.getQuantityString(getActivity(), R.string.site_settings_multiple_links_summary_zero, - R.string.site_settings_multiple_links_summary_one, - R.string.site_settings_multiple_links_summary_other, - mSiteSettings.getMultipleLinks()); + R.string.site_settings_multiple_links_summary_one, + R.string.site_settings_multiple_links_summary_other, + mSiteSettings.getMultipleLinks()); mMultipleLinksPref.setSummary(s); } else if (preference == mUsernamePref) { mSiteSettings.setUsername(newValue.toString()); @@ -700,13 +745,13 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } else if (preference == mCategoryPref) { mSiteSettings.setDefaultCategory(Integer.parseInt(newValue.toString())); setDetailListPreferenceValue(mCategoryPref, - newValue.toString(), - mSiteSettings.getDefaultCategoryForDisplay()); + newValue.toString(), + mSiteSettings.getDefaultCategoryForDisplay()); } else if (preference == mFormatPref) { mSiteSettings.setDefaultFormat(newValue.toString()); setDetailListPreferenceValue(mFormatPref, - newValue.toString(), - mSiteSettings.getDefaultPostFormatDisplay()); + newValue.toString(), + mSiteSettings.getDefaultPostFormatDisplay()); } else if (preference == mRelatedPostsPref) { mRelatedPostsPref.setSummary(newValue.toString()); } else if (preference == mModerationHoldPref) { @@ -765,7 +810,7 @@ public boolean onItemLongClick(AdapterView parent, View view, int position, l HashMap properties = new HashMap<>(); properties.put("hint_shown", hintObj.getHint()); AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_HINT_TOAST_SHOWN, mSite, - properties); + properties); ToastUtils.showToast(getActivity(), hintObj.getHint(), ToastUtils.Duration.SHORT); } return true; @@ -843,12 +888,16 @@ private void setupPreferenceList(ListView prefList, Resources res) { } // customize list dividers - prefList.setDivider(ContextUtilsKt.getDrawableFromAttribute(getActivity(), android.R.attr.listDivider)); + //noinspection deprecation + prefList.setDivider(res.getDrawable(R.drawable.bg_rectangle_divider)); prefList.setDividerHeight(res.getDimensionPixelSize(R.dimen.site_settings_divider_height)); // handle long clicks on preferences to display hints prefList.setOnItemLongClickListener(this); + // required to customize (Calypso) preference views + prefList.setOnHierarchyChangeListener(this); // remove footer divider bar prefList.setFooterDividersEnabled(false); + //noinspection deprecation prefList.setOverscrollFooter(res.getDrawable(android.R.color.transparent)); } @@ -1056,24 +1105,32 @@ private void showThreadingDialog() { args.putBoolean(NumberPickerDialog.SWITCH_ENABLED_KEY, mSiteSettings.getShouldThreadComments()); args.putString(NumberPickerDialog.SWITCH_TITLE_KEY, getString(R.string.site_settings_threading_title)); args.putString(NumberPickerDialog.SWITCH_DESC_KEY, - getString(R.string.site_settings_threading_dialog_description)); + getString(R.string.site_settings_threading_dialog_description)); args.putString(NumberPickerDialog.TITLE_KEY, getString(R.string.site_settings_threading_title)); args.putString(NumberPickerDialog.HEADER_TEXT_KEY, getString(R.string.site_settings_threading_dialog_header)); args.putInt(NumberPickerDialog.MIN_VALUE_KEY, 2); args.putInt(NumberPickerDialog.MAX_VALUE_KEY, getResources().getInteger(R.integer.threading_limit)); args.putInt(NumberPickerDialog.CUR_VALUE_KEY, mSiteSettings.getThreadingLevels()); - showNumberPickerDialog(args, THREADING_REQUEST_CODE, "threading-dialog", - value -> mSiteSettings.getThreadingDescriptionForLevel(value)); + showNumberPickerDialog(args, THREADING_REQUEST_CODE, "threading-dialog", new Formatter() { + @Override + public String format(int value) { + return mSiteSettings.getThreadingDescriptionForLevel(value); + } + }); } private void showExportContentDialog() { - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(R.string.export_your_content); String email = mAccountStore.getAccount().getEmail(); builder.setMessage(getString(R.string.export_your_content_message, email)); - builder.setPositiveButton(R.string.site_settings_export_content_title, (dialog, which) -> { - AnalyticsUtils.trackWithSiteDetails(Stat.SITE_SETTINGS_EXPORT_SITE_REQUESTED, mSite); - exportSite(); + builder.setPositiveButton(R.string.site_settings_export_content_title, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_EXPORT_SITE_REQUESTED, mSite); + exportSite(); + } }); builder.setNegativeButton(R.string.cancel, null); @@ -1110,17 +1167,23 @@ private void requestPurchasesForDeletionCheck() { final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "", getString(R.string.checking_purchases), true, false); AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_DELETE_SITE_PURCHASES_REQUESTED, mSite); - WordPress.getRestClientUtils().getSitePurchases(mSite.getSiteId(), response -> { - dismissProgressDialog(progressDialog); - if (isAdded()) { - showPurchasesOrDeleteSiteDialog(response); + WordPress.getRestClientUtils().getSitePurchases(mSite.getSiteId(), new RestRequest.Listener() { + @Override + public void onResponse(JSONObject response) { + dismissProgressDialog(progressDialog); + if (isAdded()) { + showPurchasesOrDeleteSiteDialog(response); + } } - }, error -> { - dismissProgressDialog(progressDialog); - if (isAdded()) { - ToastUtils.showToast(getActivity(), getString(R.string.purchases_request_error)); - AppLog.e(AppLog.T.API, - "Error occurred while requesting purchases for deletion check: " + error.toString()); + }, new RestRequest.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + dismissProgressDialog(progressDialog); + if (isAdded()) { + ToastUtils.showToast(getActivity(), getString(R.string.purchases_request_error)); + AppLog.e(AppLog.T.API, + "Error occurred while requesting purchases for deletion check: " + error.toString()); + } } }); } @@ -1139,15 +1202,24 @@ private void showPurchasesOrDeleteSiteDialog(JSONObject response) { } private void showPurchasesDialog() { - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(R.string.premium_upgrades_title); builder.setMessage(R.string.premium_upgrades_message); - builder.setPositiveButton(R.string.show_purchases, (dialog, which) -> { - AnalyticsUtils.trackWithSiteDetails( - Stat.SITE_SETTINGS_DELETE_SITE_PURCHASES_SHOW_CLICKED, mSite); - WPWebViewActivity.openUrlByUsingGlobalWPCOMCredentials(getActivity(), WORDPRESS_PURCHASES_URL); + builder.setPositiveButton(R.string.show_purchases, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + AnalyticsUtils.trackWithSiteDetails( + AnalyticsTracker.Stat.SITE_SETTINGS_DELETE_SITE_PURCHASES_SHOW_CLICKED, mSite); + WPWebViewActivity.openUrlByUsingGlobalWPCOMCredentials(getActivity(), WORDPRESS_PURCHASES_URL); + } + }); + builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } }); - builder.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.dismiss()); builder.show(); AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_DELETE_SITE_PURCHASES_SHOWN, mSite); } @@ -1170,13 +1242,19 @@ private void showDeleteSiteWarningDialog() { return; } - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(R.string.delete_site_warning_title); String text = getString(R.string.delete_site_warning, "" + UrlUtils.getHost(mSite.getUrl()) + "") + "

" + "" + getString(R.string.delete_site_warning_subtitle) + ""; builder.setMessage(HtmlUtils.fromHtml(text)); - builder.setPositiveButton(R.string.yes, (dialog, which) -> showDeleteSiteDialog()); + builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + showDeleteSiteDialog(); + } + }); builder.setNegativeButton(R.string.cancel, null); builder.show(); } @@ -1200,9 +1278,9 @@ private void showCloseAfterDialog() { args.putBoolean(NumberPickerDialog.SHOW_SWITCH_KEY, true); args.putBoolean(NumberPickerDialog.SWITCH_ENABLED_KEY, mSiteSettings.getShouldCloseAfter()); args.putString(NumberPickerDialog.SWITCH_TITLE_KEY, - getString(R.string.site_settings_close_after_dialog_switch_text)); + getString(R.string.site_settings_close_after_dialog_switch_text)); args.putString(NumberPickerDialog.SWITCH_DESC_KEY, - getString(R.string.site_settings_close_after_dialog_description)); + getString(R.string.site_settings_close_after_dialog_description)); args.putString(NumberPickerDialog.TITLE_KEY, getString(R.string.site_settings_close_after_dialog_title)); args.putString(NumberPickerDialog.HEADER_TEXT_KEY, getString(R.string.site_settings_close_after_dialog_header)); args.putInt(NumberPickerDialog.MIN_VALUE_KEY, 1); @@ -1229,24 +1307,24 @@ public void setPreferencesFromSiteSettings() { changeEditTextPreferenceValue(mPasswordPref, mSiteSettings.getPassword()); changeLanguageValue(mSiteSettings.getLanguageCode()); setDetailListPreferenceValue(mPrivacyPref, - String.valueOf(mSiteSettings.getPrivacy()), - mSiteSettings.getPrivacyDescription()); + String.valueOf(mSiteSettings.getPrivacy()), + mSiteSettings.getPrivacyDescription()); setCategories(); setPostFormats(); setAllowComments(mSiteSettings.getAllowComments()); setSendPingbacks(mSiteSettings.getSendPingbacks()); setReceivePingbacks(mSiteSettings.getReceivePingbacks()); setDetailListPreferenceValue(mSortByPref, - String.valueOf(mSiteSettings.getCommentSorting()), - mSiteSettings.getSortingDescription()); + String.valueOf(mSiteSettings.getCommentSorting()), + mSiteSettings.getSortingDescription()); int approval = mSiteSettings.getManualApproval() ? mSiteSettings.getUseCommentWhitelist() ? 0 - : -1 : 1; + : -1 : 1; setDetailListPreferenceValue(mWhitelistPref, String.valueOf(approval), getWhitelistSummary(approval)); String s = StringUtils.getQuantityString(getActivity(), R.string.site_settings_multiple_links_summary_zero, - R.string.site_settings_multiple_links_summary_one, - R.string.site_settings_multiple_links_summary_other, - mSiteSettings.getMultipleLinks()); + R.string.site_settings_multiple_links_summary_one, + R.string.site_settings_multiple_links_summary_other, + mSiteSettings.getMultipleLinks()); mMultipleLinksPref.setSummary(s); mIdentityRequiredPreference.setChecked(mSiteSettings.getIdentityRequired()); mUserAccountRequiredPref.setChecked(mSiteSettings.getUserAccountRequired()); @@ -1529,8 +1607,8 @@ private void updateWhitelistSettings(int val) { mSiteSettings.setManualApproval(val == -1); mSiteSettings.setUseCommentWhitelist(val == 0); setDetailListPreferenceValue(mWhitelistPref, - String.valueOf(val), - getWhitelistSummary(val)); + String.valueOf(val), + getWhitelistSummary(val)); } private void handleStartOver() { @@ -1542,7 +1620,7 @@ private void handleStartOver() { intent.setType(ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE); intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"help@wordpress.com"}); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.start_over_email_subject, - SiteUtils.getHomeURLOrHostName(mSite))); + SiteUtils.getHomeURLOrHostName(mSite))); intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.start_over_email_body, mSite.getUrl())); try { startActivity(Intent.createChooser(intent, getString(R.string.contact_support))); @@ -1550,11 +1628,11 @@ private void handleStartOver() { ToastUtils.showToast(getActivity(), R.string.start_over_email_intent_error); } AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_START_OVER_CONTACT_SUPPORT_CLICKED, - mSite); + mSite); } private void showListEditorDialog(int titleRes, int headerRes) { - mDialog = new Dialog(getActivity(), R.style.WordPress); + mDialog = new Dialog(getActivity(), R.style.Calypso_SiteSettingsTheme); mDialog.setOnDismissListener(this); mDialog.setTitle(titleRes); mDialog.setContentView(getListEditorView(getString(headerRes))); @@ -1563,11 +1641,12 @@ private void showListEditorDialog(int titleRes, int headerRes) { } private View getListEditorView(String headerText) { - View view = View.inflate(getActivity(), R.layout.list_editor, null); + Context themer = new ContextThemeWrapper(getActivity(), R.style.Calypso_SiteSettingsTheme); + View view = View.inflate(themer, R.layout.list_editor, null); ((TextView) view.findViewById(R.id.list_editor_header_text)).setText(headerText); mAdapter = null; - final EmptyViewRecyclerView list = view.findViewById(R.id.list); + final EmptyViewRecyclerView list = view.findViewById(android.R.id.list); list.setLayoutManager( new SmoothScrollLinearLayoutManager( getActivity(), @@ -1575,7 +1654,7 @@ private View getListEditorView(String headerText) { false, getResources().getInteger(android.R.integer.config_mediumAnimTime) ) - ); + ); list.setAdapter(getAdapter()); list.setEmptyView(view.findViewById(R.id.empty_view)); list.addOnItemTouchListener( @@ -1610,46 +1689,74 @@ public void onLongItemClick(View view, int position) { ) ); FloatingActionButton button = view.findViewById(R.id.fab_button); - button.setOnClickListener(v -> { - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); - final EditText input = new EditText(getActivity()); - input.setWidth(getResources().getDimensionPixelSize(R.dimen.list_editor_input_max_width)); - input.setHint(R.string.site_settings_list_editor_input_hint); - builder.setPositiveButton(android.R.string.ok, (dialog, which) -> { - String entry = input.getText().toString(); - if (!TextUtils.isEmpty(entry) && !mEditingList.contains(entry)) { - // don't modify mEditingList if it's not a reference to the JP whitelist keys - if (mEditingList == mSiteSettings.getJetpackWhitelistKeys() && !isValidIpOrRange(entry)) { - ToastUtils.showToast(getActivity(), R.string.invalid_ip_or_range); - return; - } + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + final EditText input = new EditText(getActivity()); + WPPrefUtils.layoutAsInput(input); + input.setWidth(getResources().getDimensionPixelSize(R.dimen.list_editor_input_max_width)); + input.setHint(R.string.site_settings_list_editor_input_hint); + builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + String entry = input.getText().toString(); + if (!TextUtils.isEmpty(entry) && !mEditingList.contains(entry)) { + // don't modify mEditingList if it's not a reference to the JP whitelist keys + if (mEditingList == mSiteSettings.getJetpackWhitelistKeys() && !isValidIpOrRange(entry)) { + ToastUtils.showToast(getActivity(), R.string.invalid_ip_or_range); + return; + } - mEditingList.add(entry); - getAdapter().notifyItemInserted(getAdapter().getItemCount() - 1); - list.post(() -> list.smoothScrollToPosition(getAdapter().getItemCount() - 1) - ); - mSiteSettings.saveSettings(); - AnalyticsUtils.trackWithSiteDetails(Stat.SITE_SETTINGS_ADDED_LIST_ITEM, - mSite); + mEditingList.add(entry); + getAdapter().notifyItemInserted(getAdapter().getItemCount() - 1); + list.post( + new Runnable() { + @Override + public void run() { + list.smoothScrollToPosition(getAdapter().getItemCount() - 1); + } + } + ); + mSiteSettings.saveSettings(); + AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_ADDED_LIST_ITEM, + mSite); + } + } + }); + builder.setNegativeButton(R.string.cancel, null); + final AlertDialog alertDialog = builder.create(); + int spacing = getResources().getDimensionPixelSize(R.dimen.dlp_padding_start); + alertDialog.setView(input, spacing, spacing, spacing, 0); + alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); + alertDialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); + alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + alertDialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_HIDDEN); + } + }); + alertDialog.show(); + Button positive = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); + Button negative = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + if (positive != null) { + WPPrefUtils.layoutAsFlatButton(positive); + } + if (negative != null) { + WPPrefUtils.layoutAsFlatButton(negative); } - }); - builder.setNegativeButton(R.string.cancel, null); - final AlertDialog alertDialog = builder.create(); - int spacing = getResources().getDimensionPixelSize(R.dimen.dlp_padding_start); - alertDialog.setView(input, spacing, spacing, spacing, 0); - alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); - alertDialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); - alertDialog.setOnDismissListener( - dialog -> alertDialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_HIDDEN)); - alertDialog.show(); - }); - button.setOnLongClickListener(view1 -> { - if (view1.isHapticFeedbackEnabled()) { - view1.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } + }); + button.setOnLongClickListener(new OnLongClickListener() { + @Override public boolean onLongClick(View view) { + if (view.isHapticFeedbackEnabled()) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } - Toast.makeText(view1.getContext(), R.string.add, Toast.LENGTH_SHORT).show(); - return true; + Toast.makeText(view.getContext(), R.string.add, Toast.LENGTH_SHORT).show(); + return true; + } }); ViewUtilsKt.redirectContextClickToLongPressListener(button); @@ -1697,7 +1804,7 @@ private void setupJetpackSecurityScreen() { String title = getString(R.string.jetpack_security_setting_title); Dialog dialog = mJpSecuritySettings.getDialog(); if (dialog != null) { - setupPreferenceList(dialog.findViewById(android.R.id.list), getResources()); + setupPreferenceList((ListView) dialog.findViewById(android.R.id.list), getResources()); WPActivityUtils.addToolbarToDialog(this, dialog, title); } } @@ -1854,21 +1961,27 @@ private void exportSite() { if (mSite.isWPCom()) { final ProgressDialog progressDialog = ProgressDialog .show(getActivity(), "", getActivity().getString(R.string.exporting_content_progress), true, true); - WordPress.getRestClientUtils().exportContentAll(mSite.getSiteId(), response -> { - if (isAdded()) { - AnalyticsUtils.trackWithSiteDetails( - Stat.SITE_SETTINGS_EXPORT_SITE_RESPONSE_OK, mSite); - dismissProgressDialog(progressDialog); - WPSnackbar.make(getView(), R.string.export_email_sent, Snackbar.LENGTH_LONG).show(); + WordPress.getRestClientUtils().exportContentAll(mSite.getSiteId(), new RestRequest.Listener() { + @Override + public void onResponse(JSONObject response) { + if (isAdded()) { + AnalyticsUtils.trackWithSiteDetails( + AnalyticsTracker.Stat.SITE_SETTINGS_EXPORT_SITE_RESPONSE_OK, mSite); + dismissProgressDialog(progressDialog); + WPSnackbar.make(getView(), R.string.export_email_sent, Snackbar.LENGTH_LONG).show(); + } } - }, error -> { - if (isAdded()) { - HashMap errorProperty = new HashMap<>(); - errorProperty.put(ANALYTICS_ERROR_PROPERTY_KEY, error.getMessage()); - AnalyticsUtils.trackWithSiteDetails( - Stat.SITE_SETTINGS_EXPORT_SITE_RESPONSE_ERROR, - mSite, errorProperty); - dismissProgressDialog(progressDialog); + }, new RestRequest.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + if (isAdded()) { + HashMap errorProperty = new HashMap<>(); + errorProperty.put(ANALYTICS_ERROR_PROPERTY_KEY, error.getMessage()); + AnalyticsUtils.trackWithSiteDetails( + AnalyticsTracker.Stat.SITE_SETTINGS_EXPORT_SITE_RESPONSE_ERROR, + mSite, errorProperty); + dismissProgressDialog(progressDialog); + } } }); } @@ -1885,7 +1998,7 @@ private void deleteSite() { public void handleSiteDeleted() { AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat - .SITE_SETTINGS_DELETE_SITE_RESPONSE_OK, mSite); + .SITE_SETTINGS_DELETE_SITE_RESPONSE_OK, mSite); dismissProgressDialog(mDeleteSiteProgressDialog); mDeleteSiteProgressDialog = null; mSite = null; @@ -1906,18 +2019,28 @@ public void handleDeleteSiteError(DeleteSiteError error) { } private void showDeleteSiteErrorDialog() { - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(R.string.error_deleting_site); builder.setMessage(R.string.error_deleting_site_summary); - builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); - builder.setPositiveButton(R.string.contact_support, - (dialog, which) -> mZendeskHelper.createNewTicket(getActivity(), Origin.DELETE_SITE, mSite)); + builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + } + }); + builder.setPositiveButton(R.string.contact_support, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + mZendeskHelper.createNewTicket(getActivity(), Origin.DELETE_SITE, mSite); + } + }); builder.show(); } private MultiSelectRecyclerViewAdapter getAdapter() { if (mAdapter == null) { - mAdapter = new MultiSelectRecyclerViewAdapter(mEditingList); + mAdapter = new MultiSelectRecyclerViewAdapter(getActivity(), mEditingList); } return mAdapter; @@ -1933,7 +2056,7 @@ public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { HashMap properties = new HashMap<>(); properties.put("num_items_deleted", checkedItems.size()); AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_DELETED_LIST_ITEMS, - mSite, properties); + mSite, properties); for (int i = checkedItems.size() - 1; i >= 0; i--) { final int index = checkedItems.keyAt(i); @@ -1960,6 +2083,7 @@ public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { @Override public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { + WPActivityUtils.setStatusBarColor(mDialog.getWindow(), R.color.status_bar_action_mode); mActionMode = actionMode; MenuInflater inflater = actionMode.getMenuInflater(); inflater.inflate(R.menu.list_editor, menu); @@ -1968,6 +2092,7 @@ public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { @Override public void onDestroyActionMode(ActionMode mode) { + WPActivityUtils.setStatusBarColor(mDialog.getWindow(), R.color.status_bar); getAdapter().removeItemsSelected(); mActionMode = null; } @@ -1977,7 +2102,7 @@ public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { actionMode.setTitle(getString( R.string.site_settings_list_editor_action_mode_title, getAdapter().getItemsSelected().size()) - ); + ); return true; } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java index c98e50a3115b..da249e09c634 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java @@ -1,17 +1,22 @@ package org.wordpress.android.ui.prefs; +import android.app.AlertDialog; import android.app.FragmentTransaction; import android.app.ProgressDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; @@ -20,18 +25,14 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; -import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.apache.commons.text.StringEscapeUtils; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.Dispatcher; @@ -43,7 +44,6 @@ import org.wordpress.android.fluxc.store.TaxonomyStore; import org.wordpress.android.fluxc.store.TaxonomyStore.OnTaxonomyChanged; import org.wordpress.android.ui.ActionableEmptyView; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.util.ActivityUtils; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; @@ -54,12 +54,13 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Locale; import javax.inject.Inject; -public class SiteSettingsTagListActivity extends LocaleAwareActivity +public class SiteSettingsTagListActivity extends AppCompatActivity implements SearchView.OnQueryTextListener, MenuItem.OnActionExpandListener, SiteSettingsTagDetailFragment.OnTagDetailListener { @Inject Dispatcher mDispatcher; @@ -97,10 +98,6 @@ public void onCreate(Bundle savedInstanceState) { ((WordPress) getApplication()).component().inject(this); setContentView(R.layout.site_settings_tag_list_activity); - - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); @@ -121,14 +118,21 @@ public void onCreate(Bundle savedInstanceState) { } mFabView = findViewById(R.id.fab_button); - mFabView.setOnClickListener(view -> showDetailFragment(null)); - mFabView.setOnLongClickListener(view -> { - if (view.isHapticFeedbackEnabled()) { - view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + mFabView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showDetailFragment(null); } + }); + mFabView.setOnLongClickListener(new OnLongClickListener() { + @Override public boolean onLongClick(View view) { + if (view.isHapticFeedbackEnabled()) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } - Toast.makeText(view.getContext(), R.string.site_settings_tags_empty_button, Toast.LENGTH_SHORT).show(); - return true; + Toast.makeText(view.getContext(), R.string.site_settings_tags_empty_button, Toast.LENGTH_SHORT).show(); + return true; + } }); ViewUtilsKt.redirectContextClickToLongPressListener(mFabView); @@ -138,7 +142,11 @@ public void onCreate(Bundle savedInstanceState) { } mActionableEmptyView = findViewById(R.id.actionable_empty_view); - mActionableEmptyView.button.setOnClickListener(view -> showDetailFragment(null)); + mActionableEmptyView.button.setOnClickListener(new OnClickListener() { + @Override public void onClick(View view) { + showDetailFragment(null); + } + }); mRecycler = findViewById(R.id.recycler); mRecycler.setHasFixedSize(true); @@ -180,7 +188,7 @@ public void onStop() { } @Override - protected void onSaveInstanceState(@NotNull Bundle outState) { + protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); outState.putBoolean(KEY_IS_SEARCHING, mIsSearching); @@ -242,9 +250,12 @@ public void onBackPressed() { private void showFabIfHidden() { // redisplay hidden fab after a short delay long delayMs = getResources().getInteger(R.integer.fab_animation_delay); - new Handler().postDelayed(() -> { - if (!isFinishing() && mFabView.getVisibility() != View.VISIBLE) { - AniUtils.scaleIn(mFabView, AniUtils.Duration.MEDIUM); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + if (!isFinishing() && mFabView.getVisibility() != View.VISIBLE) { + AniUtils.scaleIn(mFabView, AniUtils.Duration.MEDIUM); + } } }, delayMs); } @@ -253,10 +264,13 @@ private void showFabWithConditions() { // scale in the fab after a brief delay if it's not already showing if (mFabView.getVisibility() != View.VISIBLE) { long delayMs = getResources().getInteger(R.integer.fab_animation_delay); - new Handler().postDelayed(() -> { - if (!mIsSearching && !isDetailFragmentShowing() - && mActionableEmptyView.getVisibility() != View.VISIBLE) { - showFabIfHidden(); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + if (!mIsSearching && !isDetailFragmentShowing() + && mActionableEmptyView.getVisibility() != View.VISIBLE) { + showFabIfHidden(); + } } }, delayMs); } @@ -293,7 +307,11 @@ public void onTaxonomyChanged(OnTaxonomyChanged event) { private void loadTags() { List tags = mTaxonomyStore.getTagsForSite(mSite); - Collections.sort(tags, (t1, t2) -> StringUtils.compareIgnoreCase(t1.getName(), t2.getName())); + Collections.sort(tags, new Comparator() { + public int compare(TermModel t1, TermModel t2) { + return StringUtils.compareIgnoreCase(t1.getName(), t2.getName()); + } + }); mAdapter = new TagListAdapter(tags); mRecycler.setAdapter(mAdapter); } @@ -403,15 +421,18 @@ public void onRequestDeleteTag(@NonNull TermModel term) { private void confirmDeleteTag(@NonNull final TermModel term) { String message = String.format(getString(R.string.dlg_confirm_delete_tag), term.getName()); - AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( + new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)); dialogBuilder.setMessage(message); dialogBuilder.setPositiveButton( getResources().getText(R.string.delete_yes), - (dialog, whichButton) -> { - showProgressDialog(R.string.dlg_deleting_tag); - Action action = TaxonomyActionBuilder.newDeleteTermAction( - new TaxonomyStore.RemoteTermPayload(term, mSite)); - mDispatcher.dispatch(action); + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + showProgressDialog(R.string.dlg_deleting_tag); + Action action = TaxonomyActionBuilder.newDeleteTermAction( + new TaxonomyStore.RemoteTermPayload(term, mSite)); + mDispatcher.dispatch(action); + } }); dialogBuilder.setNegativeButton(R.string.cancel, null); dialogBuilder.setCancelable(true); @@ -498,10 +519,13 @@ class TagViewHolder extends RecyclerView.ViewHolder { super(view); mTxtTag = view.findViewById(R.id.text_tag); mTxtCount = view.findViewById(R.id.text_count); - view.setOnClickListener(view1 -> { - if (!isDetailFragmentShowing()) { - int position = getAdapterPosition(); - showDetailFragment(mFilteredTags.get(position)); + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (!isDetailFragmentShowing()) { + int position = getAdapterPosition(); + showDetailFragment(mFilteredTags.get(position)); + } } }); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTimezoneDialog.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTimezoneDialog.java index 9b67df7808b8..541b4f9179c2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTimezoneDialog.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTimezoneDialog.java @@ -1,17 +1,19 @@ package org.wordpress.android.ui.prefs; import android.app.Activity; +import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; -import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.text.TextUtils; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.EditText; import android.widget.Filter; @@ -21,14 +23,13 @@ import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; -import androidx.core.graphics.ColorUtils; +import com.android.volley.AuthFailureError; import com.android.volley.RequestQueue; import com.android.volley.Response; +import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.json.JSONArray; import org.json.JSONException; @@ -38,12 +39,12 @@ import org.wordpress.android.networking.RestClientUtils; import org.wordpress.android.util.ActivityUtils; import org.wordpress.android.util.AppLog; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Locale; import java.util.Map; @@ -88,11 +89,14 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { View view = mInflater.inflate(R.layout.site_settings_timezone_dialog, null); mListView = view.findViewById(R.id.list); - mListView.setOnItemClickListener((parent, view1, position, id) -> { - Timezone tz = (Timezone) mAdapter.getItem(position); - mSelectedTimezone = tz.mValue; - mAdapter.notifyDataSetChanged(); - hideSearchKeyboard(); + mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + Timezone tz = (Timezone) mAdapter.getItem(position); + mSelectedTimezone = tz.mValue; + mAdapter.notifyDataSetChanged(); + hideSearchKeyboard(); + } }); mSearchView = view.findViewById(R.id.search_view); @@ -113,7 +117,6 @@ public boolean onQueryTextChange(String newText) { return true; } }); - mSearchView.setEnabled(false); mSearchView.setIconifiedByDefault(false); setSearchViewContentDescription(mSearchView); @@ -122,11 +125,8 @@ public boolean onQueryTextChange(String newText) { mEmptyView = view.findViewById(R.id.empty_view); mProgressView = view.findViewById(R.id.progress_view); - int topOffset = getResources().getDimensionPixelOffset(R.dimen.settings_fragment_dialog_vertical_inset); - - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()) - .setBackgroundInsetTop(topOffset) - .setBackgroundInsetBottom(topOffset); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(R.string.cancel, this); builder.setView(view); @@ -138,29 +138,35 @@ public boolean onQueryTextChange(String newText) { } private void requestTimezones() { - Response.Listener listener = response -> { - AppLog.d(AppLog.T.SETTINGS, "timezones requested"); - if (isAdded()) { - showProgressView(false); - if (!TextUtils.isEmpty(response)) { - loadTimezones(response); - } else { - AppLog.w(AppLog.T.SETTINGS, "empty response requesting timezones"); - dismissWithError(); + Response.Listener listener = new Response.Listener() { + @Override + public void onResponse(String response) { + AppLog.d(AppLog.T.SETTINGS, "timezones requested"); + if (isAdded()) { + showProgressView(false); + if (!TextUtils.isEmpty(response)) { + loadTimezones(response); + } else { + AppLog.w(AppLog.T.SETTINGS, "empty response requesting timezones"); + dismissWithError(); + } } } }; - Response.ErrorListener errorListener = error -> { - AppLog.e(AppLog.T.SETTINGS, "Error requesting timezones", error); - if (isAdded()) { - dismissWithError(); + Response.ErrorListener errorListener = new Response.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + AppLog.e(AppLog.T.SETTINGS, "Error requesting timezones", error); + if (isAdded()) { + dismissWithError(); + } } }; StringRequest request = new StringRequest(Constants.URL_TIMEZONE_ENDPOINT, listener, errorListener) { @Override - protected Map getParams() { + protected Map getParams() throws AuthFailureError { return RestClientUtils.getRestLocaleParams(getActivity()); } }; @@ -190,22 +196,29 @@ private void loadTimezones(@NonNull String responseJson) { JSONObject json = jsonTimezones.getJSONObject(i); timezones.add( new Timezone(json.getString("label"), json.getString("value")) - ); + ); } // sort by label - Collections.sort(timezones, (t1, t2) -> StringUtils.compare(t1.mLabel, t2.mLabel)); + Collections.sort(timezones, new Comparator() { + public int compare(Timezone t1, Timezone t2) { + return StringUtils.compare(t1.mLabel, t2.mLabel); + } + }); - mAdapter = new TimezoneAdapter(timezones, mListView.getContext()); + mAdapter = new TimezoneAdapter(timezones); mListView.setAdapter(mAdapter); mSearchView.setEnabled(true); // give the list time to load before making the selection - new Handler().postDelayed(() -> { - if (isAdded()) { - int index = mAdapter.indexOfValue(mSelectedTimezone); - if (index > -1) { - mListView.setSelection(index); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + if (isAdded()) { + int index = mAdapter.indexOfValue(mSelectedTimezone); + if (index > -1) { + mListView.setSelection(index); + } } } }, 100); @@ -270,21 +283,9 @@ private class TimezoneAdapter extends BaseAdapter implements Filterable { private final List mAllTimezones = new ArrayList<>(); private final List mFilteredTimezones = new ArrayList<>(); - private int mSelectedRowColor; - private int mUnselectedColor; - - private TimezoneAdapter(@NonNull List timezones, Context context) { + private TimezoneAdapter(@NonNull List timezones) { mAllTimezones.addAll(timezones); mFilteredTimezones.addAll(timezones); - - mSelectedRowColor = ColorUtils - .setAlphaComponent( - ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorOnSurface), - context.getResources() - .getInteger(R.integer.custom_popup_selected_list_item_opacity_dec) - ); - - mUnselectedColor = context.getResources().getColor(android.R.color.transparent); } @Override @@ -326,10 +327,8 @@ public View getView(int position, View convertView, ViewGroup parent) { boolean isSelected = mSelectedTimezone != null && mSelectedTimezone.equals(mFilteredTimezones.get(position).mValue); - - - int bgColor = isSelected ? mSelectedRowColor : mUnselectedColor; - holder.mTxtLabel.setBackgroundColor(bgColor); + int colorRes = isSelected ? R.color.primary_30 : android.R.color.transparent; + holder.mTxtLabel.setBackgroundColor(getResources().getColor(colorRes)); holder.mTxtLabel.setText(mFilteredTimezones.get(position).mLabel); return convertView; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SummaryEditTextPreference.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SummaryEditTextPreference.java index 269d69d0c3f5..b6321a6a454f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SummaryEditTextPreference.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SummaryEditTextPreference.java @@ -14,6 +14,7 @@ import android.view.ViewGroup; import android.view.ViewParent; import android.view.WindowManager; +import android.widget.Button; import android.widget.EditText; import android.widget.TextView; @@ -22,9 +23,8 @@ import androidx.core.view.MarginLayoutParamsCompat; import androidx.core.view.ViewCompat; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.R; +import org.wordpress.android.util.WPPrefUtils; import java.util.Locale; @@ -86,8 +86,13 @@ public SummaryEditTextPreference(Context context, AttributeSet attrs) { protected void onBindView(@NonNull View view) { super.onBindView(view); - TextView summaryView = view.findViewById(android.R.id.summary); + TextView titleView = (TextView) view.findViewById(android.R.id.title); + TextView summaryView = (TextView) view.findViewById(android.R.id.summary); + + if (titleView != null) WPPrefUtils.layoutAsSubhead(titleView); + if (summaryView != null) { + WPPrefUtils.layoutAsBody1(summaryView); summaryView.setEllipsize(TextUtils.TruncateAt.END); summaryView.setInputType(getEditText().getInputType()); if (mLines != -1) summaryView.setLines(mLines); @@ -104,14 +109,14 @@ public Dialog getDialog() { protected void showDialog(Bundle state) { Context context = getContext(); Resources res = context.getResources(); - MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); + AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.Calypso_Dialog_Alert); View titleView = View.inflate(getContext(), R.layout.detail_list_preference_title, null); mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE; builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(res.getString(android.R.string.cancel).toUpperCase(Locale.getDefault()), this); if (titleView != null) { - TextView titleText = titleView.findViewById(R.id.title); + TextView titleText = (TextView) titleView.findViewById(R.id.title); if (titleText != null) { titleText.setText(getDialogTitle()); } @@ -131,7 +136,7 @@ protected void showDialog(Bundle state) { builder.setView(view); } - mDialog = builder.create(); + if ((mDialog = builder.create()) == null) return; if (state != null) { mDialog.onRestoreInstanceState(state); @@ -139,6 +144,11 @@ protected void showDialog(Bundle state) { mDialog.setOnDismissListener(this); mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); mDialog.show(); + + Button positive = mDialog.getButton(DialogInterface.BUTTON_POSITIVE); + Button negative = mDialog.getButton(DialogInterface.BUTTON_NEGATIVE); + if (positive != null) WPPrefUtils.layoutAsFlatButton(positive); + if (negative != null) WPPrefUtils.layoutAsFlatButton(negative); } @Override @@ -149,19 +159,21 @@ protected void onBindDialogView(final View view) { EditText editText = getEditText(); ViewParent oldParent = editText.getParent(); if (oldParent != view) { - if (oldParent instanceof ViewGroup) { + if (oldParent != null && oldParent instanceof ViewGroup) { ViewGroup groupParent = (ViewGroup) oldParent; groupParent.removeView(editText); ViewCompat.setPaddingRelative(groupParent, ViewCompat.getPaddingStart(groupParent), 0, - ViewCompat.getPaddingEnd(groupParent), groupParent.getPaddingBottom()); + ViewCompat.getPaddingEnd(groupParent), groupParent.getPaddingBottom()); } onAddEditTextToDialogView(view, editText); } + WPPrefUtils.layoutAsInput(editText); editText.setSelection(editText.getText().length()); // RtL language support editText.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); - TextView message = view.findViewById(android.R.id.message); + TextView message = (TextView) view.findViewById(android.R.id.message); + WPPrefUtils.layoutAsDialogMessage(message); // Dialog message has some extra bottom margin we don't want ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) message.getLayoutParams(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPPreference.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPPreference.java index 0556992f5dd2..064d67386c3c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPPreference.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPPreference.java @@ -6,14 +6,14 @@ import android.preference.Preference; import android.text.TextUtils; import android.util.AttributeSet; +import android.util.TypedValue; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.core.content.res.ResourcesCompat; -import androidx.core.widget.TextViewCompat; import org.wordpress.android.R; +import org.wordpress.android.util.ContextExtensionsKt; public class WPPreference extends Preference implements PreferenceHint { private String mHint; @@ -38,23 +38,17 @@ protected void onBindView(@NonNull View view) { super.onBindView(view); Resources res = getContext().getResources(); - TextView titleView = view.findViewById(android.R.id.title); - TextView summaryView = view.findViewById(android.R.id.summary); + TextView titleView = (TextView) view.findViewById(android.R.id.title); + TextView summaryView = (TextView) view.findViewById(android.R.id.summary); if (titleView != null) { - TextViewCompat.setTextAppearance(titleView, R.style.TextAppearance_MaterialComponents_Subtitle1); - if (!isEnabled()) { - titleView.setAlpha(ResourcesCompat.getFloat(res, R.dimen.material_emphasis_disabled)); - } else { - titleView.setAlpha(1f); - } + titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.text_sz_large)); + titleView.setTextColor(res.getColor( + isEnabled() ? ContextExtensionsKt.getColorResIdFromAttribute(getContext(), R.attr.wpColorText) + : R.color.neutral_20)); } if (summaryView != null) { - TextViewCompat.setTextAppearance(summaryView, R.style.TextAppearance_MaterialComponents_Body2); - if (!isEnabled()) { - summaryView.setAlpha(ResourcesCompat.getFloat(res, R.dimen.material_emphasis_disabled)); - } else { - summaryView.setAlpha(ResourcesCompat.getFloat(res, R.dimen.material_emphasis_medium)); - } + summaryView.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.text_sz_medium)); + summaryView.setTextColor(res.getColor(isEnabled() ? R.color.neutral : R.color.neutral_20)); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPStartOverPreference.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPStartOverPreference.java index 786d8c20b3b2..c8e711dc0d43 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPStartOverPreference.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPStartOverPreference.java @@ -7,6 +7,7 @@ import android.view.View; import android.widget.Button; import android.widget.ImageView; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; @@ -35,7 +36,7 @@ public WPStartOverPreference(Context context, AttributeSet attrs) { if (index == R.styleable.WPStartOverPreference_buttonText) { mButtonText = array.getString(index); } else if (index == R.styleable.WPStartOverPreference_buttonTextColor) { - mButtonTextColor = array.getColor(index, ContextCompat.getColor(context, 0)); + mButtonTextColor = array.getColor(index, ContextCompat.getColor(context, android.R.color.black)); } else if (index == R.styleable.WPStartOverPreference_buttonTextAllCaps) { mButtonTextAllCaps = array.getBoolean(index, false); } else if (index == R.styleable.WPStartOverPreference_preficon) { @@ -51,26 +52,29 @@ protected void onBindView(@NonNull View view) { super.onBindView(view); if (view.findViewById(R.id.pref_icon) != null) { - ImageView imageView = view.findViewById(R.id.pref_icon); + ImageView imageView = (ImageView) view.findViewById(R.id.pref_icon); imageView.setImageDrawable(mPrefIcon); } if (view.findViewById(R.id.button) != null) { final WPStartOverPreference wpStartOverPreference = this; - Button button = view.findViewById(R.id.button); + Button button = (Button) view.findViewById(R.id.button); button.setText(mButtonText); - if (mButtonTextColor > 0) { - button.setTextColor(mButtonTextColor); - } + button.setTextColor(mButtonTextColor); button.setAllCaps(mButtonTextAllCaps); - button.setOnClickListener(v -> getOnPreferenceClickListener().onPreferenceClick(wpStartOverPreference)); + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getOnPreferenceClickListener().onPreferenceClick(wpStartOverPreference); + } + }); } - // TODO: FluxC: We might want to get the selected site here and update the view - // if (view.findViewById(R.id.domain) != null) { - // TextView textView = (TextView) view.findViewById(R.id.domain); - // textView.setText(UrlUtils.getHost(blog.getHomeURL())); - // } + if (view.findViewById(R.id.domain) != null) { + TextView textView = (TextView) view.findViewById(R.id.domain); + // TODO: FluxC: We might want to get the selected site here and update the view + // textView.setText(UrlUtils.getHost(blog.getHomeURL())); + } } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPSwitchPreference.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPSwitchPreference.java index 79fcf91f6a56..cacaf86d2ee7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPSwitchPreference.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/WPSwitchPreference.java @@ -8,23 +8,31 @@ import android.preference.SwitchPreference; import android.text.TextUtils; import android.util.AttributeSet; +import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.Switch; import android.widget.TextView; +import androidx.annotation.ColorRes; import androidx.annotation.NonNull; -import androidx.appcompat.content.res.AppCompatResources; +import androidx.core.content.ContextCompat; import androidx.core.view.ViewCompat; import org.wordpress.android.R; +import org.wordpress.android.util.ContextExtensionsKt; public class WPSwitchPreference extends SwitchPreference implements PreferenceHint { private String mHint; - private ColorStateList mTint; + private @ColorRes int mTint = 0; private ColorStateList mThumbTint; - private int mStartOffset = 0; + private ColorStateList mTrackTint; + private @ColorRes int mTextColor = 0; + private @ColorRes int mBackgroundCheckedColor = 0; + private @ColorRes int mBackgroundUncheckedColor = 0; + + private View mContainer; public WPSwitchPreference(Context context, AttributeSet attrs) { super(context, attrs); @@ -35,14 +43,17 @@ public WPSwitchPreference(Context context, AttributeSet attrs) { if (index == R.styleable.SummaryEditTextPreference_longClickHint) { mHint = array.getString(index); } else if (index == R.styleable.SummaryEditTextPreference_iconTint) { - int resourceId = array.getResourceId(index, 0); - if (resourceId != 0) { - mTint = AppCompatResources.getColorStateList(context, resourceId); - } + mTint = array.getResourceId(index, R.color.neutral); } else if (index == R.styleable.SummaryEditTextPreference_switchThumbTint) { mThumbTint = array.getColorStateList(index); - } else if (index == R.styleable.SummaryEditTextPreference_startOffset) { - mStartOffset = array.getDimensionPixelSize(index, 0); + } else if (index == R.styleable.SummaryEditTextPreference_switchTrackTint) { + mTrackTint = array.getColorStateList(index); + } else if (index == R.styleable.SummaryEditTextPreference_preferenceTextColor) { + mTextColor = array.getResourceId(index, android.R.color.white); + } else if (index == R.styleable.SummaryEditTextPreference_backgroundColorChecked) { + mBackgroundCheckedColor = array.getResourceId(index, android.R.color.white); + } else if (index == R.styleable.SummaryEditTextPreference_backgroundColorUnchecked) { + mBackgroundUncheckedColor = array.getResourceId(index, android.R.color.white); } } @@ -52,22 +63,33 @@ public WPSwitchPreference(Context context, AttributeSet attrs) { @Override protected void onBindView(@NonNull View view) { super.onBindView(view); + mContainer = view; ImageView icon = view.findViewById(android.R.id.icon); - if (icon != null && mTint != null) { - icon.setImageTintList(mTint); + if (icon != null && mTint != 0) { + icon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(view.getContext(), mTint))); } TextView titleView = view.findViewById(android.R.id.title); - if (titleView != null) { + TextView coloredTitleView = view.findViewById(R.id.colored_title); + if (titleView != null && coloredTitleView != null) { Resources res = getContext().getResources(); + coloredTitleView.setText(titleView.getText()); + coloredTitleView.setVisibility(View.VISIBLE); + titleView.setVisibility(View.GONE); + titleView.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimensionPixelSize(R.dimen.text_sz_large)); + if (mTextColor == 0) { + coloredTitleView.setTextColor(res.getColor( + isEnabled() ? ContextExtensionsKt.getColorResIdFromAttribute(getContext(), R.attr.wpColorText) + : R.color.neutral_20)); + } else { + coloredTitleView.setTextColor(ContextCompat.getColor(this.getContext(), R.color.white)); + } // add padding to the start of nested preferences if (!TextUtils.isEmpty(getDependency())) { int margin = res.getDimensionPixelSize(R.dimen.margin_large); - ViewCompat.setPaddingRelative(titleView, margin + mStartOffset, 0, 0, 0); - } else { - ViewCompat.setPaddingRelative(titleView, mStartOffset, 0, 0, 0); + ViewCompat.setPaddingRelative(coloredTitleView, margin, 0, 0, 0); } } @@ -75,9 +97,19 @@ protected void onBindView(@NonNull View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Switch switchControl = getSwitch((ViewGroup) view); if (switchControl != null) { - if (mThumbTint != null) { + if (mThumbTint == null) { + switchControl.setThumbTintList(ContextCompat.getColorStateList(this.getContext(), + R.color.primary_40_gray_20_gray_40_selector)); + } else { switchControl.setThumbTintList(mThumbTint); } + if (mTrackTint == null) { + switchControl.setTrackTintList(ContextCompat.getColorStateList(this.getContext(), + R.color.primary_40_gray_90_gray_50_selector)); + } else { + switchControl.setTrackTintList(mTrackTint); + } + setBackground(switchControl.isChecked()); } } @@ -86,6 +118,16 @@ protected void onBindView(@NonNull View view) { getContext().getResources().getDimensionPixelSize(R.dimen.margin_extra_large), 0, 0, 0); } + private void setBackground(boolean checked) { + if (mContainer != null && mBackgroundCheckedColor != 0 && mBackgroundUncheckedColor != 0) { + if (checked) { + mContainer.setBackgroundColor(ContextCompat.getColor(this.getContext(), mBackgroundCheckedColor)); + } else { + mContainer.setBackgroundColor(ContextCompat.getColor(this.getContext(), mBackgroundUncheckedColor)); + } + } + } + private Switch getSwitch(ViewGroup parentView) { for (int i = 0; i < parentView.getChildCount(); i++) { View childView = parentView.getChildAt(i); @@ -102,6 +144,11 @@ private Switch getSwitch(ViewGroup parentView) { return null; } + @Override public void setChecked(boolean checked) { + super.setChecked(checked); + setBackground(checked); + } + @Override public boolean hasHint() { return !TextUtils.isEmpty(mHint); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationSettingsFollowedDialog.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationSettingsFollowedDialog.java index 40fe0e268902..e2de9491c222 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationSettingsFollowedDialog.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationSettingsFollowedDialog.java @@ -2,24 +2,25 @@ import android.annotation.SuppressLint; import android.app.Activity; +import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; +import android.widget.Button; import android.widget.CompoundButton; import android.widget.RadioButton; import android.widget.RadioGroup; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.SwitchCompat; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.R; import org.wordpress.android.fluxc.store.AccountStore.UpdateSubscriptionPayload.SubscriptionFrequency; +import org.wordpress.android.util.WPPrefUtils; /** * A {@link DialogFragment} displaying notification settings for followed blogs. @@ -88,7 +89,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { } } - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); builder.setTitle(getString(R.string.notification_settings_followed_dialog_title)); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(R.string.cancel, this); @@ -97,6 +99,23 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { return builder.create(); } + @Override + public void onStart() { + super.onStart(); + + AlertDialog dialog = (AlertDialog) getDialog(); + Button positive = dialog.getButton(DialogInterface.BUTTON_POSITIVE); + Button negative = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); + + if (positive != null) { + WPPrefUtils.layoutAsFlatButton(positive); + } + + if (negative != null) { + WPPrefUtils.layoutAsFlatButton(negative); + } + } + @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsActivity.java index 352de1243191..697734c95163 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsActivity.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.prefs.notifications; import android.app.FragmentManager; +import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.text.TextUtils; @@ -11,23 +12,21 @@ import android.widget.TextView; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.preference.PreferenceManager; -import com.google.android.material.elevation.ElevationOverlayProvider; - import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.wordpress.android.R; import org.wordpress.android.analytics.AnalyticsTracker; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.notifications.NotificationEvents; import org.wordpress.android.ui.prefs.notifications.PrefMasterSwitchToolbarView.MasterSwitchToolbarListener; -import org.wordpress.android.util.ContextExtensionsKt; +import org.wordpress.android.util.LocaleManager; // Simple wrapper activity for NotificationsSettingsFragment -public class NotificationsSettingsActivity extends LocaleAwareActivity +public class NotificationsSettingsActivity extends AppCompatActivity implements MasterSwitchToolbarListener { private TextView mMessageTextView; private View mMessageContainer; @@ -35,6 +34,11 @@ public class NotificationsSettingsActivity extends LocaleAwareActivity protected SharedPreferences mSharedPreferences; protected View mFragmentContainer; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -124,13 +128,6 @@ private void setUpMasterSwitch() { boolean isMasterChecked = mSharedPreferences.getBoolean(getString(R.string.wp_pref_notifications_master), true); masterSwitchToolBarView.loadInitialState(isMasterChecked); - ElevationOverlayProvider elevationOverlayProvider = new ElevationOverlayProvider(this); - float cardElevation = getResources().getDimension(R.dimen.card_elevation); - int appBarColor = elevationOverlayProvider - .compositeOverlay(ContextExtensionsKt.getColorFromAttribute(this, R.attr.wpColorAppBar), cardElevation); - - masterSwitchToolBarView.setBackgroundColor(appBarColor); - hideDisabledView(isMasterChecked); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsDialogPreference.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsDialogPreference.java index 0f91fe2a67a4..9f76bf35a36f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsDialogPreference.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsDialogPreference.java @@ -17,7 +17,6 @@ import androidx.annotation.NonNull; import androidx.appcompat.widget.SwitchCompat; -import androidx.core.content.ContextCompat; import org.json.JSONException; import org.json.JSONObject; @@ -28,7 +27,6 @@ import org.wordpress.android.ui.prefs.notifications.PrefMasterSwitchToolbarView.MasterSwitchToolbarListener; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; -import org.wordpress.android.util.ContextUtilsKt; import org.wordpress.android.util.JSONUtils; import java.util.Iterator; @@ -87,10 +85,10 @@ protected void onBindDialogView(@NonNull View view) { protected void onPrepareDialogBuilder(Builder builder) { super.onPrepareDialogBuilder(builder); if (mShouldDisplayMasterSwitch) { - if (mTitleViewWithMasterSwitch == null) { - AppLog.e(T.NOTIFS, "Master switch enabled but layout not set"); - return; - } + if (mTitleViewWithMasterSwitch == null) { + AppLog.e(T.NOTIFS, "Master switch enabled but layout not set"); + return; + } builder.setCustomTitle(mTitleViewWithMasterSwitch); } } @@ -109,10 +107,9 @@ protected View onCreateDialogView() { if (mShouldDisplayMasterSwitch) { View dividerView = new View(getContext()); int dividerHeight = getContext().getResources().getDimensionPixelSize( - R.dimen.notifications_settings_dialog_divider_height + R.dimen.notifications_settings_dialog_divider_height ); - dividerView - .setBackground(ContextUtilsKt.getDrawableFromAttribute(getContext(), android.R.attr.listDivider)); + dividerView.setBackgroundColor(getContext().getResources().getColor(R.color.divider)); dividerView.setLayoutParams(new ViewGroup.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, dividerHeight)); innerView.addView(dividerView); } else { @@ -125,17 +122,17 @@ protected View onCreateDialogView() { mDisabledView = View.inflate(getContext(), R.layout.notifications_tab_disabled_text_layout, null); mDisabledView.setLayoutParams( new ViewGroup.LayoutParams( - LayoutParams.MATCH_PARENT, - LayoutParams.WRAP_CONTENT + LayoutParams.MATCH_PARENT, + LayoutParams.WRAP_CONTENT ) - ); + ); mOptionsView = new LinearLayout(getContext()); mOptionsView.setLayoutParams( - new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.MATCH_PARENT, - LinearLayout.LayoutParams.MATCH_PARENT - ) + new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT + ) ); mOptionsView.setOrientation(LinearLayout.VERTICAL); @@ -285,8 +282,6 @@ private void setupTitleViewWithMasterSwitch(View view) { mMasterSwitchToolbarView = mTitleViewWithMasterSwitch.findViewById(R.id.master_switch); mMasterSwitchToolbarView.setMasterSwitchToolbarListener(this); - mMasterSwitchToolbarView - .setBackgroundColor(ContextCompat.getColor(getContext(), android.R.color.transparent)); // Master Switch initial state: // On: If at least one of the settings options is on diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java index 2b9877f8e558..0d9ef2189a37 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java @@ -4,7 +4,6 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.PorterDuff.Mode; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -18,10 +17,12 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.widget.EditText; -import androidx.annotation.DrawableRes; +import androidx.annotation.ColorRes; import androidx.annotation.NonNull; import androidx.appcompat.widget.SearchView; +import androidx.core.content.ContextCompat; import com.android.volley.VolleyError; import com.wordpress.rest.RestRequest; @@ -58,7 +59,7 @@ import org.wordpress.android.ui.prefs.notifications.FollowedBlogsProvider.PreferenceModel.ClickHandler; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; -import org.wordpress.android.util.ContextExtensionsKt; +import org.wordpress.android.util.ColorUtils; import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.ToastUtils.Duration; @@ -137,8 +138,10 @@ private void removeSightAndSoundsForAPI26() { PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference(getActivity().getString(R.string.wp_pref_notifications_root)); - PreferenceCategory categorySightsAndSounds = (PreferenceCategory) preferenceScreen - .findPreference(getActivity().getString(R.string.pref_notification_sights_sounds)); + PreferenceCategory categorySightsAndSounds = + (PreferenceCategory) preferenceScreen.findPreference(getActivity() + .getString( + R.string.pref_notification_sights_sounds)); preferenceScreen.removePreference(categorySightsAndSounds); } } @@ -189,6 +192,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { mSearchMenuItem = menu.findItem(R.id.menu_notifications_settings_search); mSearchView = (SearchView) mSearchMenuItem.getActionView(); mSearchView.setQueryHint(getString(R.string.search_sites)); + setSearchViewHintColor(mSearchView, R.color.wordpress_blue_5); mBlogsCategory = (PreferenceCategory) findPreference( getString(R.string.pref_notification_blogs)); mFollowedBlogsCategory = (PreferenceCategory) findPreference( @@ -240,6 +244,14 @@ public boolean onMenuItemActionCollapse(MenuItem item) { } } + private static void setSearchViewHintColor(@NonNull SearchView searchView, @ColorRes int colorResId) { + final Context context = searchView.getContext(); + if (context != null) { + ((EditText) searchView.findViewById(androidx.appcompat.R.id.search_src_text)) + .setHintTextColor(ContextCompat.getColor(context, colorResId)); + } + } + @Override public void onSaveInstanceState(Bundle outState) { if (mSearchView != null && !TextUtils.isEmpty(mSearchView.getQuery())) { @@ -681,6 +693,7 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen } PreferenceCategory rootCategory = new PreferenceCategory(context); + rootCategory.setLayoutResource(R.layout.wp_preference_category); rootCategory.setTitle(R.string.notification_types); preferenceScreen.addPreference(rootCategory); @@ -689,7 +702,8 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen mOnSettingsChangedListener ); - setPreferenceIcon(timelinePreference, R.drawable.ic_bell_white_24dp); + timelinePreference.setIcon(ColorUtils.INSTANCE.applyTintToDrawable(context, R.drawable.ic_bell_white_24dp, + R.color.neutral_60)); timelinePreference.setTitle(R.string.notifications_tab); timelinePreference.setDialogTitle(R.string.notifications_tab); timelinePreference.setSummary(R.string.notifications_tab_summary); @@ -700,7 +714,8 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen mOnSettingsChangedListener ); - setPreferenceIcon(emailPreference, R.drawable.ic_mail_white_24dp); + emailPreference.setIcon(ColorUtils.INSTANCE.applyTintToDrawable(context, R.drawable.ic_mail_white_24dp, + R.color.neutral_60)); emailPreference.setTitle(R.string.email); emailPreference.setDialogTitle(R.string.email); emailPreference.setSummary(R.string.notifications_email_summary); @@ -713,7 +728,9 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen context, null, channel, NotificationsSettings.Type.DEVICE, blogId, mNotificationsSettings, mOnSettingsChangedListener ); - setPreferenceIcon(devicePreference, R.drawable.ic_phone_white_24dp); + + devicePreference.setIcon(ColorUtils.INSTANCE.applyTintToDrawable(context, R.drawable.ic_phone_white_24dp, + R.color.neutral_60)); devicePreference.setTitle(R.string.app_notifications); devicePreference.setDialogTitle(R.string.app_notifications); devicePreference.setSummary(R.string.notifications_push_summary); @@ -724,13 +741,6 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen mTypePreferenceCategories.add(rootCategory); } - private void setPreferenceIcon(NotificationsSettingsDialogPreference preference, @DrawableRes int drawableRes) { - preference.setIcon(drawableRes); - preference.getIcon().setTintMode(Mode.SRC_IN); - preference.getIcon().setTintList(ContextExtensionsKt - .getColorStateListFromAttribute(preference.getContext(), R.attr.wpColorOnSurfaceMedium)); - } - private void addSitesForViewAllSitesScreen(PreferenceScreen preferenceScreen, boolean isFollowed) { Context context = getActivity(); if (context == null) { @@ -738,6 +748,7 @@ private void addSitesForViewAllSitesScreen(PreferenceScreen preferenceScreen, bo } PreferenceCategory rootCategory = new PreferenceCategory(context); + rootCategory.setLayoutResource(R.layout.wp_preference_category); rootCategory.setTitle(isFollowed ? R.string.notification_settings_category_followed_sites : R.string.notification_settings_category_your_sites); preferenceScreen.addPreference(rootCategory); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/PrefMasterSwitchToolbarView.kt b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/PrefMasterSwitchToolbarView.kt index 44deb5fde5ea..b7e5e859cfe1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/PrefMasterSwitchToolbarView.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/PrefMasterSwitchToolbarView.kt @@ -10,16 +10,15 @@ import android.widget.CompoundButton.OnCheckedChangeListener import android.widget.LinearLayout import android.widget.TextView import android.widget.Toast -import androidx.annotation.AttrRes -import androidx.annotation.ColorInt +import androidx.annotation.ColorRes import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.Toolbar +import androidx.core.content.ContextCompat import androidx.core.view.ViewCompat -import org.wordpress.android.BuildConfig import org.wordpress.android.R -import org.wordpress.android.util.AppLog -import org.wordpress.android.util.getColorFromAttribute import org.wordpress.android.util.redirectContextClickToLongPressListener +import org.wordpress.android.BuildConfig +import org.wordpress.android.util.AppLog /** * Custom view for master switch in toolbar for preferences. @@ -33,26 +32,29 @@ class PrefMasterSwitchToolbarView @JvmOverloads constructor( OnCheckedChangeListener, OnLongClickListener, OnClickListener { - // We should refactor this part to use style attributes, since enum is not too theming friendly enum class PrefMasterSwitchToolbarViewStyle constructor( val value: Int, - @AttrRes val titleColorResId: Int, - @AttrRes val backgroundColorResId: Int + @ColorRes val titleColorResId: Int, + @ColorRes val backgroundColorResId: Int, + @ColorRes val thumbTintColorListResId: Int, + @ColorRes val trackTintColorListResId: Int ) { HIGHLIGHTED( - 0, - R.attr.colorOnPrimary, - R.attr.colorPrimary + 0, + R.color.white, + R.color.primary_40, + R.color.primary_30_neutral_10_selector, + R.color.primary_30_primary_20_selector ), NORMAL( - 1, - R.attr.colorOnSurface, - R.attr.colorSurface + 1, + R.color.black, + R.color.white, + R.color.primary_30_neutral_selector, + R.color.primary_5_neutral_20_selector ); - companion object { - fun fromInt(value: Int): PrefMasterSwitchToolbarViewStyle? = - values().firstOrNull { it.value == value } + fun fromInt(value: Int): PrefMasterSwitchToolbarViewStyle? = values().firstOrNull { it.value == value } } } @@ -122,10 +124,7 @@ class PrefMasterSwitchToolbarView @JvmOverloads constructor( masterOffsetEndResId ) } - val viewStyle = typedArray.getInt( - R.styleable.PrefMasterSwitchToolbarView_masterViewStyle, - -1 - ) + val viewStyle = typedArray.getInt(R.styleable.PrefMasterSwitchToolbarView_masterViewStyle, -1) setTitleOn(titleOn) setTitleOff(titleOff) @@ -231,10 +230,8 @@ class PrefMasterSwitchToolbarView @JvmOverloads constructor( } ?: if (BuildConfig.DEBUG) { throw IllegalStateException("Unknown view style id: $viewStyleInt") } else { - AppLog.e( - AppLog.T.SETTINGS, - "PrefMasterSwitchToolbarView.setViewStyle called from xml with an unknown viewStyle." - ) + AppLog.e(AppLog.T.SETTINGS, "PrefMasterSwitchToolbarView.setViewStyle called from xml " + + "with an unknown viewStyle.") } } @@ -248,15 +245,15 @@ class PrefMasterSwitchToolbarView @JvmOverloads constructor( } private fun loadResourcesForViewStyle(viewStyle: PrefMasterSwitchToolbarViewStyle) { - val titleColor = context.getColorFromAttribute(viewStyle.titleColorResId) - val backgroundColor = context.getColorFromAttribute(viewStyle.backgroundColorResId) + val titleColor = ContextCompat.getColor(context, viewStyle.titleColorResId) + val backgroundColor = ContextCompat.getColor(context, viewStyle.backgroundColorResId) + val thumbColorList = ContextCompat.getColorStateList(context, viewStyle.thumbTintColorListResId) + val trackColorList = ContextCompat.getColorStateList(context, viewStyle.trackTintColorListResId) toolbarSwitch.setTitleTextColor(titleColor) toolbarSwitch.setBackgroundColor(backgroundColor) - } - - override fun setBackgroundColor(@ColorInt color: Int) { - toolbarSwitch.setBackgroundColor(color) + masterSwitch.thumbTintList = thumbColorList + masterSwitch.trackTintList = trackColorList } /* diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/ConnectButton.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/ConnectButton.java index 8d85e646c38d..7f10a21b9534 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/ConnectButton.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/ConnectButton.java @@ -2,32 +2,37 @@ import android.content.Context; import android.util.AttributeSet; +import android.widget.FrameLayout; +import android.widget.TextView; import androidx.annotation.StringRes; -import com.google.android.material.button.MaterialButton; - import org.wordpress.android.R; import org.wordpress.android.ui.publicize.PublicizeConstants.ConnectAction; /** * Publicize connect/disconnect/reconnect button */ -public class ConnectButton extends MaterialButton { +public class ConnectButton extends FrameLayout { private ConnectAction mConnectAction = ConnectAction.CONNECT; public ConnectButton(Context context) { super(context); - updateView(); + initView(context); } public ConnectButton(Context context, AttributeSet attrs) { super(context, attrs); - updateView(); + initView(context); } public ConnectButton(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + initView(context); + } + + private void initView(Context context) { + inflate(context, R.layout.publicize_connect_button, this); updateView(); } @@ -49,7 +54,8 @@ private void updateView() { default: return; } - setText(captionResId); + TextView txtConnect = (TextView) findViewById(R.id.text_connect); + txtConnect.setText(captionResId); } public ConnectAction getAction() { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserDialogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserDialogFragment.java index f6bd9ad1b564..e9365eb76ca9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserDialogFragment.java @@ -4,6 +4,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.widget.LinearLayout; @@ -14,8 +15,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.greenrobot.eventbus.EventBus; import org.json.JSONArray; import org.json.JSONException; @@ -51,7 +50,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { //noinspection InflateParams View view = inflater.inflate(R.layout.publicize_account_chooser_dialog, null); - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); configureAlertDialog(view, builder); configureRecyclerViews(view); @@ -71,7 +71,7 @@ private void configureRecyclerViews(View view) { PublicizeAccountChooserListAdapter notConnectedAdapter = new PublicizeAccountChooserListAdapter(getActivity(), mNotConnectedAccounts, this, false); notConnectedAdapter.setHasStableIds(true); - mNotConnectedRecyclerView = view.findViewById(R.id.not_connected_recyclerview); + mNotConnectedRecyclerView = (RecyclerView) view.findViewById(R.id.not_connected_recyclerview); mNotConnectedRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); mNotConnectedRecyclerView.setAdapter(notConnectedAdapter); @@ -83,12 +83,12 @@ private void configureRecyclerViews(View view) { } private void hideConnectedView(View view) { - LinearLayout connectedHeader = view.findViewById(R.id.connected_header); + LinearLayout connectedHeader = (LinearLayout) view.findViewById(R.id.connected_header); connectedHeader.setVisibility(View.GONE); } private void populateConnectedListView(View view) { - RecyclerView listViewConnected = view.findViewById(R.id.connected_recyclerview); + RecyclerView listViewConnected = (RecyclerView) view.findViewById(R.id.connected_recyclerview); PublicizeAccountChooserListAdapter connectedAdapter = new PublicizeAccountChooserListAdapter(getActivity(), mConnectedAccounts, null, true); @@ -100,21 +100,37 @@ private void configureAlertDialog(View view, AlertDialog.Builder builder) { builder.setView(view); builder.setTitle(getString(R.string.connecting_social_network, mConnectionName)); builder.setMessage(getString(R.string.connection_chooser_message)); - builder.setPositiveButton(R.string.share_btn_connect, (dialogInterface, i) -> { - dialogInterface.dismiss(); - int keychainId = mNotConnectedAccounts.get(mSelectedIndex).connectionId; - String service = mNotConnectedAccounts.get(mSelectedIndex).getService(); - String externalUserId = mNotConnectedAccounts.get(mSelectedIndex).getExternalId(); - EventBus.getDefault().post(new PublicizeEvents.ActionAccountChosen(mSite.getSiteId(), keychainId, - service, externalUserId)); + builder.setPositiveButton(R.string.share_btn_connect, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); + int keychainId = mNotConnectedAccounts.get(mSelectedIndex).connectionId; + String service = mNotConnectedAccounts.get(mSelectedIndex).getService(); + String externalUserId = mNotConnectedAccounts.get(mSelectedIndex).getExternalId(); + EventBus.getDefault().post(new PublicizeEvents.ActionAccountChosen(mSite.getSiteId(), keychainId, + service, externalUserId)); + } }); - builder.setNegativeButton(R.string.cancel, (dialogInterface, i) -> { - dialogInterface.cancel(); - ToastUtils.showToast(getActivity(), - getActivity().getString(R.string.cannot_connect_account_error, mConnectionName)); + builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.cancel(); + ToastUtils.showToast(getActivity(), + getActivity().getString(R.string.cannot_connect_account_error, mConnectionName)); + } }); } + private boolean containsSiteId(long[] array) { + for (long a : array) { + if (a == mSite.getSiteId()) { + return true; + } + } + + return false; + } + private void retrieveCurrentSiteFromArgs() { Bundle args = getArguments(); if (args != null) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserListAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserListAdapter.java index a2af1e239de8..409bc229b741 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserListAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeAccountChooserListAdapter.java @@ -10,7 +10,6 @@ import androidx.recyclerview.widget.RecyclerView; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.models.PublicizeConnection; @@ -40,7 +39,7 @@ public PublicizeAccountChooserListAdapter(Context context, List { - if (mListener != null) { - mSelectedPosition = holder.getAdapterPosition(); - mListener.onAccountSelected(mSelectedPosition); + holder.mView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (mListener != null) { + mSelectedPosition = holder.getAdapterPosition(); + mListener.onAccountSelected(mSelectedPosition); + } } }); } else { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeBaseFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeBaseFragment.java index 77099d34bb26..99d81ccc443d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeBaseFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeBaseFragment.java @@ -7,7 +7,7 @@ import org.wordpress.android.R; -class PublicizeBaseFragment extends Fragment { +public class PublicizeBaseFragment extends Fragment { private Toolbar getToolbar() { if (getActivity() != null) { return (Toolbar) getActivity().findViewById(R.id.toolbar); @@ -26,7 +26,7 @@ void setTitle(String title) { toolbar.setTitle(title); } if (getActivity() != null) { - // important for accessibility - talkBack + // important for accessibiility - talkBack getActivity().setTitle(title); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeButtonPrefsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeButtonPrefsFragment.java index d9aeda7489c3..4233f6b61e50 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeButtonPrefsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeButtonPrefsFragment.java @@ -9,7 +9,9 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import org.jetbrains.annotations.NotNull; +import com.android.volley.VolleyError; +import com.wordpress.rest.RestRequest; + import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -98,7 +100,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); } @@ -108,14 +110,14 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup view = (ViewGroup) inflater.inflate(R.layout.publicize_button_prefs_fragment, container, false); - mPrefButtonStyle = view.findViewById(R.id.pref_button_style); - mPrefSharingButtons = view.findViewById(R.id.pref_sharing_buttons); - mPrefMoreButtons = view.findViewById(R.id.pref_more_button); - mPrefLabel = view.findViewById(R.id.pref_label); - mPrefShowReblog = view.findViewById(R.id.pref_show_reblog); - mPrefShowLike = view.findViewById(R.id.pref_show_like); - mPrefAllowCommentLikes = view.findViewById(R.id.pref_allow_comment_likes); - mPrefTwitterName = view.findViewById(R.id.pref_twitter_name); + mPrefButtonStyle = (WPPrefView) view.findViewById(R.id.pref_button_style); + mPrefSharingButtons = (WPPrefView) view.findViewById(R.id.pref_sharing_buttons); + mPrefMoreButtons = (WPPrefView) view.findViewById(R.id.pref_more_button); + mPrefLabel = (WPPrefView) view.findViewById(R.id.pref_label); + mPrefShowReblog = (WPPrefView) view.findViewById(R.id.pref_show_reblog); + mPrefShowLike = (WPPrefView) view.findViewById(R.id.pref_show_like); + mPrefAllowCommentLikes = (WPPrefView) view.findViewById(R.id.pref_allow_comment_likes); + mPrefTwitterName = (WPPrefView) view.findViewById(R.id.pref_twitter_name); if (!mSite.isWPCom() && mSite.isJetpackConnected()) { mPrefShowLike.setHeading(getString(R.string.site_settings_like_header)); @@ -200,9 +202,17 @@ private void saveSharingButtons(boolean isSharingButtons) { } WordPress.getRestClientUtilsV1_1() - .setSharingButtons(Long.toString(mSite.getSiteId()), jsonObject, - this::configureSharingButtonsFromResponse, - error -> AppLog.e(AppLog.T.SETTINGS, error.getMessage())); + .setSharingButtons(Long.toString(mSite.getSiteId()), jsonObject, new RestRequest.Listener() { + @Override + public void onResponse(JSONObject response) { + configureSharingButtonsFromResponse(response); + } + }, new RestRequest.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + AppLog.e(AppLog.T.SETTINGS, error.getMessage()); + } + }); } /* @@ -215,15 +225,15 @@ private void toggleTwitterPreference() { View view = getView(); if (view != null) { - View twitterContainer = view.findViewById(R.id.twitter_container); + View twitterCard = view.findViewById(R.id.card_view_twitter); for (int i = 0; i < mPublicizeButtons.size(); i++) { PublicizeButton publicizeButton = mPublicizeButtons.get(i); if (publicizeButton.getId().equals(TWITTER_ID) && publicizeButton.isEnabled()) { - twitterContainer.setVisibility(View.VISIBLE); + twitterCard.setVisibility(View.VISIBLE); return; } } - twitterContainer.setVisibility(View.GONE); + twitterCard.setVisibility(View.GONE); } } @@ -232,9 +242,17 @@ private void toggleTwitterPreference() { */ private void configureSharingButtons() { WordPress.getRestClientUtilsV1_1() - .getSharingButtons(Long.toString(mSite.getSiteId()), - this::configureSharingButtonsFromResponse, - error -> AppLog.e(AppLog.T.SETTINGS, error)); + .getSharingButtons(Long.toString(mSite.getSiteId()), new RestRequest.Listener() { + @Override + public void onResponse(JSONObject response) { + configureSharingButtonsFromResponse(response); + } + }, new RestRequest.ErrorListener() { + @Override + public void onErrorResponse(VolleyError error) { + AppLog.e(AppLog.T.SETTINGS, error); + } + }); } private void configureSharingButtonsFromResponse(JSONObject response) { @@ -306,7 +324,12 @@ private void getSiteSettings(boolean shouldFetchSettings) { mSiteSettings.init(false); if (shouldFetchSettings) { - new Handler().postDelayed(() -> mSiteSettings.init(true), FETCH_DELAY); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + mSiteSettings.init(true); + } + }, FETCH_DELAY); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java index a0f813dbb884..c9a9530e2a89 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java @@ -9,7 +9,6 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.datasets.PublicizeTable; @@ -31,8 +30,8 @@ public class PublicizeDetailFragment extends PublicizeBaseFragment private ConnectButton mConnectBtn; private RecyclerView mRecycler; - private View mConnectionsContainer; - private ViewGroup mServiceContainer; + private View mConnectionsCardView; + private ViewGroup mServiceCardView; @Inject AccountStore mAccountStore; @@ -69,7 +68,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); outState.putString(PublicizeConstants.ARG_SERVICE_ID, mServiceId); @@ -79,10 +78,10 @@ public void onSaveInstanceState(@NotNull Bundle outState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.publicize_detail_fragment, container, false); - mConnectionsContainer = rootView.findViewById(R.id.connections_container); - mServiceContainer = rootView.findViewById(R.id.service_container); - mConnectBtn = mServiceContainer.findViewById(R.id.button_connect); - mRecycler = rootView.findViewById(R.id.recycler_view); + mConnectionsCardView = rootView.findViewById(R.id.card_view_connections); + mServiceCardView = (ViewGroup) rootView.findViewById(R.id.card_view_service); + mConnectBtn = (ConnectButton) mServiceCardView.findViewById(R.id.button_connect); + mRecycler = (RecyclerView) rootView.findViewById(R.id.recycler_view); return rootView; } @@ -109,14 +108,14 @@ public void loadData() { // disable the ability to add another G+ connection if (isGooglePlus()) { - mServiceContainer.setVisibility(View.GONE); + mServiceCardView.setVisibility(View.GONE); } else { String serviceLabel = String.format(getString(R.string.connection_service_label), mService.getLabel()); - TextView txtService = mServiceContainer.findViewById(R.id.text_service); + TextView txtService = (TextView) mServiceCardView.findViewById(R.id.text_service); txtService.setText(serviceLabel); String description = String.format(getString(R.string.connection_service_description), mService.getLabel()); - TextView txtDescription = mServiceContainer.findViewById(R.id.text_description); + TextView txtDescription = (TextView) mServiceCardView.findViewById(R.id.text_description); txtDescription.setText(description); } @@ -151,7 +150,7 @@ public void onAdapterLoaded(boolean isEmpty) { return; } - mConnectionsContainer.setVisibility(isEmpty ? View.GONE : View.VISIBLE); + mConnectionsCardView.setVisibility(isEmpty ? View.GONE : View.VISIBLE); if (hasOnPublicizeActionListener()) { if (isEmpty) { @@ -159,7 +158,12 @@ public void onAdapterLoaded(boolean isEmpty) { } else { mConnectBtn.setAction(ConnectAction.CONNECT_ANOTHER_ACCOUNT); } - mConnectBtn.setOnClickListener(v -> getOnPublicizeActionListener().onRequestConnect(mService)); + mConnectBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + getOnPublicizeActionListener().onRequestConnect(mService); + } + }); } } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java index 7d35785cce46..23ab9a6f26b6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java @@ -1,23 +1,24 @@ package org.wordpress.android.ui.publicize; import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.view.MenuItem; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.analytics.AnalyticsTracker.Stat; @@ -26,10 +27,10 @@ import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.models.PublicizeConnection; import org.wordpress.android.models.PublicizeService; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.publicize.PublicizeConstants.ConnectAction; import org.wordpress.android.ui.publicize.adapters.PublicizeServiceAdapter; import org.wordpress.android.ui.publicize.services.PublicizeUpdateService; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.analytics.AnalyticsUtils; @@ -38,7 +39,7 @@ import javax.inject.Inject; -public class PublicizeListActivity extends LocaleAwareActivity +public class PublicizeListActivity extends AppCompatActivity implements PublicizeActions.OnPublicizeActionListener, PublicizeServiceAdapter.OnServiceClickListener, @@ -48,6 +49,11 @@ public class PublicizeListActivity extends LocaleAwareActivity @Inject SiteStore mSiteStore; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -55,7 +61,7 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.publicize_list_activity); - Toolbar toolbar = findViewById(R.id.toolbar_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); @@ -80,7 +86,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - protected void onSaveInstanceState(@NotNull Bundle outState) { + protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); } @@ -171,7 +177,8 @@ private void reloadDetailFragment() { } } - private void showWebViewFragment(PublicizeService service, PublicizeConnection publicizeConnection) { + private void showWebViewFragment(PublicizeService service, + PublicizeConnection publicizeConnection) { if (isFinishing()) { return; } @@ -186,6 +193,16 @@ private void showWebViewFragment(PublicizeService service, PublicizeConnection p .commit(); } + private PublicizeWebViewFragment getWebViewFragment() { + String tag = getString(R.string.fragment_tag_publicize_webview); + Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag); + if (fragment != null) { + return (PublicizeWebViewFragment) fragment; + } else { + return null; + } + } + private void closeWebViewFragment() { String tag = getString(R.string.fragment_tag_publicize_webview); getSupportFragmentManager().popBackStack(tag, FragmentManager.POP_BACK_STACK_INCLUSIVE); @@ -244,19 +261,23 @@ public void onRequestDisconnect(PublicizeConnection publicizeConnection) { } private void confirmDisconnect(final PublicizeConnection publicizeConnection) { - AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); + AlertDialog.Builder builder = new AlertDialog.Builder( + new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)); builder.setMessage( String.format(getString(R.string.dlg_confirm_publicize_disconnect), publicizeConnection.getLabel())); builder.setTitle(R.string.share_btn_disconnect); builder.setCancelable(true); - builder.setPositiveButton(R.string.share_btn_disconnect, (dialog, id) -> { - PublicizeActions.disconnect(publicizeConnection); - // if the user disconnected from G+, return to the list fragment since the - // detail fragment would give them the ability to reconnect - if (publicizeConnection.getService().equals(PublicizeConstants.GOOGLE_PLUS_ID)) { - returnToListFragment(); - } else { - reloadDetailFragment(); + builder.setPositiveButton(R.string.share_btn_disconnect, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + PublicizeActions.disconnect(publicizeConnection); + // if the user disconnected from G+, return to the list fragment since the + // detail fragment would give them the ability to reconnect + if (publicizeConnection.getService().equals(PublicizeConstants.GOOGLE_PLUS_ID)) { + returnToListFragment(); + } else { + reloadDetailFragment(); + } } }); builder.setNegativeButton(R.string.cancel, null); @@ -352,9 +373,9 @@ public void onButtonPrefsClicked() { AnalyticsUtils.trackWithSiteDetails(Stat.OPENED_SHARING_BUTTON_MANAGEMENT, mSite); Fragment fragment = PublicizeButtonPrefsFragment.newInstance(mSite); getSupportFragmentManager().beginTransaction() - .replace(R.id.fragment_container, fragment) - .addToBackStack(null) - .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) - .commit(); + .replace(R.id.fragment_container, fragment) + .addToBackStack(null) + .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) + .commit(); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListFragment.java index 8b3328689467..5d3ec0eebe8f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListFragment.java @@ -15,13 +15,13 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.fluxc.Dispatcher; import org.wordpress.android.fluxc.model.SiteModel; import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.fluxc.store.QuickStartStore; +import org.wordpress.android.models.PublicizeService; import org.wordpress.android.ui.publicize.adapters.PublicizeServiceAdapter; import org.wordpress.android.ui.publicize.adapters.PublicizeServiceAdapter.OnAdapterLoadedListener; import org.wordpress.android.ui.publicize.adapters.PublicizeServiceAdapter.OnServiceClickListener; @@ -100,17 +100,17 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mEmptyView = rootView.findViewById(R.id.empty_view); boolean isAdminOrSelfHosted = mSite.getHasCapabilityManageOptions() || !SiteUtils.isAccessedViaWPComRest(mSite); - View manageContainer = rootView.findViewById(R.id.manage_container); + View manageCard = rootView.findViewById(R.id.manage_card); if (isAdminOrSelfHosted) { - manageContainer.setVisibility(View.VISIBLE); - View manageButton = rootView.findViewById(R.id.manage_button); - manageButton.setOnClickListener(view -> { + manageCard.setVisibility(View.VISIBLE); + View manageContainer = rootView.findViewById(R.id.container_manage); + manageContainer.setOnClickListener(view -> { if (mListener != null) { mListener.onButtonPrefsClicked(); } }); } else { - manageContainer.setVisibility(View.GONE); + manageCard.setVisibility(View.GONE); } if (mQuickStartEvent != null) { @@ -171,13 +171,13 @@ private void showQuickStartFocusPoint() { } @Override - public void onSaveInstanceState(@NotNull Bundle outState) { + public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(QuickStartEvent.KEY, mQuickStartEvent); } @Override - public void onAttach(@NotNull Activity activity) { + public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof PublicizeButtonPrefsListener) { @@ -219,14 +219,16 @@ private PublicizeServiceAdapter getAdapter() { mAccountStore.getAccount().getUserId()); mAdapter.setOnAdapterLoadedListener(mAdapterLoadedListener); if (getActivity() instanceof OnServiceClickListener) { - mAdapter.setOnServiceClickListener(service -> { - QuickStartUtils.completeTaskAndRemindNextOne(mQuickStartStore, ENABLE_POST_SHARING, - mDispatcher, mSite, mQuickStartEvent, getContext()); - if (getView() != null) { - QuickStartUtils.removeQuickStartFocusPoint((ViewGroup) getView()); + mAdapter.setOnServiceClickListener(new OnServiceClickListener() { + @Override public void onServiceClicked(PublicizeService service) { + QuickStartUtils.completeTaskAndRemindNextOne(mQuickStartStore, ENABLE_POST_SHARING, + mDispatcher, mSite, mQuickStartEvent, getContext()); + if (getView() != null) { + QuickStartUtils.removeQuickStartFocusPoint((ViewGroup) getView()); + } + mQuickStartEvent = null; + ((OnServiceClickListener) getActivity()).onServiceClicked(service); } - mQuickStartEvent = null; - ((OnServiceClickListener) getActivity()).onServiceClicked(service); }); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/adapters/PublicizeConnectionAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/adapters/PublicizeConnectionAdapter.java index 548b9be3c95e..2771f6d68325 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/adapters/PublicizeConnectionAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/adapters/PublicizeConnectionAdapter.java @@ -9,7 +9,6 @@ import androidx.recyclerview.widget.RecyclerView; -import org.jetbrains.annotations.NotNull; import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.datasets.PublicizeTable; @@ -89,7 +88,6 @@ public long getItemId(int position) { return mConnections.get(position).connectionId; } - @NotNull @Override public ConnectionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = @@ -116,18 +114,23 @@ private void bindButton(ConnectButton btnConnect, final PublicizeConnection conn case OK: case MUST_DISCONNECT: btnConnect.setAction(PublicizeConstants.ConnectAction.DISCONNECT); - btnConnect.setOnClickListener(v -> { - if (mActionListener != null) { - mActionListener.onRequestDisconnect(connection); + btnConnect.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mActionListener != null) { + mActionListener.onRequestDisconnect(connection); + } } }); break; case BROKEN: default: btnConnect.setAction(ConnectAction.RECONNECT); - btnConnect.setOnClickListener(view -> { - if (mActionListener != null) { - mActionListener.onRequestReconnect(mService, connection); + btnConnect.setOnClickListener(new View.OnClickListener() { + @Override public void onClick(View view) { + if (mActionListener != null) { + mActionListener.onRequestReconnect(mService, connection); + } } }); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/quickstart/QuickStartAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/quickstart/QuickStartAdapter.java index 62c54ba6147c..97c5217a4b91 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/quickstart/QuickStartAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/quickstart/QuickStartAdapter.java @@ -5,6 +5,7 @@ import android.content.Context; import android.graphics.Paint; import android.view.LayoutInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.view.ViewPropertyAnimator; @@ -15,6 +16,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.widget.PopupMenu; +import androidx.appcompat.widget.PopupMenu.OnMenuItemClickListener; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.ViewHolder; @@ -84,10 +86,12 @@ public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) { mTaskCompleted.size())); if (mIsCompletedTaskListExpanded) { + headerViewHolder.itemView.setBackgroundResource(R.drawable.bg_rectangle_white_radius_top_card); headerViewHolder.mChevron.setRotation(EXPANDED_CHEVRON_ROTATION); headerViewHolder.mChevron.setContentDescription( mContext.getString(R.string.quick_start_completed_tasks_header_chevron_collapse_desc)); } else { + headerViewHolder.itemView.setBackgroundResource(R.drawable.bg_rectangle_white_radius_card); headerViewHolder.mChevron.setRotation(COLLAPSED_CHEVRON_ROTATION); headerViewHolder.mChevron.setContentDescription( mContext.getString(R.string.quick_start_completed_tasks_header_chevron_expand_desc)); @@ -104,6 +108,23 @@ public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) { TaskViewHolder taskViewHolder = (TaskViewHolder) viewHolder; + // When first list item... + if (position == 0) { + // Use rounded background when next item is header. + if (getItemViewType(position + 1) == VIEW_TYPE_COMPLETED_TASKS_HEADER) { + taskViewHolder.itemView.setBackgroundResource(R.drawable.bg_rectangle_white_radius_card); + // Use top rounded background when next item is not header (i.e. middle or bottom). + } else { + taskViewHolder.itemView.setBackgroundResource(R.drawable.bg_rectangle_white_radius_top_card); + } + // When last list item or next item is header, use bottom rounded background. + } else if (position == mTasks.size() - 1 || getItemViewType(position + 1) == VIEW_TYPE_COMPLETED_TASKS_HEADER) { + taskViewHolder.itemView.setBackgroundResource(R.drawable.bg_rectangle_white_radius_bottom_card); + // Otherwise, use middle unrounded background. + } else { + taskViewHolder.itemView.setBackgroundResource(R.drawable.bg_rectangle_white); + } + QuickStartTask task = mTasks.get(position); boolean isEnabled = mTasksUncompleted.contains(task); taskViewHolder.mIcon.setEnabled(isEnabled); @@ -197,26 +218,35 @@ public class TaskViewHolder extends RecyclerView.ViewHolder { mDivider = inflate.findViewById(R.id.divider); mPopupAnchor = inflate.findViewById(R.id.popup_anchor); - View.OnClickListener clickListener = view -> { - if (mListener != null) { - mListener.onTaskTapped(mTasks.get(getAdapterPosition())); + View.OnClickListener clickListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + if (mListener != null) { + mListener.onTaskTapped(mTasks.get(getAdapterPosition())); + } } }; - View.OnLongClickListener longClickListener = v -> { - PopupMenu popup = new PopupMenu(mContext, mPopupAnchor); - popup.setOnMenuItemClickListener(item -> { - if (item.getItemId() == R.id.quick_start_task_menu_skip) { - if (mListener != null) { - mListener.onSkipTaskTapped(mTasks.get(getAdapterPosition())); + View.OnLongClickListener longClickListener = new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + PopupMenu popup = new PopupMenu(mContext, mPopupAnchor); + popup.setOnMenuItemClickListener(new OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + if (item.getItemId() == R.id.quick_start_task_menu_skip) { + if (mListener != null) { + mListener.onSkipTaskTapped(mTasks.get(getAdapterPosition())); + } + return true; + } + return false; } - return true; - } - return false; - }); - popup.inflate(R.menu.quick_start_task_menu); - popup.show(); - return true; + }); + popup.inflate(R.menu.quick_start_task_menu); + popup.show(); + return true; + } }; itemView.setOnClickListener(clickListener); @@ -234,7 +264,12 @@ public class CompletedHeaderViewHolder extends RecyclerView.ViewHolder { mChevron = inflate.findViewById(R.id.completed_tasks_header_chevron); mTitle = inflate.findViewById(R.id.completed_tasks_header_title); - View.OnClickListener clickListener = view -> toggleCompletedTasksList(); + View.OnClickListener clickListener = new View.OnClickListener() { + @Override + public void onClick(View view) { + toggleCompletedTasksList(); + } + }; itemView.setOnClickListener(clickListener); } @@ -249,7 +284,7 @@ private void toggleCompletedTasksList() { viewPropertyAnimator.setListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { - itemView.setEnabled(false); + itemView.setClickable(false); } @Override @@ -268,7 +303,7 @@ public void onAnimationEnd(Animator animation) { // Update header background based after collapsed and expanded. notifyItemChanged(positionOfHeader); mIsCompletedTaskListExpanded = !mIsCompletedTaskListExpanded; - itemView.setEnabled(true); + itemView.setClickable(true); if (mListener != null) { mListener.onCompletedTasksListToggled(mIsCompletedTaskListExpanded); @@ -277,7 +312,7 @@ public void onAnimationEnd(Animator animation) { @Override public void onAnimationCancel(Animator animation) { - itemView.setEnabled(true); + itemView.setClickable(true); } @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java index 9dda0b1fe4cd..53df9570a81f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.reader; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.Editable; @@ -22,7 +23,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; -import androidx.appcompat.widget.Toolbar; +import androidx.appcompat.app.AppCompatActivity; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearSmoothScroller; @@ -40,9 +41,9 @@ import org.wordpress.android.datasets.ReaderCommentTable; import org.wordpress.android.datasets.ReaderPostTable; import org.wordpress.android.datasets.SuggestionTable; -import org.wordpress.android.fluxc.model.SiteModel; import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.fluxc.store.SiteStore; +import org.wordpress.android.fluxc.model.SiteModel; import org.wordpress.android.models.ReaderComment; import org.wordpress.android.models.ReaderPost; import org.wordpress.android.models.Suggestion; @@ -52,7 +53,6 @@ import org.wordpress.android.ui.CollapseFullScreenDialogFragment.OnCollapseListener; import org.wordpress.android.ui.CollapseFullScreenDialogFragment.OnConfirmListener; import org.wordpress.android.ui.CommentFullScreenDialogFragment; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.reader.ReaderCommentListViewModel.ScrollPosition; import org.wordpress.android.ui.reader.ReaderPostPagerActivity.DirectOperation; @@ -70,6 +70,7 @@ import org.wordpress.android.util.AppLog.T; import org.wordpress.android.util.DisplayUtils; import org.wordpress.android.util.EditTextUtils; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.ViewUtilsKt; @@ -91,7 +92,7 @@ import static org.wordpress.android.ui.CommentFullScreenDialogFragment.RESULT_SELECTION_START; import static org.wordpress.android.util.WPSwipeToRefreshHelper.buildSwipeToRefreshHelper; -public class ReaderCommentListActivity extends LocaleAwareActivity { +public class ReaderCommentListActivity extends AppCompatActivity { private static final String KEY_REPLY_TO_COMMENT_ID = "reply_to_comment_id"; private static final String KEY_HAS_UPDATED_COMMENTS = "has_updated_comments"; @@ -125,6 +126,11 @@ public class ReaderCommentListActivity extends LocaleAwareActivity { @Inject ViewModelProvider.Factory mViewModelFactory; private ReaderCommentListViewModel mViewModel; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onBackPressed() { CollapseFullScreenDialogFragment fragment = (CollapseFullScreenDialogFragment) @@ -162,9 +168,6 @@ public void onCreate(Bundle savedInstanceState) { } }); - Toolbar toolbar = findViewById(R.id.toolbar_main); - setSupportActionBar(toolbar); - ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(true); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java index 3fa2eedc8b54..e802ed506b0f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui.reader; +import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.os.Parcelable; @@ -11,6 +12,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -18,12 +20,12 @@ import androidx.viewpager.widget.ViewPager; import org.wordpress.android.R; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.reader.models.ReaderImageList; import org.wordpress.android.ui.reader.utils.ReaderImageScanner; import org.wordpress.android.ui.reader.views.ReaderPhotoView.PhotoViewListener; import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.widgets.WPViewPager; import org.wordpress.android.widgets.WPViewPagerTransformer; import org.wordpress.android.widgets.WPViewPagerTransformer.TransformType; @@ -32,7 +34,7 @@ * Full-screen photo viewer - uses a ViewPager to enable scrolling between images in a blog * post, but also supports viewing a single image */ -public class ReaderPhotoViewerActivity extends LocaleAwareActivity +public class ReaderPhotoViewerActivity extends AppCompatActivity implements PhotoViewListener { private String mInitialImageUrl; private boolean mIsPrivate; @@ -46,6 +48,11 @@ public class ReaderPhotoViewerActivity extends LocaleAwareActivity private static final long FADE_DELAY_MS = 3000; private final Handler mFadeHandler = new Handler(); + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostDetailFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostDetailFragment.kt index b69a8f1f2dd1..c5977dd6431e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostDetailFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostDetailFragment.kt @@ -23,7 +23,6 @@ import android.widget.TextView import androidx.appcompat.app.ActionBar import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment -import com.google.android.material.elevation.ElevationOverlayProvider import com.google.android.material.snackbar.Snackbar import org.greenrobot.eventbus.EventBus import org.greenrobot.eventbus.Subscribe @@ -247,14 +246,6 @@ class ReaderPostDetailFragment : Fragment(), scrollView.setScrollDirectionListener(this) layoutFooter = view.findViewById(R.id.layout_post_detail_footer) - - val elevationOverlayProvider = ElevationOverlayProvider(layoutFooter.context) - val appbarElevation = resources.getDimension(R.dimen.appbar_elevation) - val elevatedSurfaceColor = elevationOverlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded( - appbarElevation - ) - layoutFooter.setBackgroundColor(elevatedSurfaceColor) - likingUsersView = view.findViewById(R.id.layout_liking_users_view) likingUsersDivider = view.findViewById(R.id.layout_liking_users_divider) likingUsersLabel = view.findViewById(R.id.text_liking_users_label) @@ -301,10 +292,10 @@ class ReaderPostDetailFragment : Fragment(), return post != null } - override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { + override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) { super.onCreateOptionsMenu(menu, inflater) - menu.clear() - inflater.inflate(R.menu.reader_detail, menu) + menu!!.clear() + inflater!!.inflate(R.menu.reader_detail, menu) } override fun onPrepareOptionsMenu(menu: Menu) { @@ -371,8 +362,7 @@ class ReaderPostDetailFragment : Fragment(), hasTrackedLocalRelatedPosts ) - outState.putSerializable( - ReaderConstants.ARG_POST_LIST_TYPE, + outState.putSerializable(ReaderConstants.ARG_POST_LIST_TYPE, this.postListType ) @@ -1193,8 +1183,7 @@ class ReaderPostDetailFragment : Fragment(), activity?.overridePendingTransition(0, 0) return } - POST_LIKE -> { - } + POST_LIKE -> { } } // Liking needs to be handled "later" after the post has been updated from the server so, // nothing special to do here diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java index 46417cd41b1a..afa802de518a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.reader; import android.content.ActivityNotFoundException; +import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.Menu; @@ -9,6 +10,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.fragment.app.Fragment; @@ -21,23 +23,28 @@ import org.wordpress.android.datasets.ReaderBlogTable; import org.wordpress.android.models.ReaderBlog; import org.wordpress.android.models.ReaderTag; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.reader.ReaderTypes.ReaderPostListType; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.ToastUtils; /* * serves as the host for ReaderPostListFragment when showing blog preview & tag preview */ -public class ReaderPostListActivity extends LocaleAwareActivity { +public class ReaderPostListActivity extends AppCompatActivity { private ReaderPostListType mPostListType; private long mSiteId; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reader_activity_post_list); - Toolbar toolbar = findViewById(R.id.toolbar_main); + Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java index ff157405c460..11acb8c093ae 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java @@ -41,8 +41,6 @@ import androidx.lifecycle.ViewModelProviders; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import com.google.android.material.elevation.ElevationOverlayProvider; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.snackbar.Snackbar; import com.google.android.material.tabs.TabLayout; @@ -122,7 +120,6 @@ import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; -import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.DateTimeUtils; import org.wordpress.android.util.DisplayUtils; import org.wordpress.android.util.NetworkUtils; @@ -967,13 +964,8 @@ public void onShowCustomEmptyView(EmptyViewMessageType emptyViewMsgType) { mRecyclerView.addItemDecoration(new RecyclerItemDecoration(spacingHorizontal, spacingVertical, false)); // the following will change the look and feel of the toolbar to match the current design - ElevationOverlayProvider elevationOverlayProvider = new ElevationOverlayProvider(mRecyclerView.getContext()); - float appbarElevation = getResources().getDimension(R.dimen.appbar_elevation); - int elevatedAppBarColor = elevationOverlayProvider - .compositeOverlayIfNeeded( - ContextExtensionsKt.getColorFromAttribute(mRecyclerView.getContext(), R.attr.wpColorAppBar), - appbarElevation); - mRecyclerView.setToolbarBackgroundColor(elevatedAppBarColor); + mRecyclerView.setToolbarBackgroundColor(ContextCompat.getColor(getContext(), R.color.primary)); + mRecyclerView.setToolbarSpinnerTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); mRecyclerView.setToolbarSpinnerDrawable(R.drawable.ic_dropdown_primary_30_24dp); if (mIsTopLevel) { @@ -1017,9 +1009,6 @@ public void onClick(View view) { } mSubFilterComponent = inflater.inflate(R.layout.subfilter_component, rootView, false); - float cardElevation = getResources().getDimension(R.dimen.card_elevation); - int elevatedCardColor = elevationOverlayProvider.compositeOverlayWithThemeSurfaceColorIfNeeded(cardElevation); - mSubFilterComponent.setBackgroundColor(elevatedCardColor); if (mIsTopLevel) { mRecyclerView.getAppBarLayout().addView(mSubFilterComponent); @@ -1061,7 +1050,7 @@ private void setupRecyclerToolbar() { if (mIsTopLevel) { mSettingsMenuItem.setVisible(false); } else { - mSettingsMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + mSettingsMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { showSettings(); @@ -1154,19 +1143,19 @@ public boolean onMenuItemActionCollapse(MenuItem item) { }); mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { - @Override - public boolean onQueryTextSubmit(String query) { - submitSearchQuery(query); - return true; - } - - @Override - public boolean onQueryTextChange(String newText) { - populateSearchSuggestions(newText); - showSearchMessageOrSuggestions(); - return true; - } - } + @Override + public boolean onQueryTextSubmit(String query) { + submitSearchQuery(query); + return true; + } + + @Override + public boolean onQueryTextChange(String newText) { + populateSearchSuggestions(newText); + showSearchMessageOrSuggestions(); + return true; + } + } ); } @@ -1642,8 +1631,8 @@ public void onClick(View v) { } }; WPSnackbar.make(getSnackbarParent(), getString(R.string.reader_toast_blog_blocked), Snackbar.LENGTH_LONG) - .setAction(R.string.undo, undoListener) - .show(); + .setAction(R.string.undo, undoListener) + .show(); } /* @@ -1963,7 +1952,7 @@ private void announceListStateForAccessibility() { } private void showBookmarksSavedLocallyDialog() { - mBookmarksSavedLocallyDialog = new MaterialAlertDialogBuilder(getActivity()) + mBookmarksSavedLocallyDialog = new AlertDialog.Builder(getActivity()) .setTitle(getString(R.string.reader_save_posts_locally_dialog_title)) .setMessage(getString(R.string.reader_save_posts_locally_dialog_message)) .setPositiveButton(R.string.dialog_button_ok, new OnClickListener() { @@ -1987,18 +1976,18 @@ private void showBookmarkSnackbar() { } WPSnackbar.make(getView(), R.string.reader_bookmark_snack_title, Snackbar.LENGTH_LONG) - .setAction(R.string.reader_bookmark_snack_btn, - new View.OnClickListener() { - @Override public void onClick(View view) { - AnalyticsTracker - .track(AnalyticsTracker.Stat.READER_SAVED_LIST_VIEWED_FROM_POST_LIST_NOTICE); - ActivityLauncher.viewSavedPostsListInReader(getActivity()); - if (getActivity() instanceof WPMainActivity) { - getActivity().overridePendingTransition(0, 0); - } - } - }) - .show(); + .setAction(R.string.reader_bookmark_snack_btn, + new View.OnClickListener() { + @Override public void onClick(View view) { + AnalyticsTracker + .track(AnalyticsTracker.Stat.READER_SAVED_LIST_VIEWED_FROM_POST_LIST_NOTICE); + ActivityLauncher.viewSavedPostsListInReader(getActivity()); + if (getActivity() instanceof WPMainActivity) { + getActivity().overridePendingTransition(0, 0); + } + } + }) + .show(); } /* @@ -2174,14 +2163,14 @@ && getPostAdapter().isCurrentTag(tag)) { mViewModel.onSubfilterReselected(); } else { changeReaderMode(new ReaderModeInfo( - tag, - ReaderPostListType.TAG_FOLLOWED, - 0, - 0, - false, - null, - false, - mRemoveFilterButton.getVisibility() == View.VISIBLE), + tag, + ReaderPostListType.TAG_FOLLOWED, + 0, + 0, + false, + null, + false, + mRemoveFilterButton.getVisibility() == View.VISIBLE), false ); } @@ -2760,18 +2749,17 @@ public void onFollowTapped(View view, String blogName, final long blogId) { WPSnackbar.make(getSnackbarParent(), Html.fromHtml(getString(R.string.reader_followed_blog_notifications, "", blog, "")), Snackbar.LENGTH_LONG) - .setAction(getString(R.string.reader_followed_blog_notifications_action), - new View.OnClickListener() { - @Override public void onClick(View view) { - AnalyticsUtils - .trackWithSiteId(Stat.FOLLOWED_BLOG_NOTIFICATIONS_READER_ENABLED, blogId); - AddOrDeleteSubscriptionPayload payload = new AddOrDeleteSubscriptionPayload( - String.valueOf(blogId), SubscriptionAction.NEW); - mDispatcher.dispatch(newUpdateSubscriptionNotificationPostAction(payload)); - ReaderBlogTable.setNotificationsEnabledByBlogId(blogId, true); - } - }) - .show(); + .setAction(getString(R.string.reader_followed_blog_notifications_action), + new View.OnClickListener() { + @Override public void onClick(View view) { + AnalyticsUtils.trackWithSiteId(Stat.FOLLOWED_BLOG_NOTIFICATIONS_READER_ENABLED, blogId); + AddOrDeleteSubscriptionPayload payload = new AddOrDeleteSubscriptionPayload( + String.valueOf(blogId), SubscriptionAction.NEW); + mDispatcher.dispatch(newUpdateSubscriptionNotificationPostAction(payload)); + ReaderBlogTable.setNotificationsEnabledByBlogId(blogId, true); + } + }) + .show(); } @Override diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java index 86f68e57a44b..2931f98d6a0b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.reader; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -14,6 +15,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -32,7 +34,6 @@ import org.wordpress.android.models.ReaderPost; import org.wordpress.android.models.ReaderTag; import org.wordpress.android.ui.ActivityLauncher; -import org.wordpress.android.ui.LocaleAwareActivity; import org.wordpress.android.ui.RequestCodes; import org.wordpress.android.ui.WPLaunchActivity; import org.wordpress.android.ui.posts.BasicFragmentDialog; @@ -49,6 +50,7 @@ import org.wordpress.android.util.AniUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; +import org.wordpress.android.util.LocaleManager; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.analytics.AnalyticsUtils; @@ -79,7 +81,7 @@ * * Will also handle jumping to the comments section, liking a commend and liking a post directly */ -public class ReaderPostPagerActivity extends LocaleAwareActivity +public class ReaderPostPagerActivity extends AppCompatActivity implements ReaderInterfaces.AutoHideToolbarListener, BasicFragmentDialog.BasicDialogPositiveClickInterface { /** @@ -127,6 +129,11 @@ public enum DirectOperation { @Inject SiteStore mSiteStore; @Inject ReaderTracker mReaderTracker; + @Override + protected void attachBaseContext(Context newBase) { + super.attachBaseContext(LocaleManager.setLocale(newBase)); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -134,7 +141,7 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.reader_activity_post_pager); - mToolbar = findViewById(R.id.toolbar_main); + mToolbar = findViewById(R.id.toolbar); setSupportActionBar(mToolbar); ActionBar actionBar = getSupportActionBar(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostRenderer.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostRenderer.java index 169304f3bebe..2d99f98e92db 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostRenderer.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostRenderer.java @@ -362,8 +362,7 @@ private String formatPostContentForWebView(final String content, final Set") .append(" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WordPress/src/main/res/values-nl/strings.xml b/WordPress/src/main/res/values-nl/strings.xml index f698f4aaf799..8b4afda2012a 100644 --- a/WordPress/src/main/res/values-nl/strings.xml +++ b/WordPress/src/main/res/values-nl/strings.xml @@ -1,11 +1,20 @@ + Gebruik de filterknop om berichten over specifieke onderwerpen te vinden + Selecteer een tag of site, pop-upvenster + Geselecteerd + Selecteer een site of tag om berichten te filteren + Verwijder het huidige filter + Tags en sites beheren + Inloggen op WordPress.com + Log in op WordPress.com om de laatste berichten van gevolgde tags te bekijken + Log in op WordPress.com om de laatste berichten van gevolgde sites te bekijken Voorbeeldweergave van sjabloon Huidig blok vervangen Toevoegen aan einde @@ -1835,7 +1844,6 @@ Language: nl Voer een tag of URL in om te volgen Gevolgde sites Gevolgde tags - Tags & sites Reader-tag Als je normaal gesproken zonder problemen verbinding maakt met deze site kan deze fout betekenen dat iemand zich probeert voor te doen als deze site. Ga niet verder als dat zo is. Wil je het certificaat toch vertrouwen? Ongeldig SSL-certificaat diff --git a/WordPress/src/main/res/values-pl/strings.xml b/WordPress/src/main/res/values-pl/strings.xml index c22b7b8d227c..64e2ac5e4dc1 100644 --- a/WordPress/src/main/res/values-pl/strings.xml +++ b/WordPress/src/main/res/values-pl/strings.xml @@ -1898,7 +1898,6 @@ Language: pl Wpisz adres lub tag aby obserwować Obserwowane blogi Obserwowane tagi - Tagi i Witryny Tag Czytnika Witryna Czytnika Jeśli zazwyczaj łączysz się z tą stroną bez problemów, ten błąd może oznaczać, że ktoś próbuje się pod nią podszyć i nie powinieneś kontynuować. Czy mimo to chcesz zaufać temu certyfikatowi? diff --git a/WordPress/src/main/res/values-pt-rBR/strings.xml b/WordPress/src/main/res/values-pt-rBR/strings.xml index 5c1654f7519e..f37e8cee7832 100644 --- a/WordPress/src/main/res/values-pt-rBR/strings.xml +++ b/WordPress/src/main/res/values-pt-rBR/strings.xml @@ -1950,7 +1950,6 @@ Language: pt_BR Insira um URL ou tag para seguir Sites seguidos Tags seguidas - Tags e sites Tag do Leitor Leitor do site Se você geralmente se conecta a este site sem problemas, talvez este erro signifique que alguém está tentando imitar o site, e você não deve continuar. Deseja confiar no certificado mesmo assim? diff --git a/WordPress/src/main/res/values-ro/strings.xml b/WordPress/src/main/res/values-ro/strings.xml index 42f3d49ad46b..552e20edbc46 100644 --- a/WordPress/src/main/res/values-ro/strings.xml +++ b/WordPress/src/main/res/values-ro/strings.xml @@ -1,11 +1,20 @@ + Folosește butonul de filtrare pentru a găsi articole pentru anumite subiecte + Selectează o etichetă sau un sit, ferestră popup + Selectat(ă) + Selectează un sit sau o etichetă pentru a filtra articolele + Înlătură filtrul curent + Administrează etichetele și siturile + Autentifică-te în WordPress.com + Autentifică-te în WordPress.com pentru a vedea ultimele articole pentru etichetele pe care le urmărești + Autentifică-te în WordPress.com pentru a vedea ultimele din siturile pe care le urmărești Previzualizare șablon Înlocuiește blocul curent Adaugă la sfârșit @@ -1482,7 +1491,7 @@ Language: ro Acțiune terminată! Comentariu apreciat Dezautentificare - Autentificare la WordPress.com + Autentifică-te în WordPress.com Mai multe pe WordPress.com Mai multe în %s Deschide setări dispozitiv @@ -1847,7 +1856,7 @@ Language: ro Privire generală Dezautentificare din WordPress.com Autentificare/Deautentificare - Conectare la WordPress.com + Autentifică-te în WordPress.com \"%s\" n-a fost ascuns pentru că este situl curent Ajutor și suport Setări cont @@ -1950,7 +1959,6 @@ Language: ro Introdu un URL sau o etichetă pentru urmărire Situri urmărite Etichete urmărite - Etichete și situri Etichetă cititor Sit Cititor Dacă în mod uzual te conectezi fără probleme la acest sit, această eroare poate să însemne că cineva încearcă să se substituie sitului și n-ar trebui să mai continui. Preferi să te încrezi în certificat oricum? diff --git a/WordPress/src/main/res/values-ru/strings.xml b/WordPress/src/main/res/values-ru/strings.xml index 17187b367a57..a9d3f06edb1f 100644 --- a/WordPress/src/main/res/values-ru/strings.xml +++ b/WordPress/src/main/res/values-ru/strings.xml @@ -1,11 +1,20 @@ + Используйте кнопку фильтра для поиска записей по интересующим темам + Выберите метку или сайт, всплывающее окно + Выбрано + Выберите сайт или метку для фильтрации записей + Убрать текущий фильтр + Управление метками и сайтами + Войти на WordPress.com + Войдите на WordPress.com, чтобы увидеть последние записи по меткам, на которые вы подписаны + Войдите на WordPress.com, чтобы увидеть последние записи с сайтов, на которые вы подписаны Предварительный просмотр шаблона Заменить текущий блок Добавить в конце @@ -1950,7 +1959,6 @@ Language: ru Введите URL или метку для подписки Отслеживаемые сайты Отслеживаемые метки - Метки и сайты Метка из Чтива Сайт из Чтива Если вы обычно заходите на этот сайт без проблем, эта ошибка может означать, что кто-то пытается подделать сайт и вам не стоит сюда заходить. Хотите ли вы доверять ssl сертификату? diff --git a/WordPress/src/main/res/values-sk/strings.xml b/WordPress/src/main/res/values-sk/strings.xml index 16624882d87e..bcb730e0124c 100644 --- a/WordPress/src/main/res/values-sk/strings.xml +++ b/WordPress/src/main/res/values-sk/strings.xml @@ -1431,7 +1431,6 @@ Language: sk Zadajte adresu URL alebo značku, ktorú chcete sledovať Sledované webové stránky Sledované značky - Značky a webové stránky Značka čítačky Webová stránka čítačky Ak sa bežne pripájate bez problémov, táto chyba môže znamenať, že sa niekto pokúša prevziať vašu identitu. Neodporúčame vám pokračovať. Chcete aj napriek tomu dôverovať tomuto certifikátu? diff --git a/WordPress/src/main/res/values-sq/strings.xml b/WordPress/src/main/res/values-sq/strings.xml index b5218ce365d9..d87b8bc1aed4 100644 --- a/WordPress/src/main/res/values-sq/strings.xml +++ b/WordPress/src/main/res/values-sq/strings.xml @@ -1,11 +1,20 @@ + Përdorni butonin e filtrave që të gjeni postime rreth subjektesh specifike + Përzgjidhni një Etiketë ose Sajt, Dritare Flluskë + E përzgjedhur + Përzgjidhni një Sajt ose Etiketë që të filtrohen postime + Hiqe filtrin e tanishme + Administroni Etiketa & Sajte + Hyni te WordPress.com + Bëni hyrjen te llogaria juaj në WordPress.com që të shihni postimet më të reja prej etiketash që ndiqni + Bëni hyrjen te llogaria juaj në WordPress.com që të shihni postimet më të reja prej sajtesh që ndiqni Paraparje Gjedheje Zëvendëso Bllokun e Tanishëm Shtoje Në Fund @@ -371,6 +380,7 @@ Language: sq_AL Cilido Unë Ndodhi një gabim gjatë rikthimit të postimit + Vënë në plan për: %s Objektet e treguar më sipër do të shfaqen te skeda juaj Prirje. Për t’i përshtatur, tërhiqini dhe vendosini. Shtoni Tendencë Shihni vetëm statistikat më me peshë. Shtoni dhe sistemoni më poshtë tendencat tuaja. @@ -1949,7 +1959,6 @@ Language: sq_AL Jepni një URL ose etiketë që të ndiqet Sajte te ndjekur Etiketa të ndjekura - Etiketa & Sajte Etiketë Lexuesi Sajti i Lexuesit Nëse zakonisht lidheni te ky sajt pa probleme, ky gabim mund të thotë që dikush po provon të hiqet si ky sajt, dhe s’duhet të vazhdoni. Doni të besohet dëshmia, sido qoftë? diff --git a/WordPress/src/main/res/values-sv/strings.xml b/WordPress/src/main/res/values-sv/strings.xml index 1fb9f171ea67..a0422bc5cae8 100644 --- a/WordPress/src/main/res/values-sv/strings.xml +++ b/WordPress/src/main/res/values-sv/strings.xml @@ -1,11 +1,20 @@ + Använd filtreringsknappen för att hitta inlägg om specifika ämnen + Välj en etikett eller en webbplats, popup-fönster + Valt + Välj en webbplats eller etikett för att filtrera inläggen + Ta bort befintligt filter + Hantera etiketter och webbplatser + Logga in på WordPress.com + Logga in på WordPress.com för att se de senaste inläggen från de etiketter du följer + Logga in på WordPress.com för att se de senaste inläggen från de webbplatser du följer Förhandsgranska mall Ersätt aktuellt block Lägg till sist @@ -1950,7 +1959,6 @@ Language: sv_SE Ange en URL eller tagg att följa Följda webbplatser Följda taggar - Etiketter och webbplatser Läsare-etikett Läsarwebbplats Om du vanligtvis kan nå denna webbplats utan problem kan felet betyda att någon försöker efterlikna webbplatsen och du borde inte fortsätta. Vill du lita på certifikatet ändå? diff --git a/WordPress/src/main/res/values-sw600dp/styles.xml b/WordPress/src/main/res/values-sw600dp/styles.xml index 8184978cbd3a..16088ab94877 100644 --- a/WordPress/src/main/res/values-sw600dp/styles.xml +++ b/WordPress/src/main/res/values-sw600dp/styles.xml @@ -1,6 +1,7 @@ - + + + diff --git a/WordPress/src/main/res/values-tr/strings.xml b/WordPress/src/main/res/values-tr/strings.xml index 972e38f570a9..0a8f8874a0e4 100644 --- a/WordPress/src/main/res/values-tr/strings.xml +++ b/WordPress/src/main/res/values-tr/strings.xml @@ -1,11 +1,20 @@ + Belirli konular hakkında yazılar bulmak için filtre düğmesini kullanın + Etiket veya Site Seçin, Açılır Pencere + Seçilen + Yazıları filtrelemek için bir Site veya Etiket seçin + Geçerli filtreyi kaldır + Etiketleri ve Siteleri Yönet + WordPress.com\'da oturum aç + Takip ettiğiniz etiketlerle ilişkili en son yazıları görmek için WordPress.com\'da oturum açın + Takip ettiğiniz sitelerdeki en son yazıları görmek için WordPress.com\'da oturum açın Şablon ön izlemesi Mevcut bloğu değiştir Sona ekle @@ -1950,7 +1959,6 @@ Language: tr Takip etmek için etiket veya adres girin Takip edilen siteler Takip edilen etiketler - Etiketler ve siteler Okuyucu etiketi Okuyucu sitesi Eğer bu siteye genelde sorunsuz şekilde bağlanabiliyorsanız bu hata birilerinin siteyi taklit ettiği anlamına gelebilir. Yine de sertifikaya güvenmek ister misiniz? diff --git a/WordPress/src/main/res/values-v27/styles.xml b/WordPress/src/main/res/values-v27/styles.xml index 3448ae1d4e9b..b0cf26e34ba4 100644 --- a/WordPress/src/main/res/values-v27/styles.xml +++ b/WordPress/src/main/res/values-v27/styles.xml @@ -5,4 +5,19 @@ true + + + diff --git a/WordPress/src/main/res/values-v28/strings.xml b/WordPress/src/main/res/values-v28/strings.xml deleted file mode 100644 index d2646c0c2ea1..000000000000 --- a/WordPress/src/main/res/values-v28/strings.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - @string/app_theme_entry_value_default - - @string/app_theme_light - @string/app_theme_dark - @string/app_theme_default - - - @string/app_theme_entry_value_light - @string/app_theme_entry_value_dark - @string/app_theme_entry_value_default - - diff --git a/WordPress/src/main/res/values-v29/strings.xml b/WordPress/src/main/res/values-v29/strings.xml deleted file mode 100644 index 22276dd96899..000000000000 --- a/WordPress/src/main/res/values-v29/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - System Default - diff --git a/WordPress/src/main/res/values-w528dp/dimens.xml b/WordPress/src/main/res/values-w528dp/dimens.xml index 488768462cb5..3b4c1fc8674c 100644 --- a/WordPress/src/main/res/values-w528dp/dimens.xml +++ b/WordPress/src/main/res/values-w528dp/dimens.xml @@ -1,9 +1,9 @@ 8dp - 8dp - 8dp - 16dp - 16dp + 4dp + 4dp + 8dp + 8dp 48dp diff --git a/WordPress/src/main/res/values-zh-rCN/strings.xml b/WordPress/src/main/res/values-zh-rCN/strings.xml index 03bcf5ac88f9..6fb9004b4dab 100644 --- a/WordPress/src/main/res/values-zh-rCN/strings.xml +++ b/WordPress/src/main/res/values-zh-rCN/strings.xml @@ -1,11 +1,20 @@ + 使用“过滤器”按钮查找特定主题的文章 + 选择标签、站点或弹出窗口 + 已选择 + 选择站点或标签来过滤文章 + 删除当前过滤器 + 管理标签和站点 + 登录 WordPress.com + 登录 WordPress.com 以查看属于您关注的标签的最新文章 + 登录 WordPress.com 以查看您关注的站点的最新文章 模板预览 替换现有区块 添加到结尾 @@ -1872,7 +1881,6 @@ Language: zh_CN 输入要关注的 URL 或标签 已关注的博客 关注的标签 - 标签和站点 阅读器标签 “阅读器”站点 如果你平时连接到这个网站没有任何问题,这个错误可能意味着有人试图冒充该网站,你不应该继续下去。你想仍然信任这个证书? diff --git a/WordPress/src/main/res/values-zh-rHK/strings.xml b/WordPress/src/main/res/values-zh-rHK/strings.xml index bef5d59d7f2b..c6e14a6fe472 100644 --- a/WordPress/src/main/res/values-zh-rHK/strings.xml +++ b/WordPress/src/main/res/values-zh-rHK/strings.xml @@ -1,11 +1,20 @@ + 使用篩選按鈕尋找特定主題的文章 + 選擇一個標籤或網站、快顯視窗 + 已選取 + 選擇網站或標籤以篩選文章 + 移除目前的篩選條件 + 管理標籤和網站 + 登入 WordPress.com + 登入 WordPress.com,查看關注標籤的最新文章 + 登入 WordPress.com,查看關注網站的最新文章 範例預覽 取代目前區塊 新增至「結束」 @@ -1927,7 +1936,6 @@ Language: zh_TW 輸入要關注的 URL 或標籤 關注的網站 關注的標籤 - 標籤與網站 讀者標籤 讀者網站 如果你通常能夠順利連線至此網站,則此錯誤可能代表有人正嘗試冒充該網站,因此請勿繼續操作。是否仍然要信任憑證? diff --git a/WordPress/src/main/res/values-zh-rTW/strings.xml b/WordPress/src/main/res/values-zh-rTW/strings.xml index bef5d59d7f2b..c6e14a6fe472 100644 --- a/WordPress/src/main/res/values-zh-rTW/strings.xml +++ b/WordPress/src/main/res/values-zh-rTW/strings.xml @@ -1,11 +1,20 @@ + 使用篩選按鈕尋找特定主題的文章 + 選擇一個標籤或網站、快顯視窗 + 已選取 + 選擇網站或標籤以篩選文章 + 移除目前的篩選條件 + 管理標籤和網站 + 登入 WordPress.com + 登入 WordPress.com,查看關注標籤的最新文章 + 登入 WordPress.com,查看關注網站的最新文章 範例預覽 取代目前區塊 新增至「結束」 @@ -1927,7 +1936,6 @@ Language: zh_TW 輸入要關注的 URL 或標籤 關注的網站 關注的標籤 - 標籤與網站 讀者標籤 讀者網站 如果你通常能夠順利連線至此網站,則此錯誤可能代表有人正嘗試冒充該網站,因此請勿繼續操作。是否仍然要信任憑證? diff --git a/WordPress/src/main/res/values/attrs.xml b/WordPress/src/main/res/values/attrs.xml index 19854e8ff215..375fa5cff03b 100644 --- a/WordPress/src/main/res/values/attrs.xml +++ b/WordPress/src/main/res/values/attrs.xml @@ -7,13 +7,8 @@ - - - - - @@ -21,9 +16,12 @@ - + - + + + + @@ -208,15 +206,4 @@ - - - - - - - - - - - diff --git a/WordPress/src/main/res/values/colors.xml b/WordPress/src/main/res/values/colors.xml index 76089ecbd590..f8a7b842903f 100644 --- a/WordPress/src/main/res/values/colors.xml +++ b/WordPress/src/main/res/values/colors.xml @@ -5,39 +5,26 @@ tools:ignore="UnusedResources"> - #121212 @color/neutral_0 #e6eff3 #f5f5f5 @color/neutral_80 @color/primary @color/accent + @color/primary_dark + @color/primary_light + @color/primary @color/primary @color/neutral - - - @color/gray_0 - @color/blue_5 - @color/blue_20 - @color/blue_50 - @color/blue_70 - @color/gray_10 - @color/blue_60 - @color/blue_30 - @color/pink_30 - @color/pink_60 - @color/neutral_5 - @color/accent_5 - @color/accent - @color/neutral_5 - - - - @color/neutral_0 - @color/primary + @color/background_default + @color/primary_30 + @color/neutral_10 + @color/primary + @color/primary + @color/accent @color/pink_50 @@ -185,7 +172,7 @@ #00450c #003008 #001c05 - #00BE28 + #2fb41f #f0f2eb #d0e6b8 #9dd977 diff --git a/WordPress/src/main/res/values/dimens.xml b/WordPress/src/main/res/values/dimens.xml index aa1707204ad4..6721fec5820e 100644 --- a/WordPress/src/main/res/values/dimens.xml +++ b/WordPress/src/main/res/values/dimens.xml @@ -17,23 +17,14 @@ 24dp 56dp - - @dimen/disabled_alpha - - 0.12 - - 1dp - 86dp 4dp - 8dp 2dp - - 8dp + 8dp 2dp 4dp @@ -131,6 +122,7 @@ 50dp 1px + 0dp 18dp 56dp @@ -145,7 +137,9 @@ 18sp 20sp 24sp + 26sp 32sp + 18sp 24dp 32dp @@ -197,29 +191,28 @@ 32dp 24dp + 24sp 32dp 8dp + 28sp 48dp + 600dp + 150dp 300dp - 16dp + 21dp 6dp 240dp 10dp 0dp 48dp 22dp - 4dp - 2dp - 12dp - 14dp - 6dp - 1dp + 28dp 3dp 5dp @@ -232,6 +225,10 @@ 6dp 4dp 4dp + 24dp + 24dp + 24dp + 16dp 12dp @@ -253,7 +250,7 @@ 20dp 10dp 4dp - 0.5dp + 1dp 2dp @@ -276,12 +273,15 @@ 12dp 24dp 12dp + 11sp 1dp 500dp - 24dp 320dp + 5dp + 10dp + 1dp 40dp 48dp 50dp @@ -305,6 +305,7 @@ 40dp 72dp 20dp + 1dp 72dp @@ -318,9 +319,12 @@ 1dp 10dp 40dp + 16sp 8dp + 20dp + 24dp 40dp 60dp @@ -347,6 +351,8 @@ 24dp + 60dp + 20dp 18dp @@ -409,6 +415,7 @@ 40dp 68dp 6dp + 32dp 28dp @@ -420,10 +427,10 @@ 32dp 180dp 24dp - 4dp - 4dp - 4dp - 8dp + 0dp + 0dp + 8dp + 0dp 8dp 56dp 1dp @@ -442,14 +449,14 @@ 16dp 8dp + 16dp 72dp 20dp 72dp - 161sp - + 161sp 6dp @@ -466,18 +473,10 @@ 6dp 16dp - - 0.33 - 0.15 - 8dp 4dp 4dp 32dp 4dp - - 0dp - 1dp - diff --git a/WordPress/src/main/res/values/drawables.xml b/WordPress/src/main/res/values/drawables.xml index 9a409021a62c..2e797f4c8298 100644 --- a/WordPress/src/main/res/values/drawables.xml +++ b/WordPress/src/main/res/values/drawables.xml @@ -1,6 +1,15 @@ + + + @drawable/bg_rectangle_white + @drawable/bg_rectangle_white + @drawable/bg_rectangle_white + diff --git a/WordPress/src/main/res/values/integers.xml b/WordPress/src/main/res/values/integers.xml index b9fa88ca2d44..afb6a6629dde 100644 --- a/WordPress/src/main/res/values/integers.xml +++ b/WordPress/src/main/res/values/integers.xml @@ -2,12 +2,7 @@ - - @android:integer/config_mediumAnimTime - - 50 - - 20 + @android:integer/config_mediumAnimTime 96 diff --git a/WordPress/src/main/res/values/key_strings.xml b/WordPress/src/main/res/values/key_strings.xml index 60d3d2f86c80..27a01ba832ad 100644 --- a/WordPress/src/main/res/values/key_strings.xml +++ b/WordPress/src/main/res/values/key_strings.xml @@ -19,7 +19,6 @@ wp_pref_app_about_section wp_pref_app_experimental_section wp_pref_language - wp_pref_app_theme wp_pref_app_about wp_pref_open_source_licenses wp_pref_notification_blogs diff --git a/WordPress/src/main/res/values/reader_styles.xml b/WordPress/src/main/res/values/reader_styles.xml index ae3c6c3c511b..0e78294c697d 100644 --- a/WordPress/src/main/res/values/reader_styles.xml +++ b/WordPress/src/main/res/values/reader_styles.xml @@ -12,58 +12,45 @@ - - - - - - - - - - - + diff --git a/WordPress/src/main/res/values/stats_styles.xml b/WordPress/src/main/res/values/stats_styles.xml index 5ae32361612f..3f0974c8854a 100644 --- a/WordPress/src/main/res/values/stats_styles.xml +++ b/WordPress/src/main/res/values/stats_styles.xml @@ -2,7 +2,8 @@ - @@ -12,30 +13,48 @@ @dimen/margin_extra_medium_large - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 7b52d8602358..d037ee8c3769 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -448,6 +448,7 @@ Don\'t leave it hanging! \'%1$s\' is waiting to be published. + Comment Saving changes Cancel editing this comment? Permanently delete this comment? @@ -817,22 +818,6 @@ We use other tracking tools, including some from third parties. Read about these and how to control them. Read privacy policy Remove location from media - Appearance - Light - Dark - Set by Battery Saver - light - dark - default - @string/app_theme_entry_value_light - - @string/app_theme_light - @string/app_theme_dark - - - @string/app_theme_entry_value_light - @string/app_theme_entry_value_dark - Stats @@ -1111,7 +1096,7 @@ Check that the site URL entered is valid - Select blog for QuickPress shortcut + Select blog for QuickPress shortcut Shortcut name can\'t be empty Set shortcut name QP %s @@ -1498,6 +1483,7 @@ Image settings WordPress blog + blogusername wordpress.com diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index d0075029449f..d729a9951fde 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -1,67 +1,36 @@ - - - - - - - - - - - - - - - @@ -149,9 +78,7 @@ - + + - - - - - - + + + + + + @@ -237,15 +186,15 @@ - - + + + + + + + + + + @@ -300,21 +286,21 @@ center - @@ -466,19 +457,21 @@ @@ -486,6 +479,10 @@ match_parent + + - - @@ -554,7 +553,8 @@ match_parent 1 @dimen/content_margin - ?attr/textAppearanceSubtitle1 + @color/quick_start_title_selector + @dimen/text_sz_large @@ -581,12 +582,21 @@ 1 + + + - - - - - @@ -684,7 +694,8 @@ wrap_content wrap_content center_vertical - ?attr/textAppearanceSubtitle1 + ?attr/wpColorText + @dimen/text_sz_large @@ -719,10 +730,8 @@ wrap_content @dimen/margin_extra_large @dimen/margin_extra_large - ?attr/textAppearanceHeadline6 - normal - sans-serif - sans-serif + ?attr/wpColorText + @dimen/text_sz_large end true @@ -746,12 +755,14 @@ @dimen/margin_extra_large @dimen/margin_extra_large ?android:attr/selectableItemBackground - ?attr/textAppearanceButton - ?attr/colorPrimary + true + @color/primary_40 + @dimen/text_sz_medium + bold @@ -760,19 +771,20 @@ wrap_content end 1 - ?attr/textAppearanceCaption - ?attr/colorOnSurface - @dimen/material_emphasis_medium + ?attr/wpColorTextSubtle + @dimen/text_sz_small - + + @@ -781,36 +793,35 @@ match_parent wrap_content @dimen/margin_extra_large - ?attr/textAppearanceSubtitle1 + ?attr/wpColorText + @dimen/text_sz_large + + + - @@ -821,7 +832,8 @@ @@ -878,7 +892,7 @@ + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + - + @@ -1052,12 +1127,11 @@ - - - - - + diff --git a/WordPress/src/main/res/values/styles_calypso.xml b/WordPress/src/main/res/values/styles_calypso.xml index 925271eb9922..50a98b79f6d9 100644 --- a/WordPress/src/main/res/values/styles_calypso.xml +++ b/WordPress/src/main/res/values/styles_calypso.xml @@ -10,6 +10,17 @@ @style/Calypso.TextAppearance + + + + + + + + + diff --git a/WordPress/src/main/res/xml/account_settings.xml b/WordPress/src/main/res/xml/account_settings.xml index 29401d52c0d1..a829298efc51 100644 --- a/WordPress/src/main/res/xml/account_settings.xml +++ b/WordPress/src/main/res/xml/account_settings.xml @@ -6,22 +6,27 @@ diff --git a/WordPress/src/main/res/xml/app_settings.xml b/WordPress/src/main/res/xml/app_settings.xml index de3647535394..575c606381b5 100644 --- a/WordPress/src/main/res/xml/app_settings.xml +++ b/WordPress/src/main/res/xml/app_settings.xml @@ -1,21 +1,14 @@ - - - + android:layout="@layout/wp_preference_layout" + android:title="@string/interface_language"/> + app:iconTint="@color/neutral"/> + app:url="https://www.automattic.com/cookies"/> + app:url="https://www.automattic.com/privacy"/> + app:url="https://www.automattic.com/cookies"/> + app:iconTint="@color/neutral"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/preference_open_device_settings"/> + android:title="@string/site_settings_optimize_images"/> + app:longClickHint="@string/site_settings_image_width_hint"/> + app:longClickHint="@string/site_settings_image_quality_hint"/> + android:title="@string/preference_strip_image_location"/> + android:title="@string/site_settings_optimize_videos"/> + app:longClickHint="@string/site_settings_video_width_hint"/> + app:longClickHint="@string/site_settings_video_quality_hint"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/app_title"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/open_source_licenses"/> diff --git a/WordPress/src/main/res/xml/notifications_settings.xml b/WordPress/src/main/res/xml/notifications_settings.xml index caa42ec5917e..505989b69554 100644 --- a/WordPress/src/main/res/xml/notifications_settings.xml +++ b/WordPress/src/main/res/xml/notifications_settings.xml @@ -1,50 +1,55 @@ - + + android:layout="@layout/wp_preference_category" + android:title="@string/notification_settings_category_other" > + android:layout="@layout/wp_preference_category" + android:title="@string/notification_settings_category_sights_and_sounds" > diff --git a/WordPress/src/main/res/xml/site_settings.xml b/WordPress/src/main/res/xml/site_settings.xml index c97f2299e8fb..b8d3e343bfd7 100644 --- a/WordPress/src/main/res/xml/site_settings.xml +++ b/WordPress/src/main/res/xml/site_settings.xml @@ -1,8 +1,8 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + android:key="@string/pref_key_site_screen"> + app:summaryLines="1"/> + app:summaryLines="1"/> + app:summaryLines="1"/> + app:longClickHint="@string/site_settings_privacy_hint"/> + app:longClickHint="@string/site_settings_language_hint"/> + android:title="@string/site_settings_timezone_title"/> @@ -74,32 +74,33 @@ android:title="@string/site_settings_username_title" app:longClickHint="@string/site_settings_username_hint" app:maxSummaryLines="2" - app:summaryLines="1" /> + app:summaryLines="1"/> + app:summaryLines="1"/> + android:title="@string/site_settings_editor" + android:key="@string/pref_key_site_editor"> + android:layout="@layout/wp_preference_layout" + android:title="@string/site_settings_gutenberg_default_for_new_posts" + android:summary="@string/site_settings_gutenberg_default_for_new_posts_summary"/> @@ -113,13 +114,13 @@ android:id="@+id/pref_default_category" android:key="@string/pref_key_site_category" android:title="@string/site_settings_default_category_title" - app:longClickHint="@string/site_settings_category_hint" /> + app:longClickHint="@string/site_settings_category_hint"/> + app:longClickHint="@string/site_settings_tags_hint"/> + app:longClickHint="@string/site_settings_format_hint"/> + android:title="@string/site_settings_date_format_title"/> + android:title="@string/site_settings_time_format_title"/> + android:title="@string/site_settings_week_start_title"/> + app:longClickHint="@string/site_settings_related_posts_hint"/> + android:title="@string/site_settings_posts_per_page_title"/> @@ -173,7 +174,7 @@ android:title="@string/site_settings_quota_space_title" app:longClickHint="@string/site_settings_quota_space_hint" app:maxSummaryLines="1" - app:summaryLines="1" /> + app:summaryLines="1"/> + android:title="@string/site_settings_amp_title"/> @@ -204,19 +205,25 @@ + android:layout="@layout/wp_preference_layout" + android:title="@string/site_settings_site_accelerator" + app:backgroundColorChecked="@color/primary_40" + app:backgroundColorUnchecked="@color/neutral_40" + app:preferenceTextColor="@android:color/white" + app:switchThumbTint="@color/primary_0_gray_20_gray_40_selector" + app:switchTrackTint="@color/primary_0_gray_90_gray_50_selector" /> + android:layout="@layout/wp_preference_layout" + android:title="@string/site_settings_faster_images" /> + android:layout="@layout/wp_preference_layout" + android:title="@string/site_settings_faster_static_files" /> @@ -225,12 +232,14 @@ + android:layout="@layout/wp_preference_layout" + android:title="@string/site_settings_site_accelerator" + app:backgroundColorChecked="@color/primary_40" + app:backgroundColorUnchecked="@color/neutral_40" + app:preferenceTextColor="@color/white" + app:switchThumbTint="@color/primary_0_gray_20_gray_40_selector" + app:switchTrackTint="@color/primary_0_gray_90_gray_50_selector" /> + android:layout="@layout/wp_preference_layout" + android:title="@string/site_settings_faster_images" /> + android:layout="@layout/wp_preference_layout" + android:title="@string/site_settings_faster_static_files" /> @@ -272,6 +287,7 @@ @@ -284,6 +300,7 @@ @@ -295,8 +312,9 @@ + android:layout="@layout/wp_preference_layout" + android:title="@string/site_settings_improved_search" + android:summary="@string/site_settings_improved_search_summary"/> @@ -314,19 +332,19 @@ android:id="@+id/pref_allow_comments" android:key="@string/pref_key_site_allow_comments" android:title="@string/site_settings_allow_comments_title" - app:longClickHint="@string/site_settings_allow_comments_hint" /> + app:longClickHint="@string/site_settings_allow_comments_hint"/> + app:longClickHint="@string/site_settings_send_pingbacks_hint"/> + app:longClickHint="@string/site_settings_receive_pingbacks_hint"/> + app:longClickHint="@string/site_settings_allow_comments_hint"/> + app:longClickHint="@string/site_settings_send_pingbacks_hint"/> + app:longClickHint="@string/site_settings_receive_pingbacks_hint"/> + app:useCustomJsFormatting="true"/> @@ -376,20 +394,20 @@ android:id="@+id/pref_identity_required" android:key="@string/pref_key_site_identity_required" android:title="@string/site_settings_identity_required_title" - app:longClickHint="@string/site_settings_identity_required_hint" /> + app:longClickHint="@string/site_settings_identity_required_hint"/> + app:longClickHint="@string/site_settings_user_account_required_hint"/> + app:longClickHint="@string/site_settings_close_after_hint"/> + app:longClickHint="@string/site_settings_sort_by_hint"/> + app:longClickHint="@string/site_settings_threading_hint"/> + app:longClickHint="@string/site_settings_paging_hint"/> + app:longClickHint="@string/site_settings_whitelist_hint"/> + app:longClickHint="@string/site_settings_multiple_links_hint"/> + app:longClickHint="@string/site_settings_moderation_hold_hint"/> + app:longClickHint="@string/site_settings_blacklist_hint"/> @@ -461,19 +479,22 @@ + android:layout="@layout/wp_preference_layout" + android:title="@string/jetpack_monitor_uptime_title"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/jetpack_send_email_notifications_title"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/jetpack_send_wp_notifications_title"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/jetpack_prevent_brute_force_title"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/jetpack_brute_force_whitelist_title"/> @@ -499,19 +522,22 @@ + android:layout="@layout/wp_preference_layout" + android:title="@string/jetpack_allow_wpcom_sign_in_title"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/jetpack_match_wpcom_via_email_title"/> + android:layout="@layout/wp_preference_layout" + android:title="@string/jetpack_require_two_factor_title"/> + app:useCustomJsFormatting="false"/> @@ -545,8 +571,9 @@ android:title="@string/let_us_help" app:buttonText="@string/contact_support" app:buttonTextAllCaps="true" + app:buttonTextColor="?attr/wpColorText" app:longClickHint="@string/site_settings_start_over_hint" - app:preficon="@drawable/ic_history_white_24dp" /> + app:preficon="@drawable/ic_history_white_24dp"/> @@ -554,13 +581,13 @@ android:id="@+id/pref_export_site" android:key="@string/pref_key_site_export_site" android:title="@string/site_settings_export_content_title" - app:longClickHint="@string/export_site_hint" /> + app:longClickHint="@string/export_site_hint"/> + app:longClickHint="@string/delete_site_hint"/> diff --git a/fastlane/metadata/android/ar/changelogs/836.txt b/fastlane/metadata/android/ar/changelogs/836.txt new file mode 100644 index 000000000000..d536448b1330 --- /dev/null +++ b/fastlane/metadata/android/ar/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- إضافات مُحرِّر المكوِّن: تمت إضافة مكوِّنات الأزرار والمجموعات، ودعم مزيد من الخيارات في إعدادات مكوِّن الصور والمعرض. +- تحسينات مُحرِّر المكوِّن: تمت إضافة دعم التمرير داخل منتقي المكوِّن وإعداداته، وتم إدخال شريط أدوات عائم لتسهيل التنقل بين المكوِّنات. +- إصلاحات مُحرِّر المكوِّن: تم إصلاح المشكلات المتعلقة بصور العنصر النائب في أثناء رفع الصور، ورموز المشاعر في عناوين المقالات، والتفاف النص في مكوِّنات الأكواد القصيرة. +- القارئ: تمت إضافة عامل تصفية علامة التبويب لتحسين التنقل بين المواقع/الوسوم. + diff --git a/fastlane/metadata/android/de-DE/changelogs/831.txt b/fastlane/metadata/android/de-DE/changelogs/831.txt deleted file mode 100644 index 4d4ba5d73dd4..000000000000 --- a/fastlane/metadata/android/de-DE/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -Zahlreiche Updates am Block-Editor: - -* Icon zum längeren Drücken hinzugefügt, um Blöcke davor/dahinter einzufügen. -* Die App versucht, Bilder anzuzeigen, wenn sie nach einer Verbindungsunterbrechung wieder online ist. -* Problem mit leerem Editor behoben, wenn versucht wird, einen Beitrag mit Bildern oder Links aus einer anderen App zu erstellen. -* Optionen für Bildgröße zum Galerieblock hinzugefügt. -* Fehler behoben, der das Zusammenführen von Absatzblöcken verhinderte. - diff --git a/fastlane/metadata/android/de-DE/changelogs/836.txt b/fastlane/metadata/android/de-DE/changelogs/836.txt new file mode 100644 index 000000000000..99abdc771320 --- /dev/null +++ b/fastlane/metadata/android/de-DE/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- Neu im Block-Editor: Die Blöcke „Button“ und „Gruppe“ wurden hinzugefügt. Darüber hinaus werden jetzt weitere Optionen in den Bild- und Galerieblockeinstellungen. +- Verbesserungen am Block-Editor: Support für den Bildlauf in der Blockauswahl und in den Blockeinstellungen und neue unverankerte Toolbar für einfaches Wechseln zwischen Blöcken. +- Problembehebungen am Block-Editor: Probleme bei Platzhalterbildern während Bildupload, Probleme mit Emojis in Beitragstiteln und Probleme beim Textumbruch in Shortcode-Blöcken wurden behoben. +- Reader: Tabfilter für bessere Navigation auf Websites und bei Schlagwörtern hinzugefügt. + diff --git a/fastlane/metadata/android/en-US/changelogs/831.txt b/fastlane/metadata/android/en-US/changelogs/831.txt deleted file mode 100644 index 1082bd8bac78..000000000000 --- a/fastlane/metadata/android/en-US/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -Lots of updates to the block editor: - -* Added a long-press icon for adding blocks before/after. -* App will try to display images when coming back online after a disconnection. -* Resolved issue with blank editor when trying to create a post with images or links from another app. -* Added image size options to the Gallery block. -* Fixed a bug that prevented paragraph blocks from merging. - diff --git a/fastlane/metadata/android/en-US/changelogs/836.txt b/fastlane/metadata/android/en-US/changelogs/836.txt new file mode 100644 index 000000000000..ae06a602afdf --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- Block editor additions: Added Button and Group blocks, and support for more options in Image and Gallery block settings. +- Block editor enhancements: Added scroll support inside block picker and block settings, and introduced a floating toolbar to make navigating blocks easier. +- Block editor fixes: Fixed issues around placeholder images during image upload, emojis in post titles, and text-wrapping in Shortcode blocks. +- Reader: Added tab filtering for better sites/tag navigation. + diff --git a/fastlane/metadata/android/es-ES/changelogs/831.txt b/fastlane/metadata/android/es-ES/changelogs/831.txt deleted file mode 100644 index 09183d588c61..000000000000 --- a/fastlane/metadata/android/es-ES/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -Muchas actualizaciones para el editor de bloques: - -* Añadido un icono de pulsación larga para añadir bloques antes/después. -* La aplicación intentará mostrar las imágenes cuando vuelva a estar online después de una desconexión. -* Resuelto un problema con el editor en blanco al intentar crear una entrada con imágenes o enlaces de otra aplicación. -* Añadidas opciones de tamaño de imagen al bloque de galería. -* Corregido un error que impedía la combinación de los bloques de párrafos. - diff --git a/fastlane/metadata/android/es-ES/changelogs/836.txt b/fastlane/metadata/android/es-ES/changelogs/836.txt new file mode 100644 index 000000000000..2d43fad25e82 --- /dev/null +++ b/fastlane/metadata/android/es-ES/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- Añadidos bloques al editor: Añadidos bloques de grupo y de botón, y compatibilidad con más opciones en los ajustes de los bloques de imagen y de galería. +- Mejoras en el editor de bloques: Añadida compatibilidad con scroll dentro del selector de bloques y ajustes de los bloques, y se ha introducido una barra de herramientas flotante para hacer más sencilla la navegación por los bloques. +- Correcciones en el editor de bloques: Corregidos errores con las imágenes de marcador de posición durante la subida de imágenes, emojis en títulos de entradas y envoltura de texto en los bloques de shortcode. +- Lector: Añadido filtrado de pestañas para una mejor navegación por sitios/etiquetas. + diff --git a/fastlane/metadata/android/fr-CA/changelogs/831.txt b/fastlane/metadata/android/fr-CA/changelogs/831.txt deleted file mode 100644 index d3ee7afde32a..000000000000 --- a/fastlane/metadata/android/fr-CA/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2 : -Nombreuses mises à jour de l'éditeur de blocs : - -*Ajout d'une icône à pression longue pour ajouter des blocs avant/après. -*L'application tentera d'afficher les images lors d'un retour en ligne après une déconnexion. -*Résolution d'un problème d'éditeur vierge lors de la création d'un article contenant des images ou des liens provenant d'une autre application. -*Ajout d'options de taille d'image au bloc de galerie. -*Résolution d'un bug empêchant la fusion des blocs de paragraphe. - diff --git a/fastlane/metadata/android/fr-CA/changelogs/836.txt b/fastlane/metadata/android/fr-CA/changelogs/836.txt new file mode 100644 index 000000000000..bb64f74ec713 --- /dev/null +++ b/fastlane/metadata/android/fr-CA/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3 : +- Ajouts de l'éditeur de blocs : blocs Bouton et Groupe ajoutés, + d’options dans les réglages de bloc Image et Galerie. +- Améliorations de l'éditeur de blocs : défilement ajouté dans le sélecteur et réglages de bloc, nouvelle barre d'outils flottante pour mieux naviguer dans les blocs. +- Résolutions de l'éditeur de blocs : images de texte indicatif lors du chargement d’images, émojis des titres d'article et habillage du texte de blocs de code abrégé résolus. +- Lecteur : filtrage d’onglet ajouté pour mieux naviguer sur les sites/étiquette. + diff --git a/fastlane/metadata/android/fr-FR/changelogs/831.txt b/fastlane/metadata/android/fr-FR/changelogs/831.txt deleted file mode 100644 index d3ee7afde32a..000000000000 --- a/fastlane/metadata/android/fr-FR/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2 : -Nombreuses mises à jour de l'éditeur de blocs : - -*Ajout d'une icône à pression longue pour ajouter des blocs avant/après. -*L'application tentera d'afficher les images lors d'un retour en ligne après une déconnexion. -*Résolution d'un problème d'éditeur vierge lors de la création d'un article contenant des images ou des liens provenant d'une autre application. -*Ajout d'options de taille d'image au bloc de galerie. -*Résolution d'un bug empêchant la fusion des blocs de paragraphe. - diff --git a/fastlane/metadata/android/fr-FR/changelogs/836.txt b/fastlane/metadata/android/fr-FR/changelogs/836.txt new file mode 100644 index 000000000000..bb64f74ec713 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3 : +- Ajouts de l'éditeur de blocs : blocs Bouton et Groupe ajoutés, + d’options dans les réglages de bloc Image et Galerie. +- Améliorations de l'éditeur de blocs : défilement ajouté dans le sélecteur et réglages de bloc, nouvelle barre d'outils flottante pour mieux naviguer dans les blocs. +- Résolutions de l'éditeur de blocs : images de texte indicatif lors du chargement d’images, émojis des titres d'article et habillage du texte de blocs de code abrégé résolus. +- Lecteur : filtrage d’onglet ajouté pour mieux naviguer sur les sites/étiquette. + diff --git a/fastlane/metadata/android/id/changelogs/831.txt b/fastlane/metadata/android/id/changelogs/831.txt deleted file mode 100644 index a53fdebc3582..000000000000 --- a/fastlane/metadata/android/id/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -Banyak pembaruan untuk penyunting blok: - -* Menambahkan ikon tekan lama untuk menambahkan blok sebelum/sesudah. -* Aplikasi akan mencoba menampilkan gambar saat kembali online setelah sambungan terputus. -* Menyelesaikan masalah dengan penyunting yang kosong saat mencoba membuat pos dengan gambar atau tautan dari aplikasi lain. -* Menambahkan pilihan ukuran gambar ke blok Galeri. -* Memperbaiki bug yang mencegah blok paragraf tergabung. - diff --git a/fastlane/metadata/android/id/changelogs/836.txt b/fastlane/metadata/android/id/changelogs/836.txt new file mode 100644 index 000000000000..9251aeeab511 --- /dev/null +++ b/fastlane/metadata/android/id/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- Tambahan penyunting blok: Menambahkan blok Tombol dan Kelompok, dan mendukung lebih banyak opsi di pengaturan blok Gambar dan Galeri. +- Peningkatan pada penyunting blok: Menambahkan dukungan gulir di dalam pemilih blok dan pengaturan blok, dan memperkenalkan bilah peralatan mengambang untuk mempermudah navigasi blok. +- Perbaikan pada penyunting blok: Memperbaiki masalah seputar gambar placeholder selama pengunggahan gambar, emoji di judul pos, dan text-wrapping di blok Shortcode. +- Pembaca: Menambahkan penyaringan tab untuk navigasi situs/tag yang lebih baik. + diff --git a/fastlane/metadata/android/it-IT/changelogs/831.txt b/fastlane/metadata/android/it-IT/changelogs/831.txt deleted file mode 100644 index 09cfa895023f..000000000000 --- a/fastlane/metadata/android/it-IT/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -Molti aggiornamenti per l'editor a blocchi: - -*Aggiunta un'icona a pressione prolungata per aggiungere blocchi prima/dopo. -*L'app cercherà di visualizzare le immagini quando si ritorna online dopo una disconnessione. -*Risolto un problema con l'editor vuoto quando si provava a creare un articolo con immagini o link da un'altra app. -*Aggiunte le opzioni delle dimensioni dell'immagine dal blocco Galleria. -*Risolto un bug che impediva l'unione dei blocchi Paragrafo. - diff --git a/fastlane/metadata/android/it-IT/changelogs/836.txt b/fastlane/metadata/android/it-IT/changelogs/836.txt new file mode 100644 index 000000000000..64aeec80d363 --- /dev/null +++ b/fastlane/metadata/android/it-IT/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- Aggiunte all'editor a blocchi: blocchi Pulsante e Gruppo e opzioni nelle impostazioni di Immagine e Galleria. +- Miglioramenti all'editor a blocchi: aggiunta dello scorrimento nel selezionatore e nelle impostazioni e di una barra mobile per la navigazione. +- Correzioni all'editor a blocchi: correzione del caricamento di immagini segnaposto, degli emoji nei titoli degli articoli e del ritorno a capo nei blocchi Shortcode. +- Reader: aggiunta del filtro schede per migliorare la navigazione di siti/tag. + diff --git a/fastlane/metadata/android/iw-IL/changelogs/836.txt b/fastlane/metadata/android/iw-IL/changelogs/836.txt new file mode 100644 index 000000000000..be377479183e --- /dev/null +++ b/fastlane/metadata/android/iw-IL/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- הוספות לעורך הבלוקים: הוספנו בלוק כפתור ובלוק קבוצה ותמיכה באפשרויות נוספות בהגדרות הבלוקים של תמונה וגלריה. +- שיפורים לעורך הבלוקים: הוספנו תמיכה בגלילה בתוך בורר הבלוקים ובהגדרות הבלוק. כמו כן, הוספנו סרגל כלים צף כדי לאפשר ניווט קל יותר בבלוקים. +- תיקונים לעורך הבלוקים: תיקנו כמה בעיות בתמונות של מצייני המיקום שהופיעו בשלב העלאת תמונות, בסמלי Emoji בכותרות הפוסטים ובגלישת הטקסט בבלוקים של שורטקוד. +- Reader: הוספנו לשונית לסינון כדי לאפשר ניווט יעיל יותר באתרים/בתגיות. + diff --git a/fastlane/metadata/android/ja-JP/changelogs/836.txt b/fastlane/metadata/android/ja-JP/changelogs/836.txt new file mode 100644 index 000000000000..63e3c84cd8f6 --- /dev/null +++ b/fastlane/metadata/android/ja-JP/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- ブロックエディターの追加機能 :「ボタン」ブロックと「Group」ブロックが追加され、画像ブロックとギャラリーブロックの設定で使用できるオプションが増えました。 +ブロックエディターの機能強化 :ブロックピッカー内とブロック設定内で、スクロール機能が使えるようになりました。ブロック操作を簡単にする移動式ツールバーも導入されました。 +- ブロックエディターの修正 :画像アップロード中のプレースホルダー画像、投稿名の絵文字、ショートコードブロックでのワードラップ機能で発生していた問題を修正しました。 +- Reader:サイトやタグへのナビゲーションを向上するタブのフィルタリング機能を追加しました。 + diff --git a/fastlane/metadata/android/ko-KR/changelogs/836.txt b/fastlane/metadata/android/ko-KR/changelogs/836.txt new file mode 100644 index 000000000000..c4c664f7374a --- /dev/null +++ b/fastlane/metadata/android/ko-KR/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- 블록 편집기 추가 기능: 버튼 및 그룹 블록, 이미지 및 갤러리 블록 설정의 더 많은 옵션을 위한 지원을 추가했습니다. +- 블록 편집기의 향상된 기능: 블록 선택기 및 블록 설정 내부에 스크롤 지원을 추가하고 블록을 보다 쉽게 탐색할 수 있는 플로팅 도구 모음을 도입했습니다. +- 블록 편집기 수정 사항: 이미지 업로드 중 자리 표시자 이미지, 글 제목의 이모티콘 및 쇼트코드 블록의 텍스트 줄 바꿈 문제를 수정했습니다. +- 리더: 더 효과적인 사이트/태그 탐색을 위해 탭 필터링을 추가했습니다. + diff --git a/fastlane/metadata/android/nl-NL/changelogs/831.txt b/fastlane/metadata/android/nl-NL/changelogs/831.txt deleted file mode 100644 index ac443f7abf75..000000000000 --- a/fastlane/metadata/android/nl-NL/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -Veel updates voor de blok-editor: - -* Pictogram voor iets langer indrukken toegevoegd om vooraf/achteraf blokken toe te voegen. -* App probeert afbeeldingen weer te geven als je weer online bent nadat de internetverbinding verbroken is geweest. -* Probleem opgelost met lege editor die een bericht probeert te maken met afbeeldingen of links van een andere app. -* Beeldformaatopties toegevoegd aan het galerieblok. -* Probleem opgelost waarbij werd voorkomen dat paragraafblokken werden samengevoegd. - diff --git a/fastlane/metadata/android/nl-NL/changelogs/836.txt b/fastlane/metadata/android/nl-NL/changelogs/836.txt new file mode 100644 index 000000000000..953fae49cd97 --- /dev/null +++ b/fastlane/metadata/android/nl-NL/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- Aanvullingen op de blokeditor: de knop- en groepblokken zijn toegevoegd en er wordt ondersteuning voor meer opties geboden in de instellingen van het afbeeldings- en galerijblok. +- Verbeteringen aan de blokeditor: ondersteuning voor scrollen toegevoegd aan de blokkiezer en blokinstellingen en een zwevende werkbalk geïntroduceerd om het navigeren in blokken eenvoudiger te maken. +- Fixes van de blokeditor: problemen met placeholder-afbeeldingen opgelost tijdens het uploaden van afbeeldingen, emoji's in berichttitels en tekstafbreking in shortcode-blokken. +- Reader: tabbladfilters toegevoegd voor verbeterde navigatie van sites/tags. + diff --git a/fastlane/metadata/android/pt-BR/changelogs/831.txt b/fastlane/metadata/android/pt-BR/changelogs/831.txt deleted file mode 100644 index 86cf07002fc3..000000000000 --- a/fastlane/metadata/android/pt-BR/changelogs/831.txt +++ /dev/null @@ -1,8 +0,0 @@ -14.2: -Várias melhorias no editor de blocos: - -* Adicionado um ícone de toque longo para adição de blocos antes e depois. -* O aplicativo tentará exibir imagens quando ficar online depois de ser desconectado. -* Solução do problema que mostrava o editor vazio ao tentar criar um post com imagens ou links de outro aplicativo. -* Agora há opções de tamanho de imagem no bloco de galeria. -* Solução de um erro que impedia a junção de blocos de paragrafo. diff --git a/fastlane/metadata/android/release_notes.xml b/fastlane/metadata/android/release_notes.xml index 8147222ce59b..313667d0d0d1 100644 --- a/fastlane/metadata/android/release_notes.xml +++ b/fastlane/metadata/android/release_notes.xml @@ -1,152 +1,123 @@ - -14.2: -Zahlreiche Updates am Block-Editor: + +14.3: +- إضافات مُحرِّر المكوِّن: تمت إضافة مكوِّنات الأزرار والمجموعات، ودعم مزيد من الخيارات في إعدادات مكوِّن الصور والمعرض. +- تحسينات مُحرِّر المكوِّن: تمت إضافة دعم التمرير داخل منتقي المكوِّن وإعداداته، وتم إدخال شريط أدوات عائم لتسهيل التنقل بين المكوِّنات. +- إصلاحات مُحرِّر المكوِّن: تم إصلاح المشكلات المتعلقة بصور العنصر النائب في أثناء رفع الصور، ورموز المشاعر في عناوين المقالات، والتفاف النص في مكوِّنات الأكواد القصيرة. -* Icon zum längeren Drücken hinzugefügt, um Blöcke davor/dahinter einzufügen. -* Die App versucht, Bilder anzuzeigen, wenn sie nach einer Verbindungsunterbrechung wieder online ist. -* Problem mit leerem Editor behoben, wenn versucht wird, einen Beitrag mit Bildern oder Links aus einer anderen App zu erstellen. -* Optionen für Bildgröße zum Galerieblock hinzugefügt. -* Fehler behoben, der das Zusammenführen von Absatzblöcken verhinderte. + + +14.3: +- Neu im Block-Editor: Die Blöcke „Button“ und „Gruppe“ wurden hinzugefügt. Darüber hinaus werden jetzt weitere Optionen in den Bild- und Galerieblockeinstellungen. +- Verbesserungen am Block-Editor: Support für den Bildlauf in der Blockauswahl und in den Blockeinstellungen und neue unverankerte Toolbar für einfaches Wechseln zwischen Blöcken. -14.2: -Lots of updates to the block editor: - -* Added a long-press icon for adding blocks before/after. -* App will try to display images when coming back online after a disconnection. -* Resolved issue with blank editor when trying to create a post with images or links from another app. -* Added image size options to the Gallery block. -* Fixed a bug that prevented paragraph blocks from merging. +14.3: +- Block editor additions: Added Button and Group blocks, and support for more options in Image and Gallery block settings. +- Block editor enhancements: Added scroll support inside block picker and block settings, and introduced a floating toolbar to make navigating blocks easier. +- Block editor fixes: Fixed issues around placeholder images during image upload, emojis in post titles, and text-wrapping in Shortcode blocks. +- Reader: Added tab filtering for better sites/tag navigation. -14.2: -Muchas actualizaciones para el editor de bloques: - -* Añadido un icono de pulsación larga para añadir bloques antes/después. -* La aplicación intentará mostrar las imágenes cuando vuelva a estar online después de una desconexión. -* Resuelto un problema con el editor en blanco al intentar crear una entrada con imágenes o enlaces de otra aplicación. -* Añadidas opciones de tamaño de imagen al bloque de galería. -* Corregido un error que impedía la combinación de los bloques de párrafos. - +14.3: +- Añadidos bloques al editor: Añadidos bloques de grupo y de botón, y compatibilidad con más opciones en los ajustes de los bloques de imagen y de galería. +- Mejoras en el editor de bloques: Añadida compatibilidad con scroll dentro del selector de bloques y ajustes de los bloques, y se ha introducido una barra de herramientas flotante para hacer más sencilla la navegación por los bloques. -14.2 : -Nombreuses mises à jour de l'éditeur de blocs : - -*Ajout d'une icône à pression longue pour ajouter des blocs avant/après. -*L'application tentera d'afficher les images lors d'un retour en ligne après une déconnexion. -*Résolution d'un problème d'éditeur vierge lors de la création d'un article contenant des images ou des liens provenant d'une autre application. -*Ajout d'options de taille d'image au bloc de galerie. -*Résolution d'un bug empêchant la fusion des blocs de paragraphe. +14.3 : +- Ajouts de l'éditeur de blocs : blocs Bouton et Groupe ajoutés, + d’options dans les réglages de bloc Image et Galerie. +- Améliorations de l'éditeur de blocs : défilement ajouté dans le sélecteur et réglages de bloc, nouvelle barre d'outils flottante pour mieux naviguer dans les blocs. +- Résolutions de l'éditeur de blocs : images de texte indicatif lors du chargement d’images, émojis des titres d'article et habillage du texte de blocs de code abrégé résolus. -14.2 : -Nombreuses mises à jour de l'éditeur de blocs : - -*Ajout d'une icône à pression longue pour ajouter des blocs avant/après. -*L'application tentera d'afficher les images lors d'un retour en ligne après une déconnexion. -*Résolution d'un problème d'éditeur vierge lors de la création d'un article contenant des images ou des liens provenant d'une autre application. -*Ajout d'options de taille d'image au bloc de galerie. -*Résolution d'un bug empêchant la fusion des blocs de paragraphe. +14.3 : +- Ajouts de l'éditeur de blocs : blocs Bouton et Groupe ajoutés, + d’options dans les réglages de bloc Image et Galerie. +- Améliorations de l'éditeur de blocs : défilement ajouté dans le sélecteur et réglages de bloc, nouvelle barre d'outils flottante pour mieux naviguer dans les blocs. +- Résolutions de l'éditeur de blocs : images de texte indicatif lors du chargement d’images, émojis des titres d'article et habillage du texte de blocs de code abrégé résolus. + +14.3: +- הוספות לעורך הבלוקים: הוספנו בלוק כפתור ובלוק קבוצה ותמיכה באפשרויות נוספות בהגדרות הבלוקים של תמונה וגלריה. +- שיפורים לעורך הבלוקים: הוספנו תמיכה בגלילה בתוך בורר הבלוקים ובהגדרות הבלוק. כמו כן, הוספנו סרגל כלים צף כדי לאפשר ניווט קל יותר בבלוקים. +- תיקונים לעורך הבלוקים: תיקנו כמה בעיות בתמונות של מצייני המיקום שהופיעו בשלב העלאת תמונות, בסמלי Emoji בכותרות הפוסטים ובגלישת הטקסט בבלוקים של שורטקוד. +- Reader: הוספנו לשונית לסינון כדי לאפשר ניווט יעיל יותר באתרים/בתגיות. + + -14.2: -Banyak pembaruan untuk penyunting blok: - -* Menambahkan ikon tekan lama untuk menambahkan blok sebelum/sesudah. -* Aplikasi akan mencoba menampilkan gambar saat kembali online setelah sambungan terputus. -* Menyelesaikan masalah dengan penyunting yang kosong saat mencoba membuat pos dengan gambar atau tautan dari aplikasi lain. -* Menambahkan pilihan ukuran gambar ke blok Galeri. -* Memperbaiki bug yang mencegah blok paragraf tergabung. +14.3: +- Tambahan penyunting blok: Menambahkan blok Tombol dan Kelompok, dan mendukung lebih banyak opsi di pengaturan blok Gambar dan Galeri. +- Peningkatan pada penyunting blok: Menambahkan dukungan gulir di dalam pemilih blok dan pengaturan blok, dan memperkenalkan bilah peralatan mengambang untuk mempermudah navigasi blok. +- Perbaikan pada penyunting blok: Memperbaiki masalah seputar gambar placeholder selama pengunggahan gambar, emoji di judul pos, dan text-wrapping di blok Shortcode. -14.2: -Molti aggiornamenti per l'editor a blocchi: - -*Aggiunta un'icona a pressione prolungata per aggiungere blocchi prima/dopo. -*L'app cercherà di visualizzare le immagini quando si ritorna online dopo una disconnessione. -*Risolto un problema con l'editor vuoto quando si provava a creare un articolo con immagini o link da un'altra app. -*Aggiunte le opzioni delle dimensioni dell'immagine dal blocco Galleria. -*Risolto un bug che impediva l'unione dei blocchi Paragrafo. +14.3: +- Aggiunte all'editor a blocchi: blocchi Pulsante e Gruppo e opzioni nelle impostazioni di Immagine e Galleria. +- Miglioramenti all'editor a blocchi: aggiunta dello scorrimento nel selezionatore e nelle impostazioni e di una barra mobile per la navigazione. +- Correzioni all'editor a blocchi: correzione del caricamento di immagini segnaposto, degli emoji nei titoli degli articoli e del ritorno a capo nei blocchi Shortcode. + +14.3: +- ブロックエディターの追加機能 :「ボタン」ブロックと「Group」ブロックが追加され、画像ブロックとギャラリーブロックの設定で使用できるオプションが増えました。 +ブロックエディターの機能強化 :ブロックピッカー内とブロック設定内で、スクロール機能が使えるようになりました。ブロック操作を簡単にする移動式ツールバーも導入されました。 +- ブロックエディターの修正 :画像アップロード中のプレースホルダー画像、投稿名の絵文字、ショートコードブロックでのワードラップ機能で発生していた問題を修正しました。 +- Reader:サイトやタグへのナビゲーションを向上するタブのフィルタリング機能を追加しました。 + + + +14.3: +- 블록 편집기 추가 기능: 버튼 및 그룹 블록, 이미지 및 갤러리 블록 설정의 더 많은 옵션을 위한 지원을 추가했습니다. +- 블록 편집기의 향상된 기능: 블록 선택기 및 블록 설정 내부에 스크롤 지원을 추가하고 블록을 보다 쉽게 탐색할 수 있는 플로팅 도구 모음을 도입했습니다. +- 블록 편집기 수정 사항: 이미지 업로드 중 자리 표시자 이미지, 글 제목의 이모티콘 및 쇼트코드 블록의 텍스트 줄 바꿈 문제를 수정했습니다. +- 리더: 더 효과적인 사이트/태그 탐색을 위해 탭 필터링을 추가했습니다. + + -14.2: -Veel updates voor de blok-editor: - -* Pictogram voor iets langer indrukken toegevoegd om vooraf/achteraf blokken toe te voegen. -* App probeert afbeeldingen weer te geven als je weer online bent nadat de internetverbinding verbroken is geweest. -* Probleem opgelost met lege editor die een bericht probeert te maken met afbeeldingen of links van een andere app. -* Beeldformaatopties toegevoegd aan het galerieblok. -* Probleem opgelost waarbij werd voorkomen dat paragraafblokken werden samengevoegd. +14.3: +- Aanvullingen op de blokeditor: de knop- en groepblokken zijn toegevoegd en er wordt ondersteuning voor meer opties geboden in de instellingen van het afbeeldings- en galerijblok. +- Verbeteringen aan de blokeditor: ondersteuning voor scrollen toegevoegd aan de blokkiezer en blokinstellingen en een zwevende werkbalk geïntroduceerd om het navigeren in blokken eenvoudiger te maken. - -14.2: -Várias melhorias no editor de blocos: - -* Adicionado um ícone de toque longo para adição de blocos antes e depois. -* O aplicativo tentará exibir imagens quando ficar online depois de ser desconectado. -* Solução do problema que mostrava o editor vazio ao tentar criar um post com imagens ou links de outro aplicativo. -* Agora há opções de tamanho de imagem no bloco de galeria. -* Solução de um erro que impedia a junção de blocos de paragrafo. - -14.2: -Уйма обновлений редактора блоков: - -* Добавлен значок при длительном нажатии для добавления блоков перед или после. -* Приложение будет повторно пытаться загрузить изображения после сбоев сетевого подключения. -* Исправлена проблема с пустым редактором при создании записи с изображеними или ссылками в другом приложении. -* В блок галереи добавлены варианты размеров изображений. -* Исправлена ошибка при объединении блоков параграфов. +14.3: +- Добавления к редактору блоков: Блоки кнопка и группа, поддержка большего количества настроек для блоков изображений и галереи. +- Улучшения редактора блоков: поддержка прокрутки при выборе блоков и в настройках, плавающая панель инструментов для навигации по блокам. +- Исправления редактора блоков: проблемы с изображениями-заменителями во время загрузки, эмодзи в названиях записей, перенос текста в блоках шорткодов. +- Чтиво: фильтрация вкладок для улучшенной навигации по меткам/сайтам. -14.2: -Många uppdateringar av blockredigeraren: - -* Ny ikon vid långt tryck för att lägga till block före/efter. -* Appen försöker att visa bilder när förbindelsen återkommer efter ett avbrott. -* Löst problem med tom redigerare vid försök att skapa ett inlägg med bilder eller länkar från annan app. -* Lagt till alternativ för bildstorlekar i galleriblocket. -* Rättat ett fel som inte lät styckeblock kombineras. +14.3: +- I blockredigeraren: Nya block för knapp och grupp, fler inställningar i bild- och galleriblock. +- Förbättringar av blockredigeraren: Rullist i blockväljare och blockinställningar, ny flytande verktygslist för enklare blocknavigering. +- Rättelser i blockredigeraren: Löst problem med platshållare i samband med bilduppladdning, användning av emoji i inläggsrubriker och radbrytning i kordkodsblock. +- Läsaren: Lagt till flikfiltrering för bättre navigaton mellan webbplatser och etiketter. -14.2: -Blok düzenleyicide birçok güncelleme: - -* Önce / sonra blok eklemek için uzun basın simgesi eklendi. -* Uygulama, bağlantı kesildikten sonra tekrar çevrimiçi olduğunda görüntüleri göstermeye çalışacaktır. -* Başka bir uygulamadan resimler veya bağlantılar içeren bir yazı oluşturmaya çalışırken boş düzenleyici ile ilgili sorun çözüldü. -* Galeri bloğuna görüntü boyutu seçenekleri eklendi. -* Paragraf bloklarının birleştirilmesini engelleyen bir hata düzeltildi. +14.3: +- Blok düzenleyici eklemeleri: Düğme ve Grup bloklarının yanı sıra, Görsel ve Galeri bloku ayarlarına daha fazla seçenek desteği eklendi. +- Blok düzenleyici geliştirmeleri: Blok seçici ve blok ayarlarına kaydırma desteği ve bloklarda gezinmeyi kolaylaştırmak için kayan bir araç çubuğu eklendi. +- Blok düzenleyici düzeltmeleri: Görsel karşıya yüklemesi sırasında yer tutucu görselleri, yazı başlığındaki emojiler ve Kısa Kod bloklarında yazı kaydırma ile ilgili sorunlar düzeltildi. + -14.2: -对区块编辑器进行了许多更新: - -* 添加了用于在之前/之后添加区块的长按图标。 -* 断开连接然后重新连接后,应用程序会尝试显示图片。 -* 解决了尝试创建包含图片或其他应用程序链接的文章时出现的空白编辑器问题。 -* 在图库区块中添加了图片大小选项。 -* 修复了阻止段落块合并的错误。 +14.3: +- 区块编辑器新增内容:添加了“按钮”和“组”区块,并且在“图片”和“图库”区块设置中支持更多选项。 +- 区块编辑器增强功能:在区块选择器和区块设置中添加了滚动支持,同时引入了浮动工具栏,使得区块间导航变得更加轻松。 +- 区块编辑器修复:修复了图片上传过程中的占位符图片相关问题、文章标题中的表情符号问题以及短代码区块中的文字环绕问题。 +- 阅读器:添加了选项卡过滤功能,以便在站点/标签间更方便地进行导航。 -14.2: -許多區塊編輯器更新︰ - -* 新增在之前/之後新增區塊的長按圖示。 -* 應用程式會嘗試在中斷連線又重新上線時顯示圖片。 -* 解決嘗試使用其他應用程式建立包含圖片或連結的文章時的空白編輯器問題。 -* 為「圖庫」區塊新增圖片大小選項。 -* 修正導致段落區塊無法合併的錯誤。 +14.3: +- 區塊編輯器新增功能:新增「按鈕」和「群組」區塊,並在「圖片」和「圖庫」區塊設定中支援更多選項。 +- 區塊編輯器增強功能:在區塊挑選器和區塊設定旁新增捲動功能支援,並推出讓區塊瀏覽更輕鬆的浮動工具列。 +- 區塊編輯器修正:修正圖片上傳時預留位置圖片的問題、文章標題的表情符號問題,以及短代碼區塊中的文繞圖問題。 +- 讀取器:新增分頁篩選功能,改善網站/標籤瀏覽體驗。 diff --git a/fastlane/metadata/android/ru-RU/changelogs/831.txt b/fastlane/metadata/android/ru-RU/changelogs/831.txt deleted file mode 100644 index 2d16b931a54b..000000000000 --- a/fastlane/metadata/android/ru-RU/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -Уйма обновлений редактора блоков: - -* Добавлен значок при длительном нажатии для добавления блоков перед или после. -* Приложение будет повторно пытаться загрузить изображения после сбоев сетевого подключения. -* Исправлена проблема с пустым редактором при создании записи с изображеними или ссылками в другом приложении. -* В блок галереи добавлены варианты размеров изображений. -* Исправлена ошибка при объединении блоков параграфов. - diff --git a/fastlane/metadata/android/ru-RU/changelogs/836.txt b/fastlane/metadata/android/ru-RU/changelogs/836.txt new file mode 100644 index 000000000000..b24d3faa4a8e --- /dev/null +++ b/fastlane/metadata/android/ru-RU/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- Добавления к редактору блоков: Блоки кнопка и группа, поддержка большего количества настроек для блоков изображений и галереи. +- Улучшения редактора блоков: поддержка прокрутки при выборе блоков и в настройках, плавающая панель инструментов для навигации по блокам. +- Исправления редактора блоков: проблемы с изображениями-заменителями во время загрузки, эмодзи в названиях записей, перенос текста в блоках шорткодов. +- Чтиво: фильтрация вкладок для улучшенной навигации по меткам/сайтам. + diff --git a/fastlane/metadata/android/sv-SE/changelogs/831.txt b/fastlane/metadata/android/sv-SE/changelogs/831.txt deleted file mode 100644 index 4a272ea8be63..000000000000 --- a/fastlane/metadata/android/sv-SE/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -Många uppdateringar av blockredigeraren: - -* Ny ikon vid långt tryck för att lägga till block före/efter. -* Appen försöker att visa bilder när förbindelsen återkommer efter ett avbrott. -* Löst problem med tom redigerare vid försök att skapa ett inlägg med bilder eller länkar från annan app. -* Lagt till alternativ för bildstorlekar i galleriblocket. -* Rättat ett fel som inte lät styckeblock kombineras. - diff --git a/fastlane/metadata/android/sv-SE/changelogs/836.txt b/fastlane/metadata/android/sv-SE/changelogs/836.txt new file mode 100644 index 000000000000..20cbf6958af5 --- /dev/null +++ b/fastlane/metadata/android/sv-SE/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- I blockredigeraren: Nya block för knapp och grupp, fler inställningar i bild- och galleriblock. +- Förbättringar av blockredigeraren: Rullist i blockväljare och blockinställningar, ny flytande verktygslist för enklare blocknavigering. +- Rättelser i blockredigeraren: Löst problem med platshållare i samband med bilduppladdning, användning av emoji i inläggsrubriker och radbrytning i kordkodsblock. +- Läsaren: Lagt till flikfiltrering för bättre navigaton mellan webbplatser och etiketter. + diff --git a/fastlane/metadata/android/tr-TR/changelogs/831.txt b/fastlane/metadata/android/tr-TR/changelogs/831.txt deleted file mode 100644 index 44f32619d603..000000000000 --- a/fastlane/metadata/android/tr-TR/changelogs/831.txt +++ /dev/null @@ -1,8 +0,0 @@ -14.2: -Blok düzenleyicide birçok güncelleme: - -* Önce / sonra blok eklemek için uzun basın simgesi eklendi. -* Uygulama, bağlantı kesildikten sonra tekrar çevrimiçi olduğunda görüntüleri göstermeye çalışacaktır. -* Başka bir uygulamadan resimler veya bağlantılar içeren bir yazı oluşturmaya çalışırken boş düzenleyici ile ilgili sorun çözüldü. -* Galeri bloğuna görüntü boyutu seçenekleri eklendi. -* Paragraf bloklarının birleştirilmesini engelleyen bir hata düzeltildi. diff --git a/fastlane/metadata/android/tr-TR/changelogs/836.txt b/fastlane/metadata/android/tr-TR/changelogs/836.txt new file mode 100644 index 000000000000..ace5269efe22 --- /dev/null +++ b/fastlane/metadata/android/tr-TR/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- Blok düzenleyici eklemeleri: Düğme ve Grup bloklarının yanı sıra, Görsel ve Galeri bloku ayarlarına daha fazla seçenek desteği eklendi. +- Blok düzenleyici geliştirmeleri: Blok seçici ve blok ayarlarına kaydırma desteği ve bloklarda gezinmeyi kolaylaştırmak için kayan bir araç çubuğu eklendi. +- Blok düzenleyici düzeltmeleri: Görsel karşıya yüklemesi sırasında yer tutucu görselleri, yazı başlığındaki emojiler ve Kısa Kod bloklarında yazı kaydırma ile ilgili sorunlar düzeltildi. +- Okuyucu: Daha iyi bir site/etiket gezintisi deneyimi için sekme filtreleme özelliği eklendi. + diff --git a/fastlane/metadata/android/zh-CN/changelogs/831.txt b/fastlane/metadata/android/zh-CN/changelogs/831.txt deleted file mode 100644 index 2f9b538d912a..000000000000 --- a/fastlane/metadata/android/zh-CN/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -对区块编辑器进行了许多更新: - -* 添加了用于在之前/之后添加区块的长按图标。 -* 断开连接然后重新连接后,应用程序会尝试显示图片。 -* 解决了尝试创建包含图片或其他应用程序链接的文章时出现的空白编辑器问题。 -* 在图库区块中添加了图片大小选项。 -* 修复了阻止段落块合并的错误。 - diff --git a/fastlane/metadata/android/zh-CN/changelogs/836.txt b/fastlane/metadata/android/zh-CN/changelogs/836.txt new file mode 100644 index 000000000000..a28cc3dd835d --- /dev/null +++ b/fastlane/metadata/android/zh-CN/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- 区块编辑器新增内容:添加了“按钮”和“组”区块,并且在“图片”和“图库”区块设置中支持更多选项。 +- 区块编辑器增强功能:在区块选择器和区块设置中添加了滚动支持,同时引入了浮动工具栏,使得区块间导航变得更加轻松。 +- 区块编辑器修复:修复了图片上传过程中的占位符图片相关问题、文章标题中的表情符号问题以及短代码区块中的文字环绕问题。 +- 阅读器:添加了选项卡过滤功能,以便在站点/标签间更方便地进行导航。 + diff --git a/fastlane/metadata/android/zh-TW/changelogs/831.txt b/fastlane/metadata/android/zh-TW/changelogs/831.txt deleted file mode 100644 index 5fe425878e75..000000000000 --- a/fastlane/metadata/android/zh-TW/changelogs/831.txt +++ /dev/null @@ -1,9 +0,0 @@ -14.2: -許多區塊編輯器更新︰ - -* 新增在之前/之後新增區塊的長按圖示。 -* 應用程式會嘗試在中斷連線又重新上線時顯示圖片。 -* 解決嘗試使用其他應用程式建立包含圖片或連結的文章時的空白編輯器問題。 -* 為「圖庫」區塊新增圖片大小選項。 -* 修正導致段落區塊無法合併的錯誤。 - diff --git a/fastlane/metadata/android/zh-TW/changelogs/836.txt b/fastlane/metadata/android/zh-TW/changelogs/836.txt new file mode 100644 index 000000000000..a5ace52f05a6 --- /dev/null +++ b/fastlane/metadata/android/zh-TW/changelogs/836.txt @@ -0,0 +1,6 @@ +14.3: +- 區塊編輯器新增功能:新增「按鈕」和「群組」區塊,並在「圖片」和「圖庫」區塊設定中支援更多選項。 +- 區塊編輯器增強功能:在區塊挑選器和區塊設定旁新增捲動功能支援,並推出讓區塊瀏覽更輕鬆的浮動工具列。 +- 區塊編輯器修正:修正圖片上傳時預留位置圖片的問題、文章標題的表情符號問題,以及短代碼區塊中的文繞圖問題。 +- 讀取器:新增分頁篩選功能,改善網站/標籤瀏覽體驗。 + diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java index e9b6acc72075..c499bf259ee8 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java @@ -47,7 +47,6 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; -import androidx.core.content.ContextCompat; import androidx.lifecycle.LiveData; import com.android.volley.toolbox.ImageLoader; @@ -284,14 +283,6 @@ public void afterTextChanged(Editable s) { mFormattingToolbar = (AztecToolbar) view.findViewById(R.id.formatting_toolbar); mFormattingToolbar.setExpanded(mIsToolbarExpanded); - View mediaCollapseButton = mFormattingToolbar.findViewById(R.id.format_bar_button_media_collapsed); - View mediaExpandButton = mFormattingToolbar.findViewById(R.id.format_bar_button_media_expanded); - - mediaCollapseButton.setBackgroundTintList(ContextCompat - .getColorStateList(mediaExpandButton.getContext(), R.color.media_button_background_tint_selector)); - mediaExpandButton.setBackgroundTintList(ContextCompat - .getColorStateList(mediaExpandButton.getContext(), R.color.media_button_background_tint_selector)); - mTitle.setOnFocusChangeListener( new View.OnFocusChangeListener() { @Override diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java index 0fbbfe482b6d..125d55ae5959 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergContainerFragment.java @@ -27,7 +27,6 @@ public class GutenbergContainerFragment extends Fragment { private static final String ARG_IS_NEW_POST = "param_is_new_post"; private static final String ARG_LOCALE = "param_locale"; private static final String ARG_TRANSLATIONS = "param_translations"; - private static final String ARG_PREFERRED_COLOR_SCHEME = "param_preferred_color_scheme"; private boolean mHtmlModeEnabled; private boolean mHasReceivedAnyContent; @@ -35,17 +34,13 @@ public class GutenbergContainerFragment extends Fragment { private WPAndroidGlueCode mWPAndroidGlueCode; public static GutenbergContainerFragment newInstance(String postType, - boolean isNewPost, - String localeString, - Bundle translations, - boolean isDarkMode) { + boolean isNewPost, String localeString, Bundle translations) { GutenbergContainerFragment fragment = new GutenbergContainerFragment(); Bundle args = new Bundle(); args.putString(ARG_POST_TYPE, postType); args.putBoolean(ARG_IS_NEW_POST, isNewPost); args.putString(ARG_LOCALE, localeString); args.putBundle(ARG_TRANSLATIONS, translations); - args.putBoolean(ARG_PREFERRED_COLOR_SCHEME, isDarkMode); fragment.setArguments(args); return fragment; } @@ -62,8 +57,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener RequestExecutor fetchExecutor, OnImageFullscreenPreviewListener onImageFullscreenPreviewListener, OnMediaEditorListener onMediaEditorListener, - OnLogGutenbergUserEventListener onLogGutenbergUserEventListener, - boolean isDarkMode) { + OnLogGutenbergUserEventListener onLogGutenbergUserEventListener) { mWPAndroidGlueCode.attachToContainer( viewGroup, onMediaLibraryButtonListener, @@ -74,8 +68,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener fetchExecutor, onImageFullscreenPreviewListener, onMediaEditorListener, - onLogGutenbergUserEventListener, - isDarkMode); + onLogGutenbergUserEventListener); } @Override @@ -86,7 +79,6 @@ public void onCreate(Bundle savedInstanceState) { boolean isNewPost = getArguments() != null && getArguments().getBoolean(ARG_IS_NEW_POST); String localeString = getArguments().getString(ARG_LOCALE); Bundle translations = getArguments().getBundle(ARG_TRANSLATIONS); - boolean isDarkMode = getArguments().getBoolean(ARG_PREFERRED_COLOR_SCHEME); mWPAndroidGlueCode = new WPAndroidGlueCode(); mWPAndroidGlueCode.onCreate(getContext()); @@ -99,9 +91,7 @@ public void onCreate(Bundle savedInstanceState) { postType, isNewPost, localeString, - translations, - getContext().getResources().getColor(R.color.background_color), - isDarkMode); + translations); // clear the content initialization flag since a new ReactRootView has been created; mHasReceivedAnyContent = false; diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergEditorFragment.java index 6e1e66fe1d42..441285b8a4b8 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/GutenbergEditorFragment.java @@ -222,11 +222,7 @@ public void onCreate(Bundle savedInstanceState) { FragmentManager fragmentManager = getChildFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); GutenbergContainerFragment gutenbergContainerFragment = - GutenbergContainerFragment.newInstance(postType, - isNewPost, - localeSlug, - getTranslations(), - isDarkMode()); + GutenbergContainerFragment.newInstance(postType, isNewPost, localeSlug, this.getTranslations()); gutenbergContainerFragment.setRetainInstance(true); fragmentTransaction.add(gutenbergContainerFragment, GutenbergContainerFragment.TAG); fragmentTransaction.commitNow(); @@ -385,7 +381,7 @@ public void onGutenbergUserEvent(GutenbergUserEvent event, Map p break; } } - }, isDarkMode()); + }); // request dependency injection. Do this after setting min/max dimensions if (getActivity() instanceof EditorFragmentActivity) { @@ -416,13 +412,6 @@ public void run() { return view; } - private boolean isDarkMode() { - Configuration configuration = getActivity().getResources().getConfiguration(); - int currentNightMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK; - - return currentNightMode == Configuration.UI_MODE_NIGHT_YES; - } - private ArrayList initOtherMediaImageOptions() { ArrayList otherMediaOptions = new ArrayList<>(); FragmentActivity activity = getActivity(); diff --git a/libs/editor/WordPressEditor/src/main/res/color/media_button_background_tint_selector.xml b/libs/editor/WordPressEditor/src/main/res/color/media_button_background_tint_selector.xml deleted file mode 100644 index 08afb26d2839..000000000000 --- a/libs/editor/WordPressEditor/src/main/res/color/media_button_background_tint_selector.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/libs/editor/WordPressEditor/src/main/res/drawable-anydpi-v21/img_hr.xml b/libs/editor/WordPressEditor/src/main/res/drawable-anydpi-v21/img_hr.xml deleted file mode 100644 index 15849a3537b1..000000000000 --- a/libs/editor/WordPressEditor/src/main/res/drawable-anydpi-v21/img_hr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/libs/editor/WordPressEditor/src/main/res/drawable/img_hr.xml b/libs/editor/WordPressEditor/src/main/res/drawable/img_hr.xml deleted file mode 100644 index 15849a3537b1..000000000000 --- a/libs/editor/WordPressEditor/src/main/res/drawable/img_hr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - diff --git a/libs/editor/WordPressEditor/src/main/res/layout/fragment_aztec_editor.xml b/libs/editor/WordPressEditor/src/main/res/layout/fragment_aztec_editor.xml index 28dd85e3bf12..b224a43dedde 100644 --- a/libs/editor/WordPressEditor/src/main/res/layout/fragment_aztec_editor.xml +++ b/libs/editor/WordPressEditor/src/main/res/layout/fragment_aztec_editor.xml @@ -2,23 +2,25 @@ + android:background="@android:color/white" + android:layout_height="match_parent" + android:layout_width="match_parent"> + aztec:mediaToolbarAvailable="true"> + + android:layout_height="wrap_content" + android:layout_width="match_parent" > + android:layout_height="wrap_content" + android:layout_width="match_parent" > + android:imeOptions="flagNoExtractUi" + android:lineSpacingExtra="@dimen/spacing_extra_title" + android:textColor="@color/grey_dark" + android:textColorHint="@color/hint_text"> + + android:layout_marginRight="@dimen/sourceview_side_margin" + style="@style/DividerSourceView"/> + android:layout_height="match_parent" + android:layout_width="match_parent" > + aztec:textColorHint="@color/hint_text" > + + android:fontFamily="monospace" + android:imeOptions="flagNoExtractUi" /> diff --git a/libs/editor/WordPressEditor/src/main/res/values-night/colors.xml b/libs/editor/WordPressEditor/src/main/res/values-night/colors.xml deleted file mode 100755 index b90fd56de515..000000000000 --- a/libs/editor/WordPressEditor/src/main/res/values-night/colors.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - #121212 - - diff --git a/libs/editor/WordPressEditor/src/main/res/values/colors.xml b/libs/editor/WordPressEditor/src/main/res/values/colors.xml index 8ad04d855fc8..5419d0b586e7 100755 --- a/libs/editor/WordPressEditor/src/main/res/values/colors.xml +++ b/libs/editor/WordPressEditor/src/main/res/values/colors.xml @@ -23,12 +23,6 @@ @color/wp_grey_lighten_30 @color/wp_grey_darken_30 - @color/grey_dark - #80000000 @color/black_translucent_50 - - - #f6f7f7 - diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index e288c45e882d..d377b883c761 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit e288c45e882db9808e0396715f379edb07f32416 +Subproject commit d377b883c761c2a71d29bd631f3d3227b3e313a2 diff --git a/libs/login/WordPressLoginFlow/build.gradle b/libs/login/WordPressLoginFlow/build.gradle index 2023cec713d6..41ddc07efb74 100644 --- a/libs/login/WordPressLoginFlow/build.gradle +++ b/libs/login/WordPressLoginFlow/build.gradle @@ -40,7 +40,7 @@ dependencies { implementation 'androidx.media:media:1.0.1' implementation 'androidx.legacy:legacy-support-v13:1.0.0' implementation 'androidx.gridlayout:gridlayout:1.0.0' - implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.android.material:material:1.0.0' api 'com.google.android.gms:play-services-auth:15.0.1' diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java index 96b2baab5a15..d68880dfae2a 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java @@ -7,6 +7,7 @@ import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.DigitsKeyListener; +import android.view.ContextThemeWrapper; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -20,8 +21,6 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.AlertDialog; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.wordpress.android.fluxc.generated.AccountActionBuilder; @@ -45,10 +44,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import static android.content.Context.CLIPBOARD_SERVICE; - import dagger.android.support.AndroidSupportInjection; +import static android.content.Context.CLIPBOARD_SERVICE; + public class Login2FaFragment extends LoginBaseFormFragment implements TextWatcher, OnEditorCommitListener { private static final String KEY_2FA_TYPE = "KEY_2FA_TYPE"; @@ -397,7 +396,7 @@ private void handleAuthError(AuthenticationErrorType error, String errorMessage) } private void showErrorDialog(String message) { - AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity()) + AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)) .setMessage(message) .setPositiveButton(R.string.login_error_button, null) .create(); diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java index 8a74bbb3059a..400c5fb1d15a 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java @@ -10,6 +10,7 @@ import android.text.Html; import android.text.TextWatcher; import android.util.Patterns; +import android.view.ContextThemeWrapper; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -32,7 +33,6 @@ import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks; import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -383,7 +383,7 @@ private void showEmailError(int messageId) { } private void showErrorDialog(String message) { - AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity()) + AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)) .setMessage(message) .setPositiveButton(R.string.login_error_button, null) .create(); diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java index b006931af0cd..66b1151b9ddf 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java @@ -7,6 +7,7 @@ import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; +import android.view.ContextThemeWrapper; import android.view.KeyEvent; import android.view.View; import android.widget.EditText; @@ -17,8 +18,6 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.util.EditTextUtils; public class LoginHttpAuthDialogFragment extends DialogFragment { @@ -50,7 +49,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder alert = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder alert = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)); alert.setTitle(R.string.http_authorization_required); //noinspection InflateParams diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkRequestFragment.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkRequestFragment.java index fd554f055455..7d56878202e1 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkRequestFragment.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkRequestFragment.java @@ -54,6 +54,7 @@ public class LoginMagicLinkRequestFragment extends Fragment { public static final String TAG = "login_magic_link_request_fragment_tag"; private static final String KEY_IN_PROGRESS = "KEY_IN_PROGRESS"; + private static final String KEY_GRAVATAR_IN_PROGRESS = "KEY_GRAVATAR_IN_PROGRESS"; private static final String ARG_EMAIL_ADDRESS = "ARG_EMAIL_ADDRESS"; private static final String ARG_MAGIC_LINK_SCHEME = "ARG_MAGIC_LINK_SCHEME"; private static final String ARG_IS_JETPACK_CONNECT = "ARG_IS_JETPACK_CONNECT"; @@ -223,6 +224,9 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { if (mInProgress) { showMagicLinkRequestProgressDialog(); } + + boolean gravatarInProgress = savedInstanceState.getBoolean(KEY_GRAVATAR_IN_PROGRESS); + mAvatarProgressBar.setVisibility(gravatarInProgress ? View.VISIBLE : View.GONE); } // important for accessibility - talkback getActivity().setTitle(R.string.magic_link_login_title); @@ -239,6 +243,7 @@ public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(KEY_IN_PROGRESS, mInProgress); + outState.putBoolean(KEY_GRAVATAR_IN_PROGRESS, mAvatarProgressBar.getVisibility() == View.VISIBLE); } @Override diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressHelpDialogFragment.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressHelpDialogFragment.java index c9a36a95d887..98722cbaf0a2 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressHelpDialogFragment.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressHelpDialogFragment.java @@ -4,13 +4,12 @@ import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextThemeWrapper; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.fluxc.store.SiteStore; @@ -47,7 +46,7 @@ public void onAttach(Context context) { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder alert = new MaterialAlertDialogBuilder(getActivity()); + AlertDialog.Builder alert = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)); alert.setTitle(R.string.login_site_address_help_title); //noinspection InflateParams diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupEmailFragment.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupEmailFragment.java index a492701f015b..ce49fd618c13 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupEmailFragment.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupEmailFragment.java @@ -8,6 +8,7 @@ import android.text.Editable; import android.text.TextWatcher; import android.util.Patterns; +import android.view.ContextThemeWrapper; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -28,7 +29,6 @@ import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks; import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -232,7 +232,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) { } protected void showErrorDialog(String message) { - AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity()) + AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)) .setMessage(message) .setPositiveButton(R.string.login_error_button, null) .create(); diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupMagicLinkFragment.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupMagicLinkFragment.java index 910cd28db95c..b8305d18db50 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupMagicLinkFragment.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupMagicLinkFragment.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -19,8 +20,6 @@ import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; -import com.google.android.material.dialog.MaterialAlertDialogBuilder; - import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.wordpress.android.fluxc.Dispatcher; @@ -232,7 +231,7 @@ public void onClick(DialogInterface dialog, int which) { } }; - AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity()) + AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.LoginTheme)) .setMessage(message) .setNegativeButton(R.string.signup_magic_link_error_button_negative, dialogListener) .setPositiveButton(R.string.signup_magic_link_error_button_positive, dialogListener) diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPBottomSheetDialogFragment.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPBottomSheetDialogFragment.java index bf25fcf95bb7..7bab90d22348 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPBottomSheetDialogFragment.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPBottomSheetDialogFragment.java @@ -16,6 +16,11 @@ import org.wordpress.android.login.R; public class WPBottomSheetDialogFragment extends BottomSheetDialogFragment { + @Override + public int getTheme() { + return R.style.LoginTheme_BottomSheetDialogStyle; + } + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPLoginInputRow.java b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPLoginInputRow.java index c17d99bb5280..1cb90f8b2f83 100644 --- a/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPLoginInputRow.java +++ b/libs/login/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPLoginInputRow.java @@ -1,7 +1,10 @@ package org.wordpress.android.login.widgets; import android.content.Context; +import android.content.res.ColorStateList; import android.content.res.TypedArray; +import android.graphics.PorterDuff; +import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; import android.os.Parcel; @@ -10,12 +13,16 @@ import android.util.AttributeSet; import android.util.SparseArray; import android.view.KeyEvent; +import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.EditText; +import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; import com.google.android.material.textfield.TextInputLayout; @@ -31,9 +38,14 @@ public interface OnEditorCommitListener { void onEditorCommit(); } + private ImageView mIcon; private TextInputLayout mTextInputLayout; private EditText mEditText; + public ImageView getIcon() { + return mIcon; + } + public EditText getEditText() { return mEditText; } @@ -56,6 +68,7 @@ public WPLoginInputRow(Context context, AttributeSet attrs, int defStyle) { private void init(Context context, AttributeSet attrs) { inflate(context, R.layout.login_input_row, this); + mIcon = findViewById(R.id.icon); mTextInputLayout = findViewById(R.id.input_layout); mEditText = findViewById(R.id.input); @@ -63,6 +76,27 @@ private void init(Context context, AttributeSet attrs) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.wpLoginInputRow, 0, 0); try { + if (a.hasValue(R.styleable.wpLoginInputRow_wpIconDrawable)) { + int iconResId = a.getResourceId(R.styleable.wpLoginInputRow_wpIconDrawable, + R.drawable.ic_user_grey_24dp); + int tintResId = a.getResourceId(R.styleable.wpLoginInputRow_wpIconDrawableTint, + R.color.login_input_icon_color); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + mIcon.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(context, tintResId))); + mIcon.setImageResource(iconResId); + } else { + Drawable drawable = context.getResources().getDrawable(iconResId); + DrawableCompat.setTint(drawable, context.getResources().getColor(tintResId)); + DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN); + mIcon.setImageDrawable(drawable); + } + + mIcon.setVisibility(View.VISIBLE); + } else { + mIcon.setVisibility(View.GONE); + } + if (a.hasValue(R.styleable.wpLoginInputRow_android_inputType)) { mEditText.setInputType(a.getInteger(R.styleable.wpLoginInputRow_android_inputType, 0)); } @@ -78,11 +112,16 @@ private void init(Context context, AttributeSet attrs) { // Makes the hint transparent, so the TalkBack can read it, when the field is prefilled mEditText.setHintTextColor(getResources().getColor(android.R.color.transparent)); } + if (a.hasValue(R.styleable.wpLoginInputRow_passwordToggleEnabled)) { mTextInputLayout.setPasswordVisibilityToggleEnabled( a.getBoolean(R.styleable.wpLoginInputRow_passwordToggleEnabled, false)); } + if (a.hasValue(R.styleable.wpLoginInputRow_passwordToggleTint)) { + mTextInputLayout.setPasswordVisibilityToggleTintList( + a.getColorStateList(R.styleable.wpLoginInputRow_passwordToggleTint)); + } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (a.hasValue(R.styleable.wpLoginInputRow_android_textAlignment)) { mEditText.setTextAlignment( @@ -145,8 +184,8 @@ public void setOnEditorCommitListener(final OnEditorCommitListener listener) { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE - || actionId == EditorInfo.IME_ACTION_NEXT - || (event != null + || actionId == EditorInfo.IME_ACTION_NEXT + || (event != null && event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) { listener.onEditorCommit(); diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_request_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_request_screen.xml index 29877bd2aff7..060cdce64517 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_request_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_request_screen.xml @@ -1,9 +1,11 @@ + android:layout_height="match_parent" + xmlns:tools="http://schemas.android.com/tools"> - + + android:layout_height="wrap_content"/> + android:indeterminate="true"/> - + android:text="@string/login_magic_links_label"/> - + android:background="@color/login_background_color" + android:paddingStart="@dimen/margin_small_medium" + android:paddingEnd="@dimen/margin_medium_large" + android:paddingTop="@dimen/margin_medium_large" + android:paddingBottom="@dimen/margin_medium_large" + android:layout_alignParentBottom="true" + android:clipToPadding="false" + tools:ignore="InconsistentLayout"> - - - + android:layout_marginEnd="@dimen/margin_extra_large" + android:gravity="start|center_vertical" + android:text="@string/enter_your_password_instead"/> - - - + + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_sent_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_sent_screen.xml index 1933c757144f..7cf5f68af62b 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_sent_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_sent_screen.xml @@ -1,77 +1,73 @@ + android:layout_height="match_parent" + xmlns:tools="http://schemas.android.com/tools"> - + + android:layout_centerInParent="true" + android:orientation="vertical" + android:gravity="center_horizontal"> + android:contentDescription="@null" + app:srcCompat="@drawable/login_email_alert"/> - + android:text="@string/login_magic_links_sent_label"/> - + android:background="@color/login_background_color" + android:paddingStart="@dimen/margin_small_medium" + android:paddingEnd="@dimen/margin_medium_large" + android:paddingTop="@dimen/margin_medium_large" + android:paddingBottom="@dimen/margin_medium_large" + android:layout_alignParentBottom="true" + android:clipToPadding="false" + tools:ignore="InconsistentLayout"> - - - + android:layout_marginEnd="@dimen/margin_extra_large" + android:gravity="start|center_vertical" + android:text="@string/enter_your_password_instead"/> - - - - + + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout-land/signup_bottom_sheet_dialog.xml b/libs/login/WordPressLoginFlow/src/main/res/layout-land/signup_bottom_sheet_dialog.xml index a05807f5a9f8..0f5a6453734b 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout-land/signup_bottom_sheet_dialog.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout-land/signup_bottom_sheet_dialog.xml @@ -1,50 +1,55 @@ - + android:paddingTop="@dimen/margin_medium" > - + android:text="@string/signup_terms_of_service_text" + style="@style/LoginTheme.Button.Secondary" > + + android:layout_marginTop="@dimen/margin_extra_small" + android:layout_width="match_parent" + android:orientation="horizontal" > - + android:layout_width="wrap_content" + android:text="@string/signup_with_email_button" + android:theme="@style/LoginTheme.Button" > + - + android:layout_width="wrap_content" + android:text="@string/signup_with_google_button" + android:theme="@style/LoginTheme.Button" > + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout-land/signup_magic_link.xml b/libs/login/WordPressLoginFlow/src/main/res/layout-land/signup_magic_link.xml index 290d3e3f0262..1917679299a3 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout-land/signup_magic_link.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout-land/signup_magic_link.xml @@ -1,68 +1,71 @@ - + android:layout_height="match_parent" + xmlns:tools="http://schemas.android.com/tools"> - + + + android:layout_width="match_parent" + android:orientation="vertical" > + app:srcCompat="@drawable/login_email_alert" > + + android:paddingStart="@dimen/margin_extra_extra_large" + android:paddingTop="@dimen/margin_extra_large" + android:text="@string/signup_magic_link_message" + style="@style/Base.TextAppearance.AppCompat.Body1" > + - + android:layout_width="match_parent" + android:paddingBottom="@dimen/margin_medium_large" + android:paddingEnd="@dimen/margin_medium_large" + android:paddingStart="@dimen/margin_small_medium" + android:paddingTop="@dimen/margin_medium_large" + tools:ignore="InconsistentLayout"> - + android:layout_width="wrap_content" + android:text="@string/open_mail" + style="@style/LoginTheme.Button.Primary" > + - + - - diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_2fa_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_2fa_screen.xml index de326ff78418..9d32b8352b43 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_2fa_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_2fa_screen.xml @@ -9,7 +9,7 @@ android:paddingEnd="@dimen/margin_extra_large" android:layout_marginBottom="@dimen/margin_extra_large"> - + android:layout_height="wrap_content"> + android:singleLine="true" + android:hint="@string/httpuser"/> + app:passwordToggleTint="@color/login_input_password_icon_color"> + android:inputType="textPassword" + android:hint="@string/httppassword"/> diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_alert_site_address_help.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_alert_site_address_help.xml index 2ab69b3277c3..933c2ea8f74e 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_alert_site_address_help.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_alert_site_address_help.xml @@ -3,24 +3,24 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:gravity="top" android:orientation="vertical" + android:gravity="top" android:padding="?attr/dialogPreferredPadding"> - + android:text="@string/login_site_address_help_content"/> + android:contentDescription="@null"/> diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_email_password_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_email_password_screen.xml index 8053752cf6e6..ad8b4987b601 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_email_password_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_email_password_screen.xml @@ -1,25 +1,25 @@ + android:layout_marginBottom="@dimen/margin_extra_large"> - + android:tint="@color/login_input_icon_color" + app:srcCompat="@drawable/ic_user_grey_24dp"/> + android:focusable="true"> - + android:text="@string/email_address"/> - + android:gravity="start" + tools:text="s@b.com"/> @@ -69,12 +69,15 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin_extra_large" android:layout_marginBottom="@dimen/margin_extra_extra_large" - android:gravity="start" android:hint="@string/password" android:importantForAutofill="noExcludeDescendants" android:inputType="textPassword" android:textAlignment="viewStart" + android:gravity="start" app:passwordToggleEnabled="true" - tools:ignore="UnusedAttribute" /> + app:passwordToggleTint="@color/login_input_password_icon_color" + app:wpIconDrawable="@drawable/ic_lock_grey_24dp" + tools:ignore="UnusedAttribute" > + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_email_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_email_screen.xml index 53e8e3050019..30dbc62535d1 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_email_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_email_screen.xml @@ -1,108 +1,116 @@ - + android:paddingEnd="@dimen/margin_extra_large" + android:paddingStart="@dimen/margin_extra_large" > - + android:gravity="start" + tools:text="@string/enter_email_wordpress_com" + style="@style/LoginTheme.TextLabel" > + + android:gravity="start" + tools:ignore="UnusedAttribute" > + - + android:layout_marginTop="@dimen/margin_extra_large" + android:layout_width="wrap_content" + android:text="@string/alternatively" + style="@style/LoginTheme.TextLabel" > + + android:paddingEnd="@dimen/margin_medium" + android:paddingTop="@dimen/margin_medium" + android:gravity="center_vertical" + tools:ignore="RtlSymmetry" > + android:layout_width="@dimen/google_button_icon_sz" + app:srcCompat="@drawable/ic_google_60dp" > + - + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:text="@string/login_google_button_suffix" + style="@style/LoginTheme.Button.Google" > + + android:paddingEnd="@dimen/margin_medium" + android:paddingTop="@dimen/margin_medium" + android:gravity="center_vertical" + tools:ignore="RtlSymmetry" > + android:layout_width="@dimen/google_button_icon_sz" + app:srcCompat="@drawable/ic_domains_grey_24dp" > + - + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:text="@string/enter_site_address_instead" + style="@style/LoginTheme.Button.Google" > + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_form_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_form_screen.xml index 0621b1cc49cb..4ed2340b3d47 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_form_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_form_screen.xml @@ -5,64 +5,58 @@ android:layout_height="match_parent"> + android:layout_below="@+id/toolbar" + android:layout_above="@+id/bottom_buttons"> + android:layout_marginBottom="@dimen/margin_extra_large"/> - - - - + + - - - - - - + android:layout_marginEnd="@dimen/margin_extra_large" + android:textAlignment="viewStart" + android:gravity="start|center_vertical" + tools:text="Secondary action"/> + + + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_input_row.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_input_row.xml index d39dcbb868ea..eb238712df35 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_input_row.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_input_row.xml @@ -1,24 +1,40 @@ - + + - + android:layout_marginEnd="@dimen/textinputlayout_correction_margin_right" + android:paddingEnd="@dimen/textinputlayout_correction_padding_right" + tools:hint="@string/email_address"/> + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_magic_link_request_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_magic_link_request_screen.xml index ce7ae44a4c24..5b87de6b8936 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_magic_link_request_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_magic_link_request_screen.xml @@ -1,13 +1,16 @@ - + android:layout_height="match_parent"> - + + android:layout_marginBottom="@dimen/margin_extra_large" + android:layout_marginTop="@dimen/margin_extra_extra_large"> + android:layout_height="wrap_content"/> + android:padding="@dimen/margin_large"/> - + android:text="@string/login_magic_links_label"/> - + android:theme="@style/LoginTheme.Button"/> - + android:paddingStart="@dimen/margin_medium_large" + android:text="@string/enter_your_password_instead"/> - + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_magic_link_sent_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_magic_link_sent_screen.xml index 53f833f75bb3..4b97edaf36e0 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_magic_link_sent_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_magic_link_sent_screen.xml @@ -1,44 +1,53 @@ - + android:layout_height="match_parent"> - + + app:srcCompat="@drawable/login_email_alert"/> - + android:text="@string/login_magic_links_sent_label"/> - - - + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_site_address_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_site_address_screen.xml index 596cd8e6f07c..305760d03a13 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_site_address_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_site_address_screen.xml @@ -1,33 +1,35 @@ + android:layout_marginBottom="@dimen/margin_extra_large"> - + android:imeOptions="actionNext" + android:textAlignment="viewStart" + android:gravity="start" + app:wpIconDrawable="@drawable/ic_globe_grey_24dp"/> diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/login_username_password_screen.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/login_username_password_screen.xml index f2b142305cca..d1829689dfb1 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/login_username_password_screen.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/login_username_password_screen.xml @@ -1,34 +1,34 @@ + android:layout_marginBottom="@dimen/margin_extra_large"> - @@ -61,40 +61,40 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="@dimen/margin_extra_large" - android:focusable="true" - android:orientation="vertical"> + android:orientation="vertical" + android:focusable="true"> - + tools:visibility="visible" + android:textAlignment="viewStart" + android:gravity="start"/> - + android:gravity="start" + tools:text="Arround the World with Pam"/> - + android:gravity="start" + tools:text="pamelanguyyen.wordpress.com"/> @@ -102,11 +102,12 @@ android:id="@+id/login_username_row" android:layout_width="match_parent" android:layout_height="wrap_content" - android:gravity="start" android:hint="@string/username" - android:imeOptions="actionNext" android:inputType="textPersonName" - android:textAlignment="viewStart" /> + android:imeOptions="actionNext" + android:textAlignment="viewStart" + android:gravity="start" + app:wpIconDrawable="@drawable/ic_user_grey_24dp"/> + app:passwordToggleTint="@color/login_input_password_icon_color" + android:textAlignment="viewStart" + android:gravity="start" + android:accessibilityLiveRegion="assertive" + app:wpIconDrawable="@drawable/ic_lock_grey_24dp" + tools:ignore="UnusedAttribute"/> diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/signup_bottom_sheet_dialog.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/signup_bottom_sheet_dialog.xml index 87605487db46..f0408261cdd7 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/signup_bottom_sheet_dialog.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/signup_bottom_sheet_dialog.xml @@ -1,41 +1,46 @@ - + android:paddingTop="@dimen/margin_medium" > - + android:text="@string/signup_terms_of_service_text" + style="@style/LoginTheme.Button.Secondary" > + - + android:layout_marginTop="@dimen/margin_extra_small" + android:layout_width="match_parent" + android:text="@string/signup_with_email_button" + android:theme="@style/LoginTheme.Button" > + - + android:layout_width="match_parent" + android:text="@string/signup_with_google_button" + android:theme="@style/LoginTheme.Button" > + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/signup_email_fragment.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/signup_email_fragment.xml index 50061cf17ecd..6a5d3110628f 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/signup_email_fragment.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/signup_email_fragment.xml @@ -1,34 +1,38 @@ - + android:paddingLeft="@dimen/margin_extra_large" + android:paddingRight="@dimen/margin_extra_large" + android:paddingStart="@dimen/margin_extra_large" > - + android:layout_marginTop="@dimen/margin_extra_large" + android:layout_width="match_parent" + tools:text="@string/signup_email_header" + style="@style/LoginTheme.TextLabel" > + + android:layout_height="wrap_content" + android:layout_width="match_parent" + app:wpIconDrawable="@drawable/ic_user_grey_24dp" + tools:ignore="UnusedAttribute" > + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/signup_magic_link.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/signup_magic_link.xml index 92e11f33799a..e4c2e65c448e 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/signup_magic_link.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/signup_magic_link.xml @@ -1,50 +1,58 @@ - + android:layout_width="match_parent" > - + + + android:layout_width="match_parent" > + app:srcCompat="@drawable/login_email_alert" > + + android:paddingStart="@dimen/margin_extra_extra_large" + android:paddingTop="@dimen/margin_extra_large" + android:text="@string/signup_magic_link_message" + style="@style/Base.TextAppearance.AppCompat.Body1" > + - + android:layout_width="wrap_content" + android:text="@string/open_mail" + android:theme="@style/LoginTheme.Button" + style="@style/Widget.AppCompat.Button.Colored" > + - + diff --git a/libs/login/WordPressLoginFlow/src/main/res/layout/toolbar_login.xml b/libs/login/WordPressLoginFlow/src/main/res/layout/toolbar_login.xml index 695c90671df0..bac5435ba1ba 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/layout/toolbar_login.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/layout/toolbar_login.xml @@ -1,23 +1,24 @@ - + android:layout_height="?attr/actionBarSize" + android:background="@color/login_toolbar_color" + android:elevation="@dimen/appbar_elevation" + app:contentInsetLeft="@dimen/toolbar_content_offset" + app:contentInsetStart="@dimen/toolbar_content_offset" + app:contentInsetRight="@dimen/toolbar_content_offset_end" + app:contentInsetEnd="@dimen/toolbar_content_offset_end" + app:theme="@style/LoginTheme.Toolbar" + tools:targetApi="LOLLIPOP"> - - - - - - - + + diff --git a/libs/login/WordPressLoginFlow/src/main/res/values/attrs.xml b/libs/login/WordPressLoginFlow/src/main/res/values/attrs.xml index 3f5b74b856cd..3914e5cd5ec7 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/values/attrs.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/values/attrs.xml @@ -5,10 +5,13 @@ WPLoginInputRow --> + + + diff --git a/libs/login/WordPressLoginFlow/src/main/res/values/styles.xml b/libs/login/WordPressLoginFlow/src/main/res/values/styles.xml index 31b6b44225c5..c35b06ba84aa 100644 --- a/libs/login/WordPressLoginFlow/src/main/res/values/styles.xml +++ b/libs/login/WordPressLoginFlow/src/main/res/values/styles.xml @@ -1,65 +1,47 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/AppLog.java b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/AppLog.java index 577f5f7ab216..b929a68f4e9e 100644 --- a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/AppLog.java +++ b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/AppLog.java @@ -201,6 +201,22 @@ public static void e(T tag, String volleyErrorMsg, int statusCode) { public enum LogLevel { v, d, i, w, e; + + private String toHtmlColor() { + switch (this) { + case v: + return "grey"; + case i: + return "black"; + case w: + return "purple"; + case e: + return "red"; + case d: + default: + return "teal"; + } + } } private static class LogEntry { @@ -228,12 +244,16 @@ private String formatLogDate() { private String toHtml() { StringBuilder sb = new StringBuilder(); + sb.append(""); sb.append("["); sb.append(formatLogDate()).append(" "); sb.append(mLogTag.name()).append(" "); sb.append(mLogLevel.name()); sb.append("] "); sb.append(TextUtils.htmlEncode(mLogText).replace("\n", "
")); + sb.append("
"); return sb.toString(); } } diff --git a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/SwipeToRefreshHelper.java b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/SwipeToRefreshHelper.java index 14cc5efef9a8..4f65d9891ab3 100644 --- a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/SwipeToRefreshHelper.java +++ b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/helpers/SwipeToRefreshHelper.java @@ -2,9 +2,7 @@ import android.content.Context; -import androidx.annotation.ColorInt; import androidx.annotation.ColorRes; -import androidx.core.content.ContextCompat; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener; @@ -29,13 +27,12 @@ public interface RefreshListener { * @param listener {@link RefreshListener} notified when a refresh is triggered * via the swipe gesture. * - * @deprecated Use {@link #SwipeToRefreshHelper(CustomSwipeRefreshLayout, RefreshListener, int, int...)} instead. + * @deprecated Use {@link #SwipeToRefreshHelper(CustomSwipeRefreshLayout, RefreshListener, int...)} instead. */ @Deprecated public SwipeToRefreshHelper(Context context, CustomSwipeRefreshLayout swipeRefreshLayout, RefreshListener listener) { - init(swipeRefreshLayout, listener, ContextCompat.getColor(context, android.R.color.white), - android.R.color.holo_blue_dark); + init(swipeRefreshLayout, listener, android.R.color.holo_blue_dark); } /** @@ -46,14 +43,13 @@ public SwipeToRefreshHelper(Context context, CustomSwipeRefreshLayout swipeRefre * of a view via a vertical swipe gesture. * @param listener {@link RefreshListener} notified when a refresh is triggered * via the swipe gesture. - * @param progressAnimationColors Comma-separated color resource integers used in the progress + * @param colorResIds Comma-separated color resource integers used in the progress * animation. The first color will also be the color of the bar * that grows in response to a user swipe gesture. */ public SwipeToRefreshHelper(CustomSwipeRefreshLayout swipeRefreshLayout, RefreshListener listener, - @ColorInt int backgroundColor, - @ColorRes int... progressAnimationColors) { - init(swipeRefreshLayout, listener, backgroundColor, progressAnimationColors); + @ColorRes int... colorResIds) { + init(swipeRefreshLayout, listener, colorResIds); } /** @@ -64,18 +60,16 @@ public SwipeToRefreshHelper(CustomSwipeRefreshLayout swipeRefreshLayout, Refresh * of a view via a vertical swipe gesture. * @param listener {@link RefreshListener} notified when a refresh is triggered * via the swipe gesture. - * @param progressAnimationColors Comma-separated color resource integers used in the progress + * @param colorResIds Comma-separated color resource integers used in the progress * animation. The first color will also be the color of the bar * that grows in response to a user swipe gesture. */ public void init(CustomSwipeRefreshLayout swipeRefreshLayout, RefreshListener listener, - @ColorInt int backgroundColor, - @ColorRes int... progressAnimationColors) { + @ColorRes int... colorResIds) { mRefreshListener = listener; mSwipeRefreshLayout = swipeRefreshLayout; mSwipeRefreshLayout.setOnRefreshListener(this); - mSwipeRefreshLayout.setProgressBackgroundColorSchemeColor(backgroundColor); - mSwipeRefreshLayout.setColorSchemeResources(progressAnimationColors); + mSwipeRefreshLayout.setColorSchemeResources(colorResIds); } public void setRefreshing(boolean refreshing) {