Skip to content

Commit 16df8f0

Browse files
committed
Merge branch 'develop' of https://github.com/wordpress-mobile/WordPress-Android into gb/move-editor-preference-toggle-to-site-settings
* 'develop' of https://github.com/wordpress-mobile/WordPress-Android: (22 commits) Gutenberg mobile release v1.10.0 (#10286) Fix a problem reported in code review where the mHasUnsupportedBlocks variable was not properly initializated before accessing it Add unit test for content description helpet Remove string resource that was not translatable Replace inline function with boolean param Remove focusable=false Remove importantForAccessibility flag Remove needless blank line Show publish action on post pending review when user has publish rights Add tests for displayed buttons on post list items Disable graph for accessibility Disable graph legend for accessibility Improvements to the value and column items Rename build_test_releases lane Update fastlane Improvements for the Quick Scan items Improvements to the overview card Always add the property unsupported_blocks to session_start event Remove redundant local variable Track unsupported block lists at session_start only ...
2 parents 6e4623b + af14bcc commit 16df8f0

34 files changed

+782
-174
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
source "https://rubygems.org" do
4-
gem 'fastlane', "2.126"
4+
gem 'fastlane', "2.127.2"
55
gem 'nokogiri'
66
end
77

Gemfile.lock

+6-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ GEM
3535
unf (>= 0.0.5, < 1.0.0)
3636
dotenv (2.7.4)
3737
emoji_regex (1.0.1)
38-
excon (0.64.0)
38+
excon (0.65.0)
3939
faraday (0.15.4)
4040
multipart-post (>= 1.2, < 3)
4141
faraday-cookie_jar (0.0.6)
@@ -44,7 +44,7 @@ GEM
4444
faraday_middleware (0.13.1)
4545
faraday (>= 0.7.4, < 1.0)
4646
fastimage (2.1.5)
47-
fastlane (2.126.0)
47+
fastlane (2.127.2)
4848
CFPropertyList (>= 2.3, < 4.0.0)
4949
addressable (>= 2.3, < 3.0.0)
5050
babosa (>= 1.0.2, < 2.0.0)
@@ -64,7 +64,7 @@ GEM
6464
highline (>= 1.7.2, < 2.0.0)
6565
json (< 3.0.0)
6666
jwt (~> 2.1.0)
67-
mini_magick (~> 4.5.1)
67+
mini_magick (>= 4.9.4, < 5.0.0)
6868
multi_xml (~> 0.5)
6969
multipart-post (~> 2.0.0)
7070
plist (>= 3.1.0, < 4.0.0)
@@ -120,7 +120,7 @@ GEM
120120
mime-types (3.2.2)
121121
mime-types-data (~> 3.2015)
122122
mime-types-data (3.2019.0331)
123-
mini_magick (4.5.1)
123+
mini_magick (4.9.5)
124124
mini_portile2 (2.4.0)
125125
multi_json (1.13.1)
126126
multi_xml (0.6.0)
@@ -149,6 +149,7 @@ GEM
149149
declarative-option (< 0.2.0)
150150
uber (< 0.2.0)
151151
retriable (3.1.2)
152+
rmagick (3.2.0)
152153
rouge (2.0.7)
153154
rubyzip (1.2.3)
154155
sawyer (0.8.2)
@@ -192,7 +193,7 @@ PLATFORMS
192193
ruby
193194

194195
DEPENDENCIES
195-
fastlane (= 2.126)!
196+
fastlane (= 2.127.2)!
196197
fastlane-plugin-wpmreleasetoolkit!
197198
nokogiri!
198199
rmagick (~> 3.2.0)

RELEASE-NOTES.txt

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
-----
33
* Block editor: Default to the block editor unless user opted out in v12.9.
44
* Block editor: You can now enable and disable the block editor on a per-site basis.
5+
* Block editor: Adding a block from the post title now shows the add block here indicator.
6+
* Block editor: Deselect post title any time a block is added
7+
* Block editor: Fix loss of center alignment in image captions
58

69
12.9
710
-----

WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -3812,13 +3812,13 @@ public void onJavaScriptAlert(String url, String message) {
38123812
((GutenbergEditorFragment) mEditorFragment).resetUploadingMediaToFailed(mediaIds);
38133813
}
38143814
} else if (mShowAztecEditor && mEditorFragment instanceof AztecEditorFragment) {
3815-
mPostEditorAnalyticsSession.start(false);
3815+
mPostEditorAnalyticsSession.start(null);
38163816
}
38173817
}
38183818

38193819
@Override
3820-
public void onEditorFragmentContentReady(boolean hasUnsupportedContent) {
3821-
mPostEditorAnalyticsSession.start(hasUnsupportedContent);
3820+
public void onEditorFragmentContentReady(ArrayList<Object> unsupportedBlocksList) {
3821+
mPostEditorAnalyticsSession.start(unsupportedBlocksList);
38223822
}
38233823

38243824
@Override

WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.wordpress.android.util.SiteUtils;
1010

1111
import java.io.Serializable;
12+
import java.util.ArrayList;
1213
import java.util.HashMap;
1314
import java.util.Locale;
1415
import java.util.Map;
@@ -19,6 +20,7 @@ public class PostEditorAnalyticsSession implements Serializable {
1920
private static final String KEY_CONTENT_TYPE = "content_type";
2021
private static final String KEY_EDITOR = "editor";
2122
private static final String KEY_HAS_UNSUPPORTED_BLOCKS = "has_unsupported_blocks";
23+
private static final String KEY_UNSUPPORTED_BLOCKS = "unsupported_blocks";
2224
private static final String KEY_POST_TYPE = "post_type";
2325
private static final String KEY_OUTCOME = "outcome";
2426
private static final String KEY_SESSION_ID = "session_id";
@@ -77,10 +79,12 @@ enum Outcome {
7779
}
7880
}
7981

80-
public void start(boolean hasUnsupportedBlocks) {
82+
public void start(ArrayList<Object> unsupportedBlocksList) {
8183
if (!mStarted) {
82-
mHasUnsupportedBlocks = hasUnsupportedBlocks;
84+
mHasUnsupportedBlocks = unsupportedBlocksList != null && unsupportedBlocksList.size() > 0;
8385
Map<String, Object> properties = getCommonProperties();
86+
properties.put(KEY_UNSUPPORTED_BLOCKS,
87+
unsupportedBlocksList != null ? unsupportedBlocksList : new ArrayList<>());
8488
AnalyticsTracker.track(Stat.EDITOR_SESSION_START, properties);
8589
mStarted = true;
8690
} else {

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/BlockDiffCallback.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ class BlockDiffCallback(
101101
TAB_CHANGED
102102
newItem is Columns && oldItem is Columns && oldItem.selectedColumn != newItem.selectedColumn ->
103103
return SELECTED_COLUMN_CHANGED
104-
newItem is Columns && oldItem is Columns && oldItem.values != newItem.values -> return COLUMNS_VALUE_CHANGED
104+
newItem is Columns && oldItem is Columns && oldItem.columns != newItem.columns ->
105+
return COLUMNS_VALUE_CHANGED
105106
newItem is BarChartItem && oldItem is BarChartItem && oldItem.selectedItem != newItem.selectedItem ->
106107
return SELECTED_BAR_CHANGED
107108
else -> null

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostDayViewsMapper.kt

+39-14
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,8 @@ class PostDayViewsMapper
2727
val value = selectedItem.count
2828
val previousValue = previousItem?.count
2929
val positive = value >= (previousValue ?: 0)
30-
val change = previousValue?.let {
31-
val difference = value - previousValue
32-
val percentage = when (previousValue) {
33-
value -> "0"
34-
0 -> ""
35-
else -> (difference * 100 / previousValue).toFormattedString()
36-
}
37-
if (positive) {
38-
resourceProvider.getString(R.string.stats_traffic_increase, difference.toFormattedString(), percentage)
39-
} else {
40-
resourceProvider.getString(R.string.stats_traffic_change, difference.toFormattedString(), percentage)
41-
}
42-
}
30+
val change = buildChange(previousValue, value, positive, isFormattedNumber = true)
31+
val unformattedChange = buildChange(previousValue, value, positive, isFormattedNumber = false)
4332

4433
val state = when {
4534
isLast -> State.NEUTRAL
@@ -51,10 +40,46 @@ class PostDayViewsMapper
5140
unit = R.string.stats_views,
5241
isFirst = true,
5342
change = change,
54-
state = state
43+
state = state,
44+
contentDescription = resourceProvider.getString(
45+
R.string.stats_overview_content_description,
46+
value,
47+
resourceProvider.getString(R.string.stats_views),
48+
statsDateFormatter.printDate(selectedItem.period),
49+
unformattedChange ?: ""
50+
)
5551
)
5652
}
5753

54+
private fun buildChange(
55+
previousValue: Int?,
56+
value: Int,
57+
positive: Boolean,
58+
isFormattedNumber: Boolean
59+
): String? {
60+
return previousValue?.let {
61+
val difference = value - previousValue
62+
val percentage = when (previousValue) {
63+
value -> "0"
64+
0 -> ""
65+
else -> mapIntToString((difference * 100 / previousValue), isFormattedNumber)
66+
}
67+
val formattedDifference = mapIntToString(difference, isFormattedNumber)
68+
if (positive) {
69+
resourceProvider.getString(R.string.stats_traffic_increase, formattedDifference, percentage)
70+
} else {
71+
resourceProvider.getString(R.string.stats_traffic_change, formattedDifference, percentage)
72+
}
73+
}
74+
}
75+
76+
private fun mapIntToString(value: Int, isFormattedNumber: Boolean): String {
77+
return when (isFormattedNumber) {
78+
true -> value.toFormattedString()
79+
false -> value.toString()
80+
}
81+
}
82+
5883
fun buildChart(
5984
dayViews: List<Day>,
6085
selectedDay: String?,

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/detail/PostDayViewsUseCase.kt

+11-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.wordpress.android.ui.stats.refresh.utils.StatsDateFormatter
1717
import org.wordpress.android.ui.stats.refresh.utils.StatsPostProvider
1818
import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
1919
import org.wordpress.android.ui.stats.refresh.utils.toFormattedString
20+
import org.wordpress.android.viewmodel.ResourceProvider
2021
import javax.inject.Inject
2122
import javax.inject.Named
2223

@@ -28,7 +29,8 @@ class PostDayViewsUseCase
2829
private val selectedDateProvider: SelectedDateProvider,
2930
private val statsSiteProvider: StatsSiteProvider,
3031
private val statsPostProvider: StatsPostProvider,
31-
private val postDetailStore: PostDetailStore
32+
private val postDetailStore: PostDetailStore,
33+
private val resourceProvider: ResourceProvider
3234
) : BaseStatsUseCase<PostDetailStatsModel, UiState>(
3335
PostDetailType.POST_OVERVIEW,
3436
mainDispatcher,
@@ -106,7 +108,14 @@ class PostDayViewsUseCase
106108
}
107109

108110
override fun buildLoadingItem(): List<BlockListItem> {
109-
return listOf(ValueItem(value = 0.toFormattedString(), unit = R.string.stats_views, isFirst = true))
111+
return listOf(
112+
ValueItem(
113+
value = 0.toFormattedString(),
114+
unit = R.string.stats_views,
115+
isFirst = true,
116+
contentDescription = resourceProvider.getString(R.string.stats_loading_card)
117+
)
118+
)
110119
}
111120

112121
private fun onBarSelected(period: String?) {

WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/BlockListItem.kt

+6-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ sealed class BlockListItem(val type: Type) {
9797
@StringRes val unit: Int,
9898
val isFirst: Boolean = false,
9999
val change: String? = null,
100-
val state: State = POSITIVE
100+
val state: State = POSITIVE,
101+
val contentDescription: String
101102
) : BlockListItem(VALUE_ITEM) {
102103
enum class State { POSITIVE, NEGATIVE, NEUTRAL }
103104
}
@@ -157,13 +158,14 @@ sealed class BlockListItem(val type: Type) {
157158
}
158159

159160
data class Columns(
160-
val headers: List<Int>,
161-
val values: List<String>,
161+
val columns: List<Column>,
162162
val selectedColumn: Int? = null,
163163
val onColumnSelected: ((position: Int) -> Unit)? = null
164164
) : BlockListItem(COLUMNS) {
165165
override val itemId: Int
166-
get() = headers.hashCode()
166+
get() = columns.hashCode()
167+
168+
data class Column(val header: Int, val value: String, val contentDescription: String)
167169
}
168170

169171
data class Link(

0 commit comments

Comments
 (0)