Skip to content

Commit 68c6f4c

Browse files
committed
Squashed 'libs/editor/' changes from 69aaa8a..4832795
4832795 Merge pull request #280 from wordpress-mobile/issue/remove-analytics-dependency dd68ccd Merge pull request #283 from wordpress-mobile/issue/282-localize-js-strings bec42a8 moved the brackets back into the JS code 2cd15b7 fix #282: localize JS strings by using js-java interface nativeState a64d3a7 Merge pull request #270 from wordpress-mobile/issue/242-image-container-lower-api 5339a22 Fixed some EditorFragment lint issues ab084be Used a String constant for naming the native state JS interface 0789069 Merge branch 'develop' into issue/242-image-container-lower-api 430d3a4 Merge pull request #278 from wordpress-mobile/issue/183-accessibility e4b9e76 s/Strike/Strikethrough/ ec9c6e9 Image thumbnail content description cda2f22 Make editor title i18nizable 9d92717 Merge branch 'develop' into issue/242-image-container-lower-api 67dec0b Change page title for accessibility 3167e9a add contentDescription to format bar buttons in the visual and legacy editors 29cea46 Fixed issue where compatibility upload overlays would sometimes consume a tap without triggering a tap callback for the associated image 7b26aa7 Fixed a display issue on API<19 where a dark blank space would appear below an uploading or failed image b95d94a Added a dark semi-transparent overlay for API<19 for uploading and failed images 9e1863f Revert to non-compatibility image container styling once image has begun uploading 34523c0 Hide the compatibility image upload overlay if an image upload fails and re-display it on resume abf7260 Use block instead of inline-block for the image container on pre=KitKat Android 86a985c On pre-KitKat Android, show an 'Uploading...' overlay instead of a progress bar for uploading images 047082a Updated ZSSEditor to get the current Android API level on init git-subtree-dir: libs/editor git-subtree-split: 48327953c76c593daefe93a16e41323631de5b73
1 parent 097b51b commit 68c6f4c

File tree

12 files changed

+211
-20
lines changed

12 files changed

+211
-20
lines changed

WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragment.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.view.View;
2525
import android.view.ViewGroup;
2626
import android.view.inputmethod.InputMethodManager;
27+
import android.webkit.JavascriptInterface;
2728
import android.webkit.URLUtil;
2829
import android.webkit.WebView;
2930
import android.widget.ToggleButton;
@@ -59,6 +60,7 @@ public class EditorFragment extends EditorFragmentAbstract implements View.OnCli
5960
private static final String ARG_PARAM_CONTENT = "param_content";
6061

6162
private static final String JS_CALLBACK_HANDLER = "nativeCallbackHandler";
63+
private static final String JS_STATE_INTERFACE = "nativeState";
6264

6365
private static final String KEY_TITLE = "title";
6466
private static final String KEY_CONTENT = "content";
@@ -366,13 +368,18 @@ private void setupFormatBarButtonMap(View view) {
366368
}
367369

368370
protected void initJsEditor() {
369-
if(!isAdded()) {
371+
if (!isAdded()) {
370372
return;
371373
}
372374

373375
String htmlEditor = Utils.getHtmlFromFile(getActivity(), "android-editor.html");
376+
if (htmlEditor != null) {
377+
htmlEditor = htmlEditor.replace("%%TITLE%%", getString(R.string.visual_editor));
378+
}
374379

375380
mWebView.addJavascriptInterface(new JsCallbackReceiver(this), JS_CALLBACK_HANDLER);
381+
mWebView.addJavascriptInterface(new NativeStateJsInterface(getActivity().getApplicationContext()),
382+
JS_STATE_INTERFACE);
376383

377384
mWebView.loadDataWithBaseURL("file:///android_asset/", htmlEditor, "text/html", "utf-8", "");
378385

@@ -1123,7 +1130,7 @@ private void updateVisualEditorFields() {
11231130
private void hideActionBarIfNeeded() {
11241131

11251132
ActionBar actionBar = getActionBar();
1126-
if (getActionBar() != null
1133+
if (actionBar != null
11271134
&& !isHardwareKeyboardPresent()
11281135
&& mHideActionBarOnSoftKeyboardUp
11291136
&& mIsKeyboardOpen
@@ -1138,8 +1145,8 @@ private void hideActionBarIfNeeded() {
11381145
private void showActionBarIfNeeded() {
11391146

11401147
ActionBar actionBar = getActionBar();
1141-
if (getActionBar() != null && !actionBar.isShowing()) {
1142-
getActionBar().show();
1148+
if (actionBar != null && !actionBar.isShowing()) {
1149+
actionBar.show();
11431150
}
11441151
}
11451152

@@ -1261,4 +1268,37 @@ private void applyFormattingHtmlMode(ToggleButton toggleButton, String tag) {
12611268
mSourceViewContent.setSelection(selectionEnd + endTag.length());
12621269
}
12631270
}
1271+
1272+
private class NativeStateJsInterface {
1273+
Context mContext;
1274+
1275+
NativeStateJsInterface(Context context) {
1276+
mContext = context;
1277+
}
1278+
1279+
@JavascriptInterface
1280+
public String getStringEdit() {
1281+
return mContext.getString(R.string.edit);
1282+
}
1283+
1284+
@JavascriptInterface
1285+
public String getStringTapToRetry() {
1286+
return mContext.getString(R.string.tap_to_try_again);
1287+
}
1288+
1289+
@JavascriptInterface
1290+
public String getStringUploading() {
1291+
return mContext.getString(R.string.uploading);
1292+
}
1293+
1294+
@JavascriptInterface
1295+
public String getStringUploadingGallery() {
1296+
return mContext.getString(R.string.uploading_gallery_placeholder);
1297+
}
1298+
1299+
@JavascriptInterface
1300+
public int getAPILevel() {
1301+
return Build.VERSION.SDK_INT;
1302+
}
1303+
}
12641304
}

WordPressEditor/src/main/java/org/wordpress/android/editor/RippleToggleButton.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ public class RippleToggleButton extends ToggleButton {
2121
private Paint mStrokePaint;
2222

2323
public RippleToggleButton(Context context) {
24-
super(context);
25-
}
24+
this(context, null);
25+
}
2626

2727
public RippleToggleButton(Context context, AttributeSet attrs) {
28-
super(context, attrs);
29-
init();
28+
this(context, attrs, 0);
3029
}
3130

3231
public RippleToggleButton(Context context, AttributeSet attrs, int defStyle) {

WordPressEditor/src/main/res/layout-w360dp/format_bar.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
3737
style="@style/FormatBarButton"
3838
android:layout_width="wrap_content"
3939
android:layout_height="fill_parent"
40+
android:contentDescription="@string/format_bar_description_media"
4041
android:background="@drawable/format_bar_button_media_selector"/>
4142

4243
<org.wordpress.android.editor.RippleToggleButton
4344
android:id="@+id/format_bar_button_bold"
4445
style="@style/FormatBarButton"
4546
android:layout_width="wrap_content"
4647
android:layout_height="fill_parent"
48+
android:contentDescription="@string/format_bar_description_bold"
4749
android:background="@drawable/format_bar_button_bold_selector"
4850
android:tag="@string/format_bar_tag_bold"/>
4951

@@ -52,6 +54,7 @@
5254
style="@style/FormatBarButton"
5355
android:layout_width="wrap_content"
5456
android:layout_height="fill_parent"
57+
android:contentDescription="@string/format_bar_description_italic"
5558
android:background="@drawable/format_bar_button_italic_selector"
5659
android:tag="@string/format_bar_tag_italic"/>
5760

@@ -60,6 +63,7 @@
6063
style="@style/FormatBarButton"
6164
android:layout_width="wrap_content"
6265
android:layout_height="fill_parent"
66+
android:contentDescription="@string/format_bar_description_quote"
6367
android:background="@drawable/format_bar_button_quote_selector"
6468
android:tag="@string/format_bar_tag_blockquote"/>
6569

@@ -68,6 +72,7 @@
6872
style="@style/FormatBarButton"
6973
android:layout_width="wrap_content"
7074
android:layout_height="fill_parent"
75+
android:contentDescription="@string/format_bar_description_ul"
7176
android:background="@drawable/format_bar_button_ul_selector"
7277
android:tag="@string/format_bar_tag_unorderedList"/>
7378

@@ -76,6 +81,7 @@
7681
style="@style/FormatBarButton"
7782
android:layout_width="wrap_content"
7883
android:layout_height="fill_parent"
84+
android:contentDescription="@string/format_bar_description_ol"
7985
android:background="@drawable/format_bar_button_ol_selector"
8086
android:tag="@string/format_bar_tag_orderedList"/>
8187

@@ -84,6 +90,7 @@
8490
style="@style/FormatBarButton"
8591
android:layout_width="wrap_content"
8692
android:layout_height="fill_parent"
93+
android:contentDescription="@string/format_bar_description_link"
8794
android:background="@drawable/format_bar_button_link_selector"
8895
android:tag="@string/format_bar_tag_link"/>
8996
</LinearLayout>
@@ -100,6 +107,7 @@
100107
style="@style/FormatBarHtmlButton"
101108
android:layout_width="wrap_content"
102109
android:layout_height="fill_parent"
110+
android:contentDescription="@string/format_bar_description_html"
103111
android:background="@drawable/format_bar_button_html_selector"/>
104112
</LinearLayout>
105-
</LinearLayout>
113+
</LinearLayout>

WordPressEditor/src/main/res/layout-w380dp/format_bar.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
android:layout_width="wrap_content"
3232
android:layout_height="fill_parent"
3333
android:layout_weight="1"
34+
android:contentDescription="@string/format_bar_description_media"
3435
android:background="@drawable/format_bar_button_media_selector"/>
3536

3637
<org.wordpress.android.editor.RippleToggleButton
@@ -39,6 +40,7 @@
3940
android:layout_width="wrap_content"
4041
android:layout_height="fill_parent"
4142
android:layout_weight="1"
43+
android:contentDescription="@string/format_bar_description_bold"
4244
android:background="@drawable/format_bar_button_bold_selector"
4345
android:tag="@string/format_bar_tag_bold"/>
4446

@@ -48,6 +50,7 @@
4850
android:layout_width="wrap_content"
4951
android:layout_height="fill_parent"
5052
android:layout_weight="1"
53+
android:contentDescription="@string/format_bar_description_italic"
5154
android:background="@drawable/format_bar_button_italic_selector"
5255
android:tag="@string/format_bar_tag_italic"/>
5356

@@ -57,6 +60,7 @@
5760
android:layout_width="wrap_content"
5861
android:layout_height="fill_parent"
5962
android:layout_weight="1"
63+
android:contentDescription="@string/format_bar_description_quote"
6064
android:background="@drawable/format_bar_button_quote_selector"
6165
android:tag="@string/format_bar_tag_blockquote"/>
6266

@@ -66,6 +70,7 @@
6670
android:layout_width="wrap_content"
6771
android:layout_height="fill_parent"
6872
android:layout_weight="1"
73+
android:contentDescription="@string/format_bar_description_ul"
6974
android:background="@drawable/format_bar_button_ul_selector"
7075
android:tag="@string/format_bar_tag_unorderedList"/>
7176

@@ -75,6 +80,7 @@
7580
android:layout_width="wrap_content"
7681
android:layout_height="fill_parent"
7782
android:layout_weight="1"
83+
android:contentDescription="@string/format_bar_description_ol"
7884
android:background="@drawable/format_bar_button_ol_selector"
7985
android:tag="@string/format_bar_tag_orderedList"/>
8086

@@ -84,6 +90,7 @@
8490
android:layout_width="wrap_content"
8591
android:layout_height="fill_parent"
8692
android:layout_weight="1"
93+
android:contentDescription="@string/format_bar_description_link"
8794
android:background="@drawable/format_bar_button_link_selector"
8895
android:tag="@string/format_bar_tag_link"/>
8996

@@ -99,6 +106,7 @@
99106
style="@style/FormatBarHtmlButton"
100107
android:layout_width="wrap_content"
101108
android:layout_height="fill_parent"
109+
android:contentDescription="@string/format_bar_description_html"
102110
android:background="@drawable/format_bar_button_html_selector"/>
103111
</LinearLayout>
104-
</LinearLayout>
112+
</LinearLayout>

WordPressEditor/src/main/res/layout-w600dp/format_bar.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
style="@style/FormatBarButtonTablet"
3535
android:layout_width="wrap_content"
3636
android:layout_height="fill_parent"
37+
android:contentDescription="@string/format_bar_description_media"
3738
android:background="@drawable/format_bar_button_media_selector"/>
3839
</LinearLayout>
3940

@@ -47,6 +48,7 @@
4748
style="@style/FormatBarButtonTablet"
4849
android:layout_width="wrap_content"
4950
android:layout_height="fill_parent"
51+
android:contentDescription="@string/format_bar_description_bold"
5052
android:background="@drawable/format_bar_button_bold_selector"
5153
android:tag="@string/format_bar_tag_bold"/>
5254

@@ -55,6 +57,7 @@
5557
style="@style/FormatBarButtonTablet"
5658
android:layout_width="wrap_content"
5759
android:layout_height="fill_parent"
60+
android:contentDescription="@string/format_bar_description_italic"
5861
android:background="@drawable/format_bar_button_italic_selector"
5962
android:tag="@string/format_bar_tag_italic"/>
6063

@@ -77,6 +80,7 @@
7780
style="@style/FormatBarButtonTablet"
7881
android:layout_width="wrap_content"
7982
android:layout_height="fill_parent"
83+
android:contentDescription="@string/format_bar_description_link"
8084
android:background="@drawable/format_bar_button_link_selector"
8185
android:tag="@string/format_bar_tag_link"/>
8286
</LinearLayout>
@@ -91,6 +95,7 @@
9195
style="@style/FormatBarButtonTablet"
9296
android:layout_width="wrap_content"
9397
android:layout_height="fill_parent"
98+
android:contentDescription="@string/format_bar_description_ul"
9499
android:background="@drawable/format_bar_button_ul_selector"
95100
android:tag="@string/format_bar_tag_unorderedList"/>
96101

@@ -99,6 +104,7 @@
99104
style="@style/FormatBarButtonTablet"
100105
android:layout_width="wrap_content"
101106
android:layout_height="fill_parent"
107+
android:contentDescription="@string/format_bar_description_ol"
102108
android:background="@drawable/format_bar_button_ol_selector"
103109
android:tag="@string/format_bar_tag_orderedList"/>
104110

@@ -107,6 +113,7 @@
107113
style="@style/FormatBarButtonTablet"
108114
android:layout_width="wrap_content"
109115
android:layout_height="fill_parent"
116+
android:contentDescription="@string/format_bar_description_quote"
110117
android:background="@drawable/format_bar_button_quote_selector"
111118
android:tag="@string/format_bar_tag_blockquote"/>
112119
</LinearLayout>
@@ -121,6 +128,7 @@
121128
style="@style/FormatBarButtonTablet"
122129
android:layout_width="wrap_content"
123130
android:layout_height="fill_parent"
131+
android:contentDescription="@string/format_bar_description_html"
124132
android:background="@drawable/format_bar_button_html_selector"/>
125133
</LinearLayout>
126134
</LinearLayout>

WordPressEditor/src/main/res/layout/dialog_image_options.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
<ImageView
2323
android:id="@+id/image_thumbnail"
24+
android:contentDescription="@string/image_thumbnail"
2425
android:layout_width="@dimen/image_settings_dialog_thumbnail_size"
2526
android:layout_height="@dimen/image_settings_dialog_thumbnail_size"
2627
android:layout_marginLeft="@dimen/image_settings_dialog_thumbnail_left_margin"
@@ -150,4 +151,4 @@
150151
android:layout_marginLeft="@dimen/image_settings_dialog_input_field_start_margin"
151152
android:visibility="gone"/>
152153
</LinearLayout>
153-
</ScrollView>
154+
</ScrollView>

WordPressEditor/src/main/res/layout/format_bar.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@
4242
style="@style/FormatBarButton"
4343
android:layout_width="wrap_content"
4444
android:layout_height="fill_parent"
45+
android:contentDescription="@string/format_bar_description_media"
4546
android:background="@drawable/format_bar_button_media_selector"/>
4647

4748
<org.wordpress.android.editor.RippleToggleButton
4849
android:id="@+id/format_bar_button_bold"
4950
style="@style/FormatBarButton"
5051
android:layout_width="wrap_content"
5152
android:layout_height="fill_parent"
53+
android:contentDescription="@string/format_bar_description_bold"
5254
android:background="@drawable/format_bar_button_bold_selector"
5355
android:tag="@string/format_bar_tag_bold"/>
5456

@@ -57,6 +59,7 @@
5759
style="@style/FormatBarButton"
5860
android:layout_width="wrap_content"
5961
android:layout_height="fill_parent"
62+
android:contentDescription="@string/format_bar_description_italic"
6063
android:background="@drawable/format_bar_button_italic_selector"
6164
android:tag="@string/format_bar_tag_italic"/>
6265

@@ -65,6 +68,7 @@
6568
style="@style/FormatBarButton"
6669
android:layout_width="wrap_content"
6770
android:layout_height="fill_parent"
71+
android:contentDescription="@string/format_bar_description_quote"
6872
android:background="@drawable/format_bar_button_quote_selector"
6973
android:tag="@string/format_bar_tag_blockquote"/>
7074

@@ -73,6 +77,7 @@
7377
style="@style/FormatBarButton"
7478
android:layout_width="wrap_content"
7579
android:layout_height="fill_parent"
80+
android:contentDescription="@string/format_bar_description_ul"
7681
android:background="@drawable/format_bar_button_ul_selector"
7782
android:tag="@string/format_bar_tag_unorderedList"/>
7883

@@ -81,6 +86,7 @@
8186
style="@style/FormatBarButton"
8287
android:layout_width="wrap_content"
8388
android:layout_height="fill_parent"
89+
android:contentDescription="@string/format_bar_description_ol"
8490
android:background="@drawable/format_bar_button_ol_selector"
8591
android:tag="@string/format_bar_tag_orderedList"/>
8692

@@ -89,6 +95,7 @@
8995
style="@style/FormatBarButton"
9096
android:layout_width="wrap_content"
9197
android:layout_height="fill_parent"
98+
android:contentDescription="@string/format_bar_description_link"
9299
android:background="@drawable/format_bar_button_link_selector"
93100
android:tag="@string/format_bar_tag_link"/>
94101
</LinearLayout>
@@ -106,6 +113,7 @@
106113
style="@style/FormatBarHtmlButton"
107114
android:layout_width="wrap_content"
108115
android:layout_height="fill_parent"
116+
android:contentDescription="@string/format_bar_description_html"
109117
android:background="@drawable/format_bar_button_html_selector"/>
110118
</LinearLayout>
111-
</LinearLayout>
119+
</LinearLayout>

0 commit comments

Comments
 (0)