From 3d037d682b914b81563c97155fce5a6a4a416e6c Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Sun, 6 Oct 2019 20:56:17 -0700 Subject: [PATCH 001/761] Added dark mode preference and resources. --- WordPress/src/main/res/values-v28/strings.xml | 4 ++++ WordPress/src/main/res/values/key_strings.xml | 1 + WordPress/src/main/res/values/strings.xml | 15 +++++++++++++++ WordPress/src/main/res/xml/app_settings.xml | 10 ++++++++++ 4 files changed, 30 insertions(+) create mode 100644 WordPress/src/main/res/values-v28/strings.xml diff --git a/WordPress/src/main/res/values-v28/strings.xml b/WordPress/src/main/res/values-v28/strings.xml new file mode 100644 index 000000000000..2dcf209b86b3 --- /dev/null +++ b/WordPress/src/main/res/values-v28/strings.xml @@ -0,0 +1,4 @@ + + + System default + diff --git a/WordPress/src/main/res/values/key_strings.xml b/WordPress/src/main/res/values/key_strings.xml index 27a01ba832ad..60d3d2f86c80 100644 --- a/WordPress/src/main/res/values/key_strings.xml +++ b/WordPress/src/main/res/values/key_strings.xml @@ -19,6 +19,7 @@ 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/strings.xml b/WordPress/src/main/res/values/strings.xml index 74d528cf8150..de510411b473 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -811,6 +811,21 @@ 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 + App Theme + Chose theme + Light + Dark + Set by Battery Saver + + @string/app_theme_light + @string/app_theme_dark + @string/app_theme_default + + + light + dark + default + Stats diff --git a/WordPress/src/main/res/xml/app_settings.xml b/WordPress/src/main/res/xml/app_settings.xml index 575c606381b5..b3ae35e99385 100644 --- a/WordPress/src/main/res/xml/app_settings.xml +++ b/WordPress/src/main/res/xml/app_settings.xml @@ -10,6 +10,16 @@ android:layout="@layout/wp_preference_layout" android:title="@string/interface_language"/> + + Date: Mon, 7 Oct 2019 12:35:51 -0700 Subject: [PATCH 002/761] Updated material theme dependency and related changes. --- WordPress/build.gradle | 2 +- .../android/ui/CommentFullScreenDialogFragment.kt | 2 +- .../ui/activitylog/detail/ActivityLogDetailFragment.kt | 2 +- .../ui/activitylog/list/ActivityLogListFragment.kt | 2 +- .../ui/domains/DomainRegistrationDetailsFragment.kt | 8 ++++---- .../java/org/wordpress/android/ui/pages/PagesFragment.kt | 2 +- .../org/wordpress/android/ui/posts/BasicFragmentDialog.kt | 4 ++-- .../android/ui/posts/PostDatePickerDialogFragment.kt | 2 +- .../posts/PostNotificationScheduleTimeDialogFragment.kt | 2 +- .../android/ui/posts/PostTimePickerDialogFragment.kt | 2 +- .../sitecreation/domains/SiteCreationDomainsFragment.kt | 2 +- .../sitecreation/previews/SiteCreationPreviewFragment.kt | 2 +- .../sitecreation/segments/SiteCreationSegmentsFragment.kt | 2 +- .../sitecreation/siteinfo/SiteCreationSiteInfoFragment.kt | 2 +- .../verticals/SiteCreationVerticalsFragment.kt | 2 +- .../insights/management/InsightsManagementFragment.kt | 4 ++-- .../StatsWidgetColorSelectionDialogFragment.kt | 2 +- .../widget/configuration/StatsWidgetConfigureFragment.kt | 8 ++++---- .../StatsWidgetDataTypeSelectionDialogFragment.kt | 2 +- .../StatsWidgetSiteSelectionDialogFragment.kt | 6 +++--- .../minified/StatsMinifiedWidgetConfigureFragment.kt | 8 ++++---- 21 files changed, 34 insertions(+), 34 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 51e70ec94a9f..6f4f27e5bcd5 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -165,7 +165,7 @@ dependencies { 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.0.0' + implementation 'com.google.android.material:material:1.1.0-beta01' 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/src/main/java/org/wordpress/android/ui/CommentFullScreenDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/CommentFullScreenDialogFragment.kt index fa701f81d6b0..932b9575ba10 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/CommentFullScreenDialogFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/CommentFullScreenDialogFragment.kt @@ -82,7 +82,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/activitylog/detail/ActivityLogDetailFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/detail/ActivityLogDetailFragment.kt index dcad242107cc..c675aa161e75 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(fragmentManager, it) + dialog.show(requireFragmentManager(), 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 dc8871e6d061..aff8ae26de14 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(fragmentManager, it) + dialog.show(requireFragmentManager(), it) } } 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 e4818d7a4989..47c1c947caf9 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 @@ -336,13 +336,13 @@ class DomainRegistrationDetailsFragment : Fragment() { private fun showStatePicker(states: List) { val dialogFragment = StatePickerDialogFragment.newInstance(states.toCollection(ArrayList())) dialogFragment.setTargetFragment(this, 0) - dialogFragment.show(fragmentManager, StatePickerDialogFragment.TAG) + dialogFragment.show(requireFragmentManager(), StatePickerDialogFragment.TAG) } private fun showCountryPicker(countries: List) { val dialogFragment = CountryPickerDialogFragment.newInstance(countries.toCollection(ArrayList())) dialogFragment.setTargetFragment(this, 0) - dialogFragment.show(fragmentManager, CountryPickerDialogFragment.TAG) + dialogFragment.show(requireFragmentManager(), CountryPickerDialogFragment.TAG) } private fun toggleFormProgressIndictor(visible: Boolean) { @@ -436,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) } @@ -486,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/pages/PagesFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/pages/PagesFragment.kt index 5daddb41d41e..d049b966d344 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 @@ -416,7 +416,7 @@ class PagesFragment : Fragment() { getString(R.string.delete), getString(R.string.cancel) ) - dialog.show(fragmentManager, page.id.toString()) + dialog.show(requireFragmentManager(), page.id.toString()) } override fun onStart() { 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 4d074c6b21f7..3ebe155832db 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 @@ -113,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") @@ -123,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/PostDatePickerDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostDatePickerDialogFragment.kt index f96ff69cbab4..d16192866323 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 @@ -51,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/PostNotificationScheduleTimeDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostNotificationScheduleTimeDialogFragment.kt index 7fbca3991d55..b415cf0cc838 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/PostTimePickerDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostTimePickerDialogFragment.kt index d52f9c82cf48..5a2ceeafd2b1 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 @@ -35,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/sitecreation/domains/SiteCreationDomainsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsFragment.kt index 454814b22a20..6ede15119ff9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsFragment.kt @@ -40,7 +40,7 @@ class SiteCreationDomainsFragment : SiteCreationBaseFormFragment() { @Inject internal lateinit var viewModelFactory: ViewModelProvider.Factory @Inject internal lateinit var uiHelpers: UiHelpers - override fun onAttach(context: Context?) { + override fun onAttach(context: Context) { super.onAttach(context) if (context !is DomainsScreenListener) { throw IllegalStateException("Parent activity must implement DomainsScreenListener.") diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/previews/SiteCreationPreviewFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/previews/SiteCreationPreviewFragment.kt index bc4c10043597..6b3b286bf5d2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/previews/SiteCreationPreviewFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/previews/SiteCreationPreviewFragment.kt @@ -72,7 +72,7 @@ class SiteCreationPreviewFragment : SiteCreationBaseFormFragment(), private var okButtonContainer: View? = null - override fun onAttach(context: Context?) { + override fun onAttach(context: Context) { super.onAttach(context) if (context !is SitePreviewScreenListener) { throw IllegalStateException("Parent activity must implement SitePreviewScreenListener.") diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/segments/SiteCreationSegmentsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/segments/SiteCreationSegmentsFragment.kt index 0c9fe77aa9fc..0110138161f8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/segments/SiteCreationSegmentsFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/segments/SiteCreationSegmentsFragment.kt @@ -42,7 +42,7 @@ class SiteCreationSegmentsFragment : SiteCreationBaseFormFragment() { private lateinit var helpClickedListener: OnHelpClickedListener private lateinit var segmentsScreenListener: SegmentsScreenListener - override fun onAttach(context: Context?) { + override fun onAttach(context: Context) { super.onAttach(context) if (context !is OnHelpClickedListener) { throw IllegalStateException("Parent activity must implement OnHelpClickedListener.") diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/siteinfo/SiteCreationSiteInfoFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/siteinfo/SiteCreationSiteInfoFragment.kt index 61ad94e44b18..f33bee7725f0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/siteinfo/SiteCreationSiteInfoFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/siteinfo/SiteCreationSiteInfoFragment.kt @@ -41,7 +41,7 @@ class SiteCreationSiteInfoFragment : SiteCreationBaseFormFragment() { private lateinit var helpClickedListener: OnHelpClickedListener private lateinit var siteInfoScreenListener: SiteInfoScreenListener - override fun onAttach(context: Context?) { + override fun onAttach(context: Context) { super.onAttach(context) if (context !is OnSkipClickedListener) { throw IllegalStateException("Parent activity must implement OnSkipClickedListener.") diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/verticals/SiteCreationVerticalsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/verticals/SiteCreationVerticalsFragment.kt index 4b169c2e57b5..1e2d4f8a370b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/verticals/SiteCreationVerticalsFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/verticals/SiteCreationVerticalsFragment.kt @@ -51,7 +51,7 @@ class SiteCreationVerticalsFragment : SiteCreationBaseFormFragment() { @Inject internal lateinit var viewModelFactory: ViewModelProvider.Factory @Inject internal lateinit var uiHelpers: UiHelpers - override fun onAttach(context: Context?) { + override fun onAttach(context: Context) { super.onAttach(context) if (context !is VerticalsScreenListener) { throw IllegalStateException("Parent activity must implement VerticalsScreenListener.") diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementFragment.kt index e1ec88d2546c..0e58539a9237 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementFragment.kt @@ -36,10 +36,10 @@ class InsightsManagementFragment : DaggerFragment() { return inflater.inflate(R.layout.insights_management_fragment, container, false) } - override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) { + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { super.onCreateOptionsMenu(menu, inflater) - inflater?.inflate(R.menu.menu_insights_management, menu) + inflater.inflate(R.menu.menu_insights_management, menu) this.menu = menu enableAnimations() diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetColorSelectionDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetColorSelectionDialogFragment.kt index 346c946e2c05..dd88eee4a7c3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetColorSelectionDialogFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetColorSelectionDialogFragment.kt @@ -60,7 +60,7 @@ class StatsWidgetColorSelectionDialogFragment : AppCompatDialogFragment() { } } - 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/stats/refresh/lists/widget/configuration/StatsWidgetConfigureFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetConfigureFragment.kt index 76bf9e9254ce..f8936f1fb5b6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetConfigureFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetConfigureFragment.kt @@ -26,8 +26,8 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsWi import org.wordpress.android.ui.stats.refresh.lists.widget.today.TodayWidgetUpdater import org.wordpress.android.ui.stats.refresh.lists.widget.views.ViewsWidgetUpdater import org.wordpress.android.ui.stats.refresh.utils.trackWithWidgetType -import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.ToastUtils +import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.image.ImageManager import org.wordpress.android.util.merge import javax.inject.Inject @@ -46,7 +46,7 @@ class StatsWidgetConfigureFragment : DaggerFragment() { private lateinit var colorSelectionViewModel: StatsColorSelectionViewModel private lateinit var widgetType: WidgetType - override fun onInflate(context: Context?, attrs: AttributeSet?, savedInstanceState: Bundle?) { + override fun onInflate(context: Context, attrs: AttributeSet, savedInstanceState: Bundle?) { super.onInflate(context, attrs, savedInstanceState) activity?.let { val styledAttributes = it.obtainStyledAttributes(attrs, R.styleable.statsWidget) @@ -102,13 +102,13 @@ class StatsWidgetConfigureFragment : DaggerFragment() { siteSelectionViewModel.dialogOpened.observe(this, Observer { event -> event?.applyIfNotHandled { - StatsWidgetSiteSelectionDialogFragment().show(fragmentManager, "stats_site_selection_fragment") + StatsWidgetSiteSelectionDialogFragment().show(requireFragmentManager(), "stats_site_selection_fragment") } }) colorSelectionViewModel.dialogOpened.observe(this, Observer { event -> event?.applyIfNotHandled { - StatsWidgetColorSelectionDialogFragment().show(fragmentManager, "stats_view_mode_selection_fragment") + StatsWidgetColorSelectionDialogFragment().show(requireFragmentManager(), "stats_view_mode_selection_fragment") } }) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetDataTypeSelectionDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetDataTypeSelectionDialogFragment.kt index 13607a2c4b78..c6b7a283a633 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetDataTypeSelectionDialogFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetDataTypeSelectionDialogFragment.kt @@ -66,7 +66,7 @@ class StatsWidgetDataTypeSelectionDialogFragment : AppCompatDialogFragment() { } } - 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/stats/refresh/lists/widget/configuration/StatsWidgetSiteSelectionDialogFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetSiteSelectionDialogFragment.kt index 56797646f15d..6035b9097897 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetSiteSelectionDialogFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/configuration/StatsWidgetSiteSelectionDialogFragment.kt @@ -39,12 +39,12 @@ class StatsWidgetSiteSelectionDialogFragment : AppCompatDialogFragment() { viewModel = ViewModelProviders.of(activity!!, viewModelFactory) .get(StatsSiteSelectionViewModel::class.java) viewModel.sites.observe(this, Observer { - (dialog.recycler_view.adapter as? StatsWidgetSiteAdapter)?.update(it ?: listOf()) + (requireDialog().recycler_view.adapter as? StatsWidgetSiteAdapter)?.update(it ?: listOf()) }) viewModel.hideSiteDialog.observe(this, Observer { it?.applyIfNotHandled { if (dialog?.isShowing == true) { - dialog.dismiss() + requireDialog().dismiss() } } }) @@ -52,7 +52,7 @@ class StatsWidgetSiteSelectionDialogFragment : AppCompatDialogFragment() { return alertDialogBuilder.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/stats/refresh/lists/widget/minified/StatsMinifiedWidgetConfigureFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/StatsMinifiedWidgetConfigureFragment.kt index 441dbaa11bd8..cf5281145497 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/StatsMinifiedWidgetConfigureFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/StatsMinifiedWidgetConfigureFragment.kt @@ -24,8 +24,8 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsWi import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsWidgetDataTypeSelectionDialogFragment import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsWidgetSiteSelectionDialogFragment import org.wordpress.android.ui.stats.refresh.utils.trackMinifiedWidget -import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.ToastUtils +import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.image.ImageManager import org.wordpress.android.util.mergeNotNull import javax.inject.Inject @@ -87,19 +87,19 @@ class StatsMinifiedWidgetConfigureFragment : DaggerFragment() { siteSelectionViewModel.dialogOpened.observe(this, Observer { event -> event?.applyIfNotHandled { - StatsWidgetSiteSelectionDialogFragment().show(fragmentManager, "stats_site_selection_fragment") + StatsWidgetSiteSelectionDialogFragment().show(requireFragmentManager(), "stats_site_selection_fragment") } }) colorSelectionViewModel.dialogOpened.observe(this, Observer { event -> event?.applyIfNotHandled { - StatsWidgetColorSelectionDialogFragment().show(fragmentManager, "stats_view_mode_selection_fragment") + StatsWidgetColorSelectionDialogFragment().show(requireFragmentManager(), "stats_view_mode_selection_fragment") } }) dataTypeSelectionViewModel.dialogOpened.observe(this, Observer { event -> event?.applyIfNotHandled { - StatsWidgetDataTypeSelectionDialogFragment().show(fragmentManager, "stats_data_type_selection_fragment") + StatsWidgetDataTypeSelectionDialogFragment().show(requireFragmentManager(), "stats_data_type_selection_fragment") } }) From 5010c3b45b07679577fade964b662b7a061699af Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 7 Oct 2019 12:36:11 -0700 Subject: [PATCH 003/761] Theme switch logic. --- .../android/ui/prefs/AppSettingsFragment.java | 69 ++++++++++++++----- 1 file changed, 51 insertions(+), 18 deletions(-) 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 f111cdbb8e22..916e3b7fd0d2 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,6 +5,7 @@ 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; @@ -15,6 +16,9 @@ import android.util.Pair; import android.view.MenuItem; +import androidx.appcompat.app.AppCompatDelegate; +import androidx.core.os.BuildCompat; + import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.wordpress.android.BuildConfig; @@ -50,8 +54,12 @@ public class AppSettingsFragment extends PreferenceFragment implements OnPreferenceClickListener, Preference.OnPreferenceChangeListener { public static final int LANGUAGE_CHANGED = 1000; + public static final String LIGHT_MODE = "light"; + public static final String DARK_MODE = "dark"; + public static final String DEFAULT_MODE = "default"; private DetailListPreference mLanguagePreference; + private ListPreference mAppThemePreference; // This Device settings private WPSwitchPreference mOptimizedImage; @@ -102,6 +110,9 @@ 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)) @@ -139,19 +150,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()); @@ -230,8 +241,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()); } } @@ -272,13 +283,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); @@ -286,19 +297,41 @@ 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) { + changeTheme((String) newValue); } return true; } + private void changeTheme(String newTheme) { + switch (newTheme) { + case LIGHT_MODE: + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO); + break; + + case DARK_MODE: + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES); + break; + + default: + if (BuildCompat.isAtLeastQ()) { + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); + } else { + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY); + } + break; + } + } + public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: From f278f1ca583969381b49255962a198988820ff25 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 7 Oct 2019 18:11:58 -0700 Subject: [PATCH 004/761] Added feature flag. --- WordPress/build.gradle | 3 +++ .../wordpress/android/ui/prefs/AppSettingsFragment.java | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 6f4f27e5bcd5..b60e9714708c 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -85,6 +85,7 @@ android { } versionCode 777 buildConfigField "boolean", "ME_ACTIVITY_AVAILABLE", "false" + buildConfigField "boolean", "DARK_MODE_AVAILABLE", "false" } zalpha { // alpha version - enable experimental features @@ -92,12 +93,14 @@ android { dimension "buildType" buildConfigField "boolean", "VIDEO_OPTIMIZATION_AVAILABLE", "true" buildConfigField "boolean", "ME_ACTIVITY_AVAILABLE", "true" + buildConfigField "boolean", "DARK_MODE_AVAILABLE", "false" } wasabi { // "hot" version, can be installed along release, alpha or beta versions applicationId "org.wordpress.android.beta" dimension "buildType" buildConfigField "boolean", "ME_ACTIVITY_AVAILABLE", "true" + buildConfigField "boolean", "DARK_MODE_AVAILABLE", "true" } } 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 916e3b7fd0d2..62a501c08063 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 @@ -111,7 +111,13 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { mLanguagePreference.setOnPreferenceChangeListener(this); mAppThemePreference = (ListPreference) findPreference(getString(R.string.pref_key_app_theme)); - mAppThemePreference.setOnPreferenceChangeListener(this); + if (!BuildConfig.DARK_MODE_AVAILABLE) { + PreferenceScreen preferenceScreen = + (PreferenceScreen) findPreference(getString(R.string.pref_key_app_settings_root)); + preferenceScreen.removePreference(mAppThemePreference); + } else { + mAppThemePreference.setOnPreferenceChangeListener(this); + } findPreference(getString(R.string.pref_key_language)) .setOnPreferenceClickListener(this); From a09ff243538d243f142d3a15699622ea46a65356 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 7 Oct 2019 18:12:17 -0700 Subject: [PATCH 005/761] Inheriting from material bridge theme. --- WordPress/src/main/res/values/styles.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 551b12833955..df7e042811bf 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ - + + + + + + - + + + diff --git a/WordPress/src/main/res/values/colors.xml b/WordPress/src/main/res/values/colors.xml index f8a7b842903f..8781b4065f6d 100644 --- a/WordPress/src/main/res/values/colors.xml +++ b/WordPress/src/main/res/values/colors.xml @@ -5,6 +5,7 @@ tools:ignore="UnusedResources"> + #121212 @color/neutral_0 #e6eff3 #f5f5f5 diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index db512aadb087..51d9a39c99ee 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -816,15 +816,18 @@ Light Dark Set by Battery Saver + light + dark + default @string/app_theme_light @string/app_theme_dark @string/app_theme_default - light - dark - default + @string/app_theme_entry_value_light + @string/app_theme_entry_value_dark + @string/app_theme_entry_value_default From e3dccc0eba695389fe98345d98e468b06f1b56d4 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 5 Nov 2019 22:39:11 -0800 Subject: [PATCH 019/761] Refactored utils. --- .../android/ui/main/WPMainActivity.java | 12 +--------- .../android/ui/prefs/AppSettingsFragment.java | 2 +- .../wordpress/android/util/AppThemeUtils.kt | 24 +++++++++++++++---- .../src/main/res/values-night/styles.xml | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) 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 71d995ff0074..1391016f63d8 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 @@ -4,7 +4,6 @@ import android.app.Dialog; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; @@ -21,7 +20,6 @@ import androidx.core.app.RemoteInput; import androidx.fragment.app.Fragment; import androidx.lifecycle.Observer; -import androidx.preference.PreferenceManager; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GoogleApiAvailability; @@ -201,7 +199,7 @@ public void onCreate(Bundle savedInstanceState) { ((WordPress) getApplication()).component().inject(this); super.onCreate(savedInstanceState); - setAppTheme(); + AppThemeUtils.Companion.setAppTheme(this); setContentView(R.layout.main_activity); mBottomNav = findViewById(R.id.bottom_navigation); @@ -338,14 +336,6 @@ && getIntent().getExtras().getBoolean(ARG_CONTINUE_JETPACK_CONNECT, false)) { } } - private void setAppTheme() { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - String themeKey = sharedPreferences - .getString(getString(R.string.pref_key_app_theme), getString(R.string.app_theme_default)); - - AppThemeUtils.Companion.changeTheme(this, themeKey); - } - public boolean isGooglePlayServicesAvailable(Activity activity) { GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance(); int connectionResult = googleApiAvailability.isGooglePlayServicesAvailable(activity); 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 feb34143ed77..dd3b9874d669 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 @@ -304,7 +304,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { } else if (preference == mStripImageLocation) { AppPrefs.setStripImageLocation((Boolean) newValue); } else if (preference == mAppThemePreference) { - AppThemeUtils.Companion.changeTheme(getActivity(), (String) newValue); + AppThemeUtils.Companion.setAppTheme(getActivity(), (String) newValue); } return true; } diff --git a/WordPress/src/main/java/org/wordpress/android/util/AppThemeUtils.kt b/WordPress/src/main/java/org/wordpress/android/util/AppThemeUtils.kt index d15c7249b731..30225e750558 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/AppThemeUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/AppThemeUtils.kt @@ -2,16 +2,30 @@ package org.wordpress.android.util import android.annotation.SuppressLint import android.content.Context +import android.os.Build +import android.text.TextUtils import androidx.appcompat.app.AppCompatDelegate -import androidx.core.os.BuildCompat +import androidx.preference.PreferenceManager import org.wordpress.android.R class AppThemeUtils { companion object { @SuppressLint("WrongConstant") // we use MODE_NIGHT_AUTO_BATTERY for API <= 27 @JvmStatic - fun changeTheme(context: Context, newTheme: String) { - when (newTheme) { + @JvmOverloads + fun setAppTheme(context: Context, themeKey: String? = null) { + val themeName = if (TextUtils.isEmpty(themeKey)) { + val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) + sharedPreferences + .getString( + context.getString(R.string.pref_key_app_theme), + context.getString(R.string.app_theme_default) + ) + } else { + themeKey + } + + when (themeName) { context.getString(R.string.app_theme_entry_value_light) -> { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) } @@ -19,7 +33,7 @@ class AppThemeUtils { AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) } context.getString(R.string.app_theme_entry_value_default) -> { - if (BuildCompat.isAtLeastQ()) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) { AppCompatDelegate.setDefaultNightMode( AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM ) @@ -29,7 +43,7 @@ class AppThemeUtils { ) } } - else -> AppLog.w(AppLog.T.UTILS, "Theme key $newTheme is not recognized.") + else -> AppLog.w(AppLog.T.UTILS, "Theme key $themeName is not recognized.") } } } diff --git a/WordPress/src/main/res/values-night/styles.xml b/WordPress/src/main/res/values-night/styles.xml index 5c034d9a604e..8698687d8a5a 100644 --- a/WordPress/src/main/res/values-night/styles.xml +++ b/WordPress/src/main/res/values-night/styles.xml @@ -1,7 +1,7 @@ - - diff --git a/WordPress/src/main/res/values/colors.xml b/WordPress/src/main/res/values/colors.xml index 8781b4065f6d..b7735fc6d3e8 100644 --- a/WordPress/src/main/res/values/colors.xml +++ b/WordPress/src/main/res/values/colors.xml @@ -5,7 +5,7 @@ tools:ignore="UnusedResources"> - #121212 + #121212 @color/neutral_0 #e6eff3 #f5f5f5 From d086dee73cf202606c02655bb43a6112837c58eb Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 6 Nov 2019 18:30:00 -0800 Subject: [PATCH 026/761] Restart activity after applying theme. --- .../org/wordpress/android/ui/prefs/AppSettingsFragment.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 e9a8f4b9f353..687f7388e169 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 @@ -76,6 +76,8 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); + setRetainInstance(true); + addPreferencesFromResource(R.xml.app_settings); findPreference(getString(R.string.pref_key_send_usage)).setOnPreferenceChangeListener( @@ -302,6 +304,10 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { AppPrefs.setStripImageLocation((Boolean) newValue); } else if (preference == mAppThemePreference) { AppThemeUtils.Companion.setAppTheme(getActivity(), (String) newValue); + // restart activity to make sure changes are applied to PreferenceScreen + Intent refresh = new Intent(getActivity(), getActivity().getClass()); + startActivity(refresh); + getActivity().finish(); } return true; } From 65a5b717424364cdf1db6502ee645d2f81ae2f1a Mon Sep 17 00:00:00 2001 From: Klymentiy Haykov Date: Wed, 6 Nov 2019 18:32:02 -0800 Subject: [PATCH 027/761] Update WordPress/src/main/res/values/strings.xml Co-Authored-By: Tyler Heck --- WordPress/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 653d35db8cd3..7c4dcb2b79b5 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -812,7 +812,7 @@ Read privacy policy Remove location from media App Theme - Chose theme + Choose theme Light Dark Set by Battery Saver From d43754b804aa6250dd2525e71ae48fca505e51d1 Mon Sep 17 00:00:00 2001 From: Klymentiy Haykov Date: Wed, 6 Nov 2019 18:32:49 -0800 Subject: [PATCH 028/761] Update WordPress/src/main/res/values-v29/strings.xml Co-Authored-By: Tyler Heck --- WordPress/src/main/res/values-v29/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/res/values-v29/strings.xml b/WordPress/src/main/res/values-v29/strings.xml index 2dcf209b86b3..22276dd96899 100644 --- a/WordPress/src/main/res/values-v29/strings.xml +++ b/WordPress/src/main/res/values-v29/strings.xml @@ -1,4 +1,4 @@ - System default + System Default From 8a87f584b32e98365430c159d33be947e92ab83f Mon Sep 17 00:00:00 2001 From: Klymentiy Haykov Date: Wed, 6 Nov 2019 18:36:44 -0800 Subject: [PATCH 029/761] Update WordPress/src/main/res/values-night/styles.xml Co-Authored-By: Tyler Heck --- WordPress/src/main/res/values-night/styles.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/res/values-night/styles.xml b/WordPress/src/main/res/values-night/styles.xml index e2c832dab50b..9c79b76c7b23 100644 --- a/WordPress/src/main/res/values-night/styles.xml +++ b/WordPress/src/main/res/values-night/styles.xml @@ -1,5 +1,5 @@ - + + + + + From a9e2408718f3ec506632b8384adb0b4dcd4c940b Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 7 Nov 2019 22:15:09 -0800 Subject: [PATCH 035/761] Added missing styles. --- WordPress/src/main/AndroidManifest.xml | 2 +- .../wordpress/android/ui/main/MySiteFragment.java | 3 +-- WordPress/src/main/res/values/styles.xml | 12 +++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index ac48ba6ee946..6b1fe48184e1 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -501,7 +501,7 @@ + android:theme="@style/WordPress.NoActionBar" /> + + + + + + + + + + + + + + + + From ac7dfc2055dc846934b5ae681e73bb2215cb2e82 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Sat, 9 Nov 2019 20:25:24 -0800 Subject: [PATCH 041/761] Renamed color name to more generic --- ...n_mode_menu_text_color.xml => primary_disabled_selector.xml} | 0 WordPress/src/main/res/values-night/styles.xml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename WordPress/src/main/res/color/{action_mode_menu_text_color.xml => primary_disabled_selector.xml} (100%) diff --git a/WordPress/src/main/res/color/action_mode_menu_text_color.xml b/WordPress/src/main/res/color/primary_disabled_selector.xml similarity index 100% rename from WordPress/src/main/res/color/action_mode_menu_text_color.xml rename to WordPress/src/main/res/color/primary_disabled_selector.xml diff --git a/WordPress/src/main/res/values-night/styles.xml b/WordPress/src/main/res/values-night/styles.xml index e1437595d8a9..87db1eb67fa3 100644 --- a/WordPress/src/main/res/values-night/styles.xml +++ b/WordPress/src/main/res/values-night/styles.xml @@ -33,7 +33,7 @@ @style/WordPress.ActionMode @style/WordPress.ActionMode.CloseButton - @color/action_mode_menu_text_color + @color/primary_disabled_selector - - + + + + diff --git a/WordPress/src/main/res/values/attrs.xml b/WordPress/src/main/res/values/attrs.xml index f6a82f96436d..a27a74faa020 100644 --- a/WordPress/src/main/res/values/attrs.xml +++ b/WordPress/src/main/res/values/attrs.xml @@ -8,7 +8,8 @@ - + + diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 96828881fa4b..649acc0d31da 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -29,12 +29,13 @@ @color/error @color/warning_50 @color/primary + @color/material_on_surface_emphasis_medium + @style/Widget.MaterialComponents.PopupMenu @style/Widget.MaterialComponents.PopupMenu.Overflow - @style/PopupMenu.WordPress @style/DropDownListView.Light.WordPress @style/DropDownNav.WordPress @style/ActionButton.CloseMode.WordPress @@ -165,9 +166,10 @@ ?attr/colorOnPrimarySurface - - - + - + - + + From 8c0979de6dfcab10474af5fe10c918ed306235bf Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 10 Dec 2019 17:47:10 -0800 Subject: [PATCH 063/761] Updated themes in manifest. --- WordPress/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index 8e53e1cac87b..3c1b257367d4 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -310,7 +310,7 @@ android:name=".ui.media.MediaSettingsActivity" android:windowSoftInputMode="stateHidden|adjustPan" android:label="@string/media_settings_screen_title" - android:theme="@style/WordPress.NoActionBar" /> + android:theme="@style/WordPress.NoActionBar.TranslucentStatus" /> Date: Tue, 10 Dec 2019 17:47:59 -0800 Subject: [PATCH 064/761] Updated styles. --- .../src/main/res/values-night/styles.xml | 1 + WordPress/src/main/res/values/styles.xml | 47 +++++++++++-------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/WordPress/src/main/res/values-night/styles.xml b/WordPress/src/main/res/values-night/styles.xml index b05e1b21602f..d0e3b93ea3f3 100644 --- a/WordPress/src/main/res/values-night/styles.xml +++ b/WordPress/src/main/res/values-night/styles.xml @@ -15,6 +15,7 @@ @android:color/white @android:color/black ?attr/colorPrimary + ?attr/colorSecondary @android:color/white @color/neutral_50 diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 29e5338238c8..0cd9709e341b 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -15,9 +15,9 @@ @android:color/black @android:color/black @android:color/white + ?attr/colorSecondary @color/primary_dark - @color/accent @color/primary_30 @style/WordPress.ToolBar @@ -38,7 +38,8 @@ @style/DropDownListView.Light.WordPress @style/DropDownNav.WordPress - @style/ActionButton.CloseMode.WordPress + @style/ActionButton.CloseMode.WordPress + ?attr/wpColorAppBar @style/TabTextStyle.WordPress @style/TabBarStyle.WordPress @@ -63,7 +64,7 @@ - @@ -103,7 +104,9 @@ @@ -223,7 +224,7 @@ @@ -231,15 +232,15 @@ @@ -976,7 +983,8 @@ - - - - - - - - - - - - - diff --git a/WordPress/src/main/res/values/dimens.xml b/WordPress/src/main/res/values/dimens.xml index ba3ead28ef01..7b35832c764f 100644 --- a/WordPress/src/main/res/values/dimens.xml +++ b/WordPress/src/main/res/values/dimens.xml @@ -16,6 +16,7 @@ 16dp 24dp 56dp + 1dp 86dp @@ -445,7 +446,7 @@ 24dp 1dp - + 32dp diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 29e5338238c8..591d21aba58c 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -17,7 +17,7 @@ @android:color/white @color/primary_dark - @color/accent + ?attr/colorSecondary @color/primary_30 @style/WordPress.ToolBar From d49a4a9e24804e1d3b420ace968c444278f669b5 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 16 Dec 2019 15:23:50 -0800 Subject: [PATCH 093/761] Updated connect button, --- .../android/ui/publicize/ConnectButton.java | 14 ++++++-- .../res/layout/publicize_connect_button.xml | 32 ++++++------------- 2 files changed, 21 insertions(+), 25 deletions(-) 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 7f10a21b9534..27917fbbdaf5 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,9 +2,10 @@ import android.content.Context; import android.util.AttributeSet; +import android.widget.Button; import android.widget.FrameLayout; -import android.widget.TextView; +import androidx.annotation.Nullable; import androidx.annotation.StringRes; import org.wordpress.android.R; @@ -15,6 +16,7 @@ */ public class ConnectButton extends FrameLayout { private ConnectAction mConnectAction = ConnectAction.CONNECT; + private Button mConnectButton; public ConnectButton(Context context) { super(context); @@ -33,6 +35,7 @@ public ConnectButton(Context context, AttributeSet attrs, int defStyle) { private void initView(Context context) { inflate(context, R.layout.publicize_connect_button, this); + mConnectButton = findViewById(R.id.text_connect); updateView(); } @@ -54,8 +57,7 @@ private void updateView() { default: return; } - TextView txtConnect = (TextView) findViewById(R.id.text_connect); - txtConnect.setText(captionResId); + mConnectButton.setText(captionResId); } public ConnectAction getAction() { @@ -68,4 +70,10 @@ public void setAction(ConnectAction newAction) { updateView(); } } + + @Override + public void setOnClickListener(@Nullable OnClickListener l) { + super.setOnClickListener(l); + mConnectButton.setOnClickListener(l); + } } diff --git a/WordPress/src/main/res/layout/publicize_connect_button.xml b/WordPress/src/main/res/layout/publicize_connect_button.xml index 66785a401208..ccc5adb90312 100644 --- a/WordPress/src/main/res/layout/publicize_connect_button.xml +++ b/WordPress/src/main/res/layout/publicize_connect_button.xml @@ -1,25 +1,13 @@ - - - - - - - + android:gravity="start" + android:paddingStart="@dimen/margin_extra_large" + android:paddingTop="@dimen/margin_large" + android:paddingEnd="@dimen/margin_extra_large" + android:paddingBottom="@dimen/margin_large" + tools:text="Connect" /> From 8ef03922c1abb850e8879d4646fcb2a2111ef1e2 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 16 Dec 2019 15:24:13 -0800 Subject: [PATCH 094/761] Updated publicize account choser. --- ...PublicizeAccountChooserDialogFragment.java | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) 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 e9365eb76ca9..f6bd9ad1b564 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,7 +4,6 @@ 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; @@ -15,6 +14,8 @@ 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; @@ -50,8 +51,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { //noinspection InflateParams View view = inflater.inflate(R.layout.publicize_account_chooser_dialog, null); - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); 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 = (RecyclerView) view.findViewById(R.id.not_connected_recyclerview); + mNotConnectedRecyclerView = 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 = (LinearLayout) view.findViewById(R.id.connected_header); + LinearLayout connectedHeader = view.findViewById(R.id.connected_header); connectedHeader.setVisibility(View.GONE); } private void populateConnectedListView(View view) { - RecyclerView listViewConnected = (RecyclerView) view.findViewById(R.id.connected_recyclerview); + RecyclerView listViewConnected = view.findViewById(R.id.connected_recyclerview); PublicizeAccountChooserListAdapter connectedAdapter = new PublicizeAccountChooserListAdapter(getActivity(), mConnectedAccounts, null, true); @@ -100,37 +100,21 @@ 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, 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.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.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)); - } + builder.setNegativeButton(R.string.cancel, (dialogInterface, 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) { From 8960b14e75384a01d203b412549ebeac832d5653 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 16 Dec 2019 15:25:05 -0800 Subject: [PATCH 095/761] Updated account chooser dialog. --- .../PublicizeAccountChooserListAdapter.java | 13 ++--- .../publicize_button_prefs_fragment.xml | 56 ++++++++----------- 2 files changed, 30 insertions(+), 39 deletions(-) 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 409bc229b741..2a4fd47fcdd7 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,6 +10,7 @@ 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; @@ -38,6 +39,7 @@ public PublicizeAccountChooserListAdapter(Context context, List { + if (mListener != null) { + mSelectedPosition = holder.getAdapterPosition(); + mListener.onAccountSelected(mSelectedPosition); } }); } else { diff --git a/WordPress/src/main/res/layout/publicize_button_prefs_fragment.xml b/WordPress/src/main/res/layout/publicize_button_prefs_fragment.xml index 287b3647d40a..86391dd7c73a 100644 --- a/WordPress/src/main/res/layout/publicize_button_prefs_fragment.xml +++ b/WordPress/src/main/res/layout/publicize_button_prefs_fragment.xml @@ -1,11 +1,12 @@ - + android:paddingStart="@dimen/margin_medium" + android:paddingEnd="@dimen/margin_medium"> + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textColor="?attr/colorPrimary" /> + android:textAppearance="?attr/textAppearanceCaption" /> - + + android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> - + - + android:layout_marginTop="@dimen/margin_large"> - + - + android:layout_marginTop="@dimen/margin_large"> - + - + android:layout_marginBottom="@dimen/margin_large"> - + From 2b31e45b809426309653ae57f824f76068bf7839 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 16 Dec 2019 15:25:19 -0800 Subject: [PATCH 096/761] Cleaning up base fragment. --- .../wordpress/android/ui/publicize/PublicizeBaseFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 99d81ccc443d..77099d34bb26 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; -public class PublicizeBaseFragment extends Fragment { +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 accessibiility - talkBack + // important for accessibility - talkBack getActivity().setTitle(title); } } From 1291094a8816c267a84fa829b4022ae178d2d434 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 16 Dec 2019 15:25:55 -0800 Subject: [PATCH 097/761] Updated preference view and publicize preference fragment. --- .../PublicizeButtonPrefsFragment.java | 57 ++++--------- .../wordpress/android/widgets/WPPrefView.java | 80 +++++++------------ WordPress/src/main/res/layout/wppref_view.xml | 43 +++++----- 3 files changed, 67 insertions(+), 113 deletions(-) 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 4233f6b61e50..65a14687b0bf 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,9 +9,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.android.volley.VolleyError; -import com.wordpress.rest.RestRequest; - +import org.jetbrains.annotations.NotNull; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -100,7 +98,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); } @@ -110,14 +108,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 = (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); + 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); if (!mSite.isWPCom() && mSite.isJetpackConnected()) { mPrefShowLike.setHeading(getString(R.string.site_settings_like_header)); @@ -202,17 +200,9 @@ private void saveSharingButtons(boolean isSharingButtons) { } WordPress.getRestClientUtilsV1_1() - .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()); - } - }); + .setSharingButtons(Long.toString(mSite.getSiteId()), jsonObject, + this::configureSharingButtonsFromResponse, + error -> AppLog.e(AppLog.T.SETTINGS, error.getMessage())); } /* @@ -242,17 +232,9 @@ private void toggleTwitterPreference() { */ private void configureSharingButtons() { WordPress.getRestClientUtilsV1_1() - .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); - } - }); + .getSharingButtons(Long.toString(mSite.getSiteId()), + this::configureSharingButtonsFromResponse, + error -> AppLog.e(AppLog.T.SETTINGS, error)); } private void configureSharingButtonsFromResponse(JSONObject response) { @@ -324,12 +306,7 @@ private void getSiteSettings(boolean shouldFetchSettings) { mSiteSettings.init(false); if (shouldFetchSettings) { - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - mSiteSettings.init(true); - } - }, FETCH_DELAY); + new Handler().postDelayed(() -> mSiteSettings.init(true), FETCH_DELAY); } } diff --git a/WordPress/src/main/java/org/wordpress/android/widgets/WPPrefView.java b/WordPress/src/main/java/org/wordpress/android/widgets/WPPrefView.java index 37534420b184..a031106222c9 100644 --- a/WordPress/src/main/java/org/wordpress/android/widgets/WPPrefView.java +++ b/WordPress/src/main/java/org/wordpress/android/widgets/WPPrefView.java @@ -4,14 +4,12 @@ import android.app.Dialog; import android.app.DialogFragment; import android.content.Context; -import android.content.DialogInterface; import android.content.res.TypedArray; import android.os.Bundle; import android.os.Parcelable; import android.text.TextUtils; import android.util.AttributeSet; import android.util.SparseBooleanArray; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -25,6 +23,8 @@ 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.StringUtils; @@ -73,7 +73,6 @@ public interface OnPrefChangedListener { private PrefType mPrefType = PrefType.TEXT; private final PrefListItems mListItems = new PrefListItems(); - private ViewGroup mContainer; private TextView mHeadingTextView; private TextView mTitleTextView; private TextView mSummaryTextView; @@ -175,8 +174,8 @@ public boolean containsValue(@NonNull String value) { } /* - * Wrapper that will allow us to preserve type of PrefListItems when serializing it - */ + * Wrapper that will allow us to preserve type of PrefListItems when serializing it + */ public static class PrefListItemsWrapper implements Serializable { private PrefListItems mList; @@ -212,13 +211,13 @@ public WPPrefView(Context context, AttributeSet attrs, int defStyleAttr, int def private void initView(Context context, AttributeSet attrs) { ViewGroup view = (ViewGroup) inflate(context, R.layout.wppref_view, this); - mContainer = (ViewGroup) view.findViewById(R.id.container); - mHeadingTextView = (TextView) view.findViewById(R.id.text_heading); - mTitleTextView = (TextView) view.findViewById(R.id.text_title); - mSummaryTextView = (TextView) view.findViewById(R.id.text_summary); - mToggleSwitch = (SwitchCompat) view.findViewById(R.id.switch_view); + ViewGroup container = view.findViewById(R.id.container); + mHeadingTextView = view.findViewById(R.id.text_heading); + mTitleTextView = view.findViewById(R.id.text_title); + mSummaryTextView = view.findViewById(R.id.text_summary); + mToggleSwitch = view.findViewById(R.id.switch_view); - mContainer.setOnClickListener(this); + container.setOnClickListener(this); if (attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes( @@ -340,13 +339,6 @@ public void setChecked(boolean checked) { mToggleSwitch.setChecked(checked); } - /* - * the list of data when the PrefType is CHECKLIST or RADIOLIST - */ - public @NonNull PrefListItems getListItems() { - return mListItems; - } - public void setListItems(@NonNull PrefListItems items) { mListItems.clear(); mListItems.addAll(items); @@ -395,26 +387,22 @@ private Dialog getTextDialog() { LayoutInflater inflater = LayoutInflater.from(getContext()); //noinspection InflateParams ViewGroup customView = (ViewGroup) inflater.inflate(R.layout.wppref_text_dialog, null); - final EditText editText = (EditText) customView.findViewById(R.id.edit); + final EditText editText = customView.findViewById(R.id.edit); editText.setText(mSummaryTextView.getText()); - TextView txtSubtitle = (TextView) customView.findViewById(R.id.text_subtitle); + TextView txtSubtitle = customView.findViewById(R.id.text_subtitle); if (!TextUtils.isEmpty(mTextDialogSubtitle)) { txtSubtitle.setText(mTextDialogSubtitle); } else { txtSubtitle.setVisibility(GONE); } - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getContext(), R.style.Calypso_Dialog_Alert)) + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getContext()) .setTitle(mTitleTextView.getText()) .setView(customView) .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - setTextEntry(editText.getText().toString()); - doPrefChanged(); - } + .setPositiveButton(android.R.string.ok, (dialog, which) -> { + setTextEntry(editText.getText().toString()); + doPrefChanged(); }); return builder.create(); } @@ -431,18 +419,14 @@ private Dialog getCheckListDialog() { checkedItems[i] = mListItems.get(i).mIsChecked; } - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getContext(), R.style.Calypso_Dialog_Alert)) + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getContext()) .setTitle(mTitleTextView.getText()) .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - SparseBooleanArray checkedItems = - ((AlertDialog) dialog).getListView().getCheckedItemPositions(); - mListItems.setCheckedItems(checkedItems); - doPrefChanged(); - } + .setPositiveButton(android.R.string.ok, (dialog, which) -> { + SparseBooleanArray checkedItems1 = + ((AlertDialog) dialog).getListView().getCheckedItemPositions(); + mListItems.setCheckedItems(checkedItems1); + doPrefChanged(); }) .setMultiChoiceItems(items, checkedItems, null); return builder.create(); @@ -462,20 +446,16 @@ private Dialog getRadioListDialog() { } } - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getContext(), R.style.Calypso_Dialog_Alert)) + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getContext()) .setTitle(mTitleTextView.getText()) .setNegativeButton(android.R.string.cancel, null) - .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - SparseBooleanArray checkedItems = - ((AlertDialog) dialog).getListView().getCheckedItemPositions(); - mListItems.setCheckedItems(checkedItems); - PrefListItem item = mListItems.getFirstSelectedItem(); - setSummary(item != null ? item.mItemName : ""); - doPrefChanged(); - } + .setPositiveButton(android.R.string.ok, (dialog, which) -> { + SparseBooleanArray checkedItems = + ((AlertDialog) dialog).getListView().getCheckedItemPositions(); + mListItems.setCheckedItems(checkedItems); + PrefListItem item = mListItems.getFirstSelectedItem(); + setSummary(item != null ? item.mItemName : ""); + doPrefChanged(); }) .setSingleChoiceItems(items, selectedPos, null); return builder.create(); diff --git a/WordPress/src/main/res/layout/wppref_view.xml b/WordPress/src/main/res/layout/wppref_view.xml index 71468075df53..3e867b6258be 100644 --- a/WordPress/src/main/res/layout/wppref_view.xml +++ b/WordPress/src/main/res/layout/wppref_view.xml @@ -9,23 +9,23 @@ android:id="@+id/text_heading" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginStart="@dimen/margin_extra_large" android:layout_marginTop="@dimen/margin_large" - android:textColor="@color/primary_50" - android:textSize="@dimen/text_sz_medium" - android:textStyle="bold" + android:layout_marginEnd="@dimen/margin_extra_large" + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textColor="?attr/colorPrimary" android:visibility="gone" tools:text="text_heading" - android:layout_marginEnd="@dimen/margin_extra_large" - android:layout_marginStart="@dimen/margin_extra_large"/> + tools:visibility="visible" /> + android:textAlignment="viewStart" + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:text="text_title" /> + android:clickable="false" + android:focusable="false" + tools:checked="true" /> + android:textAlignment="viewStart" + android:textAppearance="?attr/textAppearanceCaption" + tools:text="text_summary" /> + android:layout_height="@dimen/divider_size" + android:background="?android:listDivider" /> From 534ed62510a0a18bc17c9433bdcaac1fbb95691c Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 16 Dec 2019 15:30:46 -0800 Subject: [PATCH 098/761] Updated list of services. --- .../ui/publicize/PublicizeListActivity.java | 51 ++++++-------- .../ui/publicize/PublicizeListFragment.java | 22 +++---- .../res/layout/publicize_list_activity.xml | 2 +- .../res/layout/publicize_list_fragment.xml | 66 +++++++++---------- .../layout/publicize_listitem_connection.xml | 29 ++++---- .../res/layout/publicize_listitem_service.xml | 24 ++++--- 6 files changed, 85 insertions(+), 109 deletions(-) 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 0b8cb5c93b08..28b64fd27965 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 @@ -2,7 +2,6 @@ import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; import android.os.Bundle; import android.view.ContextThemeWrapper; import android.view.MenuItem; @@ -15,9 +14,12 @@ 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; @@ -60,7 +62,7 @@ public void onCreate(Bundle savedInstanceState) { setContentView(R.layout.publicize_list_activity); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + Toolbar toolbar = findViewById(R.id.toolbar_main); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); @@ -85,7 +87,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); } @@ -176,8 +178,7 @@ private void reloadDetailFragment() { } } - private void showWebViewFragment(PublicizeService service, - PublicizeConnection publicizeConnection) { + private void showWebViewFragment(PublicizeService service, PublicizeConnection publicizeConnection) { if (isFinishing()) { return; } @@ -192,16 +193,6 @@ private void showWebViewFragment(PublicizeService service, .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); @@ -260,23 +251,19 @@ public void onRequestDisconnect(PublicizeConnection publicizeConnection) { } private void confirmDisconnect(final PublicizeConnection publicizeConnection) { - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); 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, 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.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.setNegativeButton(R.string.cancel, null); @@ -371,10 +358,10 @@ 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(); } private void showAlertForFailureReason(int reasonResId) { 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 5d3ec0eebe8f..6a3621c43353 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; @@ -171,13 +171,13 @@ private void showQuickStartFocusPoint() { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(QuickStartEvent.KEY, mQuickStartEvent); } @Override - public void onAttach(Activity activity) { + public void onAttach(@NotNull Activity activity) { super.onAttach(activity); if (activity instanceof PublicizeButtonPrefsListener) { @@ -219,16 +219,14 @@ private PublicizeServiceAdapter getAdapter() { mAccountStore.getAccount().getUserId()); mAdapter.setOnAdapterLoadedListener(mAdapterLoadedListener); if (getActivity() instanceof OnServiceClickListener) { - 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); + mAdapter.setOnServiceClickListener(service -> { + QuickStartUtils.completeTaskAndRemindNextOne(mQuickStartStore, ENABLE_POST_SHARING, + mDispatcher, mSite, mQuickStartEvent, getContext()); + if (getView() != null) { + QuickStartUtils.removeQuickStartFocusPoint((ViewGroup) getView()); } + mQuickStartEvent = null; + ((OnServiceClickListener) getActivity()).onServiceClicked(service); }); } } diff --git a/WordPress/src/main/res/layout/publicize_list_activity.xml b/WordPress/src/main/res/layout/publicize_list_activity.xml index ef73ea66b0db..74e2ee4b0e5d 100644 --- a/WordPress/src/main/res/layout/publicize_list_activity.xml +++ b/WordPress/src/main/res/layout/publicize_list_activity.xml @@ -4,7 +4,7 @@ android:layout_height="match_parent" android:orientation="vertical"> - + + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> + android:paddingStart="@dimen/margin_medium" + android:paddingEnd="@dimen/margin_medium"> + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textColor="?attr/colorPrimary" /> + android:textAppearance="?attr/textAppearanceCaption" /> + android:layout_height="wrap_content" /> + tools:visibility="visible" /> - + - + android:layout_marginBottom="@dimen/margin_large"> + android:layout_marginEnd="@dimen/content_margin" + android:layout_marginBottom="@dimen/margin_extra_large" + android:paddingStart="@dimen/margin_medium" + android:paddingEnd="@dimen/margin_medium"> + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textColor="?attr/colorPrimary" /> + android:tint="?attr/colorPrimary" /> + android:textAppearance="?attr/textAppearanceSubtitle1" /> + - + + diff --git a/WordPress/src/main/res/layout/publicize_listitem_connection.xml b/WordPress/src/main/res/layout/publicize_listitem_connection.xml index f866cecac2d8..8a276c99b2b0 100644 --- a/WordPress/src/main/res/layout/publicize_listitem_connection.xml +++ b/WordPress/src/main/res/layout/publicize_listitem_connection.xml @@ -11,39 +11,38 @@ android:layout_width="@dimen/avatar_sz_small" android:layout_height="@dimen/avatar_sz_small" android:layout_centerVertical="true" - tools:src="@drawable/bg_rectangle_neutral_10_user_32dp" android:layout_marginEnd="@dimen/margin_large" - android:contentDescription="@null"/> + android:contentDescription="@null" + tools:src="@drawable/bg_rectangle_neutral_10_user_32dp" /> + android:layout_toEndOf="@+id/image_avatar" + android:background="?android:attr/listDivider" /> + android:ellipsize="end" + android:gravity="start" + android:textAlignment="viewStart" + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:text="text_user" /> - + android:layout_centerVertical="true" + android:layout_marginEnd="@dimen/margin_extra_large" /> + \ No newline at end of file diff --git a/WordPress/src/main/res/layout/publicize_listitem_service.xml b/WordPress/src/main/res/layout/publicize_listitem_service.xml index 37894e3cd8f2..c3b2075283f5 100644 --- a/WordPress/src/main/res/layout/publicize_listitem_service.xml +++ b/WordPress/src/main/res/layout/publicize_listitem_service.xml @@ -13,47 +13,45 @@ android:layout_centerVertical="true" android:layout_marginEnd="@dimen/margin_large" android:contentDescription="@null" - tools:src="@drawable/bg_rectangle_neutral_10_globe_32dp"/> + tools:src="@drawable/bg_rectangle_neutral_10_globe_32dp" /> + android:layout_height="@dimen/divider_size" + android:layout_toEndOf="@+id/image_icon" + android:background="?android:listDivider" /> + android:orientation="vertical"> From b254aef2c93e661d079eb3875e87ab24607963c5 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 16 Dec 2019 15:31:06 -0800 Subject: [PATCH 099/761] Updated publicize details. --- .../ui/publicize/PublicizeDetailFragment.java | 37 +++----- .../adapters/PublicizeConnectionAdapter.java | 19 ++-- .../layout/publicize_connection_list_item.xml | 17 ++-- .../res/layout/publicize_detail_fragment.xml | 92 +++++++++---------- 4 files changed, 71 insertions(+), 94 deletions(-) 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 be15e86e246c..cc4653a751d6 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 @@ -3,13 +3,13 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; -import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.TextView; 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; @@ -25,7 +25,7 @@ public class PublicizeDetailFragment extends PublicizeBaseFragment implements PublicizeConnectionAdapter.OnAdapterLoadedListener { - public static final String FACEBOOK_SHARING_CHANGE_BLOG_POST = + private static final String FACEBOOK_SHARING_CHANGE_BLOG_POST = "https://en.blog.wordpress.com/2018/07/23/sharing-options-from-wordpress-com-to-facebook-are-changing/"; private SiteModel mSite; private String mServiceId; @@ -72,7 +72,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); outState.putString(PublicizeConstants.ARG_SERVICE_ID, mServiceId); @@ -83,9 +83,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.publicize_detail_fragment, container, false); 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); + mServiceCardView = rootView.findViewById(R.id.card_view_service); + mConnectBtn = mServiceCardView.findViewById(R.id.button_connect); + mRecycler = rootView.findViewById(R.id.recycler_view); return rootView; } @@ -115,15 +115,15 @@ public void loadData() { mServiceCardView.setVisibility(View.GONE); } else { String serviceLabel = String.format(getString(R.string.connection_service_label), mService.getLabel()); - TextView txtService = (TextView) mServiceCardView.findViewById(R.id.text_service); + TextView txtService = mServiceCardView.findViewById(R.id.text_service); txtService.setText(serviceLabel); String description = String.format(getString(R.string.connection_service_description), mService.getLabel()); - TextView txtDescription = (TextView) mServiceCardView.findViewById(R.id.text_description); + TextView txtDescription = mServiceCardView.findViewById(R.id.text_description); txtDescription.setText(description); // Hide the Learn More button by default as at the moment it is only used for the Facebook warning below. - TextView learnMoreButton = (TextView) mServiceCardView.findViewById(R.id.learn_more_button); + TextView learnMoreButton = mServiceCardView.findViewById(R.id.learn_more_button); learnMoreButton.setVisibility(View.GONE); if (isFacebook()) { @@ -151,17 +151,13 @@ private boolean isFacebook() { private void showFacebookWarning() { String noticeText = getString(R.string.connection_service_facebook_notice); - TextView txtNotice = (TextView) mServiceCardView.findViewById(R.id.text_description_notice); + TextView txtNotice = mServiceCardView.findViewById(R.id.text_description_notice); txtNotice.setText(noticeText); txtNotice.setVisibility(View.VISIBLE); - TextView learnMoreButton = (TextView) mServiceCardView.findViewById(R.id.learn_more_button); - learnMoreButton.setOnClickListener(new OnClickListener() { - @Override public void onClick(View v) { - WPWebViewActivity.openURL(getActivity(), - FACEBOOK_SHARING_CHANGE_BLOG_POST); - } - }); + TextView learnMoreButton = mServiceCardView.findViewById(R.id.learn_more_button); + learnMoreButton.setOnClickListener(v -> WPWebViewActivity.openURL(getActivity(), + FACEBOOK_SHARING_CHANGE_BLOG_POST)); learnMoreButton.setVisibility(View.VISIBLE); } @@ -190,12 +186,7 @@ public void onAdapterLoaded(boolean isEmpty) { } else { mConnectBtn.setAction(ConnectAction.CONNECT_ANOTHER_ACCOUNT); } - mConnectBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - getOnPublicizeActionListener().onRequestConnect(mService); - } - }); + mConnectBtn.setOnClickListener(v -> getOnPublicizeActionListener().onRequestConnect(mService)); } } } 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 2771f6d68325..548b9be3c95e 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,6 +9,7 @@ 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; @@ -88,6 +89,7 @@ public long getItemId(int position) { return mConnections.get(position).connectionId; } + @NotNull @Override public ConnectionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = @@ -114,23 +116,18 @@ private void bindButton(ConnectButton btnConnect, final PublicizeConnection conn case OK: case MUST_DISCONNECT: btnConnect.setAction(PublicizeConstants.ConnectAction.DISCONNECT); - btnConnect.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (mActionListener != null) { - mActionListener.onRequestDisconnect(connection); - } + btnConnect.setOnClickListener(v -> { + if (mActionListener != null) { + mActionListener.onRequestDisconnect(connection); } }); break; case BROKEN: default: btnConnect.setAction(ConnectAction.RECONNECT); - btnConnect.setOnClickListener(new View.OnClickListener() { - @Override public void onClick(View view) { - if (mActionListener != null) { - mActionListener.onRequestReconnect(mService, connection); - } + btnConnect.setOnClickListener(view -> { + if (mActionListener != null) { + mActionListener.onRequestReconnect(mService, connection); } }); } diff --git a/WordPress/src/main/res/layout/publicize_connection_list_item.xml b/WordPress/src/main/res/layout/publicize_connection_list_item.xml index e562da840d37..a74af7bf4126 100644 --- a/WordPress/src/main/res/layout/publicize_connection_list_item.xml +++ b/WordPress/src/main/res/layout/publicize_connection_list_item.xml @@ -1,13 +1,13 @@ + android:paddingBottom="@dimen/publicize_default_margin"> - + android:contentDescription="@null" /> - + android:layout_marginStart="@dimen/publicize_name_margin" + android:textAppearance="?attr/textAppearanceSubtitle1" /> diff --git a/WordPress/src/main/res/layout/publicize_detail_fragment.xml b/WordPress/src/main/res/layout/publicize_detail_fragment.xml index b42a152f83ad..b4bfd97db301 100644 --- a/WordPress/src/main/res/layout/publicize_detail_fragment.xml +++ b/WordPress/src/main/res/layout/publicize_detail_fragment.xml @@ -1,26 +1,22 @@ - + android:paddingBottom="@dimen/content_margin"> - + tools:visibility="visible"> + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textColor="?attr/colorPrimary" /> + android:layout_marginStart="@dimen/margin_extra_large" + android:layout_marginTop="@dimen/margin_large" /> - + - + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/margin_large"> + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textColor="?attr/colorPrimary" + tools:text="text_service" /> + android:ellipsize="end" + android:textAppearance="?attr/textAppearanceCaption" + tools:text="text_description" /> + tools:text="text_description_notice" /> + android:textAppearance="?attr/textAppearanceBody2" + android:textColor="?attr/colorPrimary" + tools:text="learn_more_button" /> + android:background="?android:attr/listDivider" /> - + From 36d2189d616df97013c233be6d5bc8576fa3f075 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 15:07:18 -0800 Subject: [PATCH 100/761] Added newline to end of file. --- WordPress/src/main/res/layout/publicize_listitem_connection.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/res/layout/publicize_listitem_connection.xml b/WordPress/src/main/res/layout/publicize_listitem_connection.xml index 8a276c99b2b0..2e661b72cde0 100644 --- a/WordPress/src/main/res/layout/publicize_listitem_connection.xml +++ b/WordPress/src/main/res/layout/publicize_listitem_connection.xml @@ -45,4 +45,4 @@ android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:layout_marginEnd="@dimen/margin_extra_large" /> - \ No newline at end of file + From d5ed877b98540026b5196b26d3fb9fdec4371b6d Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 15:35:43 -0800 Subject: [PATCH 101/761] Reverted changes to photo picker activity. --- WordPress/src/main/res/layout/photo_picker_activity.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/res/layout/photo_picker_activity.xml b/WordPress/src/main/res/layout/photo_picker_activity.xml index 0ff1d854b3d5..8b3b716bb1ce 100644 --- a/WordPress/src/main/res/layout/photo_picker_activity.xml +++ b/WordPress/src/main/res/layout/photo_picker_activity.xml @@ -4,13 +4,13 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + + tools:ignore="UnknownIdInLayout"/> From 3984bcf04fd9491c3ed093b796a31ee4723ac67d Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 15:57:32 -0800 Subject: [PATCH 102/761] Cleaned up browser and settings activities. --- .../ui/media/MediaBrowserActivity.java | 81 +++++++------------ .../ui/media/MediaSettingsActivity.java | 71 +++++----------- 2 files changed, 49 insertions(+), 103 deletions(-) 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 1bebf240477f..d9ff8a10d950 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 @@ -43,6 +43,7 @@ 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; @@ -177,8 +178,8 @@ public void onCreate(Bundle savedInstanceState) { 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); @@ -186,7 +187,7 @@ public void onCreate(Bundle savedInstanceState) { // if media was shared add it to the library handleSharedMedia(); - mTabLayout = (TabLayout) findViewById(R.id.tab_layout); + mTabLayout = findViewById(R.id.tab_layout); setupTabs(); MediaFilter filter; @@ -401,7 +402,7 @@ protected void onDestroy() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putString(SAVED_QUERY, mQuery); @@ -417,12 +418,8 @@ protected void onSaveInstanceState(Bundle outState) { private void getMediaFromDeviceAndTrack(Uri imageUri, int requestCode) { final String mimeType = getContentResolver().getType(imageUri); - WPMediaUtils.fetchMediaAndDoNext(this, imageUri, new WPMediaUtils.MediaFetchDoNext() { - @Override - public void doNext(Uri uri) { - queueFileForUpload(getOptimizedPictureIfNecessary(uri), mimeType); - } - }); + WPMediaUtils.fetchMediaAndDoNext(this, imageUri, + uri -> queueFileForUpload(getOptimizedPictureIfNecessary(uri), mimeType)); trackAddMediaFromDeviceEvents( false, requestCode == RequestCodes.VIDEO_LIBRARY, @@ -794,24 +791,15 @@ private void uploadList(List uriList) { for (Uri uri : uriList) { if (uri != null) { WPMediaUtils.fetchMediaAndDoNext(this, uri, - new WPMediaUtils.MediaFetchDoNext() { - @Override - public void doNext(Uri downloadedUri) { - queueFileForUpload( - getOptimizedPictureIfNecessary(downloadedUri), - getContentResolver().getType(downloadedUri)); - } - }); + downloadedUri -> queueFileForUpload( + getOptimizedPictureIfNecessary(downloadedUri), + getContentResolver().getType(downloadedUri))); } } } - private final OnBackStackChangedListener mOnBackStackChangedListener = new OnBackStackChangedListener() { - @Override - public void onBackStackChanged() { - ActivityUtils.hideKeyboard(MediaBrowserActivity.this); - } - }; + private final OnBackStackChangedListener mOnBackStackChangedListener = + () -> ActivityUtils.hideKeyboard(MediaBrowserActivity.this); private void doBindDeleteService(Intent intent) { mDeleteServiceBound = bindService(intent, mDeleteConnection, @@ -854,53 +842,38 @@ public void showAddMediaPopup() { PopupMenu popup = new PopupMenu(this, anchor); popup.getMenu().add(R.string.photo_picker_capture_photo).setOnMenuItemClickListener( - new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - doAddMediaItemClicked(AddMenuItem.ITEM_CAPTURE_PHOTO); - return true; - } + item -> { + doAddMediaItemClicked(AddMenuItem.ITEM_CAPTURE_PHOTO); + return true; }); if (!mBrowserType.isSingleImagePicker()) { popup.getMenu().add(R.string.photo_picker_capture_video).setOnMenuItemClickListener( - new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - doAddMediaItemClicked(AddMenuItem.ITEM_CAPTURE_VIDEO); - return true; - } + item -> { + doAddMediaItemClicked(AddMenuItem.ITEM_CAPTURE_VIDEO); + return true; }); } popup.getMenu().add(R.string.photo_picker_choose_photo).setOnMenuItemClickListener( - new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_PHOTO); - return true; - } + item -> { + doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_PHOTO); + return true; }); if (!mBrowserType.isSingleImagePicker()) { popup.getMenu().add(R.string.photo_picker_choose_video).setOnMenuItemClickListener( - new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_VIDEO); - return true; - } + item -> { + doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_VIDEO); + return true; }); } if (mBrowserType.isBrowser() && mSite.isUsingWpComRestApi()) { popup.getMenu().add(R.string.photo_picker_stock_media).setOnMenuItemClickListener( - new MenuItem.OnMenuItemClickListener() { - @Override - public boolean onMenuItemClick(MenuItem item) { - doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_STOCK_MEDIA); - return true; - } + item -> { + doAddMediaItemClicked(AddMenuItem.ITEM_CHOOSE_STOCK_MEDIA); + return true; }); } @@ -1007,7 +980,7 @@ private void handleSharedMedia() { multiStream = intent.getParcelableArrayListExtra((Intent.EXTRA_STREAM)); } else if (Intent.ACTION_SEND.equals(intent.getAction())) { multiStream = new ArrayList<>(); - multiStream.add((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM)); + multiStream.add(intent.getParcelableExtra(Intent.EXTRA_STREAM)); } else { multiStream = null; } 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 5158706262b2..d30c24e32f13 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 @@ -23,7 +23,6 @@ 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; @@ -318,24 +317,17 @@ public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { // tap to show full screen view (not supported for documents) if (!isDocument()) { - View.OnClickListener listener = new View.OnClickListener() { - @Override - public void onClick(View v) { - showFullScreen(); - } - }; + View.OnClickListener listener = v -> showFullScreen(); mImageView.setOnClickListener(listener); mImagePlay.setOnClickListener(listener); mFabView.setOnClickListener(listener); - 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; + mFabView.setOnLongClickListener(view -> { + if (view.isHapticFeedbackEnabled()) { + view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } + + Toast.makeText(view.getContext(), R.string.button_preview, Toast.LENGTH_SHORT).show(); + return true; }); ViewUtilsKt.redirectContextClickToLongPressListener(mFabView); } @@ -427,12 +419,9 @@ protected void onResume() { super.onResume(); long delayMs = getResources().getInteger(R.integer.fab_animation_delay); - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - if (!isFinishing() && shouldShowFab()) { - showFab(); - } + new Handler().postDelayed(() -> { + if (!isFinishing() && shouldShowFab()) { + showFab(); } }, delayMs); @@ -443,7 +432,7 @@ public void run() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(ARG_MEDIA_LOCAL_ID, mMedia.getId()); outState.putParcelable(ARG_EDITOR_IMAGE_METADATA, mEditorImageMetaData); @@ -491,12 +480,7 @@ protected void onDestroy() { private void delayedFinishWithError() { ToastUtils.showToast(this, R.string.error_media_not_found); - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - finish(); - } - }, 1500); + new Handler().postDelayed(this::finish, 1500); } @Override @@ -664,12 +648,7 @@ private void showMetaData() { View txtCopyUrl = findViewById(R.id.text_copy_url); txtCopyUrl.setVisibility(hasUrl ? View.VISIBLE : View.GONE); if (hasUrl) { - txtCopyUrl.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - copyMediaUrlToClipboard(); - } - }); + txtCopyUrl.setOnClickListener(v -> copyMediaUrlToClipboard()); } } @@ -814,13 +793,10 @@ public void run() { int width = DisplayUtils.getDisplayPixelWidth(MediaSettingsActivity.this); final Bitmap thumb = ImageUtils.getVideoFrameFromVideo(mMedia.getUrl(), width); if (thumb != null) { - runOnUiThread(new Runnable() { - @Override - public void run() { - if (!isFinishing()) { - WordPress.getBitmapCache().put(mMedia.getUrl(), thumb); - mImageView.setImageBitmap(thumb); - } + runOnUiThread(() -> { + if (!isFinishing()) { + WordPress.getBitmapCache().put(mMedia.getUrl(), thumb); + mImageView.setImageBitmap(thumb); } }); } @@ -833,14 +809,11 @@ private void showFullScreen() { hideFab(); // show fullscreen preview after a brief delay so fab & actionBar animations don't stutter - 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); - } + new Handler().postDelayed(() -> { + if (isMediaFromEditor()) { + MediaPreviewActivity.showPreview(MediaSettingsActivity.this, mSite, mEditorImageMetaData.getSrc()); + } else { + MediaPreviewActivity.showPreview(MediaSettingsActivity.this, mSite, mMedia, mMediaIdList); } }, 200); } From 9da9a450a971516961b8a8638b8c598f089827de Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 16:00:15 -0800 Subject: [PATCH 103/761] Removed unused attribute. --- WordPress/src/main/res/values/dimens.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/src/main/res/values/dimens.xml b/WordPress/src/main/res/values/dimens.xml index 7b35832c764f..5a5a75089c72 100644 --- a/WordPress/src/main/res/values/dimens.xml +++ b/WordPress/src/main/res/values/dimens.xml @@ -304,7 +304,6 @@ 1dp 10dp 40dp - 16sp 8dp From a05452a1c12786e2c607bbccadeb1886f30e693f Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 16:26:31 -0800 Subject: [PATCH 104/761] Updated themes in manifest. --- WordPress/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index ee2202e137a2..2e961a33f64a 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -541,11 +541,11 @@ + android:theme="@style/WordPress.NoActionBar"/> + android:theme="@style/WordPress.NoActionBar"/> Date: Tue, 17 Dec 2019 16:36:12 -0800 Subject: [PATCH 105/761] Updated detail activity. --- .../ui/activitylog/detail/ActivityLogDetailActivity.kt | 4 ++-- .../src/main/res/layout/activity_log_detail_activity.xml | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) 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 0cfad8045989..517e1f255a65 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 @@ -3,7 +3,7 @@ package org.wordpress.android.ui.activitylog.detail import android.os.Bundle import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity -import kotlinx.android.synthetic.main.toolbar.* +import kotlinx.android.synthetic.main.toolbar_main.* import org.wordpress.android.R import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogNegativeClickInterface import org.wordpress.android.ui.posts.BasicFragmentDialog.BasicDialogPositiveClickInterface @@ -15,7 +15,7 @@ class ActivityLogDetailActivity : AppCompatActivity(), BasicDialogPositiveClickI setContentView(R.layout.activity_log_detail_activity) - setSupportActionBar(toolbar) + setSupportActionBar(toolbar_main) supportActionBar?.let { it.setHomeButtonEnabled(true) it.setDisplayHomeAsUpEnabled(true) diff --git a/WordPress/src/main/res/layout/activity_log_detail_activity.xml b/WordPress/src/main/res/layout/activity_log_detail_activity.xml index b3170cc798af..c24b080e7574 100644 --- a/WordPress/src/main/res/layout/activity_log_detail_activity.xml +++ b/WordPress/src/main/res/layout/activity_log_detail_activity.xml @@ -1,18 +1,15 @@ - - + + android:layout_height="match_parent" /> From 43bbb18e40da129df682665dda1ebf093259e511 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 16:36:25 -0800 Subject: [PATCH 106/761] Updated list activity. --- .../activitylog/list/ActivityLogListActivity.kt | 4 ++-- .../res/layout/activity_log_list_activity.xml | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) 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 4353df09a788..d5750d96957d 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 @@ -4,7 +4,7 @@ import android.content.Intent import android.os.Bundle import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity -import kotlinx.android.synthetic.main.toolbar.* +import kotlinx.android.synthetic.main.toolbar_main.* import org.wordpress.android.R import org.wordpress.android.ui.RequestCodes import org.wordpress.android.ui.posts.BasicFragmentDialog @@ -17,7 +17,7 @@ class ActivityLogListActivity : AppCompatActivity(), BasicFragmentDialog.BasicDi setContentView(R.layout.activity_log_list_activity) - setSupportActionBar(toolbar) + setSupportActionBar(toolbar_main) supportActionBar?.let { it.setHomeButtonEnabled(true) it.setDisplayHomeAsUpEnabled(true) diff --git a/WordPress/src/main/res/layout/activity_log_list_activity.xml b/WordPress/src/main/res/layout/activity_log_list_activity.xml index f319375f13e8..aa2d75b00b0f 100644 --- a/WordPress/src/main/res/layout/activity_log_list_activity.xml +++ b/WordPress/src/main/res/layout/activity_log_list_activity.xml @@ -1,19 +1,16 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> - + + android:layout_height="match_parent" /> From 605b34f5b930e576af8793b6d4bc296705278b29 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 18:54:17 -0800 Subject: [PATCH 107/761] Updated color in note span. --- .../ui/notifications/blocks/NoteBlockClickableSpan.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 829eb0faa69d..a3b3ed1bc770 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.wpColorText); + mTextColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorOnSurface); mBackgroundColor = ContextCompat.getColor(context, R.color.primary_5); - mLinkColor = ContextCompat.getColor(context, R.color.primary_40); - mLightTextColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.wpColorText); + mLinkColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorPrimary); + mLightTextColor = ContextExtensionsKt.getColorFromAttribute(context, R.attr.colorOnSurface); } public void setColors(@ColorInt int textColor, @ColorInt int backgroundColor, @ColorInt int linkColor, From e7f80bb220b6864f1236da83ea9c84b490690b4c Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 18:54:30 -0800 Subject: [PATCH 108/761] Using correct colors in event item view holder. --- .../ui/activitylog/list/EventItemViewHolder.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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 42e5d668ba69..139c51960071 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 @@ -9,6 +9,7 @@ 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.getColorFromAttribute class EventItemViewHolder( parent: ViewGroup, @@ -36,12 +37,16 @@ class EventItemViewHolder( text.text = activity.description if (activity.isButtonVisible) { - 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 - } + ContextCompat.getDrawable(container.context, activity.buttonIcon.drawable) + ?.let { buttonIcon -> + val wrapDrawable = DrawableCompat.wrap(buttonIcon).mutate() + DrawableCompat.setTint( + wrapDrawable, + container.context.getColorFromAttribute(R.attr.colorPrimary) + ) + actionButton.setImageDrawable(DrawableCompat.unwrap(wrapDrawable)) + actionButton.visibility = View.VISIBLE + } } else { actionButton.visibility = View.GONE } From c2071a171ffecbdeba4cac08c0e6ba20676223db Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 17 Dec 2019 18:54:41 -0800 Subject: [PATCH 109/761] Updated layouts. --- .../res/layout/activity_log_item_detail.xml | 56 ++++--- .../layout/activity_log_list_event_item.xml | 138 ++++++++---------- .../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 ++++----- 7 files changed, 144 insertions(+), 180 deletions(-) diff --git a/WordPress/src/main/res/layout/activity_log_item_detail.xml b/WordPress/src/main/res/layout/activity_log_item_detail.xml index beaccd2557a0..b2a417ed4f3c 100644 --- a/WordPress/src/main/res/layout/activity_log_item_detail.xml +++ b/WordPress/src/main/res/layout/activity_log_item_detail.xml @@ -1,11 +1,10 @@ - - + android:contentDescription="@null" + android:src="@drawable/bg_rectangle_neutral_10_user_32dp" /> + android:visibility="gone" /> + tools:text="John Smith" /> + android:textAppearance="?attr/textAppearanceCaption" + tools:text="Administrator" /> @@ -84,19 +81,19 @@ android:id="@+id/activityCreatedDate" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:textAppearance="@style/Base.TextAppearance.AppCompat.Caption" - android:textColor="?attr/wpColorText" + android:textAppearance="?attr/textAppearanceCaption" + android:textColor="?attr/colorOnSurface" tools:ignore="RelativeOverlap" - tools:text="January 8, 2018"/> + tools:text="January 8, 2018" /> + tools:text="11:32 PM" /> @@ -105,20 +102,19 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="24dp" - android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" - android:textColor="?attr/wpColorText" + android:focusable="true" android:linksClickable="true" - tools:text="Jetpack by WordPress.com autoupdated to 5.6" - android:focusable="true"/> + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:text="Jetpack by WordPress.com autoupdated to 5.6" /> + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textColor="?attr/wpColorOnSurfaceMedium" + tools:text="Plugin autoupdated" /> + android:tint="?attr/colorPrimary" /> + android:textAppearance="?attr/textAppearanceBody2" + android:textColor="?attr/colorPrimary" /> - + diff --git a/WordPress/src/main/res/layout/activity_log_list_event_item.xml b/WordPress/src/main/res/layout/activity_log_list_event_item.xml index 1bf4e4ed842c..dbba154d6ca0 100644 --- a/WordPress/src/main/res/layout/activity_log_list_event_item.xml +++ b/WordPress/src/main/res/layout/activity_log_list_event_item.xml @@ -1,92 +1,74 @@ - - + tools:layout_height="?attr/listPreferredItemHeightLarge"> - + - - + - - + - + android:ellipsize="end" + android:gravity="start" + android:singleLine="true" + android:textAlignment="viewStart" + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:text="Comment by oguzkocer on Android Studio 3.1 Configuration Issue: I think the bigger problem for me was the lack of make option, so hopefully at least that'll work." /> - - - - - - - + - - + - + - + diff --git a/WordPress/src/main/res/layout/activity_log_list_footer_item.xml b/WordPress/src/main/res/layout/activity_log_list_footer_item.xml index 94f8f8e95e9f..3bf98342cb3d 100644 --- a/WordPress/src/main/res/layout/activity_log_list_footer_item.xml +++ b/WordPress/src/main/res/layout/activity_log_list_footer_item.xml @@ -1,14 +1,12 @@ - - + android:textAppearance="?attr/textAppearanceBody1" + android:textColor="?attr/wpColorOnSurfaceMedium" /> diff --git a/WordPress/src/main/res/layout/activity_log_list_fragment.xml b/WordPress/src/main/res/layout/activity_log_list_fragment.xml index e6d27baaa880..ad00ead45766 100644 --- a/WordPress/src/main/res/layout/activity_log_list_fragment.xml +++ b/WordPress/src/main/res/layout/activity_log_list_fragment.xml @@ -1,15 +1,14 @@ - + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:layout_below="@id/toolbar_main"> diff --git a/WordPress/src/main/res/layout/activity_log_list_header_item.xml b/WordPress/src/main/res/layout/activity_log_list_header_item.xml index 815f9515823b..c4dd913cf074 100644 --- a/WordPress/src/main/res/layout/activity_log_list_header_item.xml +++ b/WordPress/src/main/res/layout/activity_log_list_header_item.xml @@ -1,18 +1,15 @@ - - + android:paddingEnd="@dimen/margin_extra_large" + android:paddingBottom="@dimen/margin_large" + android:textAppearance="?attr/textAppearanceBody2" + tools:text="Now" /> diff --git a/WordPress/src/main/res/layout/activity_log_list_loading_item.xml b/WordPress/src/main/res/layout/activity_log_list_loading_item.xml index 2e844f03ce14..79ddd8ee84da 100644 --- a/WordPress/src/main/res/layout/activity_log_list_loading_item.xml +++ b/WordPress/src/main/res/layout/activity_log_list_loading_item.xml @@ -1,21 +1,19 @@ - + android:layout_height="wrap_content" + android:minHeight="?attr/listPreferredItemHeightLarge"> - + tools:visibility="visible" /> diff --git a/WordPress/src/main/res/layout/activity_log_list_progress_item.xml b/WordPress/src/main/res/layout/activity_log_list_progress_item.xml index 0501ae244212..5d8e32bd20b1 100644 --- a/WordPress/src/main/res/layout/activity_log_list_progress_item.xml +++ b/WordPress/src/main/res/layout/activity_log_list_progress_item.xml @@ -1,94 +1,88 @@ - + tools:layout_height="?attr/listPreferredItemHeightLarge"> + android:background="?attr/selectableItemBackground"> - + android:src="@drawable/ic_notice_outline_white_24dp" /> + android:orientation="vertical"> - + tools:text="Rewinding to June 1 2018 12:22PM" /> - + tools:text="Rewind in progress" /> - + android:layout_alignParentBottom="true" + android:background="?android:attr/listDivider" /> + android:layout_alignParentBottom="true"> - + android:layout_marginBottom="@dimen/activity_progress_bar_margin_vertical" + android:background="@color/neutral_10" + android:indeterminate="true" + android:theme="@style/LinearProgress" /> From b4820c7936baa65034d0ea47c299f237c58dd2d0 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 18 Dec 2019 11:03:18 -0800 Subject: [PATCH 110/761] Removed manual color setting of appbar and fixed color of search hint. --- .../java/org/wordpress/android/ui/posts/PostsListActivity.kt | 3 --- WordPress/src/main/res/layout/post_list_activity.xml | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) 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 81f386a58dd0..a57daeeeaa64 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 @@ -30,7 +30,6 @@ 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 -import kotlinx.android.synthetic.main.post_list_activity.* import org.wordpress.android.R import org.wordpress.android.WordPress import org.wordpress.android.fluxc.Dispatcher @@ -173,8 +172,6 @@ class PostsListActivity : AppCompatActivity(), appbarElevation ) - appbar.setBackgroundColor(appBarColor) - val fadingEdgeDrawable = GradientDrawable( if (RtlUtils.isRtl(this)) { Orientation.LEFT_RIGHT diff --git a/WordPress/src/main/res/layout/post_list_activity.xml b/WordPress/src/main/res/layout/post_list_activity.xml index cf3b18d8986e..7b911a5f6191 100644 --- a/WordPress/src/main/res/layout/post_list_activity.xml +++ b/WordPress/src/main/res/layout/post_list_activity.xml @@ -7,7 +7,6 @@ android:layout_height="match_parent"> + android:elevation="0dp" + app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> Date: Wed, 18 Dec 2019 13:49:32 -0800 Subject: [PATCH 111/761] Moved activity detail out of card. --- .../res/layout/activity_log_item_detail.xml | 236 ++++++++---------- 1 file changed, 111 insertions(+), 125 deletions(-) diff --git a/WordPress/src/main/res/layout/activity_log_item_detail.xml b/WordPress/src/main/res/layout/activity_log_item_detail.xml index b2a417ed4f3c..db53979e995e 100644 --- a/WordPress/src/main/res/layout/activity_log_item_detail.xml +++ b/WordPress/src/main/res/layout/activity_log_item_detail.xml @@ -1,149 +1,135 @@ - + android:layout_height="match_parent" + android:padding="@dimen/margin_extra_large" + android:orientation="vertical"> - + android:orientation="horizontal"> + + + + - - - - - - - - - + android:ellipsize="end" + android:lines="1" + android:textAppearance="?attr/textAppearanceSubtitle2" + android:textColor="?attr/wpColorText" + tools:text="John Smith" /> - - - - - + - + - - - + + android:textAppearance="?attr/textAppearanceCaption" + android:textColor="?attr/colorOnSurface" + tools:ignore="RelativeOverlap" + tools:text="January 8, 2018" /> - - + android:textAppearance="?attr/textAppearanceCaption" + android:textColor="?attr/colorOnSurface" + tools:ignore="RelativeOverlap" + tools:text="11:32 PM" /> + + - + - - - - - + + + + + + + + + From 785dd33b07d4b8debc12f6b7e0774586a2581f55 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 18 Dec 2019 15:27:47 -0800 Subject: [PATCH 112/761] Updated style in manifest. --- WordPress/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index b75c43ce5c02..fdb412c5b716 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -530,12 +530,12 @@ + android:theme="@style/WordPress.NoActionBar"/> + android:theme="@style/WordPress.NoActionBar"/> Date: Wed, 18 Dec 2019 15:28:43 -0800 Subject: [PATCH 113/761] Added missing attributes and styles. --- .../src/main/res/values-night/styles.xml | 2 ++ WordPress/src/main/res/values/attrs.xml | 1 + WordPress/src/main/res/values/styles.xml | 19 ++++++++----------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/WordPress/src/main/res/values-night/styles.xml b/WordPress/src/main/res/values-night/styles.xml index 1bfb05413e74..e9a7c6739e00 100644 --- a/WordPress/src/main/res/values-night/styles.xml +++ b/WordPress/src/main/res/values-night/styles.xml @@ -15,10 +15,12 @@ @android:color/white @android:color/black ?attr/colorPrimary + ?attr/colorSecondary @android:color/white @color/neutral_50 @color/error_50 + @color/success_50 @color/warning_50 ?attr/colorSurface @color/material_on_surface_emphasis_medium diff --git a/WordPress/src/main/res/values/attrs.xml b/WordPress/src/main/res/values/attrs.xml index a27a74faa020..2227dffaec74 100644 --- a/WordPress/src/main/res/values/attrs.xml +++ b/WordPress/src/main/res/values/attrs.xml @@ -10,6 +10,7 @@ + diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 29e5338238c8..1e7479786dd5 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -17,7 +17,7 @@ @android:color/white @color/primary_dark - @color/accent + ?attr/colorSecondary @color/primary_30 @style/WordPress.ToolBar @@ -27,6 +27,7 @@ @color/neutral_70 @color/neutral @color/error + @color/success_50 @color/warning_50 @color/primary @color/material_on_surface_emphasis_medium @@ -685,7 +686,7 @@ @@ -738,8 +739,7 @@ wrap_content wrap_content center_vertical - ?attr/wpColorText - @dimen/text_sz_large + ?attr/textAppearanceSubtitle1 @@ -799,14 +798,12 @@ @dimen/margin_extra_large @dimen/margin_extra_large ?android:attr/selectableItemBackground - true - @color/primary_40 - @dimen/text_sz_medium - bold + ?attr/textAppearanceButton + ?attr/colorPrimary From ff53512e8daa5c8d69772d2dc54a3101896eaf12 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 18 Dec 2019 15:29:07 -0800 Subject: [PATCH 114/761] Updated plugin browser activity. --- .../ui/plugins/PluginBrowserActivity.java | 150 +++++++----------- .../res/layout/plugin_browser_activity.xml | 73 ++++----- .../main/res/layout/plugin_browser_row.xml | 28 ++-- 3 files changed, 102 insertions(+), 149 deletions(-) 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 09eef92f9eea..61267d881cc3 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 @@ -18,11 +18,10 @@ import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.content.res.AppCompatResources; 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; @@ -30,6 +29,7 @@ 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; @@ -40,6 +40,7 @@ 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; @@ -89,7 +90,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); + Toolbar toolbar = findViewById(R.id.toolbar_main); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { @@ -112,43 +113,20 @@ public void onCreate(Bundle savedInstanceState) { mViewModel.start(); // site plugin list - findViewById(R.id.text_manage).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showListFragment(PluginListType.SITE); - } - }); + findViewById(R.id.text_manage).setOnClickListener(v -> showListFragment(PluginListType.SITE)); // featured plugin list - findViewById(R.id.text_all_featured).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showListFragment(PluginListType.FEATURED); - } - }); + findViewById(R.id.text_all_featured).setOnClickListener(v -> showListFragment(PluginListType.FEATURED)); // popular plugin list - findViewById(R.id.text_all_popular).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showListFragment(PluginListType.POPULAR); - } - }); + findViewById(R.id.text_all_popular).setOnClickListener(v -> showListFragment(PluginListType.POPULAR)); // new plugin list - findViewById(R.id.text_all_new).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showListFragment(PluginListType.NEW); - } - }); + findViewById(R.id.text_all_new).setOnClickListener(v -> showListFragment(PluginListType.NEW)); - getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { - @Override - public void onBackStackChanged() { - if (getSupportFragmentManager().getBackStackEntryCount() == 0) { - mViewModel.setTitle(getString(R.string.plugins)); - } + getSupportFragmentManager().addOnBackStackChangedListener(() -> { + if (getSupportFragmentManager().getBackStackEntryCount() == 0) { + mViewModel.setTitle(getString(R.string.plugins)); } }); @@ -161,67 +139,50 @@ public void onBackStackChanged() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); mViewModel.writeToBundle(outState); } private void setupObservers() { - mViewModel.getTitle().observe(this, new Observer() { - @Override - public void onChanged(@Nullable String title) { - setTitle(title); - } - }); + mViewModel.getTitle().observe(this, title -> setTitle(title)); mViewModel.getSitePluginsLiveData() - .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); - } + .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); } } }); mViewModel.getFeaturedPluginsLiveData() - .observe(this, new Observer>() { - @Override - public void onChanged(@Nullable ListState listState) { - if (listState != null) { - reloadPluginAdapterAndVisibility(PluginListType.FEATURED, listState); - } + .observe(this, listState -> { + if (listState != null) { + reloadPluginAdapterAndVisibility(PluginListType.FEATURED, listState); } }); mViewModel.getPopularPluginsLiveData() - .observe(this, new Observer>() { - @Override - public void onChanged(@Nullable ListState listState) { - if (listState != null) { - reloadPluginAdapterAndVisibility(PluginListType.POPULAR, listState); - } + .observe(this, listState -> { + if (listState != null) { + reloadPluginAdapterAndVisibility(PluginListType.POPULAR, listState); } }); mViewModel.getNewPluginsLiveData() - .observe(this, new Observer>() { - @Override - public void onChanged(@Nullable ListState listState) { - if (listState != null) { - reloadPluginAdapterAndVisibility(PluginListType.NEW, listState); - } + .observe(this, listState -> { + if (listState != null) { + reloadPluginAdapterAndVisibility(PluginListType.NEW, listState); } }); } @@ -331,7 +292,7 @@ public boolean onQueryTextChange(String query) { private void showListFragment(@NonNull PluginListType listType) { PluginListFragment listFragment = PluginListFragment.newInstance(mViewModel.getSite(), listType); getSupportFragmentManager().beginTransaction() - .add(R.id.fragment_container, listFragment, PluginListFragment.TAG) + .replace(R.id.fragment_container, listFragment, PluginListFragment.TAG) .addToBackStack(null) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE) .commit(); @@ -398,14 +359,15 @@ public long getItemId(int position) { return mItems.getItemId(position); } + @NotNull @Override - public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) { View view = mLayoutInflater.inflate(R.layout.plugin_browser_row, parent, false); return new PluginBrowserViewHolder(view); } @Override - public void onBindViewHolder(ViewHolder viewHolder, int position) { + public void onBindViewHolder(@NotNull ViewHolder viewHolder, int position) { PluginBrowserViewHolder holder = (PluginBrowserViewHolder) viewHolder; ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); if (plugin == null) { @@ -423,23 +385,28 @@ public void onBindViewHolder(ViewHolder viewHolder, int position) { boolean isAutoManaged = PluginUtils.isAutoManaged(mViewModel.getSite(), plugin); if (isAutoManaged) { textResId = R.string.plugin_auto_managed; - colorResId = R.color.success_50; + colorResId = ContextExtensionsKt + .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); drawableResId = android.R.color.transparent; } else if (PluginUtils.isUpdateAvailable(plugin)) { textResId = R.string.plugin_needs_update; - colorResId = R.color.warning_50; + colorResId = ContextExtensionsKt + .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorWarningDark); drawableResId = R.drawable.ic_sync_white_24dp; } else if (plugin.isActive()) { textResId = R.string.plugin_active; - colorResId = R.color.success_50; + colorResId = ContextExtensionsKt + .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); drawableResId = R.drawable.ic_checkmark_white_24dp; } else { textResId = R.string.plugin_inactive; - colorResId = R.color.neutral_30; + colorResId = ContextExtensionsKt + .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorOnSurfaceMedium); drawableResId = R.drawable.ic_cross_white_24dp; } holder.mStatusText.setText(textResId); - holder.mStatusText.setTextColor(getResources().getColor(colorResId)); + holder.mStatusText.setTextColor( + AppCompatResources.getColorStateList(holder.mStatusText.getContext(), colorResId)); holder.mStatusIcon.setVisibility(isAutoManaged ? View.GONE : View.VISIBLE); ColorUtils.INSTANCE.setImageResourceWithTint(holder.mStatusIcon, drawableResId, colorResId); holder.mStatusContainer.setVisibility(View.VISIBLE); @@ -471,18 +438,15 @@ private class PluginBrowserViewHolder extends ViewHolder { mStatusText = mStatusContainer.findViewById(R.id.plugin_status_text); mStatusIcon = mStatusContainer.findViewById(R.id.plugin_status_icon); - 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()); + view.setOnClickListener(v -> { + int position = getAdapterPosition(); + ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); + if (plugin == null) { + return; } + + ActivityLauncher.viewPluginDetail(PluginBrowserActivity.this, mViewModel.getSite(), + plugin.getSlug()); }); } } diff --git a/WordPress/src/main/res/layout/plugin_browser_activity.xml b/WordPress/src/main/res/layout/plugin_browser_activity.xml index ea751e4bb030..e3462c12bade 100644 --- a/WordPress/src/main/res/layout/plugin_browser_activity.xml +++ b/WordPress/src/main/res/layout/plugin_browser_activity.xml @@ -1,13 +1,12 @@ + layout="@layout/toolbar_main" /> - - + android:layout_toStartOf="@+id/text_manage" + android:text="@string/plugin_caption_installed" /> - + style="@style/PluginDirectoryList" + android:layout_below="@+id/text_manage" /> - + - + android:layout_toStartOf="@+id/text_all_featured" + android:text="@string/plugin_caption_featured" /> - + style="@style/PluginDirectoryList" + android:layout_below="@+id/text_all_featured" /> - + - - + android:layout_toStartOf="@+id/text_all_popular" + android:text="@string/plugin_caption_popular" /> - + style="@style/PluginDirectoryList" + android:layout_below="@+id/text_all_popular" /> - + - - + android:layout_toStartOf="@+id/text_all_new" + android:text="@string/plugin_caption_new" /> - + style="@style/PluginDirectoryList" + android:layout_below="@+id/text_all_new" /> - + diff --git a/WordPress/src/main/res/layout/plugin_browser_row.xml b/WordPress/src/main/res/layout/plugin_browser_row.xml index f44aa8a826dd..f588ea043025 100644 --- a/WordPress/src/main/res/layout/plugin_browser_row.xml +++ b/WordPress/src/main/res/layout/plugin_browser_row.xml @@ -4,9 +4,9 @@ android:layout_width="@dimen/plugin_row_width" android:layout_height="match_parent" android:background="?android:attr/selectableItemBackground" - android:paddingBottom="@dimen/margin_small" + android:paddingStart="@dimen/margin_medium" android:paddingEnd="@dimen/margin_medium" - android:paddingStart="@dimen/margin_medium" > + android:paddingBottom="@dimen/margin_small"> - + tools:ignore="UnusedAttribute" + tools:text="plugin_name" /> - + tools:tint="?attr/wpColorWarningDark" /> - From c8a2652373733d373478d8d1526839032856acd5 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 18 Dec 2019 15:34:57 -0800 Subject: [PATCH 115/761] Updated plugin detail activity. --- .../ui/plugins/PluginDetailActivity.java | 277 ++++++------------ .../res/layout/plugin_detail_activity.xml | 217 +++++++------- 2 files changed, 196 insertions(+), 298 deletions(-) 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 e73a27e689f8..3ee9533b2291 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 @@ -5,19 +5,15 @@ 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; @@ -39,6 +35,9 @@ 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; @@ -261,6 +260,18 @@ 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(); @@ -353,24 +364,17 @@ public static class DomainRegistrationPromptDialog extends DialogFragment { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); 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, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (isAdded() && getActivity() instanceof OnDomainRegistrationRequestedListener) { - ((OnDomainRegistrationRequestedListener) getActivity()).onDomainRegistrationRequested(); - } + (dialogInterface, i) -> { + if (isAdded() && getActivity() instanceof OnDomainRegistrationRequestedListener) { + ((OnDomainRegistrationRequestedListener) getActivity()).onDomainRegistrationRequested(); } }); builder.setNegativeButton(R.string.cancel, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - } + (dialogInterface, i) -> { }); builder.setCancelable(true); @@ -430,7 +434,7 @@ public boolean onOptionsItemSelected(final MenuItem item) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); outState.putString(KEY_PLUGIN_SLUG, mSlug); @@ -470,30 +474,18 @@ private void setupViews() { mDescriptionTextView = findViewById(R.id.plugin_description_text); mDescriptionChevron = findViewById(R.id.plugin_description_chevron); - findViewById(R.id.plugin_description_container).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - toggleText(mDescriptionTextView, mDescriptionChevron); - } - }); + findViewById(R.id.plugin_description_container).setOnClickListener( + 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(new View.OnClickListener() { - @Override - public void onClick(View v) { - toggleText(mInstallationTextView, mInstallationChevron); - } - }); + findViewById(R.id.plugin_installation_container).setOnClickListener( + 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(new View.OnClickListener() { - @Override - public void onClick(View v) { - toggleText(mWhatsNewTextView, mWhatsNewChevron); - } - }); + findViewById(R.id.plugin_whatsnew_container).setOnClickListener( + 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 @@ -505,100 +497,56 @@ public void onClick(View v) { mFaqTextView = findViewById(R.id.plugin_faq_text); mFaqChevron = findViewById(R.id.plugin_faq_chevron); - findViewById(R.id.plugin_faq_container).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - toggleText(mFaqTextView, mFaqChevron); - } - }); + findViewById(R.id.plugin_faq_container).setOnClickListener(v -> toggleText(mFaqTextView, mFaqChevron)); - findViewById(R.id.plugin_version_layout).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - showPluginInfoPopup(); - } - }); + findViewById(R.id.plugin_version_layout).setOnClickListener(v -> showPluginInfoPopup()); - 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); - } + mSwitchActive.setOnCheckedChangeListener((compoundButton, isChecked) -> { + if (compoundButton.isPressed()) { + if (NetworkUtils.checkConnection(PluginDetailActivity.this)) { + mIsActive = isChecked; + dispatchConfigurePluginAction(false); + } else { + compoundButton.setChecked(mIsActive); } } }); - 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); - } + mSwitchAutoupdates.setOnCheckedChangeListener((compoundButton, isChecked) -> { + if (compoundButton.isPressed()) { + if (NetworkUtils.checkConnection(PluginDetailActivity.this)) { + mIsAutoUpdateEnabled = isChecked; + dispatchConfigurePluginAction(false); + } else { + compoundButton.setChecked(mIsAutoUpdateEnabled); } } }); - mUpdateButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - dispatchUpdatePluginAction(); - } - }); + mUpdateButton.setOnClickListener(view -> dispatchUpdatePluginAction()); - mInstallButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (isCustomDomainRequired()) { - showDomainCreditsCheckProgressDialog(); - mDispatcher.dispatch(SiteActionBuilder.newFetchPlansAction(mSite)); - } else { - dispatchInstallPluginAction(); - } + mInstallButton.setOnClickListener(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(new View.OnClickListener() { - @Override - public void onClick(View v) { - openUrl(mPlugin.getSettingsUrl()); - } - }); + settingsView.setOnClickListener(v -> openUrl(mPlugin.getSettingsUrl())); } else { settingsView.setVisibility(View.GONE); } - findViewById(R.id.plugin_wp_org_page).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - openUrl(getWpOrgPluginUrl()); - } - }); + findViewById(R.id.plugin_wp_org_page).setOnClickListener(view -> openUrl(getWpOrgPluginUrl())); - findViewById(R.id.plugin_home_page).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - openUrl(mPlugin.getHomepageUrl()); - } - }); + findViewById(R.id.plugin_home_page).setOnClickListener(view -> openUrl(mPlugin.getHomepageUrl())); - findViewById(R.id.read_reviews_container).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - openUrl(getWpOrgReviewsUrl()); - } - }); + findViewById(R.id.read_reviews_container).setOnClickListener(view -> openUrl(getWpOrgReviewsUrl())); // set the height of the gradient scrim that appears atop the banner image int toolbarHeight = DisplayUtils.getActionBarHeight(this); @@ -662,11 +610,12 @@ private void refreshViews() { private void setCollapsibleHtmlText(@NonNull TextView textView, @Nullable String htmlText) { if (!TextUtils.isEmpty(htmlText)) { - textView.setTextColor(ContextExtensionsKt.getColorFromAttribute(this, R.attr.wpColorText)); + textView.setTextColor(ContextExtensionsKt.getColorFromAttribute(this, R.attr.colorOnSurface)); textView.setMovementMethod(WPLinkMovementMethod.getInstance()); textView.setText(Html.fromHtml(htmlText)); } else { - textView.setTextColor(getResources().getColor(R.color.neutral_20)); + textView.setTextColor( + ContextExtensionsKt.getColorStateListFromAttribute(this, R.attr.wpColorOnSurfaceMedium)); textView.setText(R.string.plugin_empty_text); } } @@ -811,14 +760,9 @@ protected void showPluginInfoPopup() { from, to); - AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Calypso_Dialog_Alert); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); builder.setCancelable(true); - builder.setAdapter(adapter, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); + builder.setAdapter(adapter, (dialog, which) -> dialog.dismiss()); builder.show(); } @@ -845,31 +789,19 @@ protected void openUrl(@Nullable String url) { } private void confirmRemovePlugin() { - AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Calypso_Dialog_Alert); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); 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, 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.setPositiveButton(R.string.remove, (dialogInterface, i) -> { + mIsShowingRemovePluginConfirmationDialog = false; + disableAndRemovePlugin(); }); + builder.setNegativeButton(R.string.cancel, + (dialogInterface, i) -> mIsShowingRemovePluginConfirmationDialog = false); + builder.setOnCancelListener(dialogInterface -> mIsShowingRemovePluginConfirmationDialog = false); builder.setCancelable(true); builder.create(); mIsShowingRemovePluginConfirmationDialog = true; @@ -900,24 +832,14 @@ private void showSuccessfulPluginRemovedSnackbar() { private void showUpdateFailedSnackbar() { WPSnackbar.make(mContainer, getString(R.string.plugin_updated_failed, mPlugin.getDisplayName()), Snackbar.LENGTH_LONG) - .setAction(R.string.retry, new View.OnClickListener() { - @Override - public void onClick(View view) { - dispatchUpdatePluginAction(); - } - }) + .setAction(R.string.retry, view -> dispatchUpdatePluginAction()) .show(); } private void showInstallFailedSnackbar() { WPSnackbar.make(mContainer, getString(R.string.plugin_installed_failed, mPlugin.getDisplayName()), Snackbar.LENGTH_LONG) - .setAction(R.string.retry, new View.OnClickListener() { - @Override - public void onClick(View view) { - dispatchInstallPluginAction(); - } - }) + .setAction(R.string.retry, view -> dispatchInstallPluginAction()) .show(); } @@ -1303,30 +1225,21 @@ private boolean isPluginStateChangedSinceLastConfigurationDispatch() { * UI for it, so we get a confirmation first in this step. */ private void confirmInstallPluginForAutomatedTransfer() { - AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.Calypso_Dialog_Alert); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(this); 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, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - mIsShowingInstallFirstPluginConfirmationDialog = false; - startAutomatedTransfer(); - } + (dialogInterface, i) -> { + mIsShowingInstallFirstPluginConfirmationDialog = false; + startAutomatedTransfer(); }); - 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.setNegativeButton(R.string.cancel, (dialogInterface, i) -> { + 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.setOnCancelListener(dialogInterface -> { + AnalyticsUtils.trackWithSiteDetails(Stat.AUTOMATED_TRANSFER_CONFIRM_DIALOG_CANCELLED, mSite); + mIsShowingInstallFirstPluginConfirmationDialog = false; }); builder.setCancelable(true); builder.create(); @@ -1515,13 +1428,10 @@ 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(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)); - } + mHandler.postDelayed(() -> { + 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); } } @@ -1562,14 +1472,11 @@ 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(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)); - } + 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)); }, DEFAULT_RETRY_DELAY_MS); } } @@ -1635,13 +1542,9 @@ public void onPluginDirectoryFetched(OnPluginDirectoryFetched event) { } private void fetchPluginDirectory(int delay) { - mHandler.postDelayed(new Runnable() { - @Override - public void run() { - mDispatcher.dispatch(PluginActionBuilder.newFetchPluginDirectoryAction(new PluginStore - .FetchPluginDirectoryPayload(PluginDirectoryType.SITE, mSite, false))); - } - }, delay); + mHandler.postDelayed( + () -> mDispatcher.dispatch(PluginActionBuilder.newFetchPluginDirectoryAction(new PluginStore + .FetchPluginDirectoryPayload(PluginDirectoryType.SITE, mSite, false))), delay); } private String getEligibilityErrorMessage(String errorCode) { diff --git a/WordPress/src/main/res/layout/plugin_detail_activity.xml b/WordPress/src/main/res/layout/plugin_detail_activity.xml index 9883ab1b059e..aab30cf7d528 100644 --- a/WordPress/src/main/res/layout/plugin_detail_activity.xml +++ b/WordPress/src/main/res/layout/plugin_detail_activity.xml @@ -1,12 +1,11 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/plugin_detail_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:fitsSystemWindows="false"> @@ -42,12 +40,12 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="top" - android:contentDescription="@null" android:background="@drawable/media_settings_gradient_scrim" + android:contentDescription="@null" tools:layout_height="74dp" /> - - + + android:layout_toEndOf="@+id/image_icon" + android:orientation="vertical"> - + tools:text="text_title" /> - + android:textAppearance="?attr/textAppearanceBody2" + android:textColorLink="?attr/colorPrimary" + tools:text="text_byline" /> + android:layout_width="match_parent" + android:layout_height="wrap_content"> + android:paddingBottom="@dimen/margin_extra_large" + tools:ignore="RtlSymmetry"> - + app:drawableTint="?attr/colorOnSurface" + tools:text="plugin_version_top" /> - + tools:text="plugin_version_bottom" /> + android:paddingStart="@dimen/margin_extra_large" + android:paddingEnd="@dimen/margin_extra_large"> - + tools:visibility="visible" /> - + tools:visibility="visible" /> - - + - + style="@style/PluginCardView"> - + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> - + - - + - + + + + + + + + style="@style/PluginCardViewSecondaryElement" + android:theme="@style/SwitchBlueMedium" /> - + - + - + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> - + - + style="@style/PluginCardViewHorizontalContainer" + android:background="?attr/selectableItemBackground"> - + + + + + + + + + android:background="?attr/selectableItemBackground"> + android:background="?attr/selectableItemBackground"> - + - + style="@style/PluginCardView"> + android:background="?attr/selectableItemBackground"> + android:background="?attr/selectableItemBackground"> + android:background="?attr/selectableItemBackground"> + android:background="?attr/selectableItemBackground"> - + From 688387e1c921e53ac55fd9ecda6aec5991df0f15 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 18 Dec 2019 15:35:40 -0800 Subject: [PATCH 116/761] Updated plugin list and couple of extra layouts. --- .../ui/plugins/PluginListFragment.java | 118 ++++++++---------- .../android/ui/plugins/PluginUtils.java | 4 +- .../android/util/ContextExtensions.kt | 7 ++ .../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 | 117 ++++++++--------- 7 files changed, 136 insertions(+), 144 deletions(-) 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 9fdcbbeaf560..42e685d1428b 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,6 +25,7 @@ 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; @@ -32,13 +33,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; @@ -92,58 +93,43 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { private void setupObservers() { mViewModel.getSitePluginsLiveData() - .observe(this, new Observer>() { - @Override - public void onChanged(@Nullable ListState listState) { - if (mListType == PluginListType.SITE) { - refreshPluginsAndProgressBars(listState); - } + .observe(this, listState -> { + if (mListType == PluginListType.SITE) { + refreshPluginsAndProgressBars(listState); } }); mViewModel.getFeaturedPluginsLiveData() - .observe(this, new Observer>() { - @Override - public void onChanged(@Nullable ListState listState) { - if (mListType == PluginListType.FEATURED) { - refreshPluginsAndProgressBars(listState); - } + .observe(this, listState -> { + if (mListType == PluginListType.FEATURED) { + refreshPluginsAndProgressBars(listState); } }); mViewModel.getPopularPluginsLiveData() - .observe(this, new Observer>() { - @Override - public void onChanged(@Nullable ListState listState) { - if (mListType == PluginListType.POPULAR) { - refreshPluginsAndProgressBars(listState); - } + .observe(this, listState -> { + if (mListType == PluginListType.POPULAR) { + refreshPluginsAndProgressBars(listState); } }); mViewModel.getNewPluginsLiveData() - .observe(this, new Observer>() { - @Override - public void onChanged(@Nullable ListState listState) { - if (mListType == PluginListType.NEW) { - refreshPluginsAndProgressBars(listState); - } + .observe(this, listState -> { + if (mListType == PluginListType.NEW) { + refreshPluginsAndProgressBars(listState); } }); mViewModel.getSearchResultsLiveData() - .observe(this, new Observer>() { - @Override - public void onChanged(@Nullable ListState listState) { - if (mListType == PluginListType.SEARCH) { - refreshPluginsAndProgressBars(listState); + .observe(this, listState -> { + if (mListType == PluginListType.SEARCH) { + refreshPluginsAndProgressBars(listState); - if (listState instanceof ListState.Error) { - ToastUtils.showToast(getActivity(), R.string.plugin_search_error); - } - - showEmptyView(mViewModel.shouldShowEmptySearchResultsView()); + if (listState instanceof ListState.Error) { + ToastUtils.showToast(getActivity(), R.string.plugin_search_error); } + + showEmptyView(mViewModel.shouldShowEmptySearchResultsView()); } }); } @@ -157,27 +143,24 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mRecycler.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL)); mSwipeToRefreshHelper = buildSwipeToRefreshHelper( - (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); - } + view.findViewById(R.id.ptr_layout), + () -> { + if (NetworkUtils.checkConnection(getActivity())) { + mViewModel.pullToRefresh(mListType); + } else { + mSwipeToRefreshHelper.setRefreshing(false); } }); return view; } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(Menu menu, @NotNull MenuInflater inflater) { menu.clear(); super.onCreateOptionsMenu(menu, inflater); } - public PluginListType getListType() { + PluginListType getListType() { return mListType; } @@ -243,14 +226,15 @@ public int getItemCount() { return mItems.size(); } + @NotNull @Override - public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) { View view = mLayoutInflater.inflate(R.layout.plugin_list_row, parent, false); return new PluginViewHolder(view); } @Override - public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { + public void onBindViewHolder(@NotNull RecyclerView.ViewHolder viewHolder, int position) { ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); if (plugin == null) { return; @@ -267,24 +251,29 @@ public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { @DrawableRes int drawableResId; if (PluginUtils.isAutoManaged(mViewModel.getSite(), plugin)) { textResId = R.string.plugin_auto_managed; - colorResId = R.color.success_50; + colorResId = ContextExtensionsKt + .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); drawableResId = android.R.color.transparent; } else if (PluginUtils.isUpdateAvailable(plugin)) { textResId = R.string.plugin_needs_update; - colorResId = R.color.warning_50; + colorResId = ContextExtensionsKt + .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorWarningDark); drawableResId = R.drawable.ic_sync_white_24dp; } else if (plugin.isActive()) { textResId = R.string.plugin_active; - colorResId = R.color.success_50; + colorResId = ContextExtensionsKt + .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); drawableResId = R.drawable.ic_checkmark_white_24dp; } else { textResId = R.string.plugin_inactive; - colorResId = R.color.neutral_30; + colorResId = ContextExtensionsKt + .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorOnSurfaceMedium); drawableResId = R.drawable.ic_cross_white_24dp; } - int color = getResources().getColor(colorResId); + holder.mStatusText.setText(textResId); - holder.mStatusText.setTextColor(color); + holder.mStatusText.setTextColor( + AppCompatResources.getColorStateList(holder.mStatusText.getContext(), colorResId)); ColorUtils.INSTANCE.setImageResourceWithTint(holder.mStatusIcon, drawableResId, colorResId); holder.mStatusText.setVisibility(View.VISIBLE); holder.mStatusIcon.setVisibility(View.VISIBLE); @@ -318,18 +307,15 @@ private class PluginViewHolder extends RecyclerView.ViewHolder { mIcon = view.findViewById(R.id.plugin_icon); mRatingBar = view.findViewById(R.id.rating_bar); - 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()); + view.setOnClickListener(v -> { + int position = getAdapterPosition(); + ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); + if (plugin == null) { + return; } + + 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 51afcdf8ce8d..90de4fdc97da 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) } } - public static boolean isJetpack(@NonNull ImmutablePluginModel plugin) { + static boolean isJetpack(@NonNull ImmutablePluginModel plugin) { return StringUtils.equals(plugin.getName(), JETPACK_PLUGIN_NAME); } - public static boolean isAutoManaged(@NonNull SiteModel site, @NonNull ImmutablePluginModel plugin) { + static boolean isAutoManaged(@NonNull SiteModel site, @NonNull ImmutablePluginModel plugin) { if (!site.isAutomatedTransfer()) { return false; } diff --git a/WordPress/src/main/java/org/wordpress/android/util/ContextExtensions.kt b/WordPress/src/main/java/org/wordpress/android/util/ContextExtensions.kt index 1bacef160417..e69351334a72 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/ContextExtensions.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/ContextExtensions.kt @@ -1,10 +1,12 @@ package org.wordpress.android.util import android.content.Context +import android.content.res.ColorStateList import android.util.TypedValue import androidx.annotation.AttrRes import androidx.annotation.ColorInt import androidx.annotation.ColorRes +import androidx.appcompat.content.res.AppCompatResources import androidx.core.os.ConfigurationCompat import java.util.Locale @@ -22,6 +24,11 @@ fun Context.getColorFromAttribute(@AttrRes attribute: Int) = it.data } +fun Context.getColorStateListFromAttribute(@AttrRes attribute: Int): ColorStateList = + getColorResIdFromAttribute(attribute).let { + AppCompatResources.getColorStateList(this, it) + } + // https://developer.android.com/reference/android/content/res/Configuration.html#locale val Context.currentLocale: Locale get() = ConfigurationCompat.getLocales(resources.configuration)[0] diff --git a/WordPress/src/main/res/layout/plugin_info_row.xml b/WordPress/src/main/res/layout/plugin_info_row.xml index 9ec81ca8e951..d85c65a36153 100644 --- a/WordPress/src/main/res/layout/plugin_info_row.xml +++ b/WordPress/src/main/res/layout/plugin_info_row.xml @@ -5,8 +5,8 @@ android:layout_height="wrap_content" android:minHeight="@dimen/min_touch_target_sz" android:orientation="horizontal" - android:paddingEnd="@dimen/margin_extra_large" - android:paddingStart="@dimen/margin_extra_large"> + android:paddingStart="@dimen/margin_extra_large" + android:paddingEnd="@dimen/margin_extra_large"> diff --git a/WordPress/src/main/res/layout/plugin_list_fragment.xml b/WordPress/src/main/res/layout/plugin_list_fragment.xml index 906bdb8d1c50..e3526c0cb886 100644 --- a/WordPress/src/main/res/layout/plugin_list_fragment.xml +++ b/WordPress/src/main/res/layout/plugin_list_fragment.xml @@ -3,7 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@android:color/white"> + android:background="?android:attr/colorBackground"> + android:paddingTop="@dimen/margin_extra_large" + android:paddingEnd="@dimen/margin_extra_large" + android:paddingBottom="@dimen/margin_extra_large"> - @@ -67,7 +65,7 @@ tools:src="@drawable/ic_sync_white_24dp" tools:tint="@color/warning_50" /> - - + style="@style/PluginCardView"> - + android:layout_alignTop="@+id/read_reviews_container" + android:layout_alignBottom="@+id/read_reviews_container" + android:gravity="center_vertical" + android:orientation="vertical"> + + + + android:orientation="horizontal"> + android:src="@drawable/ic_external_white_24dp" + android:tint="?attr/colorPrimary" /> + - + android:textAppearance="?attr/textAppearanceCaption" + android:textSize="@dimen/text_sz_medium" /> + tools:ignore="UnusedAttribute" /> @@ -91,14 +97,14 @@ android:layout_marginTop="@dimen/margin_medium" android:orientation="horizontal"> - + android:textAppearance="?attr/textAppearanceCaption" + android:textSize="@dimen/text_sz_medium" /> + android:progress="25" /> @@ -118,14 +123,14 @@ android:layout_marginTop="@dimen/margin_medium" android:orientation="horizontal"> - + android:textAppearance="?attr/textAppearanceCaption" + android:textSize="@dimen/text_sz_medium" /> + android:progress="10" /> @@ -145,14 +149,14 @@ android:layout_marginTop="@dimen/margin_medium" android:orientation="horizontal"> - + android:textAppearance="?attr/textAppearanceCaption" + android:textSize="@dimen/text_sz_medium" /> + android:progress="10" /> @@ -172,14 +175,14 @@ android:layout_marginTop="@dimen/margin_medium" android:orientation="horizontal"> - + android:textAppearance="?attr/textAppearanceCaption" + android:textSize="@dimen/text_sz_medium" /> + android:progress="0" /> @@ -200,25 +202,26 @@ android:layout_below="@+id/plugin_ratings_container" android:layout_marginTop="@dimen/margin_large"> - - + tools:text="text_num_downloads" /> - + From 9cf5f5b2e2fb1d15415c0b5c31ae8d6d091284f1 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 18 Dec 2019 18:36:28 -0800 Subject: [PATCH 117/761] Removed unused button. --- WordPress/src/main/res/values/styles.xml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 1e7479786dd5..df92d4d9920e 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -262,12 +262,7 @@ - - - + + + + + - - - - - - From 0a2d82b892d6ebe06581af187ddd40cf2cd9fd02 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 6 Jan 2020 13:27:10 -0800 Subject: [PATCH 148/761] removed line from edit comment activity. --- WordPress/src/main/res/layout/comment_edit_activity.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/WordPress/src/main/res/layout/comment_edit_activity.xml b/WordPress/src/main/res/layout/comment_edit_activity.xml index c220c75513b2..8de871a4546b 100644 --- a/WordPress/src/main/res/layout/comment_edit_activity.xml +++ b/WordPress/src/main/res/layout/comment_edit_activity.xml @@ -39,6 +39,7 @@ Date: Mon, 6 Jan 2020 13:27:40 -0800 Subject: [PATCH 149/761] Updated colors of comment action icon and labels. --- .../ui/comments/CommentDetailFragment.java | 13 +++++ .../main/res/layout/comment_action_footer.xml | 50 ++++--------------- WordPress/src/main/res/values/styles.xml | 12 +++++ 3 files changed, 35 insertions(+), 40 deletions(-) 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 7132d4105ee1..24fcdb14e651 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 @@ -22,6 +22,7 @@ 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; @@ -144,6 +145,8 @@ 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; @@ -248,6 +251,8 @@ 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); @@ -1068,10 +1073,14 @@ private void setModerateButtonForStatus(CommentStatus status) { color = ContextExtensionsKt .getColorResIdFromAttribute(mBtnModerateTextView.getContext(), R.attr.colorSecondary); mBtnModerateTextView.setText(R.string.comment_status_approved); + mBtnModerateTextView.setAlpha(mNormalOpacity); + mBtnModerateIcon.setAlpha(mNormalOpacity); } else { color = ContextExtensionsKt .getColorResIdFromAttribute(mBtnModerateTextView.getContext(), R.attr.colorOnSurface); mBtnModerateTextView.setText(R.string.mnu_comment_approve); + mBtnModerateTextView.setAlpha(mMediumOpacity); + mBtnModerateIcon.setAlpha(mMediumOpacity); } ColorUtils.INSTANCE.setImageResourceWithTint(mBtnModerateIcon, R.drawable.ic_checkmark_white_24dp, color); @@ -1201,11 +1210,15 @@ private void toggleLikeButton(boolean isLiked) { 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); 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); } diff --git a/WordPress/src/main/res/layout/comment_action_footer.xml b/WordPress/src/main/res/layout/comment_action_footer.xml index 34c9b82e4785..296f19132b9f 100644 --- a/WordPress/src/main/res/layout/comment_action_footer.xml +++ b/WordPress/src/main/res/layout/comment_action_footer.xml @@ -31,15 +31,9 @@ + android:src="@drawable/ic_checkmark_white_24dp" /> + android:src="@drawable/ic_spam_white_24dp" /> + android:src="@drawable/ic_trash_white_24dp" /> + android:src="@drawable/ic_star_outline_white_24dp" /> + android:src="@drawable/ic_pencil_white_24dp" /> 1 ?attr/textAppearanceCaption ?attr/colorOnSurface + @dimen/material_emphasis_medium + + + - diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 0cbad848980b..881625a53e13 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -239,7 +239,7 @@ - - - - - - From 0622996f4c7c6d1a790cb396396713fa07e069de Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 13:34:21 -0800 Subject: [PATCH 162/761] Cleaning up. --- .../ui/comments/CommentDetailFragment.java | 2 -- .../android/ui/comments/CommentDialogs.java | 6 ++--- .../ui/comments/EditCommentActivity.java | 26 +++++++++---------- 3 files changed, 16 insertions(+), 18 deletions(-) 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 24fcdb14e651..2ce4c68d5efe 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 @@ -281,7 +281,6 @@ 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); @@ -1221,7 +1220,6 @@ private void toggleLikeButton(boolean isLiked) { mBtnLikeIcon.setAlpha(mMediumOpacity); } - ColorUtils.INSTANCE.setImageResourceWithTint(mBtnLikeIcon, drawable, color); mBtnLikeTextView.setTextColor(ContextCompat.getColor(requireContext(), 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 9819e5979a3b..c9d9eeaaa45f 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,9 +10,9 @@ * Dialogs related to comment moderation displayed from CommentsActivity and NotificationsActivity */ class CommentDialogs { - private static final int ID_COMMENT_DLG_APPROVING = 100; - private static final int ID_COMMENT_DLG_DISAPPROVING = 101; - private static final int ID_COMMENT_DLG_SPAMMING = 102; + 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; 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 253bb049e6de..fc7332180de1 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 @@ -272,14 +272,14 @@ private void dismissSaveDialog() { } private void showEditErrorAlert() { - MaterialAlertDialogBuilder dialog = new MaterialAlertDialogBuilder(this); - dialog.setTitle(getResources().getText(R.string.error)); - dialog.setMessage(R.string.error_edit_comment); - dialog.setPositiveButton(android.R.string.ok, (dialog1, whichButton) -> { + MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(this); + 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 }); - dialog.setCancelable(true); - dialog.create().show(); + dialogBuilder.setCancelable(true); + dialogBuilder.create().show(); } private void setFetchProgressVisible(boolean progressVisible) { @@ -309,19 +309,19 @@ private void cancelEditCommentConfirmation() { return; } - MaterialAlertDialogBuilder dialog = new MaterialAlertDialogBuilder(this); - dialog.setTitle(getResources().getText(R.string.cancel_edit)); - dialog.setMessage(getResources().getText(R.string.sure_to_cancel_edit_comment)); - dialog.setPositiveButton(getResources().getText(R.string.yes), + MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(this); + 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), (dialog12, whichButton) -> finish()); - dialog.setNegativeButton( + dialogBuilder.setNegativeButton( getResources().getText(R.string.no), (dialog1, whichButton) -> { // just close the dialog }); - dialog.setCancelable(true); + dialogBuilder.setCancelable(true); - mCancelEditCommentDialog = dialog.create(); + mCancelEditCommentDialog = dialogBuilder.create(); mCancelEditCommentDialog.show(); } From 53b021b05c2f7967911e92ce99a7339450c9a9e7 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 13:34:41 -0800 Subject: [PATCH 163/761] Reverted changes to comments bg used with notifications. --- .../drawable-ldrtl/comment_reply_background.xml | 14 +++++++++++--- .../main/res/drawable/comment_reply_background.xml | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/res/drawable-ldrtl/comment_reply_background.xml b/WordPress/src/main/res/drawable-ldrtl/comment_reply_background.xml index 3c236734b29c..74289e26f9ab 100644 --- a/WordPress/src/main/res/drawable-ldrtl/comment_reply_background.xml +++ b/WordPress/src/main/res/drawable-ldrtl/comment_reply_background.xml @@ -1,16 +1,24 @@ - + + + + + - + - + + + + + diff --git a/WordPress/src/main/res/drawable/comment_reply_background.xml b/WordPress/src/main/res/drawable/comment_reply_background.xml index 45bb40c8aac9..b0418d2d6821 100644 --- a/WordPress/src/main/res/drawable/comment_reply_background.xml +++ b/WordPress/src/main/res/drawable/comment_reply_background.xml @@ -1,16 +1,24 @@ - + + + + + - + - + + + + + From 18f190c363c463f4a20b07fa20be693dc5950e4b Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:36:15 -0800 Subject: [PATCH 164/761] Updated site settings fragment. --- .../ui/prefs/BlogPreferencesActivity.java | 7 +- .../ui/prefs/SiteSettingsFragment.java | 399 +++++++----------- .../res/layout/site_settings_activity.xml | 14 + 3 files changed, 169 insertions(+), 251 deletions(-) create mode 100644 WordPress/src/main/res/layout/site_settings_activity.xml 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 0b556512a861..11bc19b17be1 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 @@ -7,6 +7,7 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import org.apache.commons.text.StringEscapeUtils; import org.greenrobot.eventbus.EventBus; @@ -49,6 +50,7 @@ protected void attachBaseContext(Context newBase) { 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); @@ -62,6 +64,9 @@ public void onCreate(Bundle savedInstanceState) { return; } + Toolbar toolbar = findViewById(R.id.toolbar_main); + setSupportActionBar(toolbar); + ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); @@ -79,7 +84,7 @@ public void onCreate(Bundle savedInstanceState) { siteSettingsFragment = new SiteSettingsFragment(); siteSettingsFragment.setArguments(getIntent().getExtras()); fragmentManager.beginTransaction() - .replace(android.R.id.content, siteSettingsFragment, KEY_SETTINGS_FRAGMENT) + .replace(R.id.fragment_container, siteSettingsFragment, KEY_SETTINGS_FRAGMENT) .commit(); } } 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 80f0c316b3f9..71c0ee683f32 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,11 +1,9 @@ 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; @@ -21,20 +19,17 @@ 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; @@ -43,13 +38,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.android.volley.VolleyError; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; 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; @@ -74,6 +69,7 @@ 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; @@ -327,12 +323,9 @@ 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(new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - disconnectFromJetpack(); - return true; - } + disconnectPref.setOnPreferenceClickListener(preference -> { + disconnectFromJetpack(); + return true; }); parent.addPreference(disconnectPref); } @@ -359,12 +352,9 @@ public void onResume() { mSiteSettings.init(false); if (mShouldFetch) { - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - // initialize settings with locally cached values, fetch remote on first pass - mSiteSettings.init(true); - } + new Handler().postDelayed(() -> { + // 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; @@ -400,13 +390,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: @@ -439,10 +429,8 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { break; } } else { - switch (requestCode) { - case DELETE_SITE_REQUEST_CODE: - deleteSite(); - break; + if (requestCode == DELETE_SITE_REQUEST_CODE) { + deleteSite(); } } @@ -460,12 +448,10 @@ public View onCreateView(@NonNull LayoutInflater inflater, getActivity().getActionBar().setDisplayShowHomeEnabled(true); } - Context themer = new ContextThemeWrapper(getActivity(), R.style.Calypso_SiteSettingsTheme); - LayoutInflater localInflater = inflater.cloneInContext(themer); - View view = super.onCreateView(localInflater, container, savedInstanceState); + View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) { - setupPreferenceList((ListView) view.findViewById(android.R.id.list), getResources()); + setupPreferenceList(view.findViewById(android.R.id.list), getResources()); } return view; @@ -542,7 +528,7 @@ public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference prefere dialog.dismiss(); WPWebViewActivity.openUrlByUsingGlobalWPCOMCredentials(getActivity(), WORDPRESS_EMPTY_SITE_SUPPORT_URL); } else { - setupPreferenceList((ListView) dialog.findViewById(android.R.id.list), getResources()); + setupPreferenceList(dialog.findViewById(android.R.id.list), getResources()); String title = getString(R.string.start_over); WPActivityUtils.addToolbarToDialog(this, dialog, title); } @@ -568,15 +554,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) { @@ -602,29 +588,19 @@ public boolean onPreferenceClick(Preference preference) { } private void disconnectFromJetpack() { - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); builder.setMessage(R.string.jetpack_disconnect_confirmation_message); - 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.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.setNegativeButton(android.R.string.cancel, null); builder.show(); @@ -694,15 +670,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) { @@ -715,8 +691,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()); @@ -732,9 +708,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()); @@ -745,13 +721,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) { @@ -810,7 +786,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; @@ -888,8 +864,7 @@ private void setupPreferenceList(ListView prefList, Resources res) { } // customize list dividers - //noinspection deprecation - prefList.setDivider(res.getDrawable(R.drawable.bg_rectangle_divider)); + prefList.setDivider(ContextUtilsKt.getDrawableFromAttribute(getActivity(), android.R.attr.listDivider)); prefList.setDividerHeight(res.getDimensionPixelSize(R.dimen.site_settings_divider_height)); // handle long clicks on preferences to display hints prefList.setOnItemLongClickListener(this); @@ -897,7 +872,6 @@ private void setupPreferenceList(ListView prefList, Resources res) { prefList.setOnHierarchyChangeListener(this); // remove footer divider bar prefList.setFooterDividersEnabled(false); - //noinspection deprecation prefList.setOverscrollFooter(res.getDrawable(android.R.color.transparent)); } @@ -1105,32 +1079,24 @@ 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", new Formatter() { - @Override - public String format(int value) { - return mSiteSettings.getThreadingDescriptionForLevel(value); - } - }); + showNumberPickerDialog(args, THREADING_REQUEST_CODE, "threading-dialog", + value -> mSiteSettings.getThreadingDescriptionForLevel(value)); } private void showExportContentDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); 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, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_EXPORT_SITE_REQUESTED, mSite); - exportSite(); - } + builder.setPositiveButton(R.string.site_settings_export_content_title, (dialog, which) -> { + AnalyticsUtils.trackWithSiteDetails(Stat.SITE_SETTINGS_EXPORT_SITE_REQUESTED, mSite); + exportSite(); }); builder.setNegativeButton(R.string.cancel, null); @@ -1167,23 +1133,17 @@ 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(), new RestRequest.Listener() { - @Override - public void onResponse(JSONObject response) { - dismissProgressDialog(progressDialog); - if (isAdded()) { - showPurchasesOrDeleteSiteDialog(response); - } + WordPress.getRestClientUtils().getSitePurchases(mSite.getSiteId(), response -> { + dismissProgressDialog(progressDialog); + if (isAdded()) { + showPurchasesOrDeleteSiteDialog(response); } - }, 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()); - } + }, 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()); } }); } @@ -1202,24 +1162,15 @@ private void showPurchasesOrDeleteSiteDialog(JSONObject response) { } private void showPurchasesDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); builder.setTitle(R.string.premium_upgrades_title); builder.setMessage(R.string.premium_upgrades_message); - 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.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.setNegativeButton(getString(R.string.cancel), (dialog, which) -> dialog.dismiss()); builder.show(); AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.SITE_SETTINGS_DELETE_SITE_PURCHASES_SHOWN, mSite); } @@ -1242,19 +1193,13 @@ private void showDeleteSiteWarningDialog() { return; } - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); 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, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - showDeleteSiteDialog(); - } - }); + builder.setPositiveButton(R.string.yes, (dialog, which) -> showDeleteSiteDialog()); builder.setNegativeButton(R.string.cancel, null); builder.show(); } @@ -1278,9 +1223,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); @@ -1307,24 +1252,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()); @@ -1545,7 +1490,7 @@ public void changeEditTextPreferenceValue(EditTextPreference pref, String newVal return; } - if (!newValue.equals(pref.getSummary())) { + if (!newValue.contentEquals(pref.getSummary())) { String formattedValue = StringEscapeUtils.unescapeHtml4(newValue.replaceFirst(ADDRESS_FORMAT_REGEX, "")); pref.setText(formattedValue); @@ -1607,8 +1552,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() { @@ -1620,7 +1565,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))); @@ -1628,11 +1573,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.Calypso_SiteSettingsTheme); + mDialog = new Dialog(getActivity(), R.style.WordPress); mDialog.setOnDismissListener(this); mDialog.setTitle(titleRes); mDialog.setContentView(getListEditorView(getString(headerRes))); @@ -1641,12 +1586,11 @@ private void showListEditorDialog(int titleRes, int headerRes) { } private View getListEditorView(String headerText) { - Context themer = new ContextThemeWrapper(getActivity(), R.style.Calypso_SiteSettingsTheme); - View view = View.inflate(themer, R.layout.list_editor, null); + View view = View.inflate(getActivity(), R.layout.list_editor, null); ((TextView) view.findViewById(R.id.list_editor_header_text)).setText(headerText); mAdapter = null; - final EmptyViewRecyclerView list = view.findViewById(android.R.id.list); + final EmptyViewRecyclerView list = view.findViewById(R.id.list); list.setLayoutManager( new SmoothScrollLinearLayoutManager( getActivity(), @@ -1654,7 +1598,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( @@ -1689,74 +1633,47 @@ public void onLongItemClick(View view, int position) { ) ); FloatingActionButton button = view.findViewById(R.id.fab_button); - 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( - 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); + button.setOnClickListener(v -> { + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); + 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, (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; } - }); - 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); + + 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); } - } + }); + 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(new OnLongClickListener() { - @Override public boolean onLongClick(View view) { - if (view.isHapticFeedbackEnabled()) { - view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - } - - Toast.makeText(view.getContext(), R.string.add, Toast.LENGTH_SHORT).show(); - return true; + button.setOnLongClickListener(view1 -> { + if (view1.isHapticFeedbackEnabled()) { + view1.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } + + Toast.makeText(view1.getContext(), R.string.add, Toast.LENGTH_SHORT).show(); + return true; }); ViewUtilsKt.redirectContextClickToLongPressListener(button); @@ -1804,7 +1721,7 @@ private void setupJetpackSecurityScreen() { String title = getString(R.string.jetpack_security_setting_title); Dialog dialog = mJpSecuritySettings.getDialog(); if (dialog != null) { - setupPreferenceList((ListView) dialog.findViewById(android.R.id.list), getResources()); + setupPreferenceList(dialog.findViewById(android.R.id.list), getResources()); WPActivityUtils.addToolbarToDialog(this, dialog, title); } } @@ -1957,27 +1874,21 @@ 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(), 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(); - } + 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(); } - }, 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); - } + }, 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); } }); } @@ -1994,7 +1905,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; @@ -2015,28 +1926,18 @@ public void handleDeleteSiteError(DeleteSiteError error) { } private void showDeleteSiteErrorDialog() { - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); builder.setTitle(R.string.error_deleting_site); builder.setMessage(R.string.error_deleting_site_summary); - 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.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); + builder.setPositiveButton(R.string.contact_support, + (dialog, which) -> mZendeskHelper.createNewTicket(getActivity(), Origin.DELETE_SITE, mSite)); builder.show(); } private MultiSelectRecyclerViewAdapter getAdapter() { if (mAdapter == null) { - mAdapter = new MultiSelectRecyclerViewAdapter(getActivity(), mEditingList); + mAdapter = new MultiSelectRecyclerViewAdapter(mEditingList); } return mAdapter; @@ -2052,7 +1953,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); @@ -2079,7 +1980,6 @@ 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); @@ -2088,7 +1988,6 @@ 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; } @@ -2098,7 +1997,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/res/layout/site_settings_activity.xml b/WordPress/src/main/res/layout/site_settings_activity.xml new file mode 100644 index 000000000000..74e2ee4b0e5d --- /dev/null +++ b/WordPress/src/main/res/layout/site_settings_activity.xml @@ -0,0 +1,14 @@ + + + + + + + + From 8d48c2879a1f6f5713f17bd6e2ecca0c1cd1f1f3 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:36:33 -0800 Subject: [PATCH 165/761] Updated manifest for preference activities. --- WordPress/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index b98e311b208e..a858dd5e8900 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -150,7 +150,7 @@ android:configChanges="orientation|screenSize" android:label="@string/settings" android:launchMode="singleTop" - android:theme="@style/CalypsoTheme" /> + android:theme="@style/WordPress.NoActionBar" /> Date: Wed, 8 Jan 2020 20:37:18 -0800 Subject: [PATCH 166/761] Updated detail list preference. --- .../ui/prefs/DetailListPreference.java | 75 ++++--------------- .../res/layout/detail_list_preference.xml | 42 +++++------ .../layout/detail_list_preference_title.xml | 20 ++--- 3 files changed, 41 insertions(+), 96 deletions(-) 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 2b690ed1d67b..59ccd0353038 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,22 +8,21 @@ 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; @@ -63,20 +62,6 @@ 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()); @@ -92,7 +77,7 @@ public CharSequence getEntry() { protected void showDialog(Bundle state) { Context context = getContext(); Resources res = context.getResources(); - AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.Calypso_Dialog_Alert); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE; builder.setPositiveButton(android.R.string.ok, this); @@ -107,16 +92,12 @@ protected void showDialog(Bundle state) { mSelectedIndex = findIndexOfValue(mStartingValue); builder.setSingleChoiceItems(mListAdapter, mSelectedIndex, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - mSelectedIndex = which; - } - }); + (dialog, which) -> mSelectedIndex = which); View titleView = View.inflate(getContext(), R.layout.detail_list_preference_title, null); if (titleView != null) { - TextView titleText = (TextView) titleView.findViewById(R.id.title); + TextView titleText = titleView.findViewById(R.id.title); if (titleText != null) { titleText.setText(getTitle()); } @@ -126,9 +107,7 @@ public void onClick(DialogInterface dialog, int which) { builder.setTitle(getTitle()); } - if ((mDialog = builder.create()) == null) { - return; - } + mDialog = builder.create(); if (state != null) { mDialog.onRestoreInstanceState(state); @@ -137,8 +116,6 @@ public void onClick(DialogInterface dialog, int which) { 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); @@ -146,16 +123,6 @@ public void onClick(DialogInterface dialog, int which) { 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); } @@ -215,32 +182,21 @@ 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, ViewGroup parent) { + public View getView(final int position, View convertView, @NotNull ViewGroup parent) { if (convertView == null) { convertView = View.inflate(getContext(), R.layout.detail_list_preference, null); } - 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); + final RadioButton radioButton = convertView.findViewById(R.id.radio); + TextView mainText = convertView.findViewById(R.id.main_text); + TextView detailText = convertView.findViewById(R.id.detail_text); if (mainText != null && getEntries() != null && position < getEntries().length) { mainText.setText(getEntries()[position]); @@ -259,12 +215,7 @@ public View getView(final int position, View convertView, ViewGroup parent) { radioButton.setChecked(mSelectedIndex == position); } - convertView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - changeSelection(position); - } - }); + convertView.setOnClickListener(v -> changeSelection(position)); return convertView; } diff --git a/WordPress/src/main/res/layout/detail_list_preference.xml b/WordPress/src/main/res/layout/detail_list_preference.xml index 5e16016f414a..0fec2e93cd80 100644 --- a/WordPress/src/main/res/layout/detail_list_preference.xml +++ b/WordPress/src/main/res/layout/detail_list_preference.xml @@ -1,58 +1,52 @@ - + android:paddingEnd="@dimen/dlp_padding_end" + android:paddingBottom="@dimen/dlp_padding_bottom"> - - + android:clickable="false" + android:focusable="false" + android:focusableInTouchMode="false" /> + android:layout_toEndOf="@id/radio" + android:orientation="vertical"> - - diff --git a/WordPress/src/main/res/layout/detail_list_preference_title.xml b/WordPress/src/main/res/layout/detail_list_preference_title.xml index 1564ed1db2df..52f61616992c 100644 --- a/WordPress/src/main/res/layout/detail_list_preference_title.xml +++ b/WordPress/src/main/res/layout/detail_list_preference_title.xml @@ -1,22 +1,22 @@ - + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:paddingTop="@dimen/margin_extra_medium_large" + android:paddingBottom="@dimen/margin_extra_medium_large"> + android:textAppearance="?attr/textAppearanceHeadline6" /> From 4026f884127ec7d974b22c3095b7ba6082d06778 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:38:35 -0800 Subject: [PATCH 167/761] Updated number picker dialog. --- .../android/ui/prefs/NumberPickerDialog.java | 25 +++------------ .../main/res/layout/number_picker_dialog.xml | 32 +++++++++---------- 2 files changed, 19 insertions(+), 38 deletions(-) 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 8f401f82e8ff..9032f18a5412 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,7 +2,6 @@ import android.annotation.SuppressLint; import android.app.Activity; -import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.DialogInterface; @@ -10,20 +9,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, @@ -56,8 +55,7 @@ public NumberPickerDialog() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); 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); @@ -114,21 +112,6 @@ 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/res/layout/number_picker_dialog.xml b/WordPress/src/main/res/layout/number_picker_dialog.xml index d119d6afb75b..9fc9b363c56f 100644 --- a/WordPress/src/main/res/layout/number_picker_dialog.xml +++ b/WordPress/src/main/res/layout/number_picker_dialog.xml @@ -9,22 +9,20 @@ android:id="@+id/number_picker_switch" android:layout_width="match_parent" android:layout_height="wrap_content" - android:textSize="@dimen/text_sz_large" - android:textColor="@color/neutral_70_neutral_20_selector" - android:layout_marginEnd="24dp" android:layout_marginStart="24dp" + android:layout_marginEnd="24dp" + android:gravity="start" android:textAlignment="viewStart" - android:theme="@style/SwitchBlueMedium" - android:gravity="start"/> + android:textAppearance="?attr/textAppearanceSubtitle1" + android:theme="@style/SwitchBlueMedium" /> + android:layout_marginEnd="24dp" + android:textAppearance="?attr/textAppearanceCaption" /> + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textColor="@color/on_surface_disabled_selector" /> + android:layout_height="@dimen/divider_size" + android:background="?android:attr/listDivider" /> + android:theme="@style/NumberPickerTheme" /> + android:layout_height="@dimen/divider_size" + android:background="?android:attr/listDivider" /> From 7e90565235dece1f719f09db6e34fce1402bc982 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:39:22 -0800 Subject: [PATCH 168/761] Updated summary edit text preference. --- .../ui/prefs/SummaryEditTextPreference.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) 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 b6321a6a454f..d8b3b1dd3046 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,7 +14,6 @@ import android.view.ViewGroup; import android.view.ViewParent; import android.view.WindowManager; -import android.widget.Button; import android.widget.EditText; import android.widget.TextView; @@ -23,6 +22,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; @@ -86,8 +87,8 @@ public SummaryEditTextPreference(Context context, AttributeSet attrs) { protected void onBindView(@NonNull View view) { super.onBindView(view); - TextView titleView = (TextView) view.findViewById(android.R.id.title); - TextView summaryView = (TextView) view.findViewById(android.R.id.summary); + TextView titleView = view.findViewById(android.R.id.title); + TextView summaryView = view.findViewById(android.R.id.summary); if (titleView != null) WPPrefUtils.layoutAsSubhead(titleView); @@ -109,14 +110,14 @@ public Dialog getDialog() { protected void showDialog(Bundle state) { Context context = getContext(); Resources res = context.getResources(); - AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.Calypso_Dialog_Alert); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context); 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 = (TextView) titleView.findViewById(R.id.title); + TextView titleText = titleView.findViewById(R.id.title); if (titleText != null) { titleText.setText(getDialogTitle()); } @@ -136,7 +137,7 @@ protected void showDialog(Bundle state) { builder.setView(view); } - if ((mDialog = builder.create()) == null) return; + mDialog = builder.create(); if (state != null) { mDialog.onRestoreInstanceState(state); @@ -144,11 +145,6 @@ 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 @@ -163,7 +159,7 @@ protected void onBindDialogView(final View view) { 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); } From b12ec00db70462710718b7854381d0c2707cbb8d Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:40:18 -0800 Subject: [PATCH 169/761] Updated related posst dialog. --- .../android/ui/prefs/RelatedPostsDialog.java | 31 ++--- .../main/res/layout/related_posts_dialog.xml | 107 ++++++++---------- 2 files changed, 54 insertions(+), 84 deletions(-) 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 9d8eb1174f96..2a71df6698eb 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,16 +1,13 @@ 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; @@ -18,10 +15,12 @@ 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; @@ -73,9 +72,9 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { mRelatedPostsList = v.findViewById(R.id.related_posts_list); mPreviewImages = new ArrayList<>(); - 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)); + 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)); Bundle args = getArguments(); if (args != null) { @@ -93,8 +92,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { toggleViews(mShowRelatedPosts.isChecked()); - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); //noinspection InflateParams View titleView = inflater.inflate(R.layout.detail_list_preference_title, null); TextView titleText = titleView.findViewById(R.id.title); @@ -109,21 +107,6 @@ 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/res/layout/related_posts_dialog.xml b/WordPress/src/main/res/layout/related_posts_dialog.xml index 20e507a6a841..f93a1090d947 100644 --- a/WordPress/src/main/res/layout/related_posts_dialog.xml +++ b/WordPress/src/main/res/layout/related_posts_dialog.xml @@ -1,34 +1,29 @@ - + android:paddingTop="@dimen/site_settings_divider_height" + android:paddingBottom="@dimen/site_settings_divider_height"> + android:paddingBottom="@dimen/related_posts_dialog_padding_bottom"> + android:textAppearance="?attr/textAppearanceSubtitle1" /> + android:textSize="@dimen/text_sz_small" /> - + android:textSize="@dimen/text_sz_large" /> - + android:textSize="@dimen/text_sz_large" /> + android:background="?android:attr/listDivider" /> + android:textAppearance="?attr/textAppearanceSubtitle2" + android:textStyle="italic|bold" /> + android:textAppearance="?attr/textAppearanceSubtitle2" + android:textColor="@color/on_surface_disabled_selector" + android:textStyle="bold" /> + android:layout_height="wrap_content" + android:orientation="vertical"> + android:textAppearance="?attr/textAppearanceSubtitle2" + android:textStyle="bold" /> + android:text="@string/site_settings_rp_preview1_site" + android:textAppearance="?attr/textAppearanceCaption" + android:textStyle="italic" /> + android:textAppearance="?attr/textAppearanceSubtitle2" + android:textStyle="bold" /> + android:text="@string/site_settings_rp_preview2_site" + android:textAppearance="?attr/textAppearanceCaption" + android:textStyle="italic" /> + android:textAppearance="?attr/textAppearanceSubtitle2" + android:textStyle="bold" /> + android:text="@string/site_settings_rp_preview3_site" + android:textAppearance="?attr/textAppearanceCaption" + android:textStyle="italic" /> From f8d1d0f19872c130b1b8500c4709aab375e93a97 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:40:55 -0800 Subject: [PATCH 170/761] Updated site settings format dialog. --- .../ui/prefs/SiteSettingsFormatDialog.java | 30 ++++++------------- .../layout/site_settings_format_dialog.xml | 29 ++++++++---------- 2 files changed, 22 insertions(+), 37 deletions(-) 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 fa56c8daa20e..5d33db9aec07 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,7 +1,6 @@ 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; @@ -9,17 +8,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.core.widget.CompoundButtonCompat; + +import com.google.android.material.dialog.MaterialAlertDialogBuilder; +import com.google.android.material.radiobutton.MaterialRadioButton; import org.wordpress.android.Constants; import org.wordpress.android.R; @@ -104,15 +103,10 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { ? R.string.site_settings_date_format_title : R.string.site_settings_time_format_title; txtTitle.setText(titleRes); - txtHelp.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - ActivityLauncher.openUrlExternal(v.getContext(), Constants.URL_DATETIME_FORMAT_HELP); - } - }); + txtHelp.setOnClickListener( + v -> ActivityLauncher.openUrlExternal(v.getContext(), Constants.URL_DATETIME_FORMAT_HELP)); - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(R.string.cancel, this); builder.setView(view); @@ -125,9 +119,7 @@ private void createRadioButtons() { int margin = getResources().getDimensionPixelSize(R.dimen.margin_small); for (int i = 0; i < mEntries.length; i++) { - RadioButton radio = new RadioButton(getActivity()); - CompoundButtonCompat.setButtonTintList(radio, - getResources().getColorStateList(R.color.primary_40_gray_20_gray_40_selector)); + MaterialRadioButton radio = new MaterialRadioButton(getActivity()); radio.setText(mEntries[i]); radio.setId(i); mRadioGroup.addView(radio); @@ -143,12 +135,8 @@ private void createRadioButtons() { } } - mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(RadioGroup group, int checkedId) { - mEditCustomFormat.setEnabled(isCustomFormatEntry(mEntries[checkedId])); - } - }); + mRadioGroup.setOnCheckedChangeListener( + (group, checkedId) -> mEditCustomFormat.setEnabled(isCustomFormatEntry(mEntries[checkedId]))); } @Override diff --git a/WordPress/src/main/res/layout/site_settings_format_dialog.xml b/WordPress/src/main/res/layout/site_settings_format_dialog.xml index 16e73b14cbc0..e2cae130dae8 100644 --- a/WordPress/src/main/res/layout/site_settings_format_dialog.xml +++ b/WordPress/src/main/res/layout/site_settings_format_dialog.xml @@ -8,14 +8,14 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + android:text="@string/site_settings_date_format_title" + android:textAppearance="?attr/textAppearanceHeadline6" /> + android:paddingEnd="@dimen/margin_extra_large" /> - + android:inputType="text" + android:paddingStart="@dimen/margin_small" /> - + android:textAppearance="?attr/textAppearanceCaption" + android:textColor="?attr/colorPrimary" />
From fdfc2c0610c0ef7338a94dc344917208b1b26447 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:42:10 -0800 Subject: [PATCH 171/761] Updated site settings tags. --- .../ui/prefs/SiteSettingsTagListActivity.java | 81 ++++++---------- .../site_settings_tag_detail_fragment.xml | 94 ++++++++----------- .../site_settings_tag_list_activity.xml | 82 ++++++++-------- .../res/layout/site_settings_tag_list_row.xml | 30 +++--- 4 files changed, 126 insertions(+), 161 deletions(-) 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 3eadd233db69..a813581b9fbf 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,6 +1,5 @@ package org.wordpress.android.ui.prefs; -import android.app.AlertDialog; import android.app.FragmentTransaction; import android.app.ProgressDialog; import android.content.Context; @@ -9,14 +8,11 @@ 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; @@ -25,14 +21,19 @@ 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; @@ -54,7 +55,6 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.List; import java.util.Locale; @@ -98,6 +98,10 @@ 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); @@ -118,21 +122,14 @@ public void onCreate(Bundle savedInstanceState) { } mFabView = findViewById(R.id.fab_button); - mFabView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - showDetailFragment(null); + mFabView.setOnClickListener(view -> showDetailFragment(null)); + 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.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); @@ -142,11 +139,7 @@ public void onClick(View view) { } mActionableEmptyView = findViewById(R.id.actionable_empty_view); - mActionableEmptyView.button.setOnClickListener(new OnClickListener() { - @Override public void onClick(View view) { - showDetailFragment(null); - } - }); + mActionableEmptyView.button.setOnClickListener(view -> showDetailFragment(null)); mRecycler = findViewById(R.id.recycler); mRecycler.setHasFixedSize(true); @@ -188,7 +181,7 @@ public void onStop() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NotNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); outState.putBoolean(KEY_IS_SEARCHING, mIsSearching); @@ -249,12 +242,9 @@ 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(new Runnable() { - @Override - public void run() { - if (!isFinishing() && mFabView.getVisibility() != View.VISIBLE) { - AniUtils.scaleIn(mFabView, AniUtils.Duration.MEDIUM); - } + new Handler().postDelayed(() -> { + if (!isFinishing() && mFabView.getVisibility() != View.VISIBLE) { + AniUtils.scaleIn(mFabView, AniUtils.Duration.MEDIUM); } }, delayMs); } @@ -263,13 +253,10 @@ 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(new Runnable() { - @Override - public void run() { - if (!mIsSearching && !isDetailFragmentShowing() - && mActionableEmptyView.getVisibility() != View.VISIBLE) { - showFabIfHidden(); - } + new Handler().postDelayed(() -> { + if (!mIsSearching && !isDetailFragmentShowing() + && mActionableEmptyView.getVisibility() != View.VISIBLE) { + showFabIfHidden(); } }, delayMs); } @@ -306,11 +293,7 @@ public void onTaxonomyChanged(OnTaxonomyChanged event) { private void loadTags() { List tags = mTaxonomyStore.getTagsForSite(mSite); - Collections.sort(tags, new Comparator() { - public int compare(TermModel t1, TermModel t2) { - return StringUtils.compareIgnoreCase(t1.getName(), t2.getName()); - } - }); + Collections.sort(tags, (t1, t2) -> StringUtils.compareIgnoreCase(t1.getName(), t2.getName())); mAdapter = new TagListAdapter(tags); mRecycler.setAdapter(mAdapter); } @@ -420,8 +403,7 @@ 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 AlertDialog.Builder( - new ContextThemeWrapper(this, R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(this); dialogBuilder.setMessage(message); dialogBuilder.setPositiveButton( getResources().getText(R.string.delete_yes), @@ -518,13 +500,10 @@ class TagViewHolder extends RecyclerView.ViewHolder { super(view); mTxtTag = view.findViewById(R.id.text_tag); mTxtCount = view.findViewById(R.id.text_count); - view.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (!isDetailFragmentShowing()) { - int position = getAdapterPosition(); - showDetailFragment(mFilteredTags.get(position)); - } + view.setOnClickListener(view1 -> { + if (!isDetailFragmentShowing()) { + int position = getAdapterPosition(); + showDetailFragment(mFilteredTags.get(position)); } }); } diff --git a/WordPress/src/main/res/layout/site_settings_tag_detail_fragment.xml b/WordPress/src/main/res/layout/site_settings_tag_detail_fragment.xml index ac03b792e912..f50ec8e67079 100644 --- a/WordPress/src/main/res/layout/site_settings_tag_detail_fragment.xml +++ b/WordPress/src/main/res/layout/site_settings_tag_detail_fragment.xml @@ -1,67 +1,51 @@ - + android:layout_height="wrap_content" + android:layout_marginBottom="@dimen/margin_large" + android:background="?android:attr/colorBackground" + android:orientation="vertical" + android:padding="@dimen/margin_extra_large"> - + android:hint="@string/tag_name_hint" + android:importantForAccessibility="no"> - - - - - - - + android:gravity="start" + android:hint="@string/tag_name_hint" + android:inputType="textCapSentences|textAutoCorrect" + android:textAlignment="viewStart" + android:textColorHint="@android:color/transparent" + tools:text="edit_name" /> - + - + - - - - + + + + diff --git a/WordPress/src/main/res/layout/site_settings_tag_list_activity.xml b/WordPress/src/main/res/layout/site_settings_tag_list_activity.xml index c27332e6c4a6..0205a996114d 100644 --- a/WordPress/src/main/res/layout/site_settings_tag_list_activity.xml +++ b/WordPress/src/main/res/layout/site_settings_tag_list_activity.xml @@ -1,49 +1,51 @@ - - - - - + android:orientation="vertical"> - - + - - + android:layout_height="match_parent"> + + + + + + - - + - + + diff --git a/WordPress/src/main/res/layout/site_settings_tag_list_row.xml b/WordPress/src/main/res/layout/site_settings_tag_list_row.xml index b1deacb2e13e..d91011f8944e 100644 --- a/WordPress/src/main/res/layout/site_settings_tag_list_row.xml +++ b/WordPress/src/main/res/layout/site_settings_tag_list_row.xml @@ -5,43 +5,43 @@ android:layout_height="wrap_content" android:background="?android:selectableItemBackground"> - + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:text="text_tag" /> - + android:paddingBottom="@dimen/margin_medium" + android:textAppearance="?attr/textAppearanceCaption" + android:textColor="?attr/colorPrimary" + tools:text="5" /> + android:background="?android:attr/listDivider" /> From 47cf248b70a7e04b6ae77d24ee23d8a89067d4a3 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:46:39 -0800 Subject: [PATCH 172/761] Updated timezone dialog. --- .../ui/prefs/SiteSettingsTimezoneDialog.java | 103 +++++++++--------- .../layout/site_settings_timezone_dialog.xml | 13 +-- 2 files changed, 55 insertions(+), 61 deletions(-) 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 541b4f9179c2..b3f2b1ad3196 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,19 +1,17 @@ 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; @@ -23,13 +21,13 @@ import android.widget.TextView; import androidx.annotation.NonNull; +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; @@ -39,12 +37,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; @@ -89,14 +87,11 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { View view = mInflater.inflate(R.layout.site_settings_timezone_dialog, null); mListView = view.findViewById(R.id.list); - 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(); - } + mListView.setOnItemClickListener((parent, view1, position, id) -> { + Timezone tz = (Timezone) mAdapter.getItem(position); + mSelectedTimezone = tz.mValue; + mAdapter.notifyDataSetChanged(); + hideSearchKeyboard(); }); mSearchView = view.findViewById(R.id.search_view); @@ -125,8 +120,7 @@ public boolean onQueryTextChange(String newText) { mEmptyView = view.findViewById(R.id.empty_view); mProgressView = view.findViewById(R.id.progress_view); - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getActivity()); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(R.string.cancel, this); builder.setView(view); @@ -138,35 +132,29 @@ public boolean onQueryTextChange(String newText) { } private void requestTimezones() { - 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.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.ErrorListener errorListener = new Response.ErrorListener() { - @Override - public void onErrorResponse(VolleyError error) { - AppLog.e(AppLog.T.SETTINGS, "Error requesting timezones", error); - if (isAdded()) { - dismissWithError(); - } + Response.ErrorListener errorListener = 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() throws AuthFailureError { + protected Map getParams() { return RestClientUtils.getRestLocaleParams(getActivity()); } }; @@ -196,29 +184,22 @@ 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, new Comparator() { - public int compare(Timezone t1, Timezone t2) { - return StringUtils.compare(t1.mLabel, t2.mLabel); - } - }); + Collections.sort(timezones, (t1, t2) -> StringUtils.compare(t1.mLabel, t2.mLabel)); - mAdapter = new TimezoneAdapter(timezones); + mAdapter = new TimezoneAdapter(timezones, mListView.getContext()); mListView.setAdapter(mAdapter); mSearchView.setEnabled(true); // give the list time to load before making the selection - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - if (isAdded()) { - int index = mAdapter.indexOfValue(mSelectedTimezone); - if (index > -1) { - mListView.setSelection(index); - } + new Handler().postDelayed(() -> { + if (isAdded()) { + int index = mAdapter.indexOfValue(mSelectedTimezone); + if (index > -1) { + mListView.setSelection(index); } } }, 100); @@ -283,9 +264,21 @@ private class TimezoneAdapter extends BaseAdapter implements Filterable { private final List mAllTimezones = new ArrayList<>(); private final List mFilteredTimezones = new ArrayList<>(); - private TimezoneAdapter(@NonNull List timezones) { + private int mSelectedRowColor; + private int mUnselectedColor; + + private TimezoneAdapter(@NonNull List timezones, Context context) { 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 @@ -327,8 +320,10 @@ public View getView(int position, View convertView, ViewGroup parent) { boolean isSelected = mSelectedTimezone != null && mSelectedTimezone.equals(mFilteredTimezones.get(position).mValue); - int colorRes = isSelected ? R.color.primary_30 : android.R.color.transparent; - holder.mTxtLabel.setBackgroundColor(getResources().getColor(colorRes)); + + + int bgColor = isSelected ? mSelectedRowColor : mUnselectedColor; + holder.mTxtLabel.setBackgroundColor(bgColor); holder.mTxtLabel.setText(mFilteredTimezones.get(position).mLabel); return convertView; diff --git a/WordPress/src/main/res/layout/site_settings_timezone_dialog.xml b/WordPress/src/main/res/layout/site_settings_timezone_dialog.xml index 6e9925a6204c..0f6abe599127 100644 --- a/WordPress/src/main/res/layout/site_settings_timezone_dialog.xml +++ b/WordPress/src/main/res/layout/site_settings_timezone_dialog.xml @@ -18,20 +18,20 @@ android:orientation="vertical" android:padding="@dimen/margin_extra_large"> - + android:text="@string/site_settings_timezone_title" + android:textAppearance="?attr/textAppearanceHeadline6" /> - + android:text="@string/site_settings_timezone_subtitle" + android:textAppearance="?attr/textAppearanceCaption" /> - Date: Wed, 8 Jan 2020 20:47:07 -0800 Subject: [PATCH 173/761] Fixed wrong equals method and some tiny refactoring. --- .../android/ui/prefs/SiteSettingsFragment.java | 2 +- .../ui/prefs/SiteSettingsTagListActivity.java | 13 +++++-------- .../android/ui/prefs/SummaryEditTextPreference.java | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) 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 71c0ee683f32..8fe5bb884200 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 @@ -1490,7 +1490,7 @@ public void changeEditTextPreferenceValue(EditTextPreference pref, String newVal return; } - if (!newValue.contentEquals(pref.getSummary())) { + if (!newValue.equals(pref.getSummary())) { String formattedValue = StringEscapeUtils.unescapeHtml4(newValue.replaceFirst(ADDRESS_FORMAT_REGEX, "")); pref.setText(formattedValue); 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 a813581b9fbf..84a6df076470 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 @@ -3,7 +3,6 @@ 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; @@ -407,13 +406,11 @@ private void confirmDeleteTag(@NonNull final TermModel term) { dialogBuilder.setMessage(message); dialogBuilder.setPositiveButton( getResources().getText(R.string.delete_yes), - 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); - } + (dialog, 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); 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 d8b3b1dd3046..5f001a85ae37 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 @@ -155,7 +155,7 @@ protected void onBindDialogView(final View view) { EditText editText = getEditText(); ViewParent oldParent = editText.getParent(); if (oldParent != view) { - if (oldParent != null && oldParent instanceof ViewGroup) { + if (oldParent instanceof ViewGroup) { ViewGroup groupParent = (ViewGroup) oldParent; groupParent.removeView(editText); ViewCompat.setPaddingRelative(groupParent, ViewCompat.getPaddingStart(groupParent), 0, From e28d077b6f393135fc49fb18b8035ca9a6dc2e60 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 8 Jan 2020 20:48:31 -0800 Subject: [PATCH 174/761] Updated layouts and styles. --- .../color/on_surface_disabled_selector.xml | 5 ++++ .../src/main/res/drawable/tag_list_circle.xml | 2 +- WordPress/src/main/res/layout/list_editor.xml | 27 +++++++++---------- .../main/res/layout/start_over_preference.xml | 15 +++++------ .../main/res/layout/wp_simple_list_item_1.xml | 4 +-- WordPress/src/main/res/values/attrs.xml | 6 ++--- WordPress/src/main/res/values/styles.xml | 6 +---- 7 files changed, 31 insertions(+), 34 deletions(-) create mode 100644 WordPress/src/main/res/color/on_surface_disabled_selector.xml diff --git a/WordPress/src/main/res/color/on_surface_disabled_selector.xml b/WordPress/src/main/res/color/on_surface_disabled_selector.xml new file mode 100644 index 000000000000..5efe49cc1cdb --- /dev/null +++ b/WordPress/src/main/res/color/on_surface_disabled_selector.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/WordPress/src/main/res/drawable/tag_list_circle.xml b/WordPress/src/main/res/drawable/tag_list_circle.xml index fe1b56f4234b..7043e05fc41d 100644 --- a/WordPress/src/main/res/drawable/tag_list_circle.xml +++ b/WordPress/src/main/res/drawable/tag_list_circle.xml @@ -4,5 +4,5 @@ + android:color="?attr/colorPrimary"/> diff --git a/WordPress/src/main/res/layout/list_editor.xml b/WordPress/src/main/res/layout/list_editor.xml index 3722e0b79ba8..a6a79b93b990 100644 --- a/WordPress/src/main/res/layout/list_editor.xml +++ b/WordPress/src/main/res/layout/list_editor.xml @@ -1,7 +1,6 @@ - + android:textAppearance="?attr/textAppearanceCaption" /> + android:background="?android:attr/listDivider" /> + android:layout_height="wrap_content" + android:layout_below="@+id/list_editor_header_text" /> diff --git a/WordPress/src/main/res/layout/start_over_preference.xml b/WordPress/src/main/res/layout/start_over_preference.xml index f9865a8eb7f5..b401eae1dac3 100644 --- a/WordPress/src/main/res/layout/start_over_preference.xml +++ b/WordPress/src/main/res/layout/start_over_preference.xml @@ -25,39 +25,38 @@ android:padding="@dimen/start_over_icon_padding" android:contentDescription="@null" android:layout_gravity="center_vertical" - android:tint="@color/neutral_60" + android:tint="?attr/wpColorOnSurfaceMedium" android:layout_marginEnd="@dimen/start_over_icon_margin_right"/> - - - + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:text="@string/stats_jetpack_connection_faq" /> diff --git a/WordPress/src/main/res/layout/notifications_list_item.xml b/WordPress/src/main/res/layout/notifications_list_item.xml index b76308609a7d..9b6ea8774b7e 100644 --- a/WordPress/src/main/res/layout/notifications_list_item.xml +++ b/WordPress/src/main/res/layout/notifications_list_item.xml @@ -1,54 +1,51 @@ - + android:layout_width="match_parent" + android:layout_height="wrap_content"> - + tools:visibility="visible" /> + android:paddingTop="@dimen/margin_medium" + android:paddingEnd="@dimen/margin_extra_large" + android:paddingBottom="@dimen/margin_medium"> + android:layout_alignParentStart="true"> @@ -58,68 +55,63 @@ android:layout_height="@dimen/note_icon_sz" android:layout_marginStart="@dimen/notifications_note_icon_margin" android:layout_marginTop="@dimen/notifications_note_icon_margin" - android:background="@drawable/bg_oval_primary_40_stroke_notification_unread" - android:importantForAccessibility="no" + android:background="@drawable/bg_oval_primary_stroke_notification_unread" android:gravity="center" + android:importantForAccessibility="no" android:padding="4dp" /> + android:layout_toEndOf="@+id/note_avatar_container"> - + android:textColor="?attr/wpColorOnSurfaceMedium" + android:textSize="@dimen/text_sz_larger" /> - + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:text="Bob Ross commented on your post Happy Trees" /> - + tools:visibility="visible" /> - + android:layout_below="@+id/note_content_container" + android:background="?android:attr/listDivider" /> From ef9f0abbe2d9483eb522fde7c2e23cafeab71651 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 29 Jan 2020 23:58:50 -0800 Subject: [PATCH 292/761] Updated main notification settings. --- .../NotificationsSettingsActivity.java | 13 +++ .../NotificationsSettingsFragment.java | 41 ++++---- .../PrefMasterSwitchToolbarView.kt | 59 ++++++------ .../notifications_settings_activity.xml | 93 +++++++++---------- .../main/res/menu/notifications_settings.xml | 6 +- .../main/res/xml/notifications_settings.xml | 21 ++--- 6 files changed, 116 insertions(+), 117 deletions(-) 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 697734c95163..a00daf80d02c 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 @@ -16,6 +16,8 @@ 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; @@ -23,6 +25,7 @@ import org.wordpress.android.analytics.AnalyticsTracker; 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 @@ -128,6 +131,16 @@ 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/NotificationsSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java index 0d9ef2189a37..5348075eab65 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,6 +4,7 @@ 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; @@ -17,12 +18,10 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.widget.EditText; -import androidx.annotation.ColorRes; +import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.appcompat.widget.SearchView; -import androidx.core.content.ContextCompat; import com.android.volley.VolleyError; import com.wordpress.rest.RestRequest; @@ -59,7 +58,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.ColorUtils; +import org.wordpress.android.util.ContextExtensionsKt; import org.wordpress.android.util.SiteUtils; import org.wordpress.android.util.ToastUtils; import org.wordpress.android.util.ToastUtils.Duration; @@ -140,8 +139,8 @@ private void removeSightAndSoundsForAPI26() { PreferenceCategory categorySightsAndSounds = (PreferenceCategory) preferenceScreen.findPreference(getActivity() - .getString( - R.string.pref_notification_sights_sounds)); + .getString( + R.string.pref_notification_sights_sounds)); preferenceScreen.removePreference(categorySightsAndSounds); } } @@ -192,7 +191,6 @@ 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( @@ -244,14 +242,6 @@ 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())) { @@ -693,7 +683,6 @@ 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); @@ -702,8 +691,7 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen mOnSettingsChangedListener ); - timelinePreference.setIcon(ColorUtils.INSTANCE.applyTintToDrawable(context, R.drawable.ic_bell_white_24dp, - R.color.neutral_60)); + setPreferenceIcon(timelinePreference, R.drawable.ic_bell_white_24dp); timelinePreference.setTitle(R.string.notifications_tab); timelinePreference.setDialogTitle(R.string.notifications_tab); timelinePreference.setSummary(R.string.notifications_tab_summary); @@ -714,8 +702,8 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen mOnSettingsChangedListener ); - emailPreference.setIcon(ColorUtils.INSTANCE.applyTintToDrawable(context, R.drawable.ic_mail_white_24dp, - R.color.neutral_60)); + + setPreferenceIcon(emailPreference, R.drawable.ic_mail_white_24dp); emailPreference.setTitle(R.string.email); emailPreference.setDialogTitle(R.string.email); emailPreference.setSummary(R.string.notifications_email_summary); @@ -728,9 +716,7 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen context, null, channel, NotificationsSettings.Type.DEVICE, blogId, mNotificationsSettings, mOnSettingsChangedListener ); - - devicePreference.setIcon(ColorUtils.INSTANCE.applyTintToDrawable(context, R.drawable.ic_phone_white_24dp, - R.color.neutral_60)); + setPreferenceIcon(devicePreference, R.drawable.ic_phone_white_24dp); devicePreference.setTitle(R.string.app_notifications); devicePreference.setDialogTitle(R.string.app_notifications); devicePreference.setSummary(R.string.notifications_push_summary); @@ -741,6 +727,14 @@ 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) { @@ -748,7 +742,6 @@ 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 b7e5e859cfe1..2eb4875c6c06 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,15 +10,16 @@ import android.widget.CompoundButton.OnCheckedChangeListener import android.widget.LinearLayout import android.widget.TextView import android.widget.Toast -import androidx.annotation.ColorRes +import androidx.annotation.AttrRes +import androidx.annotation.ColorInt import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.Toolbar -import androidx.core.content.ContextCompat import androidx.core.view.ViewCompat -import org.wordpress.android.R -import org.wordpress.android.util.redirectContextClickToLongPressListener 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 /** * Custom view for master switch in toolbar for preferences. @@ -32,29 +33,26 @@ 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, - @ColorRes val titleColorResId: Int, - @ColorRes val backgroundColorResId: Int, - @ColorRes val thumbTintColorListResId: Int, - @ColorRes val trackTintColorListResId: Int + @AttrRes val titleColorResId: Int, + @AttrRes val backgroundColorResId: Int ) { HIGHLIGHTED( - 0, - R.color.white, - R.color.primary_40, - R.color.primary_30_neutral_10_selector, - R.color.primary_30_primary_20_selector + 0, + R.attr.colorOnPrimary, + R.attr.colorPrimary ), NORMAL( - 1, - R.color.black, - R.color.white, - R.color.primary_30_neutral_selector, - R.color.primary_5_neutral_20_selector + 1, + R.attr.colorOnSurface, + R.attr.colorSurface ); + companion object { - fun fromInt(value: Int): PrefMasterSwitchToolbarViewStyle? = values().firstOrNull { it.value == value } + fun fromInt(value: Int): PrefMasterSwitchToolbarViewStyle? = + values().firstOrNull { it.value == value } } } @@ -124,7 +122,10 @@ 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) @@ -230,8 +231,10 @@ 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." + ) } } @@ -245,15 +248,15 @@ class PrefMasterSwitchToolbarView @JvmOverloads constructor( } private fun loadResourcesForViewStyle(viewStyle: PrefMasterSwitchToolbarViewStyle) { - 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) + val titleColor = context.getColorFromAttribute(viewStyle.titleColorResId) + val backgroundColor = context.getColorFromAttribute(viewStyle.backgroundColorResId) toolbarSwitch.setTitleTextColor(titleColor) toolbarSwitch.setBackgroundColor(backgroundColor) - masterSwitch.thumbTintList = thumbColorList - masterSwitch.trackTintList = trackColorList + } + + override fun setBackgroundColor(@ColorInt color: Int) { + toolbarSwitch.setBackgroundColor(color) } /* diff --git a/WordPress/src/main/res/layout/notifications_settings_activity.xml b/WordPress/src/main/res/layout/notifications_settings_activity.xml index dac7e6288450..1f9ed91c7fe0 100644 --- a/WordPress/src/main/res/layout/notifications_settings_activity.xml +++ b/WordPress/src/main/res/layout/notifications_settings_activity.xml @@ -1,96 +1,91 @@ - + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:layout_width="match_parent" + android:layout_height="wrap_content"> - - - - - + android:layout_height="@dimen/toolbar_height" + android:focusableInTouchMode="true" + app:theme="@style/WordPress.ActionBar" /> + + + - + android:layout_height="match_parent" + android:layout_below="@id/master_switch" + android:orientation="vertical" /> + android:orientation="vertical"> - + android:paddingEnd="@dimen/margin_extra_large" + android:text="@string/notification_settings_master_off_title" /> - + android:paddingEnd="@dimen/margin_extra_large" + android:text="@string/notification_settings_master_off_message" /> + tools:visibility="invisible"> - + tools:text="Loading..." /> diff --git a/WordPress/src/main/res/menu/notifications_settings.xml b/WordPress/src/main/res/menu/notifications_settings.xml index 7607b23d2c45..963f9def45bb 100644 --- a/WordPress/src/main/res/menu/notifications_settings.xml +++ b/WordPress/src/main/res/menu/notifications_settings.xml @@ -3,9 +3,9 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> + android:visible="false" + app:actionViewClass="androidx.appcompat.widget.SearchView" + app:showAsAction="collapseActionView|ifRoom" /> diff --git a/WordPress/src/main/res/xml/notifications_settings.xml b/WordPress/src/main/res/xml/notifications_settings.xml index 505989b69554..caa42ec5917e 100644 --- a/WordPress/src/main/res/xml/notifications_settings.xml +++ b/WordPress/src/main/res/xml/notifications_settings.xml @@ -1,55 +1,50 @@ - + + android:title="@string/notification_settings_category_other"> + android:title="@string/notification_settings_category_sights_and_sounds"> From a3737209136446f799cb64566be4d65e2a1bb602 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Wed, 29 Jan 2020 23:59:32 -0800 Subject: [PATCH 293/761] Updated inner notification settings dialogs and screens. --- .../NotificationSettingsFollowedDialog.java | 27 +--- ...NotificationsSettingsDialogPreference.java | 31 ++-- .../main/res/layout/followed_sites_dialog.xml | 142 +++++++----------- .../layout/notifications_settings_switch.xml | 25 ++- ...notifications_tab_disabled_text_layout.xml | 55 ++++--- ...otifications_tab_for_blog_title_layout.xml | 30 ++-- .../res/layout/preference_dialog_title.xml | 11 +- .../preferences_master_switch_toolbar.xml | 11 +- .../src/main/res/layout/toolbar_switch.xml | 9 +- WordPress/src/main/res/values/styles.xml | 12 -- 10 files changed, 148 insertions(+), 205 deletions(-) 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 e2de9491c222..40fe0e268902 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,25 +2,24 @@ 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. @@ -89,8 +88,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { } } - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(getActivity(), R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); builder.setTitle(getString(R.string.notification_settings_followed_dialog_title)); builder.setPositiveButton(android.R.string.ok, this); builder.setNegativeButton(R.string.cancel, this); @@ -99,23 +97,6 @@ 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/NotificationsSettingsDialogPreference.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsDialogPreference.java index 9f76bf35a36f..0f91fe2a67a4 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,6 +17,7 @@ import androidx.annotation.NonNull; import androidx.appcompat.widget.SwitchCompat; +import androidx.core.content.ContextCompat; import org.json.JSONException; import org.json.JSONObject; @@ -27,6 +28,7 @@ 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; @@ -85,10 +87,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); } } @@ -107,9 +109,10 @@ 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.setBackgroundColor(getContext().getResources().getColor(R.color.divider)); + dividerView + .setBackground(ContextUtilsKt.getDrawableFromAttribute(getContext(), android.R.attr.listDivider)); dividerView.setLayoutParams(new ViewGroup.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, dividerHeight)); innerView.addView(dividerView); } else { @@ -122,17 +125,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); @@ -282,6 +285,8 @@ 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/res/layout/followed_sites_dialog.xml b/WordPress/src/main/res/layout/followed_sites_dialog.xml index 72661cab8397..d8f13b184d14 100644 --- a/WordPress/src/main/res/layout/followed_sites_dialog.xml +++ b/WordPress/src/main/res/layout/followed_sites_dialog.xml @@ -1,158 +1,132 @@ - + android:paddingBottom="@dimen/site_settings_divider_height"> + android:paddingEnd="@dimen/related_posts_dialog_padding_right" + android:paddingBottom="@dimen/related_posts_dialog_padding_bottom"> - + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:checked="true" /> - + android:textAppearance="?attr/textAppearanceBody2" + android:textColor="?attr/wpColorOnSurfaceMedium" /> - + android:layout_marginBottom="@dimen/margin_large" + android:background="?android:attr/listDivider" /> - + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:checked="true" /> + tools:ignore="UnusedAttribute" + tools:visibility="visible"> - - + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:checked="true" /> - - + android:textAppearance="?attr/textAppearanceSubtitle1" /> - - + android:textAppearance="?attr/textAppearanceSubtitle1" /> - + android:layout_marginBottom="@dimen/margin_large" + android:background="?android:attr/listDivider" /> - + android:textAppearance="?attr/textAppearanceSubtitle1" /> diff --git a/WordPress/src/main/res/layout/notifications_settings_switch.xml b/WordPress/src/main/res/layout/notifications_settings_switch.xml index 9b6375d0122b..db2c32284c2a 100644 --- a/WordPress/src/main/res/layout/notifications_settings_switch.xml +++ b/WordPress/src/main/res/layout/notifications_settings_switch.xml @@ -9,15 +9,15 @@ android:id="@+id/row_container" android:layout_width="match_parent" android:layout_height="match_parent" - android:minHeight="@dimen/min_touch_target_sz" + android:clickable="true" + android:focusable="true" android:gravity="center_vertical" + android:minHeight="@dimen/min_touch_target_sz" android:orientation="horizontal" - android:paddingBottom="@dimen/margin_medium" - android:paddingTop="@dimen/margin_medium" android:paddingStart="24dp" + android:paddingTop="@dimen/margin_medium" android:paddingEnd="24dp" - android:clickable="true" - android:focusable="true"> + android:paddingBottom="@dimen/margin_medium"> - - + android:visibility="gone" + tools:text="Some example sub text." /> + android:layout_marginEnd="24dp" + android:background="?android:attr/listDivider" /> diff --git a/WordPress/src/main/res/layout/notifications_tab_disabled_text_layout.xml b/WordPress/src/main/res/layout/notifications_tab_disabled_text_layout.xml index 61effd6e48c5..7598a642aa0e 100644 --- a/WordPress/src/main/res/layout/notifications_tab_disabled_text_layout.xml +++ b/WordPress/src/main/res/layout/notifications_tab_disabled_text_layout.xml @@ -1,39 +1,36 @@ - + android:orientation="vertical" + android:visibility="gone"> - - + - - + - + diff --git a/WordPress/src/main/res/layout/notifications_tab_for_blog_title_layout.xml b/WordPress/src/main/res/layout/notifications_tab_for_blog_title_layout.xml index c7cf453daba0..62ce642796cb 100644 --- a/WordPress/src/main/res/layout/notifications_tab_for_blog_title_layout.xml +++ b/WordPress/src/main/res/layout/notifications_tab_for_blog_title_layout.xml @@ -1,27 +1,25 @@ - - + - - + diff --git a/WordPress/src/main/res/layout/preference_dialog_title.xml b/WordPress/src/main/res/layout/preference_dialog_title.xml index f9a401f0341a..516a4f03ec11 100644 --- a/WordPress/src/main/res/layout/preference_dialog_title.xml +++ b/WordPress/src/main/res/layout/preference_dialog_title.xml @@ -1,12 +1,17 @@ + + android:layout_marginEnd="6dip" + android:gravity="start|center_vertical" + android:paddingTop="@dimen/margin_extra_large" + android:paddingBottom="@dimen/margin_extra_large" + android:singleLine="true" + android:textAppearance="?attr/textAppearanceSubtitle1" + android:textStyle="bold" /> diff --git a/WordPress/src/main/res/layout/preferences_master_switch_toolbar.xml b/WordPress/src/main/res/layout/preferences_master_switch_toolbar.xml index 7ede88d8fdf3..b6a2976b2ce9 100644 --- a/WordPress/src/main/res/layout/preferences_master_switch_toolbar.xml +++ b/WordPress/src/main/res/layout/preferences_master_switch_toolbar.xml @@ -1,11 +1,10 @@ - - + android:layout_height="@dimen/toolbar_height" + android:focusableInTouchMode="true" + android:visibility="gone" /> diff --git a/WordPress/src/main/res/layout/toolbar_switch.xml b/WordPress/src/main/res/layout/toolbar_switch.xml index fcb93b52d4bb..a5e7eacd5b05 100644 --- a/WordPress/src/main/res/layout/toolbar_switch.xml +++ b/WordPress/src/main/res/layout/toolbar_switch.xml @@ -1,10 +1,7 @@ - - + tools:ignore="RtlSymmetry" /> diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 3d203d3ff516..62a3ed282c70 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -1036,18 +1036,6 @@ @android:color/transparent - - - - - - - - - - - @@ -583,9 +564,6 @@ 1 - - - From 2d258937fd3c44ffec18b787afb063a0a243c7ae Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 31 Jan 2020 11:40:06 -0800 Subject: [PATCH 295/761] Removed unused resources. --- WordPress/src/main/res/anim/pressed_card.xml | 19 ------------------- WordPress/src/main/res/values/dimens.xml | 1 - 2 files changed, 20 deletions(-) delete mode 100644 WordPress/src/main/res/anim/pressed_card.xml diff --git a/WordPress/src/main/res/anim/pressed_card.xml b/WordPress/src/main/res/anim/pressed_card.xml deleted file mode 100644 index 47b1e1aa99be..000000000000 --- a/WordPress/src/main/res/anim/pressed_card.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - diff --git a/WordPress/src/main/res/values/dimens.xml b/WordPress/src/main/res/values/dimens.xml index 659e807b8ee7..945916c36de9 100644 --- a/WordPress/src/main/res/values/dimens.xml +++ b/WordPress/src/main/res/values/dimens.xml @@ -31,7 +31,6 @@ 8dp 2dp - 8dp 2dp 4dp From 3b9f05d8ea42bb79d1f3abd95c85d73bb4519bc9 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Sat, 1 Feb 2020 12:14:14 -0800 Subject: [PATCH 296/761] Udpated web preview toolbar style. --- WordPress/src/main/res/layout/wpwebview_activity.xml | 5 +---- WordPress/src/main/res/values/styles.xml | 10 ++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/res/layout/wpwebview_activity.xml b/WordPress/src/main/res/layout/wpwebview_activity.xml index 71a25618bcbd..e105638f3d00 100644 --- a/WordPress/src/main/res/layout/wpwebview_activity.xml +++ b/WordPress/src/main/res/layout/wpwebview_activity.xml @@ -21,10 +21,7 @@ app:contentInsetLeft="@dimen/toolbar_content_offset" app:contentInsetRight="@dimen/toolbar_content_offset_end" app:contentInsetStart="@dimen/toolbar_content_offset" - app:popupTheme="@style/ThemeOverlay.AppCompat.Light" - app:subtitleTextColor="?attr/wpColorTextSubtle" - app:theme="@style/Theme.MaterialComponents.DayNight" - app:titleTextColor="?attr/colorOnSurface" /> + app:theme="@style/WordPress.WebPreview.ActionBar" /> diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 537adab4bcd1..afbb91dd54f7 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -34,7 +34,9 @@ @color/material_on_surface_emphasis_medium ?attr/colorOnPrimary - @style/Widget.MaterialComponents.PopupMenu.ListPopupWindow + + @style/Widget.MaterialComponents.PopupMenu.ListPopupWindow + @style/Widget.MaterialComponents.PopupMenu @style/Widget.MaterialComponents.PopupMenu.Overflow @@ -166,6 +168,10 @@ ?attr/colorOnPrimarySurface + + - + + - - - - - - - - - - - - - + + - - - - - - - - - - - - - + - + + @@ -921,7 +919,7 @@ @@ -597,12 +596,6 @@ - - From 5e4f3b03f9bfc111ef0e65c6f50ee7d15196f0de Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 18:49:40 -0800 Subject: [PATCH 342/761] Added toolbar to edit post activity. --- .../android/ui/posts/EditPostActivity.java | 3 +++ .../res/layout/new_edit_post_activity.xml | 23 ++++++++++++------- WordPress/src/main/res/values/styles.xml | 4 ++++ 3 files changed, 22 insertions(+), 8 deletions(-) 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 2a60244a513b..bd2be6ff86d4 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 @@ -29,6 +29,7 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback; import androidx.core.util.Consumer; import androidx.fragment.app.Fragment; @@ -408,6 +409,8 @@ 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); diff --git a/WordPress/src/main/res/layout/new_edit_post_activity.xml b/WordPress/src/main/res/layout/new_edit_post_activity.xml index 1b91a846a431..16f7d9365c75 100644 --- a/WordPress/src/main/res/layout/new_edit_post_activity.xml +++ b/WordPress/src/main/res/layout/new_edit_post_activity.xml @@ -1,35 +1,42 @@ + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/editor_activity" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + + android:layout_below="@+id/toolbar_container" + android:importantForAccessibility="no" + tools:context=".ui.posts.EditPostActivity" /> + android:visibility="gone" /> + tools:visibility="visible" /> diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index d714da205327..9b088771a535 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -76,6 +76,10 @@ true + + - - - - - - + + From f557494cb30ca24e18f52d938f5669af63a097c6 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 21:13:07 -0800 Subject: [PATCH 354/761] Updated manifest. --- WordPress/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/AndroidManifest.xml b/WordPress/src/main/AndroidManifest.xml index 2e6e9de932b9..e8a113c7973b 100644 --- a/WordPress/src/main/AndroidManifest.xml +++ b/WordPress/src/main/AndroidManifest.xml @@ -204,7 +204,7 @@ + android:theme="@style/WordPress.Editor.NoActionBar" /> Date: Thu, 6 Feb 2020 21:16:09 -0800 Subject: [PATCH 355/761] Reverted removed selector. --- .../src/main/res/color/neutral_70_neutral_20_selector.xml | 4 ++++ WordPress/src/main/res/values/styles.xml | 1 + 2 files changed, 5 insertions(+) create mode 100644 WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml diff --git a/WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml b/WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml new file mode 100644 index 000000000000..a8b409b1d1a6 --- /dev/null +++ b/WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 738808a16c8b..3dcfd509f8bf 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -636,6 +636,7 @@ From 9f368f28140573cb3474675e19bbeca1287cb0c8 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 21:16:47 -0800 Subject: [PATCH 356/761] Added toolbar to Edit Post activity. --- .../android/ui/posts/EditPostActivity.java | 3 +++ .../res/layout/new_edit_post_activity.xml | 23 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) 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 2a60244a513b..bd2be6ff86d4 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 @@ -29,6 +29,7 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback; import androidx.core.util.Consumer; import androidx.fragment.app.Fragment; @@ -408,6 +409,8 @@ 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); diff --git a/WordPress/src/main/res/layout/new_edit_post_activity.xml b/WordPress/src/main/res/layout/new_edit_post_activity.xml index 1b91a846a431..16f7d9365c75 100644 --- a/WordPress/src/main/res/layout/new_edit_post_activity.xml +++ b/WordPress/src/main/res/layout/new_edit_post_activity.xml @@ -1,35 +1,42 @@ + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/editor_activity" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + + android:layout_below="@+id/toolbar_container" + android:importantForAccessibility="no" + tools:context=".ui.posts.EditPostActivity" /> + android:visibility="gone" /> + tools:visibility="visible" /> From 22f22a4c05723b9ab4b2254e9fd4a42afaaac914 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 21:17:00 -0800 Subject: [PATCH 357/761] Updated removed selector. --- .../main/res/color/neutral_70_neutral_20_selector.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml b/WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml index a8b409b1d1a6..c28163dff60f 100644 --- a/WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml +++ b/WordPress/src/main/res/color/neutral_70_neutral_20_selector.xml @@ -1,4 +1,9 @@ - - \ No newline at end of file + + + + + + From 7089710f0e96183c605c62b021a7c6fa5b193d44 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 21:17:15 -0800 Subject: [PATCH 358/761] Updated diff view colors. --- .../org/wordpress/android/widgets/DiffView.kt | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/widgets/DiffView.kt b/WordPress/src/main/java/org/wordpress/android/widgets/DiffView.kt index 7002346feb18..4d4bb70cbdbc 100644 --- a/WordPress/src/main/java/org/wordpress/android/widgets/DiffView.kt +++ b/WordPress/src/main/java/org/wordpress/android/widgets/DiffView.kt @@ -6,17 +6,21 @@ import android.text.SpannableString import android.text.style.BackgroundColorSpan import android.text.style.StrikethroughSpan import android.util.AttributeSet -import androidx.appcompat.widget.AppCompatTextView -import androidx.core.content.ContextCompat +import com.google.android.material.textview.MaterialTextView import org.wordpress.android.R import org.wordpress.android.fluxc.model.revisions.Diff import org.wordpress.android.fluxc.model.revisions.DiffOperations.ADD import org.wordpress.android.fluxc.model.revisions.DiffOperations.DELETE +import org.wordpress.android.util.getColorFromAttribute -class DiffView : AppCompatTextView { +class DiffView : MaterialTextView { constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super( + context, + attrs, + defStyleAttr + ) fun showDiffs(diffs: List, trimNewline: Boolean = false) { text = null @@ -33,36 +37,29 @@ class DiffView : AppCompatTextView { if (diff.operation == ADD) { diffContent.setSpan( ColorUnderlineSpan( - ContextCompat.getColor( - context, - R.color.primary - ) + context.getColorFromAttribute(R.attr.colorPrimary) ), 0, diffContent.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) diffContent.setSpan( BackgroundColorSpan( - ContextCompat.getColor( - context, - R.color.primary_0 - ) + context.getColorFromAttribute(R.attr.colorSurface) ), 0, diffContent.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) } else if (diff.operation == DELETE) { - diffContent.setSpan(StrikethroughSpan(), 0, diffContent.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) + diffContent.setSpan( + StrikethroughSpan(), + 0, + diffContent.length, + Spannable.SPAN_EXCLUSIVE_EXCLUSIVE + ) diffContent.setSpan( ColorUnderlineSpan( - ContextCompat.getColor( - context, - R.color.error - ) + context.getColorFromAttribute(R.attr.wpColorError) ), 0, diffContent.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) diffContent.setSpan( BackgroundColorSpan( - ContextCompat.getColor( - context, - R.color.error_0 - ) + context.getColorFromAttribute(R.attr.colorSurface) ), 0, diffContent.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE ) } From c23f4e6888a36a9d407e7cb1b60627129e0509bf Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 21:17:35 -0800 Subject: [PATCH 359/761] Updated history details. --- .../ui/history/HistoryDetailActivity.kt | 2 + .../res/layout/history_detail_activity.xml | 16 +- .../history_detail_container_fragment.xml | 180 +++++++++--------- .../res/layout/history_detail_fragment.xml | 53 +++--- 4 files changed, 127 insertions(+), 124 deletions(-) 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 d4c3779342e8..0370d3e26b42 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 @@ -2,6 +2,7 @@ package org.wordpress.android.ui.history import android.os.Bundle import androidx.appcompat.app.AppCompatActivity +import kotlinx.android.synthetic.main.toolbar_main.* import org.wordpress.android.R import org.wordpress.android.analytics.AnalyticsTracker import org.wordpress.android.analytics.AnalyticsTracker.Stat @@ -16,6 +17,7 @@ class HistoryDetailActivity : AppCompatActivity() { 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/res/layout/history_detail_activity.xml b/WordPress/src/main/res/layout/history_detail_activity.xml index 89b226915a2d..e9efa69b8530 100644 --- a/WordPress/src/main/res/layout/history_detail_activity.xml +++ b/WordPress/src/main/res/layout/history_detail_activity.xml @@ -1,9 +1,15 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> + + - + + \ No newline at end of file diff --git a/WordPress/src/main/res/layout/history_detail_container_fragment.xml b/WordPress/src/main/res/layout/history_detail_container_fragment.xml index e18facd45d10..8cd118058b0c 100644 --- a/WordPress/src/main/res/layout/history_detail_container_fragment.xml +++ b/WordPress/src/main/res/layout/history_detail_container_fragment.xml @@ -1,102 +1,104 @@ - - + aztec:cardCornerRadius="0dp" + aztec:cardElevation="@dimen/appbar_elevation"> - - + - - - - - - + + - + android:layout_centerInParent="true" + android:layout_toStartOf="@+id/next" + android:layout_toEndOf="@+id/previous" + android:gravity="center" + android:orientation="horizontal" + android:padding="@dimen/margin_extra_large"> + + + + + + + + - + - - - - + - + android:layout_above="@+id/bottom_bar" /> + android:visibility="gone" + tools:visibility="visible"> - + android:textStyle="bold" + tools:text="Visual Title" /> + android:layout_marginRight="@dimen/sourceview_side_margin" /> - + aztec:textColor="@color/text" /> - + android:background="?android:attr/listDivider" /> diff --git a/WordPress/src/main/res/layout/history_detail_fragment.xml b/WordPress/src/main/res/layout/history_detail_fragment.xml index fec700bea396..cf2db40751e4 100644 --- a/WordPress/src/main/res/layout/history_detail_fragment.xml +++ b/WordPress/src/main/res/layout/history_detail_fragment.xml @@ -1,66 +1,61 @@ - + android:layout_alignParentTop="true" + android:fillViewport="true"> + android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="wrap_content"> - + android:textStyle="bold" + tools:text="Title" /> - + android:layout_marginEnd="@dimen/sourceview_side_margin" /> + android:layout_width="match_parent" + android:layout_height="match_parent"> - + android:textAppearance="?attr/textAppearanceBody1" + android:textIsSelectable="true" /> From 4d5645dd606a0c2c5744a6dc4b297d5ca0408fc3 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 21:17:44 -0800 Subject: [PATCH 360/761] Updated history list. --- .../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 ++++++++---------- 4 files changed, 100 insertions(+), 125 deletions(-) diff --git a/WordPress/src/main/res/layout/history_list_footer.xml b/WordPress/src/main/res/layout/history_list_footer.xml index 7ee9ec4fe2e7..b0503cddb5d6 100644 --- a/WordPress/src/main/res/layout/history_list_footer.xml +++ b/WordPress/src/main/res/layout/history_list_footer.xml @@ -1,17 +1,15 @@ - - + android:textAppearance="?attr/textAppearanceBody1" + android:textColor="?attr/wpColorOnSurfaceMedium" + tools:text="Post Created on September 19, 2018 at 8:51am" /> diff --git a/WordPress/src/main/res/layout/history_list_fragment.xml b/WordPress/src/main/res/layout/history_list_fragment.xml index 4b35c5c8bed9..8a8ee8f81478 100644 --- a/WordPress/src/main/res/layout/history_list_fragment.xml +++ b/WordPress/src/main/res/layout/history_list_fragment.xml @@ -1,17 +1,15 @@ - + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:layout_width="match_parent" + android:layout_height="match_parent"> - + tools:visibility="visible" /> - + android:layout_height="match_parent" + android:scrollbars="vertical" /> diff --git a/WordPress/src/main/res/layout/history_list_header.xml b/WordPress/src/main/res/layout/history_list_header.xml index 6c3f95a0a4aa..cc60824bc825 100644 --- a/WordPress/src/main/res/layout/history_list_header.xml +++ b/WordPress/src/main/res/layout/history_list_header.xml @@ -1,18 +1,16 @@ - - + android:paddingEnd="@dimen/margin_extra_large" + android:paddingBottom="@dimen/margin_large" + android:textAppearance="?attr/textAppearanceSubtitle2" + android:textColor="?attr/wpColorOnSurfaceMedium" + tools:text="Today" /> diff --git a/WordPress/src/main/res/layout/history_list_item.xml b/WordPress/src/main/res/layout/history_list_item.xml index 7f6b92b32951..8f8dd38a32e1 100644 --- a/WordPress/src/main/res/layout/history_list_item.xml +++ b/WordPress/src/main/res/layout/history_list_item.xml @@ -1,116 +1,99 @@ - - + - - + - + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/margin_large" + android:drawableStart="@drawable/bg_oval_primary_plus_white_16dp" + android:drawablePadding="@dimen/margin_small" + android:textAppearance="?attr/textAppearanceBody2" + tools:text="3" /> - - + - - + - + - - - - + android:ellipsize="end" + android:gravity="start" + android:singleLine="true" + android:textAlignment="viewStart" + android:textAppearance="?attr/textAppearanceSubtitle1" + tools:text="1d ago" /> - - + - + - - + - - + From d7541780106cf5292889c51062e521ec5e6b950e Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 21:24:24 -0800 Subject: [PATCH 361/761] Updated color retrieval in extension. --- .../main/java/org/wordpress/android/util/ContextExtensions.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/ContextExtensions.kt b/WordPress/src/main/java/org/wordpress/android/util/ContextExtensions.kt index e69351334a72..e6049e8feca8 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/ContextExtensions.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/ContextExtensions.kt @@ -7,6 +7,7 @@ import androidx.annotation.AttrRes import androidx.annotation.ColorInt import androidx.annotation.ColorRes import androidx.appcompat.content.res.AppCompatResources +import androidx.core.content.ContextCompat import androidx.core.os.ConfigurationCompat import java.util.Locale @@ -21,7 +22,7 @@ fun Context.getColorResIdFromAttribute(@AttrRes attribute: Int) = fun Context.getColorFromAttribute(@AttrRes attribute: Int) = TypedValue().let { theme.resolveAttribute(attribute, it, true) - it.data + ContextCompat.getColor(this, it.resourceId) } fun Context.getColorStateListFromAttribute(@AttrRes attribute: Int): ColorStateList = From 7ccb19c662920e986a3557ea9cfd56b5f0ae0dae Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Thu, 6 Feb 2020 21:24:39 -0800 Subject: [PATCH 362/761] Fixed lint errors. --- WordPress/src/main/res/layout/history_detail_activity.xml | 2 +- WordPress/src/main/res/values/dimens.xml | 1 - WordPress/src/main/res/values/styles_calypso.xml | 6 ------ 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/WordPress/src/main/res/layout/history_detail_activity.xml b/WordPress/src/main/res/layout/history_detail_activity.xml index e9efa69b8530..429d0ebd153b 100644 --- a/WordPress/src/main/res/layout/history_detail_activity.xml +++ b/WordPress/src/main/res/layout/history_detail_activity.xml @@ -12,4 +12,4 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> - \ No newline at end of file + diff --git a/WordPress/src/main/res/values/dimens.xml b/WordPress/src/main/res/values/dimens.xml index 806d769f97f0..321d7854f8de 100644 --- a/WordPress/src/main/res/values/dimens.xml +++ b/WordPress/src/main/res/values/dimens.xml @@ -142,7 +142,6 @@ 20sp 24sp 32sp - 18sp 24dp 32dp diff --git a/WordPress/src/main/res/values/styles_calypso.xml b/WordPress/src/main/res/values/styles_calypso.xml index 5c7dd3db188b..d6ad8fc459ed 100644 --- a/WordPress/src/main/res/values/styles_calypso.xml +++ b/WordPress/src/main/res/values/styles_calypso.xml @@ -10,12 +10,6 @@ @style/Calypso.TextAppearance - - + + + + + From b7b6c642097daff05a8fe1b1d6b7c0d18b9e536d Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 7 Feb 2020 13:33:53 -0800 Subject: [PATCH 364/761] Moved NotNull annotation. --- .../ui/publicize/PublicizeAccountChooserListAdapter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 2a4fd47fcdd7..a2af1e239de8 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 @@ -39,9 +39,8 @@ public PublicizeAccountChooserListAdapter(Context context, List Date: Fri, 7 Feb 2020 13:34:29 -0800 Subject: [PATCH 365/761] Fixed name of the variable with number. --- .../main/java/org/wordpress/android/widgets/WPPrefView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/widgets/WPPrefView.java b/WordPress/src/main/java/org/wordpress/android/widgets/WPPrefView.java index a031106222c9..3ba9df110e4c 100644 --- a/WordPress/src/main/java/org/wordpress/android/widgets/WPPrefView.java +++ b/WordPress/src/main/java/org/wordpress/android/widgets/WPPrefView.java @@ -423,9 +423,9 @@ private Dialog getCheckListDialog() { .setTitle(mTitleTextView.getText()) .setNegativeButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.ok, (dialog, which) -> { - SparseBooleanArray checkedItems1 = + SparseBooleanArray userCheckedItems = ((AlertDialog) dialog).getListView().getCheckedItemPositions(); - mListItems.setCheckedItems(checkedItems1); + mListItems.setCheckedItems(userCheckedItems); doPrefChanged(); }) .setMultiChoiceItems(items, checkedItems, null); From b1087d0228ec63eb03b9f97798257e85138713bf Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 7 Feb 2020 14:50:32 -0800 Subject: [PATCH 366/761] Updated button styles. --- .../src/main/res/layout/post_signup_interstitial_default.xml | 4 ++-- .../main/res/layout/post_signup_interstitial_landscape.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/res/layout/post_signup_interstitial_default.xml b/WordPress/src/main/res/layout/post_signup_interstitial_default.xml index 614b01e44954..8a94f2225324 100644 --- a/WordPress/src/main/res/layout/post_signup_interstitial_default.xml +++ b/WordPress/src/main/res/layout/post_signup_interstitial_default.xml @@ -51,7 +51,7 @@ Date: Fri, 7 Feb 2020 15:05:13 -0800 Subject: [PATCH 367/761] Cleaning up a bit. --- .../org/wordpress/android/ui/FullScreenDialogFragment.java | 2 +- .../prefs/notifications/NotificationsSettingsActivity.java | 7 ++----- .../prefs/notifications/NotificationsSettingsFragment.java | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) 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 ebefeaf63f5b..266beaa5fbfa 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/FullScreenDialogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/FullScreenDialogFragment.java @@ -266,7 +266,7 @@ private void initToolbar(View view) { mToolbar.setSubtitle(mSubtitle); mToolbar.setNavigationIcon(ContextCompat.getDrawable(view.getContext(), R.drawable.ic_close_white_24dp)); mToolbar.setNavigationContentDescription(R.string.close_dialog_button_desc); - mToolbar.setNavigationOnClickListener(view1 -> onDismissClicked()); + mToolbar.setNavigationOnClickListener(v -> onDismissClicked()); if (mToolbarColor > 0) { mToolbar.setBackgroundColor(getResources().getColor(mToolbarColor)); 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 a00daf80d02c..561193936f90 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 @@ -133,11 +133,8 @@ private void setUpMasterSwitch() { ElevationOverlayProvider elevationOverlayProvider = new ElevationOverlayProvider(this); float cardElevation = getResources().getDimension(R.dimen.card_elevation); - int appBarColor = - elevationOverlayProvider - .compositeOverlay( - ContextExtensionsKt.getColorFromAttribute(this, R.attr.wpColorAppBar), - cardElevation); + int appBarColor = elevationOverlayProvider + .compositeOverlay(ContextExtensionsKt.getColorFromAttribute(this, R.attr.wpColorAppBar), cardElevation); masterSwitchToolBarView.setBackgroundColor(appBarColor); 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 5348075eab65..54aa0ac1cf0e 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 @@ -702,7 +702,6 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen mOnSettingsChangedListener ); - setPreferenceIcon(emailPreference, R.drawable.ic_mail_white_24dp); emailPreference.setTitle(R.string.email); emailPreference.setDialogTitle(R.string.email); From 00baf399fbb7144ec5f56fabeb87fff2e1f0d409 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 7 Feb 2020 16:45:58 -0800 Subject: [PATCH 368/761] Updated editor side. --- .../src/main/res/layout/fragment_aztec_editor.xml | 9 +++------ .../WordPressEditor/src/main/res/values/colors.xml | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) 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 b224a43dedde..3f77ce10ef75 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,7 +2,6 @@ @@ -12,8 +11,7 @@ android:layout_height="wrap_content" android:layout_width="match_parent" aztec:advanced="true" - aztec:mediaToolbarAvailable="true"> - + aztec:mediaToolbarAvailable="true" /> - + android:textColor="@color/title_color" + android:textColorHint="@color/hint_text" /> @color/wp_grey_lighten_30 @color/wp_grey_darken_30 + @color/grey_dark + #80000000 @color/black_translucent_50 From f1a5b246335ebd8ce924f3fbeeeb6f39f416beaf Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 7 Feb 2020 17:01:53 -0800 Subject: [PATCH 369/761] Overloaded styles and colors. --- ...rface_medium_disabled_checked_selector.xml | 9 +++++++ .../src/main/res/values-night/colors.xml | 16 +++++++++++++ .../src/main/res/values-night/styles.xml | 24 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml create mode 100644 WordPress/src/main/res/values-night/colors.xml diff --git a/WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml b/WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml new file mode 100644 index 000000000000..fa585e170498 --- /dev/null +++ b/WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/WordPress/src/main/res/values-night/colors.xml b/WordPress/src/main/res/values-night/colors.xml new file mode 100644 index 000000000000..a60898c6ead3 --- /dev/null +++ b/WordPress/src/main/res/values-night/colors.xml @@ -0,0 +1,16 @@ + + + + + + #282828 + ?android:attr/listDivider + @android:color/white + @color/text + @color/material_on_surface_emphasis_medium + @color/text + @color/neutral_60 + @color/neutral_60 + @android:color/white + + diff --git a/WordPress/src/main/res/values-night/styles.xml b/WordPress/src/main/res/values-night/styles.xml index d481fed6e321..6a50d1c326bb 100644 --- a/WordPress/src/main/res/values-night/styles.xml +++ b/WordPress/src/main/res/values-night/styles.xml @@ -31,6 +31,7 @@ @style/WordPress.TabLayout @style/Widget.MaterialComponents.PopupMenu @style/Widget.MaterialComponents.PopupMenu + @style/Widget.MaterialComponents.PopupMenu @style/Widget.MaterialComponents.PopupMenu.ListPopupWindow @@ -105,4 +106,27 @@ @color/on_surface_disabled_selector + + + + + + + + + + From 212096485a0d32a186fb6b913c8fe2f5ef51a312 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 7 Feb 2020 17:02:04 -0800 Subject: [PATCH 370/761] Updated style of dialogs in Aztec. --- .../java/org/wordpress/android/util/WPMediaUtils.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/WPMediaUtils.java b/WordPress/src/main/java/org/wordpress/android/util/WPMediaUtils.java index 2bec6d23728d..f1e49ad31341 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/WPMediaUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/util/WPMediaUtils.java @@ -1,7 +1,6 @@ package org.wordpress.android.util; import android.app.Activity; -import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -10,14 +9,16 @@ import android.net.Uri; import android.os.Environment; import android.provider.MediaStore; -import android.view.ContextThemeWrapper; import android.view.ViewConfiguration; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; +import com.google.android.material.dialog.MaterialAlertDialogBuilder; + import org.wordpress.android.R; import org.wordpress.android.analytics.AnalyticsTracker; import org.wordpress.android.fluxc.model.MediaModel; @@ -142,8 +143,7 @@ public void onCancel(DialogInterface dialog) { } }; - AlertDialog.Builder builder = new AlertDialog.Builder( - new ContextThemeWrapper(context, R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder builder = new MaterialAlertDialogBuilder(context); builder.setTitle(org.wordpress.android.R.string.image_optimization_promo_title); builder.setMessage(org.wordpress.android.R.string.image_optimization_promo_desc); builder.setPositiveButton(R.string.turn_on, onClickListener); @@ -202,8 +202,7 @@ String getErrorMessage(final Context context, final MediaModel media, final Medi } private static void showSDCardRequiredDialog(Context context) { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( - new ContextThemeWrapper(context, R.style.Calypso_Dialog_Alert)); + AlertDialog.Builder dialogBuilder = new MaterialAlertDialogBuilder(context); dialogBuilder.setTitle(context.getResources().getText(R.string.sdcard_title)); dialogBuilder.setMessage(context.getResources().getText(R.string.sdcard_message)); dialogBuilder.setPositiveButton(context.getString(android.R.string.ok), new DialogInterface.OnClickListener() { From a300c8199c2df664c836b13cb7c1acce53701d0a Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 7 Feb 2020 17:03:40 -0800 Subject: [PATCH 371/761] Fixed size of image picker in editor. --- WordPress/src/main/res/layout/new_edit_post_activity.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/src/main/res/layout/new_edit_post_activity.xml b/WordPress/src/main/res/layout/new_edit_post_activity.xml index 16f7d9365c75..774ad9948129 100644 --- a/WordPress/src/main/res/layout/new_edit_post_activity.xml +++ b/WordPress/src/main/res/layout/new_edit_post_activity.xml @@ -33,7 +33,6 @@ android:id="@+id/photo_fragment_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@+id/toolbar_container" android:layout_alignParentBottom="true" android:visibility="gone" tools:context=".ui.photopicker.PhotoPickerFragment" From 70b0e5dd9df48b920e22d2f5830fe1b18646b7e4 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 7 Feb 2020 17:28:45 -0800 Subject: [PATCH 372/761] Fixed lint issues. --- WordPress/src/main/res/values-night/colors.xml | 2 +- WordPress/src/main/res/values-night/styles.xml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/WordPress/src/main/res/values-night/colors.xml b/WordPress/src/main/res/values-night/colors.xml index a60898c6ead3..9ddf500b8d62 100644 --- a/WordPress/src/main/res/values-night/colors.xml +++ b/WordPress/src/main/res/values-night/colors.xml @@ -1,5 +1,5 @@ - + diff --git a/WordPress/src/main/res/values-night/styles.xml b/WordPress/src/main/res/values-night/styles.xml index 6a50d1c326bb..5af0e6e52515 100644 --- a/WordPress/src/main/res/values-night/styles.xml +++ b/WordPress/src/main/res/values-night/styles.xml @@ -29,7 +29,6 @@ @style/WordPress.FloatingActionButton @style/WordPress.TabLayout - @style/Widget.MaterialComponents.PopupMenu @style/Widget.MaterialComponents.PopupMenu @style/Widget.MaterialComponents.PopupMenu From 0bd34fec84aeb8d383223d03fe50fce91131963e Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Fri, 7 Feb 2020 17:35:27 -0800 Subject: [PATCH 373/761] Fixed namespace issue. --- WordPress/src/main/res/values-night/colors.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/res/values-night/colors.xml b/WordPress/src/main/res/values-night/colors.xml index 9ddf500b8d62..fbdac8c06943 100644 --- a/WordPress/src/main/res/values-night/colors.xml +++ b/WordPress/src/main/res/values-night/colors.xml @@ -1,5 +1,5 @@ - + From d367ee18a558b9a3118228d6b8d8fae9f272b13b Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 10 Feb 2020 17:30:31 -0600 Subject: [PATCH 374/761] Applying separate tint to media button. --- .../wordpress/android/editor/AztecEditorFragment.java | 9 +++++++++ .../res/color/media_button_background_tint_selector.xml | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100644 libs/editor/WordPressEditor/src/main/res/color/media_button_background_tint_selector.xml 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 c499bf259ee8..e9b6acc72075 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,6 +47,7 @@ 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; @@ -283,6 +284,14 @@ 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/res/color/media_button_background_tint_selector.xml b/libs/editor/WordPressEditor/src/main/res/color/media_button_background_tint_selector.xml new file mode 100644 index 000000000000..08afb26d2839 --- /dev/null +++ b/libs/editor/WordPressEditor/src/main/res/color/media_button_background_tint_selector.xml @@ -0,0 +1,7 @@ + + + + + + + From 90c9314529e456460caa5eea3ec3f0ef373a4969 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 10 Feb 2020 17:31:24 -0600 Subject: [PATCH 375/761] Overloading horizontal line drawable with listDivider background. --- .../src/main/res/drawable-anydpi-v21/img_hr.xml | 15 +++++++++++++++ .../src/main/res/drawable/img_hr.xml | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 libs/editor/WordPressEditor/src/main/res/drawable-anydpi-v21/img_hr.xml create mode 100644 libs/editor/WordPressEditor/src/main/res/drawable/img_hr.xml 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 new file mode 100644 index 000000000000..15849a3537b1 --- /dev/null +++ b/libs/editor/WordPressEditor/src/main/res/drawable-anydpi-v21/img_hr.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + diff --git a/libs/editor/WordPressEditor/src/main/res/drawable/img_hr.xml b/libs/editor/WordPressEditor/src/main/res/drawable/img_hr.xml new file mode 100644 index 000000000000..15849a3537b1 --- /dev/null +++ b/libs/editor/WordPressEditor/src/main/res/drawable/img_hr.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + From b43037f6f1460aa840346a04ff553c3f482e5edb Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Mon, 10 Feb 2020 17:32:48 -0600 Subject: [PATCH 376/761] Updated colors. --- ...rface_medium_disabled_checked_selector.xml | 2 +- .../primary_on_surface_disabled_selector.xml | 7 ++ .../src/main/res/values-night/colors.xml | 13 +-- .../main/res/layout/fragment_aztec_editor.xml | 79 ++++++++++--------- 4 files changed, 56 insertions(+), 45 deletions(-) create mode 100644 WordPress/src/main/res/color/primary_on_surface_disabled_selector.xml diff --git a/WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml b/WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml index fa585e170498..1745bbc6cf54 100644 --- a/WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml +++ b/WordPress/src/main/res/color/on_surface_medium_disabled_checked_selector.xml @@ -3,7 +3,7 @@ - + diff --git a/WordPress/src/main/res/color/primary_on_surface_disabled_selector.xml b/WordPress/src/main/res/color/primary_on_surface_disabled_selector.xml new file mode 100644 index 000000000000..4b30dace781d --- /dev/null +++ b/WordPress/src/main/res/color/primary_on_surface_disabled_selector.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WordPress/src/main/res/values-night/colors.xml b/WordPress/src/main/res/values-night/colors.xml index fbdac8c06943..a7685166b888 100644 --- a/WordPress/src/main/res/values-night/colors.xml +++ b/WordPress/src/main/res/values-night/colors.xml @@ -3,14 +3,17 @@ - #282828 + #282828 ?android:attr/listDivider - @android:color/white + @color/material_on_surface_emphasis_high_type @color/text @color/material_on_surface_emphasis_medium @color/text - @color/neutral_60 - @color/neutral_60 - @android:color/white + #222222 + @color/quote_background + @color/text + + @color/primary_on_surface_disabled_selector + 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 3f77ce10ef75..f520db98e229 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,23 @@ + android:layout_width="match_parent" + android:layout_height="match_parent"> + android:fillViewport="true"> + android:layout_width="match_parent" + android:layout_height="wrap_content"> + android:textColorHint="@color/hint_text" + android:textSize="@dimen/aztec_title_size" + android:textStyle="bold" /> + android:layout_marginRight="@dimen/sourceview_side_margin" /> + android:layout_width="match_parent" + android:layout_height="match_parent"> - + aztec:textColorHint="@color/hint_text" /> + aztec:tagColor="?attr/colorPrimary" + aztec:textColor="@color/text" /> From 9aecf92d02e69d2566528c7b2ee91db4d6221319 Mon Sep 17 00:00:00 2001 From: Marko Savic Date: Tue, 11 Feb 2020 17:03:21 +0100 Subject: [PATCH 377/761] Update gb-mobile reference --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 23ebe8599d8b..1942f88acf1b 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 23ebe8599d8b7dfc5290e7e51bf7b1b2c9f748ec +Subproject commit 1942f88acf1bf0876dc12dfc771ac321d4cec11f From 852fd13a8990563ba3bc10c15d55bac855c7054e Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 11 Feb 2020 16:06:57 -0800 Subject: [PATCH 378/761] Reverted cast. --- .../android/ui/accounts/login/LoginEpilogueFragment.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 40dd24b221d6..3f952b29494d 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 @@ -15,8 +15,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.card.MaterialCardView; - import org.wordpress.android.R; import org.wordpress.android.WordPress; import org.wordpress.android.analytics.AnalyticsTracker; @@ -42,7 +40,7 @@ public class LoginEpilogueFragment extends LoginBaseFormFragment Date: Tue, 11 Feb 2020 20:09:09 -0800 Subject: [PATCH 379/761] Fixed indentation. --- .../notifications/NotificationsSettingsFragment.java | 11 ++++------- .../notifications/PrefMasterSwitchToolbarView.kt | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) 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 54aa0ac1cf0e..2b9877f8e558 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 @@ -137,10 +137,8 @@ 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); } } @@ -729,9 +727,8 @@ private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen 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)); + preference.getIcon().setTintList(ContextExtensionsKt + .getColorStateListFromAttribute(preference.getContext(), R.attr.wpColorOnSurfaceMedium)); } private void addSitesForViewAllSitesScreen(PreferenceScreen preferenceScreen, boolean isFollowed) { 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 2eb4875c6c06..44deb5fde5ea 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 @@ -232,8 +232,8 @@ class PrefMasterSwitchToolbarView @JvmOverloads constructor( throw IllegalStateException("Unknown view style id: $viewStyleInt") } else { AppLog.e( - AppLog.T.SETTINGS, "PrefMasterSwitchToolbarView.setViewStyle called from xml " + - "with an unknown viewStyle." + AppLog.T.SETTINGS, + "PrefMasterSwitchToolbarView.setViewStyle called from xml with an unknown viewStyle." ) } } From adbbae65745ff75e861b2fcc2b5fd98032c1d352 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 11 Feb 2020 20:09:37 -0800 Subject: [PATCH 380/761] WPTextView to extend material version. --- .../main/java/org/wordpress/android/widgets/WPTextView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/widgets/WPTextView.java b/WordPress/src/main/java/org/wordpress/android/widgets/WPTextView.java index 304576d13a59..63e05a8043b2 100644 --- a/WordPress/src/main/java/org/wordpress/android/widgets/WPTextView.java +++ b/WordPress/src/main/java/org/wordpress/android/widgets/WPTextView.java @@ -8,14 +8,14 @@ import android.text.TextUtils; import android.util.AttributeSet; -import androidx.appcompat.widget.AppCompatTextView; +import com.google.android.material.textview.MaterialTextView; import org.wordpress.android.R; /** * Custom TextView - with an option to auto fix widow words. */ -public class WPTextView extends AppCompatTextView { +public class WPTextView extends MaterialTextView { protected boolean mFixWidowWordEnabled; public WPTextView(Context context) { From 071a498e1a6016d1fadf9adf60c5da5322e2d482 Mon Sep 17 00:00:00 2001 From: Klymentiy haykov Date: Tue, 11 Feb 2020 20:23:00 -0800 Subject: [PATCH 381/761] Fixed jetpack buttons. --- .../main/res/layout/notifications_list_fragment.xml | 8 ++++---- WordPress/src/main/res/values/stats_styles.xml | 11 ++--------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/WordPress/src/main/res/layout/notifications_list_fragment.xml b/WordPress/src/main/res/layout/notifications_list_fragment.xml index 419cfb0a066b..b0d4eb1e9b39 100644 --- a/WordPress/src/main/res/layout/notifications_list_fragment.xml +++ b/WordPress/src/main/res/layout/notifications_list_fragment.xml @@ -72,13 +72,13 @@ android:textAlignment="center" app:fixWidowWords="true" /> - + android:text="@string/stats_jetpack_connection_setup" /> -